@camstack/addon-provider-wyze 0.2.131 → 0.2.133
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/addon.js +2028 -57
- package/dist/addon.mjs +2028 -57
- package/package.json +1 -1
package/dist/addon.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import { getCACertificates, setDefaultCACertificates } from "node:tls";
|
|
|
10
10
|
//#region \0rolldown/runtime.js
|
|
11
11
|
var __require$1 = /* @__PURE__ */ createRequire(import.meta.url);
|
|
12
12
|
//#endregion
|
|
13
|
-
//#region ../types/dist/event-category-
|
|
13
|
+
//#region ../types/dist/event-category-DaIZi00R.mjs
|
|
14
14
|
var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
15
15
|
EventCategory["SystemBoot"] = "system.boot";
|
|
16
16
|
EventCategory["SystemAddonsReady"] = "system.addons-ready";
|
|
@@ -89,6 +89,13 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
|
89
89
|
*/
|
|
90
90
|
EventCategory["AddonLoadFailed"] = "addon.load-failed";
|
|
91
91
|
/**
|
|
92
|
+
* A keychain value was stored or removed (D787). Carries the ref, its
|
|
93
|
+
* owner and the new version — NEVER the value. A process holding the ref
|
|
94
|
+
* drops its cached copy and the owning `BaseAddon` re-resolves its config.
|
|
95
|
+
* Telemetry (D8): a process that misses it still revalidates by version.
|
|
96
|
+
*/
|
|
97
|
+
EventCategory["KeychainChanged"] = "keychain.changed";
|
|
98
|
+
/**
|
|
92
99
|
* Addon recovered from a previous failure. Emitted when an addon
|
|
93
100
|
* transitions from `failed` back to `healthy` (typically via the
|
|
94
101
|
* monitor's auto-retry loop, or after manual `addons.retryLoad`).
|
|
@@ -5381,7 +5388,7 @@ var ZodIssueCode = {
|
|
|
5381
5388
|
var ZodFirstPartyTypeKind;
|
|
5382
5389
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5383
5390
|
//#endregion
|
|
5384
|
-
//#region ../types/dist/sleep-
|
|
5391
|
+
//#region ../types/dist/sleep-DujUvOcb.mjs
|
|
5385
5392
|
/**
|
|
5386
5393
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5387
5394
|
* window to float samples (D455).
|
|
@@ -5460,6 +5467,97 @@ function buildAlawTable() {
|
|
|
5460
5467
|
}
|
|
5461
5468
|
buildUlawTable();
|
|
5462
5469
|
buildAlawTable();
|
|
5470
|
+
/** Is this field's stored value a credential? */
|
|
5471
|
+
function isSecretConfigField(field) {
|
|
5472
|
+
if (field.type === "password") return true;
|
|
5473
|
+
return "secret" in field && field.secret === true;
|
|
5474
|
+
}
|
|
5475
|
+
/**
|
|
5476
|
+
* Is this field's value stored in the KEYCHAIN (D787)? Every secret field is,
|
|
5477
|
+
* by its TYPE, unless it opts out with `storage: 'inline'` — never by its name.
|
|
5478
|
+
*/
|
|
5479
|
+
function isKeychainStoredField(field) {
|
|
5480
|
+
if (!isSecretConfigField(field)) return false;
|
|
5481
|
+
if (field.type === "textarea" && field.isJson === true) return false;
|
|
5482
|
+
return !("storage" in field && field.storage === "inline");
|
|
5483
|
+
}
|
|
5484
|
+
/**
|
|
5485
|
+
* What a settings blob holds where a secret used to be.
|
|
5486
|
+
*
|
|
5487
|
+
* A keychain-stored field never holds its value. It holds a self-describing
|
|
5488
|
+
* MARKER, `{"$secret":"secret://…","v":1}` — an object, never a string, so no
|
|
5489
|
+
* code can mistake it for a credential and no form can send it to a camera as
|
|
5490
|
+
* a password. The empty state is `null` / absent, never `''`.
|
|
5491
|
+
*
|
|
5492
|
+
* The same shapes travel to and from the admin UI:
|
|
5493
|
+
*
|
|
5494
|
+
* - read: `hydrateSchema` hands a secret field a {@link SecretFieldView}
|
|
5495
|
+
* (`{ $secret, v, set: true }`) or `null` — the browser learns whether a
|
|
5496
|
+
* value is set, never the value.
|
|
5497
|
+
* - write: an untouched field submits the view back unchanged (KEEP); a typed
|
|
5498
|
+
* value is a plain non-empty string (CHANGE); the Clear button submits
|
|
5499
|
+
* {@link SECRET_CLEAR} (CLEAR). `''`, `null` and the legacy redaction tokens
|
|
5500
|
+
* are KEEP — an empty string is what a defaults-fallback pushes back, and
|
|
5501
|
+
* treating it as "clear" is how a save destroyed a stored credential before.
|
|
5502
|
+
*
|
|
5503
|
+
* Pure and browser-safe.
|
|
5504
|
+
*/
|
|
5505
|
+
var SECRET_CLEAR = { $secretClear: true };
|
|
5506
|
+
/** The `'***'` token D634 redaction writes for non-admins. */
|
|
5507
|
+
var LEGACY_DEVICE_REDACTION = "***";
|
|
5508
|
+
function isRecord$1(value) {
|
|
5509
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5510
|
+
}
|
|
5511
|
+
function makeSecretMarker(ref) {
|
|
5512
|
+
return {
|
|
5513
|
+
$secret: ref,
|
|
5514
|
+
v: 1
|
|
5515
|
+
};
|
|
5516
|
+
}
|
|
5517
|
+
/** A stored marker: an object whose `$secret` is a non-empty string. */
|
|
5518
|
+
function isSecretMarker(value) {
|
|
5519
|
+
if (!isRecord$1(value)) return false;
|
|
5520
|
+
const ref = value["$secret"];
|
|
5521
|
+
return typeof ref === "string" && ref.length > 0;
|
|
5522
|
+
}
|
|
5523
|
+
function isSecretClear(value) {
|
|
5524
|
+
return isRecord$1(value) && value["$secretClear"] === true;
|
|
5525
|
+
}
|
|
5526
|
+
/**
|
|
5527
|
+
* The UI view of a stored secret field value: a marker becomes "set", inline
|
|
5528
|
+
* plaintext becomes "set (inline)", nothing becomes `null`. A value never
|
|
5529
|
+
* survives this function.
|
|
5530
|
+
*/
|
|
5531
|
+
function toSecretFieldView(stored) {
|
|
5532
|
+
if (isSecretMarker(stored)) return {
|
|
5533
|
+
$secret: stored.$secret,
|
|
5534
|
+
v: 1,
|
|
5535
|
+
set: true
|
|
5536
|
+
};
|
|
5537
|
+
if (typeof stored === "string" && stored.length > 0) return {
|
|
5538
|
+
$secret: null,
|
|
5539
|
+
v: 1,
|
|
5540
|
+
set: true,
|
|
5541
|
+
inline: true
|
|
5542
|
+
};
|
|
5543
|
+
return null;
|
|
5544
|
+
}
|
|
5545
|
+
/**
|
|
5546
|
+
* Classify an incoming value for a secret path. Only a non-empty string that is
|
|
5547
|
+
* not a redaction token sets a value; only {@link SECRET_CLEAR} clears.
|
|
5548
|
+
* Everything else — a marker (ours or anyone's), a UI view, `''`, `null`,
|
|
5549
|
+
* `undefined`, a redaction token, a non-string — keeps what is stored.
|
|
5550
|
+
*/
|
|
5551
|
+
function classifySecretWrite(incoming) {
|
|
5552
|
+
if (isSecretClear(incoming)) return { kind: "clear" };
|
|
5553
|
+
if (typeof incoming !== "string") return { kind: "keep" };
|
|
5554
|
+
if (incoming.length === 0) return { kind: "keep" };
|
|
5555
|
+
if (incoming === "__camstack_redacted__" || incoming === LEGACY_DEVICE_REDACTION) return { kind: "keep" };
|
|
5556
|
+
return {
|
|
5557
|
+
kind: "set",
|
|
5558
|
+
value: incoming
|
|
5559
|
+
};
|
|
5560
|
+
}
|
|
5463
5561
|
Object.fromEntries([
|
|
5464
5562
|
{
|
|
5465
5563
|
id: "overview",
|
|
@@ -5631,33 +5729,19 @@ Object.fromEntries([
|
|
|
5631
5729
|
function isValuelessField(field) {
|
|
5632
5730
|
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";
|
|
5633
5731
|
}
|
|
5634
|
-
|
|
5635
|
-
* Merge a `ConfigUISchema` with a raw `values` record into a
|
|
5636
|
-
* `ConfigUISchemaWithValues`. Used by every `get*Settings` backend endpoint
|
|
5637
|
-
* before returning to the admin UI. Groups are walked recursively.
|
|
5638
|
-
*
|
|
5639
|
-
* For each leaf field:
|
|
5640
|
-
* - structural fields (`separator`, `info`, `button`) pass through unchanged
|
|
5641
|
-
* - other fields get `value = values[key] ?? field.default ?? null`
|
|
5642
|
-
*
|
|
5643
|
-
* Unknown keys in `values` (keys not declared in the schema) are silently
|
|
5644
|
-
* ignored — they don't contribute to the output. Missing keys fall back to
|
|
5645
|
-
* the schema default or `null`. This mirrors the old backend behaviour where
|
|
5646
|
-
* `FormBuilder` rendered `values[key] ?? field.default`.
|
|
5647
|
-
*/
|
|
5648
|
-
function hydrateSchema(schema, values) {
|
|
5732
|
+
function hydrateSchema(schema, values, options = {}) {
|
|
5649
5733
|
return {
|
|
5650
5734
|
...schema.tabs ? { tabs: [...schema.tabs] } : {},
|
|
5651
5735
|
sections: schema.sections.map((section) => ({
|
|
5652
5736
|
...section,
|
|
5653
|
-
fields: section.fields.map((field) => hydrateField(field, values))
|
|
5737
|
+
fields: section.fields.map((field) => hydrateField(field, values, options))
|
|
5654
5738
|
}))
|
|
5655
5739
|
};
|
|
5656
5740
|
}
|
|
5657
|
-
function hydrateField(field, values) {
|
|
5741
|
+
function hydrateField(field, values, options) {
|
|
5658
5742
|
if (isValuelessField(field)) return field;
|
|
5659
5743
|
if (field.type === "group") {
|
|
5660
|
-
const hydratedChildren = field.fields.map((child) => hydrateField(child, values));
|
|
5744
|
+
const hydratedChildren = field.fields.map((child) => hydrateField(child, values, options));
|
|
5661
5745
|
return {
|
|
5662
5746
|
...field,
|
|
5663
5747
|
fields: hydratedChildren
|
|
@@ -5666,7 +5750,7 @@ function hydrateField(field, values) {
|
|
|
5666
5750
|
if (field.type === "sub-tabs") {
|
|
5667
5751
|
const hydratedTabs = field.tabs.map((tab) => ({
|
|
5668
5752
|
...tab,
|
|
5669
|
-
fields: tab.fields.map((child) => hydrateField(child, values))
|
|
5753
|
+
fields: tab.fields.map((child) => hydrateField(child, values, options))
|
|
5670
5754
|
}));
|
|
5671
5755
|
return {
|
|
5672
5756
|
...field,
|
|
@@ -5676,6 +5760,33 @@ function hydrateField(field, values) {
|
|
|
5676
5760
|
const key = field.key;
|
|
5677
5761
|
const storedValue = Object.prototype.hasOwnProperty.call(values, key) ? values[key] : void 0;
|
|
5678
5762
|
const defaultValue = field.default;
|
|
5763
|
+
const asView = (v) => isSecretMarker(v) || options.inlineSecretsAsViews === true && v !== void 0;
|
|
5764
|
+
if (isKeychainStoredField(field) && asView(storedValue)) return {
|
|
5765
|
+
...field,
|
|
5766
|
+
value: toSecretFieldView(storedValue)
|
|
5767
|
+
};
|
|
5768
|
+
if (isKeychainStoredField(field) && options.inlineSecretsAsViews === true) return {
|
|
5769
|
+
...field,
|
|
5770
|
+
value: null
|
|
5771
|
+
};
|
|
5772
|
+
if (field.type === "editable-array" && Array.isArray(storedValue)) {
|
|
5773
|
+
const secretItemKeys = field.itemFields.filter((item) => "key" in item && isKeychainStoredField(item)).map((item) => "key" in item ? item.key : "");
|
|
5774
|
+
if (secretItemKeys.length > 0) {
|
|
5775
|
+
const rows = storedValue.map((row) => {
|
|
5776
|
+
if (row === null || typeof row !== "object" || Array.isArray(row)) return row;
|
|
5777
|
+
const out = { ...row };
|
|
5778
|
+
for (const k of secretItemKeys) {
|
|
5779
|
+
const v = Reflect.get(row, k);
|
|
5780
|
+
if (asView(v)) out[k] = toSecretFieldView(v);
|
|
5781
|
+
}
|
|
5782
|
+
return out;
|
|
5783
|
+
});
|
|
5784
|
+
return {
|
|
5785
|
+
...field,
|
|
5786
|
+
value: rows
|
|
5787
|
+
};
|
|
5788
|
+
}
|
|
5789
|
+
}
|
|
5679
5790
|
if (field.multiple) {
|
|
5680
5791
|
const stored = Array.isArray(storedValue) ? storedValue : storedValue !== void 0 && storedValue !== null ? [storedValue] : [];
|
|
5681
5792
|
const itemFallback = field.multiple.itemDefault !== void 0 ? field.multiple.itemDefault : defaultValue !== void 0 ? defaultValue : typeOf(field) === "string" ? "" : null;
|
|
@@ -5918,6 +6029,431 @@ function projectStore(store, perNodeKeys, nodeId) {
|
|
|
5918
6029
|
}
|
|
5919
6030
|
return out;
|
|
5920
6031
|
}
|
|
6032
|
+
var GLOBAL_SCOPE = { kind: "global" };
|
|
6033
|
+
/** The scope every addon-wide (not per-node, not per-device) setting lives in. */
|
|
6034
|
+
function globalSecretScope() {
|
|
6035
|
+
return GLOBAL_SCOPE;
|
|
6036
|
+
}
|
|
6037
|
+
function encodeSegment(value) {
|
|
6038
|
+
return encodeURIComponent(value);
|
|
6039
|
+
}
|
|
6040
|
+
/**
|
|
6041
|
+
* The field path of a value inside an array item, addressed by the item's id:
|
|
6042
|
+
* `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
|
|
6043
|
+
* `providers[authentik].clientSecret`.
|
|
6044
|
+
*/
|
|
6045
|
+
function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
|
|
6046
|
+
return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
|
|
6047
|
+
}
|
|
6048
|
+
/** A write to a secret path could not be stored in the keychain, so it was refused. */
|
|
6049
|
+
var KeychainWriteRefusedError = class extends Error {
|
|
6050
|
+
fieldPath;
|
|
6051
|
+
constructor(fieldPath, cause) {
|
|
6052
|
+
super(`secret "${fieldPath}" was not saved: the keychain could not store it (${cause instanceof Error ? cause.message : String(cause)}). Nothing was written.`);
|
|
6053
|
+
this.fieldPath = fieldPath;
|
|
6054
|
+
this.name = "KeychainWriteRefusedError";
|
|
6055
|
+
}
|
|
6056
|
+
};
|
|
6057
|
+
var KEEP = { kind: "keep" };
|
|
6058
|
+
function isRecord(value) {
|
|
6059
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6060
|
+
}
|
|
6061
|
+
function defaultMintId() {
|
|
6062
|
+
return globalThis.crypto.randomUUID();
|
|
6063
|
+
}
|
|
6064
|
+
/** Every marker ref anywhere under `value`. */
|
|
6065
|
+
function collectSecretMarkerRefs(value, out = []) {
|
|
6066
|
+
if (isSecretMarker(value)) {
|
|
6067
|
+
out.push(value.$secret);
|
|
6068
|
+
return out;
|
|
6069
|
+
}
|
|
6070
|
+
if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
|
|
6071
|
+
else if (isRecord(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
|
|
6072
|
+
return out;
|
|
6073
|
+
}
|
|
6074
|
+
async function storedValueEquals(secrets, marker, candidate) {
|
|
6075
|
+
const resolved = (await secrets.resolve([marker.$secret]))[marker.$secret];
|
|
6076
|
+
return resolved?.kind === "value" && resolved.value === candidate;
|
|
6077
|
+
}
|
|
6078
|
+
async function writeLeaf(ctx, incoming, stored, fieldPath) {
|
|
6079
|
+
const intent = classifySecretWrite(incoming);
|
|
6080
|
+
const ref = ctx.secrets.ref(ctx.scope, fieldPath);
|
|
6081
|
+
const storedIsOurs = isSecretMarker(stored) && stored.$secret === ref;
|
|
6082
|
+
if (intent.kind === "keep") return KEEP;
|
|
6083
|
+
if (intent.kind === "set" && !ctx.operatorWrite && typeof stored === "string" && stored === intent.value) return KEEP;
|
|
6084
|
+
if (intent.kind === "clear") {
|
|
6085
|
+
if (storedIsOurs) ctx.deletes.push(ref);
|
|
6086
|
+
return {
|
|
6087
|
+
kind: "value",
|
|
6088
|
+
value: null
|
|
6089
|
+
};
|
|
6090
|
+
}
|
|
6091
|
+
if (storedIsOurs && await storedValueEquals(ctx.secrets, stored, intent.value)) return {
|
|
6092
|
+
kind: "value",
|
|
6093
|
+
value: stored
|
|
6094
|
+
};
|
|
6095
|
+
try {
|
|
6096
|
+
await ctx.secrets.put(ref, intent.value);
|
|
6097
|
+
} catch (err) {
|
|
6098
|
+
throw new KeychainWriteRefusedError(fieldPath, err);
|
|
6099
|
+
}
|
|
6100
|
+
return {
|
|
6101
|
+
kind: "value",
|
|
6102
|
+
value: makeSecretMarker(ref)
|
|
6103
|
+
};
|
|
6104
|
+
}
|
|
6105
|
+
/** Apply a member result onto `out`: KEEP restores the stored member, or removes it. */
|
|
6106
|
+
function applyMember(out, key, result, storedParent) {
|
|
6107
|
+
if (result.kind === "value") {
|
|
6108
|
+
out[key] = result.value;
|
|
6109
|
+
return;
|
|
6110
|
+
}
|
|
6111
|
+
if (Object.prototype.hasOwnProperty.call(storedParent, key)) out[key] = storedParent[key];
|
|
6112
|
+
else delete out[key];
|
|
6113
|
+
}
|
|
6114
|
+
async function writeMembers(ctx, children, incoming, stored, pathOf) {
|
|
6115
|
+
const out = { ...incoming };
|
|
6116
|
+
for (const [member, node] of children) applyMember(out, member, await writeNode(ctx, node, incoming[member], stored[member], pathOf(member)), stored);
|
|
6117
|
+
return out;
|
|
6118
|
+
}
|
|
6119
|
+
function rowId(row, idKey) {
|
|
6120
|
+
const raw = row[idKey];
|
|
6121
|
+
if (typeof raw === "string" && raw.length > 0) return raw;
|
|
6122
|
+
if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
|
|
6123
|
+
return null;
|
|
6124
|
+
}
|
|
6125
|
+
async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
6126
|
+
const storedRows = Array.isArray(stored) ? stored.filter(isRecord) : [];
|
|
6127
|
+
if (!Array.isArray(incoming)) {
|
|
6128
|
+
ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
|
|
6129
|
+
return {
|
|
6130
|
+
kind: "value",
|
|
6131
|
+
value: incoming
|
|
6132
|
+
};
|
|
6133
|
+
}
|
|
6134
|
+
const storedById = /* @__PURE__ */ new Map();
|
|
6135
|
+
for (const row of storedRows) {
|
|
6136
|
+
const id = rowId(row, node.idKey);
|
|
6137
|
+
if (id !== null) storedById.set(id, row);
|
|
6138
|
+
}
|
|
6139
|
+
const kept = /* @__PURE__ */ new Set();
|
|
6140
|
+
const rows = [];
|
|
6141
|
+
for (const row of incoming) {
|
|
6142
|
+
if (!isRecord(row)) {
|
|
6143
|
+
rows.push(row);
|
|
6144
|
+
continue;
|
|
6145
|
+
}
|
|
6146
|
+
const id = rowId(row, node.idKey) ?? ctx.mintId();
|
|
6147
|
+
kept.add(id);
|
|
6148
|
+
const withId = {
|
|
6149
|
+
...row,
|
|
6150
|
+
[node.idKey]: row[node.idKey] ?? id
|
|
6151
|
+
};
|
|
6152
|
+
if (rowId(withId, node.idKey) === null) withId[node.idKey] = id;
|
|
6153
|
+
const storedRow = storedById.get(id) ?? {};
|
|
6154
|
+
rows.push(await writeMembers(ctx, node.item, withId, storedRow, (member) => arrayItemFieldPath(fieldPath, id, member)));
|
|
6155
|
+
}
|
|
6156
|
+
for (const [id, row] of storedById) if (!kept.has(id)) ctx.deletes.push(...collectSecretMarkerRefs(row));
|
|
6157
|
+
return {
|
|
6158
|
+
kind: "value",
|
|
6159
|
+
value: rows
|
|
6160
|
+
};
|
|
6161
|
+
}
|
|
6162
|
+
async function writeNode(ctx, node, incoming, stored, fieldPath) {
|
|
6163
|
+
switch (node.kind) {
|
|
6164
|
+
case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
|
|
6165
|
+
case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
|
|
6166
|
+
case "object": {
|
|
6167
|
+
if (!isRecord(incoming)) {
|
|
6168
|
+
if (incoming === void 0) return KEEP;
|
|
6169
|
+
ctx.deletes.push(...collectSecretMarkerRefs(stored));
|
|
6170
|
+
return {
|
|
6171
|
+
kind: "value",
|
|
6172
|
+
value: incoming
|
|
6173
|
+
};
|
|
6174
|
+
}
|
|
6175
|
+
const storedObj = isRecord(stored) ? stored : {};
|
|
6176
|
+
return {
|
|
6177
|
+
kind: "value",
|
|
6178
|
+
value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
|
|
6179
|
+
};
|
|
6180
|
+
}
|
|
6181
|
+
}
|
|
6182
|
+
}
|
|
6183
|
+
/** Split a perNode-scoped key (`key@nodeId`). */
|
|
6184
|
+
function splitNodeKey(key) {
|
|
6185
|
+
const at = key.indexOf("@");
|
|
6186
|
+
return at <= 0 ? {
|
|
6187
|
+
base: key,
|
|
6188
|
+
nodeId: null
|
|
6189
|
+
} : {
|
|
6190
|
+
base: key.slice(0, at),
|
|
6191
|
+
nodeId: key.slice(at + 1)
|
|
6192
|
+
};
|
|
6193
|
+
}
|
|
6194
|
+
/** Rewrite a settings patch so no secret value reaches the blob. See the file doc. */
|
|
6195
|
+
async function transformSecretWrite(input) {
|
|
6196
|
+
const deletes = [];
|
|
6197
|
+
const base = {
|
|
6198
|
+
secrets: input.secrets,
|
|
6199
|
+
mintId: input.mintId ?? defaultMintId,
|
|
6200
|
+
deletes,
|
|
6201
|
+
operatorWrite: input.operatorWrite === true
|
|
6202
|
+
};
|
|
6203
|
+
const out = {};
|
|
6204
|
+
for (const [key, incoming] of Object.entries(input.patch)) {
|
|
6205
|
+
const { base: baseKey, nodeId } = splitNodeKey(key);
|
|
6206
|
+
const node = input.tree.get(baseKey);
|
|
6207
|
+
if (node === void 0) {
|
|
6208
|
+
out[key] = incoming;
|
|
6209
|
+
continue;
|
|
6210
|
+
}
|
|
6211
|
+
const scope = nodeId !== null && nodeId.length > 0 ? {
|
|
6212
|
+
kind: "node",
|
|
6213
|
+
nodeId
|
|
6214
|
+
} : input.scope ?? globalSecretScope();
|
|
6215
|
+
const result = await writeNode({
|
|
6216
|
+
...base,
|
|
6217
|
+
scope
|
|
6218
|
+
}, node, incoming, input.stored[key], baseKey);
|
|
6219
|
+
if (result.kind === "value") out[key] = result.value;
|
|
6220
|
+
}
|
|
6221
|
+
return {
|
|
6222
|
+
patch: out,
|
|
6223
|
+
afterWrite: async () => {
|
|
6224
|
+
if (deletes.length === 0) return { orphaned: [] };
|
|
6225
|
+
try {
|
|
6226
|
+
await input.secrets.delete([...new Set(deletes)]);
|
|
6227
|
+
return { orphaned: [] };
|
|
6228
|
+
} catch {
|
|
6229
|
+
return { orphaned: [...new Set(deletes)] };
|
|
6230
|
+
}
|
|
6231
|
+
}
|
|
6232
|
+
};
|
|
6233
|
+
}
|
|
6234
|
+
/**
|
|
6235
|
+
* Replace every marker in `value` with its keychain value. Returns the SAME
|
|
6236
|
+
* reference when there is no marker (no allocation, no keychain call).
|
|
6237
|
+
*/
|
|
6238
|
+
async function resolveSecretMarkers(value, secrets) {
|
|
6239
|
+
const refs = collectSecretMarkerRefs(value);
|
|
6240
|
+
if (refs.length === 0) return {
|
|
6241
|
+
value,
|
|
6242
|
+
unresolved: []
|
|
6243
|
+
};
|
|
6244
|
+
const answers = await secrets.resolve(refs);
|
|
6245
|
+
const unresolved = [];
|
|
6246
|
+
for (const ref of new Set(refs)) {
|
|
6247
|
+
const answer = answers[ref];
|
|
6248
|
+
if (answer === void 0) unresolved.push({
|
|
6249
|
+
ref,
|
|
6250
|
+
reason: "not-initialized"
|
|
6251
|
+
});
|
|
6252
|
+
else if (answer.kind === "unavailable") unresolved.push({
|
|
6253
|
+
ref,
|
|
6254
|
+
reason: answer.reason
|
|
6255
|
+
});
|
|
6256
|
+
else if (answer.kind === "missing" || answer.kind === "forbidden") unresolved.push({
|
|
6257
|
+
ref,
|
|
6258
|
+
reason: answer.kind
|
|
6259
|
+
});
|
|
6260
|
+
}
|
|
6261
|
+
const substitute = (v) => {
|
|
6262
|
+
if (isSecretMarker(v)) {
|
|
6263
|
+
const answer = answers[v.$secret];
|
|
6264
|
+
return answer?.kind === "value" ? {
|
|
6265
|
+
keep: true,
|
|
6266
|
+
value: answer.value
|
|
6267
|
+
} : {
|
|
6268
|
+
keep: false,
|
|
6269
|
+
value: void 0
|
|
6270
|
+
};
|
|
6271
|
+
}
|
|
6272
|
+
if (Array.isArray(v)) {
|
|
6273
|
+
const items = [];
|
|
6274
|
+
for (const item of v) {
|
|
6275
|
+
const s = substitute(item);
|
|
6276
|
+
if (s.keep) items.push(s.value);
|
|
6277
|
+
}
|
|
6278
|
+
return {
|
|
6279
|
+
keep: true,
|
|
6280
|
+
value: items
|
|
6281
|
+
};
|
|
6282
|
+
}
|
|
6283
|
+
if (isRecord(v)) {
|
|
6284
|
+
const out = {};
|
|
6285
|
+
for (const [k, child] of Object.entries(v)) {
|
|
6286
|
+
const s = substitute(child);
|
|
6287
|
+
if (s.keep) out[k] = s.value;
|
|
6288
|
+
}
|
|
6289
|
+
return {
|
|
6290
|
+
keep: true,
|
|
6291
|
+
value: out
|
|
6292
|
+
};
|
|
6293
|
+
}
|
|
6294
|
+
return {
|
|
6295
|
+
keep: true,
|
|
6296
|
+
value: v
|
|
6297
|
+
};
|
|
6298
|
+
};
|
|
6299
|
+
return {
|
|
6300
|
+
value: substitute(value).value,
|
|
6301
|
+
unresolved
|
|
6302
|
+
};
|
|
6303
|
+
}
|
|
6304
|
+
function touchesTree(tree, patch) {
|
|
6305
|
+
if (tree.size === 0) return false;
|
|
6306
|
+
for (const key of Object.keys(patch)) {
|
|
6307
|
+
const at = key.indexOf("@");
|
|
6308
|
+
if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
|
|
6309
|
+
}
|
|
6310
|
+
return false;
|
|
6311
|
+
}
|
|
6312
|
+
/** The blob as stored now; a failed read REFUSES the write instead of guessing. */
|
|
6313
|
+
async function readStoredAddonBlob(raw) {
|
|
6314
|
+
const threeWay = raw.readAddonStoreResult;
|
|
6315
|
+
if (threeWay === void 0) return raw.readAddonStore();
|
|
6316
|
+
const result = await threeWay.call(raw);
|
|
6317
|
+
if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
|
|
6318
|
+
return result.kind === "missing" ? {} : result.value;
|
|
6319
|
+
}
|
|
6320
|
+
function createSecretAwareSettings(raw, opts) {
|
|
6321
|
+
const chains = /* @__PURE__ */ new Map();
|
|
6322
|
+
const serialize = (key, fn) => {
|
|
6323
|
+
const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
|
|
6324
|
+
const tail = next.catch(() => void 0);
|
|
6325
|
+
chains.set(key, tail);
|
|
6326
|
+
tail.then(() => {
|
|
6327
|
+
if (chains.get(key) === tail) chains.delete(key);
|
|
6328
|
+
});
|
|
6329
|
+
return next;
|
|
6330
|
+
};
|
|
6331
|
+
const write = async (chainKey, tree, scope, patch, readStored, rawWrite) => {
|
|
6332
|
+
if (!touchesTree(tree, patch)) return rawWrite(patch);
|
|
6333
|
+
return serialize(chainKey, async () => {
|
|
6334
|
+
const stored = await readStored();
|
|
6335
|
+
const result = await transformSecretWrite({
|
|
6336
|
+
tree,
|
|
6337
|
+
secrets: opts.secrets,
|
|
6338
|
+
patch,
|
|
6339
|
+
stored,
|
|
6340
|
+
...scope !== void 0 ? { scope } : {},
|
|
6341
|
+
operatorWrite: opts.isOperatorWrite?.() === true
|
|
6342
|
+
});
|
|
6343
|
+
if (Object.keys(result.patch).length > 0) await rawWrite(result.patch);
|
|
6344
|
+
const { orphaned } = await result.afterWrite();
|
|
6345
|
+
if (orphaned.length > 0) opts.onOrphaned(orphaned);
|
|
6346
|
+
});
|
|
6347
|
+
};
|
|
6348
|
+
const wrapped = {
|
|
6349
|
+
writeAddonStore: (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p)),
|
|
6350
|
+
writeDeviceStore: (deviceId, patch) => write(`device:${deviceId}`, opts.deviceTree(), {
|
|
6351
|
+
kind: "device",
|
|
6352
|
+
deviceId
|
|
6353
|
+
}, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p))
|
|
6354
|
+
};
|
|
6355
|
+
return new Proxy(raw, { get(target, prop, receiver) {
|
|
6356
|
+
if (prop === "writeAddonStore") return wrapped.writeAddonStore;
|
|
6357
|
+
if (prop === "writeDeviceStore") return wrapped.writeDeviceStore;
|
|
6358
|
+
const value = Reflect.get(target, prop, receiver);
|
|
6359
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
6360
|
+
} });
|
|
6361
|
+
}
|
|
6362
|
+
/** The context the addon sees: identical, except that its settings writes are secret-aware. */
|
|
6363
|
+
function withSecretAwareSettings(context, opts) {
|
|
6364
|
+
const raw = context.settings;
|
|
6365
|
+
if (raw === void 0) return context;
|
|
6366
|
+
const settings = createSecretAwareSettings(raw, opts);
|
|
6367
|
+
return new Proxy(context, { get(target, prop, receiver) {
|
|
6368
|
+
if (prop === "settings") return settings;
|
|
6369
|
+
return Reflect.get(target, prop, receiver);
|
|
6370
|
+
} });
|
|
6371
|
+
}
|
|
6372
|
+
var LEAF = { kind: "leaf" };
|
|
6373
|
+
var DEFAULT_ITEM_ID_KEY = "id";
|
|
6374
|
+
function collectFields(fields, out) {
|
|
6375
|
+
for (const field of fields) {
|
|
6376
|
+
if (field.type === "group") {
|
|
6377
|
+
collectFields(field.fields, out);
|
|
6378
|
+
continue;
|
|
6379
|
+
}
|
|
6380
|
+
if (field.type === "sub-tabs") {
|
|
6381
|
+
for (const tab of field.tabs) collectFields(tab.fields, out);
|
|
6382
|
+
continue;
|
|
6383
|
+
}
|
|
6384
|
+
if (field.type === "editable-array") {
|
|
6385
|
+
const item = /* @__PURE__ */ new Map();
|
|
6386
|
+
for (const itemField of field.itemFields) if ("key" in itemField && isKeychainStoredField(itemField)) item.set(itemField.key, LEAF);
|
|
6387
|
+
if (item.size > 0) out.set(field.key, {
|
|
6388
|
+
kind: "array",
|
|
6389
|
+
idKey: field.itemIdKey ?? DEFAULT_ITEM_ID_KEY,
|
|
6390
|
+
item
|
|
6391
|
+
});
|
|
6392
|
+
continue;
|
|
6393
|
+
}
|
|
6394
|
+
if (!("key" in field) || typeof field.key !== "string") continue;
|
|
6395
|
+
if (isKeychainStoredField(field)) out.set(field.key, LEAF);
|
|
6396
|
+
}
|
|
6397
|
+
}
|
|
6398
|
+
/** The secret tree a settings schema declares. */
|
|
6399
|
+
function secretTreeFromSchema(schema) {
|
|
6400
|
+
const out = /* @__PURE__ */ new Map();
|
|
6401
|
+
if (schema === null) return out;
|
|
6402
|
+
for (const section of schema.sections) collectFields(section.fields, out);
|
|
6403
|
+
return out;
|
|
6404
|
+
}
|
|
6405
|
+
/** Parse `a.b[id].c` into segments; throws on a malformed path (a declaration bug). */
|
|
6406
|
+
function parseSecretStatePath(path) {
|
|
6407
|
+
const segments = [];
|
|
6408
|
+
for (const raw of path.split(".")) {
|
|
6409
|
+
const m = /^([^[\]]+)(?:\[([^[\]]+)\])?$/.exec(raw);
|
|
6410
|
+
if (m === null || m[1] === void 0) throw new Error(`secretStatePaths: malformed path "${path}"`);
|
|
6411
|
+
segments.push(m[2] !== void 0 ? {
|
|
6412
|
+
key: m[1],
|
|
6413
|
+
idKey: m[2]
|
|
6414
|
+
} : { key: m[1] });
|
|
6415
|
+
}
|
|
6416
|
+
if (segments.length === 0) throw new Error(`secretStatePaths: empty path`);
|
|
6417
|
+
if (segments[segments.length - 1]?.idKey !== void 0) throw new Error(`secretStatePaths: "${path}" ends on an array — name the member that is secret`);
|
|
6418
|
+
return segments;
|
|
6419
|
+
}
|
|
6420
|
+
function insert(into, segments) {
|
|
6421
|
+
const [head, ...rest] = segments;
|
|
6422
|
+
if (head === void 0) return;
|
|
6423
|
+
if (rest.length === 0) {
|
|
6424
|
+
into.set(head.key, LEAF);
|
|
6425
|
+
return;
|
|
6426
|
+
}
|
|
6427
|
+
const existing = into.get(head.key);
|
|
6428
|
+
if (head.idKey !== void 0) {
|
|
6429
|
+
const item = new Map(existing?.kind === "array" ? existing.item : []);
|
|
6430
|
+
insert(item, rest);
|
|
6431
|
+
into.set(head.key, {
|
|
6432
|
+
kind: "array",
|
|
6433
|
+
idKey: head.idKey,
|
|
6434
|
+
item
|
|
6435
|
+
});
|
|
6436
|
+
return;
|
|
6437
|
+
}
|
|
6438
|
+
const children = new Map(existing?.kind === "object" ? existing.children : []);
|
|
6439
|
+
insert(children, rest);
|
|
6440
|
+
into.set(head.key, {
|
|
6441
|
+
kind: "object",
|
|
6442
|
+
children
|
|
6443
|
+
});
|
|
6444
|
+
}
|
|
6445
|
+
/** Add hidden-state paths (`secretStatePaths`) to a schema-derived tree. */
|
|
6446
|
+
function mergeSecretStatePaths(tree, paths) {
|
|
6447
|
+
if (paths.length === 0) return tree;
|
|
6448
|
+
const out = new Map(tree);
|
|
6449
|
+
for (const path of paths) insert(out, parseSecretStatePath(path));
|
|
6450
|
+
return out;
|
|
6451
|
+
}
|
|
6452
|
+
/** First retry of a secret the keychain could not serve; doubles to {@link SECRET_RETRY_MAX_MS}. */
|
|
6453
|
+
var SECRET_RETRY_FIRST_MS = 5e3;
|
|
6454
|
+
var SECRET_RETRY_MAX_MS = 5 * 6e4;
|
|
6455
|
+
/** Coalesces a burst of `keychain.changed` events into one re-resolve. */
|
|
6456
|
+
var SECRET_CHANGE_DEBOUNCE_MS = 250;
|
|
5921
6457
|
/**
|
|
5922
6458
|
* Base class for CamStack addons. Eliminates settings boilerplate:
|
|
5923
6459
|
*
|
|
@@ -5987,6 +6523,25 @@ var BaseAddon = class {
|
|
|
5987
6523
|
settingsStoreReady = false;
|
|
5988
6524
|
/** Default config values. Provided via constructor. */
|
|
5989
6525
|
defaults;
|
|
6526
|
+
/**
|
|
6527
|
+
* Hidden-state paths that hold secrets (D787) — values the addon writes
|
|
6528
|
+
* itself (`updateGlobalSettings`, `state()`) that no form field declares.
|
|
6529
|
+
* Stored in the keychain exactly like a `password` field. Syntax:
|
|
6530
|
+
* `'snapshotSigningKey'`, `'identity.pincode'`, `'tokens[userId].accessToken'`
|
|
6531
|
+
* (`key[<id field>]` addresses array items by id, never by index).
|
|
6532
|
+
*/
|
|
6533
|
+
secretStatePaths = [];
|
|
6534
|
+
_addonSecretTree = null;
|
|
6535
|
+
_deviceSecretTree = null;
|
|
6536
|
+
/** Refs the last resolved config pointed at — a change to one re-resolves. */
|
|
6537
|
+
_configSecretRefs = /* @__PURE__ */ new Set();
|
|
6538
|
+
_unresolvedSecrets = [];
|
|
6539
|
+
_secretRetryTimer = null;
|
|
6540
|
+
_secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
|
|
6541
|
+
_secretChangeTimer = null;
|
|
6542
|
+
_secretChangeUnsub = null;
|
|
6543
|
+
/** >0 while an OPERATOR's settings write is being applied. */
|
|
6544
|
+
_operatorWriteDepth = 0;
|
|
5990
6545
|
constructor(defaults) {
|
|
5991
6546
|
this.defaults = defaults;
|
|
5992
6547
|
this._config = { ...defaults };
|
|
@@ -6022,8 +6577,18 @@ var BaseAddon = class {
|
|
|
6022
6577
|
return this._config;
|
|
6023
6578
|
}
|
|
6024
6579
|
async initialize(context) {
|
|
6025
|
-
|
|
6580
|
+
const secrets = context.secrets;
|
|
6581
|
+
this._ctx = secrets !== void 0 ? withSecretAwareSettings(context, {
|
|
6582
|
+
secrets,
|
|
6583
|
+
addonTree: () => this.addonSecretTree(),
|
|
6584
|
+
deviceTree: () => this.deviceSecretTree(),
|
|
6585
|
+
onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
|
|
6586
|
+
isOperatorWrite: () => this._operatorWriteDepth > 0
|
|
6587
|
+
}) : context;
|
|
6026
6588
|
await this.resolveConfig();
|
|
6589
|
+
if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
|
|
6590
|
+
if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
|
|
6591
|
+
});
|
|
6027
6592
|
const result = await this.onInitialize();
|
|
6028
6593
|
this.emitLifecycle(EventCategory.AddonStarted);
|
|
6029
6594
|
const normalized = normalizeAddonInitResult(result);
|
|
@@ -6056,6 +6621,12 @@ var BaseAddon = class {
|
|
|
6056
6621
|
*/
|
|
6057
6622
|
async onHubReachable() {}
|
|
6058
6623
|
async shutdown() {
|
|
6624
|
+
this._secretChangeUnsub?.();
|
|
6625
|
+
this._secretChangeUnsub = null;
|
|
6626
|
+
if (this._secretRetryTimer !== null) clearTimeout(this._secretRetryTimer);
|
|
6627
|
+
if (this._secretChangeTimer !== null) clearTimeout(this._secretChangeTimer);
|
|
6628
|
+
this._secretRetryTimer = null;
|
|
6629
|
+
this._secretChangeTimer = null;
|
|
6059
6630
|
this.emitLifecycle(EventCategory.AddonStopped);
|
|
6060
6631
|
if (this.autoEmitReadiness) this.emitReadinessForProviders("down");
|
|
6061
6632
|
await this.onShutdown();
|
|
@@ -6134,7 +6705,7 @@ var BaseAddon = class {
|
|
|
6134
6705
|
return hydrateSchema(schema, overlay ? {
|
|
6135
6706
|
...projected,
|
|
6136
6707
|
...overlay
|
|
6137
|
-
} : projected);
|
|
6708
|
+
} : projected, { inlineSecretsAsViews: true });
|
|
6138
6709
|
}
|
|
6139
6710
|
/**
|
|
6140
6711
|
* The integration-level view of this addon's settings: exactly the sections
|
|
@@ -6183,7 +6754,7 @@ var BaseAddon = class {
|
|
|
6183
6754
|
return hydrateSchema({
|
|
6184
6755
|
...schema,
|
|
6185
6756
|
sections
|
|
6186
|
-
}, projected);
|
|
6757
|
+
}, projected, { inlineSecretsAsViews: true });
|
|
6187
6758
|
}
|
|
6188
6759
|
/**
|
|
6189
6760
|
* The raw addon store PROJECTED onto the target node's bare per-node keys:
|
|
@@ -6237,18 +6808,50 @@ var BaseAddon = class {
|
|
|
6237
6808
|
value: result.value[key]
|
|
6238
6809
|
};
|
|
6239
6810
|
}
|
|
6811
|
+
/**
|
|
6812
|
+
* The OPERATOR's write — a settings form or an admin API call, dispatched by
|
|
6813
|
+
* the kernel. Identical to {@link updateGlobalSettings}, except that a secret
|
|
6814
|
+
* the operator sends is stored as sent even when it equals a pre-keychain
|
|
6815
|
+
* inline value: the operator re-entering a password is a change, an addon
|
|
6816
|
+
* writing back what it read is not (D787).
|
|
6817
|
+
*/
|
|
6818
|
+
async updateGlobalSettingsAsOperator(patch, nodeId) {
|
|
6819
|
+
this._operatorWriteDepth++;
|
|
6820
|
+
try {
|
|
6821
|
+
await this.applyGlobalPatch(patch, nodeId);
|
|
6822
|
+
} finally {
|
|
6823
|
+
this._operatorWriteDepth--;
|
|
6824
|
+
}
|
|
6825
|
+
}
|
|
6240
6826
|
async updateGlobalSettings(patch, nodeId) {
|
|
6827
|
+
await this.applyGlobalPatch(patch, nodeId);
|
|
6828
|
+
}
|
|
6829
|
+
/**
|
|
6830
|
+
* REMOVE stored secrets — their keychain values and their markers (D787).
|
|
6831
|
+
*
|
|
6832
|
+
* Writing `''` to a secret field KEEPS what is stored (an empty string is
|
|
6833
|
+
* what a defaults fallback writes back, and it must never destroy a
|
|
6834
|
+
* credential), so code that means "forget this token" says so here. Without
|
|
6835
|
+
* a keychain (an older kernel) it writes `''`, as such code always did.
|
|
6836
|
+
*/
|
|
6837
|
+
async clearSecrets(keys, nodeId) {
|
|
6838
|
+
const tree = this.addonSecretTree();
|
|
6839
|
+
const keychain = this._ctx?.secrets !== void 0;
|
|
6840
|
+
const patch = {};
|
|
6841
|
+
for (const key of keys) patch[key] = keychain && tree.has(key) ? SECRET_CLEAR : "";
|
|
6842
|
+
await this.applyGlobalPatch(patch, nodeId);
|
|
6843
|
+
}
|
|
6844
|
+
async applyGlobalPatch(barePatch, nodeId) {
|
|
6241
6845
|
const keys = this.perNodeKeys();
|
|
6242
6846
|
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
6243
6847
|
const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
6244
|
-
const barePatch = patch;
|
|
6245
6848
|
const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
|
|
6246
6849
|
await this._ctx?.settings?.writeAddonStore(scoped);
|
|
6247
6850
|
if (target !== localNode) return;
|
|
6248
6851
|
await this.resolveConfig();
|
|
6249
6852
|
await this.onConfigChanged();
|
|
6250
6853
|
this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
|
|
6251
|
-
this.maybeAutoRestart(
|
|
6854
|
+
this.maybeAutoRestart(Object.keys(barePatch), this.globalSettingsSchema());
|
|
6252
6855
|
}
|
|
6253
6856
|
/**
|
|
6254
6857
|
* The set of field keys the global settings schema declares `perNode: true`
|
|
@@ -6273,7 +6876,7 @@ var BaseAddon = class {
|
|
|
6273
6876
|
* time to return its response before the addon is torn down and
|
|
6274
6877
|
* re-initialised by `AddonRegistryService.restartAddon`.
|
|
6275
6878
|
*/
|
|
6276
|
-
maybeAutoRestart(
|
|
6879
|
+
maybeAutoRestart(patchKeys, schema) {
|
|
6277
6880
|
if (!schema) return;
|
|
6278
6881
|
const restartKeys = /* @__PURE__ */ new Set();
|
|
6279
6882
|
for (const section of schema.sections) for (const field of section.fields) {
|
|
@@ -6281,13 +6884,13 @@ var BaseAddon = class {
|
|
|
6281
6884
|
if (field.requiresRestart) restartKeys.add(field.key);
|
|
6282
6885
|
}
|
|
6283
6886
|
if (restartKeys.size === 0) return;
|
|
6284
|
-
if (!
|
|
6887
|
+
if (!patchKeys.some((k) => restartKeys.has(k))) return;
|
|
6285
6888
|
const ctx = this._ctx;
|
|
6286
6889
|
if (!ctx) return;
|
|
6287
6890
|
const addonId = ctx.id;
|
|
6288
6891
|
setImmediate(() => {
|
|
6289
6892
|
ctx.api.addons?.restartAddon?.mutate({ addonId }).then(() => {
|
|
6290
|
-
ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields:
|
|
6893
|
+
ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
|
|
6291
6894
|
}).catch((err) => {
|
|
6292
6895
|
ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
6293
6896
|
});
|
|
@@ -6296,7 +6899,7 @@ var BaseAddon = class {
|
|
|
6296
6899
|
async getDeviceSettings(deviceId) {
|
|
6297
6900
|
const schema = this.deviceSettingsSchema();
|
|
6298
6901
|
if (!schema) return { sections: [] };
|
|
6299
|
-
return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {});
|
|
6902
|
+
return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
|
|
6300
6903
|
}
|
|
6301
6904
|
async updateDeviceSettings(deviceId, patch) {
|
|
6302
6905
|
await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
|
|
@@ -6426,7 +7029,7 @@ var BaseAddon = class {
|
|
|
6426
7029
|
* selection at boot (absent scoped key ⇒ the constructor default wins).
|
|
6427
7030
|
*/
|
|
6428
7031
|
async resolveConfig() {
|
|
6429
|
-
const stored = await this.readAddonStoreWithRetry();
|
|
7032
|
+
const stored = await this.resolveStoredSecrets(await this.readAddonStoreWithRetry());
|
|
6430
7033
|
const perNode = this.perNodeKeys();
|
|
6431
7034
|
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
6432
7035
|
const resolved = { ...this.defaults };
|
|
@@ -6451,7 +7054,7 @@ var BaseAddon = class {
|
|
|
6451
7054
|
key,
|
|
6452
7055
|
schema,
|
|
6453
7056
|
fallback,
|
|
6454
|
-
read: () => this.readAddonStoreWithRetry(),
|
|
7057
|
+
read: async () => this.resolveStoredSecrets(await this.readAddonStoreWithRetry()),
|
|
6455
7058
|
write: async (patch) => {
|
|
6456
7059
|
await this._ctx?.settings?.writeAddonStore(patch);
|
|
6457
7060
|
},
|
|
@@ -6468,7 +7071,7 @@ var BaseAddon = class {
|
|
|
6468
7071
|
key,
|
|
6469
7072
|
schema,
|
|
6470
7073
|
fallback,
|
|
6471
|
-
read: async () => await this._ctx?.settings?.readDeviceStore(deviceId) ?? {},
|
|
7074
|
+
read: async () => this.resolveStoredSecrets(await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, false),
|
|
6472
7075
|
write: async (patch) => {
|
|
6473
7076
|
await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
|
|
6474
7077
|
},
|
|
@@ -6480,6 +7083,70 @@ var BaseAddon = class {
|
|
|
6480
7083
|
} })
|
|
6481
7084
|
});
|
|
6482
7085
|
}
|
|
7086
|
+
/** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
|
|
7087
|
+
addonSecretTree() {
|
|
7088
|
+
this._addonSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.globalSettingsSchema()), this.secretStatePaths);
|
|
7089
|
+
return this._addonSecretTree;
|
|
7090
|
+
}
|
|
7091
|
+
deviceSecretTree() {
|
|
7092
|
+
this._deviceSecretTree ??= secretTreeFromSchema(this.deviceSettingsSchema());
|
|
7093
|
+
return this._deviceSecretTree;
|
|
7094
|
+
}
|
|
7095
|
+
/**
|
|
7096
|
+
* Secrets of this addon's stored config that could not be resolved on the
|
|
7097
|
+
* last read, with why. Non-empty means the addon is running WITHOUT them —
|
|
7098
|
+
* an addon whose function needs one should report itself degraded rather
|
|
7099
|
+
* than start on an empty credential.
|
|
7100
|
+
*/
|
|
7101
|
+
get unresolvedSecrets() {
|
|
7102
|
+
return this._unresolvedSecrets;
|
|
7103
|
+
}
|
|
7104
|
+
/**
|
|
7105
|
+
* Substitute every keychain marker in a stored blob with its value. With no
|
|
7106
|
+
* keychain (no `ctx.secrets`) or no marker, the blob comes back unchanged.
|
|
7107
|
+
* An unresolvable value is LEFT OUT (never `''`), logged by ref — never by
|
|
7108
|
+
* value — and, when the cause can pass, retried with backoff. Nothing is
|
|
7109
|
+
* ever written back from here.
|
|
7110
|
+
*/
|
|
7111
|
+
async resolveStoredSecrets(blob, trackForConfig = true) {
|
|
7112
|
+
const secrets = this._ctx?.secrets;
|
|
7113
|
+
if (secrets === void 0) return blob;
|
|
7114
|
+
const refs = collectSecretMarkerRefs(blob);
|
|
7115
|
+
if (trackForConfig) this._configSecretRefs = new Set(refs);
|
|
7116
|
+
if (refs.length === 0) {
|
|
7117
|
+
if (trackForConfig) this._unresolvedSecrets = [];
|
|
7118
|
+
return blob;
|
|
7119
|
+
}
|
|
7120
|
+
const { value, unresolved } = await resolveSecretMarkers(blob, secrets);
|
|
7121
|
+
if (trackForConfig) {
|
|
7122
|
+
this._unresolvedSecrets = unresolved;
|
|
7123
|
+
if (unresolved.length > 0) {
|
|
7124
|
+
this._ctx?.logger?.error?.("secret unavailable — running without it, will retry", { meta: { secrets: unresolved.map((u) => ({
|
|
7125
|
+
ref: u.ref,
|
|
7126
|
+
reason: u.reason
|
|
7127
|
+
})) } });
|
|
7128
|
+
if (unresolved.some((u) => u.reason !== "missing" && u.reason !== "forbidden")) {
|
|
7129
|
+
this.scheduleSecretReresolve(this._secretRetryDelayMs);
|
|
7130
|
+
this._secretRetryDelayMs = Math.min(this._secretRetryDelayMs * 2, SECRET_RETRY_MAX_MS);
|
|
7131
|
+
}
|
|
7132
|
+
} else this._secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
|
|
7133
|
+
}
|
|
7134
|
+
return value;
|
|
7135
|
+
}
|
|
7136
|
+
/** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
|
|
7137
|
+
scheduleSecretReresolve(delayMs) {
|
|
7138
|
+
const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
|
|
7139
|
+
if (this[timerOf] !== null) return;
|
|
7140
|
+
const timer = setTimeout(() => {
|
|
7141
|
+
this[timerOf] = null;
|
|
7142
|
+
if (this._ctx === null) return;
|
|
7143
|
+
this.resolveConfig().then(() => this.onConfigChanged()).catch((err) => {
|
|
7144
|
+
this._ctx?.logger?.error?.("re-resolving secrets failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
7145
|
+
});
|
|
7146
|
+
}, delayMs);
|
|
7147
|
+
timer.unref?.();
|
|
7148
|
+
this[timerOf] = timer;
|
|
7149
|
+
}
|
|
6483
7150
|
/**
|
|
6484
7151
|
* Wrap `ctx.settings.readAddonStore()` with a short retry budget so a
|
|
6485
7152
|
* transient settings-store outage (mid-restart of sqlite-settings, tsx-watch
|
|
@@ -7055,6 +7722,69 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
|
|
|
7055
7722
|
kind: "mutation",
|
|
7056
7723
|
auth: "admin"
|
|
7057
7724
|
}), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
|
|
7725
|
+
function defOf(schema) {
|
|
7726
|
+
return schema._zod?.def ?? {};
|
|
7727
|
+
}
|
|
7728
|
+
function declaredHere(schema) {
|
|
7729
|
+
return globalRegistry.get(schema)?.secret === true;
|
|
7730
|
+
}
|
|
7731
|
+
/** Wrapper kinds whose `innerType` is the field itself. */
|
|
7732
|
+
var WRAPPERS = new Set([
|
|
7733
|
+
"optional",
|
|
7734
|
+
"nullable",
|
|
7735
|
+
"default",
|
|
7736
|
+
"prefault",
|
|
7737
|
+
"catch",
|
|
7738
|
+
"readonly",
|
|
7739
|
+
"nonoptional"
|
|
7740
|
+
]);
|
|
7741
|
+
/**
|
|
7742
|
+
* The schema layers that make up ONE field: the schema itself and every
|
|
7743
|
+
* wrapper below it (optional / default / nullable / readonly / catch), plus
|
|
7744
|
+
* both sides of a pipe (`z.preprocess` puts the real schema on `out`,
|
|
7745
|
+
* `.transform` on `in`).
|
|
7746
|
+
*/
|
|
7747
|
+
function layersOf(schema) {
|
|
7748
|
+
const out = [];
|
|
7749
|
+
const queue = [schema];
|
|
7750
|
+
while (queue.length > 0) {
|
|
7751
|
+
const s = queue.shift();
|
|
7752
|
+
if (!s || out.includes(s)) continue;
|
|
7753
|
+
out.push(s);
|
|
7754
|
+
const def = defOf(s);
|
|
7755
|
+
if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
|
|
7756
|
+
if (def.type === "pipe") {
|
|
7757
|
+
if (def.in) queue.push(def.in);
|
|
7758
|
+
if (def.out) queue.push(def.out);
|
|
7759
|
+
}
|
|
7760
|
+
}
|
|
7761
|
+
return out;
|
|
7762
|
+
}
|
|
7763
|
+
/** True when any layer of this field declares `.meta({ secret: true })`. */
|
|
7764
|
+
function isZodSecret(schema) {
|
|
7765
|
+
return layersOf(schema).some(declaredHere);
|
|
7766
|
+
}
|
|
7767
|
+
/**
|
|
7768
|
+
* Every declared secret path in a config schema: dotted keys, `[]` for "each
|
|
7769
|
+
* element of this array" (`connection.password`, `rows[].token`). A declared
|
|
7770
|
+
* object or array is reported as one path and not descended into — everything
|
|
7771
|
+
* under it is secret.
|
|
7772
|
+
*/
|
|
7773
|
+
function collectZodSecretPaths(schema, prefix = "") {
|
|
7774
|
+
if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
|
|
7775
|
+
const paths = [];
|
|
7776
|
+
for (const layer of layersOf(schema)) {
|
|
7777
|
+
const def = defOf(layer);
|
|
7778
|
+
if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
|
|
7779
|
+
else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
|
|
7780
|
+
else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
|
|
7781
|
+
else if (def.type === "intersection") {
|
|
7782
|
+
if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
|
|
7783
|
+
if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
|
|
7784
|
+
}
|
|
7785
|
+
}
|
|
7786
|
+
return [...new Set(paths)];
|
|
7787
|
+
}
|
|
7058
7788
|
//#endregion
|
|
7059
7789
|
//#region ../types/dist/err-msg-DX6i_MY4.mjs
|
|
7060
7790
|
var DeviceType = /* @__PURE__ */ function(DeviceType) {
|
|
@@ -14105,6 +14835,214 @@ id: union([string(), number()]) }), {
|
|
|
14105
14835
|
kind: "mutation",
|
|
14106
14836
|
auth: "admin"
|
|
14107
14837
|
});
|
|
14838
|
+
/**
|
|
14839
|
+
* `keychain` — the hub's encrypted store of secret values (D787).
|
|
14840
|
+
*
|
|
14841
|
+
* Settings blobs never hold a secret: they hold a marker
|
|
14842
|
+
* `{"$secret":"secret://<owner>/<scope>/<fieldPath>","v":1}` and the value
|
|
14843
|
+
* lives here, AES-256-GCM under a data key that a master key wraps. This cap
|
|
14844
|
+
* is the OWNER's door to its own values: every method is owner-checked
|
|
14845
|
+
* against the CALLER, never against anything the caller claims.
|
|
14846
|
+
*
|
|
14847
|
+
* Who the caller is: the transport stamps `callerAddonId` into the args of a
|
|
14848
|
+
* call that crossed a process (the parent `LocalChildRegistry` from the UDS
|
|
14849
|
+
* connection, the agent from its child's connection carried in
|
|
14850
|
+
* `$hub-cap-fwd`'s envelope). A stamp always overwrites; a wire call with no
|
|
14851
|
+
* stamp has its claim stripped. Only a hub in-process caller may state its own
|
|
14852
|
+
* identity — `ctx.secrets` does that with the addon id closed over. This is
|
|
14853
|
+
* identity against BUGS and misrouting, not against a malicious addon (every
|
|
14854
|
+
* runner is the same OS user): see the threat model in
|
|
14855
|
+
* `docs/design/2026-10-08-secrets-keychain.md`.
|
|
14856
|
+
*
|
|
14857
|
+
* `callerAddonId` is deliberately NOT in any input schema: the tRPC router
|
|
14858
|
+
* parses the input, so a session can never supply it, and the internal mount
|
|
14859
|
+
* floors every method to admin anyway (D240).
|
|
14860
|
+
*
|
|
14861
|
+
* Internal: addons reach it through `ctx.secrets`, never directly.
|
|
14862
|
+
*/
|
|
14863
|
+
/** Why a value cannot be served right now. Never folded into "missing". */
|
|
14864
|
+
var KeychainUnavailableReasonSchema = _enum([
|
|
14865
|
+
"key-missing",
|
|
14866
|
+
"wrong-key",
|
|
14867
|
+
"key-file-unreadable",
|
|
14868
|
+
"store-unavailable",
|
|
14869
|
+
"not-initialized",
|
|
14870
|
+
"decrypt-failed"
|
|
14871
|
+
]);
|
|
14872
|
+
var KeychainStateSchema = discriminatedUnion("state", [object({ state: literal("ready") }), object({
|
|
14873
|
+
state: literal("locked"),
|
|
14874
|
+
reason: KeychainUnavailableReasonSchema
|
|
14875
|
+
})]);
|
|
14876
|
+
var KeychainResolveEntrySchema = discriminatedUnion("kind", [
|
|
14877
|
+
object({
|
|
14878
|
+
kind: literal("value"),
|
|
14879
|
+
value: string(),
|
|
14880
|
+
version: number().int()
|
|
14881
|
+
}),
|
|
14882
|
+
object({ kind: literal("missing") }),
|
|
14883
|
+
object({
|
|
14884
|
+
kind: literal("unavailable"),
|
|
14885
|
+
reason: KeychainUnavailableReasonSchema
|
|
14886
|
+
}),
|
|
14887
|
+
object({ kind: literal("forbidden") })
|
|
14888
|
+
]);
|
|
14889
|
+
var KeychainResolveResultSchema = record(string(), KeychainResolveEntrySchema);
|
|
14890
|
+
/** Metadata of one stored value — never the value. */
|
|
14891
|
+
var KeychainSecretMetaSchema = object({
|
|
14892
|
+
ref: string(),
|
|
14893
|
+
owner: string(),
|
|
14894
|
+
/** Formatted scope (`global`, `node/<id>`, `device/<id>`, …). */
|
|
14895
|
+
scope: string(),
|
|
14896
|
+
fieldPath: string(),
|
|
14897
|
+
version: number().int(),
|
|
14898
|
+
createdAt: number(),
|
|
14899
|
+
updatedAt: number(),
|
|
14900
|
+
/** `addon:<id>` | `user:<id>` | `system`. */
|
|
14901
|
+
updatedBy: string(),
|
|
14902
|
+
/** Coarse — written at most once an hour per ref. `null` = never read. */
|
|
14903
|
+
lastReadAt: number().nullable()
|
|
14904
|
+
});
|
|
14905
|
+
var RefListSchema = array(string().min(1)).max(512);
|
|
14906
|
+
method(object({
|
|
14907
|
+
ref: string().min(1),
|
|
14908
|
+
value: string().min(1)
|
|
14909
|
+
}), object({
|
|
14910
|
+
ref: string(),
|
|
14911
|
+
version: number().int()
|
|
14912
|
+
}), {
|
|
14913
|
+
kind: "mutation",
|
|
14914
|
+
auth: "admin"
|
|
14915
|
+
}), method(object({ refs: RefListSchema }), KeychainResolveResultSchema, { auth: "admin" }), method(object({ refs: RefListSchema }), object({ deleted: number().int() }), {
|
|
14916
|
+
kind: "mutation",
|
|
14917
|
+
auth: "admin"
|
|
14918
|
+
}), method(object({}), array(KeychainSecretMetaSchema).readonly(), { auth: "admin" }), method(object({}), KeychainStateSchema, { auth: "admin" });
|
|
14919
|
+
var KeychainKeySourceSchema = object({
|
|
14920
|
+
kind: _enum([
|
|
14921
|
+
"config-file",
|
|
14922
|
+
"previous-config-file",
|
|
14923
|
+
"platform",
|
|
14924
|
+
"default-file"
|
|
14925
|
+
]),
|
|
14926
|
+
/** File sources only — a path is not a secret. */
|
|
14927
|
+
path: string().optional(),
|
|
14928
|
+
/**
|
|
14929
|
+
* True when a whole-volume backup of the data directory carries this key
|
|
14930
|
+
* next to the database it protects (the default file). The page warns.
|
|
14931
|
+
*/
|
|
14932
|
+
sharesBackupWithDatabase: boolean()
|
|
14933
|
+
});
|
|
14934
|
+
var KeychainStatusSchema = object({
|
|
14935
|
+
keychain: KeychainStateSchema,
|
|
14936
|
+
/** The source of the master key in use; `null` while locked. */
|
|
14937
|
+
keySource: KeychainKeySourceSchema.nullable(),
|
|
14938
|
+
/** The source configured to be primary — differs from `keySource` while a rotation is pending. */
|
|
14939
|
+
configuredSource: KeychainKeySourceSchema,
|
|
14940
|
+
/** Short fingerprint of the master key in use (`HMAC(KEK, label)`, 16 hex). */
|
|
14941
|
+
fingerprint: string().nullable(),
|
|
14942
|
+
activeKeyId: string().nullable(),
|
|
14943
|
+
/**
|
|
14944
|
+
* The keychain unlocked with a NON-primary source: the configured primary
|
|
14945
|
+
* key is not the one that wraps the data key yet. `rotateMasterKey` moves it.
|
|
14946
|
+
*/
|
|
14947
|
+
rotationPending: boolean(),
|
|
14948
|
+
/** Wrapped copies of the data key under a previous master key, kept until purged. */
|
|
14949
|
+
retiredWraps: number().int(),
|
|
14950
|
+
recoveryKeyDownloadedAt: number().nullable(),
|
|
14951
|
+
secretCount: number().int()
|
|
14952
|
+
});
|
|
14953
|
+
/**
|
|
14954
|
+
* Whether a stored value is still pointed at by its owner's settings.
|
|
14955
|
+
* `unknown` is a first-class answer: a scope whose blob could not be read is
|
|
14956
|
+
* never reported as an orphan (and never deleted as one).
|
|
14957
|
+
*/
|
|
14958
|
+
var KeychainSecretUsageSchema = _enum([
|
|
14959
|
+
"in-use",
|
|
14960
|
+
"orphan",
|
|
14961
|
+
"unknown"
|
|
14962
|
+
]);
|
|
14963
|
+
var KeychainAdminSecretSchema = KeychainSecretMetaSchema.extend({ usage: KeychainSecretUsageSchema });
|
|
14964
|
+
var KeychainAuditActionSchema = _enum([
|
|
14965
|
+
"put",
|
|
14966
|
+
"delete",
|
|
14967
|
+
"reveal",
|
|
14968
|
+
"rotate-master-key",
|
|
14969
|
+
"purge-retired-keys",
|
|
14970
|
+
"download-recovery-key",
|
|
14971
|
+
"delete-orphans",
|
|
14972
|
+
"reset",
|
|
14973
|
+
"initialize"
|
|
14974
|
+
]);
|
|
14975
|
+
var KeychainAuditEntrySchema = object({
|
|
14976
|
+
id: string(),
|
|
14977
|
+
at: number(),
|
|
14978
|
+
action: KeychainAuditActionSchema,
|
|
14979
|
+
/** `addon:<id>` | `user:<id>` | `system`. */
|
|
14980
|
+
actor: string(),
|
|
14981
|
+
ref: string().nullable(),
|
|
14982
|
+
detail: string().nullable()
|
|
14983
|
+
});
|
|
14984
|
+
var KEYCHAIN_RESET_CONFIRMATION = "RESET KEYCHAIN";
|
|
14985
|
+
/**
|
|
14986
|
+
* Secrets the HUB itself holds (owner `system`) that no settings form shows:
|
|
14987
|
+
* `jwt-signing-key` — the session signing key (D797). It is always "in use",
|
|
14988
|
+
* never an orphan; it is generated on a fresh hub and replaced only through
|
|
14989
|
+
* {@link keychainAdminCapability.methods.setSystemSecret}.
|
|
14990
|
+
*/
|
|
14991
|
+
var SystemHeldSecretNameSchema = _enum(["jwt-signing-key"]);
|
|
14992
|
+
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({
|
|
14993
|
+
value: string(),
|
|
14994
|
+
version: number().int()
|
|
14995
|
+
}), {
|
|
14996
|
+
kind: "mutation",
|
|
14997
|
+
auth: "admin",
|
|
14998
|
+
caller: "required"
|
|
14999
|
+
}), method(object({
|
|
15000
|
+
name: SystemHeldSecretNameSchema,
|
|
15001
|
+
value: string().min(16)
|
|
15002
|
+
}), object({
|
|
15003
|
+
ref: string(),
|
|
15004
|
+
version: number().int()
|
|
15005
|
+
}), {
|
|
15006
|
+
kind: "mutation",
|
|
15007
|
+
auth: "admin",
|
|
15008
|
+
caller: "required"
|
|
15009
|
+
}), method(object({ refs: array(string().min(1)).max(1e3) }), object({
|
|
15010
|
+
deleted: array(string()).readonly(),
|
|
15011
|
+
kept: array(object({
|
|
15012
|
+
ref: string(),
|
|
15013
|
+
usage: KeychainSecretUsageSchema
|
|
15014
|
+
})).readonly()
|
|
15015
|
+
}), {
|
|
15016
|
+
kind: "mutation",
|
|
15017
|
+
auth: "admin",
|
|
15018
|
+
caller: "required"
|
|
15019
|
+
}), method(object({}), object({
|
|
15020
|
+
fingerprint: string(),
|
|
15021
|
+
keySource: KeychainKeySourceSchema
|
|
15022
|
+
}), {
|
|
15023
|
+
kind: "mutation",
|
|
15024
|
+
auth: "admin",
|
|
15025
|
+
caller: "required"
|
|
15026
|
+
}), method(object({}), object({ purged: number().int() }), {
|
|
15027
|
+
kind: "mutation",
|
|
15028
|
+
auth: "admin",
|
|
15029
|
+
caller: "required"
|
|
15030
|
+
}), method(object({}), object({
|
|
15031
|
+
key: string(),
|
|
15032
|
+
fingerprint: string(),
|
|
15033
|
+
keySource: KeychainKeySourceSchema
|
|
15034
|
+
}), {
|
|
15035
|
+
kind: "mutation",
|
|
15036
|
+
auth: "admin",
|
|
15037
|
+
caller: "required"
|
|
15038
|
+
}), method(object({ confirm: literal(KEYCHAIN_RESET_CONFIRMATION) }), object({
|
|
15039
|
+
archivedCollection: string().nullable(),
|
|
15040
|
+
archived: number().int()
|
|
15041
|
+
}), {
|
|
15042
|
+
kind: "mutation",
|
|
15043
|
+
auth: "admin",
|
|
15044
|
+
caller: "required"
|
|
15045
|
+
});
|
|
14108
15046
|
method(_void(), object({
|
|
14109
15047
|
id: string(),
|
|
14110
15048
|
name: string(),
|
|
@@ -15347,7 +16285,11 @@ var DeviceRegisterPayloadSchema = object({
|
|
|
15347
16285
|
var DeviceRemovePayloadSchema = object({ deviceId: number() });
|
|
15348
16286
|
var DevicePersistConfigPayloadSchema = object({
|
|
15349
16287
|
deviceId: number(),
|
|
15350
|
-
data: record(string(), unknown())
|
|
16288
|
+
data: record(string(), unknown()),
|
|
16289
|
+
/** The paths the device's schema declares secret (D783), when the caller
|
|
16290
|
+
* knows them — those values are kept in the keychain, not the blob (D787).
|
|
16291
|
+
* Absent: the paths the device last reported at `registerDevice` apply. */
|
|
16292
|
+
secretConfigPaths: array(string()).optional()
|
|
15351
16293
|
});
|
|
15352
16294
|
/** What a migration actually did, per switch. `unreachable` is a first-class
|
|
15353
16295
|
* answer: a camera that could not be asked is not a camera that was silenced. */
|
|
@@ -22364,8 +23306,23 @@ var RetrainMacroClassSchema = _enum([
|
|
|
22364
23306
|
]);
|
|
22365
23307
|
/** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
|
|
22366
23308
|
var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
|
|
22367
|
-
/**
|
|
22368
|
-
|
|
23309
|
+
/**
|
|
23310
|
+
* Where a box came from. A machine-sourced box is a DRAFT on the page until
|
|
23311
|
+
* the operator confirms it; once saved it keeps its source as provenance.
|
|
23312
|
+
*
|
|
23313
|
+
* - `operator` — drawn by hand.
|
|
23314
|
+
* - `assist` — proposed by a detector run on the copy (the camera's own
|
|
23315
|
+
* model, or a larger teacher model).
|
|
23316
|
+
* - `pipeline` — the box the live pipeline actually drew on that frame, read
|
|
23317
|
+
* back from the track store (never a re-run).
|
|
23318
|
+
* - `llm` — proposed by a vision-capable LLM profile.
|
|
23319
|
+
*/
|
|
23320
|
+
var RetrainAnnotationSourceSchema = _enum([
|
|
23321
|
+
"operator",
|
|
23322
|
+
"assist",
|
|
23323
|
+
"pipeline",
|
|
23324
|
+
"llm"
|
|
23325
|
+
]);
|
|
22369
23326
|
/** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
|
|
22370
23327
|
var RetrainBboxSchema = object({
|
|
22371
23328
|
x: number(),
|
|
@@ -22383,7 +23340,8 @@ var RetrainBboxSchema = object({
|
|
|
22383
23340
|
*/
|
|
22384
23341
|
var RetrainAnnotationSchema = object({
|
|
22385
23342
|
id: string(),
|
|
22386
|
-
|
|
23343
|
+
/** The frame's track. Absent on a recording still, which has none. */
|
|
23344
|
+
trackId: string().optional(),
|
|
22387
23345
|
deviceId: number(),
|
|
22388
23346
|
/** The COPY in retrain storage — never the source track's media key. */
|
|
22389
23347
|
mediaKey: string(),
|
|
@@ -22432,13 +23390,47 @@ var RetrainFrameCandidateSchema = object({
|
|
|
22432
23390
|
* fail, whatever became of the original. */
|
|
22433
23391
|
copied: boolean()
|
|
22434
23392
|
});
|
|
23393
|
+
/**
|
|
23394
|
+
* One box the live pipeline drew on a copied frame — what a correction starts
|
|
23395
|
+
* from. Derived when the frame is listed, from the track store: the subject
|
|
23396
|
+
* box recorded on the source media row when there is one, else the track
|
|
23397
|
+
* position nearest the frame's capture time. Never stored as an annotation
|
|
23398
|
+
* until the operator confirms it.
|
|
23399
|
+
*/
|
|
23400
|
+
var RetrainPipelineBoxSchema = object({
|
|
23401
|
+
/** Normalised `[0,1]` against the full frame. */
|
|
23402
|
+
bbox: RetrainBboxSchema,
|
|
23403
|
+
macroClass: RetrainMacroClassSchema,
|
|
23404
|
+
label: string().optional(),
|
|
23405
|
+
subLabel: string().optional(),
|
|
23406
|
+
/** The detection score of the position used, when it was recorded. */
|
|
23407
|
+
score: number().optional(),
|
|
23408
|
+
/** The root model that produced the track, when it was recorded. */
|
|
23409
|
+
modelId: string().optional(),
|
|
23410
|
+
trackId: string(),
|
|
23411
|
+
/** `subject-box`: recorded on this very frame. `position`: the track's
|
|
23412
|
+
* position nearest the capture time, `deltaMs` away. */
|
|
23413
|
+
basis: _enum(["subject-box", "position"]),
|
|
23414
|
+
deltaMs: number()
|
|
23415
|
+
});
|
|
23416
|
+
/**
|
|
23417
|
+
* Where a retrain frame came from: a TRACK's stored media (copy-on-select),
|
|
23418
|
+
* or the RECORDING at an instant — the frame a model saw nothing in has no
|
|
23419
|
+
* track at all.
|
|
23420
|
+
*/
|
|
23421
|
+
var RetrainFrameOriginSchema = _enum(["track", "recording"]);
|
|
22435
23422
|
/** A frame the dataset OWNS: bytes copied at selection time. */
|
|
22436
23423
|
var RetrainFrameSchema = object({
|
|
22437
23424
|
frameId: string(),
|
|
22438
23425
|
deviceId: number(),
|
|
22439
|
-
|
|
22440
|
-
/**
|
|
22441
|
-
|
|
23426
|
+
origin: RetrainFrameOriginSchema,
|
|
23427
|
+
/** The track it was copied from. Absent on a recording still. */
|
|
23428
|
+
trackId: string().optional(),
|
|
23429
|
+
/** Provenance only. It may already point at nothing — that is expected.
|
|
23430
|
+
* Absent on a recording still. */
|
|
23431
|
+
sourceMediaId: number().int().optional(),
|
|
23432
|
+
/** A recording still: the playhead instant it was taken at. */
|
|
23433
|
+
epochMs: number().optional(),
|
|
22442
23434
|
sourceKind: MediaFileKindEnum,
|
|
22443
23435
|
sizeBytes: number().int(),
|
|
22444
23436
|
width: number().int(),
|
|
@@ -22449,7 +23441,12 @@ var RetrainFrameSchema = object({
|
|
|
22449
23441
|
/** The operator's "every subject in this frame is boxed". Detector
|
|
22450
23442
|
* evaluation keeps only complete frames: an unboxed subject would count as
|
|
22451
23443
|
* a false positive. */
|
|
22452
|
-
complete: boolean()
|
|
23444
|
+
complete: boolean(),
|
|
23445
|
+
/** The boxes the pipeline drew on this frame. Present on list answers;
|
|
23446
|
+
* empty when nothing the track store holds can be placed on it. */
|
|
23447
|
+
pipelineBoxes: array(RetrainPipelineBoxSchema).readonly().optional(),
|
|
23448
|
+
/** The named collections this frame belongs to. Present on list answers. */
|
|
23449
|
+
collectionIds: array(string()).readonly().optional()
|
|
22453
23450
|
});
|
|
22454
23451
|
/** Why a copy-on-select could not be honoured — named, never a silent skip. */
|
|
22455
23452
|
var RetrainCopyRefusalSchema = _enum([
|
|
@@ -22480,6 +23477,11 @@ var RetrainFrameListSchema = object({
|
|
|
22480
23477
|
var RetrainExportFilterSchema = object({
|
|
22481
23478
|
deviceIds: array(number()).optional(),
|
|
22482
23479
|
frameIds: array(string()).max(2e4).optional(),
|
|
23480
|
+
/** Only frames in at least one of these named collections. */
|
|
23481
|
+
collectionIds: array(string()).max(200).optional(),
|
|
23482
|
+
/** Exactly the frames of this dataset version (and its completeOnly). An
|
|
23483
|
+
* unknown id selects nothing. */
|
|
23484
|
+
datasetVersionId: string().optional(),
|
|
22483
23485
|
batchId: string().optional(),
|
|
22484
23486
|
/** Only frames the operator marked complete (all subjects boxed). */
|
|
22485
23487
|
completeOnly: boolean().optional()
|
|
@@ -22544,6 +23546,170 @@ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
|
|
|
22544
23546
|
reason: string(),
|
|
22545
23547
|
detail: string().optional()
|
|
22546
23548
|
})]);
|
|
23549
|
+
/** A named set over the retrain corpus — membership only, it owns no pixels. */
|
|
23550
|
+
var RetrainCollectionSchema = object({
|
|
23551
|
+
id: string(),
|
|
23552
|
+
name: string(),
|
|
23553
|
+
createdAt: number(),
|
|
23554
|
+
frameCount: number().int()
|
|
23555
|
+
});
|
|
23556
|
+
var RetrainCollectionCreateResultSchema = discriminatedUnion("kind", [object({
|
|
23557
|
+
kind: literal("created"),
|
|
23558
|
+
collection: RetrainCollectionSchema
|
|
23559
|
+
}), object({
|
|
23560
|
+
kind: literal("refused"),
|
|
23561
|
+
reason: _enum(["empty-name", "duplicate-name"])
|
|
23562
|
+
})]);
|
|
23563
|
+
var RetrainCollectionRenameResultSchema = discriminatedUnion("kind", [object({
|
|
23564
|
+
kind: literal("renamed"),
|
|
23565
|
+
collection: RetrainCollectionSchema
|
|
23566
|
+
}), object({
|
|
23567
|
+
kind: literal("refused"),
|
|
23568
|
+
reason: _enum([
|
|
23569
|
+
"empty-name",
|
|
23570
|
+
"duplicate-name",
|
|
23571
|
+
"unknown-collection"
|
|
23572
|
+
])
|
|
23573
|
+
})]);
|
|
23574
|
+
/**
|
|
23575
|
+
* The outcome of adding the frame at a recording instant. Every refusal is
|
|
23576
|
+
* named: `still-unavailable` (not recording, a gap, or an undecodable frame —
|
|
23577
|
+
* `detail` says which), `still-busy` (the recorder is at its decode bound; try
|
|
23578
|
+
* again), `unreadable-image`, `write-failed`, `unknown-collection`.
|
|
23579
|
+
*/
|
|
23580
|
+
var AddRetrainFrameFromRecordingResultSchema = discriminatedUnion("kind", [object({
|
|
23581
|
+
kind: literal("added"),
|
|
23582
|
+
collectionId: string(),
|
|
23583
|
+
frame: RetrainFrameSchema,
|
|
23584
|
+
/** The moment was already in the dataset; nothing was decoded. */
|
|
23585
|
+
reused: boolean()
|
|
23586
|
+
}), object({
|
|
23587
|
+
kind: literal("refused"),
|
|
23588
|
+
reason: _enum([
|
|
23589
|
+
"unknown-collection",
|
|
23590
|
+
"still-unavailable",
|
|
23591
|
+
"still-busy",
|
|
23592
|
+
"unreadable-image",
|
|
23593
|
+
"write-failed"
|
|
23594
|
+
]),
|
|
23595
|
+
detail: string().optional()
|
|
23596
|
+
})]);
|
|
23597
|
+
/** A vision LLM profile the AI assist may use, and where it sends the frame. */
|
|
23598
|
+
var RetrainAssistProfileSchema = object({
|
|
23599
|
+
id: string(),
|
|
23600
|
+
name: string(),
|
|
23601
|
+
model: string(),
|
|
23602
|
+
kind: string(),
|
|
23603
|
+
/** `true` when the frame would leave the house (a cloud vendor, or an
|
|
23604
|
+
* endpoint that is not on the local network). The page confirms each such
|
|
23605
|
+
* run, and the provider refuses one without `allowCloud`. */
|
|
23606
|
+
leavesHouse: boolean()
|
|
23607
|
+
});
|
|
23608
|
+
/** A box the AI assist proposed: a draft, plus the model's own reason. */
|
|
23609
|
+
var RetrainLlmProposalSchema = RetrainAnnotationDraftSchema.extend({ reason: string() });
|
|
23610
|
+
/** What the AI assist said about a box that was already on the canvas. */
|
|
23611
|
+
var RetrainLlmReviewSchema = object({
|
|
23612
|
+
/** The `ref` the page sent the box under. */
|
|
23613
|
+
ref: string(),
|
|
23614
|
+
verdict: _enum([
|
|
23615
|
+
"confirmed",
|
|
23616
|
+
"wrong-class",
|
|
23617
|
+
"not-an-object",
|
|
23618
|
+
"uncertain"
|
|
23619
|
+
]),
|
|
23620
|
+
suggestedClass: RetrainMacroClassSchema.optional(),
|
|
23621
|
+
reason: string()
|
|
23622
|
+
});
|
|
23623
|
+
/**
|
|
23624
|
+
* The AI assist's answer. `proposed` carries drafts (`source: 'llm'`, the
|
|
23625
|
+
* model and its confidence) and reviews; items the model got wrong (a box off
|
|
23626
|
+
* the frame, an unasked class, an unknown ref) are dropped and counted in
|
|
23627
|
+
* `rejected`. A whole answer that is not the schema is `malformed-answer`.
|
|
23628
|
+
*/
|
|
23629
|
+
var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
|
|
23630
|
+
kind: literal("proposed"),
|
|
23631
|
+
profileId: string(),
|
|
23632
|
+
model: string(),
|
|
23633
|
+
/** The frame was sent outside the house for this answer. */
|
|
23634
|
+
leftHouse: boolean(),
|
|
23635
|
+
proposals: array(RetrainLlmProposalSchema).readonly(),
|
|
23636
|
+
reviews: array(RetrainLlmReviewSchema).readonly(),
|
|
23637
|
+
rejected: number().int()
|
|
23638
|
+
}), object({
|
|
23639
|
+
kind: literal("refused"),
|
|
23640
|
+
reason: _enum([
|
|
23641
|
+
"unknown-frame",
|
|
23642
|
+
"unreadable-frame",
|
|
23643
|
+
"unknown-profile",
|
|
23644
|
+
"profile-disabled",
|
|
23645
|
+
"no-vision",
|
|
23646
|
+
"cloud-not-confirmed",
|
|
23647
|
+
"llm-error",
|
|
23648
|
+
"malformed-answer"
|
|
23649
|
+
]),
|
|
23650
|
+
detail: string().optional()
|
|
23651
|
+
})]);
|
|
23652
|
+
/** What a dataset version is cut from. Every field narrows. */
|
|
23653
|
+
var RetrainDatasetSelectionSchema = object({
|
|
23654
|
+
deviceIds: array(number()).readonly().optional(),
|
|
23655
|
+
collectionIds: array(string()).max(200).readonly().optional(),
|
|
23656
|
+
frameIds: array(string()).max(2e4).readonly().optional()
|
|
23657
|
+
});
|
|
23658
|
+
/** The counts a dataset is judged by. */
|
|
23659
|
+
var RetrainDatasetStatsSchema = object({
|
|
23660
|
+
frames: number().int(),
|
|
23661
|
+
completeFrames: number().int(),
|
|
23662
|
+
/** `completeFrames / frames`, 0..1. */
|
|
23663
|
+
completeness: number(),
|
|
23664
|
+
/** Boxes to learn (model errors excluded). */
|
|
23665
|
+
subjects: number().int(),
|
|
23666
|
+
modelErrors: number().int(),
|
|
23667
|
+
/** Complete frames with no subject. */
|
|
23668
|
+
hardNegatives: number().int(),
|
|
23669
|
+
/** Subjects per class × camera × day/night. */
|
|
23670
|
+
cells: array(object({
|
|
23671
|
+
macroClass: string(),
|
|
23672
|
+
deviceId: number(),
|
|
23673
|
+
lighting: _enum([
|
|
23674
|
+
"day",
|
|
23675
|
+
"night",
|
|
23676
|
+
"unknown"
|
|
23677
|
+
]),
|
|
23678
|
+
subjects: number().int(),
|
|
23679
|
+
frames: number().int()
|
|
23680
|
+
})).readonly(),
|
|
23681
|
+
cameras: array(object({
|
|
23682
|
+
deviceId: number(),
|
|
23683
|
+
frames: number().int(),
|
|
23684
|
+
completeFrames: number().int()
|
|
23685
|
+
})).readonly()
|
|
23686
|
+
});
|
|
23687
|
+
/** An immutable dataset version, without its frame list. */
|
|
23688
|
+
var RetrainDatasetVersionSchema = object({
|
|
23689
|
+
id: string(),
|
|
23690
|
+
name: string(),
|
|
23691
|
+
createdAt: number(),
|
|
23692
|
+
selection: RetrainDatasetSelectionSchema,
|
|
23693
|
+
layout: RetrainExportLayoutSchema,
|
|
23694
|
+
completeOnly: boolean(),
|
|
23695
|
+
frameCount: number().int(),
|
|
23696
|
+
/** sha256 of what the frames taught when the version was frozen. */
|
|
23697
|
+
annotationHash: string(),
|
|
23698
|
+
/** The export manifest schema the version was cut under. */
|
|
23699
|
+
manifestSchema: string(),
|
|
23700
|
+
stats: RetrainDatasetStatsSchema
|
|
23701
|
+
});
|
|
23702
|
+
var CreateRetrainDatasetVersionResultSchema = discriminatedUnion("kind", [object({
|
|
23703
|
+
kind: literal("created"),
|
|
23704
|
+
version: RetrainDatasetVersionSchema
|
|
23705
|
+
}), object({
|
|
23706
|
+
kind: literal("refused"),
|
|
23707
|
+
reason: _enum([
|
|
23708
|
+
"empty-name",
|
|
23709
|
+
"duplicate-name",
|
|
23710
|
+
"no-frames"
|
|
23711
|
+
])
|
|
23712
|
+
})]);
|
|
22547
23713
|
/** The outcome of a lifecycle move owned by the retrain page. */
|
|
22548
23714
|
var RetrainTransitionResultSchema = object({
|
|
22549
23715
|
trackId: string(),
|
|
@@ -23261,7 +24427,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
23261
24427
|
auth: "admin"
|
|
23262
24428
|
}), method(object({
|
|
23263
24429
|
deviceId: number(),
|
|
23264
|
-
trackId: string(),
|
|
24430
|
+
trackId: string().optional(),
|
|
23265
24431
|
frameId: string()
|
|
23266
24432
|
}), object({
|
|
23267
24433
|
removed: boolean(),
|
|
@@ -23278,7 +24444,8 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
23278
24444
|
auth: "admin"
|
|
23279
24445
|
}), method(object({
|
|
23280
24446
|
deviceId: number(),
|
|
23281
|
-
|
|
24447
|
+
/** The frame's track, when it has one — checked against the frame. */
|
|
24448
|
+
trackId: string().optional(),
|
|
23282
24449
|
frameId: string(),
|
|
23283
24450
|
subject: RetrainAssistSubjectSchema,
|
|
23284
24451
|
/** Which node runs it. Absent ⇒ wherever an unowned call lands. */
|
|
@@ -23286,12 +24453,16 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
23286
24453
|
}), RetrainAssistResultSchema, {
|
|
23287
24454
|
kind: "mutation",
|
|
23288
24455
|
auth: "admin"
|
|
23289
|
-
}), method(object({
|
|
24456
|
+
}), method(object({
|
|
24457
|
+
trackId: string().optional(),
|
|
24458
|
+
frameIds: array(string()).max(2e3).optional()
|
|
24459
|
+
}), array(RetrainAnnotationSchema).readonly(), {
|
|
23290
24460
|
kind: "query",
|
|
23291
24461
|
auth: "admin"
|
|
23292
24462
|
}), method(object({
|
|
23293
24463
|
deviceId: number(),
|
|
23294
|
-
|
|
24464
|
+
/** The frame's track, when it has one — checked against the frame. */
|
|
24465
|
+
trackId: string().optional(),
|
|
23295
24466
|
frameId: string(),
|
|
23296
24467
|
annotations: array(RetrainAnnotationDraftSchema)
|
|
23297
24468
|
}), array(RetrainAnnotationSchema).readonly(), {
|
|
@@ -23314,7 +24485,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
23314
24485
|
auth: "admin"
|
|
23315
24486
|
}), method(object({
|
|
23316
24487
|
deviceId: number(),
|
|
23317
|
-
trackId: string(),
|
|
24488
|
+
trackId: string().optional(),
|
|
23318
24489
|
frameId: string(),
|
|
23319
24490
|
complete: boolean()
|
|
23320
24491
|
}), RetrainFrameSchema, {
|
|
@@ -23328,6 +24499,104 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
23328
24499
|
kind: "mutation",
|
|
23329
24500
|
auth: "admin",
|
|
23330
24501
|
timeoutMs: 60 * 6e4
|
|
24502
|
+
}), method(object({
|
|
24503
|
+
selection: RetrainDatasetSelectionSchema,
|
|
24504
|
+
completeOnly: boolean().optional()
|
|
24505
|
+
}), RetrainDatasetStatsSchema, {
|
|
24506
|
+
kind: "query",
|
|
24507
|
+
auth: "admin"
|
|
24508
|
+
}), method(object({
|
|
24509
|
+
name: string().max(120),
|
|
24510
|
+
selection: RetrainDatasetSelectionSchema,
|
|
24511
|
+
layout: RetrainExportLayoutSchema,
|
|
24512
|
+
completeOnly: boolean()
|
|
24513
|
+
}), CreateRetrainDatasetVersionResultSchema, {
|
|
24514
|
+
kind: "mutation",
|
|
24515
|
+
auth: "admin",
|
|
24516
|
+
timeoutMs: 12e4
|
|
24517
|
+
}), method(object({}), array(RetrainDatasetVersionSchema).readonly(), {
|
|
24518
|
+
kind: "query",
|
|
24519
|
+
auth: "admin"
|
|
24520
|
+
}), method(object({ id: string() }), object({ deleted: boolean() }), {
|
|
24521
|
+
kind: "mutation",
|
|
24522
|
+
auth: "admin"
|
|
24523
|
+
}), method(object({ id: string() }), object({
|
|
24524
|
+
found: boolean(),
|
|
24525
|
+
annotationHash: string(),
|
|
24526
|
+
matches: boolean(),
|
|
24527
|
+
missingFrames: number().int()
|
|
24528
|
+
}), {
|
|
24529
|
+
kind: "query",
|
|
24530
|
+
auth: "admin",
|
|
24531
|
+
timeoutMs: 12e4
|
|
24532
|
+
}), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
|
|
24533
|
+
kind: "query",
|
|
24534
|
+
auth: "admin"
|
|
24535
|
+
}), method(object({
|
|
24536
|
+
deviceId: number(),
|
|
24537
|
+
trackId: string().optional(),
|
|
24538
|
+
frameId: string(),
|
|
24539
|
+
profileId: string(),
|
|
24540
|
+
classes: array(RetrainMacroClassSchema).min(1),
|
|
24541
|
+
boxes: array(object({
|
|
24542
|
+
ref: string(),
|
|
24543
|
+
bbox: RetrainBboxSchema,
|
|
24544
|
+
macroClass: RetrainMacroClassSchema,
|
|
24545
|
+
label: string().optional()
|
|
24546
|
+
})).max(50),
|
|
24547
|
+
allowCloud: boolean()
|
|
24548
|
+
}), RetrainLlmAssistResultSchema, {
|
|
24549
|
+
kind: "mutation",
|
|
24550
|
+
auth: "admin",
|
|
24551
|
+
timeoutMs: 18e4
|
|
24552
|
+
}), method(object({ name: string().max(120) }), RetrainCollectionCreateResultSchema, {
|
|
24553
|
+
kind: "mutation",
|
|
24554
|
+
auth: "admin"
|
|
24555
|
+
}), method(object({}), array(RetrainCollectionSchema).readonly(), {
|
|
24556
|
+
kind: "query",
|
|
24557
|
+
auth: "admin"
|
|
24558
|
+
}), method(object({
|
|
24559
|
+
id: string(),
|
|
24560
|
+
name: string().max(120)
|
|
24561
|
+
}), RetrainCollectionRenameResultSchema, {
|
|
24562
|
+
kind: "mutation",
|
|
24563
|
+
auth: "admin"
|
|
24564
|
+
}), method(object({ id: string() }), object({
|
|
24565
|
+
deleted: boolean(),
|
|
24566
|
+
removedFrames: number().int()
|
|
24567
|
+
}), {
|
|
24568
|
+
kind: "mutation",
|
|
24569
|
+
auth: "admin"
|
|
24570
|
+
}), method(object({
|
|
24571
|
+
collectionId: string(),
|
|
24572
|
+
deviceId: number(),
|
|
24573
|
+
epochMs: number()
|
|
24574
|
+
}), AddRetrainFrameFromRecordingResultSchema, {
|
|
24575
|
+
kind: "mutation",
|
|
24576
|
+
auth: "admin",
|
|
24577
|
+
timeoutMs: 6e4
|
|
24578
|
+
}), method(object({
|
|
24579
|
+
collectionId: string(),
|
|
24580
|
+
frameIds: array(string()).min(1).max(500)
|
|
24581
|
+
}), object({
|
|
24582
|
+
added: number().int(),
|
|
24583
|
+
alreadyMember: number().int(),
|
|
24584
|
+
unknownFrameIds: array(string()).readonly()
|
|
24585
|
+
}), {
|
|
24586
|
+
kind: "mutation",
|
|
24587
|
+
auth: "admin"
|
|
24588
|
+
}), method(object({
|
|
24589
|
+
collectionId: string(),
|
|
24590
|
+
frameId: string()
|
|
24591
|
+
}), object({
|
|
24592
|
+
removed: boolean(),
|
|
24593
|
+
deletedFrame: boolean()
|
|
24594
|
+
}), {
|
|
24595
|
+
kind: "mutation",
|
|
24596
|
+
auth: "admin"
|
|
24597
|
+
}), method(object({ collectionId: string() }), array(RetrainFrameSchema).readonly(), {
|
|
24598
|
+
kind: "query",
|
|
24599
|
+
auth: "admin"
|
|
23331
24600
|
}), method(object({
|
|
23332
24601
|
/** Which of the three event tables owns the row. */
|
|
23333
24602
|
ownerType: EventOwnerTypeSchema,
|
|
@@ -23951,13 +25220,31 @@ var RecommendationReasonSchema = discriminatedUnion("kind", [
|
|
|
23951
25220
|
object({
|
|
23952
25221
|
kind: literal("no-family-build"),
|
|
23953
25222
|
format: ModelFormatSchema$1
|
|
25223
|
+
}),
|
|
25224
|
+
object({
|
|
25225
|
+
kind: literal("kept-custom-pin"),
|
|
25226
|
+
modelId: string(),
|
|
25227
|
+
deviceKey: string()
|
|
23954
25228
|
})
|
|
23955
25229
|
]);
|
|
25230
|
+
/** Why a device is left exactly as it is, whatever the plan would pick (D786). */
|
|
25231
|
+
var KeptReasonSchema = _enum(["custom-pin"]);
|
|
25232
|
+
/**
|
|
25233
|
+
* Where a choice's latency came from (D791): this node's own benchmark
|
|
25234
|
+
* result, or the hardware-class table. Measured on the node beats the table.
|
|
25235
|
+
*/
|
|
25236
|
+
var LatencySourceSchema = discriminatedUnion("kind", [object({ kind: literal("table") }), object({
|
|
25237
|
+
kind: literal("node-benchmark"),
|
|
25238
|
+
resultId: string(),
|
|
25239
|
+
measuredAtMs: number()
|
|
25240
|
+
})]);
|
|
23956
25241
|
var DeviceModelChoiceSchema = object({
|
|
23957
25242
|
modelId: string(),
|
|
23958
25243
|
p50Ms: number(),
|
|
23959
25244
|
fps: number(),
|
|
23960
25245
|
measured: boolean(),
|
|
25246
|
+
/** Absent on a plan from before D791 — read as the table. */
|
|
25247
|
+
source: LatencySourceSchema.optional(),
|
|
23961
25248
|
/** Parallel sessions at the camera rate with the headroom kept free: ⌊fps × (1 − headroom) / camera fps⌋. */
|
|
23962
25249
|
capacitySessions: number(),
|
|
23963
25250
|
personRecall: number()
|
|
@@ -23968,6 +25255,8 @@ var DeviceRecommendationSchema = object({
|
|
|
23968
25255
|
enabled: boolean(),
|
|
23969
25256
|
available: boolean(),
|
|
23970
25257
|
chosen: DeviceModelChoiceSchema.nullable(),
|
|
25258
|
+
/** Present when the device is kept as is: Apply writes nothing on it. */
|
|
25259
|
+
kept: KeptReasonSchema.optional(),
|
|
23971
25260
|
reasons: array(RecommendationReasonSchema).readonly()
|
|
23972
25261
|
});
|
|
23973
25262
|
var NodeRecommendationSchema = object({
|
|
@@ -24021,6 +25310,17 @@ var AutoTuneWarningSchema = discriminatedUnion("kind", [
|
|
|
24021
25310
|
kind: literal("coral-enabled"),
|
|
24022
25311
|
nodeId: string(),
|
|
24023
25312
|
deviceKey: string()
|
|
25313
|
+
}),
|
|
25314
|
+
object({
|
|
25315
|
+
kind: literal("custom-pin-kept"),
|
|
25316
|
+
nodeId: string(),
|
|
25317
|
+
deviceKey: string().nullable(),
|
|
25318
|
+
deviceId: number().nullable(),
|
|
25319
|
+
modelId: string()
|
|
25320
|
+
}),
|
|
25321
|
+
object({
|
|
25322
|
+
kind: literal("custom-registry-unreadable"),
|
|
25323
|
+
error: string()
|
|
24024
25324
|
})
|
|
24025
25325
|
]);
|
|
24026
25326
|
var AutoTuneOptionsSchema = object({
|
|
@@ -24199,13 +25499,14 @@ var SuggestSharesResultSchema = object({
|
|
|
24199
25499
|
nodes: array(SuggestedNodeShareSchema).readonly()
|
|
24200
25500
|
});
|
|
24201
25501
|
/**
|
|
24202
|
-
* Where the node and device shares come from (D750, D755).
|
|
24203
|
-
* - `
|
|
24204
|
-
*
|
|
24205
|
-
*
|
|
24206
|
-
*
|
|
24207
|
-
*
|
|
24208
|
-
*
|
|
25502
|
+
* Where the node and device shares come from (D750, D755, D791).
|
|
25503
|
+
* - `benchmark` (default since D791) — each node's capacity as its own node
|
|
25504
|
+
* benchmark measured it; a node without fresh results is sized from
|
|
25505
|
+
* `hardware` and says so. Measured on the node beats the table.
|
|
25506
|
+
* - `hardware` — computed from each node's static capacity only (its
|
|
25507
|
+
* accelerators at their Auto tune models, from the latency table).
|
|
25508
|
+
* Both are recomputed whenever a node or device joins, leaves, is switched
|
|
25509
|
+
* on or off, changes model, or a benchmark result is written. No load input.
|
|
24209
25510
|
* - `manual` — the operator's stored sliders.
|
|
24210
25511
|
* Either way a node or device that cannot take sessions gives its share to
|
|
24211
25512
|
* the others in proportion; the stored values are never rewritten for that.
|
|
@@ -24254,6 +25555,362 @@ var EffectiveSharesSchema = object({
|
|
|
24254
25555
|
nodeWeights: record(string(), number()),
|
|
24255
25556
|
deviceWeights: record(string(), record(string(), number()))
|
|
24256
25557
|
});
|
|
25558
|
+
/**
|
|
25559
|
+
* Wire shapes of the node benchmark (D791): the operator's plan, the
|
|
25560
|
+
* preflight the confirmation shows, the run the orchestrator owns, what the
|
|
25561
|
+
* measuring runner reports, and the result rows Auto tune and the automatic
|
|
25562
|
+
* shares read.
|
|
25563
|
+
*
|
|
25564
|
+
* ONE node at a time, owned by the pipeline orchestrator. While a run is
|
|
25565
|
+
* active the cluster is in BENCHMARK MODE for that node: it is not a
|
|
25566
|
+
* detection candidate, camera pins naming it are ignored so its sessions move
|
|
25567
|
+
* elsewhere, and both come back when the mode ends — after a crash or a hub
|
|
25568
|
+
* restart too (a persisted manifest, reconciled against the registry).
|
|
25569
|
+
*
|
|
25570
|
+
* Two measurements, both on the node, driven by its own runner (frames never
|
|
25571
|
+
* cross a process at frame rate, D9):
|
|
25572
|
+
* - `device` — one accelerator × one candidate detector, root only, open
|
|
25573
|
+
* loop: how many streams at the camera rate it carries inside the frame
|
|
25574
|
+
* interval;
|
|
25575
|
+
* - `pipeline` — the chosen detector plus the operator's detail steps
|
|
25576
|
+
* (faces, plates, classifiers, CLIP…), on varied frames from the bench
|
|
25577
|
+
* clip: how many parallel sessions the node carries before latency, drops,
|
|
25578
|
+
* CPU, RAM or the event loop give out.
|
|
25579
|
+
*/
|
|
25580
|
+
/** Defaults and bounds, one place. */
|
|
25581
|
+
var NODE_BENCHMARK_DEFAULTS = {
|
|
25582
|
+
fpsPerStream: 10,
|
|
25583
|
+
budgetMinutes: 45,
|
|
25584
|
+
minBudgetMinutes: 10,
|
|
25585
|
+
maxBudgetMinutes: 120,
|
|
25586
|
+
/** A result older than this no longer beats the table. */
|
|
25587
|
+
staleAfterDays: 30,
|
|
25588
|
+
/** Warm-in per ramp step (not accounted). */
|
|
25589
|
+
settleSec: 5,
|
|
25590
|
+
/** Accounted window per ramp step. */
|
|
25591
|
+
measureSec: 20,
|
|
25592
|
+
/** Longest the drain may take before the run is refused. */
|
|
25593
|
+
drainTimeoutSec: 120,
|
|
25594
|
+
/** Candidate models per device in one run. */
|
|
25595
|
+
maxModelsPerDevice: 6
|
|
25596
|
+
};
|
|
25597
|
+
/** The two measurements a run can make. */
|
|
25598
|
+
var NodeBenchmarkPhaseSchema = _enum(["device", "pipeline"]);
|
|
25599
|
+
var NodeBenchmarkDevicePlanSchema = object({
|
|
25600
|
+
/** `<backend>:<device>` — `openvino:npu`, `coreml:all`, `cpu`. */
|
|
25601
|
+
deviceKey: string().min(1),
|
|
25602
|
+
/**
|
|
25603
|
+
* Root detector candidates for the `device` measurement, in the order
|
|
25604
|
+
* measured. The FIRST is the one the `pipeline` measurement runs.
|
|
25605
|
+
*/
|
|
25606
|
+
modelIds: array(string().min(1)).min(1).max(NODE_BENCHMARK_DEFAULTS.maxModelsPerDevice)
|
|
25607
|
+
});
|
|
25608
|
+
/** What the operator confirmed. */
|
|
25609
|
+
var NodeBenchmarkPlanSchema = object({
|
|
25610
|
+
nodeId: string().min(1),
|
|
25611
|
+
devices: array(NodeBenchmarkDevicePlanSchema).min(1),
|
|
25612
|
+
/** Which measurements run. At least one. */
|
|
25613
|
+
phases: array(NodeBenchmarkPhaseSchema).min(1).default(["device", "pipeline"]),
|
|
25614
|
+
/**
|
|
25615
|
+
* Detail steps (catalog step ids under the root: faces, plates,
|
|
25616
|
+
* classifiers, CLIP…) the `pipeline` measurement enables. The root
|
|
25617
|
+
* detector always runs.
|
|
25618
|
+
*/
|
|
25619
|
+
steps: array(string().min(1)).default([]),
|
|
25620
|
+
/** Offered rate of one stream / session. */
|
|
25621
|
+
fpsPerStream: number().int().min(1).max(30).default(NODE_BENCHMARK_DEFAULTS.fpsPerStream),
|
|
25622
|
+
/** Hard deadline: the mode ends and the cluster is restored when it passes. */
|
|
25623
|
+
budgetMinutes: number().int().min(NODE_BENCHMARK_DEFAULTS.minBudgetMinutes).max(NODE_BENCHMARK_DEFAULTS.maxBudgetMinutes).default(NODE_BENCHMARK_DEFAULTS.budgetMinutes),
|
|
25624
|
+
/** Keep the models the run downloaded (default: delete what was not installed before). */
|
|
25625
|
+
keepDownloadedModels: boolean().default(false),
|
|
25626
|
+
/** Start although the other nodes' capacity does not cover the sessions running now. */
|
|
25627
|
+
acceptInsufficientHeadroom: boolean().default(false)
|
|
25628
|
+
});
|
|
25629
|
+
var NodeBenchmarkRefusalSchema = object({
|
|
25630
|
+
kind: _enum([
|
|
25631
|
+
"benchmark-active",
|
|
25632
|
+
"node-offline",
|
|
25633
|
+
"unknown-device",
|
|
25634
|
+
"no-phase",
|
|
25635
|
+
"insufficient-headroom"
|
|
25636
|
+
]),
|
|
25637
|
+
detail: string(),
|
|
25638
|
+
overridable: boolean()
|
|
25639
|
+
});
|
|
25640
|
+
/** A camera whose detection leaves the node for the run. */
|
|
25641
|
+
var NodeBenchmarkMovingCameraSchema = object({
|
|
25642
|
+
deviceId: number(),
|
|
25643
|
+
/** Placed on the node now (a standing attach or a running session). */
|
|
25644
|
+
placedOnNode: boolean(),
|
|
25645
|
+
/** A node pin naming this node, ignored for the run. */
|
|
25646
|
+
pinnedToNode: boolean()
|
|
25647
|
+
});
|
|
25648
|
+
/** A camera that cannot leave: no other node can obtain its frames. */
|
|
25649
|
+
var NodeBenchmarkStayingCameraSchema = object({
|
|
25650
|
+
deviceId: number(),
|
|
25651
|
+
reason: literal("only-frame-source")
|
|
25652
|
+
});
|
|
25653
|
+
var NodeBenchmarkPreflightSchema = object({
|
|
25654
|
+
nodeId: string(),
|
|
25655
|
+
online: boolean(),
|
|
25656
|
+
moving: array(NodeBenchmarkMovingCameraSchema).readonly(),
|
|
25657
|
+
/** Keep running on the node during the run; the result is flagged contaminated. */
|
|
25658
|
+
staying: array(NodeBenchmarkStayingCameraSchema).readonly(),
|
|
25659
|
+
estimatedDurationMs: number(),
|
|
25660
|
+
/** The run ends and the cluster is restored at the latest after this long. */
|
|
25661
|
+
budgetMs: number(),
|
|
25662
|
+
phases: array(NodeBenchmarkPhaseSchema).readonly(),
|
|
25663
|
+
steps: array(string()).readonly(),
|
|
25664
|
+
devices: array(NodeBenchmarkDevicePlanSchema).readonly(),
|
|
25665
|
+
/** Parallel sessions the cluster runs now, and what the other nodes can carry. */
|
|
25666
|
+
headroom: object({
|
|
25667
|
+
sessionsNow: number(),
|
|
25668
|
+
otherNodesCapacitySessions: number().nullable()
|
|
25669
|
+
}),
|
|
25670
|
+
refusals: array(NodeBenchmarkRefusalSchema).readonly(),
|
|
25671
|
+
canStart: boolean()
|
|
25672
|
+
});
|
|
25673
|
+
/** Where the measuring runner is. */
|
|
25674
|
+
var NodeBenchProgressSchema = object({
|
|
25675
|
+
phase: _enum([
|
|
25676
|
+
"preparing",
|
|
25677
|
+
"device",
|
|
25678
|
+
"pipeline",
|
|
25679
|
+
"cleanup"
|
|
25680
|
+
]),
|
|
25681
|
+
deviceKey: string().nullable(),
|
|
25682
|
+
modelId: string().nullable(),
|
|
25683
|
+
/** Streams (device) or sessions (pipeline) of the step running now. */
|
|
25684
|
+
load: number().nullable(),
|
|
25685
|
+
cellsDone: number(),
|
|
25686
|
+
cellsTotal: number(),
|
|
25687
|
+
message: string()
|
|
25688
|
+
});
|
|
25689
|
+
/** What limited a ramp. `none` = the ramp ran out of steps still passing. */
|
|
25690
|
+
var NodeBenchLimitSchema = _enum([
|
|
25691
|
+
"p95",
|
|
25692
|
+
"drops",
|
|
25693
|
+
"errors",
|
|
25694
|
+
"stall",
|
|
25695
|
+
"cpu",
|
|
25696
|
+
"ram",
|
|
25697
|
+
"none"
|
|
25698
|
+
]);
|
|
25699
|
+
var NodeBenchRampStepSchema = object({
|
|
25700
|
+
load: number(),
|
|
25701
|
+
pass: boolean(),
|
|
25702
|
+
p95Ms: number(),
|
|
25703
|
+
dropRatio: number(),
|
|
25704
|
+
/** Completed frames per second over the accounted window. */
|
|
25705
|
+
fps: number(),
|
|
25706
|
+
cpuPct: number().nullable(),
|
|
25707
|
+
ramFreePct: number().nullable(),
|
|
25708
|
+
failReasons: array(string()).readonly()
|
|
25709
|
+
});
|
|
25710
|
+
var NodeBenchCellSchema = discriminatedUnion("phase", [object({
|
|
25711
|
+
phase: literal("device"),
|
|
25712
|
+
deviceKey: string(),
|
|
25713
|
+
modelId: string(),
|
|
25714
|
+
/** Single-stream latency (the K = 1 step). */
|
|
25715
|
+
p50Ms: number(),
|
|
25716
|
+
p95Ms: number(),
|
|
25717
|
+
p99Ms: number(),
|
|
25718
|
+
/** Frames per second sustained at the last passing step. */
|
|
25719
|
+
fps: number(),
|
|
25720
|
+
/** Streams at the camera rate the device carried inside the frame interval; 0 = not even one. */
|
|
25721
|
+
kMax: number(),
|
|
25722
|
+
limitedBy: NodeBenchLimitSchema,
|
|
25723
|
+
/** First call (model load + warm-up). */
|
|
25724
|
+
warmupMs: number(),
|
|
25725
|
+
ramp: array(NodeBenchRampStepSchema).readonly()
|
|
25726
|
+
}), object({
|
|
25727
|
+
phase: literal("pipeline"),
|
|
25728
|
+
deviceKey: string(),
|
|
25729
|
+
modelId: string(),
|
|
25730
|
+
steps: array(string()).readonly(),
|
|
25731
|
+
/** Parallel sessions at the camera rate the node carried; 0 = not even one. */
|
|
25732
|
+
maxSessions: number(),
|
|
25733
|
+
limitedBy: NodeBenchLimitSchema,
|
|
25734
|
+
/** Detail steps that produced at least one result on the clip — a step that never fired measured nothing. */
|
|
25735
|
+
stepsFired: array(string()).readonly(),
|
|
25736
|
+
warmupMs: number(),
|
|
25737
|
+
ramp: array(NodeBenchRampStepSchema).readonly()
|
|
25738
|
+
})]);
|
|
25739
|
+
/**
|
|
25740
|
+
* What a result was measured ON. A result whose fingerprint no longer matches
|
|
25741
|
+
* the node no longer beats the table.
|
|
25742
|
+
*/
|
|
25743
|
+
var NodeBenchFingerprintSchema = object({
|
|
25744
|
+
pipelineVersion: string().nullable(),
|
|
25745
|
+
cpuModel: string().nullable(),
|
|
25746
|
+
ramGb: number().nullable(),
|
|
25747
|
+
os: string().nullable(),
|
|
25748
|
+
/** Per device: the pool the cells ran on (runtime + tuning). */
|
|
25749
|
+
pools: record(string(), object({
|
|
25750
|
+
runtime: string(),
|
|
25751
|
+
numWorkers: number(),
|
|
25752
|
+
concurrency: number(),
|
|
25753
|
+
batchMode: string()
|
|
25754
|
+
})).default({})
|
|
25755
|
+
});
|
|
25756
|
+
/** The frames the run used. */
|
|
25757
|
+
var NodeBenchClipSchema = object({
|
|
25758
|
+
/** `camstack-bench-v1` or `reference-images` (the fallback when the clip is not reachable). */
|
|
25759
|
+
id: string(),
|
|
25760
|
+
revision: string().nullable(),
|
|
25761
|
+
frames: number(),
|
|
25762
|
+
width: number(),
|
|
25763
|
+
height: number()
|
|
25764
|
+
});
|
|
25765
|
+
var NodeBenchRunnerInputSchema = object({
|
|
25766
|
+
runId: string().min(1),
|
|
25767
|
+
devices: array(NodeBenchmarkDevicePlanSchema).min(1),
|
|
25768
|
+
phases: array(NodeBenchmarkPhaseSchema).min(1),
|
|
25769
|
+
/** The full detail step tree root for the `pipeline` measurement is built on the node from these ids. */
|
|
25770
|
+
steps: array(string()).default([]),
|
|
25771
|
+
fpsPerStream: number().int().min(1).max(30),
|
|
25772
|
+
/** The runner stops on its own past this instant, whatever the hub does. */
|
|
25773
|
+
deadlineAtMs: number(),
|
|
25774
|
+
settleSec: number().min(0).max(60).default(NODE_BENCHMARK_DEFAULTS.settleSec),
|
|
25775
|
+
measureSec: number().min(2).max(300).default(NODE_BENCHMARK_DEFAULTS.measureSec),
|
|
25776
|
+
keepDownloadedModels: boolean().default(false)
|
|
25777
|
+
});
|
|
25778
|
+
var NodeBenchRunnerStateSchema = _enum([
|
|
25779
|
+
"running",
|
|
25780
|
+
"done",
|
|
25781
|
+
"failed",
|
|
25782
|
+
"aborted"
|
|
25783
|
+
]);
|
|
25784
|
+
var NodeBenchRunnerStatusSchema = object({
|
|
25785
|
+
runId: string(),
|
|
25786
|
+
nodeId: string(),
|
|
25787
|
+
state: NodeBenchRunnerStateSchema,
|
|
25788
|
+
progress: NodeBenchProgressSchema.nullable(),
|
|
25789
|
+
/** Every finished cell so far — a run stopped half way keeps what it measured. */
|
|
25790
|
+
cells: array(NodeBenchCellSchema).readonly(),
|
|
25791
|
+
fingerprint: NodeBenchFingerprintSchema.nullable(),
|
|
25792
|
+
clip: NodeBenchClipSchema.nullable(),
|
|
25793
|
+
/** Cameras seen running on the node during the run (they share its pools). */
|
|
25794
|
+
activeCameraIds: array(number()).readonly(),
|
|
25795
|
+
/** Models the run downloaded and then deleted (not installed before). */
|
|
25796
|
+
deletedModels: array(string()).readonly(),
|
|
25797
|
+
error: string().nullable(),
|
|
25798
|
+
startedAtMs: number(),
|
|
25799
|
+
finishedAtMs: number().nullable()
|
|
25800
|
+
});
|
|
25801
|
+
var NodeBenchmarkStateSchema = _enum([
|
|
25802
|
+
"draining",
|
|
25803
|
+
"measuring",
|
|
25804
|
+
"restoring",
|
|
25805
|
+
"done",
|
|
25806
|
+
"failed",
|
|
25807
|
+
"aborted"
|
|
25808
|
+
]);
|
|
25809
|
+
/** Why a run ended. */
|
|
25810
|
+
var NodeBenchmarkEndReasonSchema = _enum([
|
|
25811
|
+
"completed",
|
|
25812
|
+
"operator-abort",
|
|
25813
|
+
"deadline",
|
|
25814
|
+
"node-lost",
|
|
25815
|
+
"runner-lost",
|
|
25816
|
+
"hub-restart",
|
|
25817
|
+
"drain-timeout",
|
|
25818
|
+
"failed"
|
|
25819
|
+
]);
|
|
25820
|
+
var NodeBenchmarkRunSchema = object({
|
|
25821
|
+
runId: string(),
|
|
25822
|
+
nodeId: string(),
|
|
25823
|
+
state: NodeBenchmarkStateSchema,
|
|
25824
|
+
plan: NodeBenchmarkPlanSchema,
|
|
25825
|
+
startedAtMs: number(),
|
|
25826
|
+
deadlineAtMs: number(),
|
|
25827
|
+
finishedAtMs: number().nullable(),
|
|
25828
|
+
endReason: NodeBenchmarkEndReasonSchema.nullable(),
|
|
25829
|
+
error: string().nullable(),
|
|
25830
|
+
/** Cameras moved off the node for the run. */
|
|
25831
|
+
moved: array(number()).readonly(),
|
|
25832
|
+
/** Cameras that stayed (their only frame source is the node). */
|
|
25833
|
+
staying: array(number()).readonly(),
|
|
25834
|
+
/** Something else ran on the node's pools during the run. */
|
|
25835
|
+
contaminated: boolean(),
|
|
25836
|
+
progress: NodeBenchProgressSchema.nullable(),
|
|
25837
|
+
resultIds: array(string()).readonly()
|
|
25838
|
+
});
|
|
25839
|
+
/** `getNodeBenchmarkStatus`: the active run (or the last one), and whether benchmark mode is on. */
|
|
25840
|
+
var NodeBenchmarkStatusSchema = object({
|
|
25841
|
+
/** The node the cluster is in benchmark mode for; null = none. */
|
|
25842
|
+
modeNodeId: string().nullable(),
|
|
25843
|
+
run: NodeBenchmarkRunSchema.nullable()
|
|
25844
|
+
});
|
|
25845
|
+
/**
|
|
25846
|
+
* One stored measurement — the only authority Auto tune and the automatic
|
|
25847
|
+
* shares read measured capacity from. Written by the orchestrator when a run
|
|
25848
|
+
* ends, never by anyone else.
|
|
25849
|
+
*/
|
|
25850
|
+
var NodeBenchmarkResultSchema = object({
|
|
25851
|
+
id: string(),
|
|
25852
|
+
runId: string(),
|
|
25853
|
+
nodeId: string(),
|
|
25854
|
+
cell: NodeBenchCellSchema,
|
|
25855
|
+
fpsPerStream: number(),
|
|
25856
|
+
fingerprint: NodeBenchFingerprintSchema.nullable(),
|
|
25857
|
+
clip: NodeBenchClipSchema.nullable(),
|
|
25858
|
+
/** Other work shared the node's pools (a camera that could not move, or the hub's own duties). */
|
|
25859
|
+
contaminated: boolean(),
|
|
25860
|
+
stayingCameras: array(number()).readonly(),
|
|
25861
|
+
/** The run ended early; the cell itself completed. */
|
|
25862
|
+
partialRun: boolean(),
|
|
25863
|
+
measuredAtMs: number()
|
|
25864
|
+
});
|
|
25865
|
+
var ListNodeBenchmarkResultsInputSchema = object({
|
|
25866
|
+
nodeId: string().optional(),
|
|
25867
|
+
deviceKey: string().optional()
|
|
25868
|
+
});
|
|
25869
|
+
/** A result with its standing today: does it still beat the table? */
|
|
25870
|
+
var NodeBenchmarkResultViewSchema = NodeBenchmarkResultSchema.extend({
|
|
25871
|
+
/** `fresh` beats the table; `stale` falls back to it; `superseded` = a newer row covers the same cell. */
|
|
25872
|
+
standing: _enum([
|
|
25873
|
+
"fresh",
|
|
25874
|
+
"stale",
|
|
25875
|
+
"superseded"
|
|
25876
|
+
]),
|
|
25877
|
+
staleWhy: _enum([
|
|
25878
|
+
"age",
|
|
25879
|
+
"runtime",
|
|
25880
|
+
"pool-tuning"
|
|
25881
|
+
]).nullable()
|
|
25882
|
+
});
|
|
25883
|
+
object({
|
|
25884
|
+
runId: string(),
|
|
25885
|
+
nodeId: string(),
|
|
25886
|
+
startedAtMs: number(),
|
|
25887
|
+
deadlineAtMs: number(),
|
|
25888
|
+
plan: NodeBenchmarkPlanSchema,
|
|
25889
|
+
moved: array(number()).readonly(),
|
|
25890
|
+
staying: array(number()).readonly()
|
|
25891
|
+
});
|
|
25892
|
+
/** Candidate detectors per device, for the plan editor. */
|
|
25893
|
+
var NodeBenchmarkCandidatesSchema = object({
|
|
25894
|
+
nodeId: string(),
|
|
25895
|
+
reachable: boolean(),
|
|
25896
|
+
devices: array(object({
|
|
25897
|
+
deviceKey: string(),
|
|
25898
|
+
enabled: boolean(),
|
|
25899
|
+
available: boolean(),
|
|
25900
|
+
/** Ordered: what Auto tune would pick first, then the rest of the family by accuracy. */
|
|
25901
|
+
suggested: array(string()).readonly(),
|
|
25902
|
+
/** Every root detector the device has a build for. */
|
|
25903
|
+
all: array(string()).readonly(),
|
|
25904
|
+
/** The model the device runs now, when pinned. */
|
|
25905
|
+
currentModelId: string().nullable()
|
|
25906
|
+
})).readonly(),
|
|
25907
|
+
/** Detail steps the node's catalog offers under the root (for the `pipeline` measurement). */
|
|
25908
|
+
steps: array(object({
|
|
25909
|
+
id: string(),
|
|
25910
|
+
name: string(),
|
|
25911
|
+
slot: string()
|
|
25912
|
+
})).readonly()
|
|
25913
|
+
});
|
|
24257
25914
|
object({
|
|
24258
25915
|
activeCameras: number(),
|
|
24259
25916
|
throttledCameras: number(),
|
|
@@ -25382,7 +27039,16 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
|
|
|
25382
27039
|
}), ParkedTrackFrameSchema.nullable()), method(object({
|
|
25383
27040
|
deviceId: number(),
|
|
25384
27041
|
trackId: string()
|
|
25385
|
-
}), object({ released: number().int().nonnegative() }), { kind: "mutation" })
|
|
27042
|
+
}), object({ released: number().int().nonnegative() }), { kind: "mutation" }), method(NodeBenchRunnerInputSchema, object({
|
|
27043
|
+
accepted: literal(true),
|
|
27044
|
+
runId: string()
|
|
27045
|
+
}), {
|
|
27046
|
+
kind: "mutation",
|
|
27047
|
+
auth: "admin"
|
|
27048
|
+
}), method(object({ runId: string() }), NodeBenchRunnerStatusSchema.nullable(), { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
|
|
27049
|
+
kind: "mutation",
|
|
27050
|
+
auth: "admin"
|
|
27051
|
+
});
|
|
25386
27052
|
var CameraPipelineConfigSchema = object({
|
|
25387
27053
|
engine: PipelineEngineChoiceSchema.optional(),
|
|
25388
27054
|
steps: array(PipelineStepInputSchema).readonly(),
|
|
@@ -26021,6 +27687,21 @@ method(object({
|
|
|
26021
27687
|
}), method(PlacementStatsInputSchema, PlacementStatsSchema, { auth: "admin" }), method(SuggestSharesInputSchema, SuggestSharesResultSchema, { auth: "admin" }), method(_void(), EffectiveSharesSchema, { auth: "admin" }), method(SetShareSourceInputSchema, object({ success: literal(true) }), {
|
|
26022
27688
|
kind: "mutation",
|
|
26023
27689
|
auth: "admin"
|
|
27690
|
+
}), method(NodeBenchmarkPlanSchema, NodeBenchmarkPreflightSchema, { auth: "admin" }), method(NodeBenchmarkPlanSchema, discriminatedUnion("kind", [object({
|
|
27691
|
+
kind: literal("started"),
|
|
27692
|
+
runId: string()
|
|
27693
|
+
}), object({
|
|
27694
|
+
kind: literal("refused"),
|
|
27695
|
+
preflight: NodeBenchmarkPreflightSchema
|
|
27696
|
+
})]), {
|
|
27697
|
+
kind: "mutation",
|
|
27698
|
+
auth: "admin"
|
|
27699
|
+
}), method(_void(), NodeBenchmarkStatusSchema, { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
|
|
27700
|
+
kind: "mutation",
|
|
27701
|
+
auth: "admin"
|
|
27702
|
+
}), method(object({ nodeId: string() }), NodeBenchmarkCandidatesSchema, { auth: "admin" }), method(ListNodeBenchmarkResultsInputSchema, array(NodeBenchmarkResultViewSchema).readonly(), { auth: "admin" }), method(object({ id: string() }), object({ deleted: boolean() }), {
|
|
27703
|
+
kind: "mutation",
|
|
27704
|
+
auth: "admin"
|
|
26024
27705
|
}), method(object({ deviceId: number() }), CameraPipelineSettingsSchema.nullable()), method(object({
|
|
26025
27706
|
deviceId: number(),
|
|
26026
27707
|
addonId: string(),
|
|
@@ -32240,6 +33921,9 @@ var CreateIntegrationInputSchema = object({
|
|
|
32240
33921
|
enabled: boolean().optional(),
|
|
32241
33922
|
info: record(string(), unknown()).optional(),
|
|
32242
33923
|
settings: record(string(), unknown()).optional(),
|
|
33924
|
+
/** Keys of `settings` the form's schema declares secret (by type) — kept in
|
|
33925
|
+
* the keychain, not the table (D787). */
|
|
33926
|
+
secretKeys: array(string()).optional(),
|
|
32243
33927
|
skipRestart: boolean().optional()
|
|
32244
33928
|
});
|
|
32245
33929
|
var UpdateIntegrationInputSchema = object({
|
|
@@ -32263,7 +33947,9 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
|
|
|
32263
33947
|
auth: "admin"
|
|
32264
33948
|
}), method(object({ id: string() }), record(string(), unknown()), { auth: "admin" }), method(object({
|
|
32265
33949
|
id: string(),
|
|
32266
|
-
settings: record(string(), unknown())
|
|
33950
|
+
settings: record(string(), unknown()),
|
|
33951
|
+
/** Keys the form's schema declares secret (by type) — keychain-stored (D787). */
|
|
33952
|
+
secretKeys: array(string()).optional()
|
|
32267
33953
|
}), object({ success: boolean() }), {
|
|
32268
33954
|
kind: "mutation",
|
|
32269
33955
|
auth: "admin"
|
|
@@ -40426,7 +42112,8 @@ var BaseDevice = class {
|
|
|
40426
42112
|
this.role = options.role;
|
|
40427
42113
|
this.parentDeviceId = ctx.parentDeviceId;
|
|
40428
42114
|
const seedData = ctx.persistedConfig ?? {};
|
|
40429
|
-
|
|
42115
|
+
const declaredSecretPaths = collectZodSecretPaths(schema);
|
|
42116
|
+
this.config = DeviceConfig.fromSchema(schema, (data) => ctx.persistConfig(data, { secretConfigPaths: declaredSecretPaths }), seedData, ({ droppedKeys, issues }) => {
|
|
40430
42117
|
ctx.logger.warn("Device config recovery: dropping invalid persisted fields", {
|
|
40431
42118
|
tags: {
|
|
40432
42119
|
deviceId: ctx.id,
|
|
@@ -44115,6 +45802,96 @@ Object.freeze({
|
|
|
44115
45802
|
addonId: null,
|
|
44116
45803
|
access: "create"
|
|
44117
45804
|
},
|
|
45805
|
+
"keychain.delete": {
|
|
45806
|
+
capName: "keychain",
|
|
45807
|
+
capScope: "system",
|
|
45808
|
+
addonId: null,
|
|
45809
|
+
access: "delete"
|
|
45810
|
+
},
|
|
45811
|
+
"keychain.getState": {
|
|
45812
|
+
capName: "keychain",
|
|
45813
|
+
capScope: "system",
|
|
45814
|
+
addonId: null,
|
|
45815
|
+
access: "view"
|
|
45816
|
+
},
|
|
45817
|
+
"keychain.listMeta": {
|
|
45818
|
+
capName: "keychain",
|
|
45819
|
+
capScope: "system",
|
|
45820
|
+
addonId: null,
|
|
45821
|
+
access: "view"
|
|
45822
|
+
},
|
|
45823
|
+
"keychain.put": {
|
|
45824
|
+
capName: "keychain",
|
|
45825
|
+
capScope: "system",
|
|
45826
|
+
addonId: null,
|
|
45827
|
+
access: "create"
|
|
45828
|
+
},
|
|
45829
|
+
"keychain.resolve": {
|
|
45830
|
+
capName: "keychain",
|
|
45831
|
+
capScope: "system",
|
|
45832
|
+
addonId: null,
|
|
45833
|
+
access: "view"
|
|
45834
|
+
},
|
|
45835
|
+
"keychainAdmin.deleteOrphans": {
|
|
45836
|
+
capName: "keychain-admin",
|
|
45837
|
+
capScope: "system",
|
|
45838
|
+
addonId: null,
|
|
45839
|
+
access: "delete"
|
|
45840
|
+
},
|
|
45841
|
+
"keychainAdmin.downloadRecoveryKey": {
|
|
45842
|
+
capName: "keychain-admin",
|
|
45843
|
+
capScope: "system",
|
|
45844
|
+
addonId: null,
|
|
45845
|
+
access: "create"
|
|
45846
|
+
},
|
|
45847
|
+
"keychainAdmin.listAudit": {
|
|
45848
|
+
capName: "keychain-admin",
|
|
45849
|
+
capScope: "system",
|
|
45850
|
+
addonId: null,
|
|
45851
|
+
access: "view"
|
|
45852
|
+
},
|
|
45853
|
+
"keychainAdmin.listSecrets": {
|
|
45854
|
+
capName: "keychain-admin",
|
|
45855
|
+
capScope: "system",
|
|
45856
|
+
addonId: null,
|
|
45857
|
+
access: "view"
|
|
45858
|
+
},
|
|
45859
|
+
"keychainAdmin.purgeRetiredKeys": {
|
|
45860
|
+
capName: "keychain-admin",
|
|
45861
|
+
capScope: "system",
|
|
45862
|
+
addonId: null,
|
|
45863
|
+
access: "delete"
|
|
45864
|
+
},
|
|
45865
|
+
"keychainAdmin.resetKeychain": {
|
|
45866
|
+
capName: "keychain-admin",
|
|
45867
|
+
capScope: "system",
|
|
45868
|
+
addonId: null,
|
|
45869
|
+
access: "delete"
|
|
45870
|
+
},
|
|
45871
|
+
"keychainAdmin.reveal": {
|
|
45872
|
+
capName: "keychain-admin",
|
|
45873
|
+
capScope: "system",
|
|
45874
|
+
addonId: null,
|
|
45875
|
+
access: "create"
|
|
45876
|
+
},
|
|
45877
|
+
"keychainAdmin.rotateMasterKey": {
|
|
45878
|
+
capName: "keychain-admin",
|
|
45879
|
+
capScope: "system",
|
|
45880
|
+
addonId: null,
|
|
45881
|
+
access: "create"
|
|
45882
|
+
},
|
|
45883
|
+
"keychainAdmin.setSystemSecret": {
|
|
45884
|
+
capName: "keychain-admin",
|
|
45885
|
+
capScope: "system",
|
|
45886
|
+
addonId: null,
|
|
45887
|
+
access: "create"
|
|
45888
|
+
},
|
|
45889
|
+
"keychainAdmin.status": {
|
|
45890
|
+
capName: "keychain-admin",
|
|
45891
|
+
capScope: "system",
|
|
45892
|
+
addonId: null,
|
|
45893
|
+
access: "view"
|
|
45894
|
+
},
|
|
44118
45895
|
"lawnMowerControl.dock": {
|
|
44119
45896
|
capName: "lawn-mower-control",
|
|
44120
45897
|
capScope: "device",
|
|
@@ -45489,6 +47266,18 @@ Object.freeze({
|
|
|
45489
47266
|
addonId: null,
|
|
45490
47267
|
access: "create"
|
|
45491
47268
|
},
|
|
47269
|
+
"pipelineAnalytics.addRetrainFrameFromRecording": {
|
|
47270
|
+
capName: "pipeline-analytics",
|
|
47271
|
+
capScope: "device",
|
|
47272
|
+
addonId: null,
|
|
47273
|
+
access: "create"
|
|
47274
|
+
},
|
|
47275
|
+
"pipelineAnalytics.addRetrainFramesToCollection": {
|
|
47276
|
+
capName: "pipeline-analytics",
|
|
47277
|
+
capScope: "device",
|
|
47278
|
+
addonId: null,
|
|
47279
|
+
access: "create"
|
|
47280
|
+
},
|
|
45492
47281
|
"pipelineAnalytics.applyDeviceSettingsPatch": {
|
|
45493
47282
|
capName: "pipeline-analytics",
|
|
45494
47283
|
capScope: "device",
|
|
@@ -45537,12 +47326,36 @@ Object.freeze({
|
|
|
45537
47326
|
addonId: null,
|
|
45538
47327
|
access: "view"
|
|
45539
47328
|
},
|
|
47329
|
+
"pipelineAnalytics.createRetrainCollection": {
|
|
47330
|
+
capName: "pipeline-analytics",
|
|
47331
|
+
capScope: "device",
|
|
47332
|
+
addonId: null,
|
|
47333
|
+
access: "create"
|
|
47334
|
+
},
|
|
47335
|
+
"pipelineAnalytics.createRetrainDatasetVersion": {
|
|
47336
|
+
capName: "pipeline-analytics",
|
|
47337
|
+
capScope: "device",
|
|
47338
|
+
addonId: null,
|
|
47339
|
+
access: "create"
|
|
47340
|
+
},
|
|
45540
47341
|
"pipelineAnalytics.deleteDeviceEvents": {
|
|
45541
47342
|
capName: "pipeline-analytics",
|
|
45542
47343
|
capScope: "device",
|
|
45543
47344
|
addonId: null,
|
|
45544
47345
|
access: "delete"
|
|
45545
47346
|
},
|
|
47347
|
+
"pipelineAnalytics.deleteRetrainCollection": {
|
|
47348
|
+
capName: "pipeline-analytics",
|
|
47349
|
+
capScope: "device",
|
|
47350
|
+
addonId: null,
|
|
47351
|
+
access: "delete"
|
|
47352
|
+
},
|
|
47353
|
+
"pipelineAnalytics.deleteRetrainDatasetVersion": {
|
|
47354
|
+
capName: "pipeline-analytics",
|
|
47355
|
+
capScope: "device",
|
|
47356
|
+
addonId: null,
|
|
47357
|
+
access: "delete"
|
|
47358
|
+
},
|
|
45546
47359
|
"pipelineAnalytics.deleteTracks": {
|
|
45547
47360
|
capName: "pipeline-analytics",
|
|
45548
47361
|
capScope: "device",
|
|
@@ -45747,6 +47560,30 @@ Object.freeze({
|
|
|
45747
47560
|
addonId: null,
|
|
45748
47561
|
access: "view"
|
|
45749
47562
|
},
|
|
47563
|
+
"pipelineAnalytics.listRetrainAssistProfiles": {
|
|
47564
|
+
capName: "pipeline-analytics",
|
|
47565
|
+
capScope: "device",
|
|
47566
|
+
addonId: null,
|
|
47567
|
+
access: "view"
|
|
47568
|
+
},
|
|
47569
|
+
"pipelineAnalytics.listRetrainCollectionFrames": {
|
|
47570
|
+
capName: "pipeline-analytics",
|
|
47571
|
+
capScope: "device",
|
|
47572
|
+
addonId: null,
|
|
47573
|
+
access: "view"
|
|
47574
|
+
},
|
|
47575
|
+
"pipelineAnalytics.listRetrainCollections": {
|
|
47576
|
+
capName: "pipeline-analytics",
|
|
47577
|
+
capScope: "device",
|
|
47578
|
+
addonId: null,
|
|
47579
|
+
access: "view"
|
|
47580
|
+
},
|
|
47581
|
+
"pipelineAnalytics.listRetrainDatasetVersions": {
|
|
47582
|
+
capName: "pipeline-analytics",
|
|
47583
|
+
capScope: "device",
|
|
47584
|
+
addonId: null,
|
|
47585
|
+
access: "view"
|
|
47586
|
+
},
|
|
45750
47587
|
"pipelineAnalytics.listRetrainFrames": {
|
|
45751
47588
|
capName: "pipeline-analytics",
|
|
45752
47589
|
capScope: "device",
|
|
@@ -45789,12 +47626,24 @@ Object.freeze({
|
|
|
45789
47626
|
addonId: null,
|
|
45790
47627
|
access: "create"
|
|
45791
47628
|
},
|
|
47629
|
+
"pipelineAnalytics.previewRetrainDataset": {
|
|
47630
|
+
capName: "pipeline-analytics",
|
|
47631
|
+
capScope: "device",
|
|
47632
|
+
addonId: null,
|
|
47633
|
+
access: "view"
|
|
47634
|
+
},
|
|
45792
47635
|
"pipelineAnalytics.proposeRetrainAnnotations": {
|
|
45793
47636
|
capName: "pipeline-analytics",
|
|
45794
47637
|
capScope: "device",
|
|
45795
47638
|
addonId: null,
|
|
45796
47639
|
access: "create"
|
|
45797
47640
|
},
|
|
47641
|
+
"pipelineAnalytics.proposeRetrainAnnotationsWithLlm": {
|
|
47642
|
+
capName: "pipeline-analytics",
|
|
47643
|
+
capScope: "device",
|
|
47644
|
+
addonId: null,
|
|
47645
|
+
access: "create"
|
|
47646
|
+
},
|
|
45798
47647
|
"pipelineAnalytics.pruneEvents": {
|
|
45799
47648
|
capName: "pipeline-analytics",
|
|
45800
47649
|
capScope: "device",
|
|
@@ -45849,6 +47698,18 @@ Object.freeze({
|
|
|
45849
47698
|
addonId: null,
|
|
45850
47699
|
access: "create"
|
|
45851
47700
|
},
|
|
47701
|
+
"pipelineAnalytics.removeRetrainFrameFromCollection": {
|
|
47702
|
+
capName: "pipeline-analytics",
|
|
47703
|
+
capScope: "device",
|
|
47704
|
+
addonId: null,
|
|
47705
|
+
access: "delete"
|
|
47706
|
+
},
|
|
47707
|
+
"pipelineAnalytics.renameRetrainCollection": {
|
|
47708
|
+
capName: "pipeline-analytics",
|
|
47709
|
+
capScope: "device",
|
|
47710
|
+
addonId: null,
|
|
47711
|
+
access: "create"
|
|
47712
|
+
},
|
|
45852
47713
|
"pipelineAnalytics.restageRetrainTrack": {
|
|
45853
47714
|
capName: "pipeline-analytics",
|
|
45854
47715
|
capScope: "device",
|
|
@@ -45909,6 +47770,12 @@ Object.freeze({
|
|
|
45909
47770
|
addonId: null,
|
|
45910
47771
|
access: "create"
|
|
45911
47772
|
},
|
|
47773
|
+
"pipelineAnalytics.verifyRetrainDatasetVersion": {
|
|
47774
|
+
capName: "pipeline-analytics",
|
|
47775
|
+
capScope: "device",
|
|
47776
|
+
addonId: null,
|
|
47777
|
+
access: "view"
|
|
47778
|
+
},
|
|
45912
47779
|
"pipelineAnalytics.wipeAllAnalytics": {
|
|
45913
47780
|
capName: "pipeline-analytics",
|
|
45914
47781
|
capScope: "device",
|
|
@@ -46137,6 +48004,12 @@ Object.freeze({
|
|
|
46137
48004
|
addonId: null,
|
|
46138
48005
|
access: "view"
|
|
46139
48006
|
},
|
|
48007
|
+
"pipelineOrchestrator.abortNodeBenchmark": {
|
|
48008
|
+
capName: "pipeline-orchestrator",
|
|
48009
|
+
capScope: "system",
|
|
48010
|
+
addonId: null,
|
|
48011
|
+
access: "create"
|
|
48012
|
+
},
|
|
46140
48013
|
"pipelineOrchestrator.applyAutoTune": {
|
|
46141
48014
|
capName: "pipeline-orchestrator",
|
|
46142
48015
|
capScope: "system",
|
|
@@ -46161,6 +48034,12 @@ Object.freeze({
|
|
|
46161
48034
|
addonId: null,
|
|
46162
48035
|
access: "create"
|
|
46163
48036
|
},
|
|
48037
|
+
"pipelineOrchestrator.deleteNodeBenchmarkResult": {
|
|
48038
|
+
capName: "pipeline-orchestrator",
|
|
48039
|
+
capScope: "system",
|
|
48040
|
+
addonId: null,
|
|
48041
|
+
access: "delete"
|
|
48042
|
+
},
|
|
46164
48043
|
"pipelineOrchestrator.getAgentLoad": {
|
|
46165
48044
|
capName: "pipeline-orchestrator",
|
|
46166
48045
|
capScope: "system",
|
|
@@ -46269,6 +48148,24 @@ Object.freeze({
|
|
|
46269
48148
|
addonId: null,
|
|
46270
48149
|
access: "view"
|
|
46271
48150
|
},
|
|
48151
|
+
"pipelineOrchestrator.getNodeBenchmarkCandidates": {
|
|
48152
|
+
capName: "pipeline-orchestrator",
|
|
48153
|
+
capScope: "system",
|
|
48154
|
+
addonId: null,
|
|
48155
|
+
access: "view"
|
|
48156
|
+
},
|
|
48157
|
+
"pipelineOrchestrator.getNodeBenchmarkPreflight": {
|
|
48158
|
+
capName: "pipeline-orchestrator",
|
|
48159
|
+
capScope: "system",
|
|
48160
|
+
addonId: null,
|
|
48161
|
+
access: "view"
|
|
48162
|
+
},
|
|
48163
|
+
"pipelineOrchestrator.getNodeBenchmarkStatus": {
|
|
48164
|
+
capName: "pipeline-orchestrator",
|
|
48165
|
+
capScope: "system",
|
|
48166
|
+
addonId: null,
|
|
48167
|
+
access: "view"
|
|
48168
|
+
},
|
|
46272
48169
|
"pipelineOrchestrator.getNodeInferenceDevices": {
|
|
46273
48170
|
capName: "pipeline-orchestrator",
|
|
46274
48171
|
capScope: "system",
|
|
@@ -46311,6 +48208,12 @@ Object.freeze({
|
|
|
46311
48208
|
addonId: null,
|
|
46312
48209
|
access: "view"
|
|
46313
48210
|
},
|
|
48211
|
+
"pipelineOrchestrator.listNodeBenchmarkResults": {
|
|
48212
|
+
capName: "pipeline-orchestrator",
|
|
48213
|
+
capScope: "system",
|
|
48214
|
+
addonId: null,
|
|
48215
|
+
access: "view"
|
|
48216
|
+
},
|
|
46314
48217
|
"pipelineOrchestrator.pauseForStorageMigration": {
|
|
46315
48218
|
capName: "pipeline-orchestrator",
|
|
46316
48219
|
capScope: "system",
|
|
@@ -46455,6 +48358,12 @@ Object.freeze({
|
|
|
46455
48358
|
addonId: null,
|
|
46456
48359
|
access: "create"
|
|
46457
48360
|
},
|
|
48361
|
+
"pipelineOrchestrator.startNodeBenchmark": {
|
|
48362
|
+
capName: "pipeline-orchestrator",
|
|
48363
|
+
capScope: "system",
|
|
48364
|
+
addonId: null,
|
|
48365
|
+
access: "create"
|
|
48366
|
+
},
|
|
46458
48367
|
"pipelineOrchestrator.suggestShares": {
|
|
46459
48368
|
capName: "pipeline-orchestrator",
|
|
46460
48369
|
capScope: "system",
|
|
@@ -46473,6 +48382,12 @@ Object.freeze({
|
|
|
46473
48382
|
addonId: null,
|
|
46474
48383
|
access: "create"
|
|
46475
48384
|
},
|
|
48385
|
+
"pipelineRunner.abortNodeBench": {
|
|
48386
|
+
capName: "pipeline-runner",
|
|
48387
|
+
capScope: "system",
|
|
48388
|
+
addonId: null,
|
|
48389
|
+
access: "create"
|
|
48390
|
+
},
|
|
46476
48391
|
"pipelineRunner.attachCamera": {
|
|
46477
48392
|
capName: "pipeline-runner",
|
|
46478
48393
|
capScope: "system",
|
|
@@ -46521,6 +48436,12 @@ Object.freeze({
|
|
|
46521
48436
|
addonId: null,
|
|
46522
48437
|
access: "view"
|
|
46523
48438
|
},
|
|
48439
|
+
"pipelineRunner.getNodeBenchStatus": {
|
|
48440
|
+
capName: "pipeline-runner",
|
|
48441
|
+
capScope: "system",
|
|
48442
|
+
addonId: null,
|
|
48443
|
+
access: "view"
|
|
48444
|
+
},
|
|
46524
48445
|
"pipelineRunner.getParkedTrackFrame": {
|
|
46525
48446
|
capName: "pipeline-runner",
|
|
46526
48447
|
capScope: "system",
|
|
@@ -46563,6 +48484,12 @@ Object.freeze({
|
|
|
46563
48484
|
addonId: null,
|
|
46564
48485
|
access: "create"
|
|
46565
48486
|
},
|
|
48487
|
+
"pipelineRunner.startNodeBench": {
|
|
48488
|
+
capName: "pipeline-runner",
|
|
48489
|
+
capScope: "system",
|
|
48490
|
+
addonId: null,
|
|
48491
|
+
access: "create"
|
|
48492
|
+
},
|
|
46566
48493
|
"plateGallery.assignPlate": {
|
|
46567
48494
|
capName: "plate-gallery",
|
|
46568
48495
|
capScope: "system",
|
|
@@ -51492,6 +53419,11 @@ Object.freeze({
|
|
|
51492
53419
|
form: "single",
|
|
51493
53420
|
optional: false
|
|
51494
53421
|
}],
|
|
53422
|
+
"pipelineAnalytics.addRetrainFrameFromRecording": [{
|
|
53423
|
+
name: "deviceId",
|
|
53424
|
+
form: "single",
|
|
53425
|
+
optional: false
|
|
53426
|
+
}],
|
|
51495
53427
|
"pipelineAnalytics.applyDeviceSettingsPatch": [{
|
|
51496
53428
|
name: "deviceId",
|
|
51497
53429
|
form: "single",
|
|
@@ -51682,6 +53614,11 @@ Object.freeze({
|
|
|
51682
53614
|
form: "single",
|
|
51683
53615
|
optional: false
|
|
51684
53616
|
}],
|
|
53617
|
+
"pipelineAnalytics.proposeRetrainAnnotationsWithLlm": [{
|
|
53618
|
+
name: "deviceId",
|
|
53619
|
+
form: "single",
|
|
53620
|
+
optional: false
|
|
53621
|
+
}],
|
|
51685
53622
|
"pipelineAnalytics.pruneEventsBefore": [{
|
|
51686
53623
|
name: "deviceId",
|
|
51687
53624
|
form: "single",
|
|
@@ -58537,6 +60474,20 @@ function getString(obj, key) {
|
|
|
58537
60474
|
const v = obj[key];
|
|
58538
60475
|
return typeof v === "string" ? v : "";
|
|
58539
60476
|
}
|
|
60477
|
+
/**
|
|
60478
|
+
* Keys the account form declares. They belong to `integration.settings`; in
|
|
60479
|
+
* the addon's global store they are stale leftovers.
|
|
60480
|
+
*/
|
|
60481
|
+
var GLOBAL_CREDENTIAL_KEYS = [
|
|
60482
|
+
"email",
|
|
60483
|
+
"password",
|
|
60484
|
+
"apiKey",
|
|
60485
|
+
"apiId"
|
|
60486
|
+
];
|
|
60487
|
+
/** A stored value worth removing: a non-empty string or a keychain marker. */
|
|
60488
|
+
function isStoredValue(v) {
|
|
60489
|
+
return typeof v === "string" && v.length > 0 || isSecretMarker(v);
|
|
60490
|
+
}
|
|
58540
60491
|
/** Extract account credentials from an integration's settings, or null. */
|
|
58541
60492
|
function credentialsFromSettings(settings) {
|
|
58542
60493
|
const email = getString(settings, "email").trim();
|
|
@@ -58601,6 +60552,9 @@ var WyzeProviderAddon = class extends BaseDeviceProvider {
|
|
|
58601
60552
|
});
|
|
58602
60553
|
});
|
|
58603
60554
|
});
|
|
60555
|
+
await this.purgeStaleGlobalCredentials().catch((err) => {
|
|
60556
|
+
this.ctx.logger.warn("could not remove stale Wyze credentials from the global store", { meta: { error: errMsg(err) } });
|
|
60557
|
+
});
|
|
58604
60558
|
await this.reconcileIntegrations();
|
|
58605
60559
|
this.subscribeIntegrationLifecycle();
|
|
58606
60560
|
return [
|
|
@@ -58736,8 +60690,25 @@ var WyzeProviderAddon = class extends BaseDeviceProvider {
|
|
|
58736
60690
|
}
|
|
58737
60691
|
});
|
|
58738
60692
|
}
|
|
60693
|
+
globalSettingsSchema() {
|
|
60694
|
+
return buildSettingsSchema();
|
|
60695
|
+
}
|
|
58739
60696
|
async getGlobalSettings() {
|
|
58740
|
-
return hydrateSchema(
|
|
60697
|
+
return hydrateSchema(this.globalSettingsSchema(), {});
|
|
60698
|
+
}
|
|
60699
|
+
/**
|
|
60700
|
+
* Remove account credentials left in the GLOBAL store. They are dead — the
|
|
60701
|
+
* addon reads credentials only from `integration.settings` — and an older
|
|
60702
|
+
* build left them there as plaintext. Idempotent: a clean store is not
|
|
60703
|
+
* written. Secret keys are cleared through `clearSecrets`, which also drops
|
|
60704
|
+
* any keychain value a marker points at.
|
|
60705
|
+
*/
|
|
60706
|
+
async purgeStaleGlobalCredentials() {
|
|
60707
|
+
const stored = await this.resolveGlobalStore();
|
|
60708
|
+
const present = GLOBAL_CREDENTIAL_KEYS.filter((key) => isStoredValue(stored[key]));
|
|
60709
|
+
if (present.length === 0) return;
|
|
60710
|
+
await this.clearSecrets(present);
|
|
60711
|
+
this.ctx.logger.info("Removed stale Wyze credentials from the addon global store", { meta: { keys: present } });
|
|
58741
60712
|
}
|
|
58742
60713
|
async onGetCreationSchema(type) {
|
|
58743
60714
|
if (type !== DeviceType.Camera) return null;
|