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