@camstack/addon-provider-amcrest 0.2.132 → 0.2.133
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
|
@@ -34,7 +34,7 @@ let node_stream = require("node:stream");
|
|
|
34
34
|
let node_stream_promises = require("node:stream/promises");
|
|
35
35
|
let node_child_process = require("node:child_process");
|
|
36
36
|
let node_os = require("node:os");
|
|
37
|
-
//#region ../types/dist/event-category-
|
|
37
|
+
//#region ../types/dist/event-category-DaIZi00R.mjs
|
|
38
38
|
var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
39
39
|
EventCategory["SystemBoot"] = "system.boot";
|
|
40
40
|
EventCategory["SystemAddonsReady"] = "system.addons-ready";
|
|
@@ -113,6 +113,13 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
|
113
113
|
*/
|
|
114
114
|
EventCategory["AddonLoadFailed"] = "addon.load-failed";
|
|
115
115
|
/**
|
|
116
|
+
* A keychain value was stored or removed (D787). Carries the ref, its
|
|
117
|
+
* owner and the new version — NEVER the value. A process holding the ref
|
|
118
|
+
* drops its cached copy and the owning `BaseAddon` re-resolves its config.
|
|
119
|
+
* Telemetry (D8): a process that misses it still revalidates by version.
|
|
120
|
+
*/
|
|
121
|
+
EventCategory["KeychainChanged"] = "keychain.changed";
|
|
122
|
+
/**
|
|
116
123
|
* Addon recovered from a previous failure. Emitted when an addon
|
|
117
124
|
* transitions from `failed` back to `healthy` (typically via the
|
|
118
125
|
* monitor's auto-retry loop, or after manual `addons.retryLoad`).
|
|
@@ -5405,7 +5412,7 @@ var ZodIssueCode = {
|
|
|
5405
5412
|
var ZodFirstPartyTypeKind;
|
|
5406
5413
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5407
5414
|
//#endregion
|
|
5408
|
-
//#region ../types/dist/sleep-
|
|
5415
|
+
//#region ../types/dist/sleep-Cr5YOk3m.mjs
|
|
5409
5416
|
/**
|
|
5410
5417
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5411
5418
|
* window to float samples (D455).
|
|
@@ -5484,6 +5491,97 @@ function buildAlawTable() {
|
|
|
5484
5491
|
}
|
|
5485
5492
|
buildUlawTable();
|
|
5486
5493
|
buildAlawTable();
|
|
5494
|
+
/** Is this field's stored value a credential? */
|
|
5495
|
+
function isSecretConfigField(field) {
|
|
5496
|
+
if (field.type === "password") return true;
|
|
5497
|
+
return "secret" in field && field.secret === true;
|
|
5498
|
+
}
|
|
5499
|
+
/**
|
|
5500
|
+
* Is this field's value stored in the KEYCHAIN (D787)? Every secret field is,
|
|
5501
|
+
* by its TYPE, unless it opts out with `storage: 'inline'` — never by its name.
|
|
5502
|
+
*/
|
|
5503
|
+
function isKeychainStoredField(field) {
|
|
5504
|
+
if (!isSecretConfigField(field)) return false;
|
|
5505
|
+
if (field.type === "textarea" && field.isJson === true) return false;
|
|
5506
|
+
return !("storage" in field && field.storage === "inline");
|
|
5507
|
+
}
|
|
5508
|
+
/**
|
|
5509
|
+
* What a settings blob holds where a secret used to be.
|
|
5510
|
+
*
|
|
5511
|
+
* A keychain-stored field never holds its value. It holds a self-describing
|
|
5512
|
+
* MARKER, `{"$secret":"secret://…","v":1}` — an object, never a string, so no
|
|
5513
|
+
* code can mistake it for a credential and no form can send it to a camera as
|
|
5514
|
+
* a password. The empty state is `null` / absent, never `''`.
|
|
5515
|
+
*
|
|
5516
|
+
* The same shapes travel to and from the admin UI:
|
|
5517
|
+
*
|
|
5518
|
+
* - read: `hydrateSchema` hands a secret field a {@link SecretFieldView}
|
|
5519
|
+
* (`{ $secret, v, set: true }`) or `null` — the browser learns whether a
|
|
5520
|
+
* value is set, never the value.
|
|
5521
|
+
* - write: an untouched field submits the view back unchanged (KEEP); a typed
|
|
5522
|
+
* value is a plain non-empty string (CHANGE); the Clear button submits
|
|
5523
|
+
* {@link SECRET_CLEAR} (CLEAR). `''`, `null` and the legacy redaction tokens
|
|
5524
|
+
* are KEEP — an empty string is what a defaults-fallback pushes back, and
|
|
5525
|
+
* treating it as "clear" is how a save destroyed a stored credential before.
|
|
5526
|
+
*
|
|
5527
|
+
* Pure and browser-safe.
|
|
5528
|
+
*/
|
|
5529
|
+
var SECRET_CLEAR = { $secretClear: true };
|
|
5530
|
+
/** The `'***'` token D634 redaction writes for non-admins. */
|
|
5531
|
+
var LEGACY_DEVICE_REDACTION = "***";
|
|
5532
|
+
function isRecord$1$1(value) {
|
|
5533
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5534
|
+
}
|
|
5535
|
+
function makeSecretMarker(ref) {
|
|
5536
|
+
return {
|
|
5537
|
+
$secret: ref,
|
|
5538
|
+
v: 1
|
|
5539
|
+
};
|
|
5540
|
+
}
|
|
5541
|
+
/** A stored marker: an object whose `$secret` is a non-empty string. */
|
|
5542
|
+
function isSecretMarker(value) {
|
|
5543
|
+
if (!isRecord$1$1(value)) return false;
|
|
5544
|
+
const ref = value["$secret"];
|
|
5545
|
+
return typeof ref === "string" && ref.length > 0;
|
|
5546
|
+
}
|
|
5547
|
+
function isSecretClear(value) {
|
|
5548
|
+
return isRecord$1$1(value) && value["$secretClear"] === true;
|
|
5549
|
+
}
|
|
5550
|
+
/**
|
|
5551
|
+
* The UI view of a stored secret field value: a marker becomes "set", inline
|
|
5552
|
+
* plaintext becomes "set (inline)", nothing becomes `null`. A value never
|
|
5553
|
+
* survives this function.
|
|
5554
|
+
*/
|
|
5555
|
+
function toSecretFieldView(stored) {
|
|
5556
|
+
if (isSecretMarker(stored)) return {
|
|
5557
|
+
$secret: stored.$secret,
|
|
5558
|
+
v: 1,
|
|
5559
|
+
set: true
|
|
5560
|
+
};
|
|
5561
|
+
if (typeof stored === "string" && stored.length > 0) return {
|
|
5562
|
+
$secret: null,
|
|
5563
|
+
v: 1,
|
|
5564
|
+
set: true,
|
|
5565
|
+
inline: true
|
|
5566
|
+
};
|
|
5567
|
+
return null;
|
|
5568
|
+
}
|
|
5569
|
+
/**
|
|
5570
|
+
* Classify an incoming value for a secret path. Only a non-empty string that is
|
|
5571
|
+
* not a redaction token sets a value; only {@link SECRET_CLEAR} clears.
|
|
5572
|
+
* Everything else — a marker (ours or anyone's), a UI view, `''`, `null`,
|
|
5573
|
+
* `undefined`, a redaction token, a non-string — keeps what is stored.
|
|
5574
|
+
*/
|
|
5575
|
+
function classifySecretWrite(incoming) {
|
|
5576
|
+
if (isSecretClear(incoming)) return { kind: "clear" };
|
|
5577
|
+
if (typeof incoming !== "string") return { kind: "keep" };
|
|
5578
|
+
if (incoming.length === 0) return { kind: "keep" };
|
|
5579
|
+
if (incoming === "__camstack_redacted__" || incoming === LEGACY_DEVICE_REDACTION) return { kind: "keep" };
|
|
5580
|
+
return {
|
|
5581
|
+
kind: "set",
|
|
5582
|
+
value: incoming
|
|
5583
|
+
};
|
|
5584
|
+
}
|
|
5487
5585
|
Object.fromEntries([
|
|
5488
5586
|
{
|
|
5489
5587
|
id: "overview",
|
|
@@ -5655,33 +5753,19 @@ Object.fromEntries([
|
|
|
5655
5753
|
function isValuelessField(field) {
|
|
5656
5754
|
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";
|
|
5657
5755
|
}
|
|
5658
|
-
|
|
5659
|
-
* Merge a `ConfigUISchema` with a raw `values` record into a
|
|
5660
|
-
* `ConfigUISchemaWithValues`. Used by every `get*Settings` backend endpoint
|
|
5661
|
-
* before returning to the admin UI. Groups are walked recursively.
|
|
5662
|
-
*
|
|
5663
|
-
* For each leaf field:
|
|
5664
|
-
* - structural fields (`separator`, `info`, `button`) pass through unchanged
|
|
5665
|
-
* - other fields get `value = values[key] ?? field.default ?? null`
|
|
5666
|
-
*
|
|
5667
|
-
* Unknown keys in `values` (keys not declared in the schema) are silently
|
|
5668
|
-
* ignored — they don't contribute to the output. Missing keys fall back to
|
|
5669
|
-
* the schema default or `null`. This mirrors the old backend behaviour where
|
|
5670
|
-
* `FormBuilder` rendered `values[key] ?? field.default`.
|
|
5671
|
-
*/
|
|
5672
|
-
function hydrateSchema(schema, values) {
|
|
5756
|
+
function hydrateSchema(schema, values, options = {}) {
|
|
5673
5757
|
return {
|
|
5674
5758
|
...schema.tabs ? { tabs: [...schema.tabs] } : {},
|
|
5675
5759
|
sections: schema.sections.map((section) => ({
|
|
5676
5760
|
...section,
|
|
5677
|
-
fields: section.fields.map((field) => hydrateField(field, values))
|
|
5761
|
+
fields: section.fields.map((field) => hydrateField(field, values, options))
|
|
5678
5762
|
}))
|
|
5679
5763
|
};
|
|
5680
5764
|
}
|
|
5681
|
-
function hydrateField(field, values) {
|
|
5765
|
+
function hydrateField(field, values, options) {
|
|
5682
5766
|
if (isValuelessField(field)) return field;
|
|
5683
5767
|
if (field.type === "group") {
|
|
5684
|
-
const hydratedChildren = field.fields.map((child) => hydrateField(child, values));
|
|
5768
|
+
const hydratedChildren = field.fields.map((child) => hydrateField(child, values, options));
|
|
5685
5769
|
return {
|
|
5686
5770
|
...field,
|
|
5687
5771
|
fields: hydratedChildren
|
|
@@ -5690,7 +5774,7 @@ function hydrateField(field, values) {
|
|
|
5690
5774
|
if (field.type === "sub-tabs") {
|
|
5691
5775
|
const hydratedTabs = field.tabs.map((tab) => ({
|
|
5692
5776
|
...tab,
|
|
5693
|
-
fields: tab.fields.map((child) => hydrateField(child, values))
|
|
5777
|
+
fields: tab.fields.map((child) => hydrateField(child, values, options))
|
|
5694
5778
|
}));
|
|
5695
5779
|
return {
|
|
5696
5780
|
...field,
|
|
@@ -5700,6 +5784,33 @@ function hydrateField(field, values) {
|
|
|
5700
5784
|
const key = field.key;
|
|
5701
5785
|
const storedValue = Object.prototype.hasOwnProperty.call(values, key) ? values[key] : void 0;
|
|
5702
5786
|
const defaultValue = field.default;
|
|
5787
|
+
const asView = (v) => isSecretMarker(v) || options.inlineSecretsAsViews === true && v !== void 0;
|
|
5788
|
+
if (isKeychainStoredField(field) && asView(storedValue)) return {
|
|
5789
|
+
...field,
|
|
5790
|
+
value: toSecretFieldView(storedValue)
|
|
5791
|
+
};
|
|
5792
|
+
if (isKeychainStoredField(field) && options.inlineSecretsAsViews === true) return {
|
|
5793
|
+
...field,
|
|
5794
|
+
value: null
|
|
5795
|
+
};
|
|
5796
|
+
if (field.type === "editable-array" && Array.isArray(storedValue)) {
|
|
5797
|
+
const secretItemKeys = field.itemFields.filter((item) => "key" in item && isKeychainStoredField(item)).map((item) => "key" in item ? item.key : "");
|
|
5798
|
+
if (secretItemKeys.length > 0) {
|
|
5799
|
+
const rows = storedValue.map((row) => {
|
|
5800
|
+
if (row === null || typeof row !== "object" || Array.isArray(row)) return row;
|
|
5801
|
+
const out = { ...row };
|
|
5802
|
+
for (const k of secretItemKeys) {
|
|
5803
|
+
const v = Reflect.get(row, k);
|
|
5804
|
+
if (asView(v)) out[k] = toSecretFieldView(v);
|
|
5805
|
+
}
|
|
5806
|
+
return out;
|
|
5807
|
+
});
|
|
5808
|
+
return {
|
|
5809
|
+
...field,
|
|
5810
|
+
value: rows
|
|
5811
|
+
};
|
|
5812
|
+
}
|
|
5813
|
+
}
|
|
5703
5814
|
if (field.multiple) {
|
|
5704
5815
|
const stored = Array.isArray(storedValue) ? storedValue : storedValue !== void 0 && storedValue !== null ? [storedValue] : [];
|
|
5705
5816
|
const itemFallback = field.multiple.itemDefault !== void 0 ? field.multiple.itemDefault : defaultValue !== void 0 ? defaultValue : typeOf(field) === "string" ? "" : null;
|
|
@@ -5942,6 +6053,431 @@ function projectStore(store, perNodeKeys, nodeId) {
|
|
|
5942
6053
|
}
|
|
5943
6054
|
return out;
|
|
5944
6055
|
}
|
|
6056
|
+
var GLOBAL_SCOPE = { kind: "global" };
|
|
6057
|
+
/** The scope every addon-wide (not per-node, not per-device) setting lives in. */
|
|
6058
|
+
function globalSecretScope() {
|
|
6059
|
+
return GLOBAL_SCOPE;
|
|
6060
|
+
}
|
|
6061
|
+
function encodeSegment(value) {
|
|
6062
|
+
return encodeURIComponent(value);
|
|
6063
|
+
}
|
|
6064
|
+
/**
|
|
6065
|
+
* The field path of a value inside an array item, addressed by the item's id:
|
|
6066
|
+
* `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
|
|
6067
|
+
* `providers[authentik].clientSecret`.
|
|
6068
|
+
*/
|
|
6069
|
+
function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
|
|
6070
|
+
return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
|
|
6071
|
+
}
|
|
6072
|
+
/** A write to a secret path could not be stored in the keychain, so it was refused. */
|
|
6073
|
+
var KeychainWriteRefusedError = class extends Error {
|
|
6074
|
+
fieldPath;
|
|
6075
|
+
constructor(fieldPath, cause) {
|
|
6076
|
+
super(`secret "${fieldPath}" was not saved: the keychain could not store it (${cause instanceof Error ? cause.message : String(cause)}). Nothing was written.`);
|
|
6077
|
+
this.fieldPath = fieldPath;
|
|
6078
|
+
this.name = "KeychainWriteRefusedError";
|
|
6079
|
+
}
|
|
6080
|
+
};
|
|
6081
|
+
var KEEP = { kind: "keep" };
|
|
6082
|
+
function isRecord$2(value) {
|
|
6083
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6084
|
+
}
|
|
6085
|
+
function defaultMintId() {
|
|
6086
|
+
return globalThis.crypto.randomUUID();
|
|
6087
|
+
}
|
|
6088
|
+
/** Every marker ref anywhere under `value`. */
|
|
6089
|
+
function collectSecretMarkerRefs(value, out = []) {
|
|
6090
|
+
if (isSecretMarker(value)) {
|
|
6091
|
+
out.push(value.$secret);
|
|
6092
|
+
return out;
|
|
6093
|
+
}
|
|
6094
|
+
if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
|
|
6095
|
+
else if (isRecord$2(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
|
|
6096
|
+
return out;
|
|
6097
|
+
}
|
|
6098
|
+
async function storedValueEquals(secrets, marker, candidate) {
|
|
6099
|
+
const resolved = (await secrets.resolve([marker.$secret]))[marker.$secret];
|
|
6100
|
+
return resolved?.kind === "value" && resolved.value === candidate;
|
|
6101
|
+
}
|
|
6102
|
+
async function writeLeaf(ctx, incoming, stored, fieldPath) {
|
|
6103
|
+
const intent = classifySecretWrite(incoming);
|
|
6104
|
+
const ref = ctx.secrets.ref(ctx.scope, fieldPath);
|
|
6105
|
+
const storedIsOurs = isSecretMarker(stored) && stored.$secret === ref;
|
|
6106
|
+
if (intent.kind === "keep") return KEEP;
|
|
6107
|
+
if (intent.kind === "set" && !ctx.operatorWrite && typeof stored === "string" && stored === intent.value) return KEEP;
|
|
6108
|
+
if (intent.kind === "clear") {
|
|
6109
|
+
if (storedIsOurs) ctx.deletes.push(ref);
|
|
6110
|
+
return {
|
|
6111
|
+
kind: "value",
|
|
6112
|
+
value: null
|
|
6113
|
+
};
|
|
6114
|
+
}
|
|
6115
|
+
if (storedIsOurs && await storedValueEquals(ctx.secrets, stored, intent.value)) return {
|
|
6116
|
+
kind: "value",
|
|
6117
|
+
value: stored
|
|
6118
|
+
};
|
|
6119
|
+
try {
|
|
6120
|
+
await ctx.secrets.put(ref, intent.value);
|
|
6121
|
+
} catch (err) {
|
|
6122
|
+
throw new KeychainWriteRefusedError(fieldPath, err);
|
|
6123
|
+
}
|
|
6124
|
+
return {
|
|
6125
|
+
kind: "value",
|
|
6126
|
+
value: makeSecretMarker(ref)
|
|
6127
|
+
};
|
|
6128
|
+
}
|
|
6129
|
+
/** Apply a member result onto `out`: KEEP restores the stored member, or removes it. */
|
|
6130
|
+
function applyMember(out, key, result, storedParent) {
|
|
6131
|
+
if (result.kind === "value") {
|
|
6132
|
+
out[key] = result.value;
|
|
6133
|
+
return;
|
|
6134
|
+
}
|
|
6135
|
+
if (Object.prototype.hasOwnProperty.call(storedParent, key)) out[key] = storedParent[key];
|
|
6136
|
+
else delete out[key];
|
|
6137
|
+
}
|
|
6138
|
+
async function writeMembers(ctx, children, incoming, stored, pathOf) {
|
|
6139
|
+
const out = { ...incoming };
|
|
6140
|
+
for (const [member, node] of children) applyMember(out, member, await writeNode(ctx, node, incoming[member], stored[member], pathOf(member)), stored);
|
|
6141
|
+
return out;
|
|
6142
|
+
}
|
|
6143
|
+
function rowId(row, idKey) {
|
|
6144
|
+
const raw = row[idKey];
|
|
6145
|
+
if (typeof raw === "string" && raw.length > 0) return raw;
|
|
6146
|
+
if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
|
|
6147
|
+
return null;
|
|
6148
|
+
}
|
|
6149
|
+
async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
6150
|
+
const storedRows = Array.isArray(stored) ? stored.filter(isRecord$2) : [];
|
|
6151
|
+
if (!Array.isArray(incoming)) {
|
|
6152
|
+
ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
|
|
6153
|
+
return {
|
|
6154
|
+
kind: "value",
|
|
6155
|
+
value: incoming
|
|
6156
|
+
};
|
|
6157
|
+
}
|
|
6158
|
+
const storedById = /* @__PURE__ */ new Map();
|
|
6159
|
+
for (const row of storedRows) {
|
|
6160
|
+
const id = rowId(row, node.idKey);
|
|
6161
|
+
if (id !== null) storedById.set(id, row);
|
|
6162
|
+
}
|
|
6163
|
+
const kept = /* @__PURE__ */ new Set();
|
|
6164
|
+
const rows = [];
|
|
6165
|
+
for (const row of incoming) {
|
|
6166
|
+
if (!isRecord$2(row)) {
|
|
6167
|
+
rows.push(row);
|
|
6168
|
+
continue;
|
|
6169
|
+
}
|
|
6170
|
+
const id = rowId(row, node.idKey) ?? ctx.mintId();
|
|
6171
|
+
kept.add(id);
|
|
6172
|
+
const withId = {
|
|
6173
|
+
...row,
|
|
6174
|
+
[node.idKey]: row[node.idKey] ?? id
|
|
6175
|
+
};
|
|
6176
|
+
if (rowId(withId, node.idKey) === null) withId[node.idKey] = id;
|
|
6177
|
+
const storedRow = storedById.get(id) ?? {};
|
|
6178
|
+
rows.push(await writeMembers(ctx, node.item, withId, storedRow, (member) => arrayItemFieldPath(fieldPath, id, member)));
|
|
6179
|
+
}
|
|
6180
|
+
for (const [id, row] of storedById) if (!kept.has(id)) ctx.deletes.push(...collectSecretMarkerRefs(row));
|
|
6181
|
+
return {
|
|
6182
|
+
kind: "value",
|
|
6183
|
+
value: rows
|
|
6184
|
+
};
|
|
6185
|
+
}
|
|
6186
|
+
async function writeNode(ctx, node, incoming, stored, fieldPath) {
|
|
6187
|
+
switch (node.kind) {
|
|
6188
|
+
case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
|
|
6189
|
+
case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
|
|
6190
|
+
case "object": {
|
|
6191
|
+
if (!isRecord$2(incoming)) {
|
|
6192
|
+
if (incoming === void 0) return KEEP;
|
|
6193
|
+
ctx.deletes.push(...collectSecretMarkerRefs(stored));
|
|
6194
|
+
return {
|
|
6195
|
+
kind: "value",
|
|
6196
|
+
value: incoming
|
|
6197
|
+
};
|
|
6198
|
+
}
|
|
6199
|
+
const storedObj = isRecord$2(stored) ? stored : {};
|
|
6200
|
+
return {
|
|
6201
|
+
kind: "value",
|
|
6202
|
+
value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
|
|
6203
|
+
};
|
|
6204
|
+
}
|
|
6205
|
+
}
|
|
6206
|
+
}
|
|
6207
|
+
/** Split a perNode-scoped key (`key@nodeId`). */
|
|
6208
|
+
function splitNodeKey(key) {
|
|
6209
|
+
const at = key.indexOf("@");
|
|
6210
|
+
return at <= 0 ? {
|
|
6211
|
+
base: key,
|
|
6212
|
+
nodeId: null
|
|
6213
|
+
} : {
|
|
6214
|
+
base: key.slice(0, at),
|
|
6215
|
+
nodeId: key.slice(at + 1)
|
|
6216
|
+
};
|
|
6217
|
+
}
|
|
6218
|
+
/** Rewrite a settings patch so no secret value reaches the blob. See the file doc. */
|
|
6219
|
+
async function transformSecretWrite(input) {
|
|
6220
|
+
const deletes = [];
|
|
6221
|
+
const base = {
|
|
6222
|
+
secrets: input.secrets,
|
|
6223
|
+
mintId: input.mintId ?? defaultMintId,
|
|
6224
|
+
deletes,
|
|
6225
|
+
operatorWrite: input.operatorWrite === true
|
|
6226
|
+
};
|
|
6227
|
+
const out = {};
|
|
6228
|
+
for (const [key, incoming] of Object.entries(input.patch)) {
|
|
6229
|
+
const { base: baseKey, nodeId } = splitNodeKey(key);
|
|
6230
|
+
const node = input.tree.get(baseKey);
|
|
6231
|
+
if (node === void 0) {
|
|
6232
|
+
out[key] = incoming;
|
|
6233
|
+
continue;
|
|
6234
|
+
}
|
|
6235
|
+
const scope = nodeId !== null && nodeId.length > 0 ? {
|
|
6236
|
+
kind: "node",
|
|
6237
|
+
nodeId
|
|
6238
|
+
} : input.scope ?? globalSecretScope();
|
|
6239
|
+
const result = await writeNode({
|
|
6240
|
+
...base,
|
|
6241
|
+
scope
|
|
6242
|
+
}, node, incoming, input.stored[key], baseKey);
|
|
6243
|
+
if (result.kind === "value") out[key] = result.value;
|
|
6244
|
+
}
|
|
6245
|
+
return {
|
|
6246
|
+
patch: out,
|
|
6247
|
+
afterWrite: async () => {
|
|
6248
|
+
if (deletes.length === 0) return { orphaned: [] };
|
|
6249
|
+
try {
|
|
6250
|
+
await input.secrets.delete([...new Set(deletes)]);
|
|
6251
|
+
return { orphaned: [] };
|
|
6252
|
+
} catch {
|
|
6253
|
+
return { orphaned: [...new Set(deletes)] };
|
|
6254
|
+
}
|
|
6255
|
+
}
|
|
6256
|
+
};
|
|
6257
|
+
}
|
|
6258
|
+
/**
|
|
6259
|
+
* Replace every marker in `value` with its keychain value. Returns the SAME
|
|
6260
|
+
* reference when there is no marker (no allocation, no keychain call).
|
|
6261
|
+
*/
|
|
6262
|
+
async function resolveSecretMarkers(value, secrets) {
|
|
6263
|
+
const refs = collectSecretMarkerRefs(value);
|
|
6264
|
+
if (refs.length === 0) return {
|
|
6265
|
+
value,
|
|
6266
|
+
unresolved: []
|
|
6267
|
+
};
|
|
6268
|
+
const answers = await secrets.resolve(refs);
|
|
6269
|
+
const unresolved = [];
|
|
6270
|
+
for (const ref of new Set(refs)) {
|
|
6271
|
+
const answer = answers[ref];
|
|
6272
|
+
if (answer === void 0) unresolved.push({
|
|
6273
|
+
ref,
|
|
6274
|
+
reason: "not-initialized"
|
|
6275
|
+
});
|
|
6276
|
+
else if (answer.kind === "unavailable") unresolved.push({
|
|
6277
|
+
ref,
|
|
6278
|
+
reason: answer.reason
|
|
6279
|
+
});
|
|
6280
|
+
else if (answer.kind === "missing" || answer.kind === "forbidden") unresolved.push({
|
|
6281
|
+
ref,
|
|
6282
|
+
reason: answer.kind
|
|
6283
|
+
});
|
|
6284
|
+
}
|
|
6285
|
+
const substitute = (v) => {
|
|
6286
|
+
if (isSecretMarker(v)) {
|
|
6287
|
+
const answer = answers[v.$secret];
|
|
6288
|
+
return answer?.kind === "value" ? {
|
|
6289
|
+
keep: true,
|
|
6290
|
+
value: answer.value
|
|
6291
|
+
} : {
|
|
6292
|
+
keep: false,
|
|
6293
|
+
value: void 0
|
|
6294
|
+
};
|
|
6295
|
+
}
|
|
6296
|
+
if (Array.isArray(v)) {
|
|
6297
|
+
const items = [];
|
|
6298
|
+
for (const item of v) {
|
|
6299
|
+
const s = substitute(item);
|
|
6300
|
+
if (s.keep) items.push(s.value);
|
|
6301
|
+
}
|
|
6302
|
+
return {
|
|
6303
|
+
keep: true,
|
|
6304
|
+
value: items
|
|
6305
|
+
};
|
|
6306
|
+
}
|
|
6307
|
+
if (isRecord$2(v)) {
|
|
6308
|
+
const out = {};
|
|
6309
|
+
for (const [k, child] of Object.entries(v)) {
|
|
6310
|
+
const s = substitute(child);
|
|
6311
|
+
if (s.keep) out[k] = s.value;
|
|
6312
|
+
}
|
|
6313
|
+
return {
|
|
6314
|
+
keep: true,
|
|
6315
|
+
value: out
|
|
6316
|
+
};
|
|
6317
|
+
}
|
|
6318
|
+
return {
|
|
6319
|
+
keep: true,
|
|
6320
|
+
value: v
|
|
6321
|
+
};
|
|
6322
|
+
};
|
|
6323
|
+
return {
|
|
6324
|
+
value: substitute(value).value,
|
|
6325
|
+
unresolved
|
|
6326
|
+
};
|
|
6327
|
+
}
|
|
6328
|
+
function touchesTree(tree, patch) {
|
|
6329
|
+
if (tree.size === 0) return false;
|
|
6330
|
+
for (const key of Object.keys(patch)) {
|
|
6331
|
+
const at = key.indexOf("@");
|
|
6332
|
+
if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
|
|
6333
|
+
}
|
|
6334
|
+
return false;
|
|
6335
|
+
}
|
|
6336
|
+
/** The blob as stored now; a failed read REFUSES the write instead of guessing. */
|
|
6337
|
+
async function readStoredAddonBlob(raw) {
|
|
6338
|
+
const threeWay = raw.readAddonStoreResult;
|
|
6339
|
+
if (threeWay === void 0) return raw.readAddonStore();
|
|
6340
|
+
const result = await threeWay.call(raw);
|
|
6341
|
+
if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
|
|
6342
|
+
return result.kind === "missing" ? {} : result.value;
|
|
6343
|
+
}
|
|
6344
|
+
function createSecretAwareSettings(raw, opts) {
|
|
6345
|
+
const chains = /* @__PURE__ */ new Map();
|
|
6346
|
+
const serialize = (key, fn) => {
|
|
6347
|
+
const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
|
|
6348
|
+
const tail = next.catch(() => void 0);
|
|
6349
|
+
chains.set(key, tail);
|
|
6350
|
+
tail.then(() => {
|
|
6351
|
+
if (chains.get(key) === tail) chains.delete(key);
|
|
6352
|
+
});
|
|
6353
|
+
return next;
|
|
6354
|
+
};
|
|
6355
|
+
const write = async (chainKey, tree, scope, patch, readStored, rawWrite) => {
|
|
6356
|
+
if (!touchesTree(tree, patch)) return rawWrite(patch);
|
|
6357
|
+
return serialize(chainKey, async () => {
|
|
6358
|
+
const stored = await readStored();
|
|
6359
|
+
const result = await transformSecretWrite({
|
|
6360
|
+
tree,
|
|
6361
|
+
secrets: opts.secrets,
|
|
6362
|
+
patch,
|
|
6363
|
+
stored,
|
|
6364
|
+
...scope !== void 0 ? { scope } : {},
|
|
6365
|
+
operatorWrite: opts.isOperatorWrite?.() === true
|
|
6366
|
+
});
|
|
6367
|
+
if (Object.keys(result.patch).length > 0) await rawWrite(result.patch);
|
|
6368
|
+
const { orphaned } = await result.afterWrite();
|
|
6369
|
+
if (orphaned.length > 0) opts.onOrphaned(orphaned);
|
|
6370
|
+
});
|
|
6371
|
+
};
|
|
6372
|
+
const wrapped = {
|
|
6373
|
+
writeAddonStore: (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p)),
|
|
6374
|
+
writeDeviceStore: (deviceId, patch) => write(`device:${deviceId}`, opts.deviceTree(), {
|
|
6375
|
+
kind: "device",
|
|
6376
|
+
deviceId
|
|
6377
|
+
}, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p))
|
|
6378
|
+
};
|
|
6379
|
+
return new Proxy(raw, { get(target, prop, receiver) {
|
|
6380
|
+
if (prop === "writeAddonStore") return wrapped.writeAddonStore;
|
|
6381
|
+
if (prop === "writeDeviceStore") return wrapped.writeDeviceStore;
|
|
6382
|
+
const value = Reflect.get(target, prop, receiver);
|
|
6383
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
6384
|
+
} });
|
|
6385
|
+
}
|
|
6386
|
+
/** The context the addon sees: identical, except that its settings writes are secret-aware. */
|
|
6387
|
+
function withSecretAwareSettings(context, opts) {
|
|
6388
|
+
const raw = context.settings;
|
|
6389
|
+
if (raw === void 0) return context;
|
|
6390
|
+
const settings = createSecretAwareSettings(raw, opts);
|
|
6391
|
+
return new Proxy(context, { get(target, prop, receiver) {
|
|
6392
|
+
if (prop === "settings") return settings;
|
|
6393
|
+
return Reflect.get(target, prop, receiver);
|
|
6394
|
+
} });
|
|
6395
|
+
}
|
|
6396
|
+
var LEAF = { kind: "leaf" };
|
|
6397
|
+
var DEFAULT_ITEM_ID_KEY = "id";
|
|
6398
|
+
function collectFields(fields, out) {
|
|
6399
|
+
for (const field of fields) {
|
|
6400
|
+
if (field.type === "group") {
|
|
6401
|
+
collectFields(field.fields, out);
|
|
6402
|
+
continue;
|
|
6403
|
+
}
|
|
6404
|
+
if (field.type === "sub-tabs") {
|
|
6405
|
+
for (const tab of field.tabs) collectFields(tab.fields, out);
|
|
6406
|
+
continue;
|
|
6407
|
+
}
|
|
6408
|
+
if (field.type === "editable-array") {
|
|
6409
|
+
const item = /* @__PURE__ */ new Map();
|
|
6410
|
+
for (const itemField of field.itemFields) if ("key" in itemField && isKeychainStoredField(itemField)) item.set(itemField.key, LEAF);
|
|
6411
|
+
if (item.size > 0) out.set(field.key, {
|
|
6412
|
+
kind: "array",
|
|
6413
|
+
idKey: field.itemIdKey ?? DEFAULT_ITEM_ID_KEY,
|
|
6414
|
+
item
|
|
6415
|
+
});
|
|
6416
|
+
continue;
|
|
6417
|
+
}
|
|
6418
|
+
if (!("key" in field) || typeof field.key !== "string") continue;
|
|
6419
|
+
if (isKeychainStoredField(field)) out.set(field.key, LEAF);
|
|
6420
|
+
}
|
|
6421
|
+
}
|
|
6422
|
+
/** The secret tree a settings schema declares. */
|
|
6423
|
+
function secretTreeFromSchema(schema) {
|
|
6424
|
+
const out = /* @__PURE__ */ new Map();
|
|
6425
|
+
if (schema === null) return out;
|
|
6426
|
+
for (const section of schema.sections) collectFields(section.fields, out);
|
|
6427
|
+
return out;
|
|
6428
|
+
}
|
|
6429
|
+
/** Parse `a.b[id].c` into segments; throws on a malformed path (a declaration bug). */
|
|
6430
|
+
function parseSecretStatePath(path) {
|
|
6431
|
+
const segments = [];
|
|
6432
|
+
for (const raw of path.split(".")) {
|
|
6433
|
+
const m = /^([^[\]]+)(?:\[([^[\]]+)\])?$/.exec(raw);
|
|
6434
|
+
if (m === null || m[1] === void 0) throw new Error(`secretStatePaths: malformed path "${path}"`);
|
|
6435
|
+
segments.push(m[2] !== void 0 ? {
|
|
6436
|
+
key: m[1],
|
|
6437
|
+
idKey: m[2]
|
|
6438
|
+
} : { key: m[1] });
|
|
6439
|
+
}
|
|
6440
|
+
if (segments.length === 0) throw new Error(`secretStatePaths: empty path`);
|
|
6441
|
+
if (segments[segments.length - 1]?.idKey !== void 0) throw new Error(`secretStatePaths: "${path}" ends on an array — name the member that is secret`);
|
|
6442
|
+
return segments;
|
|
6443
|
+
}
|
|
6444
|
+
function insert(into, segments) {
|
|
6445
|
+
const [head, ...rest] = segments;
|
|
6446
|
+
if (head === void 0) return;
|
|
6447
|
+
if (rest.length === 0) {
|
|
6448
|
+
into.set(head.key, LEAF);
|
|
6449
|
+
return;
|
|
6450
|
+
}
|
|
6451
|
+
const existing = into.get(head.key);
|
|
6452
|
+
if (head.idKey !== void 0) {
|
|
6453
|
+
const item = new Map(existing?.kind === "array" ? existing.item : []);
|
|
6454
|
+
insert(item, rest);
|
|
6455
|
+
into.set(head.key, {
|
|
6456
|
+
kind: "array",
|
|
6457
|
+
idKey: head.idKey,
|
|
6458
|
+
item
|
|
6459
|
+
});
|
|
6460
|
+
return;
|
|
6461
|
+
}
|
|
6462
|
+
const children = new Map(existing?.kind === "object" ? existing.children : []);
|
|
6463
|
+
insert(children, rest);
|
|
6464
|
+
into.set(head.key, {
|
|
6465
|
+
kind: "object",
|
|
6466
|
+
children
|
|
6467
|
+
});
|
|
6468
|
+
}
|
|
6469
|
+
/** Add hidden-state paths (`secretStatePaths`) to a schema-derived tree. */
|
|
6470
|
+
function mergeSecretStatePaths(tree, paths) {
|
|
6471
|
+
if (paths.length === 0) return tree;
|
|
6472
|
+
const out = new Map(tree);
|
|
6473
|
+
for (const path of paths) insert(out, parseSecretStatePath(path));
|
|
6474
|
+
return out;
|
|
6475
|
+
}
|
|
6476
|
+
/** First retry of a secret the keychain could not serve; doubles to {@link SECRET_RETRY_MAX_MS}. */
|
|
6477
|
+
var SECRET_RETRY_FIRST_MS = 5e3;
|
|
6478
|
+
var SECRET_RETRY_MAX_MS = 5 * 6e4;
|
|
6479
|
+
/** Coalesces a burst of `keychain.changed` events into one re-resolve. */
|
|
6480
|
+
var SECRET_CHANGE_DEBOUNCE_MS = 250;
|
|
5945
6481
|
/**
|
|
5946
6482
|
* Base class for CamStack addons. Eliminates settings boilerplate:
|
|
5947
6483
|
*
|
|
@@ -6011,6 +6547,25 @@ var BaseAddon = class {
|
|
|
6011
6547
|
settingsStoreReady = false;
|
|
6012
6548
|
/** Default config values. Provided via constructor. */
|
|
6013
6549
|
defaults;
|
|
6550
|
+
/**
|
|
6551
|
+
* Hidden-state paths that hold secrets (D787) — values the addon writes
|
|
6552
|
+
* itself (`updateGlobalSettings`, `state()`) that no form field declares.
|
|
6553
|
+
* Stored in the keychain exactly like a `password` field. Syntax:
|
|
6554
|
+
* `'snapshotSigningKey'`, `'identity.pincode'`, `'tokens[userId].accessToken'`
|
|
6555
|
+
* (`key[<id field>]` addresses array items by id, never by index).
|
|
6556
|
+
*/
|
|
6557
|
+
secretStatePaths = [];
|
|
6558
|
+
_addonSecretTree = null;
|
|
6559
|
+
_deviceSecretTree = null;
|
|
6560
|
+
/** Refs the last resolved config pointed at — a change to one re-resolves. */
|
|
6561
|
+
_configSecretRefs = /* @__PURE__ */ new Set();
|
|
6562
|
+
_unresolvedSecrets = [];
|
|
6563
|
+
_secretRetryTimer = null;
|
|
6564
|
+
_secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
|
|
6565
|
+
_secretChangeTimer = null;
|
|
6566
|
+
_secretChangeUnsub = null;
|
|
6567
|
+
/** >0 while an OPERATOR's settings write is being applied. */
|
|
6568
|
+
_operatorWriteDepth = 0;
|
|
6014
6569
|
constructor(defaults) {
|
|
6015
6570
|
this.defaults = defaults;
|
|
6016
6571
|
this._config = { ...defaults };
|
|
@@ -6046,8 +6601,18 @@ var BaseAddon = class {
|
|
|
6046
6601
|
return this._config;
|
|
6047
6602
|
}
|
|
6048
6603
|
async initialize(context) {
|
|
6049
|
-
|
|
6604
|
+
const secrets = context.secrets;
|
|
6605
|
+
this._ctx = secrets !== void 0 ? withSecretAwareSettings(context, {
|
|
6606
|
+
secrets,
|
|
6607
|
+
addonTree: () => this.addonSecretTree(),
|
|
6608
|
+
deviceTree: () => this.deviceSecretTree(),
|
|
6609
|
+
onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
|
|
6610
|
+
isOperatorWrite: () => this._operatorWriteDepth > 0
|
|
6611
|
+
}) : context;
|
|
6050
6612
|
await this.resolveConfig();
|
|
6613
|
+
if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
|
|
6614
|
+
if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
|
|
6615
|
+
});
|
|
6051
6616
|
const result = await this.onInitialize();
|
|
6052
6617
|
this.emitLifecycle(EventCategory.AddonStarted);
|
|
6053
6618
|
const normalized = normalizeAddonInitResult(result);
|
|
@@ -6080,6 +6645,12 @@ var BaseAddon = class {
|
|
|
6080
6645
|
*/
|
|
6081
6646
|
async onHubReachable() {}
|
|
6082
6647
|
async shutdown() {
|
|
6648
|
+
this._secretChangeUnsub?.();
|
|
6649
|
+
this._secretChangeUnsub = null;
|
|
6650
|
+
if (this._secretRetryTimer !== null) clearTimeout(this._secretRetryTimer);
|
|
6651
|
+
if (this._secretChangeTimer !== null) clearTimeout(this._secretChangeTimer);
|
|
6652
|
+
this._secretRetryTimer = null;
|
|
6653
|
+
this._secretChangeTimer = null;
|
|
6083
6654
|
this.emitLifecycle(EventCategory.AddonStopped);
|
|
6084
6655
|
if (this.autoEmitReadiness) this.emitReadinessForProviders("down");
|
|
6085
6656
|
await this.onShutdown();
|
|
@@ -6158,7 +6729,7 @@ var BaseAddon = class {
|
|
|
6158
6729
|
return hydrateSchema(schema, overlay ? {
|
|
6159
6730
|
...projected,
|
|
6160
6731
|
...overlay
|
|
6161
|
-
} : projected);
|
|
6732
|
+
} : projected, { inlineSecretsAsViews: true });
|
|
6162
6733
|
}
|
|
6163
6734
|
/**
|
|
6164
6735
|
* The integration-level view of this addon's settings: exactly the sections
|
|
@@ -6207,7 +6778,7 @@ var BaseAddon = class {
|
|
|
6207
6778
|
return hydrateSchema({
|
|
6208
6779
|
...schema,
|
|
6209
6780
|
sections
|
|
6210
|
-
}, projected);
|
|
6781
|
+
}, projected, { inlineSecretsAsViews: true });
|
|
6211
6782
|
}
|
|
6212
6783
|
/**
|
|
6213
6784
|
* The raw addon store PROJECTED onto the target node's bare per-node keys:
|
|
@@ -6261,18 +6832,50 @@ var BaseAddon = class {
|
|
|
6261
6832
|
value: result.value[key]
|
|
6262
6833
|
};
|
|
6263
6834
|
}
|
|
6835
|
+
/**
|
|
6836
|
+
* The OPERATOR's write — a settings form or an admin API call, dispatched by
|
|
6837
|
+
* the kernel. Identical to {@link updateGlobalSettings}, except that a secret
|
|
6838
|
+
* the operator sends is stored as sent even when it equals a pre-keychain
|
|
6839
|
+
* inline value: the operator re-entering a password is a change, an addon
|
|
6840
|
+
* writing back what it read is not (D787).
|
|
6841
|
+
*/
|
|
6842
|
+
async updateGlobalSettingsAsOperator(patch, nodeId) {
|
|
6843
|
+
this._operatorWriteDepth++;
|
|
6844
|
+
try {
|
|
6845
|
+
await this.applyGlobalPatch(patch, nodeId);
|
|
6846
|
+
} finally {
|
|
6847
|
+
this._operatorWriteDepth--;
|
|
6848
|
+
}
|
|
6849
|
+
}
|
|
6264
6850
|
async updateGlobalSettings(patch, nodeId) {
|
|
6851
|
+
await this.applyGlobalPatch(patch, nodeId);
|
|
6852
|
+
}
|
|
6853
|
+
/**
|
|
6854
|
+
* REMOVE stored secrets — their keychain values and their markers (D787).
|
|
6855
|
+
*
|
|
6856
|
+
* Writing `''` to a secret field KEEPS what is stored (an empty string is
|
|
6857
|
+
* what a defaults fallback writes back, and it must never destroy a
|
|
6858
|
+
* credential), so code that means "forget this token" says so here. Without
|
|
6859
|
+
* a keychain (an older kernel) it writes `''`, as such code always did.
|
|
6860
|
+
*/
|
|
6861
|
+
async clearSecrets(keys, nodeId) {
|
|
6862
|
+
const tree = this.addonSecretTree();
|
|
6863
|
+
const keychain = this._ctx?.secrets !== void 0;
|
|
6864
|
+
const patch = {};
|
|
6865
|
+
for (const key of keys) patch[key] = keychain && tree.has(key) ? SECRET_CLEAR : "";
|
|
6866
|
+
await this.applyGlobalPatch(patch, nodeId);
|
|
6867
|
+
}
|
|
6868
|
+
async applyGlobalPatch(barePatch, nodeId) {
|
|
6265
6869
|
const keys = this.perNodeKeys();
|
|
6266
6870
|
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
6267
6871
|
const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
6268
|
-
const barePatch = patch;
|
|
6269
6872
|
const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
|
|
6270
6873
|
await this._ctx?.settings?.writeAddonStore(scoped);
|
|
6271
6874
|
if (target !== localNode) return;
|
|
6272
6875
|
await this.resolveConfig();
|
|
6273
6876
|
await this.onConfigChanged();
|
|
6274
6877
|
this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
|
|
6275
|
-
this.maybeAutoRestart(
|
|
6878
|
+
this.maybeAutoRestart(Object.keys(barePatch), this.globalSettingsSchema());
|
|
6276
6879
|
}
|
|
6277
6880
|
/**
|
|
6278
6881
|
* The set of field keys the global settings schema declares `perNode: true`
|
|
@@ -6297,7 +6900,7 @@ var BaseAddon = class {
|
|
|
6297
6900
|
* time to return its response before the addon is torn down and
|
|
6298
6901
|
* re-initialised by `AddonRegistryService.restartAddon`.
|
|
6299
6902
|
*/
|
|
6300
|
-
maybeAutoRestart(
|
|
6903
|
+
maybeAutoRestart(patchKeys, schema) {
|
|
6301
6904
|
if (!schema) return;
|
|
6302
6905
|
const restartKeys = /* @__PURE__ */ new Set();
|
|
6303
6906
|
for (const section of schema.sections) for (const field of section.fields) {
|
|
@@ -6305,13 +6908,13 @@ var BaseAddon = class {
|
|
|
6305
6908
|
if (field.requiresRestart) restartKeys.add(field.key);
|
|
6306
6909
|
}
|
|
6307
6910
|
if (restartKeys.size === 0) return;
|
|
6308
|
-
if (!
|
|
6911
|
+
if (!patchKeys.some((k) => restartKeys.has(k))) return;
|
|
6309
6912
|
const ctx = this._ctx;
|
|
6310
6913
|
if (!ctx) return;
|
|
6311
6914
|
const addonId = ctx.id;
|
|
6312
6915
|
setImmediate(() => {
|
|
6313
6916
|
ctx.api.addons?.restartAddon?.mutate({ addonId }).then(() => {
|
|
6314
|
-
ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields:
|
|
6917
|
+
ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
|
|
6315
6918
|
}).catch((err) => {
|
|
6316
6919
|
ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
6317
6920
|
});
|
|
@@ -6320,7 +6923,7 @@ var BaseAddon = class {
|
|
|
6320
6923
|
async getDeviceSettings(deviceId) {
|
|
6321
6924
|
const schema = this.deviceSettingsSchema();
|
|
6322
6925
|
if (!schema) return { sections: [] };
|
|
6323
|
-
return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {});
|
|
6926
|
+
return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
|
|
6324
6927
|
}
|
|
6325
6928
|
async updateDeviceSettings(deviceId, patch) {
|
|
6326
6929
|
await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
|
|
@@ -6450,7 +7053,7 @@ var BaseAddon = class {
|
|
|
6450
7053
|
* selection at boot (absent scoped key ⇒ the constructor default wins).
|
|
6451
7054
|
*/
|
|
6452
7055
|
async resolveConfig() {
|
|
6453
|
-
const stored = await this.readAddonStoreWithRetry();
|
|
7056
|
+
const stored = await this.resolveStoredSecrets(await this.readAddonStoreWithRetry());
|
|
6454
7057
|
const perNode = this.perNodeKeys();
|
|
6455
7058
|
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
6456
7059
|
const resolved = { ...this.defaults };
|
|
@@ -6475,7 +7078,7 @@ var BaseAddon = class {
|
|
|
6475
7078
|
key,
|
|
6476
7079
|
schema,
|
|
6477
7080
|
fallback,
|
|
6478
|
-
read: () => this.readAddonStoreWithRetry(),
|
|
7081
|
+
read: async () => this.resolveStoredSecrets(await this.readAddonStoreWithRetry()),
|
|
6479
7082
|
write: async (patch) => {
|
|
6480
7083
|
await this._ctx?.settings?.writeAddonStore(patch);
|
|
6481
7084
|
},
|
|
@@ -6492,7 +7095,7 @@ var BaseAddon = class {
|
|
|
6492
7095
|
key,
|
|
6493
7096
|
schema,
|
|
6494
7097
|
fallback,
|
|
6495
|
-
read: async () => await this._ctx?.settings?.readDeviceStore(deviceId) ?? {},
|
|
7098
|
+
read: async () => this.resolveStoredSecrets(await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, false),
|
|
6496
7099
|
write: async (patch) => {
|
|
6497
7100
|
await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
|
|
6498
7101
|
},
|
|
@@ -6504,6 +7107,70 @@ var BaseAddon = class {
|
|
|
6504
7107
|
} })
|
|
6505
7108
|
});
|
|
6506
7109
|
}
|
|
7110
|
+
/** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
|
|
7111
|
+
addonSecretTree() {
|
|
7112
|
+
this._addonSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.globalSettingsSchema()), this.secretStatePaths);
|
|
7113
|
+
return this._addonSecretTree;
|
|
7114
|
+
}
|
|
7115
|
+
deviceSecretTree() {
|
|
7116
|
+
this._deviceSecretTree ??= secretTreeFromSchema(this.deviceSettingsSchema());
|
|
7117
|
+
return this._deviceSecretTree;
|
|
7118
|
+
}
|
|
7119
|
+
/**
|
|
7120
|
+
* Secrets of this addon's stored config that could not be resolved on the
|
|
7121
|
+
* last read, with why. Non-empty means the addon is running WITHOUT them —
|
|
7122
|
+
* an addon whose function needs one should report itself degraded rather
|
|
7123
|
+
* than start on an empty credential.
|
|
7124
|
+
*/
|
|
7125
|
+
get unresolvedSecrets() {
|
|
7126
|
+
return this._unresolvedSecrets;
|
|
7127
|
+
}
|
|
7128
|
+
/**
|
|
7129
|
+
* Substitute every keychain marker in a stored blob with its value. With no
|
|
7130
|
+
* keychain (no `ctx.secrets`) or no marker, the blob comes back unchanged.
|
|
7131
|
+
* An unresolvable value is LEFT OUT (never `''`), logged by ref — never by
|
|
7132
|
+
* value — and, when the cause can pass, retried with backoff. Nothing is
|
|
7133
|
+
* ever written back from here.
|
|
7134
|
+
*/
|
|
7135
|
+
async resolveStoredSecrets(blob, trackForConfig = true) {
|
|
7136
|
+
const secrets = this._ctx?.secrets;
|
|
7137
|
+
if (secrets === void 0) return blob;
|
|
7138
|
+
const refs = collectSecretMarkerRefs(blob);
|
|
7139
|
+
if (trackForConfig) this._configSecretRefs = new Set(refs);
|
|
7140
|
+
if (refs.length === 0) {
|
|
7141
|
+
if (trackForConfig) this._unresolvedSecrets = [];
|
|
7142
|
+
return blob;
|
|
7143
|
+
}
|
|
7144
|
+
const { value, unresolved } = await resolveSecretMarkers(blob, secrets);
|
|
7145
|
+
if (trackForConfig) {
|
|
7146
|
+
this._unresolvedSecrets = unresolved;
|
|
7147
|
+
if (unresolved.length > 0) {
|
|
7148
|
+
this._ctx?.logger?.error?.("secret unavailable — running without it, will retry", { meta: { secrets: unresolved.map((u) => ({
|
|
7149
|
+
ref: u.ref,
|
|
7150
|
+
reason: u.reason
|
|
7151
|
+
})) } });
|
|
7152
|
+
if (unresolved.some((u) => u.reason !== "missing" && u.reason !== "forbidden")) {
|
|
7153
|
+
this.scheduleSecretReresolve(this._secretRetryDelayMs);
|
|
7154
|
+
this._secretRetryDelayMs = Math.min(this._secretRetryDelayMs * 2, SECRET_RETRY_MAX_MS);
|
|
7155
|
+
}
|
|
7156
|
+
} else this._secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
|
|
7157
|
+
}
|
|
7158
|
+
return value;
|
|
7159
|
+
}
|
|
7160
|
+
/** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
|
|
7161
|
+
scheduleSecretReresolve(delayMs) {
|
|
7162
|
+
const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
|
|
7163
|
+
if (this[timerOf] !== null) return;
|
|
7164
|
+
const timer = setTimeout(() => {
|
|
7165
|
+
this[timerOf] = null;
|
|
7166
|
+
if (this._ctx === null) return;
|
|
7167
|
+
this.resolveConfig().then(() => this.onConfigChanged()).catch((err) => {
|
|
7168
|
+
this._ctx?.logger?.error?.("re-resolving secrets failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
7169
|
+
});
|
|
7170
|
+
}, delayMs);
|
|
7171
|
+
timer.unref?.();
|
|
7172
|
+
this[timerOf] = timer;
|
|
7173
|
+
}
|
|
6507
7174
|
/**
|
|
6508
7175
|
* Wrap `ctx.settings.readAddonStore()` with a short retry budget so a
|
|
6509
7176
|
* transient settings-store outage (mid-restart of sqlite-settings, tsx-watch
|
|
@@ -7079,6 +7746,69 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
|
|
|
7079
7746
|
kind: "mutation",
|
|
7080
7747
|
auth: "admin"
|
|
7081
7748
|
}), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
|
|
7749
|
+
function defOf(schema) {
|
|
7750
|
+
return schema._zod?.def ?? {};
|
|
7751
|
+
}
|
|
7752
|
+
function declaredHere(schema) {
|
|
7753
|
+
return globalRegistry.get(schema)?.secret === true;
|
|
7754
|
+
}
|
|
7755
|
+
/** Wrapper kinds whose `innerType` is the field itself. */
|
|
7756
|
+
var WRAPPERS = new Set([
|
|
7757
|
+
"optional",
|
|
7758
|
+
"nullable",
|
|
7759
|
+
"default",
|
|
7760
|
+
"prefault",
|
|
7761
|
+
"catch",
|
|
7762
|
+
"readonly",
|
|
7763
|
+
"nonoptional"
|
|
7764
|
+
]);
|
|
7765
|
+
/**
|
|
7766
|
+
* The schema layers that make up ONE field: the schema itself and every
|
|
7767
|
+
* wrapper below it (optional / default / nullable / readonly / catch), plus
|
|
7768
|
+
* both sides of a pipe (`z.preprocess` puts the real schema on `out`,
|
|
7769
|
+
* `.transform` on `in`).
|
|
7770
|
+
*/
|
|
7771
|
+
function layersOf(schema) {
|
|
7772
|
+
const out = [];
|
|
7773
|
+
const queue = [schema];
|
|
7774
|
+
while (queue.length > 0) {
|
|
7775
|
+
const s = queue.shift();
|
|
7776
|
+
if (!s || out.includes(s)) continue;
|
|
7777
|
+
out.push(s);
|
|
7778
|
+
const def = defOf(s);
|
|
7779
|
+
if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
|
|
7780
|
+
if (def.type === "pipe") {
|
|
7781
|
+
if (def.in) queue.push(def.in);
|
|
7782
|
+
if (def.out) queue.push(def.out);
|
|
7783
|
+
}
|
|
7784
|
+
}
|
|
7785
|
+
return out;
|
|
7786
|
+
}
|
|
7787
|
+
/** True when any layer of this field declares `.meta({ secret: true })`. */
|
|
7788
|
+
function isZodSecret(schema) {
|
|
7789
|
+
return layersOf(schema).some(declaredHere);
|
|
7790
|
+
}
|
|
7791
|
+
/**
|
|
7792
|
+
* Every declared secret path in a config schema: dotted keys, `[]` for "each
|
|
7793
|
+
* element of this array" (`connection.password`, `rows[].token`). A declared
|
|
7794
|
+
* object or array is reported as one path and not descended into — everything
|
|
7795
|
+
* under it is secret.
|
|
7796
|
+
*/
|
|
7797
|
+
function collectZodSecretPaths(schema, prefix = "") {
|
|
7798
|
+
if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
|
|
7799
|
+
const paths = [];
|
|
7800
|
+
for (const layer of layersOf(schema)) {
|
|
7801
|
+
const def = defOf(layer);
|
|
7802
|
+
if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
|
|
7803
|
+
else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
|
|
7804
|
+
else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
|
|
7805
|
+
else if (def.type === "intersection") {
|
|
7806
|
+
if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
|
|
7807
|
+
if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
|
|
7808
|
+
}
|
|
7809
|
+
}
|
|
7810
|
+
return [...new Set(paths)];
|
|
7811
|
+
}
|
|
7082
7812
|
//#endregion
|
|
7083
7813
|
//#region ../types/dist/err-msg-DX6i_MY4.mjs
|
|
7084
7814
|
var DeviceType = /* @__PURE__ */ function(DeviceType) {
|
|
@@ -14119,6 +14849,196 @@ id: union([string(), number()]) }), {
|
|
|
14119
14849
|
kind: "mutation",
|
|
14120
14850
|
auth: "admin"
|
|
14121
14851
|
});
|
|
14852
|
+
/**
|
|
14853
|
+
* `keychain` — the hub's encrypted store of secret values (D787).
|
|
14854
|
+
*
|
|
14855
|
+
* Settings blobs never hold a secret: they hold a marker
|
|
14856
|
+
* `{"$secret":"secret://<owner>/<scope>/<fieldPath>","v":1}` and the value
|
|
14857
|
+
* lives here, AES-256-GCM under a data key that a master key wraps. This cap
|
|
14858
|
+
* is the OWNER's door to its own values: every method is owner-checked
|
|
14859
|
+
* against the CALLER, never against anything the caller claims.
|
|
14860
|
+
*
|
|
14861
|
+
* Who the caller is: the transport stamps `callerAddonId` into the args of a
|
|
14862
|
+
* call that crossed a process (the parent `LocalChildRegistry` from the UDS
|
|
14863
|
+
* connection, the agent from its child's connection carried in
|
|
14864
|
+
* `$hub-cap-fwd`'s envelope). A stamp always overwrites; a wire call with no
|
|
14865
|
+
* stamp has its claim stripped. Only a hub in-process caller may state its own
|
|
14866
|
+
* identity — `ctx.secrets` does that with the addon id closed over. This is
|
|
14867
|
+
* identity against BUGS and misrouting, not against a malicious addon (every
|
|
14868
|
+
* runner is the same OS user): see the threat model in
|
|
14869
|
+
* `docs/design/2026-10-08-secrets-keychain.md`.
|
|
14870
|
+
*
|
|
14871
|
+
* `callerAddonId` is deliberately NOT in any input schema: the tRPC router
|
|
14872
|
+
* parses the input, so a session can never supply it, and the internal mount
|
|
14873
|
+
* floors every method to admin anyway (D240).
|
|
14874
|
+
*
|
|
14875
|
+
* Internal: addons reach it through `ctx.secrets`, never directly.
|
|
14876
|
+
*/
|
|
14877
|
+
/** Why a value cannot be served right now. Never folded into "missing". */
|
|
14878
|
+
var KeychainUnavailableReasonSchema = _enum([
|
|
14879
|
+
"key-missing",
|
|
14880
|
+
"wrong-key",
|
|
14881
|
+
"key-file-unreadable",
|
|
14882
|
+
"store-unavailable",
|
|
14883
|
+
"not-initialized",
|
|
14884
|
+
"decrypt-failed"
|
|
14885
|
+
]);
|
|
14886
|
+
var KeychainStateSchema = discriminatedUnion("state", [object({ state: literal("ready") }), object({
|
|
14887
|
+
state: literal("locked"),
|
|
14888
|
+
reason: KeychainUnavailableReasonSchema
|
|
14889
|
+
})]);
|
|
14890
|
+
var KeychainResolveEntrySchema = discriminatedUnion("kind", [
|
|
14891
|
+
object({
|
|
14892
|
+
kind: literal("value"),
|
|
14893
|
+
value: string(),
|
|
14894
|
+
version: number().int()
|
|
14895
|
+
}),
|
|
14896
|
+
object({ kind: literal("missing") }),
|
|
14897
|
+
object({
|
|
14898
|
+
kind: literal("unavailable"),
|
|
14899
|
+
reason: KeychainUnavailableReasonSchema
|
|
14900
|
+
}),
|
|
14901
|
+
object({ kind: literal("forbidden") })
|
|
14902
|
+
]);
|
|
14903
|
+
var KeychainResolveResultSchema = record(string(), KeychainResolveEntrySchema);
|
|
14904
|
+
/** Metadata of one stored value — never the value. */
|
|
14905
|
+
var KeychainSecretMetaSchema = object({
|
|
14906
|
+
ref: string(),
|
|
14907
|
+
owner: string(),
|
|
14908
|
+
/** Formatted scope (`global`, `node/<id>`, `device/<id>`, …). */
|
|
14909
|
+
scope: string(),
|
|
14910
|
+
fieldPath: string(),
|
|
14911
|
+
version: number().int(),
|
|
14912
|
+
createdAt: number(),
|
|
14913
|
+
updatedAt: number(),
|
|
14914
|
+
/** `addon:<id>` | `user:<id>` | `system`. */
|
|
14915
|
+
updatedBy: string(),
|
|
14916
|
+
/** Coarse — written at most once an hour per ref. `null` = never read. */
|
|
14917
|
+
lastReadAt: number().nullable()
|
|
14918
|
+
});
|
|
14919
|
+
var RefListSchema = array(string().min(1)).max(512);
|
|
14920
|
+
method(object({
|
|
14921
|
+
ref: string().min(1),
|
|
14922
|
+
value: string().min(1)
|
|
14923
|
+
}), object({
|
|
14924
|
+
ref: string(),
|
|
14925
|
+
version: number().int()
|
|
14926
|
+
}), {
|
|
14927
|
+
kind: "mutation",
|
|
14928
|
+
auth: "admin"
|
|
14929
|
+
}), method(object({ refs: RefListSchema }), KeychainResolveResultSchema, { auth: "admin" }), method(object({ refs: RefListSchema }), object({ deleted: number().int() }), {
|
|
14930
|
+
kind: "mutation",
|
|
14931
|
+
auth: "admin"
|
|
14932
|
+
}), method(object({}), array(KeychainSecretMetaSchema).readonly(), { auth: "admin" }), method(object({}), KeychainStateSchema, { auth: "admin" });
|
|
14933
|
+
var KeychainKeySourceSchema = object({
|
|
14934
|
+
kind: _enum([
|
|
14935
|
+
"config-file",
|
|
14936
|
+
"previous-config-file",
|
|
14937
|
+
"platform",
|
|
14938
|
+
"default-file"
|
|
14939
|
+
]),
|
|
14940
|
+
/** File sources only — a path is not a secret. */
|
|
14941
|
+
path: string().optional(),
|
|
14942
|
+
/**
|
|
14943
|
+
* True when a whole-volume backup of the data directory carries this key
|
|
14944
|
+
* next to the database it protects (the default file). The page warns.
|
|
14945
|
+
*/
|
|
14946
|
+
sharesBackupWithDatabase: boolean()
|
|
14947
|
+
});
|
|
14948
|
+
var KeychainStatusSchema = object({
|
|
14949
|
+
keychain: KeychainStateSchema,
|
|
14950
|
+
/** The source of the master key in use; `null` while locked. */
|
|
14951
|
+
keySource: KeychainKeySourceSchema.nullable(),
|
|
14952
|
+
/** The source configured to be primary — differs from `keySource` while a rotation is pending. */
|
|
14953
|
+
configuredSource: KeychainKeySourceSchema,
|
|
14954
|
+
/** Short fingerprint of the master key in use (`HMAC(KEK, label)`, 16 hex). */
|
|
14955
|
+
fingerprint: string().nullable(),
|
|
14956
|
+
activeKeyId: string().nullable(),
|
|
14957
|
+
/**
|
|
14958
|
+
* The keychain unlocked with a NON-primary source: the configured primary
|
|
14959
|
+
* key is not the one that wraps the data key yet. `rotateMasterKey` moves it.
|
|
14960
|
+
*/
|
|
14961
|
+
rotationPending: boolean(),
|
|
14962
|
+
/** Wrapped copies of the data key under a previous master key, kept until purged. */
|
|
14963
|
+
retiredWraps: number().int(),
|
|
14964
|
+
recoveryKeyDownloadedAt: number().nullable(),
|
|
14965
|
+
secretCount: number().int()
|
|
14966
|
+
});
|
|
14967
|
+
/**
|
|
14968
|
+
* Whether a stored value is still pointed at by its owner's settings.
|
|
14969
|
+
* `unknown` is a first-class answer: a scope whose blob could not be read is
|
|
14970
|
+
* never reported as an orphan (and never deleted as one).
|
|
14971
|
+
*/
|
|
14972
|
+
var KeychainSecretUsageSchema = _enum([
|
|
14973
|
+
"in-use",
|
|
14974
|
+
"orphan",
|
|
14975
|
+
"unknown"
|
|
14976
|
+
]);
|
|
14977
|
+
var KeychainAdminSecretSchema = KeychainSecretMetaSchema.extend({ usage: KeychainSecretUsageSchema });
|
|
14978
|
+
var KeychainAuditActionSchema = _enum([
|
|
14979
|
+
"put",
|
|
14980
|
+
"delete",
|
|
14981
|
+
"reveal",
|
|
14982
|
+
"rotate-master-key",
|
|
14983
|
+
"purge-retired-keys",
|
|
14984
|
+
"download-recovery-key",
|
|
14985
|
+
"delete-orphans",
|
|
14986
|
+
"reset",
|
|
14987
|
+
"initialize"
|
|
14988
|
+
]);
|
|
14989
|
+
var KeychainAuditEntrySchema = object({
|
|
14990
|
+
id: string(),
|
|
14991
|
+
at: number(),
|
|
14992
|
+
action: KeychainAuditActionSchema,
|
|
14993
|
+
/** `addon:<id>` | `user:<id>` | `system`. */
|
|
14994
|
+
actor: string(),
|
|
14995
|
+
ref: string().nullable(),
|
|
14996
|
+
detail: string().nullable()
|
|
14997
|
+
});
|
|
14998
|
+
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({
|
|
14999
|
+
value: string(),
|
|
15000
|
+
version: number().int()
|
|
15001
|
+
}), {
|
|
15002
|
+
kind: "mutation",
|
|
15003
|
+
auth: "admin",
|
|
15004
|
+
caller: "required"
|
|
15005
|
+
}), method(object({ refs: array(string().min(1)).max(1e3) }), object({
|
|
15006
|
+
deleted: array(string()).readonly(),
|
|
15007
|
+
kept: array(object({
|
|
15008
|
+
ref: string(),
|
|
15009
|
+
usage: KeychainSecretUsageSchema
|
|
15010
|
+
})).readonly()
|
|
15011
|
+
}), {
|
|
15012
|
+
kind: "mutation",
|
|
15013
|
+
auth: "admin",
|
|
15014
|
+
caller: "required"
|
|
15015
|
+
}), method(object({}), object({
|
|
15016
|
+
fingerprint: string(),
|
|
15017
|
+
keySource: KeychainKeySourceSchema
|
|
15018
|
+
}), {
|
|
15019
|
+
kind: "mutation",
|
|
15020
|
+
auth: "admin",
|
|
15021
|
+
caller: "required"
|
|
15022
|
+
}), method(object({}), object({ purged: number().int() }), {
|
|
15023
|
+
kind: "mutation",
|
|
15024
|
+
auth: "admin",
|
|
15025
|
+
caller: "required"
|
|
15026
|
+
}), method(object({}), object({
|
|
15027
|
+
key: string(),
|
|
15028
|
+
fingerprint: string(),
|
|
15029
|
+
keySource: KeychainKeySourceSchema
|
|
15030
|
+
}), {
|
|
15031
|
+
kind: "mutation",
|
|
15032
|
+
auth: "admin",
|
|
15033
|
+
caller: "required"
|
|
15034
|
+
}), method(object({ confirm: literal("RESET KEYCHAIN") }), object({
|
|
15035
|
+
archivedCollection: string().nullable(),
|
|
15036
|
+
archived: number().int()
|
|
15037
|
+
}), {
|
|
15038
|
+
kind: "mutation",
|
|
15039
|
+
auth: "admin",
|
|
15040
|
+
caller: "required"
|
|
15041
|
+
});
|
|
14122
15042
|
method(_void(), object({
|
|
14123
15043
|
id: string(),
|
|
14124
15044
|
name: string(),
|
|
@@ -15457,7 +16377,11 @@ var DeviceRegisterPayloadSchema = object({
|
|
|
15457
16377
|
var DeviceRemovePayloadSchema = object({ deviceId: number() });
|
|
15458
16378
|
var DevicePersistConfigPayloadSchema = object({
|
|
15459
16379
|
deviceId: number(),
|
|
15460
|
-
data: record(string(), unknown())
|
|
16380
|
+
data: record(string(), unknown()),
|
|
16381
|
+
/** The paths the device's schema declares secret (D783), when the caller
|
|
16382
|
+
* knows them — those values are kept in the keychain, not the blob (D787).
|
|
16383
|
+
* Absent: the paths the device last reported at `registerDevice` apply. */
|
|
16384
|
+
secretConfigPaths: array(string()).optional()
|
|
15461
16385
|
});
|
|
15462
16386
|
/** What a migration actually did, per switch. `unreachable` is a first-class
|
|
15463
16387
|
* answer: a camera that could not be asked is not a camera that was silenced. */
|
|
@@ -22474,8 +23398,23 @@ var RetrainMacroClassSchema = _enum([
|
|
|
22474
23398
|
]);
|
|
22475
23399
|
/** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
|
|
22476
23400
|
var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
|
|
22477
|
-
/**
|
|
22478
|
-
|
|
23401
|
+
/**
|
|
23402
|
+
* Where a box came from. A machine-sourced box is a DRAFT on the page until
|
|
23403
|
+
* the operator confirms it; once saved it keeps its source as provenance.
|
|
23404
|
+
*
|
|
23405
|
+
* - `operator` — drawn by hand.
|
|
23406
|
+
* - `assist` — proposed by a detector run on the copy (the camera's own
|
|
23407
|
+
* model, or a larger teacher model).
|
|
23408
|
+
* - `pipeline` — the box the live pipeline actually drew on that frame, read
|
|
23409
|
+
* back from the track store (never a re-run).
|
|
23410
|
+
* - `llm` — proposed by a vision-capable LLM profile.
|
|
23411
|
+
*/
|
|
23412
|
+
var RetrainAnnotationSourceSchema = _enum([
|
|
23413
|
+
"operator",
|
|
23414
|
+
"assist",
|
|
23415
|
+
"pipeline",
|
|
23416
|
+
"llm"
|
|
23417
|
+
]);
|
|
22479
23418
|
/** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
|
|
22480
23419
|
var RetrainBboxSchema = object({
|
|
22481
23420
|
x: number(),
|
|
@@ -22493,7 +23432,8 @@ var RetrainBboxSchema = object({
|
|
|
22493
23432
|
*/
|
|
22494
23433
|
var RetrainAnnotationSchema = object({
|
|
22495
23434
|
id: string(),
|
|
22496
|
-
|
|
23435
|
+
/** The frame's track. Absent on a recording still, which has none. */
|
|
23436
|
+
trackId: string().optional(),
|
|
22497
23437
|
deviceId: number(),
|
|
22498
23438
|
/** The COPY in retrain storage — never the source track's media key. */
|
|
22499
23439
|
mediaKey: string(),
|
|
@@ -22542,13 +23482,47 @@ var RetrainFrameCandidateSchema = object({
|
|
|
22542
23482
|
* fail, whatever became of the original. */
|
|
22543
23483
|
copied: boolean()
|
|
22544
23484
|
});
|
|
23485
|
+
/**
|
|
23486
|
+
* One box the live pipeline drew on a copied frame — what a correction starts
|
|
23487
|
+
* from. Derived when the frame is listed, from the track store: the subject
|
|
23488
|
+
* box recorded on the source media row when there is one, else the track
|
|
23489
|
+
* position nearest the frame's capture time. Never stored as an annotation
|
|
23490
|
+
* until the operator confirms it.
|
|
23491
|
+
*/
|
|
23492
|
+
var RetrainPipelineBoxSchema = object({
|
|
23493
|
+
/** Normalised `[0,1]` against the full frame. */
|
|
23494
|
+
bbox: RetrainBboxSchema,
|
|
23495
|
+
macroClass: RetrainMacroClassSchema,
|
|
23496
|
+
label: string().optional(),
|
|
23497
|
+
subLabel: string().optional(),
|
|
23498
|
+
/** The detection score of the position used, when it was recorded. */
|
|
23499
|
+
score: number().optional(),
|
|
23500
|
+
/** The root model that produced the track, when it was recorded. */
|
|
23501
|
+
modelId: string().optional(),
|
|
23502
|
+
trackId: string(),
|
|
23503
|
+
/** `subject-box`: recorded on this very frame. `position`: the track's
|
|
23504
|
+
* position nearest the capture time, `deltaMs` away. */
|
|
23505
|
+
basis: _enum(["subject-box", "position"]),
|
|
23506
|
+
deltaMs: number()
|
|
23507
|
+
});
|
|
23508
|
+
/**
|
|
23509
|
+
* Where a retrain frame came from: a TRACK's stored media (copy-on-select),
|
|
23510
|
+
* or the RECORDING at an instant — the frame a model saw nothing in has no
|
|
23511
|
+
* track at all.
|
|
23512
|
+
*/
|
|
23513
|
+
var RetrainFrameOriginSchema = _enum(["track", "recording"]);
|
|
22545
23514
|
/** A frame the dataset OWNS: bytes copied at selection time. */
|
|
22546
23515
|
var RetrainFrameSchema = object({
|
|
22547
23516
|
frameId: string(),
|
|
22548
23517
|
deviceId: number(),
|
|
22549
|
-
|
|
22550
|
-
/**
|
|
22551
|
-
|
|
23518
|
+
origin: RetrainFrameOriginSchema,
|
|
23519
|
+
/** The track it was copied from. Absent on a recording still. */
|
|
23520
|
+
trackId: string().optional(),
|
|
23521
|
+
/** Provenance only. It may already point at nothing — that is expected.
|
|
23522
|
+
* Absent on a recording still. */
|
|
23523
|
+
sourceMediaId: number().int().optional(),
|
|
23524
|
+
/** A recording still: the playhead instant it was taken at. */
|
|
23525
|
+
epochMs: number().optional(),
|
|
22552
23526
|
sourceKind: MediaFileKindEnum,
|
|
22553
23527
|
sizeBytes: number().int(),
|
|
22554
23528
|
width: number().int(),
|
|
@@ -22559,7 +23533,12 @@ var RetrainFrameSchema = object({
|
|
|
22559
23533
|
/** The operator's "every subject in this frame is boxed". Detector
|
|
22560
23534
|
* evaluation keeps only complete frames: an unboxed subject would count as
|
|
22561
23535
|
* a false positive. */
|
|
22562
|
-
complete: boolean()
|
|
23536
|
+
complete: boolean(),
|
|
23537
|
+
/** The boxes the pipeline drew on this frame. Present on list answers;
|
|
23538
|
+
* empty when nothing the track store holds can be placed on it. */
|
|
23539
|
+
pipelineBoxes: array(RetrainPipelineBoxSchema).readonly().optional(),
|
|
23540
|
+
/** The named collections this frame belongs to. Present on list answers. */
|
|
23541
|
+
collectionIds: array(string()).readonly().optional()
|
|
22563
23542
|
});
|
|
22564
23543
|
/** Why a copy-on-select could not be honoured — named, never a silent skip. */
|
|
22565
23544
|
var RetrainCopyRefusalSchema = _enum([
|
|
@@ -22590,6 +23569,8 @@ var RetrainFrameListSchema = object({
|
|
|
22590
23569
|
var RetrainExportFilterSchema = object({
|
|
22591
23570
|
deviceIds: array(number()).optional(),
|
|
22592
23571
|
frameIds: array(string()).max(2e4).optional(),
|
|
23572
|
+
/** Only frames in at least one of these named collections. */
|
|
23573
|
+
collectionIds: array(string()).max(200).optional(),
|
|
22593
23574
|
batchId: string().optional(),
|
|
22594
23575
|
/** Only frames the operator marked complete (all subjects boxed). */
|
|
22595
23576
|
completeOnly: boolean().optional()
|
|
@@ -22654,6 +23635,109 @@ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
|
|
|
22654
23635
|
reason: string(),
|
|
22655
23636
|
detail: string().optional()
|
|
22656
23637
|
})]);
|
|
23638
|
+
/** A named set over the retrain corpus — membership only, it owns no pixels. */
|
|
23639
|
+
var RetrainCollectionSchema = object({
|
|
23640
|
+
id: string(),
|
|
23641
|
+
name: string(),
|
|
23642
|
+
createdAt: number(),
|
|
23643
|
+
frameCount: number().int()
|
|
23644
|
+
});
|
|
23645
|
+
var RetrainCollectionCreateResultSchema = discriminatedUnion("kind", [object({
|
|
23646
|
+
kind: literal("created"),
|
|
23647
|
+
collection: RetrainCollectionSchema
|
|
23648
|
+
}), object({
|
|
23649
|
+
kind: literal("refused"),
|
|
23650
|
+
reason: _enum(["empty-name", "duplicate-name"])
|
|
23651
|
+
})]);
|
|
23652
|
+
var RetrainCollectionRenameResultSchema = discriminatedUnion("kind", [object({
|
|
23653
|
+
kind: literal("renamed"),
|
|
23654
|
+
collection: RetrainCollectionSchema
|
|
23655
|
+
}), object({
|
|
23656
|
+
kind: literal("refused"),
|
|
23657
|
+
reason: _enum([
|
|
23658
|
+
"empty-name",
|
|
23659
|
+
"duplicate-name",
|
|
23660
|
+
"unknown-collection"
|
|
23661
|
+
])
|
|
23662
|
+
})]);
|
|
23663
|
+
/**
|
|
23664
|
+
* The outcome of adding the frame at a recording instant. Every refusal is
|
|
23665
|
+
* named: `still-unavailable` (not recording, a gap, or an undecodable frame —
|
|
23666
|
+
* `detail` says which), `still-busy` (the recorder is at its decode bound; try
|
|
23667
|
+
* again), `unreadable-image`, `write-failed`, `unknown-collection`.
|
|
23668
|
+
*/
|
|
23669
|
+
var AddRetrainFrameFromRecordingResultSchema = discriminatedUnion("kind", [object({
|
|
23670
|
+
kind: literal("added"),
|
|
23671
|
+
collectionId: string(),
|
|
23672
|
+
frame: RetrainFrameSchema,
|
|
23673
|
+
/** The moment was already in the dataset; nothing was decoded. */
|
|
23674
|
+
reused: boolean()
|
|
23675
|
+
}), object({
|
|
23676
|
+
kind: literal("refused"),
|
|
23677
|
+
reason: _enum([
|
|
23678
|
+
"unknown-collection",
|
|
23679
|
+
"still-unavailable",
|
|
23680
|
+
"still-busy",
|
|
23681
|
+
"unreadable-image",
|
|
23682
|
+
"write-failed"
|
|
23683
|
+
]),
|
|
23684
|
+
detail: string().optional()
|
|
23685
|
+
})]);
|
|
23686
|
+
/** A vision LLM profile the AI assist may use, and where it sends the frame. */
|
|
23687
|
+
var RetrainAssistProfileSchema = object({
|
|
23688
|
+
id: string(),
|
|
23689
|
+
name: string(),
|
|
23690
|
+
model: string(),
|
|
23691
|
+
kind: string(),
|
|
23692
|
+
/** `true` when the frame would leave the house (a cloud vendor, or an
|
|
23693
|
+
* endpoint that is not on the local network). The page confirms each such
|
|
23694
|
+
* run, and the provider refuses one without `allowCloud`. */
|
|
23695
|
+
leavesHouse: boolean()
|
|
23696
|
+
});
|
|
23697
|
+
/** A box the AI assist proposed: a draft, plus the model's own reason. */
|
|
23698
|
+
var RetrainLlmProposalSchema = RetrainAnnotationDraftSchema.extend({ reason: string() });
|
|
23699
|
+
/** What the AI assist said about a box that was already on the canvas. */
|
|
23700
|
+
var RetrainLlmReviewSchema = object({
|
|
23701
|
+
/** The `ref` the page sent the box under. */
|
|
23702
|
+
ref: string(),
|
|
23703
|
+
verdict: _enum([
|
|
23704
|
+
"confirmed",
|
|
23705
|
+
"wrong-class",
|
|
23706
|
+
"not-an-object",
|
|
23707
|
+
"uncertain"
|
|
23708
|
+
]),
|
|
23709
|
+
suggestedClass: RetrainMacroClassSchema.optional(),
|
|
23710
|
+
reason: string()
|
|
23711
|
+
});
|
|
23712
|
+
/**
|
|
23713
|
+
* The AI assist's answer. `proposed` carries drafts (`source: 'llm'`, the
|
|
23714
|
+
* model and its confidence) and reviews; items the model got wrong (a box off
|
|
23715
|
+
* the frame, an unasked class, an unknown ref) are dropped and counted in
|
|
23716
|
+
* `rejected`. A whole answer that is not the schema is `malformed-answer`.
|
|
23717
|
+
*/
|
|
23718
|
+
var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
|
|
23719
|
+
kind: literal("proposed"),
|
|
23720
|
+
profileId: string(),
|
|
23721
|
+
model: string(),
|
|
23722
|
+
/** The frame was sent outside the house for this answer. */
|
|
23723
|
+
leftHouse: boolean(),
|
|
23724
|
+
proposals: array(RetrainLlmProposalSchema).readonly(),
|
|
23725
|
+
reviews: array(RetrainLlmReviewSchema).readonly(),
|
|
23726
|
+
rejected: number().int()
|
|
23727
|
+
}), object({
|
|
23728
|
+
kind: literal("refused"),
|
|
23729
|
+
reason: _enum([
|
|
23730
|
+
"unknown-frame",
|
|
23731
|
+
"unreadable-frame",
|
|
23732
|
+
"unknown-profile",
|
|
23733
|
+
"profile-disabled",
|
|
23734
|
+
"no-vision",
|
|
23735
|
+
"cloud-not-confirmed",
|
|
23736
|
+
"llm-error",
|
|
23737
|
+
"malformed-answer"
|
|
23738
|
+
]),
|
|
23739
|
+
detail: string().optional()
|
|
23740
|
+
})]);
|
|
22657
23741
|
/** The outcome of a lifecycle move owned by the retrain page. */
|
|
22658
23742
|
var RetrainTransitionResultSchema = object({
|
|
22659
23743
|
trackId: string(),
|
|
@@ -23371,7 +24455,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
23371
24455
|
auth: "admin"
|
|
23372
24456
|
}), method(object({
|
|
23373
24457
|
deviceId: number(),
|
|
23374
|
-
trackId: string(),
|
|
24458
|
+
trackId: string().optional(),
|
|
23375
24459
|
frameId: string()
|
|
23376
24460
|
}), object({
|
|
23377
24461
|
removed: boolean(),
|
|
@@ -23388,7 +24472,8 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
23388
24472
|
auth: "admin"
|
|
23389
24473
|
}), method(object({
|
|
23390
24474
|
deviceId: number(),
|
|
23391
|
-
|
|
24475
|
+
/** The frame's track, when it has one — checked against the frame. */
|
|
24476
|
+
trackId: string().optional(),
|
|
23392
24477
|
frameId: string(),
|
|
23393
24478
|
subject: RetrainAssistSubjectSchema,
|
|
23394
24479
|
/** Which node runs it. Absent ⇒ wherever an unowned call lands. */
|
|
@@ -23396,12 +24481,16 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
23396
24481
|
}), RetrainAssistResultSchema, {
|
|
23397
24482
|
kind: "mutation",
|
|
23398
24483
|
auth: "admin"
|
|
23399
|
-
}), method(object({
|
|
24484
|
+
}), method(object({
|
|
24485
|
+
trackId: string().optional(),
|
|
24486
|
+
frameIds: array(string()).max(2e3).optional()
|
|
24487
|
+
}), array(RetrainAnnotationSchema).readonly(), {
|
|
23400
24488
|
kind: "query",
|
|
23401
24489
|
auth: "admin"
|
|
23402
24490
|
}), method(object({
|
|
23403
24491
|
deviceId: number(),
|
|
23404
|
-
|
|
24492
|
+
/** The frame's track, when it has one — checked against the frame. */
|
|
24493
|
+
trackId: string().optional(),
|
|
23405
24494
|
frameId: string(),
|
|
23406
24495
|
annotations: array(RetrainAnnotationDraftSchema)
|
|
23407
24496
|
}), array(RetrainAnnotationSchema).readonly(), {
|
|
@@ -23424,7 +24513,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
23424
24513
|
auth: "admin"
|
|
23425
24514
|
}), method(object({
|
|
23426
24515
|
deviceId: number(),
|
|
23427
|
-
trackId: string(),
|
|
24516
|
+
trackId: string().optional(),
|
|
23428
24517
|
frameId: string(),
|
|
23429
24518
|
complete: boolean()
|
|
23430
24519
|
}), RetrainFrameSchema, {
|
|
@@ -23438,6 +24527,74 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
23438
24527
|
kind: "mutation",
|
|
23439
24528
|
auth: "admin",
|
|
23440
24529
|
timeoutMs: 60 * 6e4
|
|
24530
|
+
}), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
|
|
24531
|
+
kind: "query",
|
|
24532
|
+
auth: "admin"
|
|
24533
|
+
}), method(object({
|
|
24534
|
+
deviceId: number(),
|
|
24535
|
+
trackId: string().optional(),
|
|
24536
|
+
frameId: string(),
|
|
24537
|
+
profileId: string(),
|
|
24538
|
+
classes: array(RetrainMacroClassSchema).min(1),
|
|
24539
|
+
boxes: array(object({
|
|
24540
|
+
ref: string(),
|
|
24541
|
+
bbox: RetrainBboxSchema,
|
|
24542
|
+
macroClass: RetrainMacroClassSchema,
|
|
24543
|
+
label: string().optional()
|
|
24544
|
+
})).max(50),
|
|
24545
|
+
allowCloud: boolean()
|
|
24546
|
+
}), RetrainLlmAssistResultSchema, {
|
|
24547
|
+
kind: "mutation",
|
|
24548
|
+
auth: "admin",
|
|
24549
|
+
timeoutMs: 18e4
|
|
24550
|
+
}), method(object({ name: string().max(120) }), RetrainCollectionCreateResultSchema, {
|
|
24551
|
+
kind: "mutation",
|
|
24552
|
+
auth: "admin"
|
|
24553
|
+
}), method(object({}), array(RetrainCollectionSchema).readonly(), {
|
|
24554
|
+
kind: "query",
|
|
24555
|
+
auth: "admin"
|
|
24556
|
+
}), method(object({
|
|
24557
|
+
id: string(),
|
|
24558
|
+
name: string().max(120)
|
|
24559
|
+
}), RetrainCollectionRenameResultSchema, {
|
|
24560
|
+
kind: "mutation",
|
|
24561
|
+
auth: "admin"
|
|
24562
|
+
}), method(object({ id: string() }), object({
|
|
24563
|
+
deleted: boolean(),
|
|
24564
|
+
removedFrames: number().int()
|
|
24565
|
+
}), {
|
|
24566
|
+
kind: "mutation",
|
|
24567
|
+
auth: "admin"
|
|
24568
|
+
}), method(object({
|
|
24569
|
+
collectionId: string(),
|
|
24570
|
+
deviceId: number(),
|
|
24571
|
+
epochMs: number()
|
|
24572
|
+
}), AddRetrainFrameFromRecordingResultSchema, {
|
|
24573
|
+
kind: "mutation",
|
|
24574
|
+
auth: "admin",
|
|
24575
|
+
timeoutMs: 6e4
|
|
24576
|
+
}), method(object({
|
|
24577
|
+
collectionId: string(),
|
|
24578
|
+
frameIds: array(string()).min(1).max(500)
|
|
24579
|
+
}), object({
|
|
24580
|
+
added: number().int(),
|
|
24581
|
+
alreadyMember: number().int(),
|
|
24582
|
+
unknownFrameIds: array(string()).readonly()
|
|
24583
|
+
}), {
|
|
24584
|
+
kind: "mutation",
|
|
24585
|
+
auth: "admin"
|
|
24586
|
+
}), method(object({
|
|
24587
|
+
collectionId: string(),
|
|
24588
|
+
frameId: string()
|
|
24589
|
+
}), object({
|
|
24590
|
+
removed: boolean(),
|
|
24591
|
+
deletedFrame: boolean()
|
|
24592
|
+
}), {
|
|
24593
|
+
kind: "mutation",
|
|
24594
|
+
auth: "admin"
|
|
24595
|
+
}), method(object({ collectionId: string() }), array(RetrainFrameSchema).readonly(), {
|
|
24596
|
+
kind: "query",
|
|
24597
|
+
auth: "admin"
|
|
23441
24598
|
}), method(object({
|
|
23442
24599
|
/** Which of the three event tables owns the row. */
|
|
23443
24600
|
ownerType: EventOwnerTypeSchema,
|
|
@@ -24061,13 +25218,31 @@ var RecommendationReasonSchema = discriminatedUnion("kind", [
|
|
|
24061
25218
|
object({
|
|
24062
25219
|
kind: literal("no-family-build"),
|
|
24063
25220
|
format: ModelFormatSchema$1
|
|
25221
|
+
}),
|
|
25222
|
+
object({
|
|
25223
|
+
kind: literal("kept-custom-pin"),
|
|
25224
|
+
modelId: string(),
|
|
25225
|
+
deviceKey: string()
|
|
24064
25226
|
})
|
|
24065
25227
|
]);
|
|
25228
|
+
/** Why a device is left exactly as it is, whatever the plan would pick (D786). */
|
|
25229
|
+
var KeptReasonSchema = _enum(["custom-pin"]);
|
|
25230
|
+
/**
|
|
25231
|
+
* Where a choice's latency came from (D791): this node's own benchmark
|
|
25232
|
+
* result, or the hardware-class table. Measured on the node beats the table.
|
|
25233
|
+
*/
|
|
25234
|
+
var LatencySourceSchema = discriminatedUnion("kind", [object({ kind: literal("table") }), object({
|
|
25235
|
+
kind: literal("node-benchmark"),
|
|
25236
|
+
resultId: string(),
|
|
25237
|
+
measuredAtMs: number()
|
|
25238
|
+
})]);
|
|
24066
25239
|
var DeviceModelChoiceSchema = object({
|
|
24067
25240
|
modelId: string(),
|
|
24068
25241
|
p50Ms: number(),
|
|
24069
25242
|
fps: number(),
|
|
24070
25243
|
measured: boolean(),
|
|
25244
|
+
/** Absent on a plan from before D791 — read as the table. */
|
|
25245
|
+
source: LatencySourceSchema.optional(),
|
|
24071
25246
|
/** Parallel sessions at the camera rate with the headroom kept free: ⌊fps × (1 − headroom) / camera fps⌋. */
|
|
24072
25247
|
capacitySessions: number(),
|
|
24073
25248
|
personRecall: number()
|
|
@@ -24078,6 +25253,8 @@ var DeviceRecommendationSchema = object({
|
|
|
24078
25253
|
enabled: boolean(),
|
|
24079
25254
|
available: boolean(),
|
|
24080
25255
|
chosen: DeviceModelChoiceSchema.nullable(),
|
|
25256
|
+
/** Present when the device is kept as is: Apply writes nothing on it. */
|
|
25257
|
+
kept: KeptReasonSchema.optional(),
|
|
24081
25258
|
reasons: array(RecommendationReasonSchema).readonly()
|
|
24082
25259
|
});
|
|
24083
25260
|
var NodeRecommendationSchema = object({
|
|
@@ -24131,6 +25308,17 @@ var AutoTuneWarningSchema = discriminatedUnion("kind", [
|
|
|
24131
25308
|
kind: literal("coral-enabled"),
|
|
24132
25309
|
nodeId: string(),
|
|
24133
25310
|
deviceKey: string()
|
|
25311
|
+
}),
|
|
25312
|
+
object({
|
|
25313
|
+
kind: literal("custom-pin-kept"),
|
|
25314
|
+
nodeId: string(),
|
|
25315
|
+
deviceKey: string().nullable(),
|
|
25316
|
+
deviceId: number().nullable(),
|
|
25317
|
+
modelId: string()
|
|
25318
|
+
}),
|
|
25319
|
+
object({
|
|
25320
|
+
kind: literal("custom-registry-unreadable"),
|
|
25321
|
+
error: string()
|
|
24134
25322
|
})
|
|
24135
25323
|
]);
|
|
24136
25324
|
var AutoTuneOptionsSchema = object({
|
|
@@ -24309,13 +25497,14 @@ var SuggestSharesResultSchema = object({
|
|
|
24309
25497
|
nodes: array(SuggestedNodeShareSchema).readonly()
|
|
24310
25498
|
});
|
|
24311
25499
|
/**
|
|
24312
|
-
* Where the node and device shares come from (D750, D755).
|
|
24313
|
-
* - `
|
|
24314
|
-
*
|
|
24315
|
-
*
|
|
24316
|
-
*
|
|
24317
|
-
*
|
|
24318
|
-
*
|
|
25500
|
+
* Where the node and device shares come from (D750, D755, D791).
|
|
25501
|
+
* - `benchmark` (default since D791) — each node's capacity as its own node
|
|
25502
|
+
* benchmark measured it; a node without fresh results is sized from
|
|
25503
|
+
* `hardware` and says so. Measured on the node beats the table.
|
|
25504
|
+
* - `hardware` — computed from each node's static capacity only (its
|
|
25505
|
+
* accelerators at their Auto tune models, from the latency table).
|
|
25506
|
+
* Both are recomputed whenever a node or device joins, leaves, is switched
|
|
25507
|
+
* on or off, changes model, or a benchmark result is written. No load input.
|
|
24319
25508
|
* - `manual` — the operator's stored sliders.
|
|
24320
25509
|
* Either way a node or device that cannot take sessions gives its share to
|
|
24321
25510
|
* the others in proportion; the stored values are never rewritten for that.
|
|
@@ -24364,6 +25553,362 @@ var EffectiveSharesSchema = object({
|
|
|
24364
25553
|
nodeWeights: record(string(), number()),
|
|
24365
25554
|
deviceWeights: record(string(), record(string(), number()))
|
|
24366
25555
|
});
|
|
25556
|
+
/**
|
|
25557
|
+
* Wire shapes of the node benchmark (D791): the operator's plan, the
|
|
25558
|
+
* preflight the confirmation shows, the run the orchestrator owns, what the
|
|
25559
|
+
* measuring runner reports, and the result rows Auto tune and the automatic
|
|
25560
|
+
* shares read.
|
|
25561
|
+
*
|
|
25562
|
+
* ONE node at a time, owned by the pipeline orchestrator. While a run is
|
|
25563
|
+
* active the cluster is in BENCHMARK MODE for that node: it is not a
|
|
25564
|
+
* detection candidate, camera pins naming it are ignored so its sessions move
|
|
25565
|
+
* elsewhere, and both come back when the mode ends — after a crash or a hub
|
|
25566
|
+
* restart too (a persisted manifest, reconciled against the registry).
|
|
25567
|
+
*
|
|
25568
|
+
* Two measurements, both on the node, driven by its own runner (frames never
|
|
25569
|
+
* cross a process at frame rate, D9):
|
|
25570
|
+
* - `device` — one accelerator × one candidate detector, root only, open
|
|
25571
|
+
* loop: how many streams at the camera rate it carries inside the frame
|
|
25572
|
+
* interval;
|
|
25573
|
+
* - `pipeline` — the chosen detector plus the operator's detail steps
|
|
25574
|
+
* (faces, plates, classifiers, CLIP…), on varied frames from the bench
|
|
25575
|
+
* clip: how many parallel sessions the node carries before latency, drops,
|
|
25576
|
+
* CPU, RAM or the event loop give out.
|
|
25577
|
+
*/
|
|
25578
|
+
/** Defaults and bounds, one place. */
|
|
25579
|
+
var NODE_BENCHMARK_DEFAULTS = {
|
|
25580
|
+
fpsPerStream: 10,
|
|
25581
|
+
budgetMinutes: 45,
|
|
25582
|
+
minBudgetMinutes: 10,
|
|
25583
|
+
maxBudgetMinutes: 120,
|
|
25584
|
+
/** A result older than this no longer beats the table. */
|
|
25585
|
+
staleAfterDays: 30,
|
|
25586
|
+
/** Warm-in per ramp step (not accounted). */
|
|
25587
|
+
settleSec: 5,
|
|
25588
|
+
/** Accounted window per ramp step. */
|
|
25589
|
+
measureSec: 20,
|
|
25590
|
+
/** Longest the drain may take before the run is refused. */
|
|
25591
|
+
drainTimeoutSec: 120,
|
|
25592
|
+
/** Candidate models per device in one run. */
|
|
25593
|
+
maxModelsPerDevice: 6
|
|
25594
|
+
};
|
|
25595
|
+
/** The two measurements a run can make. */
|
|
25596
|
+
var NodeBenchmarkPhaseSchema = _enum(["device", "pipeline"]);
|
|
25597
|
+
var NodeBenchmarkDevicePlanSchema = object({
|
|
25598
|
+
/** `<backend>:<device>` — `openvino:npu`, `coreml:all`, `cpu`. */
|
|
25599
|
+
deviceKey: string().min(1),
|
|
25600
|
+
/**
|
|
25601
|
+
* Root detector candidates for the `device` measurement, in the order
|
|
25602
|
+
* measured. The FIRST is the one the `pipeline` measurement runs.
|
|
25603
|
+
*/
|
|
25604
|
+
modelIds: array(string().min(1)).min(1).max(NODE_BENCHMARK_DEFAULTS.maxModelsPerDevice)
|
|
25605
|
+
});
|
|
25606
|
+
/** What the operator confirmed. */
|
|
25607
|
+
var NodeBenchmarkPlanSchema = object({
|
|
25608
|
+
nodeId: string().min(1),
|
|
25609
|
+
devices: array(NodeBenchmarkDevicePlanSchema).min(1),
|
|
25610
|
+
/** Which measurements run. At least one. */
|
|
25611
|
+
phases: array(NodeBenchmarkPhaseSchema).min(1).default(["device", "pipeline"]),
|
|
25612
|
+
/**
|
|
25613
|
+
* Detail steps (catalog step ids under the root: faces, plates,
|
|
25614
|
+
* classifiers, CLIP…) the `pipeline` measurement enables. The root
|
|
25615
|
+
* detector always runs.
|
|
25616
|
+
*/
|
|
25617
|
+
steps: array(string().min(1)).default([]),
|
|
25618
|
+
/** Offered rate of one stream / session. */
|
|
25619
|
+
fpsPerStream: number().int().min(1).max(30).default(NODE_BENCHMARK_DEFAULTS.fpsPerStream),
|
|
25620
|
+
/** Hard deadline: the mode ends and the cluster is restored when it passes. */
|
|
25621
|
+
budgetMinutes: number().int().min(NODE_BENCHMARK_DEFAULTS.minBudgetMinutes).max(NODE_BENCHMARK_DEFAULTS.maxBudgetMinutes).default(NODE_BENCHMARK_DEFAULTS.budgetMinutes),
|
|
25622
|
+
/** Keep the models the run downloaded (default: delete what was not installed before). */
|
|
25623
|
+
keepDownloadedModels: boolean().default(false),
|
|
25624
|
+
/** Start although the other nodes' capacity does not cover the sessions running now. */
|
|
25625
|
+
acceptInsufficientHeadroom: boolean().default(false)
|
|
25626
|
+
});
|
|
25627
|
+
var NodeBenchmarkRefusalSchema = object({
|
|
25628
|
+
kind: _enum([
|
|
25629
|
+
"benchmark-active",
|
|
25630
|
+
"node-offline",
|
|
25631
|
+
"unknown-device",
|
|
25632
|
+
"no-phase",
|
|
25633
|
+
"insufficient-headroom"
|
|
25634
|
+
]),
|
|
25635
|
+
detail: string(),
|
|
25636
|
+
overridable: boolean()
|
|
25637
|
+
});
|
|
25638
|
+
/** A camera whose detection leaves the node for the run. */
|
|
25639
|
+
var NodeBenchmarkMovingCameraSchema = object({
|
|
25640
|
+
deviceId: number(),
|
|
25641
|
+
/** Placed on the node now (a standing attach or a running session). */
|
|
25642
|
+
placedOnNode: boolean(),
|
|
25643
|
+
/** A node pin naming this node, ignored for the run. */
|
|
25644
|
+
pinnedToNode: boolean()
|
|
25645
|
+
});
|
|
25646
|
+
/** A camera that cannot leave: no other node can obtain its frames. */
|
|
25647
|
+
var NodeBenchmarkStayingCameraSchema = object({
|
|
25648
|
+
deviceId: number(),
|
|
25649
|
+
reason: literal("only-frame-source")
|
|
25650
|
+
});
|
|
25651
|
+
var NodeBenchmarkPreflightSchema = object({
|
|
25652
|
+
nodeId: string(),
|
|
25653
|
+
online: boolean(),
|
|
25654
|
+
moving: array(NodeBenchmarkMovingCameraSchema).readonly(),
|
|
25655
|
+
/** Keep running on the node during the run; the result is flagged contaminated. */
|
|
25656
|
+
staying: array(NodeBenchmarkStayingCameraSchema).readonly(),
|
|
25657
|
+
estimatedDurationMs: number(),
|
|
25658
|
+
/** The run ends and the cluster is restored at the latest after this long. */
|
|
25659
|
+
budgetMs: number(),
|
|
25660
|
+
phases: array(NodeBenchmarkPhaseSchema).readonly(),
|
|
25661
|
+
steps: array(string()).readonly(),
|
|
25662
|
+
devices: array(NodeBenchmarkDevicePlanSchema).readonly(),
|
|
25663
|
+
/** Parallel sessions the cluster runs now, and what the other nodes can carry. */
|
|
25664
|
+
headroom: object({
|
|
25665
|
+
sessionsNow: number(),
|
|
25666
|
+
otherNodesCapacitySessions: number().nullable()
|
|
25667
|
+
}),
|
|
25668
|
+
refusals: array(NodeBenchmarkRefusalSchema).readonly(),
|
|
25669
|
+
canStart: boolean()
|
|
25670
|
+
});
|
|
25671
|
+
/** Where the measuring runner is. */
|
|
25672
|
+
var NodeBenchProgressSchema = object({
|
|
25673
|
+
phase: _enum([
|
|
25674
|
+
"preparing",
|
|
25675
|
+
"device",
|
|
25676
|
+
"pipeline",
|
|
25677
|
+
"cleanup"
|
|
25678
|
+
]),
|
|
25679
|
+
deviceKey: string().nullable(),
|
|
25680
|
+
modelId: string().nullable(),
|
|
25681
|
+
/** Streams (device) or sessions (pipeline) of the step running now. */
|
|
25682
|
+
load: number().nullable(),
|
|
25683
|
+
cellsDone: number(),
|
|
25684
|
+
cellsTotal: number(),
|
|
25685
|
+
message: string()
|
|
25686
|
+
});
|
|
25687
|
+
/** What limited a ramp. `none` = the ramp ran out of steps still passing. */
|
|
25688
|
+
var NodeBenchLimitSchema = _enum([
|
|
25689
|
+
"p95",
|
|
25690
|
+
"drops",
|
|
25691
|
+
"errors",
|
|
25692
|
+
"stall",
|
|
25693
|
+
"cpu",
|
|
25694
|
+
"ram",
|
|
25695
|
+
"none"
|
|
25696
|
+
]);
|
|
25697
|
+
var NodeBenchRampStepSchema = object({
|
|
25698
|
+
load: number(),
|
|
25699
|
+
pass: boolean(),
|
|
25700
|
+
p95Ms: number(),
|
|
25701
|
+
dropRatio: number(),
|
|
25702
|
+
/** Completed frames per second over the accounted window. */
|
|
25703
|
+
fps: number(),
|
|
25704
|
+
cpuPct: number().nullable(),
|
|
25705
|
+
ramFreePct: number().nullable(),
|
|
25706
|
+
failReasons: array(string()).readonly()
|
|
25707
|
+
});
|
|
25708
|
+
var NodeBenchCellSchema = discriminatedUnion("phase", [object({
|
|
25709
|
+
phase: literal("device"),
|
|
25710
|
+
deviceKey: string(),
|
|
25711
|
+
modelId: string(),
|
|
25712
|
+
/** Single-stream latency (the K = 1 step). */
|
|
25713
|
+
p50Ms: number(),
|
|
25714
|
+
p95Ms: number(),
|
|
25715
|
+
p99Ms: number(),
|
|
25716
|
+
/** Frames per second sustained at the last passing step. */
|
|
25717
|
+
fps: number(),
|
|
25718
|
+
/** Streams at the camera rate the device carried inside the frame interval; 0 = not even one. */
|
|
25719
|
+
kMax: number(),
|
|
25720
|
+
limitedBy: NodeBenchLimitSchema,
|
|
25721
|
+
/** First call (model load + warm-up). */
|
|
25722
|
+
warmupMs: number(),
|
|
25723
|
+
ramp: array(NodeBenchRampStepSchema).readonly()
|
|
25724
|
+
}), object({
|
|
25725
|
+
phase: literal("pipeline"),
|
|
25726
|
+
deviceKey: string(),
|
|
25727
|
+
modelId: string(),
|
|
25728
|
+
steps: array(string()).readonly(),
|
|
25729
|
+
/** Parallel sessions at the camera rate the node carried; 0 = not even one. */
|
|
25730
|
+
maxSessions: number(),
|
|
25731
|
+
limitedBy: NodeBenchLimitSchema,
|
|
25732
|
+
/** Detail steps that produced at least one result on the clip — a step that never fired measured nothing. */
|
|
25733
|
+
stepsFired: array(string()).readonly(),
|
|
25734
|
+
warmupMs: number(),
|
|
25735
|
+
ramp: array(NodeBenchRampStepSchema).readonly()
|
|
25736
|
+
})]);
|
|
25737
|
+
/**
|
|
25738
|
+
* What a result was measured ON. A result whose fingerprint no longer matches
|
|
25739
|
+
* the node no longer beats the table.
|
|
25740
|
+
*/
|
|
25741
|
+
var NodeBenchFingerprintSchema = object({
|
|
25742
|
+
pipelineVersion: string().nullable(),
|
|
25743
|
+
cpuModel: string().nullable(),
|
|
25744
|
+
ramGb: number().nullable(),
|
|
25745
|
+
os: string().nullable(),
|
|
25746
|
+
/** Per device: the pool the cells ran on (runtime + tuning). */
|
|
25747
|
+
pools: record(string(), object({
|
|
25748
|
+
runtime: string(),
|
|
25749
|
+
numWorkers: number(),
|
|
25750
|
+
concurrency: number(),
|
|
25751
|
+
batchMode: string()
|
|
25752
|
+
})).default({})
|
|
25753
|
+
});
|
|
25754
|
+
/** The frames the run used. */
|
|
25755
|
+
var NodeBenchClipSchema = object({
|
|
25756
|
+
/** `camstack-bench-v1` or `reference-images` (the fallback when the clip is not reachable). */
|
|
25757
|
+
id: string(),
|
|
25758
|
+
revision: string().nullable(),
|
|
25759
|
+
frames: number(),
|
|
25760
|
+
width: number(),
|
|
25761
|
+
height: number()
|
|
25762
|
+
});
|
|
25763
|
+
var NodeBenchRunnerInputSchema = object({
|
|
25764
|
+
runId: string().min(1),
|
|
25765
|
+
devices: array(NodeBenchmarkDevicePlanSchema).min(1),
|
|
25766
|
+
phases: array(NodeBenchmarkPhaseSchema).min(1),
|
|
25767
|
+
/** The full detail step tree root for the `pipeline` measurement is built on the node from these ids. */
|
|
25768
|
+
steps: array(string()).default([]),
|
|
25769
|
+
fpsPerStream: number().int().min(1).max(30),
|
|
25770
|
+
/** The runner stops on its own past this instant, whatever the hub does. */
|
|
25771
|
+
deadlineAtMs: number(),
|
|
25772
|
+
settleSec: number().min(0).max(60).default(NODE_BENCHMARK_DEFAULTS.settleSec),
|
|
25773
|
+
measureSec: number().min(2).max(300).default(NODE_BENCHMARK_DEFAULTS.measureSec),
|
|
25774
|
+
keepDownloadedModels: boolean().default(false)
|
|
25775
|
+
});
|
|
25776
|
+
var NodeBenchRunnerStateSchema = _enum([
|
|
25777
|
+
"running",
|
|
25778
|
+
"done",
|
|
25779
|
+
"failed",
|
|
25780
|
+
"aborted"
|
|
25781
|
+
]);
|
|
25782
|
+
var NodeBenchRunnerStatusSchema = object({
|
|
25783
|
+
runId: string(),
|
|
25784
|
+
nodeId: string(),
|
|
25785
|
+
state: NodeBenchRunnerStateSchema,
|
|
25786
|
+
progress: NodeBenchProgressSchema.nullable(),
|
|
25787
|
+
/** Every finished cell so far — a run stopped half way keeps what it measured. */
|
|
25788
|
+
cells: array(NodeBenchCellSchema).readonly(),
|
|
25789
|
+
fingerprint: NodeBenchFingerprintSchema.nullable(),
|
|
25790
|
+
clip: NodeBenchClipSchema.nullable(),
|
|
25791
|
+
/** Cameras seen running on the node during the run (they share its pools). */
|
|
25792
|
+
activeCameraIds: array(number()).readonly(),
|
|
25793
|
+
/** Models the run downloaded and then deleted (not installed before). */
|
|
25794
|
+
deletedModels: array(string()).readonly(),
|
|
25795
|
+
error: string().nullable(),
|
|
25796
|
+
startedAtMs: number(),
|
|
25797
|
+
finishedAtMs: number().nullable()
|
|
25798
|
+
});
|
|
25799
|
+
var NodeBenchmarkStateSchema = _enum([
|
|
25800
|
+
"draining",
|
|
25801
|
+
"measuring",
|
|
25802
|
+
"restoring",
|
|
25803
|
+
"done",
|
|
25804
|
+
"failed",
|
|
25805
|
+
"aborted"
|
|
25806
|
+
]);
|
|
25807
|
+
/** Why a run ended. */
|
|
25808
|
+
var NodeBenchmarkEndReasonSchema = _enum([
|
|
25809
|
+
"completed",
|
|
25810
|
+
"operator-abort",
|
|
25811
|
+
"deadline",
|
|
25812
|
+
"node-lost",
|
|
25813
|
+
"runner-lost",
|
|
25814
|
+
"hub-restart",
|
|
25815
|
+
"drain-timeout",
|
|
25816
|
+
"failed"
|
|
25817
|
+
]);
|
|
25818
|
+
var NodeBenchmarkRunSchema = object({
|
|
25819
|
+
runId: string(),
|
|
25820
|
+
nodeId: string(),
|
|
25821
|
+
state: NodeBenchmarkStateSchema,
|
|
25822
|
+
plan: NodeBenchmarkPlanSchema,
|
|
25823
|
+
startedAtMs: number(),
|
|
25824
|
+
deadlineAtMs: number(),
|
|
25825
|
+
finishedAtMs: number().nullable(),
|
|
25826
|
+
endReason: NodeBenchmarkEndReasonSchema.nullable(),
|
|
25827
|
+
error: string().nullable(),
|
|
25828
|
+
/** Cameras moved off the node for the run. */
|
|
25829
|
+
moved: array(number()).readonly(),
|
|
25830
|
+
/** Cameras that stayed (their only frame source is the node). */
|
|
25831
|
+
staying: array(number()).readonly(),
|
|
25832
|
+
/** Something else ran on the node's pools during the run. */
|
|
25833
|
+
contaminated: boolean(),
|
|
25834
|
+
progress: NodeBenchProgressSchema.nullable(),
|
|
25835
|
+
resultIds: array(string()).readonly()
|
|
25836
|
+
});
|
|
25837
|
+
/** `getNodeBenchmarkStatus`: the active run (or the last one), and whether benchmark mode is on. */
|
|
25838
|
+
var NodeBenchmarkStatusSchema = object({
|
|
25839
|
+
/** The node the cluster is in benchmark mode for; null = none. */
|
|
25840
|
+
modeNodeId: string().nullable(),
|
|
25841
|
+
run: NodeBenchmarkRunSchema.nullable()
|
|
25842
|
+
});
|
|
25843
|
+
/**
|
|
25844
|
+
* One stored measurement — the only authority Auto tune and the automatic
|
|
25845
|
+
* shares read measured capacity from. Written by the orchestrator when a run
|
|
25846
|
+
* ends, never by anyone else.
|
|
25847
|
+
*/
|
|
25848
|
+
var NodeBenchmarkResultSchema = object({
|
|
25849
|
+
id: string(),
|
|
25850
|
+
runId: string(),
|
|
25851
|
+
nodeId: string(),
|
|
25852
|
+
cell: NodeBenchCellSchema,
|
|
25853
|
+
fpsPerStream: number(),
|
|
25854
|
+
fingerprint: NodeBenchFingerprintSchema.nullable(),
|
|
25855
|
+
clip: NodeBenchClipSchema.nullable(),
|
|
25856
|
+
/** Other work shared the node's pools (a camera that could not move, or the hub's own duties). */
|
|
25857
|
+
contaminated: boolean(),
|
|
25858
|
+
stayingCameras: array(number()).readonly(),
|
|
25859
|
+
/** The run ended early; the cell itself completed. */
|
|
25860
|
+
partialRun: boolean(),
|
|
25861
|
+
measuredAtMs: number()
|
|
25862
|
+
});
|
|
25863
|
+
var ListNodeBenchmarkResultsInputSchema = object({
|
|
25864
|
+
nodeId: string().optional(),
|
|
25865
|
+
deviceKey: string().optional()
|
|
25866
|
+
});
|
|
25867
|
+
/** A result with its standing today: does it still beat the table? */
|
|
25868
|
+
var NodeBenchmarkResultViewSchema = NodeBenchmarkResultSchema.extend({
|
|
25869
|
+
/** `fresh` beats the table; `stale` falls back to it; `superseded` = a newer row covers the same cell. */
|
|
25870
|
+
standing: _enum([
|
|
25871
|
+
"fresh",
|
|
25872
|
+
"stale",
|
|
25873
|
+
"superseded"
|
|
25874
|
+
]),
|
|
25875
|
+
staleWhy: _enum([
|
|
25876
|
+
"age",
|
|
25877
|
+
"runtime",
|
|
25878
|
+
"pool-tuning"
|
|
25879
|
+
]).nullable()
|
|
25880
|
+
});
|
|
25881
|
+
object({
|
|
25882
|
+
runId: string(),
|
|
25883
|
+
nodeId: string(),
|
|
25884
|
+
startedAtMs: number(),
|
|
25885
|
+
deadlineAtMs: number(),
|
|
25886
|
+
plan: NodeBenchmarkPlanSchema,
|
|
25887
|
+
moved: array(number()).readonly(),
|
|
25888
|
+
staying: array(number()).readonly()
|
|
25889
|
+
});
|
|
25890
|
+
/** Candidate detectors per device, for the plan editor. */
|
|
25891
|
+
var NodeBenchmarkCandidatesSchema = object({
|
|
25892
|
+
nodeId: string(),
|
|
25893
|
+
reachable: boolean(),
|
|
25894
|
+
devices: array(object({
|
|
25895
|
+
deviceKey: string(),
|
|
25896
|
+
enabled: boolean(),
|
|
25897
|
+
available: boolean(),
|
|
25898
|
+
/** Ordered: what Auto tune would pick first, then the rest of the family by accuracy. */
|
|
25899
|
+
suggested: array(string()).readonly(),
|
|
25900
|
+
/** Every root detector the device has a build for. */
|
|
25901
|
+
all: array(string()).readonly(),
|
|
25902
|
+
/** The model the device runs now, when pinned. */
|
|
25903
|
+
currentModelId: string().nullable()
|
|
25904
|
+
})).readonly(),
|
|
25905
|
+
/** Detail steps the node's catalog offers under the root (for the `pipeline` measurement). */
|
|
25906
|
+
steps: array(object({
|
|
25907
|
+
id: string(),
|
|
25908
|
+
name: string(),
|
|
25909
|
+
slot: string()
|
|
25910
|
+
})).readonly()
|
|
25911
|
+
});
|
|
24367
25912
|
object({
|
|
24368
25913
|
activeCameras: number(),
|
|
24369
25914
|
throttledCameras: number(),
|
|
@@ -25492,7 +27037,16 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
|
|
|
25492
27037
|
}), ParkedTrackFrameSchema.nullable()), method(object({
|
|
25493
27038
|
deviceId: number(),
|
|
25494
27039
|
trackId: string()
|
|
25495
|
-
}), object({ released: number().int().nonnegative() }), { kind: "mutation" })
|
|
27040
|
+
}), object({ released: number().int().nonnegative() }), { kind: "mutation" }), method(NodeBenchRunnerInputSchema, object({
|
|
27041
|
+
accepted: literal(true),
|
|
27042
|
+
runId: string()
|
|
27043
|
+
}), {
|
|
27044
|
+
kind: "mutation",
|
|
27045
|
+
auth: "admin"
|
|
27046
|
+
}), method(object({ runId: string() }), NodeBenchRunnerStatusSchema.nullable(), { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
|
|
27047
|
+
kind: "mutation",
|
|
27048
|
+
auth: "admin"
|
|
27049
|
+
});
|
|
25496
27050
|
var CameraPipelineConfigSchema = object({
|
|
25497
27051
|
engine: PipelineEngineChoiceSchema.optional(),
|
|
25498
27052
|
steps: array(PipelineStepInputSchema).readonly(),
|
|
@@ -26131,6 +27685,21 @@ method(object({
|
|
|
26131
27685
|
}), method(PlacementStatsInputSchema, PlacementStatsSchema, { auth: "admin" }), method(SuggestSharesInputSchema, SuggestSharesResultSchema, { auth: "admin" }), method(_void(), EffectiveSharesSchema, { auth: "admin" }), method(SetShareSourceInputSchema, object({ success: literal(true) }), {
|
|
26132
27686
|
kind: "mutation",
|
|
26133
27687
|
auth: "admin"
|
|
27688
|
+
}), method(NodeBenchmarkPlanSchema, NodeBenchmarkPreflightSchema, { auth: "admin" }), method(NodeBenchmarkPlanSchema, discriminatedUnion("kind", [object({
|
|
27689
|
+
kind: literal("started"),
|
|
27690
|
+
runId: string()
|
|
27691
|
+
}), object({
|
|
27692
|
+
kind: literal("refused"),
|
|
27693
|
+
preflight: NodeBenchmarkPreflightSchema
|
|
27694
|
+
})]), {
|
|
27695
|
+
kind: "mutation",
|
|
27696
|
+
auth: "admin"
|
|
27697
|
+
}), method(_void(), NodeBenchmarkStatusSchema, { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
|
|
27698
|
+
kind: "mutation",
|
|
27699
|
+
auth: "admin"
|
|
27700
|
+
}), method(object({ nodeId: string() }), NodeBenchmarkCandidatesSchema, { auth: "admin" }), method(ListNodeBenchmarkResultsInputSchema, array(NodeBenchmarkResultViewSchema).readonly(), { auth: "admin" }), method(object({ id: string() }), object({ deleted: boolean() }), {
|
|
27701
|
+
kind: "mutation",
|
|
27702
|
+
auth: "admin"
|
|
26134
27703
|
}), method(object({ deviceId: number() }), CameraPipelineSettingsSchema.nullable()), method(object({
|
|
26135
27704
|
deviceId: number(),
|
|
26136
27705
|
addonId: string(),
|
|
@@ -32751,6 +34320,9 @@ var CreateIntegrationInputSchema = object({
|
|
|
32751
34320
|
enabled: boolean().optional(),
|
|
32752
34321
|
info: record(string(), unknown()).optional(),
|
|
32753
34322
|
settings: record(string(), unknown()).optional(),
|
|
34323
|
+
/** Keys of `settings` the form's schema declares secret (by type) — kept in
|
|
34324
|
+
* the keychain, not the table (D787). */
|
|
34325
|
+
secretKeys: array(string()).optional(),
|
|
32754
34326
|
skipRestart: boolean().optional()
|
|
32755
34327
|
});
|
|
32756
34328
|
var UpdateIntegrationInputSchema = object({
|
|
@@ -32774,7 +34346,9 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
|
|
|
32774
34346
|
auth: "admin"
|
|
32775
34347
|
}), method(object({ id: string() }), record(string(), unknown()), { auth: "admin" }), method(object({
|
|
32776
34348
|
id: string(),
|
|
32777
|
-
settings: record(string(), unknown())
|
|
34349
|
+
settings: record(string(), unknown()),
|
|
34350
|
+
/** Keys the form's schema declares secret (by type) — keychain-stored (D787). */
|
|
34351
|
+
secretKeys: array(string()).optional()
|
|
32778
34352
|
}), object({ success: boolean() }), {
|
|
32779
34353
|
kind: "mutation",
|
|
32780
34354
|
auth: "admin"
|
|
@@ -41399,7 +42973,8 @@ var BaseDevice = class {
|
|
|
41399
42973
|
this.role = options.role;
|
|
41400
42974
|
this.parentDeviceId = ctx.parentDeviceId;
|
|
41401
42975
|
const seedData = ctx.persistedConfig ?? {};
|
|
41402
|
-
|
|
42976
|
+
const declaredSecretPaths = collectZodSecretPaths(schema);
|
|
42977
|
+
this.config = DeviceConfig.fromSchema(schema, (data) => ctx.persistConfig(data, { secretConfigPaths: declaredSecretPaths }), seedData, ({ droppedKeys, issues }) => {
|
|
41403
42978
|
ctx.logger.warn("Device config recovery: dropping invalid persisted fields", {
|
|
41404
42979
|
tags: {
|
|
41405
42980
|
deviceId: ctx.id,
|
|
@@ -45088,6 +46663,90 @@ Object.freeze({
|
|
|
45088
46663
|
addonId: null,
|
|
45089
46664
|
access: "create"
|
|
45090
46665
|
},
|
|
46666
|
+
"keychain.delete": {
|
|
46667
|
+
capName: "keychain",
|
|
46668
|
+
capScope: "system",
|
|
46669
|
+
addonId: null,
|
|
46670
|
+
access: "delete"
|
|
46671
|
+
},
|
|
46672
|
+
"keychain.getState": {
|
|
46673
|
+
capName: "keychain",
|
|
46674
|
+
capScope: "system",
|
|
46675
|
+
addonId: null,
|
|
46676
|
+
access: "view"
|
|
46677
|
+
},
|
|
46678
|
+
"keychain.listMeta": {
|
|
46679
|
+
capName: "keychain",
|
|
46680
|
+
capScope: "system",
|
|
46681
|
+
addonId: null,
|
|
46682
|
+
access: "view"
|
|
46683
|
+
},
|
|
46684
|
+
"keychain.put": {
|
|
46685
|
+
capName: "keychain",
|
|
46686
|
+
capScope: "system",
|
|
46687
|
+
addonId: null,
|
|
46688
|
+
access: "create"
|
|
46689
|
+
},
|
|
46690
|
+
"keychain.resolve": {
|
|
46691
|
+
capName: "keychain",
|
|
46692
|
+
capScope: "system",
|
|
46693
|
+
addonId: null,
|
|
46694
|
+
access: "view"
|
|
46695
|
+
},
|
|
46696
|
+
"keychainAdmin.deleteOrphans": {
|
|
46697
|
+
capName: "keychain-admin",
|
|
46698
|
+
capScope: "system",
|
|
46699
|
+
addonId: null,
|
|
46700
|
+
access: "delete"
|
|
46701
|
+
},
|
|
46702
|
+
"keychainAdmin.downloadRecoveryKey": {
|
|
46703
|
+
capName: "keychain-admin",
|
|
46704
|
+
capScope: "system",
|
|
46705
|
+
addonId: null,
|
|
46706
|
+
access: "create"
|
|
46707
|
+
},
|
|
46708
|
+
"keychainAdmin.listAudit": {
|
|
46709
|
+
capName: "keychain-admin",
|
|
46710
|
+
capScope: "system",
|
|
46711
|
+
addonId: null,
|
|
46712
|
+
access: "view"
|
|
46713
|
+
},
|
|
46714
|
+
"keychainAdmin.listSecrets": {
|
|
46715
|
+
capName: "keychain-admin",
|
|
46716
|
+
capScope: "system",
|
|
46717
|
+
addonId: null,
|
|
46718
|
+
access: "view"
|
|
46719
|
+
},
|
|
46720
|
+
"keychainAdmin.purgeRetiredKeys": {
|
|
46721
|
+
capName: "keychain-admin",
|
|
46722
|
+
capScope: "system",
|
|
46723
|
+
addonId: null,
|
|
46724
|
+
access: "delete"
|
|
46725
|
+
},
|
|
46726
|
+
"keychainAdmin.resetKeychain": {
|
|
46727
|
+
capName: "keychain-admin",
|
|
46728
|
+
capScope: "system",
|
|
46729
|
+
addonId: null,
|
|
46730
|
+
access: "delete"
|
|
46731
|
+
},
|
|
46732
|
+
"keychainAdmin.reveal": {
|
|
46733
|
+
capName: "keychain-admin",
|
|
46734
|
+
capScope: "system",
|
|
46735
|
+
addonId: null,
|
|
46736
|
+
access: "create"
|
|
46737
|
+
},
|
|
46738
|
+
"keychainAdmin.rotateMasterKey": {
|
|
46739
|
+
capName: "keychain-admin",
|
|
46740
|
+
capScope: "system",
|
|
46741
|
+
addonId: null,
|
|
46742
|
+
access: "create"
|
|
46743
|
+
},
|
|
46744
|
+
"keychainAdmin.status": {
|
|
46745
|
+
capName: "keychain-admin",
|
|
46746
|
+
capScope: "system",
|
|
46747
|
+
addonId: null,
|
|
46748
|
+
access: "view"
|
|
46749
|
+
},
|
|
45091
46750
|
"lawnMowerControl.dock": {
|
|
45092
46751
|
capName: "lawn-mower-control",
|
|
45093
46752
|
capScope: "device",
|
|
@@ -46462,6 +48121,18 @@ Object.freeze({
|
|
|
46462
48121
|
addonId: null,
|
|
46463
48122
|
access: "create"
|
|
46464
48123
|
},
|
|
48124
|
+
"pipelineAnalytics.addRetrainFrameFromRecording": {
|
|
48125
|
+
capName: "pipeline-analytics",
|
|
48126
|
+
capScope: "device",
|
|
48127
|
+
addonId: null,
|
|
48128
|
+
access: "create"
|
|
48129
|
+
},
|
|
48130
|
+
"pipelineAnalytics.addRetrainFramesToCollection": {
|
|
48131
|
+
capName: "pipeline-analytics",
|
|
48132
|
+
capScope: "device",
|
|
48133
|
+
addonId: null,
|
|
48134
|
+
access: "create"
|
|
48135
|
+
},
|
|
46465
48136
|
"pipelineAnalytics.applyDeviceSettingsPatch": {
|
|
46466
48137
|
capName: "pipeline-analytics",
|
|
46467
48138
|
capScope: "device",
|
|
@@ -46510,12 +48181,24 @@ Object.freeze({
|
|
|
46510
48181
|
addonId: null,
|
|
46511
48182
|
access: "view"
|
|
46512
48183
|
},
|
|
48184
|
+
"pipelineAnalytics.createRetrainCollection": {
|
|
48185
|
+
capName: "pipeline-analytics",
|
|
48186
|
+
capScope: "device",
|
|
48187
|
+
addonId: null,
|
|
48188
|
+
access: "create"
|
|
48189
|
+
},
|
|
46513
48190
|
"pipelineAnalytics.deleteDeviceEvents": {
|
|
46514
48191
|
capName: "pipeline-analytics",
|
|
46515
48192
|
capScope: "device",
|
|
46516
48193
|
addonId: null,
|
|
46517
48194
|
access: "delete"
|
|
46518
48195
|
},
|
|
48196
|
+
"pipelineAnalytics.deleteRetrainCollection": {
|
|
48197
|
+
capName: "pipeline-analytics",
|
|
48198
|
+
capScope: "device",
|
|
48199
|
+
addonId: null,
|
|
48200
|
+
access: "delete"
|
|
48201
|
+
},
|
|
46519
48202
|
"pipelineAnalytics.deleteTracks": {
|
|
46520
48203
|
capName: "pipeline-analytics",
|
|
46521
48204
|
capScope: "device",
|
|
@@ -46720,6 +48403,24 @@ Object.freeze({
|
|
|
46720
48403
|
addonId: null,
|
|
46721
48404
|
access: "view"
|
|
46722
48405
|
},
|
|
48406
|
+
"pipelineAnalytics.listRetrainAssistProfiles": {
|
|
48407
|
+
capName: "pipeline-analytics",
|
|
48408
|
+
capScope: "device",
|
|
48409
|
+
addonId: null,
|
|
48410
|
+
access: "view"
|
|
48411
|
+
},
|
|
48412
|
+
"pipelineAnalytics.listRetrainCollectionFrames": {
|
|
48413
|
+
capName: "pipeline-analytics",
|
|
48414
|
+
capScope: "device",
|
|
48415
|
+
addonId: null,
|
|
48416
|
+
access: "view"
|
|
48417
|
+
},
|
|
48418
|
+
"pipelineAnalytics.listRetrainCollections": {
|
|
48419
|
+
capName: "pipeline-analytics",
|
|
48420
|
+
capScope: "device",
|
|
48421
|
+
addonId: null,
|
|
48422
|
+
access: "view"
|
|
48423
|
+
},
|
|
46723
48424
|
"pipelineAnalytics.listRetrainFrames": {
|
|
46724
48425
|
capName: "pipeline-analytics",
|
|
46725
48426
|
capScope: "device",
|
|
@@ -46768,6 +48469,12 @@ Object.freeze({
|
|
|
46768
48469
|
addonId: null,
|
|
46769
48470
|
access: "create"
|
|
46770
48471
|
},
|
|
48472
|
+
"pipelineAnalytics.proposeRetrainAnnotationsWithLlm": {
|
|
48473
|
+
capName: "pipeline-analytics",
|
|
48474
|
+
capScope: "device",
|
|
48475
|
+
addonId: null,
|
|
48476
|
+
access: "create"
|
|
48477
|
+
},
|
|
46771
48478
|
"pipelineAnalytics.pruneEvents": {
|
|
46772
48479
|
capName: "pipeline-analytics",
|
|
46773
48480
|
capScope: "device",
|
|
@@ -46822,6 +48529,18 @@ Object.freeze({
|
|
|
46822
48529
|
addonId: null,
|
|
46823
48530
|
access: "create"
|
|
46824
48531
|
},
|
|
48532
|
+
"pipelineAnalytics.removeRetrainFrameFromCollection": {
|
|
48533
|
+
capName: "pipeline-analytics",
|
|
48534
|
+
capScope: "device",
|
|
48535
|
+
addonId: null,
|
|
48536
|
+
access: "delete"
|
|
48537
|
+
},
|
|
48538
|
+
"pipelineAnalytics.renameRetrainCollection": {
|
|
48539
|
+
capName: "pipeline-analytics",
|
|
48540
|
+
capScope: "device",
|
|
48541
|
+
addonId: null,
|
|
48542
|
+
access: "create"
|
|
48543
|
+
},
|
|
46825
48544
|
"pipelineAnalytics.restageRetrainTrack": {
|
|
46826
48545
|
capName: "pipeline-analytics",
|
|
46827
48546
|
capScope: "device",
|
|
@@ -47110,6 +48829,12 @@ Object.freeze({
|
|
|
47110
48829
|
addonId: null,
|
|
47111
48830
|
access: "view"
|
|
47112
48831
|
},
|
|
48832
|
+
"pipelineOrchestrator.abortNodeBenchmark": {
|
|
48833
|
+
capName: "pipeline-orchestrator",
|
|
48834
|
+
capScope: "system",
|
|
48835
|
+
addonId: null,
|
|
48836
|
+
access: "create"
|
|
48837
|
+
},
|
|
47113
48838
|
"pipelineOrchestrator.applyAutoTune": {
|
|
47114
48839
|
capName: "pipeline-orchestrator",
|
|
47115
48840
|
capScope: "system",
|
|
@@ -47134,6 +48859,12 @@ Object.freeze({
|
|
|
47134
48859
|
addonId: null,
|
|
47135
48860
|
access: "create"
|
|
47136
48861
|
},
|
|
48862
|
+
"pipelineOrchestrator.deleteNodeBenchmarkResult": {
|
|
48863
|
+
capName: "pipeline-orchestrator",
|
|
48864
|
+
capScope: "system",
|
|
48865
|
+
addonId: null,
|
|
48866
|
+
access: "delete"
|
|
48867
|
+
},
|
|
47137
48868
|
"pipelineOrchestrator.getAgentLoad": {
|
|
47138
48869
|
capName: "pipeline-orchestrator",
|
|
47139
48870
|
capScope: "system",
|
|
@@ -47242,6 +48973,24 @@ Object.freeze({
|
|
|
47242
48973
|
addonId: null,
|
|
47243
48974
|
access: "view"
|
|
47244
48975
|
},
|
|
48976
|
+
"pipelineOrchestrator.getNodeBenchmarkCandidates": {
|
|
48977
|
+
capName: "pipeline-orchestrator",
|
|
48978
|
+
capScope: "system",
|
|
48979
|
+
addonId: null,
|
|
48980
|
+
access: "view"
|
|
48981
|
+
},
|
|
48982
|
+
"pipelineOrchestrator.getNodeBenchmarkPreflight": {
|
|
48983
|
+
capName: "pipeline-orchestrator",
|
|
48984
|
+
capScope: "system",
|
|
48985
|
+
addonId: null,
|
|
48986
|
+
access: "view"
|
|
48987
|
+
},
|
|
48988
|
+
"pipelineOrchestrator.getNodeBenchmarkStatus": {
|
|
48989
|
+
capName: "pipeline-orchestrator",
|
|
48990
|
+
capScope: "system",
|
|
48991
|
+
addonId: null,
|
|
48992
|
+
access: "view"
|
|
48993
|
+
},
|
|
47245
48994
|
"pipelineOrchestrator.getNodeInferenceDevices": {
|
|
47246
48995
|
capName: "pipeline-orchestrator",
|
|
47247
48996
|
capScope: "system",
|
|
@@ -47284,6 +49033,12 @@ Object.freeze({
|
|
|
47284
49033
|
addonId: null,
|
|
47285
49034
|
access: "view"
|
|
47286
49035
|
},
|
|
49036
|
+
"pipelineOrchestrator.listNodeBenchmarkResults": {
|
|
49037
|
+
capName: "pipeline-orchestrator",
|
|
49038
|
+
capScope: "system",
|
|
49039
|
+
addonId: null,
|
|
49040
|
+
access: "view"
|
|
49041
|
+
},
|
|
47287
49042
|
"pipelineOrchestrator.pauseForStorageMigration": {
|
|
47288
49043
|
capName: "pipeline-orchestrator",
|
|
47289
49044
|
capScope: "system",
|
|
@@ -47428,6 +49183,12 @@ Object.freeze({
|
|
|
47428
49183
|
addonId: null,
|
|
47429
49184
|
access: "create"
|
|
47430
49185
|
},
|
|
49186
|
+
"pipelineOrchestrator.startNodeBenchmark": {
|
|
49187
|
+
capName: "pipeline-orchestrator",
|
|
49188
|
+
capScope: "system",
|
|
49189
|
+
addonId: null,
|
|
49190
|
+
access: "create"
|
|
49191
|
+
},
|
|
47431
49192
|
"pipelineOrchestrator.suggestShares": {
|
|
47432
49193
|
capName: "pipeline-orchestrator",
|
|
47433
49194
|
capScope: "system",
|
|
@@ -47446,6 +49207,12 @@ Object.freeze({
|
|
|
47446
49207
|
addonId: null,
|
|
47447
49208
|
access: "create"
|
|
47448
49209
|
},
|
|
49210
|
+
"pipelineRunner.abortNodeBench": {
|
|
49211
|
+
capName: "pipeline-runner",
|
|
49212
|
+
capScope: "system",
|
|
49213
|
+
addonId: null,
|
|
49214
|
+
access: "create"
|
|
49215
|
+
},
|
|
47449
49216
|
"pipelineRunner.attachCamera": {
|
|
47450
49217
|
capName: "pipeline-runner",
|
|
47451
49218
|
capScope: "system",
|
|
@@ -47494,6 +49261,12 @@ Object.freeze({
|
|
|
47494
49261
|
addonId: null,
|
|
47495
49262
|
access: "view"
|
|
47496
49263
|
},
|
|
49264
|
+
"pipelineRunner.getNodeBenchStatus": {
|
|
49265
|
+
capName: "pipeline-runner",
|
|
49266
|
+
capScope: "system",
|
|
49267
|
+
addonId: null,
|
|
49268
|
+
access: "view"
|
|
49269
|
+
},
|
|
47497
49270
|
"pipelineRunner.getParkedTrackFrame": {
|
|
47498
49271
|
capName: "pipeline-runner",
|
|
47499
49272
|
capScope: "system",
|
|
@@ -47536,6 +49309,12 @@ Object.freeze({
|
|
|
47536
49309
|
addonId: null,
|
|
47537
49310
|
access: "create"
|
|
47538
49311
|
},
|
|
49312
|
+
"pipelineRunner.startNodeBench": {
|
|
49313
|
+
capName: "pipeline-runner",
|
|
49314
|
+
capScope: "system",
|
|
49315
|
+
addonId: null,
|
|
49316
|
+
access: "create"
|
|
49317
|
+
},
|
|
47539
49318
|
"plateGallery.assignPlate": {
|
|
47540
49319
|
capName: "plate-gallery",
|
|
47541
49320
|
capScope: "system",
|
|
@@ -52671,6 +54450,11 @@ Object.freeze({
|
|
|
52671
54450
|
form: "single",
|
|
52672
54451
|
optional: false
|
|
52673
54452
|
}],
|
|
54453
|
+
"pipelineAnalytics.addRetrainFrameFromRecording": [{
|
|
54454
|
+
name: "deviceId",
|
|
54455
|
+
form: "single",
|
|
54456
|
+
optional: false
|
|
54457
|
+
}],
|
|
52674
54458
|
"pipelineAnalytics.applyDeviceSettingsPatch": [{
|
|
52675
54459
|
name: "deviceId",
|
|
52676
54460
|
form: "single",
|
|
@@ -52861,6 +54645,11 @@ Object.freeze({
|
|
|
52861
54645
|
form: "single",
|
|
52862
54646
|
optional: false
|
|
52863
54647
|
}],
|
|
54648
|
+
"pipelineAnalytics.proposeRetrainAnnotationsWithLlm": [{
|
|
54649
|
+
name: "deviceId",
|
|
54650
|
+
form: "single",
|
|
54651
|
+
optional: false
|
|
54652
|
+
}],
|
|
52864
54653
|
"pipelineAnalytics.pruneEventsBefore": [{
|
|
52865
54654
|
name: "deviceId",
|
|
52866
54655
|
form: "single",
|