@camstack/addon-provider-dreo 0.2.122 → 0.2.123
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/addon.js +1845 -56
- package/dist/addon.mjs +1845 -56
- package/package.json +1 -1
package/dist/addon.js
CHANGED
|
@@ -35,7 +35,7 @@ var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["modu
|
|
|
35
35
|
//#endregion
|
|
36
36
|
let crypto$1 = require("crypto");
|
|
37
37
|
let events = require("events");
|
|
38
|
-
//#region ../types/dist/event-category-
|
|
38
|
+
//#region ../types/dist/event-category-DaIZi00R.mjs
|
|
39
39
|
var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
40
40
|
EventCategory["SystemBoot"] = "system.boot";
|
|
41
41
|
EventCategory["SystemAddonsReady"] = "system.addons-ready";
|
|
@@ -114,6 +114,13 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
|
114
114
|
*/
|
|
115
115
|
EventCategory["AddonLoadFailed"] = "addon.load-failed";
|
|
116
116
|
/**
|
|
117
|
+
* A keychain value was stored or removed (D787). Carries the ref, its
|
|
118
|
+
* owner and the new version — NEVER the value. A process holding the ref
|
|
119
|
+
* drops its cached copy and the owning `BaseAddon` re-resolves its config.
|
|
120
|
+
* Telemetry (D8): a process that misses it still revalidates by version.
|
|
121
|
+
*/
|
|
122
|
+
EventCategory["KeychainChanged"] = "keychain.changed";
|
|
123
|
+
/**
|
|
117
124
|
* Addon recovered from a previous failure. Emitted when an addon
|
|
118
125
|
* transitions from `failed` back to `healthy` (typically via the
|
|
119
126
|
* monitor's auto-retry loop, or after manual `addons.retryLoad`).
|
|
@@ -5406,7 +5413,7 @@ var ZodIssueCode = {
|
|
|
5406
5413
|
var ZodFirstPartyTypeKind;
|
|
5407
5414
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5408
5415
|
//#endregion
|
|
5409
|
-
//#region ../types/dist/sleep-
|
|
5416
|
+
//#region ../types/dist/sleep-Cr5YOk3m.mjs
|
|
5410
5417
|
/**
|
|
5411
5418
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5412
5419
|
* window to float samples (D455).
|
|
@@ -5485,6 +5492,97 @@ function buildAlawTable() {
|
|
|
5485
5492
|
}
|
|
5486
5493
|
buildUlawTable();
|
|
5487
5494
|
buildAlawTable();
|
|
5495
|
+
/** Is this field's stored value a credential? */
|
|
5496
|
+
function isSecretConfigField(field) {
|
|
5497
|
+
if (field.type === "password") return true;
|
|
5498
|
+
return "secret" in field && field.secret === true;
|
|
5499
|
+
}
|
|
5500
|
+
/**
|
|
5501
|
+
* Is this field's value stored in the KEYCHAIN (D787)? Every secret field is,
|
|
5502
|
+
* by its TYPE, unless it opts out with `storage: 'inline'` — never by its name.
|
|
5503
|
+
*/
|
|
5504
|
+
function isKeychainStoredField(field) {
|
|
5505
|
+
if (!isSecretConfigField(field)) return false;
|
|
5506
|
+
if (field.type === "textarea" && field.isJson === true) return false;
|
|
5507
|
+
return !("storage" in field && field.storage === "inline");
|
|
5508
|
+
}
|
|
5509
|
+
/**
|
|
5510
|
+
* What a settings blob holds where a secret used to be.
|
|
5511
|
+
*
|
|
5512
|
+
* A keychain-stored field never holds its value. It holds a self-describing
|
|
5513
|
+
* MARKER, `{"$secret":"secret://…","v":1}` — an object, never a string, so no
|
|
5514
|
+
* code can mistake it for a credential and no form can send it to a camera as
|
|
5515
|
+
* a password. The empty state is `null` / absent, never `''`.
|
|
5516
|
+
*
|
|
5517
|
+
* The same shapes travel to and from the admin UI:
|
|
5518
|
+
*
|
|
5519
|
+
* - read: `hydrateSchema` hands a secret field a {@link SecretFieldView}
|
|
5520
|
+
* (`{ $secret, v, set: true }`) or `null` — the browser learns whether a
|
|
5521
|
+
* value is set, never the value.
|
|
5522
|
+
* - write: an untouched field submits the view back unchanged (KEEP); a typed
|
|
5523
|
+
* value is a plain non-empty string (CHANGE); the Clear button submits
|
|
5524
|
+
* {@link SECRET_CLEAR} (CLEAR). `''`, `null` and the legacy redaction tokens
|
|
5525
|
+
* are KEEP — an empty string is what a defaults-fallback pushes back, and
|
|
5526
|
+
* treating it as "clear" is how a save destroyed a stored credential before.
|
|
5527
|
+
*
|
|
5528
|
+
* Pure and browser-safe.
|
|
5529
|
+
*/
|
|
5530
|
+
var SECRET_CLEAR = { $secretClear: true };
|
|
5531
|
+
/** The `'***'` token D634 redaction writes for non-admins. */
|
|
5532
|
+
var LEGACY_DEVICE_REDACTION = "***";
|
|
5533
|
+
function isRecord$1(value) {
|
|
5534
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5535
|
+
}
|
|
5536
|
+
function makeSecretMarker(ref) {
|
|
5537
|
+
return {
|
|
5538
|
+
$secret: ref,
|
|
5539
|
+
v: 1
|
|
5540
|
+
};
|
|
5541
|
+
}
|
|
5542
|
+
/** A stored marker: an object whose `$secret` is a non-empty string. */
|
|
5543
|
+
function isSecretMarker(value) {
|
|
5544
|
+
if (!isRecord$1(value)) return false;
|
|
5545
|
+
const ref = value["$secret"];
|
|
5546
|
+
return typeof ref === "string" && ref.length > 0;
|
|
5547
|
+
}
|
|
5548
|
+
function isSecretClear(value) {
|
|
5549
|
+
return isRecord$1(value) && value["$secretClear"] === true;
|
|
5550
|
+
}
|
|
5551
|
+
/**
|
|
5552
|
+
* The UI view of a stored secret field value: a marker becomes "set", inline
|
|
5553
|
+
* plaintext becomes "set (inline)", nothing becomes `null`. A value never
|
|
5554
|
+
* survives this function.
|
|
5555
|
+
*/
|
|
5556
|
+
function toSecretFieldView(stored) {
|
|
5557
|
+
if (isSecretMarker(stored)) return {
|
|
5558
|
+
$secret: stored.$secret,
|
|
5559
|
+
v: 1,
|
|
5560
|
+
set: true
|
|
5561
|
+
};
|
|
5562
|
+
if (typeof stored === "string" && stored.length > 0) return {
|
|
5563
|
+
$secret: null,
|
|
5564
|
+
v: 1,
|
|
5565
|
+
set: true,
|
|
5566
|
+
inline: true
|
|
5567
|
+
};
|
|
5568
|
+
return null;
|
|
5569
|
+
}
|
|
5570
|
+
/**
|
|
5571
|
+
* Classify an incoming value for a secret path. Only a non-empty string that is
|
|
5572
|
+
* not a redaction token sets a value; only {@link SECRET_CLEAR} clears.
|
|
5573
|
+
* Everything else — a marker (ours or anyone's), a UI view, `''`, `null`,
|
|
5574
|
+
* `undefined`, a redaction token, a non-string — keeps what is stored.
|
|
5575
|
+
*/
|
|
5576
|
+
function classifySecretWrite(incoming) {
|
|
5577
|
+
if (isSecretClear(incoming)) return { kind: "clear" };
|
|
5578
|
+
if (typeof incoming !== "string") return { kind: "keep" };
|
|
5579
|
+
if (incoming.length === 0) return { kind: "keep" };
|
|
5580
|
+
if (incoming === "__camstack_redacted__" || incoming === LEGACY_DEVICE_REDACTION) return { kind: "keep" };
|
|
5581
|
+
return {
|
|
5582
|
+
kind: "set",
|
|
5583
|
+
value: incoming
|
|
5584
|
+
};
|
|
5585
|
+
}
|
|
5488
5586
|
Object.fromEntries([
|
|
5489
5587
|
{
|
|
5490
5588
|
id: "overview",
|
|
@@ -5656,33 +5754,19 @@ Object.fromEntries([
|
|
|
5656
5754
|
function isValuelessField(field) {
|
|
5657
5755
|
return field.type === "separator" || field.type === "info" || field.type === "qr-code" || field.type === "button" || field.type === "object-array" || field.type === "widget" || field.type === "addon-action-button" || field.type === "device-action-button";
|
|
5658
5756
|
}
|
|
5659
|
-
|
|
5660
|
-
* Merge a `ConfigUISchema` with a raw `values` record into a
|
|
5661
|
-
* `ConfigUISchemaWithValues`. Used by every `get*Settings` backend endpoint
|
|
5662
|
-
* before returning to the admin UI. Groups are walked recursively.
|
|
5663
|
-
*
|
|
5664
|
-
* For each leaf field:
|
|
5665
|
-
* - structural fields (`separator`, `info`, `button`) pass through unchanged
|
|
5666
|
-
* - other fields get `value = values[key] ?? field.default ?? null`
|
|
5667
|
-
*
|
|
5668
|
-
* Unknown keys in `values` (keys not declared in the schema) are silently
|
|
5669
|
-
* ignored — they don't contribute to the output. Missing keys fall back to
|
|
5670
|
-
* the schema default or `null`. This mirrors the old backend behaviour where
|
|
5671
|
-
* `FormBuilder` rendered `values[key] ?? field.default`.
|
|
5672
|
-
*/
|
|
5673
|
-
function hydrateSchema(schema, values) {
|
|
5757
|
+
function hydrateSchema(schema, values, options = {}) {
|
|
5674
5758
|
return {
|
|
5675
5759
|
...schema.tabs ? { tabs: [...schema.tabs] } : {},
|
|
5676
5760
|
sections: schema.sections.map((section) => ({
|
|
5677
5761
|
...section,
|
|
5678
|
-
fields: section.fields.map((field) => hydrateField(field, values))
|
|
5762
|
+
fields: section.fields.map((field) => hydrateField(field, values, options))
|
|
5679
5763
|
}))
|
|
5680
5764
|
};
|
|
5681
5765
|
}
|
|
5682
|
-
function hydrateField(field, values) {
|
|
5766
|
+
function hydrateField(field, values, options) {
|
|
5683
5767
|
if (isValuelessField(field)) return field;
|
|
5684
5768
|
if (field.type === "group") {
|
|
5685
|
-
const hydratedChildren = field.fields.map((child) => hydrateField(child, values));
|
|
5769
|
+
const hydratedChildren = field.fields.map((child) => hydrateField(child, values, options));
|
|
5686
5770
|
return {
|
|
5687
5771
|
...field,
|
|
5688
5772
|
fields: hydratedChildren
|
|
@@ -5691,7 +5775,7 @@ function hydrateField(field, values) {
|
|
|
5691
5775
|
if (field.type === "sub-tabs") {
|
|
5692
5776
|
const hydratedTabs = field.tabs.map((tab) => ({
|
|
5693
5777
|
...tab,
|
|
5694
|
-
fields: tab.fields.map((child) => hydrateField(child, values))
|
|
5778
|
+
fields: tab.fields.map((child) => hydrateField(child, values, options))
|
|
5695
5779
|
}));
|
|
5696
5780
|
return {
|
|
5697
5781
|
...field,
|
|
@@ -5701,6 +5785,33 @@ function hydrateField(field, values) {
|
|
|
5701
5785
|
const key = field.key;
|
|
5702
5786
|
const storedValue = Object.prototype.hasOwnProperty.call(values, key) ? values[key] : void 0;
|
|
5703
5787
|
const defaultValue = field.default;
|
|
5788
|
+
const asView = (v) => isSecretMarker(v) || options.inlineSecretsAsViews === true && v !== void 0;
|
|
5789
|
+
if (isKeychainStoredField(field) && asView(storedValue)) return {
|
|
5790
|
+
...field,
|
|
5791
|
+
value: toSecretFieldView(storedValue)
|
|
5792
|
+
};
|
|
5793
|
+
if (isKeychainStoredField(field) && options.inlineSecretsAsViews === true) return {
|
|
5794
|
+
...field,
|
|
5795
|
+
value: null
|
|
5796
|
+
};
|
|
5797
|
+
if (field.type === "editable-array" && Array.isArray(storedValue)) {
|
|
5798
|
+
const secretItemKeys = field.itemFields.filter((item) => "key" in item && isKeychainStoredField(item)).map((item) => "key" in item ? item.key : "");
|
|
5799
|
+
if (secretItemKeys.length > 0) {
|
|
5800
|
+
const rows = storedValue.map((row) => {
|
|
5801
|
+
if (row === null || typeof row !== "object" || Array.isArray(row)) return row;
|
|
5802
|
+
const out = { ...row };
|
|
5803
|
+
for (const k of secretItemKeys) {
|
|
5804
|
+
const v = Reflect.get(row, k);
|
|
5805
|
+
if (asView(v)) out[k] = toSecretFieldView(v);
|
|
5806
|
+
}
|
|
5807
|
+
return out;
|
|
5808
|
+
});
|
|
5809
|
+
return {
|
|
5810
|
+
...field,
|
|
5811
|
+
value: rows
|
|
5812
|
+
};
|
|
5813
|
+
}
|
|
5814
|
+
}
|
|
5704
5815
|
if (field.multiple) {
|
|
5705
5816
|
const stored = Array.isArray(storedValue) ? storedValue : storedValue !== void 0 && storedValue !== null ? [storedValue] : [];
|
|
5706
5817
|
const itemFallback = field.multiple.itemDefault !== void 0 ? field.multiple.itemDefault : defaultValue !== void 0 ? defaultValue : typeOf(field) === "string" ? "" : null;
|
|
@@ -5943,6 +6054,431 @@ function projectStore(store, perNodeKeys, nodeId) {
|
|
|
5943
6054
|
}
|
|
5944
6055
|
return out;
|
|
5945
6056
|
}
|
|
6057
|
+
var GLOBAL_SCOPE = { kind: "global" };
|
|
6058
|
+
/** The scope every addon-wide (not per-node, not per-device) setting lives in. */
|
|
6059
|
+
function globalSecretScope() {
|
|
6060
|
+
return GLOBAL_SCOPE;
|
|
6061
|
+
}
|
|
6062
|
+
function encodeSegment(value) {
|
|
6063
|
+
return encodeURIComponent(value);
|
|
6064
|
+
}
|
|
6065
|
+
/**
|
|
6066
|
+
* The field path of a value inside an array item, addressed by the item's id:
|
|
6067
|
+
* `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
|
|
6068
|
+
* `providers[authentik].clientSecret`.
|
|
6069
|
+
*/
|
|
6070
|
+
function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
|
|
6071
|
+
return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
|
|
6072
|
+
}
|
|
6073
|
+
/** A write to a secret path could not be stored in the keychain, so it was refused. */
|
|
6074
|
+
var KeychainWriteRefusedError = class extends Error {
|
|
6075
|
+
fieldPath;
|
|
6076
|
+
constructor(fieldPath, cause) {
|
|
6077
|
+
super(`secret "${fieldPath}" was not saved: the keychain could not store it (${cause instanceof Error ? cause.message : String(cause)}). Nothing was written.`);
|
|
6078
|
+
this.fieldPath = fieldPath;
|
|
6079
|
+
this.name = "KeychainWriteRefusedError";
|
|
6080
|
+
}
|
|
6081
|
+
};
|
|
6082
|
+
var KEEP = { kind: "keep" };
|
|
6083
|
+
function isRecord(value) {
|
|
6084
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6085
|
+
}
|
|
6086
|
+
function defaultMintId() {
|
|
6087
|
+
return globalThis.crypto.randomUUID();
|
|
6088
|
+
}
|
|
6089
|
+
/** Every marker ref anywhere under `value`. */
|
|
6090
|
+
function collectSecretMarkerRefs(value, out = []) {
|
|
6091
|
+
if (isSecretMarker(value)) {
|
|
6092
|
+
out.push(value.$secret);
|
|
6093
|
+
return out;
|
|
6094
|
+
}
|
|
6095
|
+
if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
|
|
6096
|
+
else if (isRecord(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
|
|
6097
|
+
return out;
|
|
6098
|
+
}
|
|
6099
|
+
async function storedValueEquals(secrets, marker, candidate) {
|
|
6100
|
+
const resolved = (await secrets.resolve([marker.$secret]))[marker.$secret];
|
|
6101
|
+
return resolved?.kind === "value" && resolved.value === candidate;
|
|
6102
|
+
}
|
|
6103
|
+
async function writeLeaf(ctx, incoming, stored, fieldPath) {
|
|
6104
|
+
const intent = classifySecretWrite(incoming);
|
|
6105
|
+
const ref = ctx.secrets.ref(ctx.scope, fieldPath);
|
|
6106
|
+
const storedIsOurs = isSecretMarker(stored) && stored.$secret === ref;
|
|
6107
|
+
if (intent.kind === "keep") return KEEP;
|
|
6108
|
+
if (intent.kind === "set" && !ctx.operatorWrite && typeof stored === "string" && stored === intent.value) return KEEP;
|
|
6109
|
+
if (intent.kind === "clear") {
|
|
6110
|
+
if (storedIsOurs) ctx.deletes.push(ref);
|
|
6111
|
+
return {
|
|
6112
|
+
kind: "value",
|
|
6113
|
+
value: null
|
|
6114
|
+
};
|
|
6115
|
+
}
|
|
6116
|
+
if (storedIsOurs && await storedValueEquals(ctx.secrets, stored, intent.value)) return {
|
|
6117
|
+
kind: "value",
|
|
6118
|
+
value: stored
|
|
6119
|
+
};
|
|
6120
|
+
try {
|
|
6121
|
+
await ctx.secrets.put(ref, intent.value);
|
|
6122
|
+
} catch (err) {
|
|
6123
|
+
throw new KeychainWriteRefusedError(fieldPath, err);
|
|
6124
|
+
}
|
|
6125
|
+
return {
|
|
6126
|
+
kind: "value",
|
|
6127
|
+
value: makeSecretMarker(ref)
|
|
6128
|
+
};
|
|
6129
|
+
}
|
|
6130
|
+
/** Apply a member result onto `out`: KEEP restores the stored member, or removes it. */
|
|
6131
|
+
function applyMember(out, key, result, storedParent) {
|
|
6132
|
+
if (result.kind === "value") {
|
|
6133
|
+
out[key] = result.value;
|
|
6134
|
+
return;
|
|
6135
|
+
}
|
|
6136
|
+
if (Object.prototype.hasOwnProperty.call(storedParent, key)) out[key] = storedParent[key];
|
|
6137
|
+
else delete out[key];
|
|
6138
|
+
}
|
|
6139
|
+
async function writeMembers(ctx, children, incoming, stored, pathOf) {
|
|
6140
|
+
const out = { ...incoming };
|
|
6141
|
+
for (const [member, node] of children) applyMember(out, member, await writeNode(ctx, node, incoming[member], stored[member], pathOf(member)), stored);
|
|
6142
|
+
return out;
|
|
6143
|
+
}
|
|
6144
|
+
function rowId(row, idKey) {
|
|
6145
|
+
const raw = row[idKey];
|
|
6146
|
+
if (typeof raw === "string" && raw.length > 0) return raw;
|
|
6147
|
+
if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
|
|
6148
|
+
return null;
|
|
6149
|
+
}
|
|
6150
|
+
async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
6151
|
+
const storedRows = Array.isArray(stored) ? stored.filter(isRecord) : [];
|
|
6152
|
+
if (!Array.isArray(incoming)) {
|
|
6153
|
+
ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
|
|
6154
|
+
return {
|
|
6155
|
+
kind: "value",
|
|
6156
|
+
value: incoming
|
|
6157
|
+
};
|
|
6158
|
+
}
|
|
6159
|
+
const storedById = /* @__PURE__ */ new Map();
|
|
6160
|
+
for (const row of storedRows) {
|
|
6161
|
+
const id = rowId(row, node.idKey);
|
|
6162
|
+
if (id !== null) storedById.set(id, row);
|
|
6163
|
+
}
|
|
6164
|
+
const kept = /* @__PURE__ */ new Set();
|
|
6165
|
+
const rows = [];
|
|
6166
|
+
for (const row of incoming) {
|
|
6167
|
+
if (!isRecord(row)) {
|
|
6168
|
+
rows.push(row);
|
|
6169
|
+
continue;
|
|
6170
|
+
}
|
|
6171
|
+
const id = rowId(row, node.idKey) ?? ctx.mintId();
|
|
6172
|
+
kept.add(id);
|
|
6173
|
+
const withId = {
|
|
6174
|
+
...row,
|
|
6175
|
+
[node.idKey]: row[node.idKey] ?? id
|
|
6176
|
+
};
|
|
6177
|
+
if (rowId(withId, node.idKey) === null) withId[node.idKey] = id;
|
|
6178
|
+
const storedRow = storedById.get(id) ?? {};
|
|
6179
|
+
rows.push(await writeMembers(ctx, node.item, withId, storedRow, (member) => arrayItemFieldPath(fieldPath, id, member)));
|
|
6180
|
+
}
|
|
6181
|
+
for (const [id, row] of storedById) if (!kept.has(id)) ctx.deletes.push(...collectSecretMarkerRefs(row));
|
|
6182
|
+
return {
|
|
6183
|
+
kind: "value",
|
|
6184
|
+
value: rows
|
|
6185
|
+
};
|
|
6186
|
+
}
|
|
6187
|
+
async function writeNode(ctx, node, incoming, stored, fieldPath) {
|
|
6188
|
+
switch (node.kind) {
|
|
6189
|
+
case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
|
|
6190
|
+
case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
|
|
6191
|
+
case "object": {
|
|
6192
|
+
if (!isRecord(incoming)) {
|
|
6193
|
+
if (incoming === void 0) return KEEP;
|
|
6194
|
+
ctx.deletes.push(...collectSecretMarkerRefs(stored));
|
|
6195
|
+
return {
|
|
6196
|
+
kind: "value",
|
|
6197
|
+
value: incoming
|
|
6198
|
+
};
|
|
6199
|
+
}
|
|
6200
|
+
const storedObj = isRecord(stored) ? stored : {};
|
|
6201
|
+
return {
|
|
6202
|
+
kind: "value",
|
|
6203
|
+
value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
|
|
6204
|
+
};
|
|
6205
|
+
}
|
|
6206
|
+
}
|
|
6207
|
+
}
|
|
6208
|
+
/** Split a perNode-scoped key (`key@nodeId`). */
|
|
6209
|
+
function splitNodeKey(key) {
|
|
6210
|
+
const at = key.indexOf("@");
|
|
6211
|
+
return at <= 0 ? {
|
|
6212
|
+
base: key,
|
|
6213
|
+
nodeId: null
|
|
6214
|
+
} : {
|
|
6215
|
+
base: key.slice(0, at),
|
|
6216
|
+
nodeId: key.slice(at + 1)
|
|
6217
|
+
};
|
|
6218
|
+
}
|
|
6219
|
+
/** Rewrite a settings patch so no secret value reaches the blob. See the file doc. */
|
|
6220
|
+
async function transformSecretWrite(input) {
|
|
6221
|
+
const deletes = [];
|
|
6222
|
+
const base = {
|
|
6223
|
+
secrets: input.secrets,
|
|
6224
|
+
mintId: input.mintId ?? defaultMintId,
|
|
6225
|
+
deletes,
|
|
6226
|
+
operatorWrite: input.operatorWrite === true
|
|
6227
|
+
};
|
|
6228
|
+
const out = {};
|
|
6229
|
+
for (const [key, incoming] of Object.entries(input.patch)) {
|
|
6230
|
+
const { base: baseKey, nodeId } = splitNodeKey(key);
|
|
6231
|
+
const node = input.tree.get(baseKey);
|
|
6232
|
+
if (node === void 0) {
|
|
6233
|
+
out[key] = incoming;
|
|
6234
|
+
continue;
|
|
6235
|
+
}
|
|
6236
|
+
const scope = nodeId !== null && nodeId.length > 0 ? {
|
|
6237
|
+
kind: "node",
|
|
6238
|
+
nodeId
|
|
6239
|
+
} : input.scope ?? globalSecretScope();
|
|
6240
|
+
const result = await writeNode({
|
|
6241
|
+
...base,
|
|
6242
|
+
scope
|
|
6243
|
+
}, node, incoming, input.stored[key], baseKey);
|
|
6244
|
+
if (result.kind === "value") out[key] = result.value;
|
|
6245
|
+
}
|
|
6246
|
+
return {
|
|
6247
|
+
patch: out,
|
|
6248
|
+
afterWrite: async () => {
|
|
6249
|
+
if (deletes.length === 0) return { orphaned: [] };
|
|
6250
|
+
try {
|
|
6251
|
+
await input.secrets.delete([...new Set(deletes)]);
|
|
6252
|
+
return { orphaned: [] };
|
|
6253
|
+
} catch {
|
|
6254
|
+
return { orphaned: [...new Set(deletes)] };
|
|
6255
|
+
}
|
|
6256
|
+
}
|
|
6257
|
+
};
|
|
6258
|
+
}
|
|
6259
|
+
/**
|
|
6260
|
+
* Replace every marker in `value` with its keychain value. Returns the SAME
|
|
6261
|
+
* reference when there is no marker (no allocation, no keychain call).
|
|
6262
|
+
*/
|
|
6263
|
+
async function resolveSecretMarkers(value, secrets) {
|
|
6264
|
+
const refs = collectSecretMarkerRefs(value);
|
|
6265
|
+
if (refs.length === 0) return {
|
|
6266
|
+
value,
|
|
6267
|
+
unresolved: []
|
|
6268
|
+
};
|
|
6269
|
+
const answers = await secrets.resolve(refs);
|
|
6270
|
+
const unresolved = [];
|
|
6271
|
+
for (const ref of new Set(refs)) {
|
|
6272
|
+
const answer = answers[ref];
|
|
6273
|
+
if (answer === void 0) unresolved.push({
|
|
6274
|
+
ref,
|
|
6275
|
+
reason: "not-initialized"
|
|
6276
|
+
});
|
|
6277
|
+
else if (answer.kind === "unavailable") unresolved.push({
|
|
6278
|
+
ref,
|
|
6279
|
+
reason: answer.reason
|
|
6280
|
+
});
|
|
6281
|
+
else if (answer.kind === "missing" || answer.kind === "forbidden") unresolved.push({
|
|
6282
|
+
ref,
|
|
6283
|
+
reason: answer.kind
|
|
6284
|
+
});
|
|
6285
|
+
}
|
|
6286
|
+
const substitute = (v) => {
|
|
6287
|
+
if (isSecretMarker(v)) {
|
|
6288
|
+
const answer = answers[v.$secret];
|
|
6289
|
+
return answer?.kind === "value" ? {
|
|
6290
|
+
keep: true,
|
|
6291
|
+
value: answer.value
|
|
6292
|
+
} : {
|
|
6293
|
+
keep: false,
|
|
6294
|
+
value: void 0
|
|
6295
|
+
};
|
|
6296
|
+
}
|
|
6297
|
+
if (Array.isArray(v)) {
|
|
6298
|
+
const items = [];
|
|
6299
|
+
for (const item of v) {
|
|
6300
|
+
const s = substitute(item);
|
|
6301
|
+
if (s.keep) items.push(s.value);
|
|
6302
|
+
}
|
|
6303
|
+
return {
|
|
6304
|
+
keep: true,
|
|
6305
|
+
value: items
|
|
6306
|
+
};
|
|
6307
|
+
}
|
|
6308
|
+
if (isRecord(v)) {
|
|
6309
|
+
const out = {};
|
|
6310
|
+
for (const [k, child] of Object.entries(v)) {
|
|
6311
|
+
const s = substitute(child);
|
|
6312
|
+
if (s.keep) out[k] = s.value;
|
|
6313
|
+
}
|
|
6314
|
+
return {
|
|
6315
|
+
keep: true,
|
|
6316
|
+
value: out
|
|
6317
|
+
};
|
|
6318
|
+
}
|
|
6319
|
+
return {
|
|
6320
|
+
keep: true,
|
|
6321
|
+
value: v
|
|
6322
|
+
};
|
|
6323
|
+
};
|
|
6324
|
+
return {
|
|
6325
|
+
value: substitute(value).value,
|
|
6326
|
+
unresolved
|
|
6327
|
+
};
|
|
6328
|
+
}
|
|
6329
|
+
function touchesTree(tree, patch) {
|
|
6330
|
+
if (tree.size === 0) return false;
|
|
6331
|
+
for (const key of Object.keys(patch)) {
|
|
6332
|
+
const at = key.indexOf("@");
|
|
6333
|
+
if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
|
|
6334
|
+
}
|
|
6335
|
+
return false;
|
|
6336
|
+
}
|
|
6337
|
+
/** The blob as stored now; a failed read REFUSES the write instead of guessing. */
|
|
6338
|
+
async function readStoredAddonBlob(raw) {
|
|
6339
|
+
const threeWay = raw.readAddonStoreResult;
|
|
6340
|
+
if (threeWay === void 0) return raw.readAddonStore();
|
|
6341
|
+
const result = await threeWay.call(raw);
|
|
6342
|
+
if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
|
|
6343
|
+
return result.kind === "missing" ? {} : result.value;
|
|
6344
|
+
}
|
|
6345
|
+
function createSecretAwareSettings(raw, opts) {
|
|
6346
|
+
const chains = /* @__PURE__ */ new Map();
|
|
6347
|
+
const serialize = (key, fn) => {
|
|
6348
|
+
const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
|
|
6349
|
+
const tail = next.catch(() => void 0);
|
|
6350
|
+
chains.set(key, tail);
|
|
6351
|
+
tail.then(() => {
|
|
6352
|
+
if (chains.get(key) === tail) chains.delete(key);
|
|
6353
|
+
});
|
|
6354
|
+
return next;
|
|
6355
|
+
};
|
|
6356
|
+
const write = async (chainKey, tree, scope, patch, readStored, rawWrite) => {
|
|
6357
|
+
if (!touchesTree(tree, patch)) return rawWrite(patch);
|
|
6358
|
+
return serialize(chainKey, async () => {
|
|
6359
|
+
const stored = await readStored();
|
|
6360
|
+
const result = await transformSecretWrite({
|
|
6361
|
+
tree,
|
|
6362
|
+
secrets: opts.secrets,
|
|
6363
|
+
patch,
|
|
6364
|
+
stored,
|
|
6365
|
+
...scope !== void 0 ? { scope } : {},
|
|
6366
|
+
operatorWrite: opts.isOperatorWrite?.() === true
|
|
6367
|
+
});
|
|
6368
|
+
if (Object.keys(result.patch).length > 0) await rawWrite(result.patch);
|
|
6369
|
+
const { orphaned } = await result.afterWrite();
|
|
6370
|
+
if (orphaned.length > 0) opts.onOrphaned(orphaned);
|
|
6371
|
+
});
|
|
6372
|
+
};
|
|
6373
|
+
const wrapped = {
|
|
6374
|
+
writeAddonStore: (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p)),
|
|
6375
|
+
writeDeviceStore: (deviceId, patch) => write(`device:${deviceId}`, opts.deviceTree(), {
|
|
6376
|
+
kind: "device",
|
|
6377
|
+
deviceId
|
|
6378
|
+
}, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p))
|
|
6379
|
+
};
|
|
6380
|
+
return new Proxy(raw, { get(target, prop, receiver) {
|
|
6381
|
+
if (prop === "writeAddonStore") return wrapped.writeAddonStore;
|
|
6382
|
+
if (prop === "writeDeviceStore") return wrapped.writeDeviceStore;
|
|
6383
|
+
const value = Reflect.get(target, prop, receiver);
|
|
6384
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
6385
|
+
} });
|
|
6386
|
+
}
|
|
6387
|
+
/** The context the addon sees: identical, except that its settings writes are secret-aware. */
|
|
6388
|
+
function withSecretAwareSettings(context, opts) {
|
|
6389
|
+
const raw = context.settings;
|
|
6390
|
+
if (raw === void 0) return context;
|
|
6391
|
+
const settings = createSecretAwareSettings(raw, opts);
|
|
6392
|
+
return new Proxy(context, { get(target, prop, receiver) {
|
|
6393
|
+
if (prop === "settings") return settings;
|
|
6394
|
+
return Reflect.get(target, prop, receiver);
|
|
6395
|
+
} });
|
|
6396
|
+
}
|
|
6397
|
+
var LEAF = { kind: "leaf" };
|
|
6398
|
+
var DEFAULT_ITEM_ID_KEY = "id";
|
|
6399
|
+
function collectFields(fields, out) {
|
|
6400
|
+
for (const field of fields) {
|
|
6401
|
+
if (field.type === "group") {
|
|
6402
|
+
collectFields(field.fields, out);
|
|
6403
|
+
continue;
|
|
6404
|
+
}
|
|
6405
|
+
if (field.type === "sub-tabs") {
|
|
6406
|
+
for (const tab of field.tabs) collectFields(tab.fields, out);
|
|
6407
|
+
continue;
|
|
6408
|
+
}
|
|
6409
|
+
if (field.type === "editable-array") {
|
|
6410
|
+
const item = /* @__PURE__ */ new Map();
|
|
6411
|
+
for (const itemField of field.itemFields) if ("key" in itemField && isKeychainStoredField(itemField)) item.set(itemField.key, LEAF);
|
|
6412
|
+
if (item.size > 0) out.set(field.key, {
|
|
6413
|
+
kind: "array",
|
|
6414
|
+
idKey: field.itemIdKey ?? DEFAULT_ITEM_ID_KEY,
|
|
6415
|
+
item
|
|
6416
|
+
});
|
|
6417
|
+
continue;
|
|
6418
|
+
}
|
|
6419
|
+
if (!("key" in field) || typeof field.key !== "string") continue;
|
|
6420
|
+
if (isKeychainStoredField(field)) out.set(field.key, LEAF);
|
|
6421
|
+
}
|
|
6422
|
+
}
|
|
6423
|
+
/** The secret tree a settings schema declares. */
|
|
6424
|
+
function secretTreeFromSchema(schema) {
|
|
6425
|
+
const out = /* @__PURE__ */ new Map();
|
|
6426
|
+
if (schema === null) return out;
|
|
6427
|
+
for (const section of schema.sections) collectFields(section.fields, out);
|
|
6428
|
+
return out;
|
|
6429
|
+
}
|
|
6430
|
+
/** Parse `a.b[id].c` into segments; throws on a malformed path (a declaration bug). */
|
|
6431
|
+
function parseSecretStatePath(path) {
|
|
6432
|
+
const segments = [];
|
|
6433
|
+
for (const raw of path.split(".")) {
|
|
6434
|
+
const m = /^([^[\]]+)(?:\[([^[\]]+)\])?$/.exec(raw);
|
|
6435
|
+
if (m === null || m[1] === void 0) throw new Error(`secretStatePaths: malformed path "${path}"`);
|
|
6436
|
+
segments.push(m[2] !== void 0 ? {
|
|
6437
|
+
key: m[1],
|
|
6438
|
+
idKey: m[2]
|
|
6439
|
+
} : { key: m[1] });
|
|
6440
|
+
}
|
|
6441
|
+
if (segments.length === 0) throw new Error(`secretStatePaths: empty path`);
|
|
6442
|
+
if (segments[segments.length - 1]?.idKey !== void 0) throw new Error(`secretStatePaths: "${path}" ends on an array — name the member that is secret`);
|
|
6443
|
+
return segments;
|
|
6444
|
+
}
|
|
6445
|
+
function insert(into, segments) {
|
|
6446
|
+
const [head, ...rest] = segments;
|
|
6447
|
+
if (head === void 0) return;
|
|
6448
|
+
if (rest.length === 0) {
|
|
6449
|
+
into.set(head.key, LEAF);
|
|
6450
|
+
return;
|
|
6451
|
+
}
|
|
6452
|
+
const existing = into.get(head.key);
|
|
6453
|
+
if (head.idKey !== void 0) {
|
|
6454
|
+
const item = new Map(existing?.kind === "array" ? existing.item : []);
|
|
6455
|
+
insert(item, rest);
|
|
6456
|
+
into.set(head.key, {
|
|
6457
|
+
kind: "array",
|
|
6458
|
+
idKey: head.idKey,
|
|
6459
|
+
item
|
|
6460
|
+
});
|
|
6461
|
+
return;
|
|
6462
|
+
}
|
|
6463
|
+
const children = new Map(existing?.kind === "object" ? existing.children : []);
|
|
6464
|
+
insert(children, rest);
|
|
6465
|
+
into.set(head.key, {
|
|
6466
|
+
kind: "object",
|
|
6467
|
+
children
|
|
6468
|
+
});
|
|
6469
|
+
}
|
|
6470
|
+
/** Add hidden-state paths (`secretStatePaths`) to a schema-derived tree. */
|
|
6471
|
+
function mergeSecretStatePaths(tree, paths) {
|
|
6472
|
+
if (paths.length === 0) return tree;
|
|
6473
|
+
const out = new Map(tree);
|
|
6474
|
+
for (const path of paths) insert(out, parseSecretStatePath(path));
|
|
6475
|
+
return out;
|
|
6476
|
+
}
|
|
6477
|
+
/** First retry of a secret the keychain could not serve; doubles to {@link SECRET_RETRY_MAX_MS}. */
|
|
6478
|
+
var SECRET_RETRY_FIRST_MS = 5e3;
|
|
6479
|
+
var SECRET_RETRY_MAX_MS = 5 * 6e4;
|
|
6480
|
+
/** Coalesces a burst of `keychain.changed` events into one re-resolve. */
|
|
6481
|
+
var SECRET_CHANGE_DEBOUNCE_MS = 250;
|
|
5946
6482
|
/**
|
|
5947
6483
|
* Base class for CamStack addons. Eliminates settings boilerplate:
|
|
5948
6484
|
*
|
|
@@ -6012,6 +6548,25 @@ var BaseAddon = class {
|
|
|
6012
6548
|
settingsStoreReady = false;
|
|
6013
6549
|
/** Default config values. Provided via constructor. */
|
|
6014
6550
|
defaults;
|
|
6551
|
+
/**
|
|
6552
|
+
* Hidden-state paths that hold secrets (D787) — values the addon writes
|
|
6553
|
+
* itself (`updateGlobalSettings`, `state()`) that no form field declares.
|
|
6554
|
+
* Stored in the keychain exactly like a `password` field. Syntax:
|
|
6555
|
+
* `'snapshotSigningKey'`, `'identity.pincode'`, `'tokens[userId].accessToken'`
|
|
6556
|
+
* (`key[<id field>]` addresses array items by id, never by index).
|
|
6557
|
+
*/
|
|
6558
|
+
secretStatePaths = [];
|
|
6559
|
+
_addonSecretTree = null;
|
|
6560
|
+
_deviceSecretTree = null;
|
|
6561
|
+
/** Refs the last resolved config pointed at — a change to one re-resolves. */
|
|
6562
|
+
_configSecretRefs = /* @__PURE__ */ new Set();
|
|
6563
|
+
_unresolvedSecrets = [];
|
|
6564
|
+
_secretRetryTimer = null;
|
|
6565
|
+
_secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
|
|
6566
|
+
_secretChangeTimer = null;
|
|
6567
|
+
_secretChangeUnsub = null;
|
|
6568
|
+
/** >0 while an OPERATOR's settings write is being applied. */
|
|
6569
|
+
_operatorWriteDepth = 0;
|
|
6015
6570
|
constructor(defaults) {
|
|
6016
6571
|
this.defaults = defaults;
|
|
6017
6572
|
this._config = { ...defaults };
|
|
@@ -6047,8 +6602,18 @@ var BaseAddon = class {
|
|
|
6047
6602
|
return this._config;
|
|
6048
6603
|
}
|
|
6049
6604
|
async initialize(context) {
|
|
6050
|
-
|
|
6605
|
+
const secrets = context.secrets;
|
|
6606
|
+
this._ctx = secrets !== void 0 ? withSecretAwareSettings(context, {
|
|
6607
|
+
secrets,
|
|
6608
|
+
addonTree: () => this.addonSecretTree(),
|
|
6609
|
+
deviceTree: () => this.deviceSecretTree(),
|
|
6610
|
+
onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
|
|
6611
|
+
isOperatorWrite: () => this._operatorWriteDepth > 0
|
|
6612
|
+
}) : context;
|
|
6051
6613
|
await this.resolveConfig();
|
|
6614
|
+
if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
|
|
6615
|
+
if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
|
|
6616
|
+
});
|
|
6052
6617
|
const result = await this.onInitialize();
|
|
6053
6618
|
this.emitLifecycle(EventCategory.AddonStarted);
|
|
6054
6619
|
const normalized = normalizeAddonInitResult(result);
|
|
@@ -6081,6 +6646,12 @@ var BaseAddon = class {
|
|
|
6081
6646
|
*/
|
|
6082
6647
|
async onHubReachable() {}
|
|
6083
6648
|
async shutdown() {
|
|
6649
|
+
this._secretChangeUnsub?.();
|
|
6650
|
+
this._secretChangeUnsub = null;
|
|
6651
|
+
if (this._secretRetryTimer !== null) clearTimeout(this._secretRetryTimer);
|
|
6652
|
+
if (this._secretChangeTimer !== null) clearTimeout(this._secretChangeTimer);
|
|
6653
|
+
this._secretRetryTimer = null;
|
|
6654
|
+
this._secretChangeTimer = null;
|
|
6084
6655
|
this.emitLifecycle(EventCategory.AddonStopped);
|
|
6085
6656
|
if (this.autoEmitReadiness) this.emitReadinessForProviders("down");
|
|
6086
6657
|
await this.onShutdown();
|
|
@@ -6159,7 +6730,7 @@ var BaseAddon = class {
|
|
|
6159
6730
|
return hydrateSchema(schema, overlay ? {
|
|
6160
6731
|
...projected,
|
|
6161
6732
|
...overlay
|
|
6162
|
-
} : projected);
|
|
6733
|
+
} : projected, { inlineSecretsAsViews: true });
|
|
6163
6734
|
}
|
|
6164
6735
|
/**
|
|
6165
6736
|
* The integration-level view of this addon's settings: exactly the sections
|
|
@@ -6208,7 +6779,7 @@ var BaseAddon = class {
|
|
|
6208
6779
|
return hydrateSchema({
|
|
6209
6780
|
...schema,
|
|
6210
6781
|
sections
|
|
6211
|
-
}, projected);
|
|
6782
|
+
}, projected, { inlineSecretsAsViews: true });
|
|
6212
6783
|
}
|
|
6213
6784
|
/**
|
|
6214
6785
|
* The raw addon store PROJECTED onto the target node's bare per-node keys:
|
|
@@ -6262,18 +6833,50 @@ var BaseAddon = class {
|
|
|
6262
6833
|
value: result.value[key]
|
|
6263
6834
|
};
|
|
6264
6835
|
}
|
|
6836
|
+
/**
|
|
6837
|
+
* The OPERATOR's write — a settings form or an admin API call, dispatched by
|
|
6838
|
+
* the kernel. Identical to {@link updateGlobalSettings}, except that a secret
|
|
6839
|
+
* the operator sends is stored as sent even when it equals a pre-keychain
|
|
6840
|
+
* inline value: the operator re-entering a password is a change, an addon
|
|
6841
|
+
* writing back what it read is not (D787).
|
|
6842
|
+
*/
|
|
6843
|
+
async updateGlobalSettingsAsOperator(patch, nodeId) {
|
|
6844
|
+
this._operatorWriteDepth++;
|
|
6845
|
+
try {
|
|
6846
|
+
await this.applyGlobalPatch(patch, nodeId);
|
|
6847
|
+
} finally {
|
|
6848
|
+
this._operatorWriteDepth--;
|
|
6849
|
+
}
|
|
6850
|
+
}
|
|
6265
6851
|
async updateGlobalSettings(patch, nodeId) {
|
|
6852
|
+
await this.applyGlobalPatch(patch, nodeId);
|
|
6853
|
+
}
|
|
6854
|
+
/**
|
|
6855
|
+
* REMOVE stored secrets — their keychain values and their markers (D787).
|
|
6856
|
+
*
|
|
6857
|
+
* Writing `''` to a secret field KEEPS what is stored (an empty string is
|
|
6858
|
+
* what a defaults fallback writes back, and it must never destroy a
|
|
6859
|
+
* credential), so code that means "forget this token" says so here. Without
|
|
6860
|
+
* a keychain (an older kernel) it writes `''`, as such code always did.
|
|
6861
|
+
*/
|
|
6862
|
+
async clearSecrets(keys, nodeId) {
|
|
6863
|
+
const tree = this.addonSecretTree();
|
|
6864
|
+
const keychain = this._ctx?.secrets !== void 0;
|
|
6865
|
+
const patch = {};
|
|
6866
|
+
for (const key of keys) patch[key] = keychain && tree.has(key) ? SECRET_CLEAR : "";
|
|
6867
|
+
await this.applyGlobalPatch(patch, nodeId);
|
|
6868
|
+
}
|
|
6869
|
+
async applyGlobalPatch(barePatch, nodeId) {
|
|
6266
6870
|
const keys = this.perNodeKeys();
|
|
6267
6871
|
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
6268
6872
|
const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
6269
|
-
const barePatch = patch;
|
|
6270
6873
|
const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
|
|
6271
6874
|
await this._ctx?.settings?.writeAddonStore(scoped);
|
|
6272
6875
|
if (target !== localNode) return;
|
|
6273
6876
|
await this.resolveConfig();
|
|
6274
6877
|
await this.onConfigChanged();
|
|
6275
6878
|
this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
|
|
6276
|
-
this.maybeAutoRestart(
|
|
6879
|
+
this.maybeAutoRestart(Object.keys(barePatch), this.globalSettingsSchema());
|
|
6277
6880
|
}
|
|
6278
6881
|
/**
|
|
6279
6882
|
* The set of field keys the global settings schema declares `perNode: true`
|
|
@@ -6298,7 +6901,7 @@ var BaseAddon = class {
|
|
|
6298
6901
|
* time to return its response before the addon is torn down and
|
|
6299
6902
|
* re-initialised by `AddonRegistryService.restartAddon`.
|
|
6300
6903
|
*/
|
|
6301
|
-
maybeAutoRestart(
|
|
6904
|
+
maybeAutoRestart(patchKeys, schema) {
|
|
6302
6905
|
if (!schema) return;
|
|
6303
6906
|
const restartKeys = /* @__PURE__ */ new Set();
|
|
6304
6907
|
for (const section of schema.sections) for (const field of section.fields) {
|
|
@@ -6306,13 +6909,13 @@ var BaseAddon = class {
|
|
|
6306
6909
|
if (field.requiresRestart) restartKeys.add(field.key);
|
|
6307
6910
|
}
|
|
6308
6911
|
if (restartKeys.size === 0) return;
|
|
6309
|
-
if (!
|
|
6912
|
+
if (!patchKeys.some((k) => restartKeys.has(k))) return;
|
|
6310
6913
|
const ctx = this._ctx;
|
|
6311
6914
|
if (!ctx) return;
|
|
6312
6915
|
const addonId = ctx.id;
|
|
6313
6916
|
setImmediate(() => {
|
|
6314
6917
|
ctx.api.addons?.restartAddon?.mutate({ addonId }).then(() => {
|
|
6315
|
-
ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields:
|
|
6918
|
+
ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
|
|
6316
6919
|
}).catch((err) => {
|
|
6317
6920
|
ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
6318
6921
|
});
|
|
@@ -6321,7 +6924,7 @@ var BaseAddon = class {
|
|
|
6321
6924
|
async getDeviceSettings(deviceId) {
|
|
6322
6925
|
const schema = this.deviceSettingsSchema();
|
|
6323
6926
|
if (!schema) return { sections: [] };
|
|
6324
|
-
return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {});
|
|
6927
|
+
return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
|
|
6325
6928
|
}
|
|
6326
6929
|
async updateDeviceSettings(deviceId, patch) {
|
|
6327
6930
|
await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
|
|
@@ -6451,7 +7054,7 @@ var BaseAddon = class {
|
|
|
6451
7054
|
* selection at boot (absent scoped key ⇒ the constructor default wins).
|
|
6452
7055
|
*/
|
|
6453
7056
|
async resolveConfig() {
|
|
6454
|
-
const stored = await this.readAddonStoreWithRetry();
|
|
7057
|
+
const stored = await this.resolveStoredSecrets(await this.readAddonStoreWithRetry());
|
|
6455
7058
|
const perNode = this.perNodeKeys();
|
|
6456
7059
|
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
6457
7060
|
const resolved = { ...this.defaults };
|
|
@@ -6476,7 +7079,7 @@ var BaseAddon = class {
|
|
|
6476
7079
|
key,
|
|
6477
7080
|
schema,
|
|
6478
7081
|
fallback,
|
|
6479
|
-
read: () => this.readAddonStoreWithRetry(),
|
|
7082
|
+
read: async () => this.resolveStoredSecrets(await this.readAddonStoreWithRetry()),
|
|
6480
7083
|
write: async (patch) => {
|
|
6481
7084
|
await this._ctx?.settings?.writeAddonStore(patch);
|
|
6482
7085
|
},
|
|
@@ -6493,7 +7096,7 @@ var BaseAddon = class {
|
|
|
6493
7096
|
key,
|
|
6494
7097
|
schema,
|
|
6495
7098
|
fallback,
|
|
6496
|
-
read: async () => await this._ctx?.settings?.readDeviceStore(deviceId) ?? {},
|
|
7099
|
+
read: async () => this.resolveStoredSecrets(await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, false),
|
|
6497
7100
|
write: async (patch) => {
|
|
6498
7101
|
await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
|
|
6499
7102
|
},
|
|
@@ -6505,6 +7108,70 @@ var BaseAddon = class {
|
|
|
6505
7108
|
} })
|
|
6506
7109
|
});
|
|
6507
7110
|
}
|
|
7111
|
+
/** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
|
|
7112
|
+
addonSecretTree() {
|
|
7113
|
+
this._addonSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.globalSettingsSchema()), this.secretStatePaths);
|
|
7114
|
+
return this._addonSecretTree;
|
|
7115
|
+
}
|
|
7116
|
+
deviceSecretTree() {
|
|
7117
|
+
this._deviceSecretTree ??= secretTreeFromSchema(this.deviceSettingsSchema());
|
|
7118
|
+
return this._deviceSecretTree;
|
|
7119
|
+
}
|
|
7120
|
+
/**
|
|
7121
|
+
* Secrets of this addon's stored config that could not be resolved on the
|
|
7122
|
+
* last read, with why. Non-empty means the addon is running WITHOUT them —
|
|
7123
|
+
* an addon whose function needs one should report itself degraded rather
|
|
7124
|
+
* than start on an empty credential.
|
|
7125
|
+
*/
|
|
7126
|
+
get unresolvedSecrets() {
|
|
7127
|
+
return this._unresolvedSecrets;
|
|
7128
|
+
}
|
|
7129
|
+
/**
|
|
7130
|
+
* Substitute every keychain marker in a stored blob with its value. With no
|
|
7131
|
+
* keychain (no `ctx.secrets`) or no marker, the blob comes back unchanged.
|
|
7132
|
+
* An unresolvable value is LEFT OUT (never `''`), logged by ref — never by
|
|
7133
|
+
* value — and, when the cause can pass, retried with backoff. Nothing is
|
|
7134
|
+
* ever written back from here.
|
|
7135
|
+
*/
|
|
7136
|
+
async resolveStoredSecrets(blob, trackForConfig = true) {
|
|
7137
|
+
const secrets = this._ctx?.secrets;
|
|
7138
|
+
if (secrets === void 0) return blob;
|
|
7139
|
+
const refs = collectSecretMarkerRefs(blob);
|
|
7140
|
+
if (trackForConfig) this._configSecretRefs = new Set(refs);
|
|
7141
|
+
if (refs.length === 0) {
|
|
7142
|
+
if (trackForConfig) this._unresolvedSecrets = [];
|
|
7143
|
+
return blob;
|
|
7144
|
+
}
|
|
7145
|
+
const { value, unresolved } = await resolveSecretMarkers(blob, secrets);
|
|
7146
|
+
if (trackForConfig) {
|
|
7147
|
+
this._unresolvedSecrets = unresolved;
|
|
7148
|
+
if (unresolved.length > 0) {
|
|
7149
|
+
this._ctx?.logger?.error?.("secret unavailable — running without it, will retry", { meta: { secrets: unresolved.map((u) => ({
|
|
7150
|
+
ref: u.ref,
|
|
7151
|
+
reason: u.reason
|
|
7152
|
+
})) } });
|
|
7153
|
+
if (unresolved.some((u) => u.reason !== "missing" && u.reason !== "forbidden")) {
|
|
7154
|
+
this.scheduleSecretReresolve(this._secretRetryDelayMs);
|
|
7155
|
+
this._secretRetryDelayMs = Math.min(this._secretRetryDelayMs * 2, SECRET_RETRY_MAX_MS);
|
|
7156
|
+
}
|
|
7157
|
+
} else this._secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
|
|
7158
|
+
}
|
|
7159
|
+
return value;
|
|
7160
|
+
}
|
|
7161
|
+
/** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
|
|
7162
|
+
scheduleSecretReresolve(delayMs) {
|
|
7163
|
+
const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
|
|
7164
|
+
if (this[timerOf] !== null) return;
|
|
7165
|
+
const timer = setTimeout(() => {
|
|
7166
|
+
this[timerOf] = null;
|
|
7167
|
+
if (this._ctx === null) return;
|
|
7168
|
+
this.resolveConfig().then(() => this.onConfigChanged()).catch((err) => {
|
|
7169
|
+
this._ctx?.logger?.error?.("re-resolving secrets failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
7170
|
+
});
|
|
7171
|
+
}, delayMs);
|
|
7172
|
+
timer.unref?.();
|
|
7173
|
+
this[timerOf] = timer;
|
|
7174
|
+
}
|
|
6508
7175
|
/**
|
|
6509
7176
|
* Wrap `ctx.settings.readAddonStore()` with a short retry budget so a
|
|
6510
7177
|
* transient settings-store outage (mid-restart of sqlite-settings, tsx-watch
|
|
@@ -7080,6 +7747,69 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
|
|
|
7080
7747
|
kind: "mutation",
|
|
7081
7748
|
auth: "admin"
|
|
7082
7749
|
}), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
|
|
7750
|
+
function defOf(schema) {
|
|
7751
|
+
return schema._zod?.def ?? {};
|
|
7752
|
+
}
|
|
7753
|
+
function declaredHere(schema) {
|
|
7754
|
+
return globalRegistry.get(schema)?.secret === true;
|
|
7755
|
+
}
|
|
7756
|
+
/** Wrapper kinds whose `innerType` is the field itself. */
|
|
7757
|
+
var WRAPPERS = new Set([
|
|
7758
|
+
"optional",
|
|
7759
|
+
"nullable",
|
|
7760
|
+
"default",
|
|
7761
|
+
"prefault",
|
|
7762
|
+
"catch",
|
|
7763
|
+
"readonly",
|
|
7764
|
+
"nonoptional"
|
|
7765
|
+
]);
|
|
7766
|
+
/**
|
|
7767
|
+
* The schema layers that make up ONE field: the schema itself and every
|
|
7768
|
+
* wrapper below it (optional / default / nullable / readonly / catch), plus
|
|
7769
|
+
* both sides of a pipe (`z.preprocess` puts the real schema on `out`,
|
|
7770
|
+
* `.transform` on `in`).
|
|
7771
|
+
*/
|
|
7772
|
+
function layersOf(schema) {
|
|
7773
|
+
const out = [];
|
|
7774
|
+
const queue = [schema];
|
|
7775
|
+
while (queue.length > 0) {
|
|
7776
|
+
const s = queue.shift();
|
|
7777
|
+
if (!s || out.includes(s)) continue;
|
|
7778
|
+
out.push(s);
|
|
7779
|
+
const def = defOf(s);
|
|
7780
|
+
if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
|
|
7781
|
+
if (def.type === "pipe") {
|
|
7782
|
+
if (def.in) queue.push(def.in);
|
|
7783
|
+
if (def.out) queue.push(def.out);
|
|
7784
|
+
}
|
|
7785
|
+
}
|
|
7786
|
+
return out;
|
|
7787
|
+
}
|
|
7788
|
+
/** True when any layer of this field declares `.meta({ secret: true })`. */
|
|
7789
|
+
function isZodSecret(schema) {
|
|
7790
|
+
return layersOf(schema).some(declaredHere);
|
|
7791
|
+
}
|
|
7792
|
+
/**
|
|
7793
|
+
* Every declared secret path in a config schema: dotted keys, `[]` for "each
|
|
7794
|
+
* element of this array" (`connection.password`, `rows[].token`). A declared
|
|
7795
|
+
* object or array is reported as one path and not descended into — everything
|
|
7796
|
+
* under it is secret.
|
|
7797
|
+
*/
|
|
7798
|
+
function collectZodSecretPaths(schema, prefix = "") {
|
|
7799
|
+
if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
|
|
7800
|
+
const paths = [];
|
|
7801
|
+
for (const layer of layersOf(schema)) {
|
|
7802
|
+
const def = defOf(layer);
|
|
7803
|
+
if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
|
|
7804
|
+
else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
|
|
7805
|
+
else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
|
|
7806
|
+
else if (def.type === "intersection") {
|
|
7807
|
+
if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
|
|
7808
|
+
if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
|
|
7809
|
+
}
|
|
7810
|
+
}
|
|
7811
|
+
return [...new Set(paths)];
|
|
7812
|
+
}
|
|
7083
7813
|
//#endregion
|
|
7084
7814
|
//#region ../types/dist/err-msg-DX6i_MY4.mjs
|
|
7085
7815
|
var DeviceType = /* @__PURE__ */ function(DeviceType) {
|
|
@@ -14110,6 +14840,196 @@ id: union([string(), number()]) }), {
|
|
|
14110
14840
|
kind: "mutation",
|
|
14111
14841
|
auth: "admin"
|
|
14112
14842
|
});
|
|
14843
|
+
/**
|
|
14844
|
+
* `keychain` — the hub's encrypted store of secret values (D787).
|
|
14845
|
+
*
|
|
14846
|
+
* Settings blobs never hold a secret: they hold a marker
|
|
14847
|
+
* `{"$secret":"secret://<owner>/<scope>/<fieldPath>","v":1}` and the value
|
|
14848
|
+
* lives here, AES-256-GCM under a data key that a master key wraps. This cap
|
|
14849
|
+
* is the OWNER's door to its own values: every method is owner-checked
|
|
14850
|
+
* against the CALLER, never against anything the caller claims.
|
|
14851
|
+
*
|
|
14852
|
+
* Who the caller is: the transport stamps `callerAddonId` into the args of a
|
|
14853
|
+
* call that crossed a process (the parent `LocalChildRegistry` from the UDS
|
|
14854
|
+
* connection, the agent from its child's connection carried in
|
|
14855
|
+
* `$hub-cap-fwd`'s envelope). A stamp always overwrites; a wire call with no
|
|
14856
|
+
* stamp has its claim stripped. Only a hub in-process caller may state its own
|
|
14857
|
+
* identity — `ctx.secrets` does that with the addon id closed over. This is
|
|
14858
|
+
* identity against BUGS and misrouting, not against a malicious addon (every
|
|
14859
|
+
* runner is the same OS user): see the threat model in
|
|
14860
|
+
* `docs/design/2026-10-08-secrets-keychain.md`.
|
|
14861
|
+
*
|
|
14862
|
+
* `callerAddonId` is deliberately NOT in any input schema: the tRPC router
|
|
14863
|
+
* parses the input, so a session can never supply it, and the internal mount
|
|
14864
|
+
* floors every method to admin anyway (D240).
|
|
14865
|
+
*
|
|
14866
|
+
* Internal: addons reach it through `ctx.secrets`, never directly.
|
|
14867
|
+
*/
|
|
14868
|
+
/** Why a value cannot be served right now. Never folded into "missing". */
|
|
14869
|
+
var KeychainUnavailableReasonSchema = _enum([
|
|
14870
|
+
"key-missing",
|
|
14871
|
+
"wrong-key",
|
|
14872
|
+
"key-file-unreadable",
|
|
14873
|
+
"store-unavailable",
|
|
14874
|
+
"not-initialized",
|
|
14875
|
+
"decrypt-failed"
|
|
14876
|
+
]);
|
|
14877
|
+
var KeychainStateSchema = discriminatedUnion("state", [object({ state: literal("ready") }), object({
|
|
14878
|
+
state: literal("locked"),
|
|
14879
|
+
reason: KeychainUnavailableReasonSchema
|
|
14880
|
+
})]);
|
|
14881
|
+
var KeychainResolveEntrySchema = discriminatedUnion("kind", [
|
|
14882
|
+
object({
|
|
14883
|
+
kind: literal("value"),
|
|
14884
|
+
value: string(),
|
|
14885
|
+
version: number().int()
|
|
14886
|
+
}),
|
|
14887
|
+
object({ kind: literal("missing") }),
|
|
14888
|
+
object({
|
|
14889
|
+
kind: literal("unavailable"),
|
|
14890
|
+
reason: KeychainUnavailableReasonSchema
|
|
14891
|
+
}),
|
|
14892
|
+
object({ kind: literal("forbidden") })
|
|
14893
|
+
]);
|
|
14894
|
+
var KeychainResolveResultSchema = record(string(), KeychainResolveEntrySchema);
|
|
14895
|
+
/** Metadata of one stored value — never the value. */
|
|
14896
|
+
var KeychainSecretMetaSchema = object({
|
|
14897
|
+
ref: string(),
|
|
14898
|
+
owner: string(),
|
|
14899
|
+
/** Formatted scope (`global`, `node/<id>`, `device/<id>`, …). */
|
|
14900
|
+
scope: string(),
|
|
14901
|
+
fieldPath: string(),
|
|
14902
|
+
version: number().int(),
|
|
14903
|
+
createdAt: number(),
|
|
14904
|
+
updatedAt: number(),
|
|
14905
|
+
/** `addon:<id>` | `user:<id>` | `system`. */
|
|
14906
|
+
updatedBy: string(),
|
|
14907
|
+
/** Coarse — written at most once an hour per ref. `null` = never read. */
|
|
14908
|
+
lastReadAt: number().nullable()
|
|
14909
|
+
});
|
|
14910
|
+
var RefListSchema = array(string().min(1)).max(512);
|
|
14911
|
+
method(object({
|
|
14912
|
+
ref: string().min(1),
|
|
14913
|
+
value: string().min(1)
|
|
14914
|
+
}), object({
|
|
14915
|
+
ref: string(),
|
|
14916
|
+
version: number().int()
|
|
14917
|
+
}), {
|
|
14918
|
+
kind: "mutation",
|
|
14919
|
+
auth: "admin"
|
|
14920
|
+
}), method(object({ refs: RefListSchema }), KeychainResolveResultSchema, { auth: "admin" }), method(object({ refs: RefListSchema }), object({ deleted: number().int() }), {
|
|
14921
|
+
kind: "mutation",
|
|
14922
|
+
auth: "admin"
|
|
14923
|
+
}), method(object({}), array(KeychainSecretMetaSchema).readonly(), { auth: "admin" }), method(object({}), KeychainStateSchema, { auth: "admin" });
|
|
14924
|
+
var KeychainKeySourceSchema = object({
|
|
14925
|
+
kind: _enum([
|
|
14926
|
+
"config-file",
|
|
14927
|
+
"previous-config-file",
|
|
14928
|
+
"platform",
|
|
14929
|
+
"default-file"
|
|
14930
|
+
]),
|
|
14931
|
+
/** File sources only — a path is not a secret. */
|
|
14932
|
+
path: string().optional(),
|
|
14933
|
+
/**
|
|
14934
|
+
* True when a whole-volume backup of the data directory carries this key
|
|
14935
|
+
* next to the database it protects (the default file). The page warns.
|
|
14936
|
+
*/
|
|
14937
|
+
sharesBackupWithDatabase: boolean()
|
|
14938
|
+
});
|
|
14939
|
+
var KeychainStatusSchema = object({
|
|
14940
|
+
keychain: KeychainStateSchema,
|
|
14941
|
+
/** The source of the master key in use; `null` while locked. */
|
|
14942
|
+
keySource: KeychainKeySourceSchema.nullable(),
|
|
14943
|
+
/** The source configured to be primary — differs from `keySource` while a rotation is pending. */
|
|
14944
|
+
configuredSource: KeychainKeySourceSchema,
|
|
14945
|
+
/** Short fingerprint of the master key in use (`HMAC(KEK, label)`, 16 hex). */
|
|
14946
|
+
fingerprint: string().nullable(),
|
|
14947
|
+
activeKeyId: string().nullable(),
|
|
14948
|
+
/**
|
|
14949
|
+
* The keychain unlocked with a NON-primary source: the configured primary
|
|
14950
|
+
* key is not the one that wraps the data key yet. `rotateMasterKey` moves it.
|
|
14951
|
+
*/
|
|
14952
|
+
rotationPending: boolean(),
|
|
14953
|
+
/** Wrapped copies of the data key under a previous master key, kept until purged. */
|
|
14954
|
+
retiredWraps: number().int(),
|
|
14955
|
+
recoveryKeyDownloadedAt: number().nullable(),
|
|
14956
|
+
secretCount: number().int()
|
|
14957
|
+
});
|
|
14958
|
+
/**
|
|
14959
|
+
* Whether a stored value is still pointed at by its owner's settings.
|
|
14960
|
+
* `unknown` is a first-class answer: a scope whose blob could not be read is
|
|
14961
|
+
* never reported as an orphan (and never deleted as one).
|
|
14962
|
+
*/
|
|
14963
|
+
var KeychainSecretUsageSchema = _enum([
|
|
14964
|
+
"in-use",
|
|
14965
|
+
"orphan",
|
|
14966
|
+
"unknown"
|
|
14967
|
+
]);
|
|
14968
|
+
var KeychainAdminSecretSchema = KeychainSecretMetaSchema.extend({ usage: KeychainSecretUsageSchema });
|
|
14969
|
+
var KeychainAuditActionSchema = _enum([
|
|
14970
|
+
"put",
|
|
14971
|
+
"delete",
|
|
14972
|
+
"reveal",
|
|
14973
|
+
"rotate-master-key",
|
|
14974
|
+
"purge-retired-keys",
|
|
14975
|
+
"download-recovery-key",
|
|
14976
|
+
"delete-orphans",
|
|
14977
|
+
"reset",
|
|
14978
|
+
"initialize"
|
|
14979
|
+
]);
|
|
14980
|
+
var KeychainAuditEntrySchema = object({
|
|
14981
|
+
id: string(),
|
|
14982
|
+
at: number(),
|
|
14983
|
+
action: KeychainAuditActionSchema,
|
|
14984
|
+
/** `addon:<id>` | `user:<id>` | `system`. */
|
|
14985
|
+
actor: string(),
|
|
14986
|
+
ref: string().nullable(),
|
|
14987
|
+
detail: string().nullable()
|
|
14988
|
+
});
|
|
14989
|
+
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({
|
|
14990
|
+
value: string(),
|
|
14991
|
+
version: number().int()
|
|
14992
|
+
}), {
|
|
14993
|
+
kind: "mutation",
|
|
14994
|
+
auth: "admin",
|
|
14995
|
+
caller: "required"
|
|
14996
|
+
}), method(object({ refs: array(string().min(1)).max(1e3) }), object({
|
|
14997
|
+
deleted: array(string()).readonly(),
|
|
14998
|
+
kept: array(object({
|
|
14999
|
+
ref: string(),
|
|
15000
|
+
usage: KeychainSecretUsageSchema
|
|
15001
|
+
})).readonly()
|
|
15002
|
+
}), {
|
|
15003
|
+
kind: "mutation",
|
|
15004
|
+
auth: "admin",
|
|
15005
|
+
caller: "required"
|
|
15006
|
+
}), method(object({}), object({
|
|
15007
|
+
fingerprint: string(),
|
|
15008
|
+
keySource: KeychainKeySourceSchema
|
|
15009
|
+
}), {
|
|
15010
|
+
kind: "mutation",
|
|
15011
|
+
auth: "admin",
|
|
15012
|
+
caller: "required"
|
|
15013
|
+
}), method(object({}), object({ purged: number().int() }), {
|
|
15014
|
+
kind: "mutation",
|
|
15015
|
+
auth: "admin",
|
|
15016
|
+
caller: "required"
|
|
15017
|
+
}), method(object({}), object({
|
|
15018
|
+
key: string(),
|
|
15019
|
+
fingerprint: string(),
|
|
15020
|
+
keySource: KeychainKeySourceSchema
|
|
15021
|
+
}), {
|
|
15022
|
+
kind: "mutation",
|
|
15023
|
+
auth: "admin",
|
|
15024
|
+
caller: "required"
|
|
15025
|
+
}), method(object({ confirm: literal("RESET KEYCHAIN") }), object({
|
|
15026
|
+
archivedCollection: string().nullable(),
|
|
15027
|
+
archived: number().int()
|
|
15028
|
+
}), {
|
|
15029
|
+
kind: "mutation",
|
|
15030
|
+
auth: "admin",
|
|
15031
|
+
caller: "required"
|
|
15032
|
+
});
|
|
14113
15033
|
method(_void(), object({
|
|
14114
15034
|
id: string(),
|
|
14115
15035
|
name: string(),
|
|
@@ -15352,7 +16272,11 @@ var DeviceRegisterPayloadSchema = object({
|
|
|
15352
16272
|
var DeviceRemovePayloadSchema = object({ deviceId: number() });
|
|
15353
16273
|
var DevicePersistConfigPayloadSchema = object({
|
|
15354
16274
|
deviceId: number(),
|
|
15355
|
-
data: record(string(), unknown())
|
|
16275
|
+
data: record(string(), unknown()),
|
|
16276
|
+
/** The paths the device's schema declares secret (D783), when the caller
|
|
16277
|
+
* knows them — those values are kept in the keychain, not the blob (D787).
|
|
16278
|
+
* Absent: the paths the device last reported at `registerDevice` apply. */
|
|
16279
|
+
secretConfigPaths: array(string()).optional()
|
|
15356
16280
|
});
|
|
15357
16281
|
/** What a migration actually did, per switch. `unreachable` is a first-class
|
|
15358
16282
|
* answer: a camera that could not be asked is not a camera that was silenced. */
|
|
@@ -22369,8 +23293,23 @@ var RetrainMacroClassSchema = _enum([
|
|
|
22369
23293
|
]);
|
|
22370
23294
|
/** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
|
|
22371
23295
|
var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
|
|
22372
|
-
/**
|
|
22373
|
-
|
|
23296
|
+
/**
|
|
23297
|
+
* Where a box came from. A machine-sourced box is a DRAFT on the page until
|
|
23298
|
+
* the operator confirms it; once saved it keeps its source as provenance.
|
|
23299
|
+
*
|
|
23300
|
+
* - `operator` — drawn by hand.
|
|
23301
|
+
* - `assist` — proposed by a detector run on the copy (the camera's own
|
|
23302
|
+
* model, or a larger teacher model).
|
|
23303
|
+
* - `pipeline` — the box the live pipeline actually drew on that frame, read
|
|
23304
|
+
* back from the track store (never a re-run).
|
|
23305
|
+
* - `llm` — proposed by a vision-capable LLM profile.
|
|
23306
|
+
*/
|
|
23307
|
+
var RetrainAnnotationSourceSchema = _enum([
|
|
23308
|
+
"operator",
|
|
23309
|
+
"assist",
|
|
23310
|
+
"pipeline",
|
|
23311
|
+
"llm"
|
|
23312
|
+
]);
|
|
22374
23313
|
/** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
|
|
22375
23314
|
var RetrainBboxSchema = object({
|
|
22376
23315
|
x: number(),
|
|
@@ -22388,7 +23327,8 @@ var RetrainBboxSchema = object({
|
|
|
22388
23327
|
*/
|
|
22389
23328
|
var RetrainAnnotationSchema = object({
|
|
22390
23329
|
id: string(),
|
|
22391
|
-
|
|
23330
|
+
/** The frame's track. Absent on a recording still, which has none. */
|
|
23331
|
+
trackId: string().optional(),
|
|
22392
23332
|
deviceId: number(),
|
|
22393
23333
|
/** The COPY in retrain storage — never the source track's media key. */
|
|
22394
23334
|
mediaKey: string(),
|
|
@@ -22437,13 +23377,47 @@ var RetrainFrameCandidateSchema = object({
|
|
|
22437
23377
|
* fail, whatever became of the original. */
|
|
22438
23378
|
copied: boolean()
|
|
22439
23379
|
});
|
|
23380
|
+
/**
|
|
23381
|
+
* One box the live pipeline drew on a copied frame — what a correction starts
|
|
23382
|
+
* from. Derived when the frame is listed, from the track store: the subject
|
|
23383
|
+
* box recorded on the source media row when there is one, else the track
|
|
23384
|
+
* position nearest the frame's capture time. Never stored as an annotation
|
|
23385
|
+
* until the operator confirms it.
|
|
23386
|
+
*/
|
|
23387
|
+
var RetrainPipelineBoxSchema = object({
|
|
23388
|
+
/** Normalised `[0,1]` against the full frame. */
|
|
23389
|
+
bbox: RetrainBboxSchema,
|
|
23390
|
+
macroClass: RetrainMacroClassSchema,
|
|
23391
|
+
label: string().optional(),
|
|
23392
|
+
subLabel: string().optional(),
|
|
23393
|
+
/** The detection score of the position used, when it was recorded. */
|
|
23394
|
+
score: number().optional(),
|
|
23395
|
+
/** The root model that produced the track, when it was recorded. */
|
|
23396
|
+
modelId: string().optional(),
|
|
23397
|
+
trackId: string(),
|
|
23398
|
+
/** `subject-box`: recorded on this very frame. `position`: the track's
|
|
23399
|
+
* position nearest the capture time, `deltaMs` away. */
|
|
23400
|
+
basis: _enum(["subject-box", "position"]),
|
|
23401
|
+
deltaMs: number()
|
|
23402
|
+
});
|
|
23403
|
+
/**
|
|
23404
|
+
* Where a retrain frame came from: a TRACK's stored media (copy-on-select),
|
|
23405
|
+
* or the RECORDING at an instant — the frame a model saw nothing in has no
|
|
23406
|
+
* track at all.
|
|
23407
|
+
*/
|
|
23408
|
+
var RetrainFrameOriginSchema = _enum(["track", "recording"]);
|
|
22440
23409
|
/** A frame the dataset OWNS: bytes copied at selection time. */
|
|
22441
23410
|
var RetrainFrameSchema = object({
|
|
22442
23411
|
frameId: string(),
|
|
22443
23412
|
deviceId: number(),
|
|
22444
|
-
|
|
22445
|
-
/**
|
|
22446
|
-
|
|
23413
|
+
origin: RetrainFrameOriginSchema,
|
|
23414
|
+
/** The track it was copied from. Absent on a recording still. */
|
|
23415
|
+
trackId: string().optional(),
|
|
23416
|
+
/** Provenance only. It may already point at nothing — that is expected.
|
|
23417
|
+
* Absent on a recording still. */
|
|
23418
|
+
sourceMediaId: number().int().optional(),
|
|
23419
|
+
/** A recording still: the playhead instant it was taken at. */
|
|
23420
|
+
epochMs: number().optional(),
|
|
22447
23421
|
sourceKind: MediaFileKindEnum,
|
|
22448
23422
|
sizeBytes: number().int(),
|
|
22449
23423
|
width: number().int(),
|
|
@@ -22454,7 +23428,12 @@ var RetrainFrameSchema = object({
|
|
|
22454
23428
|
/** The operator's "every subject in this frame is boxed". Detector
|
|
22455
23429
|
* evaluation keeps only complete frames: an unboxed subject would count as
|
|
22456
23430
|
* a false positive. */
|
|
22457
|
-
complete: boolean()
|
|
23431
|
+
complete: boolean(),
|
|
23432
|
+
/** The boxes the pipeline drew on this frame. Present on list answers;
|
|
23433
|
+
* empty when nothing the track store holds can be placed on it. */
|
|
23434
|
+
pipelineBoxes: array(RetrainPipelineBoxSchema).readonly().optional(),
|
|
23435
|
+
/** The named collections this frame belongs to. Present on list answers. */
|
|
23436
|
+
collectionIds: array(string()).readonly().optional()
|
|
22458
23437
|
});
|
|
22459
23438
|
/** Why a copy-on-select could not be honoured — named, never a silent skip. */
|
|
22460
23439
|
var RetrainCopyRefusalSchema = _enum([
|
|
@@ -22485,6 +23464,8 @@ var RetrainFrameListSchema = object({
|
|
|
22485
23464
|
var RetrainExportFilterSchema = object({
|
|
22486
23465
|
deviceIds: array(number()).optional(),
|
|
22487
23466
|
frameIds: array(string()).max(2e4).optional(),
|
|
23467
|
+
/** Only frames in at least one of these named collections. */
|
|
23468
|
+
collectionIds: array(string()).max(200).optional(),
|
|
22488
23469
|
batchId: string().optional(),
|
|
22489
23470
|
/** Only frames the operator marked complete (all subjects boxed). */
|
|
22490
23471
|
completeOnly: boolean().optional()
|
|
@@ -22549,6 +23530,109 @@ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
|
|
|
22549
23530
|
reason: string(),
|
|
22550
23531
|
detail: string().optional()
|
|
22551
23532
|
})]);
|
|
23533
|
+
/** A named set over the retrain corpus — membership only, it owns no pixels. */
|
|
23534
|
+
var RetrainCollectionSchema = object({
|
|
23535
|
+
id: string(),
|
|
23536
|
+
name: string(),
|
|
23537
|
+
createdAt: number(),
|
|
23538
|
+
frameCount: number().int()
|
|
23539
|
+
});
|
|
23540
|
+
var RetrainCollectionCreateResultSchema = discriminatedUnion("kind", [object({
|
|
23541
|
+
kind: literal("created"),
|
|
23542
|
+
collection: RetrainCollectionSchema
|
|
23543
|
+
}), object({
|
|
23544
|
+
kind: literal("refused"),
|
|
23545
|
+
reason: _enum(["empty-name", "duplicate-name"])
|
|
23546
|
+
})]);
|
|
23547
|
+
var RetrainCollectionRenameResultSchema = discriminatedUnion("kind", [object({
|
|
23548
|
+
kind: literal("renamed"),
|
|
23549
|
+
collection: RetrainCollectionSchema
|
|
23550
|
+
}), object({
|
|
23551
|
+
kind: literal("refused"),
|
|
23552
|
+
reason: _enum([
|
|
23553
|
+
"empty-name",
|
|
23554
|
+
"duplicate-name",
|
|
23555
|
+
"unknown-collection"
|
|
23556
|
+
])
|
|
23557
|
+
})]);
|
|
23558
|
+
/**
|
|
23559
|
+
* The outcome of adding the frame at a recording instant. Every refusal is
|
|
23560
|
+
* named: `still-unavailable` (not recording, a gap, or an undecodable frame —
|
|
23561
|
+
* `detail` says which), `still-busy` (the recorder is at its decode bound; try
|
|
23562
|
+
* again), `unreadable-image`, `write-failed`, `unknown-collection`.
|
|
23563
|
+
*/
|
|
23564
|
+
var AddRetrainFrameFromRecordingResultSchema = discriminatedUnion("kind", [object({
|
|
23565
|
+
kind: literal("added"),
|
|
23566
|
+
collectionId: string(),
|
|
23567
|
+
frame: RetrainFrameSchema,
|
|
23568
|
+
/** The moment was already in the dataset; nothing was decoded. */
|
|
23569
|
+
reused: boolean()
|
|
23570
|
+
}), object({
|
|
23571
|
+
kind: literal("refused"),
|
|
23572
|
+
reason: _enum([
|
|
23573
|
+
"unknown-collection",
|
|
23574
|
+
"still-unavailable",
|
|
23575
|
+
"still-busy",
|
|
23576
|
+
"unreadable-image",
|
|
23577
|
+
"write-failed"
|
|
23578
|
+
]),
|
|
23579
|
+
detail: string().optional()
|
|
23580
|
+
})]);
|
|
23581
|
+
/** A vision LLM profile the AI assist may use, and where it sends the frame. */
|
|
23582
|
+
var RetrainAssistProfileSchema = object({
|
|
23583
|
+
id: string(),
|
|
23584
|
+
name: string(),
|
|
23585
|
+
model: string(),
|
|
23586
|
+
kind: string(),
|
|
23587
|
+
/** `true` when the frame would leave the house (a cloud vendor, or an
|
|
23588
|
+
* endpoint that is not on the local network). The page confirms each such
|
|
23589
|
+
* run, and the provider refuses one without `allowCloud`. */
|
|
23590
|
+
leavesHouse: boolean()
|
|
23591
|
+
});
|
|
23592
|
+
/** A box the AI assist proposed: a draft, plus the model's own reason. */
|
|
23593
|
+
var RetrainLlmProposalSchema = RetrainAnnotationDraftSchema.extend({ reason: string() });
|
|
23594
|
+
/** What the AI assist said about a box that was already on the canvas. */
|
|
23595
|
+
var RetrainLlmReviewSchema = object({
|
|
23596
|
+
/** The `ref` the page sent the box under. */
|
|
23597
|
+
ref: string(),
|
|
23598
|
+
verdict: _enum([
|
|
23599
|
+
"confirmed",
|
|
23600
|
+
"wrong-class",
|
|
23601
|
+
"not-an-object",
|
|
23602
|
+
"uncertain"
|
|
23603
|
+
]),
|
|
23604
|
+
suggestedClass: RetrainMacroClassSchema.optional(),
|
|
23605
|
+
reason: string()
|
|
23606
|
+
});
|
|
23607
|
+
/**
|
|
23608
|
+
* The AI assist's answer. `proposed` carries drafts (`source: 'llm'`, the
|
|
23609
|
+
* model and its confidence) and reviews; items the model got wrong (a box off
|
|
23610
|
+
* the frame, an unasked class, an unknown ref) are dropped and counted in
|
|
23611
|
+
* `rejected`. A whole answer that is not the schema is `malformed-answer`.
|
|
23612
|
+
*/
|
|
23613
|
+
var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
|
|
23614
|
+
kind: literal("proposed"),
|
|
23615
|
+
profileId: string(),
|
|
23616
|
+
model: string(),
|
|
23617
|
+
/** The frame was sent outside the house for this answer. */
|
|
23618
|
+
leftHouse: boolean(),
|
|
23619
|
+
proposals: array(RetrainLlmProposalSchema).readonly(),
|
|
23620
|
+
reviews: array(RetrainLlmReviewSchema).readonly(),
|
|
23621
|
+
rejected: number().int()
|
|
23622
|
+
}), object({
|
|
23623
|
+
kind: literal("refused"),
|
|
23624
|
+
reason: _enum([
|
|
23625
|
+
"unknown-frame",
|
|
23626
|
+
"unreadable-frame",
|
|
23627
|
+
"unknown-profile",
|
|
23628
|
+
"profile-disabled",
|
|
23629
|
+
"no-vision",
|
|
23630
|
+
"cloud-not-confirmed",
|
|
23631
|
+
"llm-error",
|
|
23632
|
+
"malformed-answer"
|
|
23633
|
+
]),
|
|
23634
|
+
detail: string().optional()
|
|
23635
|
+
})]);
|
|
22552
23636
|
/** The outcome of a lifecycle move owned by the retrain page. */
|
|
22553
23637
|
var RetrainTransitionResultSchema = object({
|
|
22554
23638
|
trackId: string(),
|
|
@@ -23266,7 +24350,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
23266
24350
|
auth: "admin"
|
|
23267
24351
|
}), method(object({
|
|
23268
24352
|
deviceId: number(),
|
|
23269
|
-
trackId: string(),
|
|
24353
|
+
trackId: string().optional(),
|
|
23270
24354
|
frameId: string()
|
|
23271
24355
|
}), object({
|
|
23272
24356
|
removed: boolean(),
|
|
@@ -23283,7 +24367,8 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
23283
24367
|
auth: "admin"
|
|
23284
24368
|
}), method(object({
|
|
23285
24369
|
deviceId: number(),
|
|
23286
|
-
|
|
24370
|
+
/** The frame's track, when it has one — checked against the frame. */
|
|
24371
|
+
trackId: string().optional(),
|
|
23287
24372
|
frameId: string(),
|
|
23288
24373
|
subject: RetrainAssistSubjectSchema,
|
|
23289
24374
|
/** Which node runs it. Absent ⇒ wherever an unowned call lands. */
|
|
@@ -23291,12 +24376,16 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
23291
24376
|
}), RetrainAssistResultSchema, {
|
|
23292
24377
|
kind: "mutation",
|
|
23293
24378
|
auth: "admin"
|
|
23294
|
-
}), method(object({
|
|
24379
|
+
}), method(object({
|
|
24380
|
+
trackId: string().optional(),
|
|
24381
|
+
frameIds: array(string()).max(2e3).optional()
|
|
24382
|
+
}), array(RetrainAnnotationSchema).readonly(), {
|
|
23295
24383
|
kind: "query",
|
|
23296
24384
|
auth: "admin"
|
|
23297
24385
|
}), method(object({
|
|
23298
24386
|
deviceId: number(),
|
|
23299
|
-
|
|
24387
|
+
/** The frame's track, when it has one — checked against the frame. */
|
|
24388
|
+
trackId: string().optional(),
|
|
23300
24389
|
frameId: string(),
|
|
23301
24390
|
annotations: array(RetrainAnnotationDraftSchema)
|
|
23302
24391
|
}), array(RetrainAnnotationSchema).readonly(), {
|
|
@@ -23319,7 +24408,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
23319
24408
|
auth: "admin"
|
|
23320
24409
|
}), method(object({
|
|
23321
24410
|
deviceId: number(),
|
|
23322
|
-
trackId: string(),
|
|
24411
|
+
trackId: string().optional(),
|
|
23323
24412
|
frameId: string(),
|
|
23324
24413
|
complete: boolean()
|
|
23325
24414
|
}), RetrainFrameSchema, {
|
|
@@ -23333,6 +24422,74 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
23333
24422
|
kind: "mutation",
|
|
23334
24423
|
auth: "admin",
|
|
23335
24424
|
timeoutMs: 60 * 6e4
|
|
24425
|
+
}), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
|
|
24426
|
+
kind: "query",
|
|
24427
|
+
auth: "admin"
|
|
24428
|
+
}), method(object({
|
|
24429
|
+
deviceId: number(),
|
|
24430
|
+
trackId: string().optional(),
|
|
24431
|
+
frameId: string(),
|
|
24432
|
+
profileId: string(),
|
|
24433
|
+
classes: array(RetrainMacroClassSchema).min(1),
|
|
24434
|
+
boxes: array(object({
|
|
24435
|
+
ref: string(),
|
|
24436
|
+
bbox: RetrainBboxSchema,
|
|
24437
|
+
macroClass: RetrainMacroClassSchema,
|
|
24438
|
+
label: string().optional()
|
|
24439
|
+
})).max(50),
|
|
24440
|
+
allowCloud: boolean()
|
|
24441
|
+
}), RetrainLlmAssistResultSchema, {
|
|
24442
|
+
kind: "mutation",
|
|
24443
|
+
auth: "admin",
|
|
24444
|
+
timeoutMs: 18e4
|
|
24445
|
+
}), method(object({ name: string().max(120) }), RetrainCollectionCreateResultSchema, {
|
|
24446
|
+
kind: "mutation",
|
|
24447
|
+
auth: "admin"
|
|
24448
|
+
}), method(object({}), array(RetrainCollectionSchema).readonly(), {
|
|
24449
|
+
kind: "query",
|
|
24450
|
+
auth: "admin"
|
|
24451
|
+
}), method(object({
|
|
24452
|
+
id: string(),
|
|
24453
|
+
name: string().max(120)
|
|
24454
|
+
}), RetrainCollectionRenameResultSchema, {
|
|
24455
|
+
kind: "mutation",
|
|
24456
|
+
auth: "admin"
|
|
24457
|
+
}), method(object({ id: string() }), object({
|
|
24458
|
+
deleted: boolean(),
|
|
24459
|
+
removedFrames: number().int()
|
|
24460
|
+
}), {
|
|
24461
|
+
kind: "mutation",
|
|
24462
|
+
auth: "admin"
|
|
24463
|
+
}), method(object({
|
|
24464
|
+
collectionId: string(),
|
|
24465
|
+
deviceId: number(),
|
|
24466
|
+
epochMs: number()
|
|
24467
|
+
}), AddRetrainFrameFromRecordingResultSchema, {
|
|
24468
|
+
kind: "mutation",
|
|
24469
|
+
auth: "admin",
|
|
24470
|
+
timeoutMs: 6e4
|
|
24471
|
+
}), method(object({
|
|
24472
|
+
collectionId: string(),
|
|
24473
|
+
frameIds: array(string()).min(1).max(500)
|
|
24474
|
+
}), object({
|
|
24475
|
+
added: number().int(),
|
|
24476
|
+
alreadyMember: number().int(),
|
|
24477
|
+
unknownFrameIds: array(string()).readonly()
|
|
24478
|
+
}), {
|
|
24479
|
+
kind: "mutation",
|
|
24480
|
+
auth: "admin"
|
|
24481
|
+
}), method(object({
|
|
24482
|
+
collectionId: string(),
|
|
24483
|
+
frameId: string()
|
|
24484
|
+
}), object({
|
|
24485
|
+
removed: boolean(),
|
|
24486
|
+
deletedFrame: boolean()
|
|
24487
|
+
}), {
|
|
24488
|
+
kind: "mutation",
|
|
24489
|
+
auth: "admin"
|
|
24490
|
+
}), method(object({ collectionId: string() }), array(RetrainFrameSchema).readonly(), {
|
|
24491
|
+
kind: "query",
|
|
24492
|
+
auth: "admin"
|
|
23336
24493
|
}), method(object({
|
|
23337
24494
|
/** Which of the three event tables owns the row. */
|
|
23338
24495
|
ownerType: EventOwnerTypeSchema,
|
|
@@ -23956,13 +25113,31 @@ var RecommendationReasonSchema = discriminatedUnion("kind", [
|
|
|
23956
25113
|
object({
|
|
23957
25114
|
kind: literal("no-family-build"),
|
|
23958
25115
|
format: ModelFormatSchema$1
|
|
25116
|
+
}),
|
|
25117
|
+
object({
|
|
25118
|
+
kind: literal("kept-custom-pin"),
|
|
25119
|
+
modelId: string(),
|
|
25120
|
+
deviceKey: string()
|
|
23959
25121
|
})
|
|
23960
25122
|
]);
|
|
25123
|
+
/** Why a device is left exactly as it is, whatever the plan would pick (D786). */
|
|
25124
|
+
var KeptReasonSchema = _enum(["custom-pin"]);
|
|
25125
|
+
/**
|
|
25126
|
+
* Where a choice's latency came from (D791): this node's own benchmark
|
|
25127
|
+
* result, or the hardware-class table. Measured on the node beats the table.
|
|
25128
|
+
*/
|
|
25129
|
+
var LatencySourceSchema = discriminatedUnion("kind", [object({ kind: literal("table") }), object({
|
|
25130
|
+
kind: literal("node-benchmark"),
|
|
25131
|
+
resultId: string(),
|
|
25132
|
+
measuredAtMs: number()
|
|
25133
|
+
})]);
|
|
23961
25134
|
var DeviceModelChoiceSchema = object({
|
|
23962
25135
|
modelId: string(),
|
|
23963
25136
|
p50Ms: number(),
|
|
23964
25137
|
fps: number(),
|
|
23965
25138
|
measured: boolean(),
|
|
25139
|
+
/** Absent on a plan from before D791 — read as the table. */
|
|
25140
|
+
source: LatencySourceSchema.optional(),
|
|
23966
25141
|
/** Parallel sessions at the camera rate with the headroom kept free: ⌊fps × (1 − headroom) / camera fps⌋. */
|
|
23967
25142
|
capacitySessions: number(),
|
|
23968
25143
|
personRecall: number()
|
|
@@ -23973,6 +25148,8 @@ var DeviceRecommendationSchema = object({
|
|
|
23973
25148
|
enabled: boolean(),
|
|
23974
25149
|
available: boolean(),
|
|
23975
25150
|
chosen: DeviceModelChoiceSchema.nullable(),
|
|
25151
|
+
/** Present when the device is kept as is: Apply writes nothing on it. */
|
|
25152
|
+
kept: KeptReasonSchema.optional(),
|
|
23976
25153
|
reasons: array(RecommendationReasonSchema).readonly()
|
|
23977
25154
|
});
|
|
23978
25155
|
var NodeRecommendationSchema = object({
|
|
@@ -24026,6 +25203,17 @@ var AutoTuneWarningSchema = discriminatedUnion("kind", [
|
|
|
24026
25203
|
kind: literal("coral-enabled"),
|
|
24027
25204
|
nodeId: string(),
|
|
24028
25205
|
deviceKey: string()
|
|
25206
|
+
}),
|
|
25207
|
+
object({
|
|
25208
|
+
kind: literal("custom-pin-kept"),
|
|
25209
|
+
nodeId: string(),
|
|
25210
|
+
deviceKey: string().nullable(),
|
|
25211
|
+
deviceId: number().nullable(),
|
|
25212
|
+
modelId: string()
|
|
25213
|
+
}),
|
|
25214
|
+
object({
|
|
25215
|
+
kind: literal("custom-registry-unreadable"),
|
|
25216
|
+
error: string()
|
|
24029
25217
|
})
|
|
24030
25218
|
]);
|
|
24031
25219
|
var AutoTuneOptionsSchema = object({
|
|
@@ -24204,13 +25392,14 @@ var SuggestSharesResultSchema = object({
|
|
|
24204
25392
|
nodes: array(SuggestedNodeShareSchema).readonly()
|
|
24205
25393
|
});
|
|
24206
25394
|
/**
|
|
24207
|
-
* Where the node and device shares come from (D750, D755).
|
|
24208
|
-
* - `
|
|
24209
|
-
*
|
|
24210
|
-
*
|
|
24211
|
-
*
|
|
24212
|
-
*
|
|
24213
|
-
*
|
|
25395
|
+
* Where the node and device shares come from (D750, D755, D791).
|
|
25396
|
+
* - `benchmark` (default since D791) — each node's capacity as its own node
|
|
25397
|
+
* benchmark measured it; a node without fresh results is sized from
|
|
25398
|
+
* `hardware` and says so. Measured on the node beats the table.
|
|
25399
|
+
* - `hardware` — computed from each node's static capacity only (its
|
|
25400
|
+
* accelerators at their Auto tune models, from the latency table).
|
|
25401
|
+
* Both are recomputed whenever a node or device joins, leaves, is switched
|
|
25402
|
+
* on or off, changes model, or a benchmark result is written. No load input.
|
|
24214
25403
|
* - `manual` — the operator's stored sliders.
|
|
24215
25404
|
* Either way a node or device that cannot take sessions gives its share to
|
|
24216
25405
|
* the others in proportion; the stored values are never rewritten for that.
|
|
@@ -24259,6 +25448,362 @@ var EffectiveSharesSchema = object({
|
|
|
24259
25448
|
nodeWeights: record(string(), number()),
|
|
24260
25449
|
deviceWeights: record(string(), record(string(), number()))
|
|
24261
25450
|
});
|
|
25451
|
+
/**
|
|
25452
|
+
* Wire shapes of the node benchmark (D791): the operator's plan, the
|
|
25453
|
+
* preflight the confirmation shows, the run the orchestrator owns, what the
|
|
25454
|
+
* measuring runner reports, and the result rows Auto tune and the automatic
|
|
25455
|
+
* shares read.
|
|
25456
|
+
*
|
|
25457
|
+
* ONE node at a time, owned by the pipeline orchestrator. While a run is
|
|
25458
|
+
* active the cluster is in BENCHMARK MODE for that node: it is not a
|
|
25459
|
+
* detection candidate, camera pins naming it are ignored so its sessions move
|
|
25460
|
+
* elsewhere, and both come back when the mode ends — after a crash or a hub
|
|
25461
|
+
* restart too (a persisted manifest, reconciled against the registry).
|
|
25462
|
+
*
|
|
25463
|
+
* Two measurements, both on the node, driven by its own runner (frames never
|
|
25464
|
+
* cross a process at frame rate, D9):
|
|
25465
|
+
* - `device` — one accelerator × one candidate detector, root only, open
|
|
25466
|
+
* loop: how many streams at the camera rate it carries inside the frame
|
|
25467
|
+
* interval;
|
|
25468
|
+
* - `pipeline` — the chosen detector plus the operator's detail steps
|
|
25469
|
+
* (faces, plates, classifiers, CLIP…), on varied frames from the bench
|
|
25470
|
+
* clip: how many parallel sessions the node carries before latency, drops,
|
|
25471
|
+
* CPU, RAM or the event loop give out.
|
|
25472
|
+
*/
|
|
25473
|
+
/** Defaults and bounds, one place. */
|
|
25474
|
+
var NODE_BENCHMARK_DEFAULTS = {
|
|
25475
|
+
fpsPerStream: 10,
|
|
25476
|
+
budgetMinutes: 45,
|
|
25477
|
+
minBudgetMinutes: 10,
|
|
25478
|
+
maxBudgetMinutes: 120,
|
|
25479
|
+
/** A result older than this no longer beats the table. */
|
|
25480
|
+
staleAfterDays: 30,
|
|
25481
|
+
/** Warm-in per ramp step (not accounted). */
|
|
25482
|
+
settleSec: 5,
|
|
25483
|
+
/** Accounted window per ramp step. */
|
|
25484
|
+
measureSec: 20,
|
|
25485
|
+
/** Longest the drain may take before the run is refused. */
|
|
25486
|
+
drainTimeoutSec: 120,
|
|
25487
|
+
/** Candidate models per device in one run. */
|
|
25488
|
+
maxModelsPerDevice: 6
|
|
25489
|
+
};
|
|
25490
|
+
/** The two measurements a run can make. */
|
|
25491
|
+
var NodeBenchmarkPhaseSchema = _enum(["device", "pipeline"]);
|
|
25492
|
+
var NodeBenchmarkDevicePlanSchema = object({
|
|
25493
|
+
/** `<backend>:<device>` — `openvino:npu`, `coreml:all`, `cpu`. */
|
|
25494
|
+
deviceKey: string().min(1),
|
|
25495
|
+
/**
|
|
25496
|
+
* Root detector candidates for the `device` measurement, in the order
|
|
25497
|
+
* measured. The FIRST is the one the `pipeline` measurement runs.
|
|
25498
|
+
*/
|
|
25499
|
+
modelIds: array(string().min(1)).min(1).max(NODE_BENCHMARK_DEFAULTS.maxModelsPerDevice)
|
|
25500
|
+
});
|
|
25501
|
+
/** What the operator confirmed. */
|
|
25502
|
+
var NodeBenchmarkPlanSchema = object({
|
|
25503
|
+
nodeId: string().min(1),
|
|
25504
|
+
devices: array(NodeBenchmarkDevicePlanSchema).min(1),
|
|
25505
|
+
/** Which measurements run. At least one. */
|
|
25506
|
+
phases: array(NodeBenchmarkPhaseSchema).min(1).default(["device", "pipeline"]),
|
|
25507
|
+
/**
|
|
25508
|
+
* Detail steps (catalog step ids under the root: faces, plates,
|
|
25509
|
+
* classifiers, CLIP…) the `pipeline` measurement enables. The root
|
|
25510
|
+
* detector always runs.
|
|
25511
|
+
*/
|
|
25512
|
+
steps: array(string().min(1)).default([]),
|
|
25513
|
+
/** Offered rate of one stream / session. */
|
|
25514
|
+
fpsPerStream: number().int().min(1).max(30).default(NODE_BENCHMARK_DEFAULTS.fpsPerStream),
|
|
25515
|
+
/** Hard deadline: the mode ends and the cluster is restored when it passes. */
|
|
25516
|
+
budgetMinutes: number().int().min(NODE_BENCHMARK_DEFAULTS.minBudgetMinutes).max(NODE_BENCHMARK_DEFAULTS.maxBudgetMinutes).default(NODE_BENCHMARK_DEFAULTS.budgetMinutes),
|
|
25517
|
+
/** Keep the models the run downloaded (default: delete what was not installed before). */
|
|
25518
|
+
keepDownloadedModels: boolean().default(false),
|
|
25519
|
+
/** Start although the other nodes' capacity does not cover the sessions running now. */
|
|
25520
|
+
acceptInsufficientHeadroom: boolean().default(false)
|
|
25521
|
+
});
|
|
25522
|
+
var NodeBenchmarkRefusalSchema = object({
|
|
25523
|
+
kind: _enum([
|
|
25524
|
+
"benchmark-active",
|
|
25525
|
+
"node-offline",
|
|
25526
|
+
"unknown-device",
|
|
25527
|
+
"no-phase",
|
|
25528
|
+
"insufficient-headroom"
|
|
25529
|
+
]),
|
|
25530
|
+
detail: string(),
|
|
25531
|
+
overridable: boolean()
|
|
25532
|
+
});
|
|
25533
|
+
/** A camera whose detection leaves the node for the run. */
|
|
25534
|
+
var NodeBenchmarkMovingCameraSchema = object({
|
|
25535
|
+
deviceId: number(),
|
|
25536
|
+
/** Placed on the node now (a standing attach or a running session). */
|
|
25537
|
+
placedOnNode: boolean(),
|
|
25538
|
+
/** A node pin naming this node, ignored for the run. */
|
|
25539
|
+
pinnedToNode: boolean()
|
|
25540
|
+
});
|
|
25541
|
+
/** A camera that cannot leave: no other node can obtain its frames. */
|
|
25542
|
+
var NodeBenchmarkStayingCameraSchema = object({
|
|
25543
|
+
deviceId: number(),
|
|
25544
|
+
reason: literal("only-frame-source")
|
|
25545
|
+
});
|
|
25546
|
+
var NodeBenchmarkPreflightSchema = object({
|
|
25547
|
+
nodeId: string(),
|
|
25548
|
+
online: boolean(),
|
|
25549
|
+
moving: array(NodeBenchmarkMovingCameraSchema).readonly(),
|
|
25550
|
+
/** Keep running on the node during the run; the result is flagged contaminated. */
|
|
25551
|
+
staying: array(NodeBenchmarkStayingCameraSchema).readonly(),
|
|
25552
|
+
estimatedDurationMs: number(),
|
|
25553
|
+
/** The run ends and the cluster is restored at the latest after this long. */
|
|
25554
|
+
budgetMs: number(),
|
|
25555
|
+
phases: array(NodeBenchmarkPhaseSchema).readonly(),
|
|
25556
|
+
steps: array(string()).readonly(),
|
|
25557
|
+
devices: array(NodeBenchmarkDevicePlanSchema).readonly(),
|
|
25558
|
+
/** Parallel sessions the cluster runs now, and what the other nodes can carry. */
|
|
25559
|
+
headroom: object({
|
|
25560
|
+
sessionsNow: number(),
|
|
25561
|
+
otherNodesCapacitySessions: number().nullable()
|
|
25562
|
+
}),
|
|
25563
|
+
refusals: array(NodeBenchmarkRefusalSchema).readonly(),
|
|
25564
|
+
canStart: boolean()
|
|
25565
|
+
});
|
|
25566
|
+
/** Where the measuring runner is. */
|
|
25567
|
+
var NodeBenchProgressSchema = object({
|
|
25568
|
+
phase: _enum([
|
|
25569
|
+
"preparing",
|
|
25570
|
+
"device",
|
|
25571
|
+
"pipeline",
|
|
25572
|
+
"cleanup"
|
|
25573
|
+
]),
|
|
25574
|
+
deviceKey: string().nullable(),
|
|
25575
|
+
modelId: string().nullable(),
|
|
25576
|
+
/** Streams (device) or sessions (pipeline) of the step running now. */
|
|
25577
|
+
load: number().nullable(),
|
|
25578
|
+
cellsDone: number(),
|
|
25579
|
+
cellsTotal: number(),
|
|
25580
|
+
message: string()
|
|
25581
|
+
});
|
|
25582
|
+
/** What limited a ramp. `none` = the ramp ran out of steps still passing. */
|
|
25583
|
+
var NodeBenchLimitSchema = _enum([
|
|
25584
|
+
"p95",
|
|
25585
|
+
"drops",
|
|
25586
|
+
"errors",
|
|
25587
|
+
"stall",
|
|
25588
|
+
"cpu",
|
|
25589
|
+
"ram",
|
|
25590
|
+
"none"
|
|
25591
|
+
]);
|
|
25592
|
+
var NodeBenchRampStepSchema = object({
|
|
25593
|
+
load: number(),
|
|
25594
|
+
pass: boolean(),
|
|
25595
|
+
p95Ms: number(),
|
|
25596
|
+
dropRatio: number(),
|
|
25597
|
+
/** Completed frames per second over the accounted window. */
|
|
25598
|
+
fps: number(),
|
|
25599
|
+
cpuPct: number().nullable(),
|
|
25600
|
+
ramFreePct: number().nullable(),
|
|
25601
|
+
failReasons: array(string()).readonly()
|
|
25602
|
+
});
|
|
25603
|
+
var NodeBenchCellSchema = discriminatedUnion("phase", [object({
|
|
25604
|
+
phase: literal("device"),
|
|
25605
|
+
deviceKey: string(),
|
|
25606
|
+
modelId: string(),
|
|
25607
|
+
/** Single-stream latency (the K = 1 step). */
|
|
25608
|
+
p50Ms: number(),
|
|
25609
|
+
p95Ms: number(),
|
|
25610
|
+
p99Ms: number(),
|
|
25611
|
+
/** Frames per second sustained at the last passing step. */
|
|
25612
|
+
fps: number(),
|
|
25613
|
+
/** Streams at the camera rate the device carried inside the frame interval; 0 = not even one. */
|
|
25614
|
+
kMax: number(),
|
|
25615
|
+
limitedBy: NodeBenchLimitSchema,
|
|
25616
|
+
/** First call (model load + warm-up). */
|
|
25617
|
+
warmupMs: number(),
|
|
25618
|
+
ramp: array(NodeBenchRampStepSchema).readonly()
|
|
25619
|
+
}), object({
|
|
25620
|
+
phase: literal("pipeline"),
|
|
25621
|
+
deviceKey: string(),
|
|
25622
|
+
modelId: string(),
|
|
25623
|
+
steps: array(string()).readonly(),
|
|
25624
|
+
/** Parallel sessions at the camera rate the node carried; 0 = not even one. */
|
|
25625
|
+
maxSessions: number(),
|
|
25626
|
+
limitedBy: NodeBenchLimitSchema,
|
|
25627
|
+
/** Detail steps that produced at least one result on the clip — a step that never fired measured nothing. */
|
|
25628
|
+
stepsFired: array(string()).readonly(),
|
|
25629
|
+
warmupMs: number(),
|
|
25630
|
+
ramp: array(NodeBenchRampStepSchema).readonly()
|
|
25631
|
+
})]);
|
|
25632
|
+
/**
|
|
25633
|
+
* What a result was measured ON. A result whose fingerprint no longer matches
|
|
25634
|
+
* the node no longer beats the table.
|
|
25635
|
+
*/
|
|
25636
|
+
var NodeBenchFingerprintSchema = object({
|
|
25637
|
+
pipelineVersion: string().nullable(),
|
|
25638
|
+
cpuModel: string().nullable(),
|
|
25639
|
+
ramGb: number().nullable(),
|
|
25640
|
+
os: string().nullable(),
|
|
25641
|
+
/** Per device: the pool the cells ran on (runtime + tuning). */
|
|
25642
|
+
pools: record(string(), object({
|
|
25643
|
+
runtime: string(),
|
|
25644
|
+
numWorkers: number(),
|
|
25645
|
+
concurrency: number(),
|
|
25646
|
+
batchMode: string()
|
|
25647
|
+
})).default({})
|
|
25648
|
+
});
|
|
25649
|
+
/** The frames the run used. */
|
|
25650
|
+
var NodeBenchClipSchema = object({
|
|
25651
|
+
/** `camstack-bench-v1` or `reference-images` (the fallback when the clip is not reachable). */
|
|
25652
|
+
id: string(),
|
|
25653
|
+
revision: string().nullable(),
|
|
25654
|
+
frames: number(),
|
|
25655
|
+
width: number(),
|
|
25656
|
+
height: number()
|
|
25657
|
+
});
|
|
25658
|
+
var NodeBenchRunnerInputSchema = object({
|
|
25659
|
+
runId: string().min(1),
|
|
25660
|
+
devices: array(NodeBenchmarkDevicePlanSchema).min(1),
|
|
25661
|
+
phases: array(NodeBenchmarkPhaseSchema).min(1),
|
|
25662
|
+
/** The full detail step tree root for the `pipeline` measurement is built on the node from these ids. */
|
|
25663
|
+
steps: array(string()).default([]),
|
|
25664
|
+
fpsPerStream: number().int().min(1).max(30),
|
|
25665
|
+
/** The runner stops on its own past this instant, whatever the hub does. */
|
|
25666
|
+
deadlineAtMs: number(),
|
|
25667
|
+
settleSec: number().min(0).max(60).default(NODE_BENCHMARK_DEFAULTS.settleSec),
|
|
25668
|
+
measureSec: number().min(2).max(300).default(NODE_BENCHMARK_DEFAULTS.measureSec),
|
|
25669
|
+
keepDownloadedModels: boolean().default(false)
|
|
25670
|
+
});
|
|
25671
|
+
var NodeBenchRunnerStateSchema = _enum([
|
|
25672
|
+
"running",
|
|
25673
|
+
"done",
|
|
25674
|
+
"failed",
|
|
25675
|
+
"aborted"
|
|
25676
|
+
]);
|
|
25677
|
+
var NodeBenchRunnerStatusSchema = object({
|
|
25678
|
+
runId: string(),
|
|
25679
|
+
nodeId: string(),
|
|
25680
|
+
state: NodeBenchRunnerStateSchema,
|
|
25681
|
+
progress: NodeBenchProgressSchema.nullable(),
|
|
25682
|
+
/** Every finished cell so far — a run stopped half way keeps what it measured. */
|
|
25683
|
+
cells: array(NodeBenchCellSchema).readonly(),
|
|
25684
|
+
fingerprint: NodeBenchFingerprintSchema.nullable(),
|
|
25685
|
+
clip: NodeBenchClipSchema.nullable(),
|
|
25686
|
+
/** Cameras seen running on the node during the run (they share its pools). */
|
|
25687
|
+
activeCameraIds: array(number()).readonly(),
|
|
25688
|
+
/** Models the run downloaded and then deleted (not installed before). */
|
|
25689
|
+
deletedModels: array(string()).readonly(),
|
|
25690
|
+
error: string().nullable(),
|
|
25691
|
+
startedAtMs: number(),
|
|
25692
|
+
finishedAtMs: number().nullable()
|
|
25693
|
+
});
|
|
25694
|
+
var NodeBenchmarkStateSchema = _enum([
|
|
25695
|
+
"draining",
|
|
25696
|
+
"measuring",
|
|
25697
|
+
"restoring",
|
|
25698
|
+
"done",
|
|
25699
|
+
"failed",
|
|
25700
|
+
"aborted"
|
|
25701
|
+
]);
|
|
25702
|
+
/** Why a run ended. */
|
|
25703
|
+
var NodeBenchmarkEndReasonSchema = _enum([
|
|
25704
|
+
"completed",
|
|
25705
|
+
"operator-abort",
|
|
25706
|
+
"deadline",
|
|
25707
|
+
"node-lost",
|
|
25708
|
+
"runner-lost",
|
|
25709
|
+
"hub-restart",
|
|
25710
|
+
"drain-timeout",
|
|
25711
|
+
"failed"
|
|
25712
|
+
]);
|
|
25713
|
+
var NodeBenchmarkRunSchema = object({
|
|
25714
|
+
runId: string(),
|
|
25715
|
+
nodeId: string(),
|
|
25716
|
+
state: NodeBenchmarkStateSchema,
|
|
25717
|
+
plan: NodeBenchmarkPlanSchema,
|
|
25718
|
+
startedAtMs: number(),
|
|
25719
|
+
deadlineAtMs: number(),
|
|
25720
|
+
finishedAtMs: number().nullable(),
|
|
25721
|
+
endReason: NodeBenchmarkEndReasonSchema.nullable(),
|
|
25722
|
+
error: string().nullable(),
|
|
25723
|
+
/** Cameras moved off the node for the run. */
|
|
25724
|
+
moved: array(number()).readonly(),
|
|
25725
|
+
/** Cameras that stayed (their only frame source is the node). */
|
|
25726
|
+
staying: array(number()).readonly(),
|
|
25727
|
+
/** Something else ran on the node's pools during the run. */
|
|
25728
|
+
contaminated: boolean(),
|
|
25729
|
+
progress: NodeBenchProgressSchema.nullable(),
|
|
25730
|
+
resultIds: array(string()).readonly()
|
|
25731
|
+
});
|
|
25732
|
+
/** `getNodeBenchmarkStatus`: the active run (or the last one), and whether benchmark mode is on. */
|
|
25733
|
+
var NodeBenchmarkStatusSchema = object({
|
|
25734
|
+
/** The node the cluster is in benchmark mode for; null = none. */
|
|
25735
|
+
modeNodeId: string().nullable(),
|
|
25736
|
+
run: NodeBenchmarkRunSchema.nullable()
|
|
25737
|
+
});
|
|
25738
|
+
/**
|
|
25739
|
+
* One stored measurement — the only authority Auto tune and the automatic
|
|
25740
|
+
* shares read measured capacity from. Written by the orchestrator when a run
|
|
25741
|
+
* ends, never by anyone else.
|
|
25742
|
+
*/
|
|
25743
|
+
var NodeBenchmarkResultSchema = object({
|
|
25744
|
+
id: string(),
|
|
25745
|
+
runId: string(),
|
|
25746
|
+
nodeId: string(),
|
|
25747
|
+
cell: NodeBenchCellSchema,
|
|
25748
|
+
fpsPerStream: number(),
|
|
25749
|
+
fingerprint: NodeBenchFingerprintSchema.nullable(),
|
|
25750
|
+
clip: NodeBenchClipSchema.nullable(),
|
|
25751
|
+
/** Other work shared the node's pools (a camera that could not move, or the hub's own duties). */
|
|
25752
|
+
contaminated: boolean(),
|
|
25753
|
+
stayingCameras: array(number()).readonly(),
|
|
25754
|
+
/** The run ended early; the cell itself completed. */
|
|
25755
|
+
partialRun: boolean(),
|
|
25756
|
+
measuredAtMs: number()
|
|
25757
|
+
});
|
|
25758
|
+
var ListNodeBenchmarkResultsInputSchema = object({
|
|
25759
|
+
nodeId: string().optional(),
|
|
25760
|
+
deviceKey: string().optional()
|
|
25761
|
+
});
|
|
25762
|
+
/** A result with its standing today: does it still beat the table? */
|
|
25763
|
+
var NodeBenchmarkResultViewSchema = NodeBenchmarkResultSchema.extend({
|
|
25764
|
+
/** `fresh` beats the table; `stale` falls back to it; `superseded` = a newer row covers the same cell. */
|
|
25765
|
+
standing: _enum([
|
|
25766
|
+
"fresh",
|
|
25767
|
+
"stale",
|
|
25768
|
+
"superseded"
|
|
25769
|
+
]),
|
|
25770
|
+
staleWhy: _enum([
|
|
25771
|
+
"age",
|
|
25772
|
+
"runtime",
|
|
25773
|
+
"pool-tuning"
|
|
25774
|
+
]).nullable()
|
|
25775
|
+
});
|
|
25776
|
+
object({
|
|
25777
|
+
runId: string(),
|
|
25778
|
+
nodeId: string(),
|
|
25779
|
+
startedAtMs: number(),
|
|
25780
|
+
deadlineAtMs: number(),
|
|
25781
|
+
plan: NodeBenchmarkPlanSchema,
|
|
25782
|
+
moved: array(number()).readonly(),
|
|
25783
|
+
staying: array(number()).readonly()
|
|
25784
|
+
});
|
|
25785
|
+
/** Candidate detectors per device, for the plan editor. */
|
|
25786
|
+
var NodeBenchmarkCandidatesSchema = object({
|
|
25787
|
+
nodeId: string(),
|
|
25788
|
+
reachable: boolean(),
|
|
25789
|
+
devices: array(object({
|
|
25790
|
+
deviceKey: string(),
|
|
25791
|
+
enabled: boolean(),
|
|
25792
|
+
available: boolean(),
|
|
25793
|
+
/** Ordered: what Auto tune would pick first, then the rest of the family by accuracy. */
|
|
25794
|
+
suggested: array(string()).readonly(),
|
|
25795
|
+
/** Every root detector the device has a build for. */
|
|
25796
|
+
all: array(string()).readonly(),
|
|
25797
|
+
/** The model the device runs now, when pinned. */
|
|
25798
|
+
currentModelId: string().nullable()
|
|
25799
|
+
})).readonly(),
|
|
25800
|
+
/** Detail steps the node's catalog offers under the root (for the `pipeline` measurement). */
|
|
25801
|
+
steps: array(object({
|
|
25802
|
+
id: string(),
|
|
25803
|
+
name: string(),
|
|
25804
|
+
slot: string()
|
|
25805
|
+
})).readonly()
|
|
25806
|
+
});
|
|
24262
25807
|
object({
|
|
24263
25808
|
activeCameras: number(),
|
|
24264
25809
|
throttledCameras: number(),
|
|
@@ -25387,7 +26932,16 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
|
|
|
25387
26932
|
}), ParkedTrackFrameSchema.nullable()), method(object({
|
|
25388
26933
|
deviceId: number(),
|
|
25389
26934
|
trackId: string()
|
|
25390
|
-
}), object({ released: number().int().nonnegative() }), { kind: "mutation" })
|
|
26935
|
+
}), object({ released: number().int().nonnegative() }), { kind: "mutation" }), method(NodeBenchRunnerInputSchema, object({
|
|
26936
|
+
accepted: literal(true),
|
|
26937
|
+
runId: string()
|
|
26938
|
+
}), {
|
|
26939
|
+
kind: "mutation",
|
|
26940
|
+
auth: "admin"
|
|
26941
|
+
}), method(object({ runId: string() }), NodeBenchRunnerStatusSchema.nullable(), { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
|
|
26942
|
+
kind: "mutation",
|
|
26943
|
+
auth: "admin"
|
|
26944
|
+
});
|
|
25391
26945
|
var CameraPipelineConfigSchema = object({
|
|
25392
26946
|
engine: PipelineEngineChoiceSchema.optional(),
|
|
25393
26947
|
steps: array(PipelineStepInputSchema).readonly(),
|
|
@@ -26026,6 +27580,21 @@ method(object({
|
|
|
26026
27580
|
}), method(PlacementStatsInputSchema, PlacementStatsSchema, { auth: "admin" }), method(SuggestSharesInputSchema, SuggestSharesResultSchema, { auth: "admin" }), method(_void(), EffectiveSharesSchema, { auth: "admin" }), method(SetShareSourceInputSchema, object({ success: literal(true) }), {
|
|
26027
27581
|
kind: "mutation",
|
|
26028
27582
|
auth: "admin"
|
|
27583
|
+
}), method(NodeBenchmarkPlanSchema, NodeBenchmarkPreflightSchema, { auth: "admin" }), method(NodeBenchmarkPlanSchema, discriminatedUnion("kind", [object({
|
|
27584
|
+
kind: literal("started"),
|
|
27585
|
+
runId: string()
|
|
27586
|
+
}), object({
|
|
27587
|
+
kind: literal("refused"),
|
|
27588
|
+
preflight: NodeBenchmarkPreflightSchema
|
|
27589
|
+
})]), {
|
|
27590
|
+
kind: "mutation",
|
|
27591
|
+
auth: "admin"
|
|
27592
|
+
}), method(_void(), NodeBenchmarkStatusSchema, { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
|
|
27593
|
+
kind: "mutation",
|
|
27594
|
+
auth: "admin"
|
|
27595
|
+
}), method(object({ nodeId: string() }), NodeBenchmarkCandidatesSchema, { auth: "admin" }), method(ListNodeBenchmarkResultsInputSchema, array(NodeBenchmarkResultViewSchema).readonly(), { auth: "admin" }), method(object({ id: string() }), object({ deleted: boolean() }), {
|
|
27596
|
+
kind: "mutation",
|
|
27597
|
+
auth: "admin"
|
|
26029
27598
|
}), method(object({ deviceId: number() }), CameraPipelineSettingsSchema.nullable()), method(object({
|
|
26030
27599
|
deviceId: number(),
|
|
26031
27600
|
addonId: string(),
|
|
@@ -32141,6 +33710,9 @@ var CreateIntegrationInputSchema = object({
|
|
|
32141
33710
|
enabled: boolean().optional(),
|
|
32142
33711
|
info: record(string(), unknown()).optional(),
|
|
32143
33712
|
settings: record(string(), unknown()).optional(),
|
|
33713
|
+
/** Keys of `settings` the form's schema declares secret (by type) — kept in
|
|
33714
|
+
* the keychain, not the table (D787). */
|
|
33715
|
+
secretKeys: array(string()).optional(),
|
|
32144
33716
|
skipRestart: boolean().optional()
|
|
32145
33717
|
});
|
|
32146
33718
|
var UpdateIntegrationInputSchema = object({
|
|
@@ -32164,7 +33736,9 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
|
|
|
32164
33736
|
auth: "admin"
|
|
32165
33737
|
}), method(object({ id: string() }), record(string(), unknown()), { auth: "admin" }), method(object({
|
|
32166
33738
|
id: string(),
|
|
32167
|
-
settings: record(string(), unknown())
|
|
33739
|
+
settings: record(string(), unknown()),
|
|
33740
|
+
/** Keys the form's schema declares secret (by type) — keychain-stored (D787). */
|
|
33741
|
+
secretKeys: array(string()).optional()
|
|
32168
33742
|
}), object({ success: boolean() }), {
|
|
32169
33743
|
kind: "mutation",
|
|
32170
33744
|
auth: "admin"
|
|
@@ -40327,7 +41901,8 @@ var BaseDevice$1 = class {
|
|
|
40327
41901
|
this.role = options.role;
|
|
40328
41902
|
this.parentDeviceId = ctx.parentDeviceId;
|
|
40329
41903
|
const seedData = ctx.persistedConfig ?? {};
|
|
40330
|
-
|
|
41904
|
+
const declaredSecretPaths = collectZodSecretPaths(schema);
|
|
41905
|
+
this.config = DeviceConfig.fromSchema(schema, (data) => ctx.persistConfig(data, { secretConfigPaths: declaredSecretPaths }), seedData, ({ droppedKeys, issues }) => {
|
|
40331
41906
|
ctx.logger.warn("Device config recovery: dropping invalid persisted fields", {
|
|
40332
41907
|
tags: {
|
|
40333
41908
|
deviceId: ctx.id,
|
|
@@ -44016,6 +45591,90 @@ Object.freeze({
|
|
|
44016
45591
|
addonId: null,
|
|
44017
45592
|
access: "create"
|
|
44018
45593
|
},
|
|
45594
|
+
"keychain.delete": {
|
|
45595
|
+
capName: "keychain",
|
|
45596
|
+
capScope: "system",
|
|
45597
|
+
addonId: null,
|
|
45598
|
+
access: "delete"
|
|
45599
|
+
},
|
|
45600
|
+
"keychain.getState": {
|
|
45601
|
+
capName: "keychain",
|
|
45602
|
+
capScope: "system",
|
|
45603
|
+
addonId: null,
|
|
45604
|
+
access: "view"
|
|
45605
|
+
},
|
|
45606
|
+
"keychain.listMeta": {
|
|
45607
|
+
capName: "keychain",
|
|
45608
|
+
capScope: "system",
|
|
45609
|
+
addonId: null,
|
|
45610
|
+
access: "view"
|
|
45611
|
+
},
|
|
45612
|
+
"keychain.put": {
|
|
45613
|
+
capName: "keychain",
|
|
45614
|
+
capScope: "system",
|
|
45615
|
+
addonId: null,
|
|
45616
|
+
access: "create"
|
|
45617
|
+
},
|
|
45618
|
+
"keychain.resolve": {
|
|
45619
|
+
capName: "keychain",
|
|
45620
|
+
capScope: "system",
|
|
45621
|
+
addonId: null,
|
|
45622
|
+
access: "view"
|
|
45623
|
+
},
|
|
45624
|
+
"keychainAdmin.deleteOrphans": {
|
|
45625
|
+
capName: "keychain-admin",
|
|
45626
|
+
capScope: "system",
|
|
45627
|
+
addonId: null,
|
|
45628
|
+
access: "delete"
|
|
45629
|
+
},
|
|
45630
|
+
"keychainAdmin.downloadRecoveryKey": {
|
|
45631
|
+
capName: "keychain-admin",
|
|
45632
|
+
capScope: "system",
|
|
45633
|
+
addonId: null,
|
|
45634
|
+
access: "create"
|
|
45635
|
+
},
|
|
45636
|
+
"keychainAdmin.listAudit": {
|
|
45637
|
+
capName: "keychain-admin",
|
|
45638
|
+
capScope: "system",
|
|
45639
|
+
addonId: null,
|
|
45640
|
+
access: "view"
|
|
45641
|
+
},
|
|
45642
|
+
"keychainAdmin.listSecrets": {
|
|
45643
|
+
capName: "keychain-admin",
|
|
45644
|
+
capScope: "system",
|
|
45645
|
+
addonId: null,
|
|
45646
|
+
access: "view"
|
|
45647
|
+
},
|
|
45648
|
+
"keychainAdmin.purgeRetiredKeys": {
|
|
45649
|
+
capName: "keychain-admin",
|
|
45650
|
+
capScope: "system",
|
|
45651
|
+
addonId: null,
|
|
45652
|
+
access: "delete"
|
|
45653
|
+
},
|
|
45654
|
+
"keychainAdmin.resetKeychain": {
|
|
45655
|
+
capName: "keychain-admin",
|
|
45656
|
+
capScope: "system",
|
|
45657
|
+
addonId: null,
|
|
45658
|
+
access: "delete"
|
|
45659
|
+
},
|
|
45660
|
+
"keychainAdmin.reveal": {
|
|
45661
|
+
capName: "keychain-admin",
|
|
45662
|
+
capScope: "system",
|
|
45663
|
+
addonId: null,
|
|
45664
|
+
access: "create"
|
|
45665
|
+
},
|
|
45666
|
+
"keychainAdmin.rotateMasterKey": {
|
|
45667
|
+
capName: "keychain-admin",
|
|
45668
|
+
capScope: "system",
|
|
45669
|
+
addonId: null,
|
|
45670
|
+
access: "create"
|
|
45671
|
+
},
|
|
45672
|
+
"keychainAdmin.status": {
|
|
45673
|
+
capName: "keychain-admin",
|
|
45674
|
+
capScope: "system",
|
|
45675
|
+
addonId: null,
|
|
45676
|
+
access: "view"
|
|
45677
|
+
},
|
|
44019
45678
|
"lawnMowerControl.dock": {
|
|
44020
45679
|
capName: "lawn-mower-control",
|
|
44021
45680
|
capScope: "device",
|
|
@@ -45390,6 +47049,18 @@ Object.freeze({
|
|
|
45390
47049
|
addonId: null,
|
|
45391
47050
|
access: "create"
|
|
45392
47051
|
},
|
|
47052
|
+
"pipelineAnalytics.addRetrainFrameFromRecording": {
|
|
47053
|
+
capName: "pipeline-analytics",
|
|
47054
|
+
capScope: "device",
|
|
47055
|
+
addonId: null,
|
|
47056
|
+
access: "create"
|
|
47057
|
+
},
|
|
47058
|
+
"pipelineAnalytics.addRetrainFramesToCollection": {
|
|
47059
|
+
capName: "pipeline-analytics",
|
|
47060
|
+
capScope: "device",
|
|
47061
|
+
addonId: null,
|
|
47062
|
+
access: "create"
|
|
47063
|
+
},
|
|
45393
47064
|
"pipelineAnalytics.applyDeviceSettingsPatch": {
|
|
45394
47065
|
capName: "pipeline-analytics",
|
|
45395
47066
|
capScope: "device",
|
|
@@ -45438,12 +47109,24 @@ Object.freeze({
|
|
|
45438
47109
|
addonId: null,
|
|
45439
47110
|
access: "view"
|
|
45440
47111
|
},
|
|
47112
|
+
"pipelineAnalytics.createRetrainCollection": {
|
|
47113
|
+
capName: "pipeline-analytics",
|
|
47114
|
+
capScope: "device",
|
|
47115
|
+
addonId: null,
|
|
47116
|
+
access: "create"
|
|
47117
|
+
},
|
|
45441
47118
|
"pipelineAnalytics.deleteDeviceEvents": {
|
|
45442
47119
|
capName: "pipeline-analytics",
|
|
45443
47120
|
capScope: "device",
|
|
45444
47121
|
addonId: null,
|
|
45445
47122
|
access: "delete"
|
|
45446
47123
|
},
|
|
47124
|
+
"pipelineAnalytics.deleteRetrainCollection": {
|
|
47125
|
+
capName: "pipeline-analytics",
|
|
47126
|
+
capScope: "device",
|
|
47127
|
+
addonId: null,
|
|
47128
|
+
access: "delete"
|
|
47129
|
+
},
|
|
45447
47130
|
"pipelineAnalytics.deleteTracks": {
|
|
45448
47131
|
capName: "pipeline-analytics",
|
|
45449
47132
|
capScope: "device",
|
|
@@ -45648,6 +47331,24 @@ Object.freeze({
|
|
|
45648
47331
|
addonId: null,
|
|
45649
47332
|
access: "view"
|
|
45650
47333
|
},
|
|
47334
|
+
"pipelineAnalytics.listRetrainAssistProfiles": {
|
|
47335
|
+
capName: "pipeline-analytics",
|
|
47336
|
+
capScope: "device",
|
|
47337
|
+
addonId: null,
|
|
47338
|
+
access: "view"
|
|
47339
|
+
},
|
|
47340
|
+
"pipelineAnalytics.listRetrainCollectionFrames": {
|
|
47341
|
+
capName: "pipeline-analytics",
|
|
47342
|
+
capScope: "device",
|
|
47343
|
+
addonId: null,
|
|
47344
|
+
access: "view"
|
|
47345
|
+
},
|
|
47346
|
+
"pipelineAnalytics.listRetrainCollections": {
|
|
47347
|
+
capName: "pipeline-analytics",
|
|
47348
|
+
capScope: "device",
|
|
47349
|
+
addonId: null,
|
|
47350
|
+
access: "view"
|
|
47351
|
+
},
|
|
45651
47352
|
"pipelineAnalytics.listRetrainFrames": {
|
|
45652
47353
|
capName: "pipeline-analytics",
|
|
45653
47354
|
capScope: "device",
|
|
@@ -45696,6 +47397,12 @@ Object.freeze({
|
|
|
45696
47397
|
addonId: null,
|
|
45697
47398
|
access: "create"
|
|
45698
47399
|
},
|
|
47400
|
+
"pipelineAnalytics.proposeRetrainAnnotationsWithLlm": {
|
|
47401
|
+
capName: "pipeline-analytics",
|
|
47402
|
+
capScope: "device",
|
|
47403
|
+
addonId: null,
|
|
47404
|
+
access: "create"
|
|
47405
|
+
},
|
|
45699
47406
|
"pipelineAnalytics.pruneEvents": {
|
|
45700
47407
|
capName: "pipeline-analytics",
|
|
45701
47408
|
capScope: "device",
|
|
@@ -45750,6 +47457,18 @@ Object.freeze({
|
|
|
45750
47457
|
addonId: null,
|
|
45751
47458
|
access: "create"
|
|
45752
47459
|
},
|
|
47460
|
+
"pipelineAnalytics.removeRetrainFrameFromCollection": {
|
|
47461
|
+
capName: "pipeline-analytics",
|
|
47462
|
+
capScope: "device",
|
|
47463
|
+
addonId: null,
|
|
47464
|
+
access: "delete"
|
|
47465
|
+
},
|
|
47466
|
+
"pipelineAnalytics.renameRetrainCollection": {
|
|
47467
|
+
capName: "pipeline-analytics",
|
|
47468
|
+
capScope: "device",
|
|
47469
|
+
addonId: null,
|
|
47470
|
+
access: "create"
|
|
47471
|
+
},
|
|
45753
47472
|
"pipelineAnalytics.restageRetrainTrack": {
|
|
45754
47473
|
capName: "pipeline-analytics",
|
|
45755
47474
|
capScope: "device",
|
|
@@ -46038,6 +47757,12 @@ Object.freeze({
|
|
|
46038
47757
|
addonId: null,
|
|
46039
47758
|
access: "view"
|
|
46040
47759
|
},
|
|
47760
|
+
"pipelineOrchestrator.abortNodeBenchmark": {
|
|
47761
|
+
capName: "pipeline-orchestrator",
|
|
47762
|
+
capScope: "system",
|
|
47763
|
+
addonId: null,
|
|
47764
|
+
access: "create"
|
|
47765
|
+
},
|
|
46041
47766
|
"pipelineOrchestrator.applyAutoTune": {
|
|
46042
47767
|
capName: "pipeline-orchestrator",
|
|
46043
47768
|
capScope: "system",
|
|
@@ -46062,6 +47787,12 @@ Object.freeze({
|
|
|
46062
47787
|
addonId: null,
|
|
46063
47788
|
access: "create"
|
|
46064
47789
|
},
|
|
47790
|
+
"pipelineOrchestrator.deleteNodeBenchmarkResult": {
|
|
47791
|
+
capName: "pipeline-orchestrator",
|
|
47792
|
+
capScope: "system",
|
|
47793
|
+
addonId: null,
|
|
47794
|
+
access: "delete"
|
|
47795
|
+
},
|
|
46065
47796
|
"pipelineOrchestrator.getAgentLoad": {
|
|
46066
47797
|
capName: "pipeline-orchestrator",
|
|
46067
47798
|
capScope: "system",
|
|
@@ -46170,6 +47901,24 @@ Object.freeze({
|
|
|
46170
47901
|
addonId: null,
|
|
46171
47902
|
access: "view"
|
|
46172
47903
|
},
|
|
47904
|
+
"pipelineOrchestrator.getNodeBenchmarkCandidates": {
|
|
47905
|
+
capName: "pipeline-orchestrator",
|
|
47906
|
+
capScope: "system",
|
|
47907
|
+
addonId: null,
|
|
47908
|
+
access: "view"
|
|
47909
|
+
},
|
|
47910
|
+
"pipelineOrchestrator.getNodeBenchmarkPreflight": {
|
|
47911
|
+
capName: "pipeline-orchestrator",
|
|
47912
|
+
capScope: "system",
|
|
47913
|
+
addonId: null,
|
|
47914
|
+
access: "view"
|
|
47915
|
+
},
|
|
47916
|
+
"pipelineOrchestrator.getNodeBenchmarkStatus": {
|
|
47917
|
+
capName: "pipeline-orchestrator",
|
|
47918
|
+
capScope: "system",
|
|
47919
|
+
addonId: null,
|
|
47920
|
+
access: "view"
|
|
47921
|
+
},
|
|
46173
47922
|
"pipelineOrchestrator.getNodeInferenceDevices": {
|
|
46174
47923
|
capName: "pipeline-orchestrator",
|
|
46175
47924
|
capScope: "system",
|
|
@@ -46212,6 +47961,12 @@ Object.freeze({
|
|
|
46212
47961
|
addonId: null,
|
|
46213
47962
|
access: "view"
|
|
46214
47963
|
},
|
|
47964
|
+
"pipelineOrchestrator.listNodeBenchmarkResults": {
|
|
47965
|
+
capName: "pipeline-orchestrator",
|
|
47966
|
+
capScope: "system",
|
|
47967
|
+
addonId: null,
|
|
47968
|
+
access: "view"
|
|
47969
|
+
},
|
|
46215
47970
|
"pipelineOrchestrator.pauseForStorageMigration": {
|
|
46216
47971
|
capName: "pipeline-orchestrator",
|
|
46217
47972
|
capScope: "system",
|
|
@@ -46356,6 +48111,12 @@ Object.freeze({
|
|
|
46356
48111
|
addonId: null,
|
|
46357
48112
|
access: "create"
|
|
46358
48113
|
},
|
|
48114
|
+
"pipelineOrchestrator.startNodeBenchmark": {
|
|
48115
|
+
capName: "pipeline-orchestrator",
|
|
48116
|
+
capScope: "system",
|
|
48117
|
+
addonId: null,
|
|
48118
|
+
access: "create"
|
|
48119
|
+
},
|
|
46359
48120
|
"pipelineOrchestrator.suggestShares": {
|
|
46360
48121
|
capName: "pipeline-orchestrator",
|
|
46361
48122
|
capScope: "system",
|
|
@@ -46374,6 +48135,12 @@ Object.freeze({
|
|
|
46374
48135
|
addonId: null,
|
|
46375
48136
|
access: "create"
|
|
46376
48137
|
},
|
|
48138
|
+
"pipelineRunner.abortNodeBench": {
|
|
48139
|
+
capName: "pipeline-runner",
|
|
48140
|
+
capScope: "system",
|
|
48141
|
+
addonId: null,
|
|
48142
|
+
access: "create"
|
|
48143
|
+
},
|
|
46377
48144
|
"pipelineRunner.attachCamera": {
|
|
46378
48145
|
capName: "pipeline-runner",
|
|
46379
48146
|
capScope: "system",
|
|
@@ -46422,6 +48189,12 @@ Object.freeze({
|
|
|
46422
48189
|
addonId: null,
|
|
46423
48190
|
access: "view"
|
|
46424
48191
|
},
|
|
48192
|
+
"pipelineRunner.getNodeBenchStatus": {
|
|
48193
|
+
capName: "pipeline-runner",
|
|
48194
|
+
capScope: "system",
|
|
48195
|
+
addonId: null,
|
|
48196
|
+
access: "view"
|
|
48197
|
+
},
|
|
46425
48198
|
"pipelineRunner.getParkedTrackFrame": {
|
|
46426
48199
|
capName: "pipeline-runner",
|
|
46427
48200
|
capScope: "system",
|
|
@@ -46464,6 +48237,12 @@ Object.freeze({
|
|
|
46464
48237
|
addonId: null,
|
|
46465
48238
|
access: "create"
|
|
46466
48239
|
},
|
|
48240
|
+
"pipelineRunner.startNodeBench": {
|
|
48241
|
+
capName: "pipeline-runner",
|
|
48242
|
+
capScope: "system",
|
|
48243
|
+
addonId: null,
|
|
48244
|
+
access: "create"
|
|
48245
|
+
},
|
|
46467
48246
|
"plateGallery.assignPlate": {
|
|
46468
48247
|
capName: "plate-gallery",
|
|
46469
48248
|
capScope: "system",
|
|
@@ -51393,6 +53172,11 @@ Object.freeze({
|
|
|
51393
53172
|
form: "single",
|
|
51394
53173
|
optional: false
|
|
51395
53174
|
}],
|
|
53175
|
+
"pipelineAnalytics.addRetrainFrameFromRecording": [{
|
|
53176
|
+
name: "deviceId",
|
|
53177
|
+
form: "single",
|
|
53178
|
+
optional: false
|
|
53179
|
+
}],
|
|
51396
53180
|
"pipelineAnalytics.applyDeviceSettingsPatch": [{
|
|
51397
53181
|
name: "deviceId",
|
|
51398
53182
|
form: "single",
|
|
@@ -51583,6 +53367,11 @@ Object.freeze({
|
|
|
51583
53367
|
form: "single",
|
|
51584
53368
|
optional: false
|
|
51585
53369
|
}],
|
|
53370
|
+
"pipelineAnalytics.proposeRetrainAnnotationsWithLlm": [{
|
|
53371
|
+
name: "deviceId",
|
|
53372
|
+
form: "single",
|
|
53373
|
+
optional: false
|
|
53374
|
+
}],
|
|
51586
53375
|
"pipelineAnalytics.pruneEventsBefore": [{
|
|
51587
53376
|
name: "deviceId",
|
|
51588
53377
|
form: "single",
|