@camstack/addon-provider-ecowitt 0.2.123 → 0.2.124
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.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createServer } from "http";
|
|
2
2
|
import { EventEmitter } from "events";
|
|
3
3
|
import { createSocket } from "dgram";
|
|
4
|
-
//#region ../types/dist/event-category-
|
|
4
|
+
//#region ../types/dist/event-category-DaIZi00R.mjs
|
|
5
5
|
var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
6
6
|
EventCategory["SystemBoot"] = "system.boot";
|
|
7
7
|
EventCategory["SystemAddonsReady"] = "system.addons-ready";
|
|
@@ -80,6 +80,13 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
|
80
80
|
*/
|
|
81
81
|
EventCategory["AddonLoadFailed"] = "addon.load-failed";
|
|
82
82
|
/**
|
|
83
|
+
* A keychain value was stored or removed (D787). Carries the ref, its
|
|
84
|
+
* owner and the new version — NEVER the value. A process holding the ref
|
|
85
|
+
* drops its cached copy and the owning `BaseAddon` re-resolves its config.
|
|
86
|
+
* Telemetry (D8): a process that misses it still revalidates by version.
|
|
87
|
+
*/
|
|
88
|
+
EventCategory["KeychainChanged"] = "keychain.changed";
|
|
89
|
+
/**
|
|
83
90
|
* Addon recovered from a previous failure. Emitted when an addon
|
|
84
91
|
* transitions from `failed` back to `healthy` (typically via the
|
|
85
92
|
* monitor's auto-retry loop, or after manual `addons.retryLoad`).
|
|
@@ -5372,7 +5379,7 @@ var ZodIssueCode$1 = {
|
|
|
5372
5379
|
var ZodFirstPartyTypeKind$1;
|
|
5373
5380
|
ZodFirstPartyTypeKind$1 || (ZodFirstPartyTypeKind$1 = {});
|
|
5374
5381
|
//#endregion
|
|
5375
|
-
//#region ../types/dist/sleep-
|
|
5382
|
+
//#region ../types/dist/sleep-Cr5YOk3m.mjs
|
|
5376
5383
|
/**
|
|
5377
5384
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5378
5385
|
* window to float samples (D455).
|
|
@@ -5451,6 +5458,97 @@ function buildAlawTable() {
|
|
|
5451
5458
|
}
|
|
5452
5459
|
buildUlawTable();
|
|
5453
5460
|
buildAlawTable();
|
|
5461
|
+
/** Is this field's stored value a credential? */
|
|
5462
|
+
function isSecretConfigField(field) {
|
|
5463
|
+
if (field.type === "password") return true;
|
|
5464
|
+
return "secret" in field && field.secret === true;
|
|
5465
|
+
}
|
|
5466
|
+
/**
|
|
5467
|
+
* Is this field's value stored in the KEYCHAIN (D787)? Every secret field is,
|
|
5468
|
+
* by its TYPE, unless it opts out with `storage: 'inline'` — never by its name.
|
|
5469
|
+
*/
|
|
5470
|
+
function isKeychainStoredField(field) {
|
|
5471
|
+
if (!isSecretConfigField(field)) return false;
|
|
5472
|
+
if (field.type === "textarea" && field.isJson === true) return false;
|
|
5473
|
+
return !("storage" in field && field.storage === "inline");
|
|
5474
|
+
}
|
|
5475
|
+
/**
|
|
5476
|
+
* What a settings blob holds where a secret used to be.
|
|
5477
|
+
*
|
|
5478
|
+
* A keychain-stored field never holds its value. It holds a self-describing
|
|
5479
|
+
* MARKER, `{"$secret":"secret://…","v":1}` — an object, never a string, so no
|
|
5480
|
+
* code can mistake it for a credential and no form can send it to a camera as
|
|
5481
|
+
* a password. The empty state is `null` / absent, never `''`.
|
|
5482
|
+
*
|
|
5483
|
+
* The same shapes travel to and from the admin UI:
|
|
5484
|
+
*
|
|
5485
|
+
* - read: `hydrateSchema` hands a secret field a {@link SecretFieldView}
|
|
5486
|
+
* (`{ $secret, v, set: true }`) or `null` — the browser learns whether a
|
|
5487
|
+
* value is set, never the value.
|
|
5488
|
+
* - write: an untouched field submits the view back unchanged (KEEP); a typed
|
|
5489
|
+
* value is a plain non-empty string (CHANGE); the Clear button submits
|
|
5490
|
+
* {@link SECRET_CLEAR} (CLEAR). `''`, `null` and the legacy redaction tokens
|
|
5491
|
+
* are KEEP — an empty string is what a defaults-fallback pushes back, and
|
|
5492
|
+
* treating it as "clear" is how a save destroyed a stored credential before.
|
|
5493
|
+
*
|
|
5494
|
+
* Pure and browser-safe.
|
|
5495
|
+
*/
|
|
5496
|
+
var SECRET_CLEAR = { $secretClear: true };
|
|
5497
|
+
/** The `'***'` token D634 redaction writes for non-admins. */
|
|
5498
|
+
var LEGACY_DEVICE_REDACTION = "***";
|
|
5499
|
+
function isRecord$1(value) {
|
|
5500
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5501
|
+
}
|
|
5502
|
+
function makeSecretMarker(ref) {
|
|
5503
|
+
return {
|
|
5504
|
+
$secret: ref,
|
|
5505
|
+
v: 1
|
|
5506
|
+
};
|
|
5507
|
+
}
|
|
5508
|
+
/** A stored marker: an object whose `$secret` is a non-empty string. */
|
|
5509
|
+
function isSecretMarker(value) {
|
|
5510
|
+
if (!isRecord$1(value)) return false;
|
|
5511
|
+
const ref = value["$secret"];
|
|
5512
|
+
return typeof ref === "string" && ref.length > 0;
|
|
5513
|
+
}
|
|
5514
|
+
function isSecretClear(value) {
|
|
5515
|
+
return isRecord$1(value) && value["$secretClear"] === true;
|
|
5516
|
+
}
|
|
5517
|
+
/**
|
|
5518
|
+
* The UI view of a stored secret field value: a marker becomes "set", inline
|
|
5519
|
+
* plaintext becomes "set (inline)", nothing becomes `null`. A value never
|
|
5520
|
+
* survives this function.
|
|
5521
|
+
*/
|
|
5522
|
+
function toSecretFieldView(stored) {
|
|
5523
|
+
if (isSecretMarker(stored)) return {
|
|
5524
|
+
$secret: stored.$secret,
|
|
5525
|
+
v: 1,
|
|
5526
|
+
set: true
|
|
5527
|
+
};
|
|
5528
|
+
if (typeof stored === "string" && stored.length > 0) return {
|
|
5529
|
+
$secret: null,
|
|
5530
|
+
v: 1,
|
|
5531
|
+
set: true,
|
|
5532
|
+
inline: true
|
|
5533
|
+
};
|
|
5534
|
+
return null;
|
|
5535
|
+
}
|
|
5536
|
+
/**
|
|
5537
|
+
* Classify an incoming value for a secret path. Only a non-empty string that is
|
|
5538
|
+
* not a redaction token sets a value; only {@link SECRET_CLEAR} clears.
|
|
5539
|
+
* Everything else — a marker (ours or anyone's), a UI view, `''`, `null`,
|
|
5540
|
+
* `undefined`, a redaction token, a non-string — keeps what is stored.
|
|
5541
|
+
*/
|
|
5542
|
+
function classifySecretWrite(incoming) {
|
|
5543
|
+
if (isSecretClear(incoming)) return { kind: "clear" };
|
|
5544
|
+
if (typeof incoming !== "string") return { kind: "keep" };
|
|
5545
|
+
if (incoming.length === 0) return { kind: "keep" };
|
|
5546
|
+
if (incoming === "__camstack_redacted__" || incoming === LEGACY_DEVICE_REDACTION) return { kind: "keep" };
|
|
5547
|
+
return {
|
|
5548
|
+
kind: "set",
|
|
5549
|
+
value: incoming
|
|
5550
|
+
};
|
|
5551
|
+
}
|
|
5454
5552
|
Object.fromEntries([
|
|
5455
5553
|
{
|
|
5456
5554
|
id: "overview",
|
|
@@ -5622,33 +5720,19 @@ Object.fromEntries([
|
|
|
5622
5720
|
function isValuelessField(field) {
|
|
5623
5721
|
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";
|
|
5624
5722
|
}
|
|
5625
|
-
|
|
5626
|
-
* Merge a `ConfigUISchema` with a raw `values` record into a
|
|
5627
|
-
* `ConfigUISchemaWithValues`. Used by every `get*Settings` backend endpoint
|
|
5628
|
-
* before returning to the admin UI. Groups are walked recursively.
|
|
5629
|
-
*
|
|
5630
|
-
* For each leaf field:
|
|
5631
|
-
* - structural fields (`separator`, `info`, `button`) pass through unchanged
|
|
5632
|
-
* - other fields get `value = values[key] ?? field.default ?? null`
|
|
5633
|
-
*
|
|
5634
|
-
* Unknown keys in `values` (keys not declared in the schema) are silently
|
|
5635
|
-
* ignored — they don't contribute to the output. Missing keys fall back to
|
|
5636
|
-
* the schema default or `null`. This mirrors the old backend behaviour where
|
|
5637
|
-
* `FormBuilder` rendered `values[key] ?? field.default`.
|
|
5638
|
-
*/
|
|
5639
|
-
function hydrateSchema(schema, values) {
|
|
5723
|
+
function hydrateSchema(schema, values, options = {}) {
|
|
5640
5724
|
return {
|
|
5641
5725
|
...schema.tabs ? { tabs: [...schema.tabs] } : {},
|
|
5642
5726
|
sections: schema.sections.map((section) => ({
|
|
5643
5727
|
...section,
|
|
5644
|
-
fields: section.fields.map((field) => hydrateField(field, values))
|
|
5728
|
+
fields: section.fields.map((field) => hydrateField(field, values, options))
|
|
5645
5729
|
}))
|
|
5646
5730
|
};
|
|
5647
5731
|
}
|
|
5648
|
-
function hydrateField(field, values) {
|
|
5732
|
+
function hydrateField(field, values, options) {
|
|
5649
5733
|
if (isValuelessField(field)) return field;
|
|
5650
5734
|
if (field.type === "group") {
|
|
5651
|
-
const hydratedChildren = field.fields.map((child) => hydrateField(child, values));
|
|
5735
|
+
const hydratedChildren = field.fields.map((child) => hydrateField(child, values, options));
|
|
5652
5736
|
return {
|
|
5653
5737
|
...field,
|
|
5654
5738
|
fields: hydratedChildren
|
|
@@ -5657,7 +5741,7 @@ function hydrateField(field, values) {
|
|
|
5657
5741
|
if (field.type === "sub-tabs") {
|
|
5658
5742
|
const hydratedTabs = field.tabs.map((tab) => ({
|
|
5659
5743
|
...tab,
|
|
5660
|
-
fields: tab.fields.map((child) => hydrateField(child, values))
|
|
5744
|
+
fields: tab.fields.map((child) => hydrateField(child, values, options))
|
|
5661
5745
|
}));
|
|
5662
5746
|
return {
|
|
5663
5747
|
...field,
|
|
@@ -5667,6 +5751,33 @@ function hydrateField(field, values) {
|
|
|
5667
5751
|
const key = field.key;
|
|
5668
5752
|
const storedValue = Object.prototype.hasOwnProperty.call(values, key) ? values[key] : void 0;
|
|
5669
5753
|
const defaultValue = field.default;
|
|
5754
|
+
const asView = (v) => isSecretMarker(v) || options.inlineSecretsAsViews === true && v !== void 0;
|
|
5755
|
+
if (isKeychainStoredField(field) && asView(storedValue)) return {
|
|
5756
|
+
...field,
|
|
5757
|
+
value: toSecretFieldView(storedValue)
|
|
5758
|
+
};
|
|
5759
|
+
if (isKeychainStoredField(field) && options.inlineSecretsAsViews === true) return {
|
|
5760
|
+
...field,
|
|
5761
|
+
value: null
|
|
5762
|
+
};
|
|
5763
|
+
if (field.type === "editable-array" && Array.isArray(storedValue)) {
|
|
5764
|
+
const secretItemKeys = field.itemFields.filter((item) => "key" in item && isKeychainStoredField(item)).map((item) => "key" in item ? item.key : "");
|
|
5765
|
+
if (secretItemKeys.length > 0) {
|
|
5766
|
+
const rows = storedValue.map((row) => {
|
|
5767
|
+
if (row === null || typeof row !== "object" || Array.isArray(row)) return row;
|
|
5768
|
+
const out = { ...row };
|
|
5769
|
+
for (const k of secretItemKeys) {
|
|
5770
|
+
const v = Reflect.get(row, k);
|
|
5771
|
+
if (asView(v)) out[k] = toSecretFieldView(v);
|
|
5772
|
+
}
|
|
5773
|
+
return out;
|
|
5774
|
+
});
|
|
5775
|
+
return {
|
|
5776
|
+
...field,
|
|
5777
|
+
value: rows
|
|
5778
|
+
};
|
|
5779
|
+
}
|
|
5780
|
+
}
|
|
5670
5781
|
if (field.multiple) {
|
|
5671
5782
|
const stored = Array.isArray(storedValue) ? storedValue : storedValue !== void 0 && storedValue !== null ? [storedValue] : [];
|
|
5672
5783
|
const itemFallback = field.multiple.itemDefault !== void 0 ? field.multiple.itemDefault : defaultValue !== void 0 ? defaultValue : typeOf(field) === "string" ? "" : null;
|
|
@@ -5909,6 +6020,431 @@ function projectStore(store, perNodeKeys, nodeId) {
|
|
|
5909
6020
|
}
|
|
5910
6021
|
return out;
|
|
5911
6022
|
}
|
|
6023
|
+
var GLOBAL_SCOPE = { kind: "global" };
|
|
6024
|
+
/** The scope every addon-wide (not per-node, not per-device) setting lives in. */
|
|
6025
|
+
function globalSecretScope() {
|
|
6026
|
+
return GLOBAL_SCOPE;
|
|
6027
|
+
}
|
|
6028
|
+
function encodeSegment(value) {
|
|
6029
|
+
return encodeURIComponent(value);
|
|
6030
|
+
}
|
|
6031
|
+
/**
|
|
6032
|
+
* The field path of a value inside an array item, addressed by the item's id:
|
|
6033
|
+
* `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
|
|
6034
|
+
* `providers[authentik].clientSecret`.
|
|
6035
|
+
*/
|
|
6036
|
+
function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
|
|
6037
|
+
return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
|
|
6038
|
+
}
|
|
6039
|
+
/** A write to a secret path could not be stored in the keychain, so it was refused. */
|
|
6040
|
+
var KeychainWriteRefusedError = class extends Error {
|
|
6041
|
+
fieldPath;
|
|
6042
|
+
constructor(fieldPath, cause) {
|
|
6043
|
+
super(`secret "${fieldPath}" was not saved: the keychain could not store it (${cause instanceof Error ? cause.message : String(cause)}). Nothing was written.`);
|
|
6044
|
+
this.fieldPath = fieldPath;
|
|
6045
|
+
this.name = "KeychainWriteRefusedError";
|
|
6046
|
+
}
|
|
6047
|
+
};
|
|
6048
|
+
var KEEP = { kind: "keep" };
|
|
6049
|
+
function isRecord(value) {
|
|
6050
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6051
|
+
}
|
|
6052
|
+
function defaultMintId() {
|
|
6053
|
+
return globalThis.crypto.randomUUID();
|
|
6054
|
+
}
|
|
6055
|
+
/** Every marker ref anywhere under `value`. */
|
|
6056
|
+
function collectSecretMarkerRefs(value, out = []) {
|
|
6057
|
+
if (isSecretMarker(value)) {
|
|
6058
|
+
out.push(value.$secret);
|
|
6059
|
+
return out;
|
|
6060
|
+
}
|
|
6061
|
+
if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
|
|
6062
|
+
else if (isRecord(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
|
|
6063
|
+
return out;
|
|
6064
|
+
}
|
|
6065
|
+
async function storedValueEquals(secrets, marker, candidate) {
|
|
6066
|
+
const resolved = (await secrets.resolve([marker.$secret]))[marker.$secret];
|
|
6067
|
+
return resolved?.kind === "value" && resolved.value === candidate;
|
|
6068
|
+
}
|
|
6069
|
+
async function writeLeaf(ctx, incoming, stored, fieldPath) {
|
|
6070
|
+
const intent = classifySecretWrite(incoming);
|
|
6071
|
+
const ref = ctx.secrets.ref(ctx.scope, fieldPath);
|
|
6072
|
+
const storedIsOurs = isSecretMarker(stored) && stored.$secret === ref;
|
|
6073
|
+
if (intent.kind === "keep") return KEEP;
|
|
6074
|
+
if (intent.kind === "set" && !ctx.operatorWrite && typeof stored === "string" && stored === intent.value) return KEEP;
|
|
6075
|
+
if (intent.kind === "clear") {
|
|
6076
|
+
if (storedIsOurs) ctx.deletes.push(ref);
|
|
6077
|
+
return {
|
|
6078
|
+
kind: "value",
|
|
6079
|
+
value: null
|
|
6080
|
+
};
|
|
6081
|
+
}
|
|
6082
|
+
if (storedIsOurs && await storedValueEquals(ctx.secrets, stored, intent.value)) return {
|
|
6083
|
+
kind: "value",
|
|
6084
|
+
value: stored
|
|
6085
|
+
};
|
|
6086
|
+
try {
|
|
6087
|
+
await ctx.secrets.put(ref, intent.value);
|
|
6088
|
+
} catch (err) {
|
|
6089
|
+
throw new KeychainWriteRefusedError(fieldPath, err);
|
|
6090
|
+
}
|
|
6091
|
+
return {
|
|
6092
|
+
kind: "value",
|
|
6093
|
+
value: makeSecretMarker(ref)
|
|
6094
|
+
};
|
|
6095
|
+
}
|
|
6096
|
+
/** Apply a member result onto `out`: KEEP restores the stored member, or removes it. */
|
|
6097
|
+
function applyMember(out, key, result, storedParent) {
|
|
6098
|
+
if (result.kind === "value") {
|
|
6099
|
+
out[key] = result.value;
|
|
6100
|
+
return;
|
|
6101
|
+
}
|
|
6102
|
+
if (Object.prototype.hasOwnProperty.call(storedParent, key)) out[key] = storedParent[key];
|
|
6103
|
+
else delete out[key];
|
|
6104
|
+
}
|
|
6105
|
+
async function writeMembers(ctx, children, incoming, stored, pathOf) {
|
|
6106
|
+
const out = { ...incoming };
|
|
6107
|
+
for (const [member, node] of children) applyMember(out, member, await writeNode(ctx, node, incoming[member], stored[member], pathOf(member)), stored);
|
|
6108
|
+
return out;
|
|
6109
|
+
}
|
|
6110
|
+
function rowId(row, idKey) {
|
|
6111
|
+
const raw = row[idKey];
|
|
6112
|
+
if (typeof raw === "string" && raw.length > 0) return raw;
|
|
6113
|
+
if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
|
|
6114
|
+
return null;
|
|
6115
|
+
}
|
|
6116
|
+
async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
6117
|
+
const storedRows = Array.isArray(stored) ? stored.filter(isRecord) : [];
|
|
6118
|
+
if (!Array.isArray(incoming)) {
|
|
6119
|
+
ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
|
|
6120
|
+
return {
|
|
6121
|
+
kind: "value",
|
|
6122
|
+
value: incoming
|
|
6123
|
+
};
|
|
6124
|
+
}
|
|
6125
|
+
const storedById = /* @__PURE__ */ new Map();
|
|
6126
|
+
for (const row of storedRows) {
|
|
6127
|
+
const id = rowId(row, node.idKey);
|
|
6128
|
+
if (id !== null) storedById.set(id, row);
|
|
6129
|
+
}
|
|
6130
|
+
const kept = /* @__PURE__ */ new Set();
|
|
6131
|
+
const rows = [];
|
|
6132
|
+
for (const row of incoming) {
|
|
6133
|
+
if (!isRecord(row)) {
|
|
6134
|
+
rows.push(row);
|
|
6135
|
+
continue;
|
|
6136
|
+
}
|
|
6137
|
+
const id = rowId(row, node.idKey) ?? ctx.mintId();
|
|
6138
|
+
kept.add(id);
|
|
6139
|
+
const withId = {
|
|
6140
|
+
...row,
|
|
6141
|
+
[node.idKey]: row[node.idKey] ?? id
|
|
6142
|
+
};
|
|
6143
|
+
if (rowId(withId, node.idKey) === null) withId[node.idKey] = id;
|
|
6144
|
+
const storedRow = storedById.get(id) ?? {};
|
|
6145
|
+
rows.push(await writeMembers(ctx, node.item, withId, storedRow, (member) => arrayItemFieldPath(fieldPath, id, member)));
|
|
6146
|
+
}
|
|
6147
|
+
for (const [id, row] of storedById) if (!kept.has(id)) ctx.deletes.push(...collectSecretMarkerRefs(row));
|
|
6148
|
+
return {
|
|
6149
|
+
kind: "value",
|
|
6150
|
+
value: rows
|
|
6151
|
+
};
|
|
6152
|
+
}
|
|
6153
|
+
async function writeNode(ctx, node, incoming, stored, fieldPath) {
|
|
6154
|
+
switch (node.kind) {
|
|
6155
|
+
case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
|
|
6156
|
+
case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
|
|
6157
|
+
case "object": {
|
|
6158
|
+
if (!isRecord(incoming)) {
|
|
6159
|
+
if (incoming === void 0) return KEEP;
|
|
6160
|
+
ctx.deletes.push(...collectSecretMarkerRefs(stored));
|
|
6161
|
+
return {
|
|
6162
|
+
kind: "value",
|
|
6163
|
+
value: incoming
|
|
6164
|
+
};
|
|
6165
|
+
}
|
|
6166
|
+
const storedObj = isRecord(stored) ? stored : {};
|
|
6167
|
+
return {
|
|
6168
|
+
kind: "value",
|
|
6169
|
+
value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
|
|
6170
|
+
};
|
|
6171
|
+
}
|
|
6172
|
+
}
|
|
6173
|
+
}
|
|
6174
|
+
/** Split a perNode-scoped key (`key@nodeId`). */
|
|
6175
|
+
function splitNodeKey(key) {
|
|
6176
|
+
const at = key.indexOf("@");
|
|
6177
|
+
return at <= 0 ? {
|
|
6178
|
+
base: key,
|
|
6179
|
+
nodeId: null
|
|
6180
|
+
} : {
|
|
6181
|
+
base: key.slice(0, at),
|
|
6182
|
+
nodeId: key.slice(at + 1)
|
|
6183
|
+
};
|
|
6184
|
+
}
|
|
6185
|
+
/** Rewrite a settings patch so no secret value reaches the blob. See the file doc. */
|
|
6186
|
+
async function transformSecretWrite(input) {
|
|
6187
|
+
const deletes = [];
|
|
6188
|
+
const base = {
|
|
6189
|
+
secrets: input.secrets,
|
|
6190
|
+
mintId: input.mintId ?? defaultMintId,
|
|
6191
|
+
deletes,
|
|
6192
|
+
operatorWrite: input.operatorWrite === true
|
|
6193
|
+
};
|
|
6194
|
+
const out = {};
|
|
6195
|
+
for (const [key, incoming] of Object.entries(input.patch)) {
|
|
6196
|
+
const { base: baseKey, nodeId } = splitNodeKey(key);
|
|
6197
|
+
const node = input.tree.get(baseKey);
|
|
6198
|
+
if (node === void 0) {
|
|
6199
|
+
out[key] = incoming;
|
|
6200
|
+
continue;
|
|
6201
|
+
}
|
|
6202
|
+
const scope = nodeId !== null && nodeId.length > 0 ? {
|
|
6203
|
+
kind: "node",
|
|
6204
|
+
nodeId
|
|
6205
|
+
} : input.scope ?? globalSecretScope();
|
|
6206
|
+
const result = await writeNode({
|
|
6207
|
+
...base,
|
|
6208
|
+
scope
|
|
6209
|
+
}, node, incoming, input.stored[key], baseKey);
|
|
6210
|
+
if (result.kind === "value") out[key] = result.value;
|
|
6211
|
+
}
|
|
6212
|
+
return {
|
|
6213
|
+
patch: out,
|
|
6214
|
+
afterWrite: async () => {
|
|
6215
|
+
if (deletes.length === 0) return { orphaned: [] };
|
|
6216
|
+
try {
|
|
6217
|
+
await input.secrets.delete([...new Set(deletes)]);
|
|
6218
|
+
return { orphaned: [] };
|
|
6219
|
+
} catch {
|
|
6220
|
+
return { orphaned: [...new Set(deletes)] };
|
|
6221
|
+
}
|
|
6222
|
+
}
|
|
6223
|
+
};
|
|
6224
|
+
}
|
|
6225
|
+
/**
|
|
6226
|
+
* Replace every marker in `value` with its keychain value. Returns the SAME
|
|
6227
|
+
* reference when there is no marker (no allocation, no keychain call).
|
|
6228
|
+
*/
|
|
6229
|
+
async function resolveSecretMarkers(value, secrets) {
|
|
6230
|
+
const refs = collectSecretMarkerRefs(value);
|
|
6231
|
+
if (refs.length === 0) return {
|
|
6232
|
+
value,
|
|
6233
|
+
unresolved: []
|
|
6234
|
+
};
|
|
6235
|
+
const answers = await secrets.resolve(refs);
|
|
6236
|
+
const unresolved = [];
|
|
6237
|
+
for (const ref of new Set(refs)) {
|
|
6238
|
+
const answer = answers[ref];
|
|
6239
|
+
if (answer === void 0) unresolved.push({
|
|
6240
|
+
ref,
|
|
6241
|
+
reason: "not-initialized"
|
|
6242
|
+
});
|
|
6243
|
+
else if (answer.kind === "unavailable") unresolved.push({
|
|
6244
|
+
ref,
|
|
6245
|
+
reason: answer.reason
|
|
6246
|
+
});
|
|
6247
|
+
else if (answer.kind === "missing" || answer.kind === "forbidden") unresolved.push({
|
|
6248
|
+
ref,
|
|
6249
|
+
reason: answer.kind
|
|
6250
|
+
});
|
|
6251
|
+
}
|
|
6252
|
+
const substitute = (v) => {
|
|
6253
|
+
if (isSecretMarker(v)) {
|
|
6254
|
+
const answer = answers[v.$secret];
|
|
6255
|
+
return answer?.kind === "value" ? {
|
|
6256
|
+
keep: true,
|
|
6257
|
+
value: answer.value
|
|
6258
|
+
} : {
|
|
6259
|
+
keep: false,
|
|
6260
|
+
value: void 0
|
|
6261
|
+
};
|
|
6262
|
+
}
|
|
6263
|
+
if (Array.isArray(v)) {
|
|
6264
|
+
const items = [];
|
|
6265
|
+
for (const item of v) {
|
|
6266
|
+
const s = substitute(item);
|
|
6267
|
+
if (s.keep) items.push(s.value);
|
|
6268
|
+
}
|
|
6269
|
+
return {
|
|
6270
|
+
keep: true,
|
|
6271
|
+
value: items
|
|
6272
|
+
};
|
|
6273
|
+
}
|
|
6274
|
+
if (isRecord(v)) {
|
|
6275
|
+
const out = {};
|
|
6276
|
+
for (const [k, child] of Object.entries(v)) {
|
|
6277
|
+
const s = substitute(child);
|
|
6278
|
+
if (s.keep) out[k] = s.value;
|
|
6279
|
+
}
|
|
6280
|
+
return {
|
|
6281
|
+
keep: true,
|
|
6282
|
+
value: out
|
|
6283
|
+
};
|
|
6284
|
+
}
|
|
6285
|
+
return {
|
|
6286
|
+
keep: true,
|
|
6287
|
+
value: v
|
|
6288
|
+
};
|
|
6289
|
+
};
|
|
6290
|
+
return {
|
|
6291
|
+
value: substitute(value).value,
|
|
6292
|
+
unresolved
|
|
6293
|
+
};
|
|
6294
|
+
}
|
|
6295
|
+
function touchesTree(tree, patch) {
|
|
6296
|
+
if (tree.size === 0) return false;
|
|
6297
|
+
for (const key of Object.keys(patch)) {
|
|
6298
|
+
const at = key.indexOf("@");
|
|
6299
|
+
if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
|
|
6300
|
+
}
|
|
6301
|
+
return false;
|
|
6302
|
+
}
|
|
6303
|
+
/** The blob as stored now; a failed read REFUSES the write instead of guessing. */
|
|
6304
|
+
async function readStoredAddonBlob(raw) {
|
|
6305
|
+
const threeWay = raw.readAddonStoreResult;
|
|
6306
|
+
if (threeWay === void 0) return raw.readAddonStore();
|
|
6307
|
+
const result = await threeWay.call(raw);
|
|
6308
|
+
if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
|
|
6309
|
+
return result.kind === "missing" ? {} : result.value;
|
|
6310
|
+
}
|
|
6311
|
+
function createSecretAwareSettings(raw, opts) {
|
|
6312
|
+
const chains = /* @__PURE__ */ new Map();
|
|
6313
|
+
const serialize = (key, fn) => {
|
|
6314
|
+
const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
|
|
6315
|
+
const tail = next.catch(() => void 0);
|
|
6316
|
+
chains.set(key, tail);
|
|
6317
|
+
tail.then(() => {
|
|
6318
|
+
if (chains.get(key) === tail) chains.delete(key);
|
|
6319
|
+
});
|
|
6320
|
+
return next;
|
|
6321
|
+
};
|
|
6322
|
+
const write = async (chainKey, tree, scope, patch, readStored, rawWrite) => {
|
|
6323
|
+
if (!touchesTree(tree, patch)) return rawWrite(patch);
|
|
6324
|
+
return serialize(chainKey, async () => {
|
|
6325
|
+
const stored = await readStored();
|
|
6326
|
+
const result = await transformSecretWrite({
|
|
6327
|
+
tree,
|
|
6328
|
+
secrets: opts.secrets,
|
|
6329
|
+
patch,
|
|
6330
|
+
stored,
|
|
6331
|
+
...scope !== void 0 ? { scope } : {},
|
|
6332
|
+
operatorWrite: opts.isOperatorWrite?.() === true
|
|
6333
|
+
});
|
|
6334
|
+
if (Object.keys(result.patch).length > 0) await rawWrite(result.patch);
|
|
6335
|
+
const { orphaned } = await result.afterWrite();
|
|
6336
|
+
if (orphaned.length > 0) opts.onOrphaned(orphaned);
|
|
6337
|
+
});
|
|
6338
|
+
};
|
|
6339
|
+
const wrapped = {
|
|
6340
|
+
writeAddonStore: (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p)),
|
|
6341
|
+
writeDeviceStore: (deviceId, patch) => write(`device:${deviceId}`, opts.deviceTree(), {
|
|
6342
|
+
kind: "device",
|
|
6343
|
+
deviceId
|
|
6344
|
+
}, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p))
|
|
6345
|
+
};
|
|
6346
|
+
return new Proxy(raw, { get(target, prop, receiver) {
|
|
6347
|
+
if (prop === "writeAddonStore") return wrapped.writeAddonStore;
|
|
6348
|
+
if (prop === "writeDeviceStore") return wrapped.writeDeviceStore;
|
|
6349
|
+
const value = Reflect.get(target, prop, receiver);
|
|
6350
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
6351
|
+
} });
|
|
6352
|
+
}
|
|
6353
|
+
/** The context the addon sees: identical, except that its settings writes are secret-aware. */
|
|
6354
|
+
function withSecretAwareSettings(context, opts) {
|
|
6355
|
+
const raw = context.settings;
|
|
6356
|
+
if (raw === void 0) return context;
|
|
6357
|
+
const settings = createSecretAwareSettings(raw, opts);
|
|
6358
|
+
return new Proxy(context, { get(target, prop, receiver) {
|
|
6359
|
+
if (prop === "settings") return settings;
|
|
6360
|
+
return Reflect.get(target, prop, receiver);
|
|
6361
|
+
} });
|
|
6362
|
+
}
|
|
6363
|
+
var LEAF = { kind: "leaf" };
|
|
6364
|
+
var DEFAULT_ITEM_ID_KEY = "id";
|
|
6365
|
+
function collectFields(fields, out) {
|
|
6366
|
+
for (const field of fields) {
|
|
6367
|
+
if (field.type === "group") {
|
|
6368
|
+
collectFields(field.fields, out);
|
|
6369
|
+
continue;
|
|
6370
|
+
}
|
|
6371
|
+
if (field.type === "sub-tabs") {
|
|
6372
|
+
for (const tab of field.tabs) collectFields(tab.fields, out);
|
|
6373
|
+
continue;
|
|
6374
|
+
}
|
|
6375
|
+
if (field.type === "editable-array") {
|
|
6376
|
+
const item = /* @__PURE__ */ new Map();
|
|
6377
|
+
for (const itemField of field.itemFields) if ("key" in itemField && isKeychainStoredField(itemField)) item.set(itemField.key, LEAF);
|
|
6378
|
+
if (item.size > 0) out.set(field.key, {
|
|
6379
|
+
kind: "array",
|
|
6380
|
+
idKey: field.itemIdKey ?? DEFAULT_ITEM_ID_KEY,
|
|
6381
|
+
item
|
|
6382
|
+
});
|
|
6383
|
+
continue;
|
|
6384
|
+
}
|
|
6385
|
+
if (!("key" in field) || typeof field.key !== "string") continue;
|
|
6386
|
+
if (isKeychainStoredField(field)) out.set(field.key, LEAF);
|
|
6387
|
+
}
|
|
6388
|
+
}
|
|
6389
|
+
/** The secret tree a settings schema declares. */
|
|
6390
|
+
function secretTreeFromSchema(schema) {
|
|
6391
|
+
const out = /* @__PURE__ */ new Map();
|
|
6392
|
+
if (schema === null) return out;
|
|
6393
|
+
for (const section of schema.sections) collectFields(section.fields, out);
|
|
6394
|
+
return out;
|
|
6395
|
+
}
|
|
6396
|
+
/** Parse `a.b[id].c` into segments; throws on a malformed path (a declaration bug). */
|
|
6397
|
+
function parseSecretStatePath(path) {
|
|
6398
|
+
const segments = [];
|
|
6399
|
+
for (const raw of path.split(".")) {
|
|
6400
|
+
const m = /^([^[\]]+)(?:\[([^[\]]+)\])?$/.exec(raw);
|
|
6401
|
+
if (m === null || m[1] === void 0) throw new Error(`secretStatePaths: malformed path "${path}"`);
|
|
6402
|
+
segments.push(m[2] !== void 0 ? {
|
|
6403
|
+
key: m[1],
|
|
6404
|
+
idKey: m[2]
|
|
6405
|
+
} : { key: m[1] });
|
|
6406
|
+
}
|
|
6407
|
+
if (segments.length === 0) throw new Error(`secretStatePaths: empty path`);
|
|
6408
|
+
if (segments[segments.length - 1]?.idKey !== void 0) throw new Error(`secretStatePaths: "${path}" ends on an array — name the member that is secret`);
|
|
6409
|
+
return segments;
|
|
6410
|
+
}
|
|
6411
|
+
function insert(into, segments) {
|
|
6412
|
+
const [head, ...rest] = segments;
|
|
6413
|
+
if (head === void 0) return;
|
|
6414
|
+
if (rest.length === 0) {
|
|
6415
|
+
into.set(head.key, LEAF);
|
|
6416
|
+
return;
|
|
6417
|
+
}
|
|
6418
|
+
const existing = into.get(head.key);
|
|
6419
|
+
if (head.idKey !== void 0) {
|
|
6420
|
+
const item = new Map(existing?.kind === "array" ? existing.item : []);
|
|
6421
|
+
insert(item, rest);
|
|
6422
|
+
into.set(head.key, {
|
|
6423
|
+
kind: "array",
|
|
6424
|
+
idKey: head.idKey,
|
|
6425
|
+
item
|
|
6426
|
+
});
|
|
6427
|
+
return;
|
|
6428
|
+
}
|
|
6429
|
+
const children = new Map(existing?.kind === "object" ? existing.children : []);
|
|
6430
|
+
insert(children, rest);
|
|
6431
|
+
into.set(head.key, {
|
|
6432
|
+
kind: "object",
|
|
6433
|
+
children
|
|
6434
|
+
});
|
|
6435
|
+
}
|
|
6436
|
+
/** Add hidden-state paths (`secretStatePaths`) to a schema-derived tree. */
|
|
6437
|
+
function mergeSecretStatePaths(tree, paths) {
|
|
6438
|
+
if (paths.length === 0) return tree;
|
|
6439
|
+
const out = new Map(tree);
|
|
6440
|
+
for (const path of paths) insert(out, parseSecretStatePath(path));
|
|
6441
|
+
return out;
|
|
6442
|
+
}
|
|
6443
|
+
/** First retry of a secret the keychain could not serve; doubles to {@link SECRET_RETRY_MAX_MS}. */
|
|
6444
|
+
var SECRET_RETRY_FIRST_MS = 5e3;
|
|
6445
|
+
var SECRET_RETRY_MAX_MS = 5 * 6e4;
|
|
6446
|
+
/** Coalesces a burst of `keychain.changed` events into one re-resolve. */
|
|
6447
|
+
var SECRET_CHANGE_DEBOUNCE_MS = 250;
|
|
5912
6448
|
/**
|
|
5913
6449
|
* Base class for CamStack addons. Eliminates settings boilerplate:
|
|
5914
6450
|
*
|
|
@@ -5978,6 +6514,25 @@ var BaseAddon = class {
|
|
|
5978
6514
|
settingsStoreReady = false;
|
|
5979
6515
|
/** Default config values. Provided via constructor. */
|
|
5980
6516
|
defaults;
|
|
6517
|
+
/**
|
|
6518
|
+
* Hidden-state paths that hold secrets (D787) — values the addon writes
|
|
6519
|
+
* itself (`updateGlobalSettings`, `state()`) that no form field declares.
|
|
6520
|
+
* Stored in the keychain exactly like a `password` field. Syntax:
|
|
6521
|
+
* `'snapshotSigningKey'`, `'identity.pincode'`, `'tokens[userId].accessToken'`
|
|
6522
|
+
* (`key[<id field>]` addresses array items by id, never by index).
|
|
6523
|
+
*/
|
|
6524
|
+
secretStatePaths = [];
|
|
6525
|
+
_addonSecretTree = null;
|
|
6526
|
+
_deviceSecretTree = null;
|
|
6527
|
+
/** Refs the last resolved config pointed at — a change to one re-resolves. */
|
|
6528
|
+
_configSecretRefs = /* @__PURE__ */ new Set();
|
|
6529
|
+
_unresolvedSecrets = [];
|
|
6530
|
+
_secretRetryTimer = null;
|
|
6531
|
+
_secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
|
|
6532
|
+
_secretChangeTimer = null;
|
|
6533
|
+
_secretChangeUnsub = null;
|
|
6534
|
+
/** >0 while an OPERATOR's settings write is being applied. */
|
|
6535
|
+
_operatorWriteDepth = 0;
|
|
5981
6536
|
constructor(defaults) {
|
|
5982
6537
|
this.defaults = defaults;
|
|
5983
6538
|
this._config = { ...defaults };
|
|
@@ -6013,8 +6568,18 @@ var BaseAddon = class {
|
|
|
6013
6568
|
return this._config;
|
|
6014
6569
|
}
|
|
6015
6570
|
async initialize(context) {
|
|
6016
|
-
|
|
6571
|
+
const secrets = context.secrets;
|
|
6572
|
+
this._ctx = secrets !== void 0 ? withSecretAwareSettings(context, {
|
|
6573
|
+
secrets,
|
|
6574
|
+
addonTree: () => this.addonSecretTree(),
|
|
6575
|
+
deviceTree: () => this.deviceSecretTree(),
|
|
6576
|
+
onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
|
|
6577
|
+
isOperatorWrite: () => this._operatorWriteDepth > 0
|
|
6578
|
+
}) : context;
|
|
6017
6579
|
await this.resolveConfig();
|
|
6580
|
+
if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
|
|
6581
|
+
if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
|
|
6582
|
+
});
|
|
6018
6583
|
const result = await this.onInitialize();
|
|
6019
6584
|
this.emitLifecycle(EventCategory.AddonStarted);
|
|
6020
6585
|
const normalized = normalizeAddonInitResult(result);
|
|
@@ -6047,6 +6612,12 @@ var BaseAddon = class {
|
|
|
6047
6612
|
*/
|
|
6048
6613
|
async onHubReachable() {}
|
|
6049
6614
|
async shutdown() {
|
|
6615
|
+
this._secretChangeUnsub?.();
|
|
6616
|
+
this._secretChangeUnsub = null;
|
|
6617
|
+
if (this._secretRetryTimer !== null) clearTimeout(this._secretRetryTimer);
|
|
6618
|
+
if (this._secretChangeTimer !== null) clearTimeout(this._secretChangeTimer);
|
|
6619
|
+
this._secretRetryTimer = null;
|
|
6620
|
+
this._secretChangeTimer = null;
|
|
6050
6621
|
this.emitLifecycle(EventCategory.AddonStopped);
|
|
6051
6622
|
if (this.autoEmitReadiness) this.emitReadinessForProviders("down");
|
|
6052
6623
|
await this.onShutdown();
|
|
@@ -6125,7 +6696,7 @@ var BaseAddon = class {
|
|
|
6125
6696
|
return hydrateSchema(schema, overlay ? {
|
|
6126
6697
|
...projected,
|
|
6127
6698
|
...overlay
|
|
6128
|
-
} : projected);
|
|
6699
|
+
} : projected, { inlineSecretsAsViews: true });
|
|
6129
6700
|
}
|
|
6130
6701
|
/**
|
|
6131
6702
|
* The integration-level view of this addon's settings: exactly the sections
|
|
@@ -6174,7 +6745,7 @@ var BaseAddon = class {
|
|
|
6174
6745
|
return hydrateSchema({
|
|
6175
6746
|
...schema,
|
|
6176
6747
|
sections
|
|
6177
|
-
}, projected);
|
|
6748
|
+
}, projected, { inlineSecretsAsViews: true });
|
|
6178
6749
|
}
|
|
6179
6750
|
/**
|
|
6180
6751
|
* The raw addon store PROJECTED onto the target node's bare per-node keys:
|
|
@@ -6228,18 +6799,50 @@ var BaseAddon = class {
|
|
|
6228
6799
|
value: result.value[key]
|
|
6229
6800
|
};
|
|
6230
6801
|
}
|
|
6802
|
+
/**
|
|
6803
|
+
* The OPERATOR's write — a settings form or an admin API call, dispatched by
|
|
6804
|
+
* the kernel. Identical to {@link updateGlobalSettings}, except that a secret
|
|
6805
|
+
* the operator sends is stored as sent even when it equals a pre-keychain
|
|
6806
|
+
* inline value: the operator re-entering a password is a change, an addon
|
|
6807
|
+
* writing back what it read is not (D787).
|
|
6808
|
+
*/
|
|
6809
|
+
async updateGlobalSettingsAsOperator(patch, nodeId) {
|
|
6810
|
+
this._operatorWriteDepth++;
|
|
6811
|
+
try {
|
|
6812
|
+
await this.applyGlobalPatch(patch, nodeId);
|
|
6813
|
+
} finally {
|
|
6814
|
+
this._operatorWriteDepth--;
|
|
6815
|
+
}
|
|
6816
|
+
}
|
|
6231
6817
|
async updateGlobalSettings(patch, nodeId) {
|
|
6818
|
+
await this.applyGlobalPatch(patch, nodeId);
|
|
6819
|
+
}
|
|
6820
|
+
/**
|
|
6821
|
+
* REMOVE stored secrets — their keychain values and their markers (D787).
|
|
6822
|
+
*
|
|
6823
|
+
* Writing `''` to a secret field KEEPS what is stored (an empty string is
|
|
6824
|
+
* what a defaults fallback writes back, and it must never destroy a
|
|
6825
|
+
* credential), so code that means "forget this token" says so here. Without
|
|
6826
|
+
* a keychain (an older kernel) it writes `''`, as such code always did.
|
|
6827
|
+
*/
|
|
6828
|
+
async clearSecrets(keys, nodeId) {
|
|
6829
|
+
const tree = this.addonSecretTree();
|
|
6830
|
+
const keychain = this._ctx?.secrets !== void 0;
|
|
6831
|
+
const patch = {};
|
|
6832
|
+
for (const key of keys) patch[key] = keychain && tree.has(key) ? SECRET_CLEAR : "";
|
|
6833
|
+
await this.applyGlobalPatch(patch, nodeId);
|
|
6834
|
+
}
|
|
6835
|
+
async applyGlobalPatch(barePatch, nodeId) {
|
|
6232
6836
|
const keys = this.perNodeKeys();
|
|
6233
6837
|
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
6234
6838
|
const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
6235
|
-
const barePatch = patch;
|
|
6236
6839
|
const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
|
|
6237
6840
|
await this._ctx?.settings?.writeAddonStore(scoped);
|
|
6238
6841
|
if (target !== localNode) return;
|
|
6239
6842
|
await this.resolveConfig();
|
|
6240
6843
|
await this.onConfigChanged();
|
|
6241
6844
|
this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
|
|
6242
|
-
this.maybeAutoRestart(
|
|
6845
|
+
this.maybeAutoRestart(Object.keys(barePatch), this.globalSettingsSchema());
|
|
6243
6846
|
}
|
|
6244
6847
|
/**
|
|
6245
6848
|
* The set of field keys the global settings schema declares `perNode: true`
|
|
@@ -6264,7 +6867,7 @@ var BaseAddon = class {
|
|
|
6264
6867
|
* time to return its response before the addon is torn down and
|
|
6265
6868
|
* re-initialised by `AddonRegistryService.restartAddon`.
|
|
6266
6869
|
*/
|
|
6267
|
-
maybeAutoRestart(
|
|
6870
|
+
maybeAutoRestart(patchKeys, schema) {
|
|
6268
6871
|
if (!schema) return;
|
|
6269
6872
|
const restartKeys = /* @__PURE__ */ new Set();
|
|
6270
6873
|
for (const section of schema.sections) for (const field of section.fields) {
|
|
@@ -6272,13 +6875,13 @@ var BaseAddon = class {
|
|
|
6272
6875
|
if (field.requiresRestart) restartKeys.add(field.key);
|
|
6273
6876
|
}
|
|
6274
6877
|
if (restartKeys.size === 0) return;
|
|
6275
|
-
if (!
|
|
6878
|
+
if (!patchKeys.some((k) => restartKeys.has(k))) return;
|
|
6276
6879
|
const ctx = this._ctx;
|
|
6277
6880
|
if (!ctx) return;
|
|
6278
6881
|
const addonId = ctx.id;
|
|
6279
6882
|
setImmediate(() => {
|
|
6280
6883
|
ctx.api.addons?.restartAddon?.mutate({ addonId }).then(() => {
|
|
6281
|
-
ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields:
|
|
6884
|
+
ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
|
|
6282
6885
|
}).catch((err) => {
|
|
6283
6886
|
ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
6284
6887
|
});
|
|
@@ -6287,7 +6890,7 @@ var BaseAddon = class {
|
|
|
6287
6890
|
async getDeviceSettings(deviceId) {
|
|
6288
6891
|
const schema = this.deviceSettingsSchema();
|
|
6289
6892
|
if (!schema) return { sections: [] };
|
|
6290
|
-
return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {});
|
|
6893
|
+
return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
|
|
6291
6894
|
}
|
|
6292
6895
|
async updateDeviceSettings(deviceId, patch) {
|
|
6293
6896
|
await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
|
|
@@ -6417,7 +7020,7 @@ var BaseAddon = class {
|
|
|
6417
7020
|
* selection at boot (absent scoped key ⇒ the constructor default wins).
|
|
6418
7021
|
*/
|
|
6419
7022
|
async resolveConfig() {
|
|
6420
|
-
const stored = await this.readAddonStoreWithRetry();
|
|
7023
|
+
const stored = await this.resolveStoredSecrets(await this.readAddonStoreWithRetry());
|
|
6421
7024
|
const perNode = this.perNodeKeys();
|
|
6422
7025
|
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
6423
7026
|
const resolved = { ...this.defaults };
|
|
@@ -6442,7 +7045,7 @@ var BaseAddon = class {
|
|
|
6442
7045
|
key,
|
|
6443
7046
|
schema,
|
|
6444
7047
|
fallback,
|
|
6445
|
-
read: () => this.readAddonStoreWithRetry(),
|
|
7048
|
+
read: async () => this.resolveStoredSecrets(await this.readAddonStoreWithRetry()),
|
|
6446
7049
|
write: async (patch) => {
|
|
6447
7050
|
await this._ctx?.settings?.writeAddonStore(patch);
|
|
6448
7051
|
},
|
|
@@ -6459,7 +7062,7 @@ var BaseAddon = class {
|
|
|
6459
7062
|
key,
|
|
6460
7063
|
schema,
|
|
6461
7064
|
fallback,
|
|
6462
|
-
read: async () => await this._ctx?.settings?.readDeviceStore(deviceId) ?? {},
|
|
7065
|
+
read: async () => this.resolveStoredSecrets(await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, false),
|
|
6463
7066
|
write: async (patch) => {
|
|
6464
7067
|
await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
|
|
6465
7068
|
},
|
|
@@ -6471,6 +7074,70 @@ var BaseAddon = class {
|
|
|
6471
7074
|
} })
|
|
6472
7075
|
});
|
|
6473
7076
|
}
|
|
7077
|
+
/** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
|
|
7078
|
+
addonSecretTree() {
|
|
7079
|
+
this._addonSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.globalSettingsSchema()), this.secretStatePaths);
|
|
7080
|
+
return this._addonSecretTree;
|
|
7081
|
+
}
|
|
7082
|
+
deviceSecretTree() {
|
|
7083
|
+
this._deviceSecretTree ??= secretTreeFromSchema(this.deviceSettingsSchema());
|
|
7084
|
+
return this._deviceSecretTree;
|
|
7085
|
+
}
|
|
7086
|
+
/**
|
|
7087
|
+
* Secrets of this addon's stored config that could not be resolved on the
|
|
7088
|
+
* last read, with why. Non-empty means the addon is running WITHOUT them —
|
|
7089
|
+
* an addon whose function needs one should report itself degraded rather
|
|
7090
|
+
* than start on an empty credential.
|
|
7091
|
+
*/
|
|
7092
|
+
get unresolvedSecrets() {
|
|
7093
|
+
return this._unresolvedSecrets;
|
|
7094
|
+
}
|
|
7095
|
+
/**
|
|
7096
|
+
* Substitute every keychain marker in a stored blob with its value. With no
|
|
7097
|
+
* keychain (no `ctx.secrets`) or no marker, the blob comes back unchanged.
|
|
7098
|
+
* An unresolvable value is LEFT OUT (never `''`), logged by ref — never by
|
|
7099
|
+
* value — and, when the cause can pass, retried with backoff. Nothing is
|
|
7100
|
+
* ever written back from here.
|
|
7101
|
+
*/
|
|
7102
|
+
async resolveStoredSecrets(blob, trackForConfig = true) {
|
|
7103
|
+
const secrets = this._ctx?.secrets;
|
|
7104
|
+
if (secrets === void 0) return blob;
|
|
7105
|
+
const refs = collectSecretMarkerRefs(blob);
|
|
7106
|
+
if (trackForConfig) this._configSecretRefs = new Set(refs);
|
|
7107
|
+
if (refs.length === 0) {
|
|
7108
|
+
if (trackForConfig) this._unresolvedSecrets = [];
|
|
7109
|
+
return blob;
|
|
7110
|
+
}
|
|
7111
|
+
const { value, unresolved } = await resolveSecretMarkers(blob, secrets);
|
|
7112
|
+
if (trackForConfig) {
|
|
7113
|
+
this._unresolvedSecrets = unresolved;
|
|
7114
|
+
if (unresolved.length > 0) {
|
|
7115
|
+
this._ctx?.logger?.error?.("secret unavailable — running without it, will retry", { meta: { secrets: unresolved.map((u) => ({
|
|
7116
|
+
ref: u.ref,
|
|
7117
|
+
reason: u.reason
|
|
7118
|
+
})) } });
|
|
7119
|
+
if (unresolved.some((u) => u.reason !== "missing" && u.reason !== "forbidden")) {
|
|
7120
|
+
this.scheduleSecretReresolve(this._secretRetryDelayMs);
|
|
7121
|
+
this._secretRetryDelayMs = Math.min(this._secretRetryDelayMs * 2, SECRET_RETRY_MAX_MS);
|
|
7122
|
+
}
|
|
7123
|
+
} else this._secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
|
|
7124
|
+
}
|
|
7125
|
+
return value;
|
|
7126
|
+
}
|
|
7127
|
+
/** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
|
|
7128
|
+
scheduleSecretReresolve(delayMs) {
|
|
7129
|
+
const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
|
|
7130
|
+
if (this[timerOf] !== null) return;
|
|
7131
|
+
const timer = setTimeout(() => {
|
|
7132
|
+
this[timerOf] = null;
|
|
7133
|
+
if (this._ctx === null) return;
|
|
7134
|
+
this.resolveConfig().then(() => this.onConfigChanged()).catch((err) => {
|
|
7135
|
+
this._ctx?.logger?.error?.("re-resolving secrets failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
7136
|
+
});
|
|
7137
|
+
}, delayMs);
|
|
7138
|
+
timer.unref?.();
|
|
7139
|
+
this[timerOf] = timer;
|
|
7140
|
+
}
|
|
6474
7141
|
/**
|
|
6475
7142
|
* Wrap `ctx.settings.readAddonStore()` with a short retry budget so a
|
|
6476
7143
|
* transient settings-store outage (mid-restart of sqlite-settings, tsx-watch
|
|
@@ -7046,6 +7713,69 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
|
|
|
7046
7713
|
kind: "mutation",
|
|
7047
7714
|
auth: "admin"
|
|
7048
7715
|
}), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
|
|
7716
|
+
function defOf(schema) {
|
|
7717
|
+
return schema._zod?.def ?? {};
|
|
7718
|
+
}
|
|
7719
|
+
function declaredHere(schema) {
|
|
7720
|
+
return globalRegistry.get(schema)?.secret === true;
|
|
7721
|
+
}
|
|
7722
|
+
/** Wrapper kinds whose `innerType` is the field itself. */
|
|
7723
|
+
var WRAPPERS = new Set([
|
|
7724
|
+
"optional",
|
|
7725
|
+
"nullable",
|
|
7726
|
+
"default",
|
|
7727
|
+
"prefault",
|
|
7728
|
+
"catch",
|
|
7729
|
+
"readonly",
|
|
7730
|
+
"nonoptional"
|
|
7731
|
+
]);
|
|
7732
|
+
/**
|
|
7733
|
+
* The schema layers that make up ONE field: the schema itself and every
|
|
7734
|
+
* wrapper below it (optional / default / nullable / readonly / catch), plus
|
|
7735
|
+
* both sides of a pipe (`z.preprocess` puts the real schema on `out`,
|
|
7736
|
+
* `.transform` on `in`).
|
|
7737
|
+
*/
|
|
7738
|
+
function layersOf(schema) {
|
|
7739
|
+
const out = [];
|
|
7740
|
+
const queue = [schema];
|
|
7741
|
+
while (queue.length > 0) {
|
|
7742
|
+
const s = queue.shift();
|
|
7743
|
+
if (!s || out.includes(s)) continue;
|
|
7744
|
+
out.push(s);
|
|
7745
|
+
const def = defOf(s);
|
|
7746
|
+
if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
|
|
7747
|
+
if (def.type === "pipe") {
|
|
7748
|
+
if (def.in) queue.push(def.in);
|
|
7749
|
+
if (def.out) queue.push(def.out);
|
|
7750
|
+
}
|
|
7751
|
+
}
|
|
7752
|
+
return out;
|
|
7753
|
+
}
|
|
7754
|
+
/** True when any layer of this field declares `.meta({ secret: true })`. */
|
|
7755
|
+
function isZodSecret(schema) {
|
|
7756
|
+
return layersOf(schema).some(declaredHere);
|
|
7757
|
+
}
|
|
7758
|
+
/**
|
|
7759
|
+
* Every declared secret path in a config schema: dotted keys, `[]` for "each
|
|
7760
|
+
* element of this array" (`connection.password`, `rows[].token`). A declared
|
|
7761
|
+
* object or array is reported as one path and not descended into — everything
|
|
7762
|
+
* under it is secret.
|
|
7763
|
+
*/
|
|
7764
|
+
function collectZodSecretPaths(schema, prefix = "") {
|
|
7765
|
+
if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
|
|
7766
|
+
const paths = [];
|
|
7767
|
+
for (const layer of layersOf(schema)) {
|
|
7768
|
+
const def = defOf(layer);
|
|
7769
|
+
if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
|
|
7770
|
+
else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
|
|
7771
|
+
else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
|
|
7772
|
+
else if (def.type === "intersection") {
|
|
7773
|
+
if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
|
|
7774
|
+
if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
|
|
7775
|
+
}
|
|
7776
|
+
}
|
|
7777
|
+
return [...new Set(paths)];
|
|
7778
|
+
}
|
|
7049
7779
|
//#endregion
|
|
7050
7780
|
//#region ../types/dist/err-msg-DX6i_MY4.mjs
|
|
7051
7781
|
var DeviceType = /* @__PURE__ */ function(DeviceType) {
|
|
@@ -14076,6 +14806,196 @@ id: union([string(), number()]) }), {
|
|
|
14076
14806
|
kind: "mutation",
|
|
14077
14807
|
auth: "admin"
|
|
14078
14808
|
});
|
|
14809
|
+
/**
|
|
14810
|
+
* `keychain` — the hub's encrypted store of secret values (D787).
|
|
14811
|
+
*
|
|
14812
|
+
* Settings blobs never hold a secret: they hold a marker
|
|
14813
|
+
* `{"$secret":"secret://<owner>/<scope>/<fieldPath>","v":1}` and the value
|
|
14814
|
+
* lives here, AES-256-GCM under a data key that a master key wraps. This cap
|
|
14815
|
+
* is the OWNER's door to its own values: every method is owner-checked
|
|
14816
|
+
* against the CALLER, never against anything the caller claims.
|
|
14817
|
+
*
|
|
14818
|
+
* Who the caller is: the transport stamps `callerAddonId` into the args of a
|
|
14819
|
+
* call that crossed a process (the parent `LocalChildRegistry` from the UDS
|
|
14820
|
+
* connection, the agent from its child's connection carried in
|
|
14821
|
+
* `$hub-cap-fwd`'s envelope). A stamp always overwrites; a wire call with no
|
|
14822
|
+
* stamp has its claim stripped. Only a hub in-process caller may state its own
|
|
14823
|
+
* identity — `ctx.secrets` does that with the addon id closed over. This is
|
|
14824
|
+
* identity against BUGS and misrouting, not against a malicious addon (every
|
|
14825
|
+
* runner is the same OS user): see the threat model in
|
|
14826
|
+
* `docs/design/2026-10-08-secrets-keychain.md`.
|
|
14827
|
+
*
|
|
14828
|
+
* `callerAddonId` is deliberately NOT in any input schema: the tRPC router
|
|
14829
|
+
* parses the input, so a session can never supply it, and the internal mount
|
|
14830
|
+
* floors every method to admin anyway (D240).
|
|
14831
|
+
*
|
|
14832
|
+
* Internal: addons reach it through `ctx.secrets`, never directly.
|
|
14833
|
+
*/
|
|
14834
|
+
/** Why a value cannot be served right now. Never folded into "missing". */
|
|
14835
|
+
var KeychainUnavailableReasonSchema = _enum([
|
|
14836
|
+
"key-missing",
|
|
14837
|
+
"wrong-key",
|
|
14838
|
+
"key-file-unreadable",
|
|
14839
|
+
"store-unavailable",
|
|
14840
|
+
"not-initialized",
|
|
14841
|
+
"decrypt-failed"
|
|
14842
|
+
]);
|
|
14843
|
+
var KeychainStateSchema = discriminatedUnion("state", [object({ state: literal("ready") }), object({
|
|
14844
|
+
state: literal("locked"),
|
|
14845
|
+
reason: KeychainUnavailableReasonSchema
|
|
14846
|
+
})]);
|
|
14847
|
+
var KeychainResolveEntrySchema = discriminatedUnion("kind", [
|
|
14848
|
+
object({
|
|
14849
|
+
kind: literal("value"),
|
|
14850
|
+
value: string(),
|
|
14851
|
+
version: number().int()
|
|
14852
|
+
}),
|
|
14853
|
+
object({ kind: literal("missing") }),
|
|
14854
|
+
object({
|
|
14855
|
+
kind: literal("unavailable"),
|
|
14856
|
+
reason: KeychainUnavailableReasonSchema
|
|
14857
|
+
}),
|
|
14858
|
+
object({ kind: literal("forbidden") })
|
|
14859
|
+
]);
|
|
14860
|
+
var KeychainResolveResultSchema = record(string(), KeychainResolveEntrySchema);
|
|
14861
|
+
/** Metadata of one stored value — never the value. */
|
|
14862
|
+
var KeychainSecretMetaSchema = object({
|
|
14863
|
+
ref: string(),
|
|
14864
|
+
owner: string(),
|
|
14865
|
+
/** Formatted scope (`global`, `node/<id>`, `device/<id>`, …). */
|
|
14866
|
+
scope: string(),
|
|
14867
|
+
fieldPath: string(),
|
|
14868
|
+
version: number().int(),
|
|
14869
|
+
createdAt: number(),
|
|
14870
|
+
updatedAt: number(),
|
|
14871
|
+
/** `addon:<id>` | `user:<id>` | `system`. */
|
|
14872
|
+
updatedBy: string(),
|
|
14873
|
+
/** Coarse — written at most once an hour per ref. `null` = never read. */
|
|
14874
|
+
lastReadAt: number().nullable()
|
|
14875
|
+
});
|
|
14876
|
+
var RefListSchema = array(string().min(1)).max(512);
|
|
14877
|
+
method(object({
|
|
14878
|
+
ref: string().min(1),
|
|
14879
|
+
value: string().min(1)
|
|
14880
|
+
}), object({
|
|
14881
|
+
ref: string(),
|
|
14882
|
+
version: number().int()
|
|
14883
|
+
}), {
|
|
14884
|
+
kind: "mutation",
|
|
14885
|
+
auth: "admin"
|
|
14886
|
+
}), method(object({ refs: RefListSchema }), KeychainResolveResultSchema, { auth: "admin" }), method(object({ refs: RefListSchema }), object({ deleted: number().int() }), {
|
|
14887
|
+
kind: "mutation",
|
|
14888
|
+
auth: "admin"
|
|
14889
|
+
}), method(object({}), array(KeychainSecretMetaSchema).readonly(), { auth: "admin" }), method(object({}), KeychainStateSchema, { auth: "admin" });
|
|
14890
|
+
var KeychainKeySourceSchema = object({
|
|
14891
|
+
kind: _enum([
|
|
14892
|
+
"config-file",
|
|
14893
|
+
"previous-config-file",
|
|
14894
|
+
"platform",
|
|
14895
|
+
"default-file"
|
|
14896
|
+
]),
|
|
14897
|
+
/** File sources only — a path is not a secret. */
|
|
14898
|
+
path: string().optional(),
|
|
14899
|
+
/**
|
|
14900
|
+
* True when a whole-volume backup of the data directory carries this key
|
|
14901
|
+
* next to the database it protects (the default file). The page warns.
|
|
14902
|
+
*/
|
|
14903
|
+
sharesBackupWithDatabase: boolean()
|
|
14904
|
+
});
|
|
14905
|
+
var KeychainStatusSchema = object({
|
|
14906
|
+
keychain: KeychainStateSchema,
|
|
14907
|
+
/** The source of the master key in use; `null` while locked. */
|
|
14908
|
+
keySource: KeychainKeySourceSchema.nullable(),
|
|
14909
|
+
/** The source configured to be primary — differs from `keySource` while a rotation is pending. */
|
|
14910
|
+
configuredSource: KeychainKeySourceSchema,
|
|
14911
|
+
/** Short fingerprint of the master key in use (`HMAC(KEK, label)`, 16 hex). */
|
|
14912
|
+
fingerprint: string().nullable(),
|
|
14913
|
+
activeKeyId: string().nullable(),
|
|
14914
|
+
/**
|
|
14915
|
+
* The keychain unlocked with a NON-primary source: the configured primary
|
|
14916
|
+
* key is not the one that wraps the data key yet. `rotateMasterKey` moves it.
|
|
14917
|
+
*/
|
|
14918
|
+
rotationPending: boolean(),
|
|
14919
|
+
/** Wrapped copies of the data key under a previous master key, kept until purged. */
|
|
14920
|
+
retiredWraps: number().int(),
|
|
14921
|
+
recoveryKeyDownloadedAt: number().nullable(),
|
|
14922
|
+
secretCount: number().int()
|
|
14923
|
+
});
|
|
14924
|
+
/**
|
|
14925
|
+
* Whether a stored value is still pointed at by its owner's settings.
|
|
14926
|
+
* `unknown` is a first-class answer: a scope whose blob could not be read is
|
|
14927
|
+
* never reported as an orphan (and never deleted as one).
|
|
14928
|
+
*/
|
|
14929
|
+
var KeychainSecretUsageSchema = _enum([
|
|
14930
|
+
"in-use",
|
|
14931
|
+
"orphan",
|
|
14932
|
+
"unknown"
|
|
14933
|
+
]);
|
|
14934
|
+
var KeychainAdminSecretSchema = KeychainSecretMetaSchema.extend({ usage: KeychainSecretUsageSchema });
|
|
14935
|
+
var KeychainAuditActionSchema = _enum([
|
|
14936
|
+
"put",
|
|
14937
|
+
"delete",
|
|
14938
|
+
"reveal",
|
|
14939
|
+
"rotate-master-key",
|
|
14940
|
+
"purge-retired-keys",
|
|
14941
|
+
"download-recovery-key",
|
|
14942
|
+
"delete-orphans",
|
|
14943
|
+
"reset",
|
|
14944
|
+
"initialize"
|
|
14945
|
+
]);
|
|
14946
|
+
var KeychainAuditEntrySchema = object({
|
|
14947
|
+
id: string(),
|
|
14948
|
+
at: number(),
|
|
14949
|
+
action: KeychainAuditActionSchema,
|
|
14950
|
+
/** `addon:<id>` | `user:<id>` | `system`. */
|
|
14951
|
+
actor: string(),
|
|
14952
|
+
ref: string().nullable(),
|
|
14953
|
+
detail: string().nullable()
|
|
14954
|
+
});
|
|
14955
|
+
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({
|
|
14956
|
+
value: string(),
|
|
14957
|
+
version: number().int()
|
|
14958
|
+
}), {
|
|
14959
|
+
kind: "mutation",
|
|
14960
|
+
auth: "admin",
|
|
14961
|
+
caller: "required"
|
|
14962
|
+
}), method(object({ refs: array(string().min(1)).max(1e3) }), object({
|
|
14963
|
+
deleted: array(string()).readonly(),
|
|
14964
|
+
kept: array(object({
|
|
14965
|
+
ref: string(),
|
|
14966
|
+
usage: KeychainSecretUsageSchema
|
|
14967
|
+
})).readonly()
|
|
14968
|
+
}), {
|
|
14969
|
+
kind: "mutation",
|
|
14970
|
+
auth: "admin",
|
|
14971
|
+
caller: "required"
|
|
14972
|
+
}), method(object({}), object({
|
|
14973
|
+
fingerprint: string(),
|
|
14974
|
+
keySource: KeychainKeySourceSchema
|
|
14975
|
+
}), {
|
|
14976
|
+
kind: "mutation",
|
|
14977
|
+
auth: "admin",
|
|
14978
|
+
caller: "required"
|
|
14979
|
+
}), method(object({}), object({ purged: number().int() }), {
|
|
14980
|
+
kind: "mutation",
|
|
14981
|
+
auth: "admin",
|
|
14982
|
+
caller: "required"
|
|
14983
|
+
}), method(object({}), object({
|
|
14984
|
+
key: string(),
|
|
14985
|
+
fingerprint: string(),
|
|
14986
|
+
keySource: KeychainKeySourceSchema
|
|
14987
|
+
}), {
|
|
14988
|
+
kind: "mutation",
|
|
14989
|
+
auth: "admin",
|
|
14990
|
+
caller: "required"
|
|
14991
|
+
}), method(object({ confirm: literal("RESET KEYCHAIN") }), object({
|
|
14992
|
+
archivedCollection: string().nullable(),
|
|
14993
|
+
archived: number().int()
|
|
14994
|
+
}), {
|
|
14995
|
+
kind: "mutation",
|
|
14996
|
+
auth: "admin",
|
|
14997
|
+
caller: "required"
|
|
14998
|
+
});
|
|
14079
14999
|
method(_void(), object({
|
|
14080
15000
|
id: string(),
|
|
14081
15001
|
name: string(),
|
|
@@ -15414,7 +16334,11 @@ var DeviceRegisterPayloadSchema = object({
|
|
|
15414
16334
|
var DeviceRemovePayloadSchema = object({ deviceId: number() });
|
|
15415
16335
|
var DevicePersistConfigPayloadSchema = object({
|
|
15416
16336
|
deviceId: number(),
|
|
15417
|
-
data: record(string(), unknown())
|
|
16337
|
+
data: record(string(), unknown()),
|
|
16338
|
+
/** The paths the device's schema declares secret (D783), when the caller
|
|
16339
|
+
* knows them — those values are kept in the keychain, not the blob (D787).
|
|
16340
|
+
* Absent: the paths the device last reported at `registerDevice` apply. */
|
|
16341
|
+
secretConfigPaths: array(string()).optional()
|
|
15418
16342
|
});
|
|
15419
16343
|
/** What a migration actually did, per switch. `unreachable` is a first-class
|
|
15420
16344
|
* answer: a camera that could not be asked is not a camera that was silenced. */
|
|
@@ -22431,8 +23355,23 @@ var RetrainMacroClassSchema = _enum([
|
|
|
22431
23355
|
]);
|
|
22432
23356
|
/** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
|
|
22433
23357
|
var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
|
|
22434
|
-
/**
|
|
22435
|
-
|
|
23358
|
+
/**
|
|
23359
|
+
* Where a box came from. A machine-sourced box is a DRAFT on the page until
|
|
23360
|
+
* the operator confirms it; once saved it keeps its source as provenance.
|
|
23361
|
+
*
|
|
23362
|
+
* - `operator` — drawn by hand.
|
|
23363
|
+
* - `assist` — proposed by a detector run on the copy (the camera's own
|
|
23364
|
+
* model, or a larger teacher model).
|
|
23365
|
+
* - `pipeline` — the box the live pipeline actually drew on that frame, read
|
|
23366
|
+
* back from the track store (never a re-run).
|
|
23367
|
+
* - `llm` — proposed by a vision-capable LLM profile.
|
|
23368
|
+
*/
|
|
23369
|
+
var RetrainAnnotationSourceSchema = _enum([
|
|
23370
|
+
"operator",
|
|
23371
|
+
"assist",
|
|
23372
|
+
"pipeline",
|
|
23373
|
+
"llm"
|
|
23374
|
+
]);
|
|
22436
23375
|
/** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
|
|
22437
23376
|
var RetrainBboxSchema = object({
|
|
22438
23377
|
x: number(),
|
|
@@ -22450,7 +23389,8 @@ var RetrainBboxSchema = object({
|
|
|
22450
23389
|
*/
|
|
22451
23390
|
var RetrainAnnotationSchema = object({
|
|
22452
23391
|
id: string(),
|
|
22453
|
-
|
|
23392
|
+
/** The frame's track. Absent on a recording still, which has none. */
|
|
23393
|
+
trackId: string().optional(),
|
|
22454
23394
|
deviceId: number(),
|
|
22455
23395
|
/** The COPY in retrain storage — never the source track's media key. */
|
|
22456
23396
|
mediaKey: string(),
|
|
@@ -22499,13 +23439,47 @@ var RetrainFrameCandidateSchema = object({
|
|
|
22499
23439
|
* fail, whatever became of the original. */
|
|
22500
23440
|
copied: boolean()
|
|
22501
23441
|
});
|
|
23442
|
+
/**
|
|
23443
|
+
* One box the live pipeline drew on a copied frame — what a correction starts
|
|
23444
|
+
* from. Derived when the frame is listed, from the track store: the subject
|
|
23445
|
+
* box recorded on the source media row when there is one, else the track
|
|
23446
|
+
* position nearest the frame's capture time. Never stored as an annotation
|
|
23447
|
+
* until the operator confirms it.
|
|
23448
|
+
*/
|
|
23449
|
+
var RetrainPipelineBoxSchema = object({
|
|
23450
|
+
/** Normalised `[0,1]` against the full frame. */
|
|
23451
|
+
bbox: RetrainBboxSchema,
|
|
23452
|
+
macroClass: RetrainMacroClassSchema,
|
|
23453
|
+
label: string().optional(),
|
|
23454
|
+
subLabel: string().optional(),
|
|
23455
|
+
/** The detection score of the position used, when it was recorded. */
|
|
23456
|
+
score: number().optional(),
|
|
23457
|
+
/** The root model that produced the track, when it was recorded. */
|
|
23458
|
+
modelId: string().optional(),
|
|
23459
|
+
trackId: string(),
|
|
23460
|
+
/** `subject-box`: recorded on this very frame. `position`: the track's
|
|
23461
|
+
* position nearest the capture time, `deltaMs` away. */
|
|
23462
|
+
basis: _enum(["subject-box", "position"]),
|
|
23463
|
+
deltaMs: number()
|
|
23464
|
+
});
|
|
23465
|
+
/**
|
|
23466
|
+
* Where a retrain frame came from: a TRACK's stored media (copy-on-select),
|
|
23467
|
+
* or the RECORDING at an instant — the frame a model saw nothing in has no
|
|
23468
|
+
* track at all.
|
|
23469
|
+
*/
|
|
23470
|
+
var RetrainFrameOriginSchema = _enum(["track", "recording"]);
|
|
22502
23471
|
/** A frame the dataset OWNS: bytes copied at selection time. */
|
|
22503
23472
|
var RetrainFrameSchema = object({
|
|
22504
23473
|
frameId: string(),
|
|
22505
23474
|
deviceId: number(),
|
|
22506
|
-
|
|
22507
|
-
/**
|
|
22508
|
-
|
|
23475
|
+
origin: RetrainFrameOriginSchema,
|
|
23476
|
+
/** The track it was copied from. Absent on a recording still. */
|
|
23477
|
+
trackId: string().optional(),
|
|
23478
|
+
/** Provenance only. It may already point at nothing — that is expected.
|
|
23479
|
+
* Absent on a recording still. */
|
|
23480
|
+
sourceMediaId: number().int().optional(),
|
|
23481
|
+
/** A recording still: the playhead instant it was taken at. */
|
|
23482
|
+
epochMs: number().optional(),
|
|
22509
23483
|
sourceKind: MediaFileKindEnum,
|
|
22510
23484
|
sizeBytes: number().int(),
|
|
22511
23485
|
width: number().int(),
|
|
@@ -22516,7 +23490,12 @@ var RetrainFrameSchema = object({
|
|
|
22516
23490
|
/** The operator's "every subject in this frame is boxed". Detector
|
|
22517
23491
|
* evaluation keeps only complete frames: an unboxed subject would count as
|
|
22518
23492
|
* a false positive. */
|
|
22519
|
-
complete: boolean()
|
|
23493
|
+
complete: boolean(),
|
|
23494
|
+
/** The boxes the pipeline drew on this frame. Present on list answers;
|
|
23495
|
+
* empty when nothing the track store holds can be placed on it. */
|
|
23496
|
+
pipelineBoxes: array(RetrainPipelineBoxSchema).readonly().optional(),
|
|
23497
|
+
/** The named collections this frame belongs to. Present on list answers. */
|
|
23498
|
+
collectionIds: array(string()).readonly().optional()
|
|
22520
23499
|
});
|
|
22521
23500
|
/** Why a copy-on-select could not be honoured — named, never a silent skip. */
|
|
22522
23501
|
var RetrainCopyRefusalSchema = _enum([
|
|
@@ -22547,6 +23526,8 @@ var RetrainFrameListSchema = object({
|
|
|
22547
23526
|
var RetrainExportFilterSchema = object({
|
|
22548
23527
|
deviceIds: array(number()).optional(),
|
|
22549
23528
|
frameIds: array(string()).max(2e4).optional(),
|
|
23529
|
+
/** Only frames in at least one of these named collections. */
|
|
23530
|
+
collectionIds: array(string()).max(200).optional(),
|
|
22550
23531
|
batchId: string().optional(),
|
|
22551
23532
|
/** Only frames the operator marked complete (all subjects boxed). */
|
|
22552
23533
|
completeOnly: boolean().optional()
|
|
@@ -22611,6 +23592,109 @@ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
|
|
|
22611
23592
|
reason: string(),
|
|
22612
23593
|
detail: string().optional()
|
|
22613
23594
|
})]);
|
|
23595
|
+
/** A named set over the retrain corpus — membership only, it owns no pixels. */
|
|
23596
|
+
var RetrainCollectionSchema = object({
|
|
23597
|
+
id: string(),
|
|
23598
|
+
name: string(),
|
|
23599
|
+
createdAt: number(),
|
|
23600
|
+
frameCount: number().int()
|
|
23601
|
+
});
|
|
23602
|
+
var RetrainCollectionCreateResultSchema = discriminatedUnion("kind", [object({
|
|
23603
|
+
kind: literal("created"),
|
|
23604
|
+
collection: RetrainCollectionSchema
|
|
23605
|
+
}), object({
|
|
23606
|
+
kind: literal("refused"),
|
|
23607
|
+
reason: _enum(["empty-name", "duplicate-name"])
|
|
23608
|
+
})]);
|
|
23609
|
+
var RetrainCollectionRenameResultSchema = discriminatedUnion("kind", [object({
|
|
23610
|
+
kind: literal("renamed"),
|
|
23611
|
+
collection: RetrainCollectionSchema
|
|
23612
|
+
}), object({
|
|
23613
|
+
kind: literal("refused"),
|
|
23614
|
+
reason: _enum([
|
|
23615
|
+
"empty-name",
|
|
23616
|
+
"duplicate-name",
|
|
23617
|
+
"unknown-collection"
|
|
23618
|
+
])
|
|
23619
|
+
})]);
|
|
23620
|
+
/**
|
|
23621
|
+
* The outcome of adding the frame at a recording instant. Every refusal is
|
|
23622
|
+
* named: `still-unavailable` (not recording, a gap, or an undecodable frame —
|
|
23623
|
+
* `detail` says which), `still-busy` (the recorder is at its decode bound; try
|
|
23624
|
+
* again), `unreadable-image`, `write-failed`, `unknown-collection`.
|
|
23625
|
+
*/
|
|
23626
|
+
var AddRetrainFrameFromRecordingResultSchema = discriminatedUnion("kind", [object({
|
|
23627
|
+
kind: literal("added"),
|
|
23628
|
+
collectionId: string(),
|
|
23629
|
+
frame: RetrainFrameSchema,
|
|
23630
|
+
/** The moment was already in the dataset; nothing was decoded. */
|
|
23631
|
+
reused: boolean()
|
|
23632
|
+
}), object({
|
|
23633
|
+
kind: literal("refused"),
|
|
23634
|
+
reason: _enum([
|
|
23635
|
+
"unknown-collection",
|
|
23636
|
+
"still-unavailable",
|
|
23637
|
+
"still-busy",
|
|
23638
|
+
"unreadable-image",
|
|
23639
|
+
"write-failed"
|
|
23640
|
+
]),
|
|
23641
|
+
detail: string().optional()
|
|
23642
|
+
})]);
|
|
23643
|
+
/** A vision LLM profile the AI assist may use, and where it sends the frame. */
|
|
23644
|
+
var RetrainAssistProfileSchema = object({
|
|
23645
|
+
id: string(),
|
|
23646
|
+
name: string(),
|
|
23647
|
+
model: string(),
|
|
23648
|
+
kind: string(),
|
|
23649
|
+
/** `true` when the frame would leave the house (a cloud vendor, or an
|
|
23650
|
+
* endpoint that is not on the local network). The page confirms each such
|
|
23651
|
+
* run, and the provider refuses one without `allowCloud`. */
|
|
23652
|
+
leavesHouse: boolean()
|
|
23653
|
+
});
|
|
23654
|
+
/** A box the AI assist proposed: a draft, plus the model's own reason. */
|
|
23655
|
+
var RetrainLlmProposalSchema = RetrainAnnotationDraftSchema.extend({ reason: string() });
|
|
23656
|
+
/** What the AI assist said about a box that was already on the canvas. */
|
|
23657
|
+
var RetrainLlmReviewSchema = object({
|
|
23658
|
+
/** The `ref` the page sent the box under. */
|
|
23659
|
+
ref: string(),
|
|
23660
|
+
verdict: _enum([
|
|
23661
|
+
"confirmed",
|
|
23662
|
+
"wrong-class",
|
|
23663
|
+
"not-an-object",
|
|
23664
|
+
"uncertain"
|
|
23665
|
+
]),
|
|
23666
|
+
suggestedClass: RetrainMacroClassSchema.optional(),
|
|
23667
|
+
reason: string()
|
|
23668
|
+
});
|
|
23669
|
+
/**
|
|
23670
|
+
* The AI assist's answer. `proposed` carries drafts (`source: 'llm'`, the
|
|
23671
|
+
* model and its confidence) and reviews; items the model got wrong (a box off
|
|
23672
|
+
* the frame, an unasked class, an unknown ref) are dropped and counted in
|
|
23673
|
+
* `rejected`. A whole answer that is not the schema is `malformed-answer`.
|
|
23674
|
+
*/
|
|
23675
|
+
var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
|
|
23676
|
+
kind: literal("proposed"),
|
|
23677
|
+
profileId: string(),
|
|
23678
|
+
model: string(),
|
|
23679
|
+
/** The frame was sent outside the house for this answer. */
|
|
23680
|
+
leftHouse: boolean(),
|
|
23681
|
+
proposals: array(RetrainLlmProposalSchema).readonly(),
|
|
23682
|
+
reviews: array(RetrainLlmReviewSchema).readonly(),
|
|
23683
|
+
rejected: number().int()
|
|
23684
|
+
}), object({
|
|
23685
|
+
kind: literal("refused"),
|
|
23686
|
+
reason: _enum([
|
|
23687
|
+
"unknown-frame",
|
|
23688
|
+
"unreadable-frame",
|
|
23689
|
+
"unknown-profile",
|
|
23690
|
+
"profile-disabled",
|
|
23691
|
+
"no-vision",
|
|
23692
|
+
"cloud-not-confirmed",
|
|
23693
|
+
"llm-error",
|
|
23694
|
+
"malformed-answer"
|
|
23695
|
+
]),
|
|
23696
|
+
detail: string().optional()
|
|
23697
|
+
})]);
|
|
22614
23698
|
/** The outcome of a lifecycle move owned by the retrain page. */
|
|
22615
23699
|
var RetrainTransitionResultSchema = object({
|
|
22616
23700
|
trackId: string(),
|
|
@@ -23328,7 +24412,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
23328
24412
|
auth: "admin"
|
|
23329
24413
|
}), method(object({
|
|
23330
24414
|
deviceId: number(),
|
|
23331
|
-
trackId: string(),
|
|
24415
|
+
trackId: string().optional(),
|
|
23332
24416
|
frameId: string()
|
|
23333
24417
|
}), object({
|
|
23334
24418
|
removed: boolean(),
|
|
@@ -23345,7 +24429,8 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
23345
24429
|
auth: "admin"
|
|
23346
24430
|
}), method(object({
|
|
23347
24431
|
deviceId: number(),
|
|
23348
|
-
|
|
24432
|
+
/** The frame's track, when it has one — checked against the frame. */
|
|
24433
|
+
trackId: string().optional(),
|
|
23349
24434
|
frameId: string(),
|
|
23350
24435
|
subject: RetrainAssistSubjectSchema,
|
|
23351
24436
|
/** Which node runs it. Absent ⇒ wherever an unowned call lands. */
|
|
@@ -23353,12 +24438,16 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
23353
24438
|
}), RetrainAssistResultSchema, {
|
|
23354
24439
|
kind: "mutation",
|
|
23355
24440
|
auth: "admin"
|
|
23356
|
-
}), method(object({
|
|
24441
|
+
}), method(object({
|
|
24442
|
+
trackId: string().optional(),
|
|
24443
|
+
frameIds: array(string()).max(2e3).optional()
|
|
24444
|
+
}), array(RetrainAnnotationSchema).readonly(), {
|
|
23357
24445
|
kind: "query",
|
|
23358
24446
|
auth: "admin"
|
|
23359
24447
|
}), method(object({
|
|
23360
24448
|
deviceId: number(),
|
|
23361
|
-
|
|
24449
|
+
/** The frame's track, when it has one — checked against the frame. */
|
|
24450
|
+
trackId: string().optional(),
|
|
23362
24451
|
frameId: string(),
|
|
23363
24452
|
annotations: array(RetrainAnnotationDraftSchema)
|
|
23364
24453
|
}), array(RetrainAnnotationSchema).readonly(), {
|
|
@@ -23381,7 +24470,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
23381
24470
|
auth: "admin"
|
|
23382
24471
|
}), method(object({
|
|
23383
24472
|
deviceId: number(),
|
|
23384
|
-
trackId: string(),
|
|
24473
|
+
trackId: string().optional(),
|
|
23385
24474
|
frameId: string(),
|
|
23386
24475
|
complete: boolean()
|
|
23387
24476
|
}), RetrainFrameSchema, {
|
|
@@ -23395,6 +24484,74 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
23395
24484
|
kind: "mutation",
|
|
23396
24485
|
auth: "admin",
|
|
23397
24486
|
timeoutMs: 60 * 6e4
|
|
24487
|
+
}), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
|
|
24488
|
+
kind: "query",
|
|
24489
|
+
auth: "admin"
|
|
24490
|
+
}), method(object({
|
|
24491
|
+
deviceId: number(),
|
|
24492
|
+
trackId: string().optional(),
|
|
24493
|
+
frameId: string(),
|
|
24494
|
+
profileId: string(),
|
|
24495
|
+
classes: array(RetrainMacroClassSchema).min(1),
|
|
24496
|
+
boxes: array(object({
|
|
24497
|
+
ref: string(),
|
|
24498
|
+
bbox: RetrainBboxSchema,
|
|
24499
|
+
macroClass: RetrainMacroClassSchema,
|
|
24500
|
+
label: string().optional()
|
|
24501
|
+
})).max(50),
|
|
24502
|
+
allowCloud: boolean()
|
|
24503
|
+
}), RetrainLlmAssistResultSchema, {
|
|
24504
|
+
kind: "mutation",
|
|
24505
|
+
auth: "admin",
|
|
24506
|
+
timeoutMs: 18e4
|
|
24507
|
+
}), method(object({ name: string().max(120) }), RetrainCollectionCreateResultSchema, {
|
|
24508
|
+
kind: "mutation",
|
|
24509
|
+
auth: "admin"
|
|
24510
|
+
}), method(object({}), array(RetrainCollectionSchema).readonly(), {
|
|
24511
|
+
kind: "query",
|
|
24512
|
+
auth: "admin"
|
|
24513
|
+
}), method(object({
|
|
24514
|
+
id: string(),
|
|
24515
|
+
name: string().max(120)
|
|
24516
|
+
}), RetrainCollectionRenameResultSchema, {
|
|
24517
|
+
kind: "mutation",
|
|
24518
|
+
auth: "admin"
|
|
24519
|
+
}), method(object({ id: string() }), object({
|
|
24520
|
+
deleted: boolean(),
|
|
24521
|
+
removedFrames: number().int()
|
|
24522
|
+
}), {
|
|
24523
|
+
kind: "mutation",
|
|
24524
|
+
auth: "admin"
|
|
24525
|
+
}), method(object({
|
|
24526
|
+
collectionId: string(),
|
|
24527
|
+
deviceId: number(),
|
|
24528
|
+
epochMs: number()
|
|
24529
|
+
}), AddRetrainFrameFromRecordingResultSchema, {
|
|
24530
|
+
kind: "mutation",
|
|
24531
|
+
auth: "admin",
|
|
24532
|
+
timeoutMs: 6e4
|
|
24533
|
+
}), method(object({
|
|
24534
|
+
collectionId: string(),
|
|
24535
|
+
frameIds: array(string()).min(1).max(500)
|
|
24536
|
+
}), object({
|
|
24537
|
+
added: number().int(),
|
|
24538
|
+
alreadyMember: number().int(),
|
|
24539
|
+
unknownFrameIds: array(string()).readonly()
|
|
24540
|
+
}), {
|
|
24541
|
+
kind: "mutation",
|
|
24542
|
+
auth: "admin"
|
|
24543
|
+
}), method(object({
|
|
24544
|
+
collectionId: string(),
|
|
24545
|
+
frameId: string()
|
|
24546
|
+
}), object({
|
|
24547
|
+
removed: boolean(),
|
|
24548
|
+
deletedFrame: boolean()
|
|
24549
|
+
}), {
|
|
24550
|
+
kind: "mutation",
|
|
24551
|
+
auth: "admin"
|
|
24552
|
+
}), method(object({ collectionId: string() }), array(RetrainFrameSchema).readonly(), {
|
|
24553
|
+
kind: "query",
|
|
24554
|
+
auth: "admin"
|
|
23398
24555
|
}), method(object({
|
|
23399
24556
|
/** Which of the three event tables owns the row. */
|
|
23400
24557
|
ownerType: EventOwnerTypeSchema,
|
|
@@ -24018,13 +25175,31 @@ var RecommendationReasonSchema = discriminatedUnion("kind", [
|
|
|
24018
25175
|
object({
|
|
24019
25176
|
kind: literal("no-family-build"),
|
|
24020
25177
|
format: ModelFormatSchema$1
|
|
25178
|
+
}),
|
|
25179
|
+
object({
|
|
25180
|
+
kind: literal("kept-custom-pin"),
|
|
25181
|
+
modelId: string(),
|
|
25182
|
+
deviceKey: string()
|
|
24021
25183
|
})
|
|
24022
25184
|
]);
|
|
25185
|
+
/** Why a device is left exactly as it is, whatever the plan would pick (D786). */
|
|
25186
|
+
var KeptReasonSchema = _enum(["custom-pin"]);
|
|
25187
|
+
/**
|
|
25188
|
+
* Where a choice's latency came from (D791): this node's own benchmark
|
|
25189
|
+
* result, or the hardware-class table. Measured on the node beats the table.
|
|
25190
|
+
*/
|
|
25191
|
+
var LatencySourceSchema = discriminatedUnion("kind", [object({ kind: literal("table") }), object({
|
|
25192
|
+
kind: literal("node-benchmark"),
|
|
25193
|
+
resultId: string(),
|
|
25194
|
+
measuredAtMs: number()
|
|
25195
|
+
})]);
|
|
24023
25196
|
var DeviceModelChoiceSchema = object({
|
|
24024
25197
|
modelId: string(),
|
|
24025
25198
|
p50Ms: number(),
|
|
24026
25199
|
fps: number(),
|
|
24027
25200
|
measured: boolean(),
|
|
25201
|
+
/** Absent on a plan from before D791 — read as the table. */
|
|
25202
|
+
source: LatencySourceSchema.optional(),
|
|
24028
25203
|
/** Parallel sessions at the camera rate with the headroom kept free: ⌊fps × (1 − headroom) / camera fps⌋. */
|
|
24029
25204
|
capacitySessions: number(),
|
|
24030
25205
|
personRecall: number()
|
|
@@ -24035,6 +25210,8 @@ var DeviceRecommendationSchema = object({
|
|
|
24035
25210
|
enabled: boolean(),
|
|
24036
25211
|
available: boolean(),
|
|
24037
25212
|
chosen: DeviceModelChoiceSchema.nullable(),
|
|
25213
|
+
/** Present when the device is kept as is: Apply writes nothing on it. */
|
|
25214
|
+
kept: KeptReasonSchema.optional(),
|
|
24038
25215
|
reasons: array(RecommendationReasonSchema).readonly()
|
|
24039
25216
|
});
|
|
24040
25217
|
var NodeRecommendationSchema = object({
|
|
@@ -24088,6 +25265,17 @@ var AutoTuneWarningSchema = discriminatedUnion("kind", [
|
|
|
24088
25265
|
kind: literal("coral-enabled"),
|
|
24089
25266
|
nodeId: string(),
|
|
24090
25267
|
deviceKey: string()
|
|
25268
|
+
}),
|
|
25269
|
+
object({
|
|
25270
|
+
kind: literal("custom-pin-kept"),
|
|
25271
|
+
nodeId: string(),
|
|
25272
|
+
deviceKey: string().nullable(),
|
|
25273
|
+
deviceId: number().nullable(),
|
|
25274
|
+
modelId: string()
|
|
25275
|
+
}),
|
|
25276
|
+
object({
|
|
25277
|
+
kind: literal("custom-registry-unreadable"),
|
|
25278
|
+
error: string()
|
|
24091
25279
|
})
|
|
24092
25280
|
]);
|
|
24093
25281
|
var AutoTuneOptionsSchema = object({
|
|
@@ -24266,13 +25454,14 @@ var SuggestSharesResultSchema = object({
|
|
|
24266
25454
|
nodes: array(SuggestedNodeShareSchema).readonly()
|
|
24267
25455
|
});
|
|
24268
25456
|
/**
|
|
24269
|
-
* Where the node and device shares come from (D750, D755).
|
|
24270
|
-
* - `
|
|
24271
|
-
*
|
|
24272
|
-
*
|
|
24273
|
-
*
|
|
24274
|
-
*
|
|
24275
|
-
*
|
|
25457
|
+
* Where the node and device shares come from (D750, D755, D791).
|
|
25458
|
+
* - `benchmark` (default since D791) — each node's capacity as its own node
|
|
25459
|
+
* benchmark measured it; a node without fresh results is sized from
|
|
25460
|
+
* `hardware` and says so. Measured on the node beats the table.
|
|
25461
|
+
* - `hardware` — computed from each node's static capacity only (its
|
|
25462
|
+
* accelerators at their Auto tune models, from the latency table).
|
|
25463
|
+
* Both are recomputed whenever a node or device joins, leaves, is switched
|
|
25464
|
+
* on or off, changes model, or a benchmark result is written. No load input.
|
|
24276
25465
|
* - `manual` — the operator's stored sliders.
|
|
24277
25466
|
* Either way a node or device that cannot take sessions gives its share to
|
|
24278
25467
|
* the others in proportion; the stored values are never rewritten for that.
|
|
@@ -24321,6 +25510,362 @@ var EffectiveSharesSchema = object({
|
|
|
24321
25510
|
nodeWeights: record(string(), number()),
|
|
24322
25511
|
deviceWeights: record(string(), record(string(), number()))
|
|
24323
25512
|
});
|
|
25513
|
+
/**
|
|
25514
|
+
* Wire shapes of the node benchmark (D791): the operator's plan, the
|
|
25515
|
+
* preflight the confirmation shows, the run the orchestrator owns, what the
|
|
25516
|
+
* measuring runner reports, and the result rows Auto tune and the automatic
|
|
25517
|
+
* shares read.
|
|
25518
|
+
*
|
|
25519
|
+
* ONE node at a time, owned by the pipeline orchestrator. While a run is
|
|
25520
|
+
* active the cluster is in BENCHMARK MODE for that node: it is not a
|
|
25521
|
+
* detection candidate, camera pins naming it are ignored so its sessions move
|
|
25522
|
+
* elsewhere, and both come back when the mode ends — after a crash or a hub
|
|
25523
|
+
* restart too (a persisted manifest, reconciled against the registry).
|
|
25524
|
+
*
|
|
25525
|
+
* Two measurements, both on the node, driven by its own runner (frames never
|
|
25526
|
+
* cross a process at frame rate, D9):
|
|
25527
|
+
* - `device` — one accelerator × one candidate detector, root only, open
|
|
25528
|
+
* loop: how many streams at the camera rate it carries inside the frame
|
|
25529
|
+
* interval;
|
|
25530
|
+
* - `pipeline` — the chosen detector plus the operator's detail steps
|
|
25531
|
+
* (faces, plates, classifiers, CLIP…), on varied frames from the bench
|
|
25532
|
+
* clip: how many parallel sessions the node carries before latency, drops,
|
|
25533
|
+
* CPU, RAM or the event loop give out.
|
|
25534
|
+
*/
|
|
25535
|
+
/** Defaults and bounds, one place. */
|
|
25536
|
+
var NODE_BENCHMARK_DEFAULTS = {
|
|
25537
|
+
fpsPerStream: 10,
|
|
25538
|
+
budgetMinutes: 45,
|
|
25539
|
+
minBudgetMinutes: 10,
|
|
25540
|
+
maxBudgetMinutes: 120,
|
|
25541
|
+
/** A result older than this no longer beats the table. */
|
|
25542
|
+
staleAfterDays: 30,
|
|
25543
|
+
/** Warm-in per ramp step (not accounted). */
|
|
25544
|
+
settleSec: 5,
|
|
25545
|
+
/** Accounted window per ramp step. */
|
|
25546
|
+
measureSec: 20,
|
|
25547
|
+
/** Longest the drain may take before the run is refused. */
|
|
25548
|
+
drainTimeoutSec: 120,
|
|
25549
|
+
/** Candidate models per device in one run. */
|
|
25550
|
+
maxModelsPerDevice: 6
|
|
25551
|
+
};
|
|
25552
|
+
/** The two measurements a run can make. */
|
|
25553
|
+
var NodeBenchmarkPhaseSchema = _enum(["device", "pipeline"]);
|
|
25554
|
+
var NodeBenchmarkDevicePlanSchema = object({
|
|
25555
|
+
/** `<backend>:<device>` — `openvino:npu`, `coreml:all`, `cpu`. */
|
|
25556
|
+
deviceKey: string().min(1),
|
|
25557
|
+
/**
|
|
25558
|
+
* Root detector candidates for the `device` measurement, in the order
|
|
25559
|
+
* measured. The FIRST is the one the `pipeline` measurement runs.
|
|
25560
|
+
*/
|
|
25561
|
+
modelIds: array(string().min(1)).min(1).max(NODE_BENCHMARK_DEFAULTS.maxModelsPerDevice)
|
|
25562
|
+
});
|
|
25563
|
+
/** What the operator confirmed. */
|
|
25564
|
+
var NodeBenchmarkPlanSchema = object({
|
|
25565
|
+
nodeId: string().min(1),
|
|
25566
|
+
devices: array(NodeBenchmarkDevicePlanSchema).min(1),
|
|
25567
|
+
/** Which measurements run. At least one. */
|
|
25568
|
+
phases: array(NodeBenchmarkPhaseSchema).min(1).default(["device", "pipeline"]),
|
|
25569
|
+
/**
|
|
25570
|
+
* Detail steps (catalog step ids under the root: faces, plates,
|
|
25571
|
+
* classifiers, CLIP…) the `pipeline` measurement enables. The root
|
|
25572
|
+
* detector always runs.
|
|
25573
|
+
*/
|
|
25574
|
+
steps: array(string().min(1)).default([]),
|
|
25575
|
+
/** Offered rate of one stream / session. */
|
|
25576
|
+
fpsPerStream: number().int().min(1).max(30).default(NODE_BENCHMARK_DEFAULTS.fpsPerStream),
|
|
25577
|
+
/** Hard deadline: the mode ends and the cluster is restored when it passes. */
|
|
25578
|
+
budgetMinutes: number().int().min(NODE_BENCHMARK_DEFAULTS.minBudgetMinutes).max(NODE_BENCHMARK_DEFAULTS.maxBudgetMinutes).default(NODE_BENCHMARK_DEFAULTS.budgetMinutes),
|
|
25579
|
+
/** Keep the models the run downloaded (default: delete what was not installed before). */
|
|
25580
|
+
keepDownloadedModels: boolean().default(false),
|
|
25581
|
+
/** Start although the other nodes' capacity does not cover the sessions running now. */
|
|
25582
|
+
acceptInsufficientHeadroom: boolean().default(false)
|
|
25583
|
+
});
|
|
25584
|
+
var NodeBenchmarkRefusalSchema = object({
|
|
25585
|
+
kind: _enum([
|
|
25586
|
+
"benchmark-active",
|
|
25587
|
+
"node-offline",
|
|
25588
|
+
"unknown-device",
|
|
25589
|
+
"no-phase",
|
|
25590
|
+
"insufficient-headroom"
|
|
25591
|
+
]),
|
|
25592
|
+
detail: string(),
|
|
25593
|
+
overridable: boolean()
|
|
25594
|
+
});
|
|
25595
|
+
/** A camera whose detection leaves the node for the run. */
|
|
25596
|
+
var NodeBenchmarkMovingCameraSchema = object({
|
|
25597
|
+
deviceId: number(),
|
|
25598
|
+
/** Placed on the node now (a standing attach or a running session). */
|
|
25599
|
+
placedOnNode: boolean(),
|
|
25600
|
+
/** A node pin naming this node, ignored for the run. */
|
|
25601
|
+
pinnedToNode: boolean()
|
|
25602
|
+
});
|
|
25603
|
+
/** A camera that cannot leave: no other node can obtain its frames. */
|
|
25604
|
+
var NodeBenchmarkStayingCameraSchema = object({
|
|
25605
|
+
deviceId: number(),
|
|
25606
|
+
reason: literal("only-frame-source")
|
|
25607
|
+
});
|
|
25608
|
+
var NodeBenchmarkPreflightSchema = object({
|
|
25609
|
+
nodeId: string(),
|
|
25610
|
+
online: boolean(),
|
|
25611
|
+
moving: array(NodeBenchmarkMovingCameraSchema).readonly(),
|
|
25612
|
+
/** Keep running on the node during the run; the result is flagged contaminated. */
|
|
25613
|
+
staying: array(NodeBenchmarkStayingCameraSchema).readonly(),
|
|
25614
|
+
estimatedDurationMs: number(),
|
|
25615
|
+
/** The run ends and the cluster is restored at the latest after this long. */
|
|
25616
|
+
budgetMs: number(),
|
|
25617
|
+
phases: array(NodeBenchmarkPhaseSchema).readonly(),
|
|
25618
|
+
steps: array(string()).readonly(),
|
|
25619
|
+
devices: array(NodeBenchmarkDevicePlanSchema).readonly(),
|
|
25620
|
+
/** Parallel sessions the cluster runs now, and what the other nodes can carry. */
|
|
25621
|
+
headroom: object({
|
|
25622
|
+
sessionsNow: number(),
|
|
25623
|
+
otherNodesCapacitySessions: number().nullable()
|
|
25624
|
+
}),
|
|
25625
|
+
refusals: array(NodeBenchmarkRefusalSchema).readonly(),
|
|
25626
|
+
canStart: boolean()
|
|
25627
|
+
});
|
|
25628
|
+
/** Where the measuring runner is. */
|
|
25629
|
+
var NodeBenchProgressSchema = object({
|
|
25630
|
+
phase: _enum([
|
|
25631
|
+
"preparing",
|
|
25632
|
+
"device",
|
|
25633
|
+
"pipeline",
|
|
25634
|
+
"cleanup"
|
|
25635
|
+
]),
|
|
25636
|
+
deviceKey: string().nullable(),
|
|
25637
|
+
modelId: string().nullable(),
|
|
25638
|
+
/** Streams (device) or sessions (pipeline) of the step running now. */
|
|
25639
|
+
load: number().nullable(),
|
|
25640
|
+
cellsDone: number(),
|
|
25641
|
+
cellsTotal: number(),
|
|
25642
|
+
message: string()
|
|
25643
|
+
});
|
|
25644
|
+
/** What limited a ramp. `none` = the ramp ran out of steps still passing. */
|
|
25645
|
+
var NodeBenchLimitSchema = _enum([
|
|
25646
|
+
"p95",
|
|
25647
|
+
"drops",
|
|
25648
|
+
"errors",
|
|
25649
|
+
"stall",
|
|
25650
|
+
"cpu",
|
|
25651
|
+
"ram",
|
|
25652
|
+
"none"
|
|
25653
|
+
]);
|
|
25654
|
+
var NodeBenchRampStepSchema = object({
|
|
25655
|
+
load: number(),
|
|
25656
|
+
pass: boolean(),
|
|
25657
|
+
p95Ms: number(),
|
|
25658
|
+
dropRatio: number(),
|
|
25659
|
+
/** Completed frames per second over the accounted window. */
|
|
25660
|
+
fps: number(),
|
|
25661
|
+
cpuPct: number().nullable(),
|
|
25662
|
+
ramFreePct: number().nullable(),
|
|
25663
|
+
failReasons: array(string()).readonly()
|
|
25664
|
+
});
|
|
25665
|
+
var NodeBenchCellSchema = discriminatedUnion("phase", [object({
|
|
25666
|
+
phase: literal("device"),
|
|
25667
|
+
deviceKey: string(),
|
|
25668
|
+
modelId: string(),
|
|
25669
|
+
/** Single-stream latency (the K = 1 step). */
|
|
25670
|
+
p50Ms: number(),
|
|
25671
|
+
p95Ms: number(),
|
|
25672
|
+
p99Ms: number(),
|
|
25673
|
+
/** Frames per second sustained at the last passing step. */
|
|
25674
|
+
fps: number(),
|
|
25675
|
+
/** Streams at the camera rate the device carried inside the frame interval; 0 = not even one. */
|
|
25676
|
+
kMax: number(),
|
|
25677
|
+
limitedBy: NodeBenchLimitSchema,
|
|
25678
|
+
/** First call (model load + warm-up). */
|
|
25679
|
+
warmupMs: number(),
|
|
25680
|
+
ramp: array(NodeBenchRampStepSchema).readonly()
|
|
25681
|
+
}), object({
|
|
25682
|
+
phase: literal("pipeline"),
|
|
25683
|
+
deviceKey: string(),
|
|
25684
|
+
modelId: string(),
|
|
25685
|
+
steps: array(string()).readonly(),
|
|
25686
|
+
/** Parallel sessions at the camera rate the node carried; 0 = not even one. */
|
|
25687
|
+
maxSessions: number(),
|
|
25688
|
+
limitedBy: NodeBenchLimitSchema,
|
|
25689
|
+
/** Detail steps that produced at least one result on the clip — a step that never fired measured nothing. */
|
|
25690
|
+
stepsFired: array(string()).readonly(),
|
|
25691
|
+
warmupMs: number(),
|
|
25692
|
+
ramp: array(NodeBenchRampStepSchema).readonly()
|
|
25693
|
+
})]);
|
|
25694
|
+
/**
|
|
25695
|
+
* What a result was measured ON. A result whose fingerprint no longer matches
|
|
25696
|
+
* the node no longer beats the table.
|
|
25697
|
+
*/
|
|
25698
|
+
var NodeBenchFingerprintSchema = object({
|
|
25699
|
+
pipelineVersion: string().nullable(),
|
|
25700
|
+
cpuModel: string().nullable(),
|
|
25701
|
+
ramGb: number().nullable(),
|
|
25702
|
+
os: string().nullable(),
|
|
25703
|
+
/** Per device: the pool the cells ran on (runtime + tuning). */
|
|
25704
|
+
pools: record(string(), object({
|
|
25705
|
+
runtime: string(),
|
|
25706
|
+
numWorkers: number(),
|
|
25707
|
+
concurrency: number(),
|
|
25708
|
+
batchMode: string()
|
|
25709
|
+
})).default({})
|
|
25710
|
+
});
|
|
25711
|
+
/** The frames the run used. */
|
|
25712
|
+
var NodeBenchClipSchema = object({
|
|
25713
|
+
/** `camstack-bench-v1` or `reference-images` (the fallback when the clip is not reachable). */
|
|
25714
|
+
id: string(),
|
|
25715
|
+
revision: string().nullable(),
|
|
25716
|
+
frames: number(),
|
|
25717
|
+
width: number(),
|
|
25718
|
+
height: number()
|
|
25719
|
+
});
|
|
25720
|
+
var NodeBenchRunnerInputSchema = object({
|
|
25721
|
+
runId: string().min(1),
|
|
25722
|
+
devices: array(NodeBenchmarkDevicePlanSchema).min(1),
|
|
25723
|
+
phases: array(NodeBenchmarkPhaseSchema).min(1),
|
|
25724
|
+
/** The full detail step tree root for the `pipeline` measurement is built on the node from these ids. */
|
|
25725
|
+
steps: array(string()).default([]),
|
|
25726
|
+
fpsPerStream: number().int().min(1).max(30),
|
|
25727
|
+
/** The runner stops on its own past this instant, whatever the hub does. */
|
|
25728
|
+
deadlineAtMs: number(),
|
|
25729
|
+
settleSec: number().min(0).max(60).default(NODE_BENCHMARK_DEFAULTS.settleSec),
|
|
25730
|
+
measureSec: number().min(2).max(300).default(NODE_BENCHMARK_DEFAULTS.measureSec),
|
|
25731
|
+
keepDownloadedModels: boolean().default(false)
|
|
25732
|
+
});
|
|
25733
|
+
var NodeBenchRunnerStateSchema = _enum([
|
|
25734
|
+
"running",
|
|
25735
|
+
"done",
|
|
25736
|
+
"failed",
|
|
25737
|
+
"aborted"
|
|
25738
|
+
]);
|
|
25739
|
+
var NodeBenchRunnerStatusSchema = object({
|
|
25740
|
+
runId: string(),
|
|
25741
|
+
nodeId: string(),
|
|
25742
|
+
state: NodeBenchRunnerStateSchema,
|
|
25743
|
+
progress: NodeBenchProgressSchema.nullable(),
|
|
25744
|
+
/** Every finished cell so far — a run stopped half way keeps what it measured. */
|
|
25745
|
+
cells: array(NodeBenchCellSchema).readonly(),
|
|
25746
|
+
fingerprint: NodeBenchFingerprintSchema.nullable(),
|
|
25747
|
+
clip: NodeBenchClipSchema.nullable(),
|
|
25748
|
+
/** Cameras seen running on the node during the run (they share its pools). */
|
|
25749
|
+
activeCameraIds: array(number()).readonly(),
|
|
25750
|
+
/** Models the run downloaded and then deleted (not installed before). */
|
|
25751
|
+
deletedModels: array(string()).readonly(),
|
|
25752
|
+
error: string().nullable(),
|
|
25753
|
+
startedAtMs: number(),
|
|
25754
|
+
finishedAtMs: number().nullable()
|
|
25755
|
+
});
|
|
25756
|
+
var NodeBenchmarkStateSchema = _enum([
|
|
25757
|
+
"draining",
|
|
25758
|
+
"measuring",
|
|
25759
|
+
"restoring",
|
|
25760
|
+
"done",
|
|
25761
|
+
"failed",
|
|
25762
|
+
"aborted"
|
|
25763
|
+
]);
|
|
25764
|
+
/** Why a run ended. */
|
|
25765
|
+
var NodeBenchmarkEndReasonSchema = _enum([
|
|
25766
|
+
"completed",
|
|
25767
|
+
"operator-abort",
|
|
25768
|
+
"deadline",
|
|
25769
|
+
"node-lost",
|
|
25770
|
+
"runner-lost",
|
|
25771
|
+
"hub-restart",
|
|
25772
|
+
"drain-timeout",
|
|
25773
|
+
"failed"
|
|
25774
|
+
]);
|
|
25775
|
+
var NodeBenchmarkRunSchema = object({
|
|
25776
|
+
runId: string(),
|
|
25777
|
+
nodeId: string(),
|
|
25778
|
+
state: NodeBenchmarkStateSchema,
|
|
25779
|
+
plan: NodeBenchmarkPlanSchema,
|
|
25780
|
+
startedAtMs: number(),
|
|
25781
|
+
deadlineAtMs: number(),
|
|
25782
|
+
finishedAtMs: number().nullable(),
|
|
25783
|
+
endReason: NodeBenchmarkEndReasonSchema.nullable(),
|
|
25784
|
+
error: string().nullable(),
|
|
25785
|
+
/** Cameras moved off the node for the run. */
|
|
25786
|
+
moved: array(number()).readonly(),
|
|
25787
|
+
/** Cameras that stayed (their only frame source is the node). */
|
|
25788
|
+
staying: array(number()).readonly(),
|
|
25789
|
+
/** Something else ran on the node's pools during the run. */
|
|
25790
|
+
contaminated: boolean(),
|
|
25791
|
+
progress: NodeBenchProgressSchema.nullable(),
|
|
25792
|
+
resultIds: array(string()).readonly()
|
|
25793
|
+
});
|
|
25794
|
+
/** `getNodeBenchmarkStatus`: the active run (or the last one), and whether benchmark mode is on. */
|
|
25795
|
+
var NodeBenchmarkStatusSchema = object({
|
|
25796
|
+
/** The node the cluster is in benchmark mode for; null = none. */
|
|
25797
|
+
modeNodeId: string().nullable(),
|
|
25798
|
+
run: NodeBenchmarkRunSchema.nullable()
|
|
25799
|
+
});
|
|
25800
|
+
/**
|
|
25801
|
+
* One stored measurement — the only authority Auto tune and the automatic
|
|
25802
|
+
* shares read measured capacity from. Written by the orchestrator when a run
|
|
25803
|
+
* ends, never by anyone else.
|
|
25804
|
+
*/
|
|
25805
|
+
var NodeBenchmarkResultSchema = object({
|
|
25806
|
+
id: string(),
|
|
25807
|
+
runId: string(),
|
|
25808
|
+
nodeId: string(),
|
|
25809
|
+
cell: NodeBenchCellSchema,
|
|
25810
|
+
fpsPerStream: number(),
|
|
25811
|
+
fingerprint: NodeBenchFingerprintSchema.nullable(),
|
|
25812
|
+
clip: NodeBenchClipSchema.nullable(),
|
|
25813
|
+
/** Other work shared the node's pools (a camera that could not move, or the hub's own duties). */
|
|
25814
|
+
contaminated: boolean(),
|
|
25815
|
+
stayingCameras: array(number()).readonly(),
|
|
25816
|
+
/** The run ended early; the cell itself completed. */
|
|
25817
|
+
partialRun: boolean(),
|
|
25818
|
+
measuredAtMs: number()
|
|
25819
|
+
});
|
|
25820
|
+
var ListNodeBenchmarkResultsInputSchema = object({
|
|
25821
|
+
nodeId: string().optional(),
|
|
25822
|
+
deviceKey: string().optional()
|
|
25823
|
+
});
|
|
25824
|
+
/** A result with its standing today: does it still beat the table? */
|
|
25825
|
+
var NodeBenchmarkResultViewSchema = NodeBenchmarkResultSchema.extend({
|
|
25826
|
+
/** `fresh` beats the table; `stale` falls back to it; `superseded` = a newer row covers the same cell. */
|
|
25827
|
+
standing: _enum([
|
|
25828
|
+
"fresh",
|
|
25829
|
+
"stale",
|
|
25830
|
+
"superseded"
|
|
25831
|
+
]),
|
|
25832
|
+
staleWhy: _enum([
|
|
25833
|
+
"age",
|
|
25834
|
+
"runtime",
|
|
25835
|
+
"pool-tuning"
|
|
25836
|
+
]).nullable()
|
|
25837
|
+
});
|
|
25838
|
+
object({
|
|
25839
|
+
runId: string(),
|
|
25840
|
+
nodeId: string(),
|
|
25841
|
+
startedAtMs: number(),
|
|
25842
|
+
deadlineAtMs: number(),
|
|
25843
|
+
plan: NodeBenchmarkPlanSchema,
|
|
25844
|
+
moved: array(number()).readonly(),
|
|
25845
|
+
staying: array(number()).readonly()
|
|
25846
|
+
});
|
|
25847
|
+
/** Candidate detectors per device, for the plan editor. */
|
|
25848
|
+
var NodeBenchmarkCandidatesSchema = object({
|
|
25849
|
+
nodeId: string(),
|
|
25850
|
+
reachable: boolean(),
|
|
25851
|
+
devices: array(object({
|
|
25852
|
+
deviceKey: string(),
|
|
25853
|
+
enabled: boolean(),
|
|
25854
|
+
available: boolean(),
|
|
25855
|
+
/** Ordered: what Auto tune would pick first, then the rest of the family by accuracy. */
|
|
25856
|
+
suggested: array(string()).readonly(),
|
|
25857
|
+
/** Every root detector the device has a build for. */
|
|
25858
|
+
all: array(string()).readonly(),
|
|
25859
|
+
/** The model the device runs now, when pinned. */
|
|
25860
|
+
currentModelId: string().nullable()
|
|
25861
|
+
})).readonly(),
|
|
25862
|
+
/** Detail steps the node's catalog offers under the root (for the `pipeline` measurement). */
|
|
25863
|
+
steps: array(object({
|
|
25864
|
+
id: string(),
|
|
25865
|
+
name: string(),
|
|
25866
|
+
slot: string()
|
|
25867
|
+
})).readonly()
|
|
25868
|
+
});
|
|
24324
25869
|
object({
|
|
24325
25870
|
activeCameras: number(),
|
|
24326
25871
|
throttledCameras: number(),
|
|
@@ -25449,7 +26994,16 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
|
|
|
25449
26994
|
}), ParkedTrackFrameSchema.nullable()), method(object({
|
|
25450
26995
|
deviceId: number(),
|
|
25451
26996
|
trackId: string()
|
|
25452
|
-
}), object({ released: number().int().nonnegative() }), { kind: "mutation" })
|
|
26997
|
+
}), object({ released: number().int().nonnegative() }), { kind: "mutation" }), method(NodeBenchRunnerInputSchema, object({
|
|
26998
|
+
accepted: literal(true),
|
|
26999
|
+
runId: string()
|
|
27000
|
+
}), {
|
|
27001
|
+
kind: "mutation",
|
|
27002
|
+
auth: "admin"
|
|
27003
|
+
}), method(object({ runId: string() }), NodeBenchRunnerStatusSchema.nullable(), { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
|
|
27004
|
+
kind: "mutation",
|
|
27005
|
+
auth: "admin"
|
|
27006
|
+
});
|
|
25453
27007
|
var CameraPipelineConfigSchema = object({
|
|
25454
27008
|
engine: PipelineEngineChoiceSchema.optional(),
|
|
25455
27009
|
steps: array(PipelineStepInputSchema).readonly(),
|
|
@@ -26088,6 +27642,21 @@ method(object({
|
|
|
26088
27642
|
}), method(PlacementStatsInputSchema, PlacementStatsSchema, { auth: "admin" }), method(SuggestSharesInputSchema, SuggestSharesResultSchema, { auth: "admin" }), method(_void(), EffectiveSharesSchema, { auth: "admin" }), method(SetShareSourceInputSchema, object({ success: literal(true) }), {
|
|
26089
27643
|
kind: "mutation",
|
|
26090
27644
|
auth: "admin"
|
|
27645
|
+
}), method(NodeBenchmarkPlanSchema, NodeBenchmarkPreflightSchema, { auth: "admin" }), method(NodeBenchmarkPlanSchema, discriminatedUnion("kind", [object({
|
|
27646
|
+
kind: literal("started"),
|
|
27647
|
+
runId: string()
|
|
27648
|
+
}), object({
|
|
27649
|
+
kind: literal("refused"),
|
|
27650
|
+
preflight: NodeBenchmarkPreflightSchema
|
|
27651
|
+
})]), {
|
|
27652
|
+
kind: "mutation",
|
|
27653
|
+
auth: "admin"
|
|
27654
|
+
}), method(_void(), NodeBenchmarkStatusSchema, { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
|
|
27655
|
+
kind: "mutation",
|
|
27656
|
+
auth: "admin"
|
|
27657
|
+
}), method(object({ nodeId: string() }), NodeBenchmarkCandidatesSchema, { auth: "admin" }), method(ListNodeBenchmarkResultsInputSchema, array(NodeBenchmarkResultViewSchema).readonly(), { auth: "admin" }), method(object({ id: string() }), object({ deleted: boolean() }), {
|
|
27658
|
+
kind: "mutation",
|
|
27659
|
+
auth: "admin"
|
|
26091
27660
|
}), method(object({ deviceId: number() }), CameraPipelineSettingsSchema.nullable()), method(object({
|
|
26092
27661
|
deviceId: number(),
|
|
26093
27662
|
addonId: string(),
|
|
@@ -32195,6 +33764,9 @@ var CreateIntegrationInputSchema = object({
|
|
|
32195
33764
|
enabled: boolean().optional(),
|
|
32196
33765
|
info: record(string(), unknown()).optional(),
|
|
32197
33766
|
settings: record(string(), unknown()).optional(),
|
|
33767
|
+
/** Keys of `settings` the form's schema declares secret (by type) — kept in
|
|
33768
|
+
* the keychain, not the table (D787). */
|
|
33769
|
+
secretKeys: array(string()).optional(),
|
|
32198
33770
|
skipRestart: boolean().optional()
|
|
32199
33771
|
});
|
|
32200
33772
|
var UpdateIntegrationInputSchema = object({
|
|
@@ -32218,7 +33790,9 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
|
|
|
32218
33790
|
auth: "admin"
|
|
32219
33791
|
}), method(object({ id: string() }), record(string(), unknown()), { auth: "admin" }), method(object({
|
|
32220
33792
|
id: string(),
|
|
32221
|
-
settings: record(string(), unknown())
|
|
33793
|
+
settings: record(string(), unknown()),
|
|
33794
|
+
/** Keys the form's schema declares secret (by type) — keychain-stored (D787). */
|
|
33795
|
+
secretKeys: array(string()).optional()
|
|
32222
33796
|
}), object({ success: boolean() }), {
|
|
32223
33797
|
kind: "mutation",
|
|
32224
33798
|
auth: "admin"
|
|
@@ -40381,7 +41955,8 @@ var BaseDevice = class {
|
|
|
40381
41955
|
this.role = options.role;
|
|
40382
41956
|
this.parentDeviceId = ctx.parentDeviceId;
|
|
40383
41957
|
const seedData = ctx.persistedConfig ?? {};
|
|
40384
|
-
|
|
41958
|
+
const declaredSecretPaths = collectZodSecretPaths(schema);
|
|
41959
|
+
this.config = DeviceConfig.fromSchema(schema, (data) => ctx.persistConfig(data, { secretConfigPaths: declaredSecretPaths }), seedData, ({ droppedKeys, issues }) => {
|
|
40385
41960
|
ctx.logger.warn("Device config recovery: dropping invalid persisted fields", {
|
|
40386
41961
|
tags: {
|
|
40387
41962
|
deviceId: ctx.id,
|
|
@@ -44070,6 +45645,90 @@ Object.freeze({
|
|
|
44070
45645
|
addonId: null,
|
|
44071
45646
|
access: "create"
|
|
44072
45647
|
},
|
|
45648
|
+
"keychain.delete": {
|
|
45649
|
+
capName: "keychain",
|
|
45650
|
+
capScope: "system",
|
|
45651
|
+
addonId: null,
|
|
45652
|
+
access: "delete"
|
|
45653
|
+
},
|
|
45654
|
+
"keychain.getState": {
|
|
45655
|
+
capName: "keychain",
|
|
45656
|
+
capScope: "system",
|
|
45657
|
+
addonId: null,
|
|
45658
|
+
access: "view"
|
|
45659
|
+
},
|
|
45660
|
+
"keychain.listMeta": {
|
|
45661
|
+
capName: "keychain",
|
|
45662
|
+
capScope: "system",
|
|
45663
|
+
addonId: null,
|
|
45664
|
+
access: "view"
|
|
45665
|
+
},
|
|
45666
|
+
"keychain.put": {
|
|
45667
|
+
capName: "keychain",
|
|
45668
|
+
capScope: "system",
|
|
45669
|
+
addonId: null,
|
|
45670
|
+
access: "create"
|
|
45671
|
+
},
|
|
45672
|
+
"keychain.resolve": {
|
|
45673
|
+
capName: "keychain",
|
|
45674
|
+
capScope: "system",
|
|
45675
|
+
addonId: null,
|
|
45676
|
+
access: "view"
|
|
45677
|
+
},
|
|
45678
|
+
"keychainAdmin.deleteOrphans": {
|
|
45679
|
+
capName: "keychain-admin",
|
|
45680
|
+
capScope: "system",
|
|
45681
|
+
addonId: null,
|
|
45682
|
+
access: "delete"
|
|
45683
|
+
},
|
|
45684
|
+
"keychainAdmin.downloadRecoveryKey": {
|
|
45685
|
+
capName: "keychain-admin",
|
|
45686
|
+
capScope: "system",
|
|
45687
|
+
addonId: null,
|
|
45688
|
+
access: "create"
|
|
45689
|
+
},
|
|
45690
|
+
"keychainAdmin.listAudit": {
|
|
45691
|
+
capName: "keychain-admin",
|
|
45692
|
+
capScope: "system",
|
|
45693
|
+
addonId: null,
|
|
45694
|
+
access: "view"
|
|
45695
|
+
},
|
|
45696
|
+
"keychainAdmin.listSecrets": {
|
|
45697
|
+
capName: "keychain-admin",
|
|
45698
|
+
capScope: "system",
|
|
45699
|
+
addonId: null,
|
|
45700
|
+
access: "view"
|
|
45701
|
+
},
|
|
45702
|
+
"keychainAdmin.purgeRetiredKeys": {
|
|
45703
|
+
capName: "keychain-admin",
|
|
45704
|
+
capScope: "system",
|
|
45705
|
+
addonId: null,
|
|
45706
|
+
access: "delete"
|
|
45707
|
+
},
|
|
45708
|
+
"keychainAdmin.resetKeychain": {
|
|
45709
|
+
capName: "keychain-admin",
|
|
45710
|
+
capScope: "system",
|
|
45711
|
+
addonId: null,
|
|
45712
|
+
access: "delete"
|
|
45713
|
+
},
|
|
45714
|
+
"keychainAdmin.reveal": {
|
|
45715
|
+
capName: "keychain-admin",
|
|
45716
|
+
capScope: "system",
|
|
45717
|
+
addonId: null,
|
|
45718
|
+
access: "create"
|
|
45719
|
+
},
|
|
45720
|
+
"keychainAdmin.rotateMasterKey": {
|
|
45721
|
+
capName: "keychain-admin",
|
|
45722
|
+
capScope: "system",
|
|
45723
|
+
addonId: null,
|
|
45724
|
+
access: "create"
|
|
45725
|
+
},
|
|
45726
|
+
"keychainAdmin.status": {
|
|
45727
|
+
capName: "keychain-admin",
|
|
45728
|
+
capScope: "system",
|
|
45729
|
+
addonId: null,
|
|
45730
|
+
access: "view"
|
|
45731
|
+
},
|
|
44073
45732
|
"lawnMowerControl.dock": {
|
|
44074
45733
|
capName: "lawn-mower-control",
|
|
44075
45734
|
capScope: "device",
|
|
@@ -45444,6 +47103,18 @@ Object.freeze({
|
|
|
45444
47103
|
addonId: null,
|
|
45445
47104
|
access: "create"
|
|
45446
47105
|
},
|
|
47106
|
+
"pipelineAnalytics.addRetrainFrameFromRecording": {
|
|
47107
|
+
capName: "pipeline-analytics",
|
|
47108
|
+
capScope: "device",
|
|
47109
|
+
addonId: null,
|
|
47110
|
+
access: "create"
|
|
47111
|
+
},
|
|
47112
|
+
"pipelineAnalytics.addRetrainFramesToCollection": {
|
|
47113
|
+
capName: "pipeline-analytics",
|
|
47114
|
+
capScope: "device",
|
|
47115
|
+
addonId: null,
|
|
47116
|
+
access: "create"
|
|
47117
|
+
},
|
|
45447
47118
|
"pipelineAnalytics.applyDeviceSettingsPatch": {
|
|
45448
47119
|
capName: "pipeline-analytics",
|
|
45449
47120
|
capScope: "device",
|
|
@@ -45492,12 +47163,24 @@ Object.freeze({
|
|
|
45492
47163
|
addonId: null,
|
|
45493
47164
|
access: "view"
|
|
45494
47165
|
},
|
|
47166
|
+
"pipelineAnalytics.createRetrainCollection": {
|
|
47167
|
+
capName: "pipeline-analytics",
|
|
47168
|
+
capScope: "device",
|
|
47169
|
+
addonId: null,
|
|
47170
|
+
access: "create"
|
|
47171
|
+
},
|
|
45495
47172
|
"pipelineAnalytics.deleteDeviceEvents": {
|
|
45496
47173
|
capName: "pipeline-analytics",
|
|
45497
47174
|
capScope: "device",
|
|
45498
47175
|
addonId: null,
|
|
45499
47176
|
access: "delete"
|
|
45500
47177
|
},
|
|
47178
|
+
"pipelineAnalytics.deleteRetrainCollection": {
|
|
47179
|
+
capName: "pipeline-analytics",
|
|
47180
|
+
capScope: "device",
|
|
47181
|
+
addonId: null,
|
|
47182
|
+
access: "delete"
|
|
47183
|
+
},
|
|
45501
47184
|
"pipelineAnalytics.deleteTracks": {
|
|
45502
47185
|
capName: "pipeline-analytics",
|
|
45503
47186
|
capScope: "device",
|
|
@@ -45702,6 +47385,24 @@ Object.freeze({
|
|
|
45702
47385
|
addonId: null,
|
|
45703
47386
|
access: "view"
|
|
45704
47387
|
},
|
|
47388
|
+
"pipelineAnalytics.listRetrainAssistProfiles": {
|
|
47389
|
+
capName: "pipeline-analytics",
|
|
47390
|
+
capScope: "device",
|
|
47391
|
+
addonId: null,
|
|
47392
|
+
access: "view"
|
|
47393
|
+
},
|
|
47394
|
+
"pipelineAnalytics.listRetrainCollectionFrames": {
|
|
47395
|
+
capName: "pipeline-analytics",
|
|
47396
|
+
capScope: "device",
|
|
47397
|
+
addonId: null,
|
|
47398
|
+
access: "view"
|
|
47399
|
+
},
|
|
47400
|
+
"pipelineAnalytics.listRetrainCollections": {
|
|
47401
|
+
capName: "pipeline-analytics",
|
|
47402
|
+
capScope: "device",
|
|
47403
|
+
addonId: null,
|
|
47404
|
+
access: "view"
|
|
47405
|
+
},
|
|
45705
47406
|
"pipelineAnalytics.listRetrainFrames": {
|
|
45706
47407
|
capName: "pipeline-analytics",
|
|
45707
47408
|
capScope: "device",
|
|
@@ -45750,6 +47451,12 @@ Object.freeze({
|
|
|
45750
47451
|
addonId: null,
|
|
45751
47452
|
access: "create"
|
|
45752
47453
|
},
|
|
47454
|
+
"pipelineAnalytics.proposeRetrainAnnotationsWithLlm": {
|
|
47455
|
+
capName: "pipeline-analytics",
|
|
47456
|
+
capScope: "device",
|
|
47457
|
+
addonId: null,
|
|
47458
|
+
access: "create"
|
|
47459
|
+
},
|
|
45753
47460
|
"pipelineAnalytics.pruneEvents": {
|
|
45754
47461
|
capName: "pipeline-analytics",
|
|
45755
47462
|
capScope: "device",
|
|
@@ -45804,6 +47511,18 @@ Object.freeze({
|
|
|
45804
47511
|
addonId: null,
|
|
45805
47512
|
access: "create"
|
|
45806
47513
|
},
|
|
47514
|
+
"pipelineAnalytics.removeRetrainFrameFromCollection": {
|
|
47515
|
+
capName: "pipeline-analytics",
|
|
47516
|
+
capScope: "device",
|
|
47517
|
+
addonId: null,
|
|
47518
|
+
access: "delete"
|
|
47519
|
+
},
|
|
47520
|
+
"pipelineAnalytics.renameRetrainCollection": {
|
|
47521
|
+
capName: "pipeline-analytics",
|
|
47522
|
+
capScope: "device",
|
|
47523
|
+
addonId: null,
|
|
47524
|
+
access: "create"
|
|
47525
|
+
},
|
|
45807
47526
|
"pipelineAnalytics.restageRetrainTrack": {
|
|
45808
47527
|
capName: "pipeline-analytics",
|
|
45809
47528
|
capScope: "device",
|
|
@@ -46092,6 +47811,12 @@ Object.freeze({
|
|
|
46092
47811
|
addonId: null,
|
|
46093
47812
|
access: "view"
|
|
46094
47813
|
},
|
|
47814
|
+
"pipelineOrchestrator.abortNodeBenchmark": {
|
|
47815
|
+
capName: "pipeline-orchestrator",
|
|
47816
|
+
capScope: "system",
|
|
47817
|
+
addonId: null,
|
|
47818
|
+
access: "create"
|
|
47819
|
+
},
|
|
46095
47820
|
"pipelineOrchestrator.applyAutoTune": {
|
|
46096
47821
|
capName: "pipeline-orchestrator",
|
|
46097
47822
|
capScope: "system",
|
|
@@ -46116,6 +47841,12 @@ Object.freeze({
|
|
|
46116
47841
|
addonId: null,
|
|
46117
47842
|
access: "create"
|
|
46118
47843
|
},
|
|
47844
|
+
"pipelineOrchestrator.deleteNodeBenchmarkResult": {
|
|
47845
|
+
capName: "pipeline-orchestrator",
|
|
47846
|
+
capScope: "system",
|
|
47847
|
+
addonId: null,
|
|
47848
|
+
access: "delete"
|
|
47849
|
+
},
|
|
46119
47850
|
"pipelineOrchestrator.getAgentLoad": {
|
|
46120
47851
|
capName: "pipeline-orchestrator",
|
|
46121
47852
|
capScope: "system",
|
|
@@ -46224,6 +47955,24 @@ Object.freeze({
|
|
|
46224
47955
|
addonId: null,
|
|
46225
47956
|
access: "view"
|
|
46226
47957
|
},
|
|
47958
|
+
"pipelineOrchestrator.getNodeBenchmarkCandidates": {
|
|
47959
|
+
capName: "pipeline-orchestrator",
|
|
47960
|
+
capScope: "system",
|
|
47961
|
+
addonId: null,
|
|
47962
|
+
access: "view"
|
|
47963
|
+
},
|
|
47964
|
+
"pipelineOrchestrator.getNodeBenchmarkPreflight": {
|
|
47965
|
+
capName: "pipeline-orchestrator",
|
|
47966
|
+
capScope: "system",
|
|
47967
|
+
addonId: null,
|
|
47968
|
+
access: "view"
|
|
47969
|
+
},
|
|
47970
|
+
"pipelineOrchestrator.getNodeBenchmarkStatus": {
|
|
47971
|
+
capName: "pipeline-orchestrator",
|
|
47972
|
+
capScope: "system",
|
|
47973
|
+
addonId: null,
|
|
47974
|
+
access: "view"
|
|
47975
|
+
},
|
|
46227
47976
|
"pipelineOrchestrator.getNodeInferenceDevices": {
|
|
46228
47977
|
capName: "pipeline-orchestrator",
|
|
46229
47978
|
capScope: "system",
|
|
@@ -46266,6 +48015,12 @@ Object.freeze({
|
|
|
46266
48015
|
addonId: null,
|
|
46267
48016
|
access: "view"
|
|
46268
48017
|
},
|
|
48018
|
+
"pipelineOrchestrator.listNodeBenchmarkResults": {
|
|
48019
|
+
capName: "pipeline-orchestrator",
|
|
48020
|
+
capScope: "system",
|
|
48021
|
+
addonId: null,
|
|
48022
|
+
access: "view"
|
|
48023
|
+
},
|
|
46269
48024
|
"pipelineOrchestrator.pauseForStorageMigration": {
|
|
46270
48025
|
capName: "pipeline-orchestrator",
|
|
46271
48026
|
capScope: "system",
|
|
@@ -46410,6 +48165,12 @@ Object.freeze({
|
|
|
46410
48165
|
addonId: null,
|
|
46411
48166
|
access: "create"
|
|
46412
48167
|
},
|
|
48168
|
+
"pipelineOrchestrator.startNodeBenchmark": {
|
|
48169
|
+
capName: "pipeline-orchestrator",
|
|
48170
|
+
capScope: "system",
|
|
48171
|
+
addonId: null,
|
|
48172
|
+
access: "create"
|
|
48173
|
+
},
|
|
46413
48174
|
"pipelineOrchestrator.suggestShares": {
|
|
46414
48175
|
capName: "pipeline-orchestrator",
|
|
46415
48176
|
capScope: "system",
|
|
@@ -46428,6 +48189,12 @@ Object.freeze({
|
|
|
46428
48189
|
addonId: null,
|
|
46429
48190
|
access: "create"
|
|
46430
48191
|
},
|
|
48192
|
+
"pipelineRunner.abortNodeBench": {
|
|
48193
|
+
capName: "pipeline-runner",
|
|
48194
|
+
capScope: "system",
|
|
48195
|
+
addonId: null,
|
|
48196
|
+
access: "create"
|
|
48197
|
+
},
|
|
46431
48198
|
"pipelineRunner.attachCamera": {
|
|
46432
48199
|
capName: "pipeline-runner",
|
|
46433
48200
|
capScope: "system",
|
|
@@ -46476,6 +48243,12 @@ Object.freeze({
|
|
|
46476
48243
|
addonId: null,
|
|
46477
48244
|
access: "view"
|
|
46478
48245
|
},
|
|
48246
|
+
"pipelineRunner.getNodeBenchStatus": {
|
|
48247
|
+
capName: "pipeline-runner",
|
|
48248
|
+
capScope: "system",
|
|
48249
|
+
addonId: null,
|
|
48250
|
+
access: "view"
|
|
48251
|
+
},
|
|
46479
48252
|
"pipelineRunner.getParkedTrackFrame": {
|
|
46480
48253
|
capName: "pipeline-runner",
|
|
46481
48254
|
capScope: "system",
|
|
@@ -46518,6 +48291,12 @@ Object.freeze({
|
|
|
46518
48291
|
addonId: null,
|
|
46519
48292
|
access: "create"
|
|
46520
48293
|
},
|
|
48294
|
+
"pipelineRunner.startNodeBench": {
|
|
48295
|
+
capName: "pipeline-runner",
|
|
48296
|
+
capScope: "system",
|
|
48297
|
+
addonId: null,
|
|
48298
|
+
access: "create"
|
|
48299
|
+
},
|
|
46521
48300
|
"plateGallery.assignPlate": {
|
|
46522
48301
|
capName: "plate-gallery",
|
|
46523
48302
|
capScope: "system",
|
|
@@ -51447,6 +53226,11 @@ Object.freeze({
|
|
|
51447
53226
|
form: "single",
|
|
51448
53227
|
optional: false
|
|
51449
53228
|
}],
|
|
53229
|
+
"pipelineAnalytics.addRetrainFrameFromRecording": [{
|
|
53230
|
+
name: "deviceId",
|
|
53231
|
+
form: "single",
|
|
53232
|
+
optional: false
|
|
53233
|
+
}],
|
|
51450
53234
|
"pipelineAnalytics.applyDeviceSettingsPatch": [{
|
|
51451
53235
|
name: "deviceId",
|
|
51452
53236
|
form: "single",
|
|
@@ -51637,6 +53421,11 @@ Object.freeze({
|
|
|
51637
53421
|
form: "single",
|
|
51638
53422
|
optional: false
|
|
51639
53423
|
}],
|
|
53424
|
+
"pipelineAnalytics.proposeRetrainAnnotationsWithLlm": [{
|
|
53425
|
+
name: "deviceId",
|
|
53426
|
+
form: "single",
|
|
53427
|
+
optional: false
|
|
53428
|
+
}],
|
|
51640
53429
|
"pipelineAnalytics.pruneEventsBefore": [{
|
|
51641
53430
|
name: "deviceId",
|
|
51642
53431
|
form: "single",
|