@camstack/addon-provider-onvif 1.2.122 → 1.2.124

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/addon.js +1936 -63
  2. package/dist/addon.mjs +1936 -63
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  //#region \0rolldown/runtime.js
3
3
  var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
4
4
  //#endregion
5
- //#region ../types/dist/event-category-B_0XEcLF.mjs
5
+ //#region ../types/dist/event-category-DaIZi00R.mjs
6
6
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
7
7
  EventCategory["SystemBoot"] = "system.boot";
8
8
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -81,6 +81,13 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
81
81
  */
82
82
  EventCategory["AddonLoadFailed"] = "addon.load-failed";
83
83
  /**
84
+ * A keychain value was stored or removed (D787). Carries the ref, its
85
+ * owner and the new version — NEVER the value. A process holding the ref
86
+ * drops its cached copy and the owning `BaseAddon` re-resolves its config.
87
+ * Telemetry (D8): a process that misses it still revalidates by version.
88
+ */
89
+ EventCategory["KeychainChanged"] = "keychain.changed";
90
+ /**
84
91
  * Addon recovered from a previous failure. Emitted when an addon
85
92
  * transitions from `failed` back to `healthy` (typically via the
86
93
  * monitor's auto-retry loop, or after manual `addons.retryLoad`).
@@ -5373,7 +5380,7 @@ var ZodIssueCode = {
5373
5380
  var ZodFirstPartyTypeKind;
5374
5381
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5375
5382
  //#endregion
5376
- //#region ../types/dist/sleep-B0JG7-_F.mjs
5383
+ //#region ../types/dist/sleep-DujUvOcb.mjs
5377
5384
  /**
5378
5385
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5379
5386
  * window to float samples (D455).
@@ -5452,6 +5459,97 @@ function buildAlawTable() {
5452
5459
  }
5453
5460
  buildUlawTable();
5454
5461
  buildAlawTable();
5462
+ /** Is this field's stored value a credential? */
5463
+ function isSecretConfigField(field) {
5464
+ if (field.type === "password") return true;
5465
+ return "secret" in field && field.secret === true;
5466
+ }
5467
+ /**
5468
+ * Is this field's value stored in the KEYCHAIN (D787)? Every secret field is,
5469
+ * by its TYPE, unless it opts out with `storage: 'inline'` — never by its name.
5470
+ */
5471
+ function isKeychainStoredField(field) {
5472
+ if (!isSecretConfigField(field)) return false;
5473
+ if (field.type === "textarea" && field.isJson === true) return false;
5474
+ return !("storage" in field && field.storage === "inline");
5475
+ }
5476
+ /**
5477
+ * What a settings blob holds where a secret used to be.
5478
+ *
5479
+ * A keychain-stored field never holds its value. It holds a self-describing
5480
+ * MARKER, `{"$secret":"secret://…","v":1}` — an object, never a string, so no
5481
+ * code can mistake it for a credential and no form can send it to a camera as
5482
+ * a password. The empty state is `null` / absent, never `''`.
5483
+ *
5484
+ * The same shapes travel to and from the admin UI:
5485
+ *
5486
+ * - read: `hydrateSchema` hands a secret field a {@link SecretFieldView}
5487
+ * (`{ $secret, v, set: true }`) or `null` — the browser learns whether a
5488
+ * value is set, never the value.
5489
+ * - write: an untouched field submits the view back unchanged (KEEP); a typed
5490
+ * value is a plain non-empty string (CHANGE); the Clear button submits
5491
+ * {@link SECRET_CLEAR} (CLEAR). `''`, `null` and the legacy redaction tokens
5492
+ * are KEEP — an empty string is what a defaults-fallback pushes back, and
5493
+ * treating it as "clear" is how a save destroyed a stored credential before.
5494
+ *
5495
+ * Pure and browser-safe.
5496
+ */
5497
+ var SECRET_CLEAR = { $secretClear: true };
5498
+ /** The `'***'` token D634 redaction writes for non-admins. */
5499
+ var LEGACY_DEVICE_REDACTION = "***";
5500
+ function isRecord$1(value) {
5501
+ return typeof value === "object" && value !== null && !Array.isArray(value);
5502
+ }
5503
+ function makeSecretMarker(ref) {
5504
+ return {
5505
+ $secret: ref,
5506
+ v: 1
5507
+ };
5508
+ }
5509
+ /** A stored marker: an object whose `$secret` is a non-empty string. */
5510
+ function isSecretMarker(value) {
5511
+ if (!isRecord$1(value)) return false;
5512
+ const ref = value["$secret"];
5513
+ return typeof ref === "string" && ref.length > 0;
5514
+ }
5515
+ function isSecretClear(value) {
5516
+ return isRecord$1(value) && value["$secretClear"] === true;
5517
+ }
5518
+ /**
5519
+ * The UI view of a stored secret field value: a marker becomes "set", inline
5520
+ * plaintext becomes "set (inline)", nothing becomes `null`. A value never
5521
+ * survives this function.
5522
+ */
5523
+ function toSecretFieldView(stored) {
5524
+ if (isSecretMarker(stored)) return {
5525
+ $secret: stored.$secret,
5526
+ v: 1,
5527
+ set: true
5528
+ };
5529
+ if (typeof stored === "string" && stored.length > 0) return {
5530
+ $secret: null,
5531
+ v: 1,
5532
+ set: true,
5533
+ inline: true
5534
+ };
5535
+ return null;
5536
+ }
5537
+ /**
5538
+ * Classify an incoming value for a secret path. Only a non-empty string that is
5539
+ * not a redaction token sets a value; only {@link SECRET_CLEAR} clears.
5540
+ * Everything else — a marker (ours or anyone's), a UI view, `''`, `null`,
5541
+ * `undefined`, a redaction token, a non-string — keeps what is stored.
5542
+ */
5543
+ function classifySecretWrite(incoming) {
5544
+ if (isSecretClear(incoming)) return { kind: "clear" };
5545
+ if (typeof incoming !== "string") return { kind: "keep" };
5546
+ if (incoming.length === 0) return { kind: "keep" };
5547
+ if (incoming === "__camstack_redacted__" || incoming === LEGACY_DEVICE_REDACTION) return { kind: "keep" };
5548
+ return {
5549
+ kind: "set",
5550
+ value: incoming
5551
+ };
5552
+ }
5455
5553
  Object.fromEntries([
5456
5554
  {
5457
5555
  id: "overview",
@@ -5623,33 +5721,19 @@ Object.fromEntries([
5623
5721
  function isValuelessField(field) {
5624
5722
  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";
5625
5723
  }
5626
- /**
5627
- * Merge a `ConfigUISchema` with a raw `values` record into a
5628
- * `ConfigUISchemaWithValues`. Used by every `get*Settings` backend endpoint
5629
- * before returning to the admin UI. Groups are walked recursively.
5630
- *
5631
- * For each leaf field:
5632
- * - structural fields (`separator`, `info`, `button`) pass through unchanged
5633
- * - other fields get `value = values[key] ?? field.default ?? null`
5634
- *
5635
- * Unknown keys in `values` (keys not declared in the schema) are silently
5636
- * ignored — they don't contribute to the output. Missing keys fall back to
5637
- * the schema default or `null`. This mirrors the old backend behaviour where
5638
- * `FormBuilder` rendered `values[key] ?? field.default`.
5639
- */
5640
- function hydrateSchema(schema, values) {
5724
+ function hydrateSchema(schema, values, options = {}) {
5641
5725
  return {
5642
5726
  ...schema.tabs ? { tabs: [...schema.tabs] } : {},
5643
5727
  sections: schema.sections.map((section) => ({
5644
5728
  ...section,
5645
- fields: section.fields.map((field) => hydrateField(field, values))
5729
+ fields: section.fields.map((field) => hydrateField(field, values, options))
5646
5730
  }))
5647
5731
  };
5648
5732
  }
5649
- function hydrateField(field, values) {
5733
+ function hydrateField(field, values, options) {
5650
5734
  if (isValuelessField(field)) return field;
5651
5735
  if (field.type === "group") {
5652
- const hydratedChildren = field.fields.map((child) => hydrateField(child, values));
5736
+ const hydratedChildren = field.fields.map((child) => hydrateField(child, values, options));
5653
5737
  return {
5654
5738
  ...field,
5655
5739
  fields: hydratedChildren
@@ -5658,7 +5742,7 @@ function hydrateField(field, values) {
5658
5742
  if (field.type === "sub-tabs") {
5659
5743
  const hydratedTabs = field.tabs.map((tab) => ({
5660
5744
  ...tab,
5661
- fields: tab.fields.map((child) => hydrateField(child, values))
5745
+ fields: tab.fields.map((child) => hydrateField(child, values, options))
5662
5746
  }));
5663
5747
  return {
5664
5748
  ...field,
@@ -5668,6 +5752,33 @@ function hydrateField(field, values) {
5668
5752
  const key = field.key;
5669
5753
  const storedValue = Object.prototype.hasOwnProperty.call(values, key) ? values[key] : void 0;
5670
5754
  const defaultValue = field.default;
5755
+ const asView = (v) => isSecretMarker(v) || options.inlineSecretsAsViews === true && v !== void 0;
5756
+ if (isKeychainStoredField(field) && asView(storedValue)) return {
5757
+ ...field,
5758
+ value: toSecretFieldView(storedValue)
5759
+ };
5760
+ if (isKeychainStoredField(field) && options.inlineSecretsAsViews === true) return {
5761
+ ...field,
5762
+ value: null
5763
+ };
5764
+ if (field.type === "editable-array" && Array.isArray(storedValue)) {
5765
+ const secretItemKeys = field.itemFields.filter((item) => "key" in item && isKeychainStoredField(item)).map((item) => "key" in item ? item.key : "");
5766
+ if (secretItemKeys.length > 0) {
5767
+ const rows = storedValue.map((row) => {
5768
+ if (row === null || typeof row !== "object" || Array.isArray(row)) return row;
5769
+ const out = { ...row };
5770
+ for (const k of secretItemKeys) {
5771
+ const v = Reflect.get(row, k);
5772
+ if (asView(v)) out[k] = toSecretFieldView(v);
5773
+ }
5774
+ return out;
5775
+ });
5776
+ return {
5777
+ ...field,
5778
+ value: rows
5779
+ };
5780
+ }
5781
+ }
5671
5782
  if (field.multiple) {
5672
5783
  const stored = Array.isArray(storedValue) ? storedValue : storedValue !== void 0 && storedValue !== null ? [storedValue] : [];
5673
5784
  const itemFallback = field.multiple.itemDefault !== void 0 ? field.multiple.itemDefault : defaultValue !== void 0 ? defaultValue : typeOf(field) === "string" ? "" : null;
@@ -5910,6 +6021,431 @@ function projectStore(store, perNodeKeys, nodeId) {
5910
6021
  }
5911
6022
  return out;
5912
6023
  }
6024
+ var GLOBAL_SCOPE = { kind: "global" };
6025
+ /** The scope every addon-wide (not per-node, not per-device) setting lives in. */
6026
+ function globalSecretScope() {
6027
+ return GLOBAL_SCOPE;
6028
+ }
6029
+ function encodeSegment(value) {
6030
+ return encodeURIComponent(value);
6031
+ }
6032
+ /**
6033
+ * The field path of a value inside an array item, addressed by the item's id:
6034
+ * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
6035
+ * `providers[authentik].clientSecret`.
6036
+ */
6037
+ function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6038
+ return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6039
+ }
6040
+ /** A write to a secret path could not be stored in the keychain, so it was refused. */
6041
+ var KeychainWriteRefusedError = class extends Error {
6042
+ fieldPath;
6043
+ constructor(fieldPath, cause) {
6044
+ super(`secret "${fieldPath}" was not saved: the keychain could not store it (${cause instanceof Error ? cause.message : String(cause)}). Nothing was written.`);
6045
+ this.fieldPath = fieldPath;
6046
+ this.name = "KeychainWriteRefusedError";
6047
+ }
6048
+ };
6049
+ var KEEP = { kind: "keep" };
6050
+ function isRecord(value) {
6051
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6052
+ }
6053
+ function defaultMintId() {
6054
+ return globalThis.crypto.randomUUID();
6055
+ }
6056
+ /** Every marker ref anywhere under `value`. */
6057
+ function collectSecretMarkerRefs(value, out = []) {
6058
+ if (isSecretMarker(value)) {
6059
+ out.push(value.$secret);
6060
+ return out;
6061
+ }
6062
+ if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6063
+ else if (isRecord(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6064
+ return out;
6065
+ }
6066
+ async function storedValueEquals(secrets, marker, candidate) {
6067
+ const resolved = (await secrets.resolve([marker.$secret]))[marker.$secret];
6068
+ return resolved?.kind === "value" && resolved.value === candidate;
6069
+ }
6070
+ async function writeLeaf(ctx, incoming, stored, fieldPath) {
6071
+ const intent = classifySecretWrite(incoming);
6072
+ const ref = ctx.secrets.ref(ctx.scope, fieldPath);
6073
+ const storedIsOurs = isSecretMarker(stored) && stored.$secret === ref;
6074
+ if (intent.kind === "keep") return KEEP;
6075
+ if (intent.kind === "set" && !ctx.operatorWrite && typeof stored === "string" && stored === intent.value) return KEEP;
6076
+ if (intent.kind === "clear") {
6077
+ if (storedIsOurs) ctx.deletes.push(ref);
6078
+ return {
6079
+ kind: "value",
6080
+ value: null
6081
+ };
6082
+ }
6083
+ if (storedIsOurs && await storedValueEquals(ctx.secrets, stored, intent.value)) return {
6084
+ kind: "value",
6085
+ value: stored
6086
+ };
6087
+ try {
6088
+ await ctx.secrets.put(ref, intent.value);
6089
+ } catch (err) {
6090
+ throw new KeychainWriteRefusedError(fieldPath, err);
6091
+ }
6092
+ return {
6093
+ kind: "value",
6094
+ value: makeSecretMarker(ref)
6095
+ };
6096
+ }
6097
+ /** Apply a member result onto `out`: KEEP restores the stored member, or removes it. */
6098
+ function applyMember(out, key, result, storedParent) {
6099
+ if (result.kind === "value") {
6100
+ out[key] = result.value;
6101
+ return;
6102
+ }
6103
+ if (Object.prototype.hasOwnProperty.call(storedParent, key)) out[key] = storedParent[key];
6104
+ else delete out[key];
6105
+ }
6106
+ async function writeMembers(ctx, children, incoming, stored, pathOf) {
6107
+ const out = { ...incoming };
6108
+ for (const [member, node] of children) applyMember(out, member, await writeNode(ctx, node, incoming[member], stored[member], pathOf(member)), stored);
6109
+ return out;
6110
+ }
6111
+ function rowId(row, idKey) {
6112
+ const raw = row[idKey];
6113
+ if (typeof raw === "string" && raw.length > 0) return raw;
6114
+ if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
6115
+ return null;
6116
+ }
6117
+ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6118
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord) : [];
6119
+ if (!Array.isArray(incoming)) {
6120
+ ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6121
+ return {
6122
+ kind: "value",
6123
+ value: incoming
6124
+ };
6125
+ }
6126
+ const storedById = /* @__PURE__ */ new Map();
6127
+ for (const row of storedRows) {
6128
+ const id = rowId(row, node.idKey);
6129
+ if (id !== null) storedById.set(id, row);
6130
+ }
6131
+ const kept = /* @__PURE__ */ new Set();
6132
+ const rows = [];
6133
+ for (const row of incoming) {
6134
+ if (!isRecord(row)) {
6135
+ rows.push(row);
6136
+ continue;
6137
+ }
6138
+ const id = rowId(row, node.idKey) ?? ctx.mintId();
6139
+ kept.add(id);
6140
+ const withId = {
6141
+ ...row,
6142
+ [node.idKey]: row[node.idKey] ?? id
6143
+ };
6144
+ if (rowId(withId, node.idKey) === null) withId[node.idKey] = id;
6145
+ const storedRow = storedById.get(id) ?? {};
6146
+ rows.push(await writeMembers(ctx, node.item, withId, storedRow, (member) => arrayItemFieldPath(fieldPath, id, member)));
6147
+ }
6148
+ for (const [id, row] of storedById) if (!kept.has(id)) ctx.deletes.push(...collectSecretMarkerRefs(row));
6149
+ return {
6150
+ kind: "value",
6151
+ value: rows
6152
+ };
6153
+ }
6154
+ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6155
+ switch (node.kind) {
6156
+ case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6157
+ case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6158
+ case "object": {
6159
+ if (!isRecord(incoming)) {
6160
+ if (incoming === void 0) return KEEP;
6161
+ ctx.deletes.push(...collectSecretMarkerRefs(stored));
6162
+ return {
6163
+ kind: "value",
6164
+ value: incoming
6165
+ };
6166
+ }
6167
+ const storedObj = isRecord(stored) ? stored : {};
6168
+ return {
6169
+ kind: "value",
6170
+ value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
6171
+ };
6172
+ }
6173
+ }
6174
+ }
6175
+ /** Split a perNode-scoped key (`key@nodeId`). */
6176
+ function splitNodeKey(key) {
6177
+ const at = key.indexOf("@");
6178
+ return at <= 0 ? {
6179
+ base: key,
6180
+ nodeId: null
6181
+ } : {
6182
+ base: key.slice(0, at),
6183
+ nodeId: key.slice(at + 1)
6184
+ };
6185
+ }
6186
+ /** Rewrite a settings patch so no secret value reaches the blob. See the file doc. */
6187
+ async function transformSecretWrite(input) {
6188
+ const deletes = [];
6189
+ const base = {
6190
+ secrets: input.secrets,
6191
+ mintId: input.mintId ?? defaultMintId,
6192
+ deletes,
6193
+ operatorWrite: input.operatorWrite === true
6194
+ };
6195
+ const out = {};
6196
+ for (const [key, incoming] of Object.entries(input.patch)) {
6197
+ const { base: baseKey, nodeId } = splitNodeKey(key);
6198
+ const node = input.tree.get(baseKey);
6199
+ if (node === void 0) {
6200
+ out[key] = incoming;
6201
+ continue;
6202
+ }
6203
+ const scope = nodeId !== null && nodeId.length > 0 ? {
6204
+ kind: "node",
6205
+ nodeId
6206
+ } : input.scope ?? globalSecretScope();
6207
+ const result = await writeNode({
6208
+ ...base,
6209
+ scope
6210
+ }, node, incoming, input.stored[key], baseKey);
6211
+ if (result.kind === "value") out[key] = result.value;
6212
+ }
6213
+ return {
6214
+ patch: out,
6215
+ afterWrite: async () => {
6216
+ if (deletes.length === 0) return { orphaned: [] };
6217
+ try {
6218
+ await input.secrets.delete([...new Set(deletes)]);
6219
+ return { orphaned: [] };
6220
+ } catch {
6221
+ return { orphaned: [...new Set(deletes)] };
6222
+ }
6223
+ }
6224
+ };
6225
+ }
6226
+ /**
6227
+ * Replace every marker in `value` with its keychain value. Returns the SAME
6228
+ * reference when there is no marker (no allocation, no keychain call).
6229
+ */
6230
+ async function resolveSecretMarkers(value, secrets) {
6231
+ const refs = collectSecretMarkerRefs(value);
6232
+ if (refs.length === 0) return {
6233
+ value,
6234
+ unresolved: []
6235
+ };
6236
+ const answers = await secrets.resolve(refs);
6237
+ const unresolved = [];
6238
+ for (const ref of new Set(refs)) {
6239
+ const answer = answers[ref];
6240
+ if (answer === void 0) unresolved.push({
6241
+ ref,
6242
+ reason: "not-initialized"
6243
+ });
6244
+ else if (answer.kind === "unavailable") unresolved.push({
6245
+ ref,
6246
+ reason: answer.reason
6247
+ });
6248
+ else if (answer.kind === "missing" || answer.kind === "forbidden") unresolved.push({
6249
+ ref,
6250
+ reason: answer.kind
6251
+ });
6252
+ }
6253
+ const substitute = (v) => {
6254
+ if (isSecretMarker(v)) {
6255
+ const answer = answers[v.$secret];
6256
+ return answer?.kind === "value" ? {
6257
+ keep: true,
6258
+ value: answer.value
6259
+ } : {
6260
+ keep: false,
6261
+ value: void 0
6262
+ };
6263
+ }
6264
+ if (Array.isArray(v)) {
6265
+ const items = [];
6266
+ for (const item of v) {
6267
+ const s = substitute(item);
6268
+ if (s.keep) items.push(s.value);
6269
+ }
6270
+ return {
6271
+ keep: true,
6272
+ value: items
6273
+ };
6274
+ }
6275
+ if (isRecord(v)) {
6276
+ const out = {};
6277
+ for (const [k, child] of Object.entries(v)) {
6278
+ const s = substitute(child);
6279
+ if (s.keep) out[k] = s.value;
6280
+ }
6281
+ return {
6282
+ keep: true,
6283
+ value: out
6284
+ };
6285
+ }
6286
+ return {
6287
+ keep: true,
6288
+ value: v
6289
+ };
6290
+ };
6291
+ return {
6292
+ value: substitute(value).value,
6293
+ unresolved
6294
+ };
6295
+ }
6296
+ function touchesTree(tree, patch) {
6297
+ if (tree.size === 0) return false;
6298
+ for (const key of Object.keys(patch)) {
6299
+ const at = key.indexOf("@");
6300
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6301
+ }
6302
+ return false;
6303
+ }
6304
+ /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
6305
+ async function readStoredAddonBlob(raw) {
6306
+ const threeWay = raw.readAddonStoreResult;
6307
+ if (threeWay === void 0) return raw.readAddonStore();
6308
+ const result = await threeWay.call(raw);
6309
+ if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
6310
+ return result.kind === "missing" ? {} : result.value;
6311
+ }
6312
+ function createSecretAwareSettings(raw, opts) {
6313
+ const chains = /* @__PURE__ */ new Map();
6314
+ const serialize = (key, fn) => {
6315
+ const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
6316
+ const tail = next.catch(() => void 0);
6317
+ chains.set(key, tail);
6318
+ tail.then(() => {
6319
+ if (chains.get(key) === tail) chains.delete(key);
6320
+ });
6321
+ return next;
6322
+ };
6323
+ const write = async (chainKey, tree, scope, patch, readStored, rawWrite) => {
6324
+ if (!touchesTree(tree, patch)) return rawWrite(patch);
6325
+ return serialize(chainKey, async () => {
6326
+ const stored = await readStored();
6327
+ const result = await transformSecretWrite({
6328
+ tree,
6329
+ secrets: opts.secrets,
6330
+ patch,
6331
+ stored,
6332
+ ...scope !== void 0 ? { scope } : {},
6333
+ operatorWrite: opts.isOperatorWrite?.() === true
6334
+ });
6335
+ if (Object.keys(result.patch).length > 0) await rawWrite(result.patch);
6336
+ const { orphaned } = await result.afterWrite();
6337
+ if (orphaned.length > 0) opts.onOrphaned(orphaned);
6338
+ });
6339
+ };
6340
+ const wrapped = {
6341
+ writeAddonStore: (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p)),
6342
+ writeDeviceStore: (deviceId, patch) => write(`device:${deviceId}`, opts.deviceTree(), {
6343
+ kind: "device",
6344
+ deviceId
6345
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p))
6346
+ };
6347
+ return new Proxy(raw, { get(target, prop, receiver) {
6348
+ if (prop === "writeAddonStore") return wrapped.writeAddonStore;
6349
+ if (prop === "writeDeviceStore") return wrapped.writeDeviceStore;
6350
+ const value = Reflect.get(target, prop, receiver);
6351
+ return typeof value === "function" ? value.bind(target) : value;
6352
+ } });
6353
+ }
6354
+ /** The context the addon sees: identical, except that its settings writes are secret-aware. */
6355
+ function withSecretAwareSettings(context, opts) {
6356
+ const raw = context.settings;
6357
+ if (raw === void 0) return context;
6358
+ const settings = createSecretAwareSettings(raw, opts);
6359
+ return new Proxy(context, { get(target, prop, receiver) {
6360
+ if (prop === "settings") return settings;
6361
+ return Reflect.get(target, prop, receiver);
6362
+ } });
6363
+ }
6364
+ var LEAF = { kind: "leaf" };
6365
+ var DEFAULT_ITEM_ID_KEY = "id";
6366
+ function collectFields(fields, out) {
6367
+ for (const field of fields) {
6368
+ if (field.type === "group") {
6369
+ collectFields(field.fields, out);
6370
+ continue;
6371
+ }
6372
+ if (field.type === "sub-tabs") {
6373
+ for (const tab of field.tabs) collectFields(tab.fields, out);
6374
+ continue;
6375
+ }
6376
+ if (field.type === "editable-array") {
6377
+ const item = /* @__PURE__ */ new Map();
6378
+ for (const itemField of field.itemFields) if ("key" in itemField && isKeychainStoredField(itemField)) item.set(itemField.key, LEAF);
6379
+ if (item.size > 0) out.set(field.key, {
6380
+ kind: "array",
6381
+ idKey: field.itemIdKey ?? DEFAULT_ITEM_ID_KEY,
6382
+ item
6383
+ });
6384
+ continue;
6385
+ }
6386
+ if (!("key" in field) || typeof field.key !== "string") continue;
6387
+ if (isKeychainStoredField(field)) out.set(field.key, LEAF);
6388
+ }
6389
+ }
6390
+ /** The secret tree a settings schema declares. */
6391
+ function secretTreeFromSchema(schema) {
6392
+ const out = /* @__PURE__ */ new Map();
6393
+ if (schema === null) return out;
6394
+ for (const section of schema.sections) collectFields(section.fields, out);
6395
+ return out;
6396
+ }
6397
+ /** Parse `a.b[id].c` into segments; throws on a malformed path (a declaration bug). */
6398
+ function parseSecretStatePath(path) {
6399
+ const segments = [];
6400
+ for (const raw of path.split(".")) {
6401
+ const m = /^([^[\]]+)(?:\[([^[\]]+)\])?$/.exec(raw);
6402
+ if (m === null || m[1] === void 0) throw new Error(`secretStatePaths: malformed path "${path}"`);
6403
+ segments.push(m[2] !== void 0 ? {
6404
+ key: m[1],
6405
+ idKey: m[2]
6406
+ } : { key: m[1] });
6407
+ }
6408
+ if (segments.length === 0) throw new Error(`secretStatePaths: empty path`);
6409
+ if (segments[segments.length - 1]?.idKey !== void 0) throw new Error(`secretStatePaths: "${path}" ends on an array — name the member that is secret`);
6410
+ return segments;
6411
+ }
6412
+ function insert(into, segments) {
6413
+ const [head, ...rest] = segments;
6414
+ if (head === void 0) return;
6415
+ if (rest.length === 0) {
6416
+ into.set(head.key, LEAF);
6417
+ return;
6418
+ }
6419
+ const existing = into.get(head.key);
6420
+ if (head.idKey !== void 0) {
6421
+ const item = new Map(existing?.kind === "array" ? existing.item : []);
6422
+ insert(item, rest);
6423
+ into.set(head.key, {
6424
+ kind: "array",
6425
+ idKey: head.idKey,
6426
+ item
6427
+ });
6428
+ return;
6429
+ }
6430
+ const children = new Map(existing?.kind === "object" ? existing.children : []);
6431
+ insert(children, rest);
6432
+ into.set(head.key, {
6433
+ kind: "object",
6434
+ children
6435
+ });
6436
+ }
6437
+ /** Add hidden-state paths (`secretStatePaths`) to a schema-derived tree. */
6438
+ function mergeSecretStatePaths(tree, paths) {
6439
+ if (paths.length === 0) return tree;
6440
+ const out = new Map(tree);
6441
+ for (const path of paths) insert(out, parseSecretStatePath(path));
6442
+ return out;
6443
+ }
6444
+ /** First retry of a secret the keychain could not serve; doubles to {@link SECRET_RETRY_MAX_MS}. */
6445
+ var SECRET_RETRY_FIRST_MS = 5e3;
6446
+ var SECRET_RETRY_MAX_MS = 5 * 6e4;
6447
+ /** Coalesces a burst of `keychain.changed` events into one re-resolve. */
6448
+ var SECRET_CHANGE_DEBOUNCE_MS = 250;
5913
6449
  /**
5914
6450
  * Base class for CamStack addons. Eliminates settings boilerplate:
5915
6451
  *
@@ -5979,6 +6515,25 @@ var BaseAddon = class {
5979
6515
  settingsStoreReady = false;
5980
6516
  /** Default config values. Provided via constructor. */
5981
6517
  defaults;
6518
+ /**
6519
+ * Hidden-state paths that hold secrets (D787) — values the addon writes
6520
+ * itself (`updateGlobalSettings`, `state()`) that no form field declares.
6521
+ * Stored in the keychain exactly like a `password` field. Syntax:
6522
+ * `'snapshotSigningKey'`, `'identity.pincode'`, `'tokens[userId].accessToken'`
6523
+ * (`key[<id field>]` addresses array items by id, never by index).
6524
+ */
6525
+ secretStatePaths = [];
6526
+ _addonSecretTree = null;
6527
+ _deviceSecretTree = null;
6528
+ /** Refs the last resolved config pointed at — a change to one re-resolves. */
6529
+ _configSecretRefs = /* @__PURE__ */ new Set();
6530
+ _unresolvedSecrets = [];
6531
+ _secretRetryTimer = null;
6532
+ _secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
6533
+ _secretChangeTimer = null;
6534
+ _secretChangeUnsub = null;
6535
+ /** >0 while an OPERATOR's settings write is being applied. */
6536
+ _operatorWriteDepth = 0;
5982
6537
  constructor(defaults) {
5983
6538
  this.defaults = defaults;
5984
6539
  this._config = { ...defaults };
@@ -6014,8 +6569,18 @@ var BaseAddon = class {
6014
6569
  return this._config;
6015
6570
  }
6016
6571
  async initialize(context) {
6017
- this._ctx = context;
6572
+ const secrets = context.secrets;
6573
+ this._ctx = secrets !== void 0 ? withSecretAwareSettings(context, {
6574
+ secrets,
6575
+ addonTree: () => this.addonSecretTree(),
6576
+ deviceTree: () => this.deviceSecretTree(),
6577
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6578
+ isOperatorWrite: () => this._operatorWriteDepth > 0
6579
+ }) : context;
6018
6580
  await this.resolveConfig();
6581
+ if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
6582
+ if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
6583
+ });
6019
6584
  const result = await this.onInitialize();
6020
6585
  this.emitLifecycle(EventCategory.AddonStarted);
6021
6586
  const normalized = normalizeAddonInitResult(result);
@@ -6048,6 +6613,12 @@ var BaseAddon = class {
6048
6613
  */
6049
6614
  async onHubReachable() {}
6050
6615
  async shutdown() {
6616
+ this._secretChangeUnsub?.();
6617
+ this._secretChangeUnsub = null;
6618
+ if (this._secretRetryTimer !== null) clearTimeout(this._secretRetryTimer);
6619
+ if (this._secretChangeTimer !== null) clearTimeout(this._secretChangeTimer);
6620
+ this._secretRetryTimer = null;
6621
+ this._secretChangeTimer = null;
6051
6622
  this.emitLifecycle(EventCategory.AddonStopped);
6052
6623
  if (this.autoEmitReadiness) this.emitReadinessForProviders("down");
6053
6624
  await this.onShutdown();
@@ -6126,7 +6697,7 @@ var BaseAddon = class {
6126
6697
  return hydrateSchema(schema, overlay ? {
6127
6698
  ...projected,
6128
6699
  ...overlay
6129
- } : projected);
6700
+ } : projected, { inlineSecretsAsViews: true });
6130
6701
  }
6131
6702
  /**
6132
6703
  * The integration-level view of this addon's settings: exactly the sections
@@ -6175,7 +6746,7 @@ var BaseAddon = class {
6175
6746
  return hydrateSchema({
6176
6747
  ...schema,
6177
6748
  sections
6178
- }, projected);
6749
+ }, projected, { inlineSecretsAsViews: true });
6179
6750
  }
6180
6751
  /**
6181
6752
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
@@ -6229,18 +6800,50 @@ var BaseAddon = class {
6229
6800
  value: result.value[key]
6230
6801
  };
6231
6802
  }
6803
+ /**
6804
+ * The OPERATOR's write — a settings form or an admin API call, dispatched by
6805
+ * the kernel. Identical to {@link updateGlobalSettings}, except that a secret
6806
+ * the operator sends is stored as sent even when it equals a pre-keychain
6807
+ * inline value: the operator re-entering a password is a change, an addon
6808
+ * writing back what it read is not (D787).
6809
+ */
6810
+ async updateGlobalSettingsAsOperator(patch, nodeId) {
6811
+ this._operatorWriteDepth++;
6812
+ try {
6813
+ await this.applyGlobalPatch(patch, nodeId);
6814
+ } finally {
6815
+ this._operatorWriteDepth--;
6816
+ }
6817
+ }
6232
6818
  async updateGlobalSettings(patch, nodeId) {
6819
+ await this.applyGlobalPatch(patch, nodeId);
6820
+ }
6821
+ /**
6822
+ * REMOVE stored secrets — their keychain values and their markers (D787).
6823
+ *
6824
+ * Writing `''` to a secret field KEEPS what is stored (an empty string is
6825
+ * what a defaults fallback writes back, and it must never destroy a
6826
+ * credential), so code that means "forget this token" says so here. Without
6827
+ * a keychain (an older kernel) it writes `''`, as such code always did.
6828
+ */
6829
+ async clearSecrets(keys, nodeId) {
6830
+ const tree = this.addonSecretTree();
6831
+ const keychain = this._ctx?.secrets !== void 0;
6832
+ const patch = {};
6833
+ for (const key of keys) patch[key] = keychain && tree.has(key) ? SECRET_CLEAR : "";
6834
+ await this.applyGlobalPatch(patch, nodeId);
6835
+ }
6836
+ async applyGlobalPatch(barePatch, nodeId) {
6233
6837
  const keys = this.perNodeKeys();
6234
6838
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6235
6839
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6236
- const barePatch = patch;
6237
6840
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
6238
6841
  await this._ctx?.settings?.writeAddonStore(scoped);
6239
6842
  if (target !== localNode) return;
6240
6843
  await this.resolveConfig();
6241
6844
  await this.onConfigChanged();
6242
6845
  this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
6243
- this.maybeAutoRestart(patch, this.globalSettingsSchema());
6846
+ this.maybeAutoRestart(Object.keys(barePatch), this.globalSettingsSchema());
6244
6847
  }
6245
6848
  /**
6246
6849
  * The set of field keys the global settings schema declares `perNode: true`
@@ -6265,7 +6868,7 @@ var BaseAddon = class {
6265
6868
  * time to return its response before the addon is torn down and
6266
6869
  * re-initialised by `AddonRegistryService.restartAddon`.
6267
6870
  */
6268
- maybeAutoRestart(patch, schema) {
6871
+ maybeAutoRestart(patchKeys, schema) {
6269
6872
  if (!schema) return;
6270
6873
  const restartKeys = /* @__PURE__ */ new Set();
6271
6874
  for (const section of schema.sections) for (const field of section.fields) {
@@ -6273,13 +6876,13 @@ var BaseAddon = class {
6273
6876
  if (field.requiresRestart) restartKeys.add(field.key);
6274
6877
  }
6275
6878
  if (restartKeys.size === 0) return;
6276
- if (!Object.keys(patch).some((k) => restartKeys.has(k))) return;
6879
+ if (!patchKeys.some((k) => restartKeys.has(k))) return;
6277
6880
  const ctx = this._ctx;
6278
6881
  if (!ctx) return;
6279
6882
  const addonId = ctx.id;
6280
6883
  setImmediate(() => {
6281
6884
  ctx.api.addons?.restartAddon?.mutate({ addonId }).then(() => {
6282
- ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: Object.keys(patch).filter((k) => restartKeys.has(k)) } });
6885
+ ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
6283
6886
  }).catch((err) => {
6284
6887
  ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
6285
6888
  });
@@ -6288,7 +6891,7 @@ var BaseAddon = class {
6288
6891
  async getDeviceSettings(deviceId) {
6289
6892
  const schema = this.deviceSettingsSchema();
6290
6893
  if (!schema) return { sections: [] };
6291
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {});
6894
+ return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
6292
6895
  }
6293
6896
  async updateDeviceSettings(deviceId, patch) {
6294
6897
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -6418,7 +7021,7 @@ var BaseAddon = class {
6418
7021
  * selection at boot (absent scoped key ⇒ the constructor default wins).
6419
7022
  */
6420
7023
  async resolveConfig() {
6421
- const stored = await this.readAddonStoreWithRetry();
7024
+ const stored = await this.resolveStoredSecrets(await this.readAddonStoreWithRetry());
6422
7025
  const perNode = this.perNodeKeys();
6423
7026
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6424
7027
  const resolved = { ...this.defaults };
@@ -6443,7 +7046,7 @@ var BaseAddon = class {
6443
7046
  key,
6444
7047
  schema,
6445
7048
  fallback,
6446
- read: () => this.readAddonStoreWithRetry(),
7049
+ read: async () => this.resolveStoredSecrets(await this.readAddonStoreWithRetry()),
6447
7050
  write: async (patch) => {
6448
7051
  await this._ctx?.settings?.writeAddonStore(patch);
6449
7052
  },
@@ -6460,7 +7063,7 @@ var BaseAddon = class {
6460
7063
  key,
6461
7064
  schema,
6462
7065
  fallback,
6463
- read: async () => await this._ctx?.settings?.readDeviceStore(deviceId) ?? {},
7066
+ read: async () => this.resolveStoredSecrets(await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, false),
6464
7067
  write: async (patch) => {
6465
7068
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
6466
7069
  },
@@ -6472,6 +7075,70 @@ var BaseAddon = class {
6472
7075
  } })
6473
7076
  });
6474
7077
  }
7078
+ /** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
7079
+ addonSecretTree() {
7080
+ this._addonSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.globalSettingsSchema()), this.secretStatePaths);
7081
+ return this._addonSecretTree;
7082
+ }
7083
+ deviceSecretTree() {
7084
+ this._deviceSecretTree ??= secretTreeFromSchema(this.deviceSettingsSchema());
7085
+ return this._deviceSecretTree;
7086
+ }
7087
+ /**
7088
+ * Secrets of this addon's stored config that could not be resolved on the
7089
+ * last read, with why. Non-empty means the addon is running WITHOUT them —
7090
+ * an addon whose function needs one should report itself degraded rather
7091
+ * than start on an empty credential.
7092
+ */
7093
+ get unresolvedSecrets() {
7094
+ return this._unresolvedSecrets;
7095
+ }
7096
+ /**
7097
+ * Substitute every keychain marker in a stored blob with its value. With no
7098
+ * keychain (no `ctx.secrets`) or no marker, the blob comes back unchanged.
7099
+ * An unresolvable value is LEFT OUT (never `''`), logged by ref — never by
7100
+ * value — and, when the cause can pass, retried with backoff. Nothing is
7101
+ * ever written back from here.
7102
+ */
7103
+ async resolveStoredSecrets(blob, trackForConfig = true) {
7104
+ const secrets = this._ctx?.secrets;
7105
+ if (secrets === void 0) return blob;
7106
+ const refs = collectSecretMarkerRefs(blob);
7107
+ if (trackForConfig) this._configSecretRefs = new Set(refs);
7108
+ if (refs.length === 0) {
7109
+ if (trackForConfig) this._unresolvedSecrets = [];
7110
+ return blob;
7111
+ }
7112
+ const { value, unresolved } = await resolveSecretMarkers(blob, secrets);
7113
+ if (trackForConfig) {
7114
+ this._unresolvedSecrets = unresolved;
7115
+ if (unresolved.length > 0) {
7116
+ this._ctx?.logger?.error?.("secret unavailable — running without it, will retry", { meta: { secrets: unresolved.map((u) => ({
7117
+ ref: u.ref,
7118
+ reason: u.reason
7119
+ })) } });
7120
+ if (unresolved.some((u) => u.reason !== "missing" && u.reason !== "forbidden")) {
7121
+ this.scheduleSecretReresolve(this._secretRetryDelayMs);
7122
+ this._secretRetryDelayMs = Math.min(this._secretRetryDelayMs * 2, SECRET_RETRY_MAX_MS);
7123
+ }
7124
+ } else this._secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
7125
+ }
7126
+ return value;
7127
+ }
7128
+ /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
7129
+ scheduleSecretReresolve(delayMs) {
7130
+ const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
7131
+ if (this[timerOf] !== null) return;
7132
+ const timer = setTimeout(() => {
7133
+ this[timerOf] = null;
7134
+ if (this._ctx === null) return;
7135
+ this.resolveConfig().then(() => this.onConfigChanged()).catch((err) => {
7136
+ this._ctx?.logger?.error?.("re-resolving secrets failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
7137
+ });
7138
+ }, delayMs);
7139
+ timer.unref?.();
7140
+ this[timerOf] = timer;
7141
+ }
6475
7142
  /**
6476
7143
  * Wrap `ctx.settings.readAddonStore()` with a short retry budget so a
6477
7144
  * transient settings-store outage (mid-restart of sqlite-settings, tsx-watch
@@ -13971,6 +14638,214 @@ id: union([string(), number()]) }), {
13971
14638
  kind: "mutation",
13972
14639
  auth: "admin"
13973
14640
  });
14641
+ /**
14642
+ * `keychain` — the hub's encrypted store of secret values (D787).
14643
+ *
14644
+ * Settings blobs never hold a secret: they hold a marker
14645
+ * `{"$secret":"secret://<owner>/<scope>/<fieldPath>","v":1}` and the value
14646
+ * lives here, AES-256-GCM under a data key that a master key wraps. This cap
14647
+ * is the OWNER's door to its own values: every method is owner-checked
14648
+ * against the CALLER, never against anything the caller claims.
14649
+ *
14650
+ * Who the caller is: the transport stamps `callerAddonId` into the args of a
14651
+ * call that crossed a process (the parent `LocalChildRegistry` from the UDS
14652
+ * connection, the agent from its child's connection carried in
14653
+ * `$hub-cap-fwd`'s envelope). A stamp always overwrites; a wire call with no
14654
+ * stamp has its claim stripped. Only a hub in-process caller may state its own
14655
+ * identity — `ctx.secrets` does that with the addon id closed over. This is
14656
+ * identity against BUGS and misrouting, not against a malicious addon (every
14657
+ * runner is the same OS user): see the threat model in
14658
+ * `docs/design/2026-10-08-secrets-keychain.md`.
14659
+ *
14660
+ * `callerAddonId` is deliberately NOT in any input schema: the tRPC router
14661
+ * parses the input, so a session can never supply it, and the internal mount
14662
+ * floors every method to admin anyway (D240).
14663
+ *
14664
+ * Internal: addons reach it through `ctx.secrets`, never directly.
14665
+ */
14666
+ /** Why a value cannot be served right now. Never folded into "missing". */
14667
+ var KeychainUnavailableReasonSchema = _enum([
14668
+ "key-missing",
14669
+ "wrong-key",
14670
+ "key-file-unreadable",
14671
+ "store-unavailable",
14672
+ "not-initialized",
14673
+ "decrypt-failed"
14674
+ ]);
14675
+ var KeychainStateSchema = discriminatedUnion("state", [object({ state: literal("ready") }), object({
14676
+ state: literal("locked"),
14677
+ reason: KeychainUnavailableReasonSchema
14678
+ })]);
14679
+ var KeychainResolveEntrySchema = discriminatedUnion("kind", [
14680
+ object({
14681
+ kind: literal("value"),
14682
+ value: string(),
14683
+ version: number().int()
14684
+ }),
14685
+ object({ kind: literal("missing") }),
14686
+ object({
14687
+ kind: literal("unavailable"),
14688
+ reason: KeychainUnavailableReasonSchema
14689
+ }),
14690
+ object({ kind: literal("forbidden") })
14691
+ ]);
14692
+ var KeychainResolveResultSchema = record(string(), KeychainResolveEntrySchema);
14693
+ /** Metadata of one stored value — never the value. */
14694
+ var KeychainSecretMetaSchema = object({
14695
+ ref: string(),
14696
+ owner: string(),
14697
+ /** Formatted scope (`global`, `node/<id>`, `device/<id>`, …). */
14698
+ scope: string(),
14699
+ fieldPath: string(),
14700
+ version: number().int(),
14701
+ createdAt: number(),
14702
+ updatedAt: number(),
14703
+ /** `addon:<id>` | `user:<id>` | `system`. */
14704
+ updatedBy: string(),
14705
+ /** Coarse — written at most once an hour per ref. `null` = never read. */
14706
+ lastReadAt: number().nullable()
14707
+ });
14708
+ var RefListSchema = array(string().min(1)).max(512);
14709
+ method(object({
14710
+ ref: string().min(1),
14711
+ value: string().min(1)
14712
+ }), object({
14713
+ ref: string(),
14714
+ version: number().int()
14715
+ }), {
14716
+ kind: "mutation",
14717
+ auth: "admin"
14718
+ }), method(object({ refs: RefListSchema }), KeychainResolveResultSchema, { auth: "admin" }), method(object({ refs: RefListSchema }), object({ deleted: number().int() }), {
14719
+ kind: "mutation",
14720
+ auth: "admin"
14721
+ }), method(object({}), array(KeychainSecretMetaSchema).readonly(), { auth: "admin" }), method(object({}), KeychainStateSchema, { auth: "admin" });
14722
+ var KeychainKeySourceSchema = object({
14723
+ kind: _enum([
14724
+ "config-file",
14725
+ "previous-config-file",
14726
+ "platform",
14727
+ "default-file"
14728
+ ]),
14729
+ /** File sources only — a path is not a secret. */
14730
+ path: string().optional(),
14731
+ /**
14732
+ * True when a whole-volume backup of the data directory carries this key
14733
+ * next to the database it protects (the default file). The page warns.
14734
+ */
14735
+ sharesBackupWithDatabase: boolean()
14736
+ });
14737
+ var KeychainStatusSchema = object({
14738
+ keychain: KeychainStateSchema,
14739
+ /** The source of the master key in use; `null` while locked. */
14740
+ keySource: KeychainKeySourceSchema.nullable(),
14741
+ /** The source configured to be primary — differs from `keySource` while a rotation is pending. */
14742
+ configuredSource: KeychainKeySourceSchema,
14743
+ /** Short fingerprint of the master key in use (`HMAC(KEK, label)`, 16 hex). */
14744
+ fingerprint: string().nullable(),
14745
+ activeKeyId: string().nullable(),
14746
+ /**
14747
+ * The keychain unlocked with a NON-primary source: the configured primary
14748
+ * key is not the one that wraps the data key yet. `rotateMasterKey` moves it.
14749
+ */
14750
+ rotationPending: boolean(),
14751
+ /** Wrapped copies of the data key under a previous master key, kept until purged. */
14752
+ retiredWraps: number().int(),
14753
+ recoveryKeyDownloadedAt: number().nullable(),
14754
+ secretCount: number().int()
14755
+ });
14756
+ /**
14757
+ * Whether a stored value is still pointed at by its owner's settings.
14758
+ * `unknown` is a first-class answer: a scope whose blob could not be read is
14759
+ * never reported as an orphan (and never deleted as one).
14760
+ */
14761
+ var KeychainSecretUsageSchema = _enum([
14762
+ "in-use",
14763
+ "orphan",
14764
+ "unknown"
14765
+ ]);
14766
+ var KeychainAdminSecretSchema = KeychainSecretMetaSchema.extend({ usage: KeychainSecretUsageSchema });
14767
+ var KeychainAuditActionSchema = _enum([
14768
+ "put",
14769
+ "delete",
14770
+ "reveal",
14771
+ "rotate-master-key",
14772
+ "purge-retired-keys",
14773
+ "download-recovery-key",
14774
+ "delete-orphans",
14775
+ "reset",
14776
+ "initialize"
14777
+ ]);
14778
+ var KeychainAuditEntrySchema = object({
14779
+ id: string(),
14780
+ at: number(),
14781
+ action: KeychainAuditActionSchema,
14782
+ /** `addon:<id>` | `user:<id>` | `system`. */
14783
+ actor: string(),
14784
+ ref: string().nullable(),
14785
+ detail: string().nullable()
14786
+ });
14787
+ var KEYCHAIN_RESET_CONFIRMATION = "RESET KEYCHAIN";
14788
+ /**
14789
+ * Secrets the HUB itself holds (owner `system`) that no settings form shows:
14790
+ * `jwt-signing-key` — the session signing key (D797). It is always "in use",
14791
+ * never an orphan; it is generated on a fresh hub and replaced only through
14792
+ * {@link keychainAdminCapability.methods.setSystemSecret}.
14793
+ */
14794
+ var SystemHeldSecretNameSchema = _enum(["jwt-signing-key"]);
14795
+ 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({
14796
+ value: string(),
14797
+ version: number().int()
14798
+ }), {
14799
+ kind: "mutation",
14800
+ auth: "admin",
14801
+ caller: "required"
14802
+ }), method(object({
14803
+ name: SystemHeldSecretNameSchema,
14804
+ value: string().min(16)
14805
+ }), object({
14806
+ ref: string(),
14807
+ version: number().int()
14808
+ }), {
14809
+ kind: "mutation",
14810
+ auth: "admin",
14811
+ caller: "required"
14812
+ }), method(object({ refs: array(string().min(1)).max(1e3) }), object({
14813
+ deleted: array(string()).readonly(),
14814
+ kept: array(object({
14815
+ ref: string(),
14816
+ usage: KeychainSecretUsageSchema
14817
+ })).readonly()
14818
+ }), {
14819
+ kind: "mutation",
14820
+ auth: "admin",
14821
+ caller: "required"
14822
+ }), method(object({}), object({
14823
+ fingerprint: string(),
14824
+ keySource: KeychainKeySourceSchema
14825
+ }), {
14826
+ kind: "mutation",
14827
+ auth: "admin",
14828
+ caller: "required"
14829
+ }), method(object({}), object({ purged: number().int() }), {
14830
+ kind: "mutation",
14831
+ auth: "admin",
14832
+ caller: "required"
14833
+ }), method(object({}), object({
14834
+ key: string(),
14835
+ fingerprint: string(),
14836
+ keySource: KeychainKeySourceSchema
14837
+ }), {
14838
+ kind: "mutation",
14839
+ auth: "admin",
14840
+ caller: "required"
14841
+ }), method(object({ confirm: literal(KEYCHAIN_RESET_CONFIRMATION) }), object({
14842
+ archivedCollection: string().nullable(),
14843
+ archived: number().int()
14844
+ }), {
14845
+ kind: "mutation",
14846
+ auth: "admin",
14847
+ caller: "required"
14848
+ });
13974
14849
  method(_void(), object({
13975
14850
  id: string(),
13976
14851
  name: string(),
@@ -15202,7 +16077,11 @@ var DeviceRegisterPayloadSchema = object({
15202
16077
  var DeviceRemovePayloadSchema = object({ deviceId: number() });
15203
16078
  var DevicePersistConfigPayloadSchema = object({
15204
16079
  deviceId: number(),
15205
- data: record(string(), unknown())
16080
+ data: record(string(), unknown()),
16081
+ /** The paths the device's schema declares secret (D783), when the caller
16082
+ * knows them — those values are kept in the keychain, not the blob (D787).
16083
+ * Absent: the paths the device last reported at `registerDevice` apply. */
16084
+ secretConfigPaths: array(string()).optional()
15206
16085
  });
15207
16086
  /** What a migration actually did, per switch. `unreachable` is a first-class
15208
16087
  * answer: a camera that could not be asked is not a camera that was silenced. */
@@ -22181,8 +23060,23 @@ var RetrainMacroClassSchema = _enum([
22181
23060
  ]);
22182
23061
  /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
22183
23062
  var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
22184
- /** Did a human draw this box, or did the assist propose it? */
22185
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
23063
+ /**
23064
+ * Where a box came from. A machine-sourced box is a DRAFT on the page until
23065
+ * the operator confirms it; once saved it keeps its source as provenance.
23066
+ *
23067
+ * - `operator` — drawn by hand.
23068
+ * - `assist` — proposed by a detector run on the copy (the camera's own
23069
+ * model, or a larger teacher model).
23070
+ * - `pipeline` — the box the live pipeline actually drew on that frame, read
23071
+ * back from the track store (never a re-run).
23072
+ * - `llm` — proposed by a vision-capable LLM profile.
23073
+ */
23074
+ var RetrainAnnotationSourceSchema = _enum([
23075
+ "operator",
23076
+ "assist",
23077
+ "pipeline",
23078
+ "llm"
23079
+ ]);
22186
23080
  /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
22187
23081
  var RetrainBboxSchema = object({
22188
23082
  x: number(),
@@ -22200,7 +23094,8 @@ var RetrainBboxSchema = object({
22200
23094
  */
22201
23095
  var RetrainAnnotationSchema = object({
22202
23096
  id: string(),
22203
- trackId: string(),
23097
+ /** The frame's track. Absent on a recording still, which has none. */
23098
+ trackId: string().optional(),
22204
23099
  deviceId: number(),
22205
23100
  /** The COPY in retrain storage — never the source track's media key. */
22206
23101
  mediaKey: string(),
@@ -22249,13 +23144,47 @@ var RetrainFrameCandidateSchema = object({
22249
23144
  * fail, whatever became of the original. */
22250
23145
  copied: boolean()
22251
23146
  });
23147
+ /**
23148
+ * One box the live pipeline drew on a copied frame — what a correction starts
23149
+ * from. Derived when the frame is listed, from the track store: the subject
23150
+ * box recorded on the source media row when there is one, else the track
23151
+ * position nearest the frame's capture time. Never stored as an annotation
23152
+ * until the operator confirms it.
23153
+ */
23154
+ var RetrainPipelineBoxSchema = object({
23155
+ /** Normalised `[0,1]` against the full frame. */
23156
+ bbox: RetrainBboxSchema,
23157
+ macroClass: RetrainMacroClassSchema,
23158
+ label: string().optional(),
23159
+ subLabel: string().optional(),
23160
+ /** The detection score of the position used, when it was recorded. */
23161
+ score: number().optional(),
23162
+ /** The root model that produced the track, when it was recorded. */
23163
+ modelId: string().optional(),
23164
+ trackId: string(),
23165
+ /** `subject-box`: recorded on this very frame. `position`: the track's
23166
+ * position nearest the capture time, `deltaMs` away. */
23167
+ basis: _enum(["subject-box", "position"]),
23168
+ deltaMs: number()
23169
+ });
23170
+ /**
23171
+ * Where a retrain frame came from: a TRACK's stored media (copy-on-select),
23172
+ * or the RECORDING at an instant — the frame a model saw nothing in has no
23173
+ * track at all.
23174
+ */
23175
+ var RetrainFrameOriginSchema = _enum(["track", "recording"]);
22252
23176
  /** A frame the dataset OWNS: bytes copied at selection time. */
22253
23177
  var RetrainFrameSchema = object({
22254
23178
  frameId: string(),
22255
23179
  deviceId: number(),
22256
- trackId: string(),
22257
- /** Provenance only. It may already point at nothing — that is expected. */
22258
- sourceMediaId: number().int(),
23180
+ origin: RetrainFrameOriginSchema,
23181
+ /** The track it was copied from. Absent on a recording still. */
23182
+ trackId: string().optional(),
23183
+ /** Provenance only. It may already point at nothing — that is expected.
23184
+ * Absent on a recording still. */
23185
+ sourceMediaId: number().int().optional(),
23186
+ /** A recording still: the playhead instant it was taken at. */
23187
+ epochMs: number().optional(),
22259
23188
  sourceKind: MediaFileKindEnum,
22260
23189
  sizeBytes: number().int(),
22261
23190
  width: number().int(),
@@ -22266,7 +23195,12 @@ var RetrainFrameSchema = object({
22266
23195
  /** The operator's "every subject in this frame is boxed". Detector
22267
23196
  * evaluation keeps only complete frames: an unboxed subject would count as
22268
23197
  * a false positive. */
22269
- complete: boolean()
23198
+ complete: boolean(),
23199
+ /** The boxes the pipeline drew on this frame. Present on list answers;
23200
+ * empty when nothing the track store holds can be placed on it. */
23201
+ pipelineBoxes: array(RetrainPipelineBoxSchema).readonly().optional(),
23202
+ /** The named collections this frame belongs to. Present on list answers. */
23203
+ collectionIds: array(string()).readonly().optional()
22270
23204
  });
22271
23205
  /** Why a copy-on-select could not be honoured — named, never a silent skip. */
22272
23206
  var RetrainCopyRefusalSchema = _enum([
@@ -22297,6 +23231,11 @@ var RetrainFrameListSchema = object({
22297
23231
  var RetrainExportFilterSchema = object({
22298
23232
  deviceIds: array(number()).optional(),
22299
23233
  frameIds: array(string()).max(2e4).optional(),
23234
+ /** Only frames in at least one of these named collections. */
23235
+ collectionIds: array(string()).max(200).optional(),
23236
+ /** Exactly the frames of this dataset version (and its completeOnly). An
23237
+ * unknown id selects nothing. */
23238
+ datasetVersionId: string().optional(),
22300
23239
  batchId: string().optional(),
22301
23240
  /** Only frames the operator marked complete (all subjects boxed). */
22302
23241
  completeOnly: boolean().optional()
@@ -22361,6 +23300,170 @@ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
22361
23300
  reason: string(),
22362
23301
  detail: string().optional()
22363
23302
  })]);
23303
+ /** A named set over the retrain corpus — membership only, it owns no pixels. */
23304
+ var RetrainCollectionSchema = object({
23305
+ id: string(),
23306
+ name: string(),
23307
+ createdAt: number(),
23308
+ frameCount: number().int()
23309
+ });
23310
+ var RetrainCollectionCreateResultSchema = discriminatedUnion("kind", [object({
23311
+ kind: literal("created"),
23312
+ collection: RetrainCollectionSchema
23313
+ }), object({
23314
+ kind: literal("refused"),
23315
+ reason: _enum(["empty-name", "duplicate-name"])
23316
+ })]);
23317
+ var RetrainCollectionRenameResultSchema = discriminatedUnion("kind", [object({
23318
+ kind: literal("renamed"),
23319
+ collection: RetrainCollectionSchema
23320
+ }), object({
23321
+ kind: literal("refused"),
23322
+ reason: _enum([
23323
+ "empty-name",
23324
+ "duplicate-name",
23325
+ "unknown-collection"
23326
+ ])
23327
+ })]);
23328
+ /**
23329
+ * The outcome of adding the frame at a recording instant. Every refusal is
23330
+ * named: `still-unavailable` (not recording, a gap, or an undecodable frame —
23331
+ * `detail` says which), `still-busy` (the recorder is at its decode bound; try
23332
+ * again), `unreadable-image`, `write-failed`, `unknown-collection`.
23333
+ */
23334
+ var AddRetrainFrameFromRecordingResultSchema = discriminatedUnion("kind", [object({
23335
+ kind: literal("added"),
23336
+ collectionId: string(),
23337
+ frame: RetrainFrameSchema,
23338
+ /** The moment was already in the dataset; nothing was decoded. */
23339
+ reused: boolean()
23340
+ }), object({
23341
+ kind: literal("refused"),
23342
+ reason: _enum([
23343
+ "unknown-collection",
23344
+ "still-unavailable",
23345
+ "still-busy",
23346
+ "unreadable-image",
23347
+ "write-failed"
23348
+ ]),
23349
+ detail: string().optional()
23350
+ })]);
23351
+ /** A vision LLM profile the AI assist may use, and where it sends the frame. */
23352
+ var RetrainAssistProfileSchema = object({
23353
+ id: string(),
23354
+ name: string(),
23355
+ model: string(),
23356
+ kind: string(),
23357
+ /** `true` when the frame would leave the house (a cloud vendor, or an
23358
+ * endpoint that is not on the local network). The page confirms each such
23359
+ * run, and the provider refuses one without `allowCloud`. */
23360
+ leavesHouse: boolean()
23361
+ });
23362
+ /** A box the AI assist proposed: a draft, plus the model's own reason. */
23363
+ var RetrainLlmProposalSchema = RetrainAnnotationDraftSchema.extend({ reason: string() });
23364
+ /** What the AI assist said about a box that was already on the canvas. */
23365
+ var RetrainLlmReviewSchema = object({
23366
+ /** The `ref` the page sent the box under. */
23367
+ ref: string(),
23368
+ verdict: _enum([
23369
+ "confirmed",
23370
+ "wrong-class",
23371
+ "not-an-object",
23372
+ "uncertain"
23373
+ ]),
23374
+ suggestedClass: RetrainMacroClassSchema.optional(),
23375
+ reason: string()
23376
+ });
23377
+ /**
23378
+ * The AI assist's answer. `proposed` carries drafts (`source: 'llm'`, the
23379
+ * model and its confidence) and reviews; items the model got wrong (a box off
23380
+ * the frame, an unasked class, an unknown ref) are dropped and counted in
23381
+ * `rejected`. A whole answer that is not the schema is `malformed-answer`.
23382
+ */
23383
+ var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
23384
+ kind: literal("proposed"),
23385
+ profileId: string(),
23386
+ model: string(),
23387
+ /** The frame was sent outside the house for this answer. */
23388
+ leftHouse: boolean(),
23389
+ proposals: array(RetrainLlmProposalSchema).readonly(),
23390
+ reviews: array(RetrainLlmReviewSchema).readonly(),
23391
+ rejected: number().int()
23392
+ }), object({
23393
+ kind: literal("refused"),
23394
+ reason: _enum([
23395
+ "unknown-frame",
23396
+ "unreadable-frame",
23397
+ "unknown-profile",
23398
+ "profile-disabled",
23399
+ "no-vision",
23400
+ "cloud-not-confirmed",
23401
+ "llm-error",
23402
+ "malformed-answer"
23403
+ ]),
23404
+ detail: string().optional()
23405
+ })]);
23406
+ /** What a dataset version is cut from. Every field narrows. */
23407
+ var RetrainDatasetSelectionSchema = object({
23408
+ deviceIds: array(number()).readonly().optional(),
23409
+ collectionIds: array(string()).max(200).readonly().optional(),
23410
+ frameIds: array(string()).max(2e4).readonly().optional()
23411
+ });
23412
+ /** The counts a dataset is judged by. */
23413
+ var RetrainDatasetStatsSchema = object({
23414
+ frames: number().int(),
23415
+ completeFrames: number().int(),
23416
+ /** `completeFrames / frames`, 0..1. */
23417
+ completeness: number(),
23418
+ /** Boxes to learn (model errors excluded). */
23419
+ subjects: number().int(),
23420
+ modelErrors: number().int(),
23421
+ /** Complete frames with no subject. */
23422
+ hardNegatives: number().int(),
23423
+ /** Subjects per class × camera × day/night. */
23424
+ cells: array(object({
23425
+ macroClass: string(),
23426
+ deviceId: number(),
23427
+ lighting: _enum([
23428
+ "day",
23429
+ "night",
23430
+ "unknown"
23431
+ ]),
23432
+ subjects: number().int(),
23433
+ frames: number().int()
23434
+ })).readonly(),
23435
+ cameras: array(object({
23436
+ deviceId: number(),
23437
+ frames: number().int(),
23438
+ completeFrames: number().int()
23439
+ })).readonly()
23440
+ });
23441
+ /** An immutable dataset version, without its frame list. */
23442
+ var RetrainDatasetVersionSchema = object({
23443
+ id: string(),
23444
+ name: string(),
23445
+ createdAt: number(),
23446
+ selection: RetrainDatasetSelectionSchema,
23447
+ layout: RetrainExportLayoutSchema,
23448
+ completeOnly: boolean(),
23449
+ frameCount: number().int(),
23450
+ /** sha256 of what the frames taught when the version was frozen. */
23451
+ annotationHash: string(),
23452
+ /** The export manifest schema the version was cut under. */
23453
+ manifestSchema: string(),
23454
+ stats: RetrainDatasetStatsSchema
23455
+ });
23456
+ var CreateRetrainDatasetVersionResultSchema = discriminatedUnion("kind", [object({
23457
+ kind: literal("created"),
23458
+ version: RetrainDatasetVersionSchema
23459
+ }), object({
23460
+ kind: literal("refused"),
23461
+ reason: _enum([
23462
+ "empty-name",
23463
+ "duplicate-name",
23464
+ "no-frames"
23465
+ ])
23466
+ })]);
22364
23467
  /** The outcome of a lifecycle move owned by the retrain page. */
22365
23468
  var RetrainTransitionResultSchema = object({
22366
23469
  trackId: string(),
@@ -23078,7 +24181,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23078
24181
  auth: "admin"
23079
24182
  }), method(object({
23080
24183
  deviceId: number(),
23081
- trackId: string(),
24184
+ trackId: string().optional(),
23082
24185
  frameId: string()
23083
24186
  }), object({
23084
24187
  removed: boolean(),
@@ -23095,7 +24198,8 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23095
24198
  auth: "admin"
23096
24199
  }), method(object({
23097
24200
  deviceId: number(),
23098
- trackId: string(),
24201
+ /** The frame's track, when it has one — checked against the frame. */
24202
+ trackId: string().optional(),
23099
24203
  frameId: string(),
23100
24204
  subject: RetrainAssistSubjectSchema,
23101
24205
  /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
@@ -23103,12 +24207,16 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23103
24207
  }), RetrainAssistResultSchema, {
23104
24208
  kind: "mutation",
23105
24209
  auth: "admin"
23106
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
24210
+ }), method(object({
24211
+ trackId: string().optional(),
24212
+ frameIds: array(string()).max(2e3).optional()
24213
+ }), array(RetrainAnnotationSchema).readonly(), {
23107
24214
  kind: "query",
23108
24215
  auth: "admin"
23109
24216
  }), method(object({
23110
24217
  deviceId: number(),
23111
- trackId: string(),
24218
+ /** The frame's track, when it has one — checked against the frame. */
24219
+ trackId: string().optional(),
23112
24220
  frameId: string(),
23113
24221
  annotations: array(RetrainAnnotationDraftSchema)
23114
24222
  }), array(RetrainAnnotationSchema).readonly(), {
@@ -23131,7 +24239,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23131
24239
  auth: "admin"
23132
24240
  }), method(object({
23133
24241
  deviceId: number(),
23134
- trackId: string(),
24242
+ trackId: string().optional(),
23135
24243
  frameId: string(),
23136
24244
  complete: boolean()
23137
24245
  }), RetrainFrameSchema, {
@@ -23145,6 +24253,104 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23145
24253
  kind: "mutation",
23146
24254
  auth: "admin",
23147
24255
  timeoutMs: 60 * 6e4
24256
+ }), method(object({
24257
+ selection: RetrainDatasetSelectionSchema,
24258
+ completeOnly: boolean().optional()
24259
+ }), RetrainDatasetStatsSchema, {
24260
+ kind: "query",
24261
+ auth: "admin"
24262
+ }), method(object({
24263
+ name: string().max(120),
24264
+ selection: RetrainDatasetSelectionSchema,
24265
+ layout: RetrainExportLayoutSchema,
24266
+ completeOnly: boolean()
24267
+ }), CreateRetrainDatasetVersionResultSchema, {
24268
+ kind: "mutation",
24269
+ auth: "admin",
24270
+ timeoutMs: 12e4
24271
+ }), method(object({}), array(RetrainDatasetVersionSchema).readonly(), {
24272
+ kind: "query",
24273
+ auth: "admin"
24274
+ }), method(object({ id: string() }), object({ deleted: boolean() }), {
24275
+ kind: "mutation",
24276
+ auth: "admin"
24277
+ }), method(object({ id: string() }), object({
24278
+ found: boolean(),
24279
+ annotationHash: string(),
24280
+ matches: boolean(),
24281
+ missingFrames: number().int()
24282
+ }), {
24283
+ kind: "query",
24284
+ auth: "admin",
24285
+ timeoutMs: 12e4
24286
+ }), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
24287
+ kind: "query",
24288
+ auth: "admin"
24289
+ }), method(object({
24290
+ deviceId: number(),
24291
+ trackId: string().optional(),
24292
+ frameId: string(),
24293
+ profileId: string(),
24294
+ classes: array(RetrainMacroClassSchema).min(1),
24295
+ boxes: array(object({
24296
+ ref: string(),
24297
+ bbox: RetrainBboxSchema,
24298
+ macroClass: RetrainMacroClassSchema,
24299
+ label: string().optional()
24300
+ })).max(50),
24301
+ allowCloud: boolean()
24302
+ }), RetrainLlmAssistResultSchema, {
24303
+ kind: "mutation",
24304
+ auth: "admin",
24305
+ timeoutMs: 18e4
24306
+ }), method(object({ name: string().max(120) }), RetrainCollectionCreateResultSchema, {
24307
+ kind: "mutation",
24308
+ auth: "admin"
24309
+ }), method(object({}), array(RetrainCollectionSchema).readonly(), {
24310
+ kind: "query",
24311
+ auth: "admin"
24312
+ }), method(object({
24313
+ id: string(),
24314
+ name: string().max(120)
24315
+ }), RetrainCollectionRenameResultSchema, {
24316
+ kind: "mutation",
24317
+ auth: "admin"
24318
+ }), method(object({ id: string() }), object({
24319
+ deleted: boolean(),
24320
+ removedFrames: number().int()
24321
+ }), {
24322
+ kind: "mutation",
24323
+ auth: "admin"
24324
+ }), method(object({
24325
+ collectionId: string(),
24326
+ deviceId: number(),
24327
+ epochMs: number()
24328
+ }), AddRetrainFrameFromRecordingResultSchema, {
24329
+ kind: "mutation",
24330
+ auth: "admin",
24331
+ timeoutMs: 6e4
24332
+ }), method(object({
24333
+ collectionId: string(),
24334
+ frameIds: array(string()).min(1).max(500)
24335
+ }), object({
24336
+ added: number().int(),
24337
+ alreadyMember: number().int(),
24338
+ unknownFrameIds: array(string()).readonly()
24339
+ }), {
24340
+ kind: "mutation",
24341
+ auth: "admin"
24342
+ }), method(object({
24343
+ collectionId: string(),
24344
+ frameId: string()
24345
+ }), object({
24346
+ removed: boolean(),
24347
+ deletedFrame: boolean()
24348
+ }), {
24349
+ kind: "mutation",
24350
+ auth: "admin"
24351
+ }), method(object({ collectionId: string() }), array(RetrainFrameSchema).readonly(), {
24352
+ kind: "query",
24353
+ auth: "admin"
23148
24354
  }), method(object({
23149
24355
  /** Which of the three event tables owns the row. */
23150
24356
  ownerType: EventOwnerTypeSchema,
@@ -23768,13 +24974,31 @@ var RecommendationReasonSchema = discriminatedUnion("kind", [
23768
24974
  object({
23769
24975
  kind: literal("no-family-build"),
23770
24976
  format: ModelFormatSchema$1
24977
+ }),
24978
+ object({
24979
+ kind: literal("kept-custom-pin"),
24980
+ modelId: string(),
24981
+ deviceKey: string()
23771
24982
  })
23772
24983
  ]);
24984
+ /** Why a device is left exactly as it is, whatever the plan would pick (D786). */
24985
+ var KeptReasonSchema = _enum(["custom-pin"]);
24986
+ /**
24987
+ * Where a choice's latency came from (D791): this node's own benchmark
24988
+ * result, or the hardware-class table. Measured on the node beats the table.
24989
+ */
24990
+ var LatencySourceSchema = discriminatedUnion("kind", [object({ kind: literal("table") }), object({
24991
+ kind: literal("node-benchmark"),
24992
+ resultId: string(),
24993
+ measuredAtMs: number()
24994
+ })]);
23773
24995
  var DeviceModelChoiceSchema = object({
23774
24996
  modelId: string(),
23775
24997
  p50Ms: number(),
23776
24998
  fps: number(),
23777
24999
  measured: boolean(),
25000
+ /** Absent on a plan from before D791 — read as the table. */
25001
+ source: LatencySourceSchema.optional(),
23778
25002
  /** Parallel sessions at the camera rate with the headroom kept free: ⌊fps × (1 − headroom) / camera fps⌋. */
23779
25003
  capacitySessions: number(),
23780
25004
  personRecall: number()
@@ -23785,6 +25009,8 @@ var DeviceRecommendationSchema = object({
23785
25009
  enabled: boolean(),
23786
25010
  available: boolean(),
23787
25011
  chosen: DeviceModelChoiceSchema.nullable(),
25012
+ /** Present when the device is kept as is: Apply writes nothing on it. */
25013
+ kept: KeptReasonSchema.optional(),
23788
25014
  reasons: array(RecommendationReasonSchema).readonly()
23789
25015
  });
23790
25016
  var NodeRecommendationSchema = object({
@@ -23838,6 +25064,17 @@ var AutoTuneWarningSchema = discriminatedUnion("kind", [
23838
25064
  kind: literal("coral-enabled"),
23839
25065
  nodeId: string(),
23840
25066
  deviceKey: string()
25067
+ }),
25068
+ object({
25069
+ kind: literal("custom-pin-kept"),
25070
+ nodeId: string(),
25071
+ deviceKey: string().nullable(),
25072
+ deviceId: number().nullable(),
25073
+ modelId: string()
25074
+ }),
25075
+ object({
25076
+ kind: literal("custom-registry-unreadable"),
25077
+ error: string()
23841
25078
  })
23842
25079
  ]);
23843
25080
  var AutoTuneOptionsSchema = object({
@@ -24016,13 +25253,14 @@ var SuggestSharesResultSchema = object({
24016
25253
  nodes: array(SuggestedNodeShareSchema).readonly()
24017
25254
  });
24018
25255
  /**
24019
- * Where the node and device shares come from (D750, D755).
24020
- * - `hardware` (default) — computed by the system from each node's static
24021
- * capacity (its accelerators at their Auto tune models, from the measured
24022
- * latency table), recomputed whenever a node or device joins, leaves, is
24023
- * switched on or off, or changes model. No load input.
24024
- * - `benchmark` — the same, from each node's measured capacity (node
24025
- * benchmark results); a node without results falls back to `hardware`.
25256
+ * Where the node and device shares come from (D750, D755, D791).
25257
+ * - `benchmark` (default since D791) — each node's capacity as its own node
25258
+ * benchmark measured it; a node without fresh results is sized from
25259
+ * `hardware` and says so. Measured on the node beats the table.
25260
+ * - `hardware` — computed from each node's static capacity only (its
25261
+ * accelerators at their Auto tune models, from the latency table).
25262
+ * Both are recomputed whenever a node or device joins, leaves, is switched
25263
+ * on or off, changes model, or a benchmark result is written. No load input.
24026
25264
  * - `manual` — the operator's stored sliders.
24027
25265
  * Either way a node or device that cannot take sessions gives its share to
24028
25266
  * the others in proportion; the stored values are never rewritten for that.
@@ -24071,6 +25309,362 @@ var EffectiveSharesSchema = object({
24071
25309
  nodeWeights: record(string(), number()),
24072
25310
  deviceWeights: record(string(), record(string(), number()))
24073
25311
  });
25312
+ /**
25313
+ * Wire shapes of the node benchmark (D791): the operator's plan, the
25314
+ * preflight the confirmation shows, the run the orchestrator owns, what the
25315
+ * measuring runner reports, and the result rows Auto tune and the automatic
25316
+ * shares read.
25317
+ *
25318
+ * ONE node at a time, owned by the pipeline orchestrator. While a run is
25319
+ * active the cluster is in BENCHMARK MODE for that node: it is not a
25320
+ * detection candidate, camera pins naming it are ignored so its sessions move
25321
+ * elsewhere, and both come back when the mode ends — after a crash or a hub
25322
+ * restart too (a persisted manifest, reconciled against the registry).
25323
+ *
25324
+ * Two measurements, both on the node, driven by its own runner (frames never
25325
+ * cross a process at frame rate, D9):
25326
+ * - `device` — one accelerator × one candidate detector, root only, open
25327
+ * loop: how many streams at the camera rate it carries inside the frame
25328
+ * interval;
25329
+ * - `pipeline` — the chosen detector plus the operator's detail steps
25330
+ * (faces, plates, classifiers, CLIP…), on varied frames from the bench
25331
+ * clip: how many parallel sessions the node carries before latency, drops,
25332
+ * CPU, RAM or the event loop give out.
25333
+ */
25334
+ /** Defaults and bounds, one place. */
25335
+ var NODE_BENCHMARK_DEFAULTS = {
25336
+ fpsPerStream: 10,
25337
+ budgetMinutes: 45,
25338
+ minBudgetMinutes: 10,
25339
+ maxBudgetMinutes: 120,
25340
+ /** A result older than this no longer beats the table. */
25341
+ staleAfterDays: 30,
25342
+ /** Warm-in per ramp step (not accounted). */
25343
+ settleSec: 5,
25344
+ /** Accounted window per ramp step. */
25345
+ measureSec: 20,
25346
+ /** Longest the drain may take before the run is refused. */
25347
+ drainTimeoutSec: 120,
25348
+ /** Candidate models per device in one run. */
25349
+ maxModelsPerDevice: 6
25350
+ };
25351
+ /** The two measurements a run can make. */
25352
+ var NodeBenchmarkPhaseSchema = _enum(["device", "pipeline"]);
25353
+ var NodeBenchmarkDevicePlanSchema = object({
25354
+ /** `<backend>:<device>` — `openvino:npu`, `coreml:all`, `cpu`. */
25355
+ deviceKey: string().min(1),
25356
+ /**
25357
+ * Root detector candidates for the `device` measurement, in the order
25358
+ * measured. The FIRST is the one the `pipeline` measurement runs.
25359
+ */
25360
+ modelIds: array(string().min(1)).min(1).max(NODE_BENCHMARK_DEFAULTS.maxModelsPerDevice)
25361
+ });
25362
+ /** What the operator confirmed. */
25363
+ var NodeBenchmarkPlanSchema = object({
25364
+ nodeId: string().min(1),
25365
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
25366
+ /** Which measurements run. At least one. */
25367
+ phases: array(NodeBenchmarkPhaseSchema).min(1).default(["device", "pipeline"]),
25368
+ /**
25369
+ * Detail steps (catalog step ids under the root: faces, plates,
25370
+ * classifiers, CLIP…) the `pipeline` measurement enables. The root
25371
+ * detector always runs.
25372
+ */
25373
+ steps: array(string().min(1)).default([]),
25374
+ /** Offered rate of one stream / session. */
25375
+ fpsPerStream: number().int().min(1).max(30).default(NODE_BENCHMARK_DEFAULTS.fpsPerStream),
25376
+ /** Hard deadline: the mode ends and the cluster is restored when it passes. */
25377
+ budgetMinutes: number().int().min(NODE_BENCHMARK_DEFAULTS.minBudgetMinutes).max(NODE_BENCHMARK_DEFAULTS.maxBudgetMinutes).default(NODE_BENCHMARK_DEFAULTS.budgetMinutes),
25378
+ /** Keep the models the run downloaded (default: delete what was not installed before). */
25379
+ keepDownloadedModels: boolean().default(false),
25380
+ /** Start although the other nodes' capacity does not cover the sessions running now. */
25381
+ acceptInsufficientHeadroom: boolean().default(false)
25382
+ });
25383
+ var NodeBenchmarkRefusalSchema = object({
25384
+ kind: _enum([
25385
+ "benchmark-active",
25386
+ "node-offline",
25387
+ "unknown-device",
25388
+ "no-phase",
25389
+ "insufficient-headroom"
25390
+ ]),
25391
+ detail: string(),
25392
+ overridable: boolean()
25393
+ });
25394
+ /** A camera whose detection leaves the node for the run. */
25395
+ var NodeBenchmarkMovingCameraSchema = object({
25396
+ deviceId: number(),
25397
+ /** Placed on the node now (a standing attach or a running session). */
25398
+ placedOnNode: boolean(),
25399
+ /** A node pin naming this node, ignored for the run. */
25400
+ pinnedToNode: boolean()
25401
+ });
25402
+ /** A camera that cannot leave: no other node can obtain its frames. */
25403
+ var NodeBenchmarkStayingCameraSchema = object({
25404
+ deviceId: number(),
25405
+ reason: literal("only-frame-source")
25406
+ });
25407
+ var NodeBenchmarkPreflightSchema = object({
25408
+ nodeId: string(),
25409
+ online: boolean(),
25410
+ moving: array(NodeBenchmarkMovingCameraSchema).readonly(),
25411
+ /** Keep running on the node during the run; the result is flagged contaminated. */
25412
+ staying: array(NodeBenchmarkStayingCameraSchema).readonly(),
25413
+ estimatedDurationMs: number(),
25414
+ /** The run ends and the cluster is restored at the latest after this long. */
25415
+ budgetMs: number(),
25416
+ phases: array(NodeBenchmarkPhaseSchema).readonly(),
25417
+ steps: array(string()).readonly(),
25418
+ devices: array(NodeBenchmarkDevicePlanSchema).readonly(),
25419
+ /** Parallel sessions the cluster runs now, and what the other nodes can carry. */
25420
+ headroom: object({
25421
+ sessionsNow: number(),
25422
+ otherNodesCapacitySessions: number().nullable()
25423
+ }),
25424
+ refusals: array(NodeBenchmarkRefusalSchema).readonly(),
25425
+ canStart: boolean()
25426
+ });
25427
+ /** Where the measuring runner is. */
25428
+ var NodeBenchProgressSchema = object({
25429
+ phase: _enum([
25430
+ "preparing",
25431
+ "device",
25432
+ "pipeline",
25433
+ "cleanup"
25434
+ ]),
25435
+ deviceKey: string().nullable(),
25436
+ modelId: string().nullable(),
25437
+ /** Streams (device) or sessions (pipeline) of the step running now. */
25438
+ load: number().nullable(),
25439
+ cellsDone: number(),
25440
+ cellsTotal: number(),
25441
+ message: string()
25442
+ });
25443
+ /** What limited a ramp. `none` = the ramp ran out of steps still passing. */
25444
+ var NodeBenchLimitSchema = _enum([
25445
+ "p95",
25446
+ "drops",
25447
+ "errors",
25448
+ "stall",
25449
+ "cpu",
25450
+ "ram",
25451
+ "none"
25452
+ ]);
25453
+ var NodeBenchRampStepSchema = object({
25454
+ load: number(),
25455
+ pass: boolean(),
25456
+ p95Ms: number(),
25457
+ dropRatio: number(),
25458
+ /** Completed frames per second over the accounted window. */
25459
+ fps: number(),
25460
+ cpuPct: number().nullable(),
25461
+ ramFreePct: number().nullable(),
25462
+ failReasons: array(string()).readonly()
25463
+ });
25464
+ var NodeBenchCellSchema = discriminatedUnion("phase", [object({
25465
+ phase: literal("device"),
25466
+ deviceKey: string(),
25467
+ modelId: string(),
25468
+ /** Single-stream latency (the K = 1 step). */
25469
+ p50Ms: number(),
25470
+ p95Ms: number(),
25471
+ p99Ms: number(),
25472
+ /** Frames per second sustained at the last passing step. */
25473
+ fps: number(),
25474
+ /** Streams at the camera rate the device carried inside the frame interval; 0 = not even one. */
25475
+ kMax: number(),
25476
+ limitedBy: NodeBenchLimitSchema,
25477
+ /** First call (model load + warm-up). */
25478
+ warmupMs: number(),
25479
+ ramp: array(NodeBenchRampStepSchema).readonly()
25480
+ }), object({
25481
+ phase: literal("pipeline"),
25482
+ deviceKey: string(),
25483
+ modelId: string(),
25484
+ steps: array(string()).readonly(),
25485
+ /** Parallel sessions at the camera rate the node carried; 0 = not even one. */
25486
+ maxSessions: number(),
25487
+ limitedBy: NodeBenchLimitSchema,
25488
+ /** Detail steps that produced at least one result on the clip — a step that never fired measured nothing. */
25489
+ stepsFired: array(string()).readonly(),
25490
+ warmupMs: number(),
25491
+ ramp: array(NodeBenchRampStepSchema).readonly()
25492
+ })]);
25493
+ /**
25494
+ * What a result was measured ON. A result whose fingerprint no longer matches
25495
+ * the node no longer beats the table.
25496
+ */
25497
+ var NodeBenchFingerprintSchema = object({
25498
+ pipelineVersion: string().nullable(),
25499
+ cpuModel: string().nullable(),
25500
+ ramGb: number().nullable(),
25501
+ os: string().nullable(),
25502
+ /** Per device: the pool the cells ran on (runtime + tuning). */
25503
+ pools: record(string(), object({
25504
+ runtime: string(),
25505
+ numWorkers: number(),
25506
+ concurrency: number(),
25507
+ batchMode: string()
25508
+ })).default({})
25509
+ });
25510
+ /** The frames the run used. */
25511
+ var NodeBenchClipSchema = object({
25512
+ /** `camstack-bench-v1` or `reference-images` (the fallback when the clip is not reachable). */
25513
+ id: string(),
25514
+ revision: string().nullable(),
25515
+ frames: number(),
25516
+ width: number(),
25517
+ height: number()
25518
+ });
25519
+ var NodeBenchRunnerInputSchema = object({
25520
+ runId: string().min(1),
25521
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
25522
+ phases: array(NodeBenchmarkPhaseSchema).min(1),
25523
+ /** The full detail step tree root for the `pipeline` measurement is built on the node from these ids. */
25524
+ steps: array(string()).default([]),
25525
+ fpsPerStream: number().int().min(1).max(30),
25526
+ /** The runner stops on its own past this instant, whatever the hub does. */
25527
+ deadlineAtMs: number(),
25528
+ settleSec: number().min(0).max(60).default(NODE_BENCHMARK_DEFAULTS.settleSec),
25529
+ measureSec: number().min(2).max(300).default(NODE_BENCHMARK_DEFAULTS.measureSec),
25530
+ keepDownloadedModels: boolean().default(false)
25531
+ });
25532
+ var NodeBenchRunnerStateSchema = _enum([
25533
+ "running",
25534
+ "done",
25535
+ "failed",
25536
+ "aborted"
25537
+ ]);
25538
+ var NodeBenchRunnerStatusSchema = object({
25539
+ runId: string(),
25540
+ nodeId: string(),
25541
+ state: NodeBenchRunnerStateSchema,
25542
+ progress: NodeBenchProgressSchema.nullable(),
25543
+ /** Every finished cell so far — a run stopped half way keeps what it measured. */
25544
+ cells: array(NodeBenchCellSchema).readonly(),
25545
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
25546
+ clip: NodeBenchClipSchema.nullable(),
25547
+ /** Cameras seen running on the node during the run (they share its pools). */
25548
+ activeCameraIds: array(number()).readonly(),
25549
+ /** Models the run downloaded and then deleted (not installed before). */
25550
+ deletedModels: array(string()).readonly(),
25551
+ error: string().nullable(),
25552
+ startedAtMs: number(),
25553
+ finishedAtMs: number().nullable()
25554
+ });
25555
+ var NodeBenchmarkStateSchema = _enum([
25556
+ "draining",
25557
+ "measuring",
25558
+ "restoring",
25559
+ "done",
25560
+ "failed",
25561
+ "aborted"
25562
+ ]);
25563
+ /** Why a run ended. */
25564
+ var NodeBenchmarkEndReasonSchema = _enum([
25565
+ "completed",
25566
+ "operator-abort",
25567
+ "deadline",
25568
+ "node-lost",
25569
+ "runner-lost",
25570
+ "hub-restart",
25571
+ "drain-timeout",
25572
+ "failed"
25573
+ ]);
25574
+ var NodeBenchmarkRunSchema = object({
25575
+ runId: string(),
25576
+ nodeId: string(),
25577
+ state: NodeBenchmarkStateSchema,
25578
+ plan: NodeBenchmarkPlanSchema,
25579
+ startedAtMs: number(),
25580
+ deadlineAtMs: number(),
25581
+ finishedAtMs: number().nullable(),
25582
+ endReason: NodeBenchmarkEndReasonSchema.nullable(),
25583
+ error: string().nullable(),
25584
+ /** Cameras moved off the node for the run. */
25585
+ moved: array(number()).readonly(),
25586
+ /** Cameras that stayed (their only frame source is the node). */
25587
+ staying: array(number()).readonly(),
25588
+ /** Something else ran on the node's pools during the run. */
25589
+ contaminated: boolean(),
25590
+ progress: NodeBenchProgressSchema.nullable(),
25591
+ resultIds: array(string()).readonly()
25592
+ });
25593
+ /** `getNodeBenchmarkStatus`: the active run (or the last one), and whether benchmark mode is on. */
25594
+ var NodeBenchmarkStatusSchema = object({
25595
+ /** The node the cluster is in benchmark mode for; null = none. */
25596
+ modeNodeId: string().nullable(),
25597
+ run: NodeBenchmarkRunSchema.nullable()
25598
+ });
25599
+ /**
25600
+ * One stored measurement — the only authority Auto tune and the automatic
25601
+ * shares read measured capacity from. Written by the orchestrator when a run
25602
+ * ends, never by anyone else.
25603
+ */
25604
+ var NodeBenchmarkResultSchema = object({
25605
+ id: string(),
25606
+ runId: string(),
25607
+ nodeId: string(),
25608
+ cell: NodeBenchCellSchema,
25609
+ fpsPerStream: number(),
25610
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
25611
+ clip: NodeBenchClipSchema.nullable(),
25612
+ /** Other work shared the node's pools (a camera that could not move, or the hub's own duties). */
25613
+ contaminated: boolean(),
25614
+ stayingCameras: array(number()).readonly(),
25615
+ /** The run ended early; the cell itself completed. */
25616
+ partialRun: boolean(),
25617
+ measuredAtMs: number()
25618
+ });
25619
+ var ListNodeBenchmarkResultsInputSchema = object({
25620
+ nodeId: string().optional(),
25621
+ deviceKey: string().optional()
25622
+ });
25623
+ /** A result with its standing today: does it still beat the table? */
25624
+ var NodeBenchmarkResultViewSchema = NodeBenchmarkResultSchema.extend({
25625
+ /** `fresh` beats the table; `stale` falls back to it; `superseded` = a newer row covers the same cell. */
25626
+ standing: _enum([
25627
+ "fresh",
25628
+ "stale",
25629
+ "superseded"
25630
+ ]),
25631
+ staleWhy: _enum([
25632
+ "age",
25633
+ "runtime",
25634
+ "pool-tuning"
25635
+ ]).nullable()
25636
+ });
25637
+ object({
25638
+ runId: string(),
25639
+ nodeId: string(),
25640
+ startedAtMs: number(),
25641
+ deadlineAtMs: number(),
25642
+ plan: NodeBenchmarkPlanSchema,
25643
+ moved: array(number()).readonly(),
25644
+ staying: array(number()).readonly()
25645
+ });
25646
+ /** Candidate detectors per device, for the plan editor. */
25647
+ var NodeBenchmarkCandidatesSchema = object({
25648
+ nodeId: string(),
25649
+ reachable: boolean(),
25650
+ devices: array(object({
25651
+ deviceKey: string(),
25652
+ enabled: boolean(),
25653
+ available: boolean(),
25654
+ /** Ordered: what Auto tune would pick first, then the rest of the family by accuracy. */
25655
+ suggested: array(string()).readonly(),
25656
+ /** Every root detector the device has a build for. */
25657
+ all: array(string()).readonly(),
25658
+ /** The model the device runs now, when pinned. */
25659
+ currentModelId: string().nullable()
25660
+ })).readonly(),
25661
+ /** Detail steps the node's catalog offers under the root (for the `pipeline` measurement). */
25662
+ steps: array(object({
25663
+ id: string(),
25664
+ name: string(),
25665
+ slot: string()
25666
+ })).readonly()
25667
+ });
24074
25668
  object({
24075
25669
  activeCameras: number(),
24076
25670
  throttledCameras: number(),
@@ -25159,7 +26753,16 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
25159
26753
  }), ParkedTrackFrameSchema.nullable()), method(object({
25160
26754
  deviceId: number(),
25161
26755
  trackId: string()
25162
- }), object({ released: number().int().nonnegative() }), { kind: "mutation" });
26756
+ }), object({ released: number().int().nonnegative() }), { kind: "mutation" }), method(NodeBenchRunnerInputSchema, object({
26757
+ accepted: literal(true),
26758
+ runId: string()
26759
+ }), {
26760
+ kind: "mutation",
26761
+ auth: "admin"
26762
+ }), method(object({ runId: string() }), NodeBenchRunnerStatusSchema.nullable(), { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
26763
+ kind: "mutation",
26764
+ auth: "admin"
26765
+ });
25163
26766
  var CameraPipelineConfigSchema = object({
25164
26767
  engine: PipelineEngineChoiceSchema.optional(),
25165
26768
  steps: array(PipelineStepInputSchema).readonly(),
@@ -25798,6 +27401,21 @@ method(object({
25798
27401
  }), method(PlacementStatsInputSchema, PlacementStatsSchema, { auth: "admin" }), method(SuggestSharesInputSchema, SuggestSharesResultSchema, { auth: "admin" }), method(_void(), EffectiveSharesSchema, { auth: "admin" }), method(SetShareSourceInputSchema, object({ success: literal(true) }), {
25799
27402
  kind: "mutation",
25800
27403
  auth: "admin"
27404
+ }), method(NodeBenchmarkPlanSchema, NodeBenchmarkPreflightSchema, { auth: "admin" }), method(NodeBenchmarkPlanSchema, discriminatedUnion("kind", [object({
27405
+ kind: literal("started"),
27406
+ runId: string()
27407
+ }), object({
27408
+ kind: literal("refused"),
27409
+ preflight: NodeBenchmarkPreflightSchema
27410
+ })]), {
27411
+ kind: "mutation",
27412
+ auth: "admin"
27413
+ }), method(_void(), NodeBenchmarkStatusSchema, { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
27414
+ kind: "mutation",
27415
+ auth: "admin"
27416
+ }), method(object({ nodeId: string() }), NodeBenchmarkCandidatesSchema, { auth: "admin" }), method(ListNodeBenchmarkResultsInputSchema, array(NodeBenchmarkResultViewSchema).readonly(), { auth: "admin" }), method(object({ id: string() }), object({ deleted: boolean() }), {
27417
+ kind: "mutation",
27418
+ auth: "admin"
25801
27419
  }), method(object({ deviceId: number() }), CameraPipelineSettingsSchema.nullable()), method(object({
25802
27420
  deviceId: number(),
25803
27421
  addonId: string(),
@@ -30983,6 +32601,9 @@ var CreateIntegrationInputSchema = object({
30983
32601
  enabled: boolean().optional(),
30984
32602
  info: record(string(), unknown()).optional(),
30985
32603
  settings: record(string(), unknown()).optional(),
32604
+ /** Keys of `settings` the form's schema declares secret (by type) — kept in
32605
+ * the keychain, not the table (D787). */
32606
+ secretKeys: array(string()).optional(),
30986
32607
  skipRestart: boolean().optional()
30987
32608
  });
30988
32609
  var UpdateIntegrationInputSchema = object({
@@ -31006,7 +32627,9 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
31006
32627
  auth: "admin"
31007
32628
  }), method(object({ id: string() }), record(string(), unknown()), { auth: "admin" }), method(object({
31008
32629
  id: string(),
31009
- settings: record(string(), unknown())
32630
+ settings: record(string(), unknown()),
32631
+ /** Keys the form's schema declares secret (by type) — keychain-stored (D787). */
32632
+ secretKeys: array(string()).optional()
31010
32633
  }), object({ success: boolean() }), {
31011
32634
  kind: "mutation",
31012
32635
  auth: "admin"
@@ -40622,6 +42245,96 @@ Object.freeze({
40622
42245
  addonId: null,
40623
42246
  access: "create"
40624
42247
  },
42248
+ "keychain.delete": {
42249
+ capName: "keychain",
42250
+ capScope: "system",
42251
+ addonId: null,
42252
+ access: "delete"
42253
+ },
42254
+ "keychain.getState": {
42255
+ capName: "keychain",
42256
+ capScope: "system",
42257
+ addonId: null,
42258
+ access: "view"
42259
+ },
42260
+ "keychain.listMeta": {
42261
+ capName: "keychain",
42262
+ capScope: "system",
42263
+ addonId: null,
42264
+ access: "view"
42265
+ },
42266
+ "keychain.put": {
42267
+ capName: "keychain",
42268
+ capScope: "system",
42269
+ addonId: null,
42270
+ access: "create"
42271
+ },
42272
+ "keychain.resolve": {
42273
+ capName: "keychain",
42274
+ capScope: "system",
42275
+ addonId: null,
42276
+ access: "view"
42277
+ },
42278
+ "keychainAdmin.deleteOrphans": {
42279
+ capName: "keychain-admin",
42280
+ capScope: "system",
42281
+ addonId: null,
42282
+ access: "delete"
42283
+ },
42284
+ "keychainAdmin.downloadRecoveryKey": {
42285
+ capName: "keychain-admin",
42286
+ capScope: "system",
42287
+ addonId: null,
42288
+ access: "create"
42289
+ },
42290
+ "keychainAdmin.listAudit": {
42291
+ capName: "keychain-admin",
42292
+ capScope: "system",
42293
+ addonId: null,
42294
+ access: "view"
42295
+ },
42296
+ "keychainAdmin.listSecrets": {
42297
+ capName: "keychain-admin",
42298
+ capScope: "system",
42299
+ addonId: null,
42300
+ access: "view"
42301
+ },
42302
+ "keychainAdmin.purgeRetiredKeys": {
42303
+ capName: "keychain-admin",
42304
+ capScope: "system",
42305
+ addonId: null,
42306
+ access: "delete"
42307
+ },
42308
+ "keychainAdmin.resetKeychain": {
42309
+ capName: "keychain-admin",
42310
+ capScope: "system",
42311
+ addonId: null,
42312
+ access: "delete"
42313
+ },
42314
+ "keychainAdmin.reveal": {
42315
+ capName: "keychain-admin",
42316
+ capScope: "system",
42317
+ addonId: null,
42318
+ access: "create"
42319
+ },
42320
+ "keychainAdmin.rotateMasterKey": {
42321
+ capName: "keychain-admin",
42322
+ capScope: "system",
42323
+ addonId: null,
42324
+ access: "create"
42325
+ },
42326
+ "keychainAdmin.setSystemSecret": {
42327
+ capName: "keychain-admin",
42328
+ capScope: "system",
42329
+ addonId: null,
42330
+ access: "create"
42331
+ },
42332
+ "keychainAdmin.status": {
42333
+ capName: "keychain-admin",
42334
+ capScope: "system",
42335
+ addonId: null,
42336
+ access: "view"
42337
+ },
40625
42338
  "lawnMowerControl.dock": {
40626
42339
  capName: "lawn-mower-control",
40627
42340
  capScope: "device",
@@ -41996,6 +43709,18 @@ Object.freeze({
41996
43709
  addonId: null,
41997
43710
  access: "create"
41998
43711
  },
43712
+ "pipelineAnalytics.addRetrainFrameFromRecording": {
43713
+ capName: "pipeline-analytics",
43714
+ capScope: "device",
43715
+ addonId: null,
43716
+ access: "create"
43717
+ },
43718
+ "pipelineAnalytics.addRetrainFramesToCollection": {
43719
+ capName: "pipeline-analytics",
43720
+ capScope: "device",
43721
+ addonId: null,
43722
+ access: "create"
43723
+ },
41999
43724
  "pipelineAnalytics.applyDeviceSettingsPatch": {
42000
43725
  capName: "pipeline-analytics",
42001
43726
  capScope: "device",
@@ -42044,12 +43769,36 @@ Object.freeze({
42044
43769
  addonId: null,
42045
43770
  access: "view"
42046
43771
  },
43772
+ "pipelineAnalytics.createRetrainCollection": {
43773
+ capName: "pipeline-analytics",
43774
+ capScope: "device",
43775
+ addonId: null,
43776
+ access: "create"
43777
+ },
43778
+ "pipelineAnalytics.createRetrainDatasetVersion": {
43779
+ capName: "pipeline-analytics",
43780
+ capScope: "device",
43781
+ addonId: null,
43782
+ access: "create"
43783
+ },
42047
43784
  "pipelineAnalytics.deleteDeviceEvents": {
42048
43785
  capName: "pipeline-analytics",
42049
43786
  capScope: "device",
42050
43787
  addonId: null,
42051
43788
  access: "delete"
42052
43789
  },
43790
+ "pipelineAnalytics.deleteRetrainCollection": {
43791
+ capName: "pipeline-analytics",
43792
+ capScope: "device",
43793
+ addonId: null,
43794
+ access: "delete"
43795
+ },
43796
+ "pipelineAnalytics.deleteRetrainDatasetVersion": {
43797
+ capName: "pipeline-analytics",
43798
+ capScope: "device",
43799
+ addonId: null,
43800
+ access: "delete"
43801
+ },
42053
43802
  "pipelineAnalytics.deleteTracks": {
42054
43803
  capName: "pipeline-analytics",
42055
43804
  capScope: "device",
@@ -42254,6 +44003,30 @@ Object.freeze({
42254
44003
  addonId: null,
42255
44004
  access: "view"
42256
44005
  },
44006
+ "pipelineAnalytics.listRetrainAssistProfiles": {
44007
+ capName: "pipeline-analytics",
44008
+ capScope: "device",
44009
+ addonId: null,
44010
+ access: "view"
44011
+ },
44012
+ "pipelineAnalytics.listRetrainCollectionFrames": {
44013
+ capName: "pipeline-analytics",
44014
+ capScope: "device",
44015
+ addonId: null,
44016
+ access: "view"
44017
+ },
44018
+ "pipelineAnalytics.listRetrainCollections": {
44019
+ capName: "pipeline-analytics",
44020
+ capScope: "device",
44021
+ addonId: null,
44022
+ access: "view"
44023
+ },
44024
+ "pipelineAnalytics.listRetrainDatasetVersions": {
44025
+ capName: "pipeline-analytics",
44026
+ capScope: "device",
44027
+ addonId: null,
44028
+ access: "view"
44029
+ },
42257
44030
  "pipelineAnalytics.listRetrainFrames": {
42258
44031
  capName: "pipeline-analytics",
42259
44032
  capScope: "device",
@@ -42296,12 +44069,24 @@ Object.freeze({
42296
44069
  addonId: null,
42297
44070
  access: "create"
42298
44071
  },
44072
+ "pipelineAnalytics.previewRetrainDataset": {
44073
+ capName: "pipeline-analytics",
44074
+ capScope: "device",
44075
+ addonId: null,
44076
+ access: "view"
44077
+ },
42299
44078
  "pipelineAnalytics.proposeRetrainAnnotations": {
42300
44079
  capName: "pipeline-analytics",
42301
44080
  capScope: "device",
42302
44081
  addonId: null,
42303
44082
  access: "create"
42304
44083
  },
44084
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": {
44085
+ capName: "pipeline-analytics",
44086
+ capScope: "device",
44087
+ addonId: null,
44088
+ access: "create"
44089
+ },
42305
44090
  "pipelineAnalytics.pruneEvents": {
42306
44091
  capName: "pipeline-analytics",
42307
44092
  capScope: "device",
@@ -42356,6 +44141,18 @@ Object.freeze({
42356
44141
  addonId: null,
42357
44142
  access: "create"
42358
44143
  },
44144
+ "pipelineAnalytics.removeRetrainFrameFromCollection": {
44145
+ capName: "pipeline-analytics",
44146
+ capScope: "device",
44147
+ addonId: null,
44148
+ access: "delete"
44149
+ },
44150
+ "pipelineAnalytics.renameRetrainCollection": {
44151
+ capName: "pipeline-analytics",
44152
+ capScope: "device",
44153
+ addonId: null,
44154
+ access: "create"
44155
+ },
42359
44156
  "pipelineAnalytics.restageRetrainTrack": {
42360
44157
  capName: "pipeline-analytics",
42361
44158
  capScope: "device",
@@ -42416,6 +44213,12 @@ Object.freeze({
42416
44213
  addonId: null,
42417
44214
  access: "create"
42418
44215
  },
44216
+ "pipelineAnalytics.verifyRetrainDatasetVersion": {
44217
+ capName: "pipeline-analytics",
44218
+ capScope: "device",
44219
+ addonId: null,
44220
+ access: "view"
44221
+ },
42419
44222
  "pipelineAnalytics.wipeAllAnalytics": {
42420
44223
  capName: "pipeline-analytics",
42421
44224
  capScope: "device",
@@ -42644,6 +44447,12 @@ Object.freeze({
42644
44447
  addonId: null,
42645
44448
  access: "view"
42646
44449
  },
44450
+ "pipelineOrchestrator.abortNodeBenchmark": {
44451
+ capName: "pipeline-orchestrator",
44452
+ capScope: "system",
44453
+ addonId: null,
44454
+ access: "create"
44455
+ },
42647
44456
  "pipelineOrchestrator.applyAutoTune": {
42648
44457
  capName: "pipeline-orchestrator",
42649
44458
  capScope: "system",
@@ -42668,6 +44477,12 @@ Object.freeze({
42668
44477
  addonId: null,
42669
44478
  access: "create"
42670
44479
  },
44480
+ "pipelineOrchestrator.deleteNodeBenchmarkResult": {
44481
+ capName: "pipeline-orchestrator",
44482
+ capScope: "system",
44483
+ addonId: null,
44484
+ access: "delete"
44485
+ },
42671
44486
  "pipelineOrchestrator.getAgentLoad": {
42672
44487
  capName: "pipeline-orchestrator",
42673
44488
  capScope: "system",
@@ -42776,6 +44591,24 @@ Object.freeze({
42776
44591
  addonId: null,
42777
44592
  access: "view"
42778
44593
  },
44594
+ "pipelineOrchestrator.getNodeBenchmarkCandidates": {
44595
+ capName: "pipeline-orchestrator",
44596
+ capScope: "system",
44597
+ addonId: null,
44598
+ access: "view"
44599
+ },
44600
+ "pipelineOrchestrator.getNodeBenchmarkPreflight": {
44601
+ capName: "pipeline-orchestrator",
44602
+ capScope: "system",
44603
+ addonId: null,
44604
+ access: "view"
44605
+ },
44606
+ "pipelineOrchestrator.getNodeBenchmarkStatus": {
44607
+ capName: "pipeline-orchestrator",
44608
+ capScope: "system",
44609
+ addonId: null,
44610
+ access: "view"
44611
+ },
42779
44612
  "pipelineOrchestrator.getNodeInferenceDevices": {
42780
44613
  capName: "pipeline-orchestrator",
42781
44614
  capScope: "system",
@@ -42818,6 +44651,12 @@ Object.freeze({
42818
44651
  addonId: null,
42819
44652
  access: "view"
42820
44653
  },
44654
+ "pipelineOrchestrator.listNodeBenchmarkResults": {
44655
+ capName: "pipeline-orchestrator",
44656
+ capScope: "system",
44657
+ addonId: null,
44658
+ access: "view"
44659
+ },
42821
44660
  "pipelineOrchestrator.pauseForStorageMigration": {
42822
44661
  capName: "pipeline-orchestrator",
42823
44662
  capScope: "system",
@@ -42962,6 +44801,12 @@ Object.freeze({
42962
44801
  addonId: null,
42963
44802
  access: "create"
42964
44803
  },
44804
+ "pipelineOrchestrator.startNodeBenchmark": {
44805
+ capName: "pipeline-orchestrator",
44806
+ capScope: "system",
44807
+ addonId: null,
44808
+ access: "create"
44809
+ },
42965
44810
  "pipelineOrchestrator.suggestShares": {
42966
44811
  capName: "pipeline-orchestrator",
42967
44812
  capScope: "system",
@@ -42980,6 +44825,12 @@ Object.freeze({
42980
44825
  addonId: null,
42981
44826
  access: "create"
42982
44827
  },
44828
+ "pipelineRunner.abortNodeBench": {
44829
+ capName: "pipeline-runner",
44830
+ capScope: "system",
44831
+ addonId: null,
44832
+ access: "create"
44833
+ },
42983
44834
  "pipelineRunner.attachCamera": {
42984
44835
  capName: "pipeline-runner",
42985
44836
  capScope: "system",
@@ -43028,6 +44879,12 @@ Object.freeze({
43028
44879
  addonId: null,
43029
44880
  access: "view"
43030
44881
  },
44882
+ "pipelineRunner.getNodeBenchStatus": {
44883
+ capName: "pipeline-runner",
44884
+ capScope: "system",
44885
+ addonId: null,
44886
+ access: "view"
44887
+ },
43031
44888
  "pipelineRunner.getParkedTrackFrame": {
43032
44889
  capName: "pipeline-runner",
43033
44890
  capScope: "system",
@@ -43070,6 +44927,12 @@ Object.freeze({
43070
44927
  addonId: null,
43071
44928
  access: "create"
43072
44929
  },
44930
+ "pipelineRunner.startNodeBench": {
44931
+ capName: "pipeline-runner",
44932
+ capScope: "system",
44933
+ addonId: null,
44934
+ access: "create"
44935
+ },
43073
44936
  "plateGallery.assignPlate": {
43074
44937
  capName: "plate-gallery",
43075
44938
  capScope: "system",
@@ -48065,6 +49928,11 @@ Object.freeze({
48065
49928
  form: "single",
48066
49929
  optional: false
48067
49930
  }],
49931
+ "pipelineAnalytics.addRetrainFrameFromRecording": [{
49932
+ name: "deviceId",
49933
+ form: "single",
49934
+ optional: false
49935
+ }],
48068
49936
  "pipelineAnalytics.applyDeviceSettingsPatch": [{
48069
49937
  name: "deviceId",
48070
49938
  form: "single",
@@ -48255,6 +50123,11 @@ Object.freeze({
48255
50123
  form: "single",
48256
50124
  optional: false
48257
50125
  }],
50126
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": [{
50127
+ name: "deviceId",
50128
+ form: "single",
50129
+ optional: false
50130
+ }],
48258
50131
  "pipelineAnalytics.pruneEventsBefore": [{
48259
50132
  name: "deviceId",
48260
50133
  form: "single",
@@ -59696,7 +61569,10 @@ var OnvifProviderAddon = class extends BaseDeviceProvider {
59696
61569
  /** Cache of last WS-Discovery scan results — used by adoptDiscoveredDevice */
59697
61570
  lastDiscovered = [];
59698
61571
  constructor() {
59699
- super({});
61572
+ super({
61573
+ defaultUsername: "",
61574
+ defaultPassword: ""
61575
+ });
59700
61576
  }
59701
61577
  async supportsDiscovery() {
59702
61578
  return true;
@@ -59821,7 +61697,7 @@ var OnvifProviderAddon = class extends BaseDeviceProvider {
59821
61697
  });
59822
61698
  });
59823
61699
  }
59824
- buildGlobalSchema() {
61700
+ globalSettingsSchema() {
59825
61701
  return { sections: [{
59826
61702
  id: "discovery",
59827
61703
  title: "ONVIF Discovery",
@@ -59859,19 +61735,16 @@ var OnvifProviderAddon = class extends BaseDeviceProvider {
59859
61735
  }]
59860
61736
  }] };
59861
61737
  }
59862
- async getGlobalSettings() {
59863
- const raw = await this.resolveGlobalStore();
59864
- return hydrateSchema(this.buildGlobalSchema(), raw);
59865
- }
59866
61738
  async _getAddonConfig() {
59867
61739
  const raw = await this.resolveGlobalStore();
61740
+ const { defaultUsername, defaultPassword } = this.config;
59868
61741
  return {
59869
61742
  id: typeof raw["id"] === "string" ? raw["id"] : "onvif-default",
59870
61743
  name: typeof raw["name"] === "string" ? raw["name"] : "ONVIF Cameras",
59871
61744
  discovery: raw["discovery"],
59872
61745
  cameras: raw["cameras"],
59873
- defaultUsername: typeof raw["defaultUsername"] === "string" ? raw["defaultUsername"] : void 0,
59874
- defaultPassword: typeof raw["defaultPassword"] === "string" ? raw["defaultPassword"] : void 0
61746
+ defaultUsername: defaultUsername !== "" ? defaultUsername : void 0,
61747
+ defaultPassword: defaultPassword !== "" ? defaultPassword : void 0
59875
61748
  };
59876
61749
  }
59877
61750
  /**