@camstack/addon-agent-ui 1.2.191 → 1.2.193

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/addon.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import path from "node:path";
2
2
  import { fileURLToPath } from "node:url";
3
- //#region ../types/dist/event-category-B_0XEcLF.mjs
3
+ //#region ../types/dist/event-category-DaIZi00R.mjs
4
4
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
5
5
  EventCategory["SystemBoot"] = "system.boot";
6
6
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -79,6 +79,13 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
79
79
  */
80
80
  EventCategory["AddonLoadFailed"] = "addon.load-failed";
81
81
  /**
82
+ * A keychain value was stored or removed (D787). Carries the ref, its
83
+ * owner and the new version — NEVER the value. A process holding the ref
84
+ * drops its cached copy and the owning `BaseAddon` re-resolves its config.
85
+ * Telemetry (D8): a process that misses it still revalidates by version.
86
+ */
87
+ EventCategory["KeychainChanged"] = "keychain.changed";
88
+ /**
82
89
  * Addon recovered from a previous failure. Emitted when an addon
83
90
  * transitions from `failed` back to `healthy` (typically via the
84
91
  * monitor's auto-retry loop, or after manual `addons.retryLoad`).
@@ -5371,7 +5378,7 @@ var ZodIssueCode = {
5371
5378
  var ZodFirstPartyTypeKind;
5372
5379
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5373
5380
  //#endregion
5374
- //#region ../types/dist/sleep-B0JG7-_F.mjs
5381
+ //#region ../types/dist/sleep-DujUvOcb.mjs
5375
5382
  /**
5376
5383
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5377
5384
  * window to float samples (D455).
@@ -5450,6 +5457,97 @@ function buildAlawTable() {
5450
5457
  }
5451
5458
  buildUlawTable();
5452
5459
  buildAlawTable();
5460
+ /** Is this field's stored value a credential? */
5461
+ function isSecretConfigField(field) {
5462
+ if (field.type === "password") return true;
5463
+ return "secret" in field && field.secret === true;
5464
+ }
5465
+ /**
5466
+ * Is this field's value stored in the KEYCHAIN (D787)? Every secret field is,
5467
+ * by its TYPE, unless it opts out with `storage: 'inline'` — never by its name.
5468
+ */
5469
+ function isKeychainStoredField(field) {
5470
+ if (!isSecretConfigField(field)) return false;
5471
+ if (field.type === "textarea" && field.isJson === true) return false;
5472
+ return !("storage" in field && field.storage === "inline");
5473
+ }
5474
+ /**
5475
+ * What a settings blob holds where a secret used to be.
5476
+ *
5477
+ * A keychain-stored field never holds its value. It holds a self-describing
5478
+ * MARKER, `{"$secret":"secret://…","v":1}` — an object, never a string, so no
5479
+ * code can mistake it for a credential and no form can send it to a camera as
5480
+ * a password. The empty state is `null` / absent, never `''`.
5481
+ *
5482
+ * The same shapes travel to and from the admin UI:
5483
+ *
5484
+ * - read: `hydrateSchema` hands a secret field a {@link SecretFieldView}
5485
+ * (`{ $secret, v, set: true }`) or `null` — the browser learns whether a
5486
+ * value is set, never the value.
5487
+ * - write: an untouched field submits the view back unchanged (KEEP); a typed
5488
+ * value is a plain non-empty string (CHANGE); the Clear button submits
5489
+ * {@link SECRET_CLEAR} (CLEAR). `''`, `null` and the legacy redaction tokens
5490
+ * are KEEP — an empty string is what a defaults-fallback pushes back, and
5491
+ * treating it as "clear" is how a save destroyed a stored credential before.
5492
+ *
5493
+ * Pure and browser-safe.
5494
+ */
5495
+ var SECRET_CLEAR = { $secretClear: true };
5496
+ /** The `'***'` token D634 redaction writes for non-admins. */
5497
+ var LEGACY_DEVICE_REDACTION = "***";
5498
+ function isRecord$1(value) {
5499
+ return typeof value === "object" && value !== null && !Array.isArray(value);
5500
+ }
5501
+ function makeSecretMarker(ref) {
5502
+ return {
5503
+ $secret: ref,
5504
+ v: 1
5505
+ };
5506
+ }
5507
+ /** A stored marker: an object whose `$secret` is a non-empty string. */
5508
+ function isSecretMarker(value) {
5509
+ if (!isRecord$1(value)) return false;
5510
+ const ref = value["$secret"];
5511
+ return typeof ref === "string" && ref.length > 0;
5512
+ }
5513
+ function isSecretClear(value) {
5514
+ return isRecord$1(value) && value["$secretClear"] === true;
5515
+ }
5516
+ /**
5517
+ * The UI view of a stored secret field value: a marker becomes "set", inline
5518
+ * plaintext becomes "set (inline)", nothing becomes `null`. A value never
5519
+ * survives this function.
5520
+ */
5521
+ function toSecretFieldView(stored) {
5522
+ if (isSecretMarker(stored)) return {
5523
+ $secret: stored.$secret,
5524
+ v: 1,
5525
+ set: true
5526
+ };
5527
+ if (typeof stored === "string" && stored.length > 0) return {
5528
+ $secret: null,
5529
+ v: 1,
5530
+ set: true,
5531
+ inline: true
5532
+ };
5533
+ return null;
5534
+ }
5535
+ /**
5536
+ * Classify an incoming value for a secret path. Only a non-empty string that is
5537
+ * not a redaction token sets a value; only {@link SECRET_CLEAR} clears.
5538
+ * Everything else — a marker (ours or anyone's), a UI view, `''`, `null`,
5539
+ * `undefined`, a redaction token, a non-string — keeps what is stored.
5540
+ */
5541
+ function classifySecretWrite(incoming) {
5542
+ if (isSecretClear(incoming)) return { kind: "clear" };
5543
+ if (typeof incoming !== "string") return { kind: "keep" };
5544
+ if (incoming.length === 0) return { kind: "keep" };
5545
+ if (incoming === "__camstack_redacted__" || incoming === LEGACY_DEVICE_REDACTION) return { kind: "keep" };
5546
+ return {
5547
+ kind: "set",
5548
+ value: incoming
5549
+ };
5550
+ }
5453
5551
  Object.fromEntries([
5454
5552
  {
5455
5553
  id: "overview",
@@ -5621,33 +5719,19 @@ Object.fromEntries([
5621
5719
  function isValuelessField(field) {
5622
5720
  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";
5623
5721
  }
5624
- /**
5625
- * Merge a `ConfigUISchema` with a raw `values` record into a
5626
- * `ConfigUISchemaWithValues`. Used by every `get*Settings` backend endpoint
5627
- * before returning to the admin UI. Groups are walked recursively.
5628
- *
5629
- * For each leaf field:
5630
- * - structural fields (`separator`, `info`, `button`) pass through unchanged
5631
- * - other fields get `value = values[key] ?? field.default ?? null`
5632
- *
5633
- * Unknown keys in `values` (keys not declared in the schema) are silently
5634
- * ignored — they don't contribute to the output. Missing keys fall back to
5635
- * the schema default or `null`. This mirrors the old backend behaviour where
5636
- * `FormBuilder` rendered `values[key] ?? field.default`.
5637
- */
5638
- function hydrateSchema(schema, values) {
5722
+ function hydrateSchema(schema, values, options = {}) {
5639
5723
  return {
5640
5724
  ...schema.tabs ? { tabs: [...schema.tabs] } : {},
5641
5725
  sections: schema.sections.map((section) => ({
5642
5726
  ...section,
5643
- fields: section.fields.map((field) => hydrateField(field, values))
5727
+ fields: section.fields.map((field) => hydrateField(field, values, options))
5644
5728
  }))
5645
5729
  };
5646
5730
  }
5647
- function hydrateField(field, values) {
5731
+ function hydrateField(field, values, options) {
5648
5732
  if (isValuelessField(field)) return field;
5649
5733
  if (field.type === "group") {
5650
- const hydratedChildren = field.fields.map((child) => hydrateField(child, values));
5734
+ const hydratedChildren = field.fields.map((child) => hydrateField(child, values, options));
5651
5735
  return {
5652
5736
  ...field,
5653
5737
  fields: hydratedChildren
@@ -5656,7 +5740,7 @@ function hydrateField(field, values) {
5656
5740
  if (field.type === "sub-tabs") {
5657
5741
  const hydratedTabs = field.tabs.map((tab) => ({
5658
5742
  ...tab,
5659
- fields: tab.fields.map((child) => hydrateField(child, values))
5743
+ fields: tab.fields.map((child) => hydrateField(child, values, options))
5660
5744
  }));
5661
5745
  return {
5662
5746
  ...field,
@@ -5666,6 +5750,33 @@ function hydrateField(field, values) {
5666
5750
  const key = field.key;
5667
5751
  const storedValue = Object.prototype.hasOwnProperty.call(values, key) ? values[key] : void 0;
5668
5752
  const defaultValue = field.default;
5753
+ const asView = (v) => isSecretMarker(v) || options.inlineSecretsAsViews === true && v !== void 0;
5754
+ if (isKeychainStoredField(field) && asView(storedValue)) return {
5755
+ ...field,
5756
+ value: toSecretFieldView(storedValue)
5757
+ };
5758
+ if (isKeychainStoredField(field) && options.inlineSecretsAsViews === true) return {
5759
+ ...field,
5760
+ value: null
5761
+ };
5762
+ if (field.type === "editable-array" && Array.isArray(storedValue)) {
5763
+ const secretItemKeys = field.itemFields.filter((item) => "key" in item && isKeychainStoredField(item)).map((item) => "key" in item ? item.key : "");
5764
+ if (secretItemKeys.length > 0) {
5765
+ const rows = storedValue.map((row) => {
5766
+ if (row === null || typeof row !== "object" || Array.isArray(row)) return row;
5767
+ const out = { ...row };
5768
+ for (const k of secretItemKeys) {
5769
+ const v = Reflect.get(row, k);
5770
+ if (asView(v)) out[k] = toSecretFieldView(v);
5771
+ }
5772
+ return out;
5773
+ });
5774
+ return {
5775
+ ...field,
5776
+ value: rows
5777
+ };
5778
+ }
5779
+ }
5669
5780
  if (field.multiple) {
5670
5781
  const stored = Array.isArray(storedValue) ? storedValue : storedValue !== void 0 && storedValue !== null ? [storedValue] : [];
5671
5782
  const itemFallback = field.multiple.itemDefault !== void 0 ? field.multiple.itemDefault : defaultValue !== void 0 ? defaultValue : typeOf(field) === "string" ? "" : null;
@@ -5908,6 +6019,431 @@ function projectStore(store, perNodeKeys, nodeId) {
5908
6019
  }
5909
6020
  return out;
5910
6021
  }
6022
+ var GLOBAL_SCOPE = { kind: "global" };
6023
+ /** The scope every addon-wide (not per-node, not per-device) setting lives in. */
6024
+ function globalSecretScope() {
6025
+ return GLOBAL_SCOPE;
6026
+ }
6027
+ function encodeSegment(value) {
6028
+ return encodeURIComponent(value);
6029
+ }
6030
+ /**
6031
+ * The field path of a value inside an array item, addressed by the item's id:
6032
+ * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
6033
+ * `providers[authentik].clientSecret`.
6034
+ */
6035
+ function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6036
+ return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6037
+ }
6038
+ /** A write to a secret path could not be stored in the keychain, so it was refused. */
6039
+ var KeychainWriteRefusedError = class extends Error {
6040
+ fieldPath;
6041
+ constructor(fieldPath, cause) {
6042
+ super(`secret "${fieldPath}" was not saved: the keychain could not store it (${cause instanceof Error ? cause.message : String(cause)}). Nothing was written.`);
6043
+ this.fieldPath = fieldPath;
6044
+ this.name = "KeychainWriteRefusedError";
6045
+ }
6046
+ };
6047
+ var KEEP = { kind: "keep" };
6048
+ function isRecord(value) {
6049
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6050
+ }
6051
+ function defaultMintId() {
6052
+ return globalThis.crypto.randomUUID();
6053
+ }
6054
+ /** Every marker ref anywhere under `value`. */
6055
+ function collectSecretMarkerRefs(value, out = []) {
6056
+ if (isSecretMarker(value)) {
6057
+ out.push(value.$secret);
6058
+ return out;
6059
+ }
6060
+ if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6061
+ else if (isRecord(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6062
+ return out;
6063
+ }
6064
+ async function storedValueEquals(secrets, marker, candidate) {
6065
+ const resolved = (await secrets.resolve([marker.$secret]))[marker.$secret];
6066
+ return resolved?.kind === "value" && resolved.value === candidate;
6067
+ }
6068
+ async function writeLeaf(ctx, incoming, stored, fieldPath) {
6069
+ const intent = classifySecretWrite(incoming);
6070
+ const ref = ctx.secrets.ref(ctx.scope, fieldPath);
6071
+ const storedIsOurs = isSecretMarker(stored) && stored.$secret === ref;
6072
+ if (intent.kind === "keep") return KEEP;
6073
+ if (intent.kind === "set" && !ctx.operatorWrite && typeof stored === "string" && stored === intent.value) return KEEP;
6074
+ if (intent.kind === "clear") {
6075
+ if (storedIsOurs) ctx.deletes.push(ref);
6076
+ return {
6077
+ kind: "value",
6078
+ value: null
6079
+ };
6080
+ }
6081
+ if (storedIsOurs && await storedValueEquals(ctx.secrets, stored, intent.value)) return {
6082
+ kind: "value",
6083
+ value: stored
6084
+ };
6085
+ try {
6086
+ await ctx.secrets.put(ref, intent.value);
6087
+ } catch (err) {
6088
+ throw new KeychainWriteRefusedError(fieldPath, err);
6089
+ }
6090
+ return {
6091
+ kind: "value",
6092
+ value: makeSecretMarker(ref)
6093
+ };
6094
+ }
6095
+ /** Apply a member result onto `out`: KEEP restores the stored member, or removes it. */
6096
+ function applyMember(out, key, result, storedParent) {
6097
+ if (result.kind === "value") {
6098
+ out[key] = result.value;
6099
+ return;
6100
+ }
6101
+ if (Object.prototype.hasOwnProperty.call(storedParent, key)) out[key] = storedParent[key];
6102
+ else delete out[key];
6103
+ }
6104
+ async function writeMembers(ctx, children, incoming, stored, pathOf) {
6105
+ const out = { ...incoming };
6106
+ for (const [member, node] of children) applyMember(out, member, await writeNode(ctx, node, incoming[member], stored[member], pathOf(member)), stored);
6107
+ return out;
6108
+ }
6109
+ function rowId(row, idKey) {
6110
+ const raw = row[idKey];
6111
+ if (typeof raw === "string" && raw.length > 0) return raw;
6112
+ if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
6113
+ return null;
6114
+ }
6115
+ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6116
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord) : [];
6117
+ if (!Array.isArray(incoming)) {
6118
+ ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6119
+ return {
6120
+ kind: "value",
6121
+ value: incoming
6122
+ };
6123
+ }
6124
+ const storedById = /* @__PURE__ */ new Map();
6125
+ for (const row of storedRows) {
6126
+ const id = rowId(row, node.idKey);
6127
+ if (id !== null) storedById.set(id, row);
6128
+ }
6129
+ const kept = /* @__PURE__ */ new Set();
6130
+ const rows = [];
6131
+ for (const row of incoming) {
6132
+ if (!isRecord(row)) {
6133
+ rows.push(row);
6134
+ continue;
6135
+ }
6136
+ const id = rowId(row, node.idKey) ?? ctx.mintId();
6137
+ kept.add(id);
6138
+ const withId = {
6139
+ ...row,
6140
+ [node.idKey]: row[node.idKey] ?? id
6141
+ };
6142
+ if (rowId(withId, node.idKey) === null) withId[node.idKey] = id;
6143
+ const storedRow = storedById.get(id) ?? {};
6144
+ rows.push(await writeMembers(ctx, node.item, withId, storedRow, (member) => arrayItemFieldPath(fieldPath, id, member)));
6145
+ }
6146
+ for (const [id, row] of storedById) if (!kept.has(id)) ctx.deletes.push(...collectSecretMarkerRefs(row));
6147
+ return {
6148
+ kind: "value",
6149
+ value: rows
6150
+ };
6151
+ }
6152
+ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6153
+ switch (node.kind) {
6154
+ case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6155
+ case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6156
+ case "object": {
6157
+ if (!isRecord(incoming)) {
6158
+ if (incoming === void 0) return KEEP;
6159
+ ctx.deletes.push(...collectSecretMarkerRefs(stored));
6160
+ return {
6161
+ kind: "value",
6162
+ value: incoming
6163
+ };
6164
+ }
6165
+ const storedObj = isRecord(stored) ? stored : {};
6166
+ return {
6167
+ kind: "value",
6168
+ value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
6169
+ };
6170
+ }
6171
+ }
6172
+ }
6173
+ /** Split a perNode-scoped key (`key@nodeId`). */
6174
+ function splitNodeKey(key) {
6175
+ const at = key.indexOf("@");
6176
+ return at <= 0 ? {
6177
+ base: key,
6178
+ nodeId: null
6179
+ } : {
6180
+ base: key.slice(0, at),
6181
+ nodeId: key.slice(at + 1)
6182
+ };
6183
+ }
6184
+ /** Rewrite a settings patch so no secret value reaches the blob. See the file doc. */
6185
+ async function transformSecretWrite(input) {
6186
+ const deletes = [];
6187
+ const base = {
6188
+ secrets: input.secrets,
6189
+ mintId: input.mintId ?? defaultMintId,
6190
+ deletes,
6191
+ operatorWrite: input.operatorWrite === true
6192
+ };
6193
+ const out = {};
6194
+ for (const [key, incoming] of Object.entries(input.patch)) {
6195
+ const { base: baseKey, nodeId } = splitNodeKey(key);
6196
+ const node = input.tree.get(baseKey);
6197
+ if (node === void 0) {
6198
+ out[key] = incoming;
6199
+ continue;
6200
+ }
6201
+ const scope = nodeId !== null && nodeId.length > 0 ? {
6202
+ kind: "node",
6203
+ nodeId
6204
+ } : input.scope ?? globalSecretScope();
6205
+ const result = await writeNode({
6206
+ ...base,
6207
+ scope
6208
+ }, node, incoming, input.stored[key], baseKey);
6209
+ if (result.kind === "value") out[key] = result.value;
6210
+ }
6211
+ return {
6212
+ patch: out,
6213
+ afterWrite: async () => {
6214
+ if (deletes.length === 0) return { orphaned: [] };
6215
+ try {
6216
+ await input.secrets.delete([...new Set(deletes)]);
6217
+ return { orphaned: [] };
6218
+ } catch {
6219
+ return { orphaned: [...new Set(deletes)] };
6220
+ }
6221
+ }
6222
+ };
6223
+ }
6224
+ /**
6225
+ * Replace every marker in `value` with its keychain value. Returns the SAME
6226
+ * reference when there is no marker (no allocation, no keychain call).
6227
+ */
6228
+ async function resolveSecretMarkers(value, secrets) {
6229
+ const refs = collectSecretMarkerRefs(value);
6230
+ if (refs.length === 0) return {
6231
+ value,
6232
+ unresolved: []
6233
+ };
6234
+ const answers = await secrets.resolve(refs);
6235
+ const unresolved = [];
6236
+ for (const ref of new Set(refs)) {
6237
+ const answer = answers[ref];
6238
+ if (answer === void 0) unresolved.push({
6239
+ ref,
6240
+ reason: "not-initialized"
6241
+ });
6242
+ else if (answer.kind === "unavailable") unresolved.push({
6243
+ ref,
6244
+ reason: answer.reason
6245
+ });
6246
+ else if (answer.kind === "missing" || answer.kind === "forbidden") unresolved.push({
6247
+ ref,
6248
+ reason: answer.kind
6249
+ });
6250
+ }
6251
+ const substitute = (v) => {
6252
+ if (isSecretMarker(v)) {
6253
+ const answer = answers[v.$secret];
6254
+ return answer?.kind === "value" ? {
6255
+ keep: true,
6256
+ value: answer.value
6257
+ } : {
6258
+ keep: false,
6259
+ value: void 0
6260
+ };
6261
+ }
6262
+ if (Array.isArray(v)) {
6263
+ const items = [];
6264
+ for (const item of v) {
6265
+ const s = substitute(item);
6266
+ if (s.keep) items.push(s.value);
6267
+ }
6268
+ return {
6269
+ keep: true,
6270
+ value: items
6271
+ };
6272
+ }
6273
+ if (isRecord(v)) {
6274
+ const out = {};
6275
+ for (const [k, child] of Object.entries(v)) {
6276
+ const s = substitute(child);
6277
+ if (s.keep) out[k] = s.value;
6278
+ }
6279
+ return {
6280
+ keep: true,
6281
+ value: out
6282
+ };
6283
+ }
6284
+ return {
6285
+ keep: true,
6286
+ value: v
6287
+ };
6288
+ };
6289
+ return {
6290
+ value: substitute(value).value,
6291
+ unresolved
6292
+ };
6293
+ }
6294
+ function touchesTree(tree, patch) {
6295
+ if (tree.size === 0) return false;
6296
+ for (const key of Object.keys(patch)) {
6297
+ const at = key.indexOf("@");
6298
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6299
+ }
6300
+ return false;
6301
+ }
6302
+ /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
6303
+ async function readStoredAddonBlob(raw) {
6304
+ const threeWay = raw.readAddonStoreResult;
6305
+ if (threeWay === void 0) return raw.readAddonStore();
6306
+ const result = await threeWay.call(raw);
6307
+ if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
6308
+ return result.kind === "missing" ? {} : result.value;
6309
+ }
6310
+ function createSecretAwareSettings(raw, opts) {
6311
+ const chains = /* @__PURE__ */ new Map();
6312
+ const serialize = (key, fn) => {
6313
+ const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
6314
+ const tail = next.catch(() => void 0);
6315
+ chains.set(key, tail);
6316
+ tail.then(() => {
6317
+ if (chains.get(key) === tail) chains.delete(key);
6318
+ });
6319
+ return next;
6320
+ };
6321
+ const write = async (chainKey, tree, scope, patch, readStored, rawWrite) => {
6322
+ if (!touchesTree(tree, patch)) return rawWrite(patch);
6323
+ return serialize(chainKey, async () => {
6324
+ const stored = await readStored();
6325
+ const result = await transformSecretWrite({
6326
+ tree,
6327
+ secrets: opts.secrets,
6328
+ patch,
6329
+ stored,
6330
+ ...scope !== void 0 ? { scope } : {},
6331
+ operatorWrite: opts.isOperatorWrite?.() === true
6332
+ });
6333
+ if (Object.keys(result.patch).length > 0) await rawWrite(result.patch);
6334
+ const { orphaned } = await result.afterWrite();
6335
+ if (orphaned.length > 0) opts.onOrphaned(orphaned);
6336
+ });
6337
+ };
6338
+ const wrapped = {
6339
+ writeAddonStore: (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p)),
6340
+ writeDeviceStore: (deviceId, patch) => write(`device:${deviceId}`, opts.deviceTree(), {
6341
+ kind: "device",
6342
+ deviceId
6343
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p))
6344
+ };
6345
+ return new Proxy(raw, { get(target, prop, receiver) {
6346
+ if (prop === "writeAddonStore") return wrapped.writeAddonStore;
6347
+ if (prop === "writeDeviceStore") return wrapped.writeDeviceStore;
6348
+ const value = Reflect.get(target, prop, receiver);
6349
+ return typeof value === "function" ? value.bind(target) : value;
6350
+ } });
6351
+ }
6352
+ /** The context the addon sees: identical, except that its settings writes are secret-aware. */
6353
+ function withSecretAwareSettings(context, opts) {
6354
+ const raw = context.settings;
6355
+ if (raw === void 0) return context;
6356
+ const settings = createSecretAwareSettings(raw, opts);
6357
+ return new Proxy(context, { get(target, prop, receiver) {
6358
+ if (prop === "settings") return settings;
6359
+ return Reflect.get(target, prop, receiver);
6360
+ } });
6361
+ }
6362
+ var LEAF = { kind: "leaf" };
6363
+ var DEFAULT_ITEM_ID_KEY = "id";
6364
+ function collectFields(fields, out) {
6365
+ for (const field of fields) {
6366
+ if (field.type === "group") {
6367
+ collectFields(field.fields, out);
6368
+ continue;
6369
+ }
6370
+ if (field.type === "sub-tabs") {
6371
+ for (const tab of field.tabs) collectFields(tab.fields, out);
6372
+ continue;
6373
+ }
6374
+ if (field.type === "editable-array") {
6375
+ const item = /* @__PURE__ */ new Map();
6376
+ for (const itemField of field.itemFields) if ("key" in itemField && isKeychainStoredField(itemField)) item.set(itemField.key, LEAF);
6377
+ if (item.size > 0) out.set(field.key, {
6378
+ kind: "array",
6379
+ idKey: field.itemIdKey ?? DEFAULT_ITEM_ID_KEY,
6380
+ item
6381
+ });
6382
+ continue;
6383
+ }
6384
+ if (!("key" in field) || typeof field.key !== "string") continue;
6385
+ if (isKeychainStoredField(field)) out.set(field.key, LEAF);
6386
+ }
6387
+ }
6388
+ /** The secret tree a settings schema declares. */
6389
+ function secretTreeFromSchema(schema) {
6390
+ const out = /* @__PURE__ */ new Map();
6391
+ if (schema === null) return out;
6392
+ for (const section of schema.sections) collectFields(section.fields, out);
6393
+ return out;
6394
+ }
6395
+ /** Parse `a.b[id].c` into segments; throws on a malformed path (a declaration bug). */
6396
+ function parseSecretStatePath(path) {
6397
+ const segments = [];
6398
+ for (const raw of path.split(".")) {
6399
+ const m = /^([^[\]]+)(?:\[([^[\]]+)\])?$/.exec(raw);
6400
+ if (m === null || m[1] === void 0) throw new Error(`secretStatePaths: malformed path "${path}"`);
6401
+ segments.push(m[2] !== void 0 ? {
6402
+ key: m[1],
6403
+ idKey: m[2]
6404
+ } : { key: m[1] });
6405
+ }
6406
+ if (segments.length === 0) throw new Error(`secretStatePaths: empty path`);
6407
+ if (segments[segments.length - 1]?.idKey !== void 0) throw new Error(`secretStatePaths: "${path}" ends on an array — name the member that is secret`);
6408
+ return segments;
6409
+ }
6410
+ function insert(into, segments) {
6411
+ const [head, ...rest] = segments;
6412
+ if (head === void 0) return;
6413
+ if (rest.length === 0) {
6414
+ into.set(head.key, LEAF);
6415
+ return;
6416
+ }
6417
+ const existing = into.get(head.key);
6418
+ if (head.idKey !== void 0) {
6419
+ const item = new Map(existing?.kind === "array" ? existing.item : []);
6420
+ insert(item, rest);
6421
+ into.set(head.key, {
6422
+ kind: "array",
6423
+ idKey: head.idKey,
6424
+ item
6425
+ });
6426
+ return;
6427
+ }
6428
+ const children = new Map(existing?.kind === "object" ? existing.children : []);
6429
+ insert(children, rest);
6430
+ into.set(head.key, {
6431
+ kind: "object",
6432
+ children
6433
+ });
6434
+ }
6435
+ /** Add hidden-state paths (`secretStatePaths`) to a schema-derived tree. */
6436
+ function mergeSecretStatePaths(tree, paths) {
6437
+ if (paths.length === 0) return tree;
6438
+ const out = new Map(tree);
6439
+ for (const path of paths) insert(out, parseSecretStatePath(path));
6440
+ return out;
6441
+ }
6442
+ /** First retry of a secret the keychain could not serve; doubles to {@link SECRET_RETRY_MAX_MS}. */
6443
+ var SECRET_RETRY_FIRST_MS = 5e3;
6444
+ var SECRET_RETRY_MAX_MS = 5 * 6e4;
6445
+ /** Coalesces a burst of `keychain.changed` events into one re-resolve. */
6446
+ var SECRET_CHANGE_DEBOUNCE_MS = 250;
5911
6447
  /**
5912
6448
  * Base class for CamStack addons. Eliminates settings boilerplate:
5913
6449
  *
@@ -5977,6 +6513,25 @@ var BaseAddon = class {
5977
6513
  settingsStoreReady = false;
5978
6514
  /** Default config values. Provided via constructor. */
5979
6515
  defaults;
6516
+ /**
6517
+ * Hidden-state paths that hold secrets (D787) — values the addon writes
6518
+ * itself (`updateGlobalSettings`, `state()`) that no form field declares.
6519
+ * Stored in the keychain exactly like a `password` field. Syntax:
6520
+ * `'snapshotSigningKey'`, `'identity.pincode'`, `'tokens[userId].accessToken'`
6521
+ * (`key[<id field>]` addresses array items by id, never by index).
6522
+ */
6523
+ secretStatePaths = [];
6524
+ _addonSecretTree = null;
6525
+ _deviceSecretTree = null;
6526
+ /** Refs the last resolved config pointed at — a change to one re-resolves. */
6527
+ _configSecretRefs = /* @__PURE__ */ new Set();
6528
+ _unresolvedSecrets = [];
6529
+ _secretRetryTimer = null;
6530
+ _secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
6531
+ _secretChangeTimer = null;
6532
+ _secretChangeUnsub = null;
6533
+ /** >0 while an OPERATOR's settings write is being applied. */
6534
+ _operatorWriteDepth = 0;
5980
6535
  constructor(defaults) {
5981
6536
  this.defaults = defaults;
5982
6537
  this._config = { ...defaults };
@@ -6012,8 +6567,18 @@ var BaseAddon = class {
6012
6567
  return this._config;
6013
6568
  }
6014
6569
  async initialize(context) {
6015
- this._ctx = context;
6570
+ const secrets = context.secrets;
6571
+ this._ctx = secrets !== void 0 ? withSecretAwareSettings(context, {
6572
+ secrets,
6573
+ addonTree: () => this.addonSecretTree(),
6574
+ deviceTree: () => this.deviceSecretTree(),
6575
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6576
+ isOperatorWrite: () => this._operatorWriteDepth > 0
6577
+ }) : context;
6016
6578
  await this.resolveConfig();
6579
+ if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
6580
+ if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
6581
+ });
6017
6582
  const result = await this.onInitialize();
6018
6583
  this.emitLifecycle(EventCategory.AddonStarted);
6019
6584
  const normalized = normalizeAddonInitResult(result);
@@ -6046,6 +6611,12 @@ var BaseAddon = class {
6046
6611
  */
6047
6612
  async onHubReachable() {}
6048
6613
  async shutdown() {
6614
+ this._secretChangeUnsub?.();
6615
+ this._secretChangeUnsub = null;
6616
+ if (this._secretRetryTimer !== null) clearTimeout(this._secretRetryTimer);
6617
+ if (this._secretChangeTimer !== null) clearTimeout(this._secretChangeTimer);
6618
+ this._secretRetryTimer = null;
6619
+ this._secretChangeTimer = null;
6049
6620
  this.emitLifecycle(EventCategory.AddonStopped);
6050
6621
  if (this.autoEmitReadiness) this.emitReadinessForProviders("down");
6051
6622
  await this.onShutdown();
@@ -6124,7 +6695,7 @@ var BaseAddon = class {
6124
6695
  return hydrateSchema(schema, overlay ? {
6125
6696
  ...projected,
6126
6697
  ...overlay
6127
- } : projected);
6698
+ } : projected, { inlineSecretsAsViews: true });
6128
6699
  }
6129
6700
  /**
6130
6701
  * The integration-level view of this addon's settings: exactly the sections
@@ -6173,7 +6744,7 @@ var BaseAddon = class {
6173
6744
  return hydrateSchema({
6174
6745
  ...schema,
6175
6746
  sections
6176
- }, projected);
6747
+ }, projected, { inlineSecretsAsViews: true });
6177
6748
  }
6178
6749
  /**
6179
6750
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
@@ -6227,18 +6798,50 @@ var BaseAddon = class {
6227
6798
  value: result.value[key]
6228
6799
  };
6229
6800
  }
6801
+ /**
6802
+ * The OPERATOR's write — a settings form or an admin API call, dispatched by
6803
+ * the kernel. Identical to {@link updateGlobalSettings}, except that a secret
6804
+ * the operator sends is stored as sent even when it equals a pre-keychain
6805
+ * inline value: the operator re-entering a password is a change, an addon
6806
+ * writing back what it read is not (D787).
6807
+ */
6808
+ async updateGlobalSettingsAsOperator(patch, nodeId) {
6809
+ this._operatorWriteDepth++;
6810
+ try {
6811
+ await this.applyGlobalPatch(patch, nodeId);
6812
+ } finally {
6813
+ this._operatorWriteDepth--;
6814
+ }
6815
+ }
6230
6816
  async updateGlobalSettings(patch, nodeId) {
6817
+ await this.applyGlobalPatch(patch, nodeId);
6818
+ }
6819
+ /**
6820
+ * REMOVE stored secrets — their keychain values and their markers (D787).
6821
+ *
6822
+ * Writing `''` to a secret field KEEPS what is stored (an empty string is
6823
+ * what a defaults fallback writes back, and it must never destroy a
6824
+ * credential), so code that means "forget this token" says so here. Without
6825
+ * a keychain (an older kernel) it writes `''`, as such code always did.
6826
+ */
6827
+ async clearSecrets(keys, nodeId) {
6828
+ const tree = this.addonSecretTree();
6829
+ const keychain = this._ctx?.secrets !== void 0;
6830
+ const patch = {};
6831
+ for (const key of keys) patch[key] = keychain && tree.has(key) ? SECRET_CLEAR : "";
6832
+ await this.applyGlobalPatch(patch, nodeId);
6833
+ }
6834
+ async applyGlobalPatch(barePatch, nodeId) {
6231
6835
  const keys = this.perNodeKeys();
6232
6836
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6233
6837
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6234
- const barePatch = patch;
6235
6838
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
6236
6839
  await this._ctx?.settings?.writeAddonStore(scoped);
6237
6840
  if (target !== localNode) return;
6238
6841
  await this.resolveConfig();
6239
6842
  await this.onConfigChanged();
6240
6843
  this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
6241
- this.maybeAutoRestart(patch, this.globalSettingsSchema());
6844
+ this.maybeAutoRestart(Object.keys(barePatch), this.globalSettingsSchema());
6242
6845
  }
6243
6846
  /**
6244
6847
  * The set of field keys the global settings schema declares `perNode: true`
@@ -6263,7 +6866,7 @@ var BaseAddon = class {
6263
6866
  * time to return its response before the addon is torn down and
6264
6867
  * re-initialised by `AddonRegistryService.restartAddon`.
6265
6868
  */
6266
- maybeAutoRestart(patch, schema) {
6869
+ maybeAutoRestart(patchKeys, schema) {
6267
6870
  if (!schema) return;
6268
6871
  const restartKeys = /* @__PURE__ */ new Set();
6269
6872
  for (const section of schema.sections) for (const field of section.fields) {
@@ -6271,13 +6874,13 @@ var BaseAddon = class {
6271
6874
  if (field.requiresRestart) restartKeys.add(field.key);
6272
6875
  }
6273
6876
  if (restartKeys.size === 0) return;
6274
- if (!Object.keys(patch).some((k) => restartKeys.has(k))) return;
6877
+ if (!patchKeys.some((k) => restartKeys.has(k))) return;
6275
6878
  const ctx = this._ctx;
6276
6879
  if (!ctx) return;
6277
6880
  const addonId = ctx.id;
6278
6881
  setImmediate(() => {
6279
6882
  ctx.api.addons?.restartAddon?.mutate({ addonId }).then(() => {
6280
- ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: Object.keys(patch).filter((k) => restartKeys.has(k)) } });
6883
+ ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
6281
6884
  }).catch((err) => {
6282
6885
  ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
6283
6886
  });
@@ -6286,7 +6889,7 @@ var BaseAddon = class {
6286
6889
  async getDeviceSettings(deviceId) {
6287
6890
  const schema = this.deviceSettingsSchema();
6288
6891
  if (!schema) return { sections: [] };
6289
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {});
6892
+ return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
6290
6893
  }
6291
6894
  async updateDeviceSettings(deviceId, patch) {
6292
6895
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -6416,7 +7019,7 @@ var BaseAddon = class {
6416
7019
  * selection at boot (absent scoped key ⇒ the constructor default wins).
6417
7020
  */
6418
7021
  async resolveConfig() {
6419
- const stored = await this.readAddonStoreWithRetry();
7022
+ const stored = await this.resolveStoredSecrets(await this.readAddonStoreWithRetry());
6420
7023
  const perNode = this.perNodeKeys();
6421
7024
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6422
7025
  const resolved = { ...this.defaults };
@@ -6441,7 +7044,7 @@ var BaseAddon = class {
6441
7044
  key,
6442
7045
  schema,
6443
7046
  fallback,
6444
- read: () => this.readAddonStoreWithRetry(),
7047
+ read: async () => this.resolveStoredSecrets(await this.readAddonStoreWithRetry()),
6445
7048
  write: async (patch) => {
6446
7049
  await this._ctx?.settings?.writeAddonStore(patch);
6447
7050
  },
@@ -6458,7 +7061,7 @@ var BaseAddon = class {
6458
7061
  key,
6459
7062
  schema,
6460
7063
  fallback,
6461
- read: async () => await this._ctx?.settings?.readDeviceStore(deviceId) ?? {},
7064
+ read: async () => this.resolveStoredSecrets(await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, false),
6462
7065
  write: async (patch) => {
6463
7066
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
6464
7067
  },
@@ -6470,6 +7073,70 @@ var BaseAddon = class {
6470
7073
  } })
6471
7074
  });
6472
7075
  }
7076
+ /** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
7077
+ addonSecretTree() {
7078
+ this._addonSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.globalSettingsSchema()), this.secretStatePaths);
7079
+ return this._addonSecretTree;
7080
+ }
7081
+ deviceSecretTree() {
7082
+ this._deviceSecretTree ??= secretTreeFromSchema(this.deviceSettingsSchema());
7083
+ return this._deviceSecretTree;
7084
+ }
7085
+ /**
7086
+ * Secrets of this addon's stored config that could not be resolved on the
7087
+ * last read, with why. Non-empty means the addon is running WITHOUT them —
7088
+ * an addon whose function needs one should report itself degraded rather
7089
+ * than start on an empty credential.
7090
+ */
7091
+ get unresolvedSecrets() {
7092
+ return this._unresolvedSecrets;
7093
+ }
7094
+ /**
7095
+ * Substitute every keychain marker in a stored blob with its value. With no
7096
+ * keychain (no `ctx.secrets`) or no marker, the blob comes back unchanged.
7097
+ * An unresolvable value is LEFT OUT (never `''`), logged by ref — never by
7098
+ * value — and, when the cause can pass, retried with backoff. Nothing is
7099
+ * ever written back from here.
7100
+ */
7101
+ async resolveStoredSecrets(blob, trackForConfig = true) {
7102
+ const secrets = this._ctx?.secrets;
7103
+ if (secrets === void 0) return blob;
7104
+ const refs = collectSecretMarkerRefs(blob);
7105
+ if (trackForConfig) this._configSecretRefs = new Set(refs);
7106
+ if (refs.length === 0) {
7107
+ if (trackForConfig) this._unresolvedSecrets = [];
7108
+ return blob;
7109
+ }
7110
+ const { value, unresolved } = await resolveSecretMarkers(blob, secrets);
7111
+ if (trackForConfig) {
7112
+ this._unresolvedSecrets = unresolved;
7113
+ if (unresolved.length > 0) {
7114
+ this._ctx?.logger?.error?.("secret unavailable — running without it, will retry", { meta: { secrets: unresolved.map((u) => ({
7115
+ ref: u.ref,
7116
+ reason: u.reason
7117
+ })) } });
7118
+ if (unresolved.some((u) => u.reason !== "missing" && u.reason !== "forbidden")) {
7119
+ this.scheduleSecretReresolve(this._secretRetryDelayMs);
7120
+ this._secretRetryDelayMs = Math.min(this._secretRetryDelayMs * 2, SECRET_RETRY_MAX_MS);
7121
+ }
7122
+ } else this._secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
7123
+ }
7124
+ return value;
7125
+ }
7126
+ /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
7127
+ scheduleSecretReresolve(delayMs) {
7128
+ const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
7129
+ if (this[timerOf] !== null) return;
7130
+ const timer = setTimeout(() => {
7131
+ this[timerOf] = null;
7132
+ if (this._ctx === null) return;
7133
+ this.resolveConfig().then(() => this.onConfigChanged()).catch((err) => {
7134
+ this._ctx?.logger?.error?.("re-resolving secrets failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
7135
+ });
7136
+ }, delayMs);
7137
+ timer.unref?.();
7138
+ this[timerOf] = timer;
7139
+ }
6473
7140
  /**
6474
7141
  * Wrap `ctx.settings.readAddonStore()` with a short retry budget so a
6475
7142
  * transient settings-store outage (mid-restart of sqlite-settings, tsx-watch
@@ -13977,6 +14644,196 @@ id: union([string(), number()]) }), {
13977
14644
  kind: "mutation",
13978
14645
  auth: "admin"
13979
14646
  });
14647
+ /**
14648
+ * `keychain` — the hub's encrypted store of secret values (D787).
14649
+ *
14650
+ * Settings blobs never hold a secret: they hold a marker
14651
+ * `{"$secret":"secret://<owner>/<scope>/<fieldPath>","v":1}` and the value
14652
+ * lives here, AES-256-GCM under a data key that a master key wraps. This cap
14653
+ * is the OWNER's door to its own values: every method is owner-checked
14654
+ * against the CALLER, never against anything the caller claims.
14655
+ *
14656
+ * Who the caller is: the transport stamps `callerAddonId` into the args of a
14657
+ * call that crossed a process (the parent `LocalChildRegistry` from the UDS
14658
+ * connection, the agent from its child's connection carried in
14659
+ * `$hub-cap-fwd`'s envelope). A stamp always overwrites; a wire call with no
14660
+ * stamp has its claim stripped. Only a hub in-process caller may state its own
14661
+ * identity — `ctx.secrets` does that with the addon id closed over. This is
14662
+ * identity against BUGS and misrouting, not against a malicious addon (every
14663
+ * runner is the same OS user): see the threat model in
14664
+ * `docs/design/2026-10-08-secrets-keychain.md`.
14665
+ *
14666
+ * `callerAddonId` is deliberately NOT in any input schema: the tRPC router
14667
+ * parses the input, so a session can never supply it, and the internal mount
14668
+ * floors every method to admin anyway (D240).
14669
+ *
14670
+ * Internal: addons reach it through `ctx.secrets`, never directly.
14671
+ */
14672
+ /** Why a value cannot be served right now. Never folded into "missing". */
14673
+ var KeychainUnavailableReasonSchema = _enum([
14674
+ "key-missing",
14675
+ "wrong-key",
14676
+ "key-file-unreadable",
14677
+ "store-unavailable",
14678
+ "not-initialized",
14679
+ "decrypt-failed"
14680
+ ]);
14681
+ var KeychainStateSchema = discriminatedUnion("state", [object({ state: literal("ready") }), object({
14682
+ state: literal("locked"),
14683
+ reason: KeychainUnavailableReasonSchema
14684
+ })]);
14685
+ var KeychainResolveEntrySchema = discriminatedUnion("kind", [
14686
+ object({
14687
+ kind: literal("value"),
14688
+ value: string(),
14689
+ version: number().int()
14690
+ }),
14691
+ object({ kind: literal("missing") }),
14692
+ object({
14693
+ kind: literal("unavailable"),
14694
+ reason: KeychainUnavailableReasonSchema
14695
+ }),
14696
+ object({ kind: literal("forbidden") })
14697
+ ]);
14698
+ var KeychainResolveResultSchema = record(string(), KeychainResolveEntrySchema);
14699
+ /** Metadata of one stored value — never the value. */
14700
+ var KeychainSecretMetaSchema = object({
14701
+ ref: string(),
14702
+ owner: string(),
14703
+ /** Formatted scope (`global`, `node/<id>`, `device/<id>`, …). */
14704
+ scope: string(),
14705
+ fieldPath: string(),
14706
+ version: number().int(),
14707
+ createdAt: number(),
14708
+ updatedAt: number(),
14709
+ /** `addon:<id>` | `user:<id>` | `system`. */
14710
+ updatedBy: string(),
14711
+ /** Coarse — written at most once an hour per ref. `null` = never read. */
14712
+ lastReadAt: number().nullable()
14713
+ });
14714
+ var RefListSchema = array(string().min(1)).max(512);
14715
+ method(object({
14716
+ ref: string().min(1),
14717
+ value: string().min(1)
14718
+ }), object({
14719
+ ref: string(),
14720
+ version: number().int()
14721
+ }), {
14722
+ kind: "mutation",
14723
+ auth: "admin"
14724
+ }), method(object({ refs: RefListSchema }), KeychainResolveResultSchema, { auth: "admin" }), method(object({ refs: RefListSchema }), object({ deleted: number().int() }), {
14725
+ kind: "mutation",
14726
+ auth: "admin"
14727
+ }), method(object({}), array(KeychainSecretMetaSchema).readonly(), { auth: "admin" }), method(object({}), KeychainStateSchema, { auth: "admin" });
14728
+ var KeychainKeySourceSchema = object({
14729
+ kind: _enum([
14730
+ "config-file",
14731
+ "previous-config-file",
14732
+ "platform",
14733
+ "default-file"
14734
+ ]),
14735
+ /** File sources only — a path is not a secret. */
14736
+ path: string().optional(),
14737
+ /**
14738
+ * True when a whole-volume backup of the data directory carries this key
14739
+ * next to the database it protects (the default file). The page warns.
14740
+ */
14741
+ sharesBackupWithDatabase: boolean()
14742
+ });
14743
+ var KeychainStatusSchema = object({
14744
+ keychain: KeychainStateSchema,
14745
+ /** The source of the master key in use; `null` while locked. */
14746
+ keySource: KeychainKeySourceSchema.nullable(),
14747
+ /** The source configured to be primary — differs from `keySource` while a rotation is pending. */
14748
+ configuredSource: KeychainKeySourceSchema,
14749
+ /** Short fingerprint of the master key in use (`HMAC(KEK, label)`, 16 hex). */
14750
+ fingerprint: string().nullable(),
14751
+ activeKeyId: string().nullable(),
14752
+ /**
14753
+ * The keychain unlocked with a NON-primary source: the configured primary
14754
+ * key is not the one that wraps the data key yet. `rotateMasterKey` moves it.
14755
+ */
14756
+ rotationPending: boolean(),
14757
+ /** Wrapped copies of the data key under a previous master key, kept until purged. */
14758
+ retiredWraps: number().int(),
14759
+ recoveryKeyDownloadedAt: number().nullable(),
14760
+ secretCount: number().int()
14761
+ });
14762
+ /**
14763
+ * Whether a stored value is still pointed at by its owner's settings.
14764
+ * `unknown` is a first-class answer: a scope whose blob could not be read is
14765
+ * never reported as an orphan (and never deleted as one).
14766
+ */
14767
+ var KeychainSecretUsageSchema = _enum([
14768
+ "in-use",
14769
+ "orphan",
14770
+ "unknown"
14771
+ ]);
14772
+ var KeychainAdminSecretSchema = KeychainSecretMetaSchema.extend({ usage: KeychainSecretUsageSchema });
14773
+ var KeychainAuditActionSchema = _enum([
14774
+ "put",
14775
+ "delete",
14776
+ "reveal",
14777
+ "rotate-master-key",
14778
+ "purge-retired-keys",
14779
+ "download-recovery-key",
14780
+ "delete-orphans",
14781
+ "reset",
14782
+ "initialize"
14783
+ ]);
14784
+ var KeychainAuditEntrySchema = object({
14785
+ id: string(),
14786
+ at: number(),
14787
+ action: KeychainAuditActionSchema,
14788
+ /** `addon:<id>` | `user:<id>` | `system`. */
14789
+ actor: string(),
14790
+ ref: string().nullable(),
14791
+ detail: string().nullable()
14792
+ });
14793
+ 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({
14794
+ value: string(),
14795
+ version: number().int()
14796
+ }), {
14797
+ kind: "mutation",
14798
+ auth: "admin",
14799
+ caller: "required"
14800
+ }), method(object({ refs: array(string().min(1)).max(1e3) }), object({
14801
+ deleted: array(string()).readonly(),
14802
+ kept: array(object({
14803
+ ref: string(),
14804
+ usage: KeychainSecretUsageSchema
14805
+ })).readonly()
14806
+ }), {
14807
+ kind: "mutation",
14808
+ auth: "admin",
14809
+ caller: "required"
14810
+ }), method(object({}), object({
14811
+ fingerprint: string(),
14812
+ keySource: KeychainKeySourceSchema
14813
+ }), {
14814
+ kind: "mutation",
14815
+ auth: "admin",
14816
+ caller: "required"
14817
+ }), method(object({}), object({ purged: number().int() }), {
14818
+ kind: "mutation",
14819
+ auth: "admin",
14820
+ caller: "required"
14821
+ }), method(object({}), object({
14822
+ key: string(),
14823
+ fingerprint: string(),
14824
+ keySource: KeychainKeySourceSchema
14825
+ }), {
14826
+ kind: "mutation",
14827
+ auth: "admin",
14828
+ caller: "required"
14829
+ }), method(object({ confirm: literal("RESET KEYCHAIN") }), object({
14830
+ archivedCollection: string().nullable(),
14831
+ archived: number().int()
14832
+ }), {
14833
+ kind: "mutation",
14834
+ auth: "admin",
14835
+ caller: "required"
14836
+ });
13980
14837
  method(_void(), object({
13981
14838
  id: string(),
13982
14839
  name: string(),
@@ -15014,7 +15871,11 @@ var DeviceRegisterPayloadSchema = object({
15014
15871
  var DeviceRemovePayloadSchema = object({ deviceId: number() });
15015
15872
  var DevicePersistConfigPayloadSchema = object({
15016
15873
  deviceId: number(),
15017
- data: record(string(), unknown())
15874
+ data: record(string(), unknown()),
15875
+ /** The paths the device's schema declares secret (D783), when the caller
15876
+ * knows them — those values are kept in the keychain, not the blob (D787).
15877
+ * Absent: the paths the device last reported at `registerDevice` apply. */
15878
+ secretConfigPaths: array(string()).optional()
15018
15879
  });
15019
15880
  /** What a migration actually did, per switch. `unreachable` is a first-class
15020
15881
  * answer: a camera that could not be asked is not a camera that was silenced. */
@@ -21993,8 +22854,23 @@ var RetrainMacroClassSchema = _enum([
21993
22854
  ]);
21994
22855
  /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
21995
22856
  var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
21996
- /** Did a human draw this box, or did the assist propose it? */
21997
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
22857
+ /**
22858
+ * Where a box came from. A machine-sourced box is a DRAFT on the page until
22859
+ * the operator confirms it; once saved it keeps its source as provenance.
22860
+ *
22861
+ * - `operator` — drawn by hand.
22862
+ * - `assist` — proposed by a detector run on the copy (the camera's own
22863
+ * model, or a larger teacher model).
22864
+ * - `pipeline` — the box the live pipeline actually drew on that frame, read
22865
+ * back from the track store (never a re-run).
22866
+ * - `llm` — proposed by a vision-capable LLM profile.
22867
+ */
22868
+ var RetrainAnnotationSourceSchema = _enum([
22869
+ "operator",
22870
+ "assist",
22871
+ "pipeline",
22872
+ "llm"
22873
+ ]);
21998
22874
  /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
21999
22875
  var RetrainBboxSchema = object({
22000
22876
  x: number(),
@@ -22012,7 +22888,8 @@ var RetrainBboxSchema = object({
22012
22888
  */
22013
22889
  var RetrainAnnotationSchema = object({
22014
22890
  id: string(),
22015
- trackId: string(),
22891
+ /** The frame's track. Absent on a recording still, which has none. */
22892
+ trackId: string().optional(),
22016
22893
  deviceId: number(),
22017
22894
  /** The COPY in retrain storage — never the source track's media key. */
22018
22895
  mediaKey: string(),
@@ -22061,13 +22938,47 @@ var RetrainFrameCandidateSchema = object({
22061
22938
  * fail, whatever became of the original. */
22062
22939
  copied: boolean()
22063
22940
  });
22941
+ /**
22942
+ * One box the live pipeline drew on a copied frame — what a correction starts
22943
+ * from. Derived when the frame is listed, from the track store: the subject
22944
+ * box recorded on the source media row when there is one, else the track
22945
+ * position nearest the frame's capture time. Never stored as an annotation
22946
+ * until the operator confirms it.
22947
+ */
22948
+ var RetrainPipelineBoxSchema = object({
22949
+ /** Normalised `[0,1]` against the full frame. */
22950
+ bbox: RetrainBboxSchema,
22951
+ macroClass: RetrainMacroClassSchema,
22952
+ label: string().optional(),
22953
+ subLabel: string().optional(),
22954
+ /** The detection score of the position used, when it was recorded. */
22955
+ score: number().optional(),
22956
+ /** The root model that produced the track, when it was recorded. */
22957
+ modelId: string().optional(),
22958
+ trackId: string(),
22959
+ /** `subject-box`: recorded on this very frame. `position`: the track's
22960
+ * position nearest the capture time, `deltaMs` away. */
22961
+ basis: _enum(["subject-box", "position"]),
22962
+ deltaMs: number()
22963
+ });
22964
+ /**
22965
+ * Where a retrain frame came from: a TRACK's stored media (copy-on-select),
22966
+ * or the RECORDING at an instant — the frame a model saw nothing in has no
22967
+ * track at all.
22968
+ */
22969
+ var RetrainFrameOriginSchema = _enum(["track", "recording"]);
22064
22970
  /** A frame the dataset OWNS: bytes copied at selection time. */
22065
22971
  var RetrainFrameSchema = object({
22066
22972
  frameId: string(),
22067
22973
  deviceId: number(),
22068
- trackId: string(),
22069
- /** Provenance only. It may already point at nothing — that is expected. */
22070
- sourceMediaId: number().int(),
22974
+ origin: RetrainFrameOriginSchema,
22975
+ /** The track it was copied from. Absent on a recording still. */
22976
+ trackId: string().optional(),
22977
+ /** Provenance only. It may already point at nothing — that is expected.
22978
+ * Absent on a recording still. */
22979
+ sourceMediaId: number().int().optional(),
22980
+ /** A recording still: the playhead instant it was taken at. */
22981
+ epochMs: number().optional(),
22071
22982
  sourceKind: MediaFileKindEnum,
22072
22983
  sizeBytes: number().int(),
22073
22984
  width: number().int(),
@@ -22078,7 +22989,12 @@ var RetrainFrameSchema = object({
22078
22989
  /** The operator's "every subject in this frame is boxed". Detector
22079
22990
  * evaluation keeps only complete frames: an unboxed subject would count as
22080
22991
  * a false positive. */
22081
- complete: boolean()
22992
+ complete: boolean(),
22993
+ /** The boxes the pipeline drew on this frame. Present on list answers;
22994
+ * empty when nothing the track store holds can be placed on it. */
22995
+ pipelineBoxes: array(RetrainPipelineBoxSchema).readonly().optional(),
22996
+ /** The named collections this frame belongs to. Present on list answers. */
22997
+ collectionIds: array(string()).readonly().optional()
22082
22998
  });
22083
22999
  /** Why a copy-on-select could not be honoured — named, never a silent skip. */
22084
23000
  var RetrainCopyRefusalSchema = _enum([
@@ -22109,6 +23025,11 @@ var RetrainFrameListSchema = object({
22109
23025
  var RetrainExportFilterSchema = object({
22110
23026
  deviceIds: array(number()).optional(),
22111
23027
  frameIds: array(string()).max(2e4).optional(),
23028
+ /** Only frames in at least one of these named collections. */
23029
+ collectionIds: array(string()).max(200).optional(),
23030
+ /** Exactly the frames of this dataset version (and its completeOnly). An
23031
+ * unknown id selects nothing. */
23032
+ datasetVersionId: string().optional(),
22112
23033
  batchId: string().optional(),
22113
23034
  /** Only frames the operator marked complete (all subjects boxed). */
22114
23035
  completeOnly: boolean().optional()
@@ -22173,6 +23094,170 @@ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
22173
23094
  reason: string(),
22174
23095
  detail: string().optional()
22175
23096
  })]);
23097
+ /** A named set over the retrain corpus — membership only, it owns no pixels. */
23098
+ var RetrainCollectionSchema = object({
23099
+ id: string(),
23100
+ name: string(),
23101
+ createdAt: number(),
23102
+ frameCount: number().int()
23103
+ });
23104
+ var RetrainCollectionCreateResultSchema = discriminatedUnion("kind", [object({
23105
+ kind: literal("created"),
23106
+ collection: RetrainCollectionSchema
23107
+ }), object({
23108
+ kind: literal("refused"),
23109
+ reason: _enum(["empty-name", "duplicate-name"])
23110
+ })]);
23111
+ var RetrainCollectionRenameResultSchema = discriminatedUnion("kind", [object({
23112
+ kind: literal("renamed"),
23113
+ collection: RetrainCollectionSchema
23114
+ }), object({
23115
+ kind: literal("refused"),
23116
+ reason: _enum([
23117
+ "empty-name",
23118
+ "duplicate-name",
23119
+ "unknown-collection"
23120
+ ])
23121
+ })]);
23122
+ /**
23123
+ * The outcome of adding the frame at a recording instant. Every refusal is
23124
+ * named: `still-unavailable` (not recording, a gap, or an undecodable frame —
23125
+ * `detail` says which), `still-busy` (the recorder is at its decode bound; try
23126
+ * again), `unreadable-image`, `write-failed`, `unknown-collection`.
23127
+ */
23128
+ var AddRetrainFrameFromRecordingResultSchema = discriminatedUnion("kind", [object({
23129
+ kind: literal("added"),
23130
+ collectionId: string(),
23131
+ frame: RetrainFrameSchema,
23132
+ /** The moment was already in the dataset; nothing was decoded. */
23133
+ reused: boolean()
23134
+ }), object({
23135
+ kind: literal("refused"),
23136
+ reason: _enum([
23137
+ "unknown-collection",
23138
+ "still-unavailable",
23139
+ "still-busy",
23140
+ "unreadable-image",
23141
+ "write-failed"
23142
+ ]),
23143
+ detail: string().optional()
23144
+ })]);
23145
+ /** A vision LLM profile the AI assist may use, and where it sends the frame. */
23146
+ var RetrainAssistProfileSchema = object({
23147
+ id: string(),
23148
+ name: string(),
23149
+ model: string(),
23150
+ kind: string(),
23151
+ /** `true` when the frame would leave the house (a cloud vendor, or an
23152
+ * endpoint that is not on the local network). The page confirms each such
23153
+ * run, and the provider refuses one without `allowCloud`. */
23154
+ leavesHouse: boolean()
23155
+ });
23156
+ /** A box the AI assist proposed: a draft, plus the model's own reason. */
23157
+ var RetrainLlmProposalSchema = RetrainAnnotationDraftSchema.extend({ reason: string() });
23158
+ /** What the AI assist said about a box that was already on the canvas. */
23159
+ var RetrainLlmReviewSchema = object({
23160
+ /** The `ref` the page sent the box under. */
23161
+ ref: string(),
23162
+ verdict: _enum([
23163
+ "confirmed",
23164
+ "wrong-class",
23165
+ "not-an-object",
23166
+ "uncertain"
23167
+ ]),
23168
+ suggestedClass: RetrainMacroClassSchema.optional(),
23169
+ reason: string()
23170
+ });
23171
+ /**
23172
+ * The AI assist's answer. `proposed` carries drafts (`source: 'llm'`, the
23173
+ * model and its confidence) and reviews; items the model got wrong (a box off
23174
+ * the frame, an unasked class, an unknown ref) are dropped and counted in
23175
+ * `rejected`. A whole answer that is not the schema is `malformed-answer`.
23176
+ */
23177
+ var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
23178
+ kind: literal("proposed"),
23179
+ profileId: string(),
23180
+ model: string(),
23181
+ /** The frame was sent outside the house for this answer. */
23182
+ leftHouse: boolean(),
23183
+ proposals: array(RetrainLlmProposalSchema).readonly(),
23184
+ reviews: array(RetrainLlmReviewSchema).readonly(),
23185
+ rejected: number().int()
23186
+ }), object({
23187
+ kind: literal("refused"),
23188
+ reason: _enum([
23189
+ "unknown-frame",
23190
+ "unreadable-frame",
23191
+ "unknown-profile",
23192
+ "profile-disabled",
23193
+ "no-vision",
23194
+ "cloud-not-confirmed",
23195
+ "llm-error",
23196
+ "malformed-answer"
23197
+ ]),
23198
+ detail: string().optional()
23199
+ })]);
23200
+ /** What a dataset version is cut from. Every field narrows. */
23201
+ var RetrainDatasetSelectionSchema = object({
23202
+ deviceIds: array(number()).readonly().optional(),
23203
+ collectionIds: array(string()).max(200).readonly().optional(),
23204
+ frameIds: array(string()).max(2e4).readonly().optional()
23205
+ });
23206
+ /** The counts a dataset is judged by. */
23207
+ var RetrainDatasetStatsSchema = object({
23208
+ frames: number().int(),
23209
+ completeFrames: number().int(),
23210
+ /** `completeFrames / frames`, 0..1. */
23211
+ completeness: number(),
23212
+ /** Boxes to learn (model errors excluded). */
23213
+ subjects: number().int(),
23214
+ modelErrors: number().int(),
23215
+ /** Complete frames with no subject. */
23216
+ hardNegatives: number().int(),
23217
+ /** Subjects per class × camera × day/night. */
23218
+ cells: array(object({
23219
+ macroClass: string(),
23220
+ deviceId: number(),
23221
+ lighting: _enum([
23222
+ "day",
23223
+ "night",
23224
+ "unknown"
23225
+ ]),
23226
+ subjects: number().int(),
23227
+ frames: number().int()
23228
+ })).readonly(),
23229
+ cameras: array(object({
23230
+ deviceId: number(),
23231
+ frames: number().int(),
23232
+ completeFrames: number().int()
23233
+ })).readonly()
23234
+ });
23235
+ /** An immutable dataset version, without its frame list. */
23236
+ var RetrainDatasetVersionSchema = object({
23237
+ id: string(),
23238
+ name: string(),
23239
+ createdAt: number(),
23240
+ selection: RetrainDatasetSelectionSchema,
23241
+ layout: RetrainExportLayoutSchema,
23242
+ completeOnly: boolean(),
23243
+ frameCount: number().int(),
23244
+ /** sha256 of what the frames taught when the version was frozen. */
23245
+ annotationHash: string(),
23246
+ /** The export manifest schema the version was cut under. */
23247
+ manifestSchema: string(),
23248
+ stats: RetrainDatasetStatsSchema
23249
+ });
23250
+ var CreateRetrainDatasetVersionResultSchema = discriminatedUnion("kind", [object({
23251
+ kind: literal("created"),
23252
+ version: RetrainDatasetVersionSchema
23253
+ }), object({
23254
+ kind: literal("refused"),
23255
+ reason: _enum([
23256
+ "empty-name",
23257
+ "duplicate-name",
23258
+ "no-frames"
23259
+ ])
23260
+ })]);
22176
23261
  /** The outcome of a lifecycle move owned by the retrain page. */
22177
23262
  var RetrainTransitionResultSchema = object({
22178
23263
  trackId: string(),
@@ -22890,7 +23975,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
22890
23975
  auth: "admin"
22891
23976
  }), method(object({
22892
23977
  deviceId: number(),
22893
- trackId: string(),
23978
+ trackId: string().optional(),
22894
23979
  frameId: string()
22895
23980
  }), object({
22896
23981
  removed: boolean(),
@@ -22907,7 +23992,8 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
22907
23992
  auth: "admin"
22908
23993
  }), method(object({
22909
23994
  deviceId: number(),
22910
- trackId: string(),
23995
+ /** The frame's track, when it has one — checked against the frame. */
23996
+ trackId: string().optional(),
22911
23997
  frameId: string(),
22912
23998
  subject: RetrainAssistSubjectSchema,
22913
23999
  /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
@@ -22915,12 +24001,16 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
22915
24001
  }), RetrainAssistResultSchema, {
22916
24002
  kind: "mutation",
22917
24003
  auth: "admin"
22918
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
24004
+ }), method(object({
24005
+ trackId: string().optional(),
24006
+ frameIds: array(string()).max(2e3).optional()
24007
+ }), array(RetrainAnnotationSchema).readonly(), {
22919
24008
  kind: "query",
22920
24009
  auth: "admin"
22921
24010
  }), method(object({
22922
24011
  deviceId: number(),
22923
- trackId: string(),
24012
+ /** The frame's track, when it has one — checked against the frame. */
24013
+ trackId: string().optional(),
22924
24014
  frameId: string(),
22925
24015
  annotations: array(RetrainAnnotationDraftSchema)
22926
24016
  }), array(RetrainAnnotationSchema).readonly(), {
@@ -22943,7 +24033,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
22943
24033
  auth: "admin"
22944
24034
  }), method(object({
22945
24035
  deviceId: number(),
22946
- trackId: string(),
24036
+ trackId: string().optional(),
22947
24037
  frameId: string(),
22948
24038
  complete: boolean()
22949
24039
  }), RetrainFrameSchema, {
@@ -22957,6 +24047,104 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
22957
24047
  kind: "mutation",
22958
24048
  auth: "admin",
22959
24049
  timeoutMs: 60 * 6e4
24050
+ }), method(object({
24051
+ selection: RetrainDatasetSelectionSchema,
24052
+ completeOnly: boolean().optional()
24053
+ }), RetrainDatasetStatsSchema, {
24054
+ kind: "query",
24055
+ auth: "admin"
24056
+ }), method(object({
24057
+ name: string().max(120),
24058
+ selection: RetrainDatasetSelectionSchema,
24059
+ layout: RetrainExportLayoutSchema,
24060
+ completeOnly: boolean()
24061
+ }), CreateRetrainDatasetVersionResultSchema, {
24062
+ kind: "mutation",
24063
+ auth: "admin",
24064
+ timeoutMs: 12e4
24065
+ }), method(object({}), array(RetrainDatasetVersionSchema).readonly(), {
24066
+ kind: "query",
24067
+ auth: "admin"
24068
+ }), method(object({ id: string() }), object({ deleted: boolean() }), {
24069
+ kind: "mutation",
24070
+ auth: "admin"
24071
+ }), method(object({ id: string() }), object({
24072
+ found: boolean(),
24073
+ annotationHash: string(),
24074
+ matches: boolean(),
24075
+ missingFrames: number().int()
24076
+ }), {
24077
+ kind: "query",
24078
+ auth: "admin",
24079
+ timeoutMs: 12e4
24080
+ }), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
24081
+ kind: "query",
24082
+ auth: "admin"
24083
+ }), method(object({
24084
+ deviceId: number(),
24085
+ trackId: string().optional(),
24086
+ frameId: string(),
24087
+ profileId: string(),
24088
+ classes: array(RetrainMacroClassSchema).min(1),
24089
+ boxes: array(object({
24090
+ ref: string(),
24091
+ bbox: RetrainBboxSchema,
24092
+ macroClass: RetrainMacroClassSchema,
24093
+ label: string().optional()
24094
+ })).max(50),
24095
+ allowCloud: boolean()
24096
+ }), RetrainLlmAssistResultSchema, {
24097
+ kind: "mutation",
24098
+ auth: "admin",
24099
+ timeoutMs: 18e4
24100
+ }), method(object({ name: string().max(120) }), RetrainCollectionCreateResultSchema, {
24101
+ kind: "mutation",
24102
+ auth: "admin"
24103
+ }), method(object({}), array(RetrainCollectionSchema).readonly(), {
24104
+ kind: "query",
24105
+ auth: "admin"
24106
+ }), method(object({
24107
+ id: string(),
24108
+ name: string().max(120)
24109
+ }), RetrainCollectionRenameResultSchema, {
24110
+ kind: "mutation",
24111
+ auth: "admin"
24112
+ }), method(object({ id: string() }), object({
24113
+ deleted: boolean(),
24114
+ removedFrames: number().int()
24115
+ }), {
24116
+ kind: "mutation",
24117
+ auth: "admin"
24118
+ }), method(object({
24119
+ collectionId: string(),
24120
+ deviceId: number(),
24121
+ epochMs: number()
24122
+ }), AddRetrainFrameFromRecordingResultSchema, {
24123
+ kind: "mutation",
24124
+ auth: "admin",
24125
+ timeoutMs: 6e4
24126
+ }), method(object({
24127
+ collectionId: string(),
24128
+ frameIds: array(string()).min(1).max(500)
24129
+ }), object({
24130
+ added: number().int(),
24131
+ alreadyMember: number().int(),
24132
+ unknownFrameIds: array(string()).readonly()
24133
+ }), {
24134
+ kind: "mutation",
24135
+ auth: "admin"
24136
+ }), method(object({
24137
+ collectionId: string(),
24138
+ frameId: string()
24139
+ }), object({
24140
+ removed: boolean(),
24141
+ deletedFrame: boolean()
24142
+ }), {
24143
+ kind: "mutation",
24144
+ auth: "admin"
24145
+ }), method(object({ collectionId: string() }), array(RetrainFrameSchema).readonly(), {
24146
+ kind: "query",
24147
+ auth: "admin"
22960
24148
  }), method(object({
22961
24149
  /** Which of the three event tables owns the row. */
22962
24150
  ownerType: EventOwnerTypeSchema,
@@ -23580,13 +24768,31 @@ var RecommendationReasonSchema = discriminatedUnion("kind", [
23580
24768
  object({
23581
24769
  kind: literal("no-family-build"),
23582
24770
  format: ModelFormatSchema$1
24771
+ }),
24772
+ object({
24773
+ kind: literal("kept-custom-pin"),
24774
+ modelId: string(),
24775
+ deviceKey: string()
23583
24776
  })
23584
24777
  ]);
24778
+ /** Why a device is left exactly as it is, whatever the plan would pick (D786). */
24779
+ var KeptReasonSchema = _enum(["custom-pin"]);
24780
+ /**
24781
+ * Where a choice's latency came from (D791): this node's own benchmark
24782
+ * result, or the hardware-class table. Measured on the node beats the table.
24783
+ */
24784
+ var LatencySourceSchema = discriminatedUnion("kind", [object({ kind: literal("table") }), object({
24785
+ kind: literal("node-benchmark"),
24786
+ resultId: string(),
24787
+ measuredAtMs: number()
24788
+ })]);
23585
24789
  var DeviceModelChoiceSchema = object({
23586
24790
  modelId: string(),
23587
24791
  p50Ms: number(),
23588
24792
  fps: number(),
23589
24793
  measured: boolean(),
24794
+ /** Absent on a plan from before D791 — read as the table. */
24795
+ source: LatencySourceSchema.optional(),
23590
24796
  /** Parallel sessions at the camera rate with the headroom kept free: ⌊fps × (1 − headroom) / camera fps⌋. */
23591
24797
  capacitySessions: number(),
23592
24798
  personRecall: number()
@@ -23597,6 +24803,8 @@ var DeviceRecommendationSchema = object({
23597
24803
  enabled: boolean(),
23598
24804
  available: boolean(),
23599
24805
  chosen: DeviceModelChoiceSchema.nullable(),
24806
+ /** Present when the device is kept as is: Apply writes nothing on it. */
24807
+ kept: KeptReasonSchema.optional(),
23600
24808
  reasons: array(RecommendationReasonSchema).readonly()
23601
24809
  });
23602
24810
  var NodeRecommendationSchema = object({
@@ -23650,6 +24858,17 @@ var AutoTuneWarningSchema = discriminatedUnion("kind", [
23650
24858
  kind: literal("coral-enabled"),
23651
24859
  nodeId: string(),
23652
24860
  deviceKey: string()
24861
+ }),
24862
+ object({
24863
+ kind: literal("custom-pin-kept"),
24864
+ nodeId: string(),
24865
+ deviceKey: string().nullable(),
24866
+ deviceId: number().nullable(),
24867
+ modelId: string()
24868
+ }),
24869
+ object({
24870
+ kind: literal("custom-registry-unreadable"),
24871
+ error: string()
23653
24872
  })
23654
24873
  ]);
23655
24874
  var AutoTuneOptionsSchema = object({
@@ -23828,13 +25047,14 @@ var SuggestSharesResultSchema = object({
23828
25047
  nodes: array(SuggestedNodeShareSchema).readonly()
23829
25048
  });
23830
25049
  /**
23831
- * Where the node and device shares come from (D750, D755).
23832
- * - `hardware` (default) — computed by the system from each node's static
23833
- * capacity (its accelerators at their Auto tune models, from the measured
23834
- * latency table), recomputed whenever a node or device joins, leaves, is
23835
- * switched on or off, or changes model. No load input.
23836
- * - `benchmark` — the same, from each node's measured capacity (node
23837
- * benchmark results); a node without results falls back to `hardware`.
25050
+ * Where the node and device shares come from (D750, D755, D791).
25051
+ * - `benchmark` (default since D791) — each node's capacity as its own node
25052
+ * benchmark measured it; a node without fresh results is sized from
25053
+ * `hardware` and says so. Measured on the node beats the table.
25054
+ * - `hardware` — computed from each node's static capacity only (its
25055
+ * accelerators at their Auto tune models, from the latency table).
25056
+ * Both are recomputed whenever a node or device joins, leaves, is switched
25057
+ * on or off, changes model, or a benchmark result is written. No load input.
23838
25058
  * - `manual` — the operator's stored sliders.
23839
25059
  * Either way a node or device that cannot take sessions gives its share to
23840
25060
  * the others in proportion; the stored values are never rewritten for that.
@@ -23883,6 +25103,362 @@ var EffectiveSharesSchema = object({
23883
25103
  nodeWeights: record(string(), number()),
23884
25104
  deviceWeights: record(string(), record(string(), number()))
23885
25105
  });
25106
+ /**
25107
+ * Wire shapes of the node benchmark (D791): the operator's plan, the
25108
+ * preflight the confirmation shows, the run the orchestrator owns, what the
25109
+ * measuring runner reports, and the result rows Auto tune and the automatic
25110
+ * shares read.
25111
+ *
25112
+ * ONE node at a time, owned by the pipeline orchestrator. While a run is
25113
+ * active the cluster is in BENCHMARK MODE for that node: it is not a
25114
+ * detection candidate, camera pins naming it are ignored so its sessions move
25115
+ * elsewhere, and both come back when the mode ends — after a crash or a hub
25116
+ * restart too (a persisted manifest, reconciled against the registry).
25117
+ *
25118
+ * Two measurements, both on the node, driven by its own runner (frames never
25119
+ * cross a process at frame rate, D9):
25120
+ * - `device` — one accelerator × one candidate detector, root only, open
25121
+ * loop: how many streams at the camera rate it carries inside the frame
25122
+ * interval;
25123
+ * - `pipeline` — the chosen detector plus the operator's detail steps
25124
+ * (faces, plates, classifiers, CLIP…), on varied frames from the bench
25125
+ * clip: how many parallel sessions the node carries before latency, drops,
25126
+ * CPU, RAM or the event loop give out.
25127
+ */
25128
+ /** Defaults and bounds, one place. */
25129
+ var NODE_BENCHMARK_DEFAULTS = {
25130
+ fpsPerStream: 10,
25131
+ budgetMinutes: 45,
25132
+ minBudgetMinutes: 10,
25133
+ maxBudgetMinutes: 120,
25134
+ /** A result older than this no longer beats the table. */
25135
+ staleAfterDays: 30,
25136
+ /** Warm-in per ramp step (not accounted). */
25137
+ settleSec: 5,
25138
+ /** Accounted window per ramp step. */
25139
+ measureSec: 20,
25140
+ /** Longest the drain may take before the run is refused. */
25141
+ drainTimeoutSec: 120,
25142
+ /** Candidate models per device in one run. */
25143
+ maxModelsPerDevice: 6
25144
+ };
25145
+ /** The two measurements a run can make. */
25146
+ var NodeBenchmarkPhaseSchema = _enum(["device", "pipeline"]);
25147
+ var NodeBenchmarkDevicePlanSchema = object({
25148
+ /** `<backend>:<device>` — `openvino:npu`, `coreml:all`, `cpu`. */
25149
+ deviceKey: string().min(1),
25150
+ /**
25151
+ * Root detector candidates for the `device` measurement, in the order
25152
+ * measured. The FIRST is the one the `pipeline` measurement runs.
25153
+ */
25154
+ modelIds: array(string().min(1)).min(1).max(NODE_BENCHMARK_DEFAULTS.maxModelsPerDevice)
25155
+ });
25156
+ /** What the operator confirmed. */
25157
+ var NodeBenchmarkPlanSchema = object({
25158
+ nodeId: string().min(1),
25159
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
25160
+ /** Which measurements run. At least one. */
25161
+ phases: array(NodeBenchmarkPhaseSchema).min(1).default(["device", "pipeline"]),
25162
+ /**
25163
+ * Detail steps (catalog step ids under the root: faces, plates,
25164
+ * classifiers, CLIP…) the `pipeline` measurement enables. The root
25165
+ * detector always runs.
25166
+ */
25167
+ steps: array(string().min(1)).default([]),
25168
+ /** Offered rate of one stream / session. */
25169
+ fpsPerStream: number().int().min(1).max(30).default(NODE_BENCHMARK_DEFAULTS.fpsPerStream),
25170
+ /** Hard deadline: the mode ends and the cluster is restored when it passes. */
25171
+ budgetMinutes: number().int().min(NODE_BENCHMARK_DEFAULTS.minBudgetMinutes).max(NODE_BENCHMARK_DEFAULTS.maxBudgetMinutes).default(NODE_BENCHMARK_DEFAULTS.budgetMinutes),
25172
+ /** Keep the models the run downloaded (default: delete what was not installed before). */
25173
+ keepDownloadedModels: boolean().default(false),
25174
+ /** Start although the other nodes' capacity does not cover the sessions running now. */
25175
+ acceptInsufficientHeadroom: boolean().default(false)
25176
+ });
25177
+ var NodeBenchmarkRefusalSchema = object({
25178
+ kind: _enum([
25179
+ "benchmark-active",
25180
+ "node-offline",
25181
+ "unknown-device",
25182
+ "no-phase",
25183
+ "insufficient-headroom"
25184
+ ]),
25185
+ detail: string(),
25186
+ overridable: boolean()
25187
+ });
25188
+ /** A camera whose detection leaves the node for the run. */
25189
+ var NodeBenchmarkMovingCameraSchema = object({
25190
+ deviceId: number(),
25191
+ /** Placed on the node now (a standing attach or a running session). */
25192
+ placedOnNode: boolean(),
25193
+ /** A node pin naming this node, ignored for the run. */
25194
+ pinnedToNode: boolean()
25195
+ });
25196
+ /** A camera that cannot leave: no other node can obtain its frames. */
25197
+ var NodeBenchmarkStayingCameraSchema = object({
25198
+ deviceId: number(),
25199
+ reason: literal("only-frame-source")
25200
+ });
25201
+ var NodeBenchmarkPreflightSchema = object({
25202
+ nodeId: string(),
25203
+ online: boolean(),
25204
+ moving: array(NodeBenchmarkMovingCameraSchema).readonly(),
25205
+ /** Keep running on the node during the run; the result is flagged contaminated. */
25206
+ staying: array(NodeBenchmarkStayingCameraSchema).readonly(),
25207
+ estimatedDurationMs: number(),
25208
+ /** The run ends and the cluster is restored at the latest after this long. */
25209
+ budgetMs: number(),
25210
+ phases: array(NodeBenchmarkPhaseSchema).readonly(),
25211
+ steps: array(string()).readonly(),
25212
+ devices: array(NodeBenchmarkDevicePlanSchema).readonly(),
25213
+ /** Parallel sessions the cluster runs now, and what the other nodes can carry. */
25214
+ headroom: object({
25215
+ sessionsNow: number(),
25216
+ otherNodesCapacitySessions: number().nullable()
25217
+ }),
25218
+ refusals: array(NodeBenchmarkRefusalSchema).readonly(),
25219
+ canStart: boolean()
25220
+ });
25221
+ /** Where the measuring runner is. */
25222
+ var NodeBenchProgressSchema = object({
25223
+ phase: _enum([
25224
+ "preparing",
25225
+ "device",
25226
+ "pipeline",
25227
+ "cleanup"
25228
+ ]),
25229
+ deviceKey: string().nullable(),
25230
+ modelId: string().nullable(),
25231
+ /** Streams (device) or sessions (pipeline) of the step running now. */
25232
+ load: number().nullable(),
25233
+ cellsDone: number(),
25234
+ cellsTotal: number(),
25235
+ message: string()
25236
+ });
25237
+ /** What limited a ramp. `none` = the ramp ran out of steps still passing. */
25238
+ var NodeBenchLimitSchema = _enum([
25239
+ "p95",
25240
+ "drops",
25241
+ "errors",
25242
+ "stall",
25243
+ "cpu",
25244
+ "ram",
25245
+ "none"
25246
+ ]);
25247
+ var NodeBenchRampStepSchema = object({
25248
+ load: number(),
25249
+ pass: boolean(),
25250
+ p95Ms: number(),
25251
+ dropRatio: number(),
25252
+ /** Completed frames per second over the accounted window. */
25253
+ fps: number(),
25254
+ cpuPct: number().nullable(),
25255
+ ramFreePct: number().nullable(),
25256
+ failReasons: array(string()).readonly()
25257
+ });
25258
+ var NodeBenchCellSchema = discriminatedUnion("phase", [object({
25259
+ phase: literal("device"),
25260
+ deviceKey: string(),
25261
+ modelId: string(),
25262
+ /** Single-stream latency (the K = 1 step). */
25263
+ p50Ms: number(),
25264
+ p95Ms: number(),
25265
+ p99Ms: number(),
25266
+ /** Frames per second sustained at the last passing step. */
25267
+ fps: number(),
25268
+ /** Streams at the camera rate the device carried inside the frame interval; 0 = not even one. */
25269
+ kMax: number(),
25270
+ limitedBy: NodeBenchLimitSchema,
25271
+ /** First call (model load + warm-up). */
25272
+ warmupMs: number(),
25273
+ ramp: array(NodeBenchRampStepSchema).readonly()
25274
+ }), object({
25275
+ phase: literal("pipeline"),
25276
+ deviceKey: string(),
25277
+ modelId: string(),
25278
+ steps: array(string()).readonly(),
25279
+ /** Parallel sessions at the camera rate the node carried; 0 = not even one. */
25280
+ maxSessions: number(),
25281
+ limitedBy: NodeBenchLimitSchema,
25282
+ /** Detail steps that produced at least one result on the clip — a step that never fired measured nothing. */
25283
+ stepsFired: array(string()).readonly(),
25284
+ warmupMs: number(),
25285
+ ramp: array(NodeBenchRampStepSchema).readonly()
25286
+ })]);
25287
+ /**
25288
+ * What a result was measured ON. A result whose fingerprint no longer matches
25289
+ * the node no longer beats the table.
25290
+ */
25291
+ var NodeBenchFingerprintSchema = object({
25292
+ pipelineVersion: string().nullable(),
25293
+ cpuModel: string().nullable(),
25294
+ ramGb: number().nullable(),
25295
+ os: string().nullable(),
25296
+ /** Per device: the pool the cells ran on (runtime + tuning). */
25297
+ pools: record(string(), object({
25298
+ runtime: string(),
25299
+ numWorkers: number(),
25300
+ concurrency: number(),
25301
+ batchMode: string()
25302
+ })).default({})
25303
+ });
25304
+ /** The frames the run used. */
25305
+ var NodeBenchClipSchema = object({
25306
+ /** `camstack-bench-v1` or `reference-images` (the fallback when the clip is not reachable). */
25307
+ id: string(),
25308
+ revision: string().nullable(),
25309
+ frames: number(),
25310
+ width: number(),
25311
+ height: number()
25312
+ });
25313
+ var NodeBenchRunnerInputSchema = object({
25314
+ runId: string().min(1),
25315
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
25316
+ phases: array(NodeBenchmarkPhaseSchema).min(1),
25317
+ /** The full detail step tree root for the `pipeline` measurement is built on the node from these ids. */
25318
+ steps: array(string()).default([]),
25319
+ fpsPerStream: number().int().min(1).max(30),
25320
+ /** The runner stops on its own past this instant, whatever the hub does. */
25321
+ deadlineAtMs: number(),
25322
+ settleSec: number().min(0).max(60).default(NODE_BENCHMARK_DEFAULTS.settleSec),
25323
+ measureSec: number().min(2).max(300).default(NODE_BENCHMARK_DEFAULTS.measureSec),
25324
+ keepDownloadedModels: boolean().default(false)
25325
+ });
25326
+ var NodeBenchRunnerStateSchema = _enum([
25327
+ "running",
25328
+ "done",
25329
+ "failed",
25330
+ "aborted"
25331
+ ]);
25332
+ var NodeBenchRunnerStatusSchema = object({
25333
+ runId: string(),
25334
+ nodeId: string(),
25335
+ state: NodeBenchRunnerStateSchema,
25336
+ progress: NodeBenchProgressSchema.nullable(),
25337
+ /** Every finished cell so far — a run stopped half way keeps what it measured. */
25338
+ cells: array(NodeBenchCellSchema).readonly(),
25339
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
25340
+ clip: NodeBenchClipSchema.nullable(),
25341
+ /** Cameras seen running on the node during the run (they share its pools). */
25342
+ activeCameraIds: array(number()).readonly(),
25343
+ /** Models the run downloaded and then deleted (not installed before). */
25344
+ deletedModels: array(string()).readonly(),
25345
+ error: string().nullable(),
25346
+ startedAtMs: number(),
25347
+ finishedAtMs: number().nullable()
25348
+ });
25349
+ var NodeBenchmarkStateSchema = _enum([
25350
+ "draining",
25351
+ "measuring",
25352
+ "restoring",
25353
+ "done",
25354
+ "failed",
25355
+ "aborted"
25356
+ ]);
25357
+ /** Why a run ended. */
25358
+ var NodeBenchmarkEndReasonSchema = _enum([
25359
+ "completed",
25360
+ "operator-abort",
25361
+ "deadline",
25362
+ "node-lost",
25363
+ "runner-lost",
25364
+ "hub-restart",
25365
+ "drain-timeout",
25366
+ "failed"
25367
+ ]);
25368
+ var NodeBenchmarkRunSchema = object({
25369
+ runId: string(),
25370
+ nodeId: string(),
25371
+ state: NodeBenchmarkStateSchema,
25372
+ plan: NodeBenchmarkPlanSchema,
25373
+ startedAtMs: number(),
25374
+ deadlineAtMs: number(),
25375
+ finishedAtMs: number().nullable(),
25376
+ endReason: NodeBenchmarkEndReasonSchema.nullable(),
25377
+ error: string().nullable(),
25378
+ /** Cameras moved off the node for the run. */
25379
+ moved: array(number()).readonly(),
25380
+ /** Cameras that stayed (their only frame source is the node). */
25381
+ staying: array(number()).readonly(),
25382
+ /** Something else ran on the node's pools during the run. */
25383
+ contaminated: boolean(),
25384
+ progress: NodeBenchProgressSchema.nullable(),
25385
+ resultIds: array(string()).readonly()
25386
+ });
25387
+ /** `getNodeBenchmarkStatus`: the active run (or the last one), and whether benchmark mode is on. */
25388
+ var NodeBenchmarkStatusSchema = object({
25389
+ /** The node the cluster is in benchmark mode for; null = none. */
25390
+ modeNodeId: string().nullable(),
25391
+ run: NodeBenchmarkRunSchema.nullable()
25392
+ });
25393
+ /**
25394
+ * One stored measurement — the only authority Auto tune and the automatic
25395
+ * shares read measured capacity from. Written by the orchestrator when a run
25396
+ * ends, never by anyone else.
25397
+ */
25398
+ var NodeBenchmarkResultSchema = object({
25399
+ id: string(),
25400
+ runId: string(),
25401
+ nodeId: string(),
25402
+ cell: NodeBenchCellSchema,
25403
+ fpsPerStream: number(),
25404
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
25405
+ clip: NodeBenchClipSchema.nullable(),
25406
+ /** Other work shared the node's pools (a camera that could not move, or the hub's own duties). */
25407
+ contaminated: boolean(),
25408
+ stayingCameras: array(number()).readonly(),
25409
+ /** The run ended early; the cell itself completed. */
25410
+ partialRun: boolean(),
25411
+ measuredAtMs: number()
25412
+ });
25413
+ var ListNodeBenchmarkResultsInputSchema = object({
25414
+ nodeId: string().optional(),
25415
+ deviceKey: string().optional()
25416
+ });
25417
+ /** A result with its standing today: does it still beat the table? */
25418
+ var NodeBenchmarkResultViewSchema = NodeBenchmarkResultSchema.extend({
25419
+ /** `fresh` beats the table; `stale` falls back to it; `superseded` = a newer row covers the same cell. */
25420
+ standing: _enum([
25421
+ "fresh",
25422
+ "stale",
25423
+ "superseded"
25424
+ ]),
25425
+ staleWhy: _enum([
25426
+ "age",
25427
+ "runtime",
25428
+ "pool-tuning"
25429
+ ]).nullable()
25430
+ });
25431
+ object({
25432
+ runId: string(),
25433
+ nodeId: string(),
25434
+ startedAtMs: number(),
25435
+ deadlineAtMs: number(),
25436
+ plan: NodeBenchmarkPlanSchema,
25437
+ moved: array(number()).readonly(),
25438
+ staying: array(number()).readonly()
25439
+ });
25440
+ /** Candidate detectors per device, for the plan editor. */
25441
+ var NodeBenchmarkCandidatesSchema = object({
25442
+ nodeId: string(),
25443
+ reachable: boolean(),
25444
+ devices: array(object({
25445
+ deviceKey: string(),
25446
+ enabled: boolean(),
25447
+ available: boolean(),
25448
+ /** Ordered: what Auto tune would pick first, then the rest of the family by accuracy. */
25449
+ suggested: array(string()).readonly(),
25450
+ /** Every root detector the device has a build for. */
25451
+ all: array(string()).readonly(),
25452
+ /** The model the device runs now, when pinned. */
25453
+ currentModelId: string().nullable()
25454
+ })).readonly(),
25455
+ /** Detail steps the node's catalog offers under the root (for the `pipeline` measurement). */
25456
+ steps: array(object({
25457
+ id: string(),
25458
+ name: string(),
25459
+ slot: string()
25460
+ })).readonly()
25461
+ });
23886
25462
  object({
23887
25463
  activeCameras: number(),
23888
25464
  throttledCameras: number(),
@@ -24971,7 +26547,16 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
24971
26547
  }), ParkedTrackFrameSchema.nullable()), method(object({
24972
26548
  deviceId: number(),
24973
26549
  trackId: string()
24974
- }), object({ released: number().int().nonnegative() }), { kind: "mutation" });
26550
+ }), object({ released: number().int().nonnegative() }), { kind: "mutation" }), method(NodeBenchRunnerInputSchema, object({
26551
+ accepted: literal(true),
26552
+ runId: string()
26553
+ }), {
26554
+ kind: "mutation",
26555
+ auth: "admin"
26556
+ }), method(object({ runId: string() }), NodeBenchRunnerStatusSchema.nullable(), { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
26557
+ kind: "mutation",
26558
+ auth: "admin"
26559
+ });
24975
26560
  var CameraPipelineConfigSchema = object({
24976
26561
  engine: PipelineEngineChoiceSchema.optional(),
24977
26562
  steps: array(PipelineStepInputSchema).readonly(),
@@ -25610,6 +27195,21 @@ method(object({
25610
27195
  }), method(PlacementStatsInputSchema, PlacementStatsSchema, { auth: "admin" }), method(SuggestSharesInputSchema, SuggestSharesResultSchema, { auth: "admin" }), method(_void(), EffectiveSharesSchema, { auth: "admin" }), method(SetShareSourceInputSchema, object({ success: literal(true) }), {
25611
27196
  kind: "mutation",
25612
27197
  auth: "admin"
27198
+ }), method(NodeBenchmarkPlanSchema, NodeBenchmarkPreflightSchema, { auth: "admin" }), method(NodeBenchmarkPlanSchema, discriminatedUnion("kind", [object({
27199
+ kind: literal("started"),
27200
+ runId: string()
27201
+ }), object({
27202
+ kind: literal("refused"),
27203
+ preflight: NodeBenchmarkPreflightSchema
27204
+ })]), {
27205
+ kind: "mutation",
27206
+ auth: "admin"
27207
+ }), method(_void(), NodeBenchmarkStatusSchema, { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
27208
+ kind: "mutation",
27209
+ auth: "admin"
27210
+ }), method(object({ nodeId: string() }), NodeBenchmarkCandidatesSchema, { auth: "admin" }), method(ListNodeBenchmarkResultsInputSchema, array(NodeBenchmarkResultViewSchema).readonly(), { auth: "admin" }), method(object({ id: string() }), object({ deleted: boolean() }), {
27211
+ kind: "mutation",
27212
+ auth: "admin"
25613
27213
  }), method(object({ deviceId: number() }), CameraPipelineSettingsSchema.nullable()), method(object({
25614
27214
  deviceId: number(),
25615
27215
  addonId: string(),
@@ -30691,6 +32291,9 @@ var CreateIntegrationInputSchema = object({
30691
32291
  enabled: boolean().optional(),
30692
32292
  info: record(string(), unknown()).optional(),
30693
32293
  settings: record(string(), unknown()).optional(),
32294
+ /** Keys of `settings` the form's schema declares secret (by type) — kept in
32295
+ * the keychain, not the table (D787). */
32296
+ secretKeys: array(string()).optional(),
30694
32297
  skipRestart: boolean().optional()
30695
32298
  });
30696
32299
  var UpdateIntegrationInputSchema = object({
@@ -30714,7 +32317,9 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
30714
32317
  auth: "admin"
30715
32318
  }), method(object({ id: string() }), record(string(), unknown()), { auth: "admin" }), method(object({
30716
32319
  id: string(),
30717
- settings: record(string(), unknown())
32320
+ settings: record(string(), unknown()),
32321
+ /** Keys the form's schema declares secret (by type) — keychain-stored (D787). */
32322
+ secretKeys: array(string()).optional()
30718
32323
  }), object({ success: boolean() }), {
30719
32324
  kind: "mutation",
30720
32325
  auth: "admin"
@@ -39419,6 +41024,90 @@ Object.freeze({
39419
41024
  addonId: null,
39420
41025
  access: "create"
39421
41026
  },
41027
+ "keychain.delete": {
41028
+ capName: "keychain",
41029
+ capScope: "system",
41030
+ addonId: null,
41031
+ access: "delete"
41032
+ },
41033
+ "keychain.getState": {
41034
+ capName: "keychain",
41035
+ capScope: "system",
41036
+ addonId: null,
41037
+ access: "view"
41038
+ },
41039
+ "keychain.listMeta": {
41040
+ capName: "keychain",
41041
+ capScope: "system",
41042
+ addonId: null,
41043
+ access: "view"
41044
+ },
41045
+ "keychain.put": {
41046
+ capName: "keychain",
41047
+ capScope: "system",
41048
+ addonId: null,
41049
+ access: "create"
41050
+ },
41051
+ "keychain.resolve": {
41052
+ capName: "keychain",
41053
+ capScope: "system",
41054
+ addonId: null,
41055
+ access: "view"
41056
+ },
41057
+ "keychainAdmin.deleteOrphans": {
41058
+ capName: "keychain-admin",
41059
+ capScope: "system",
41060
+ addonId: null,
41061
+ access: "delete"
41062
+ },
41063
+ "keychainAdmin.downloadRecoveryKey": {
41064
+ capName: "keychain-admin",
41065
+ capScope: "system",
41066
+ addonId: null,
41067
+ access: "create"
41068
+ },
41069
+ "keychainAdmin.listAudit": {
41070
+ capName: "keychain-admin",
41071
+ capScope: "system",
41072
+ addonId: null,
41073
+ access: "view"
41074
+ },
41075
+ "keychainAdmin.listSecrets": {
41076
+ capName: "keychain-admin",
41077
+ capScope: "system",
41078
+ addonId: null,
41079
+ access: "view"
41080
+ },
41081
+ "keychainAdmin.purgeRetiredKeys": {
41082
+ capName: "keychain-admin",
41083
+ capScope: "system",
41084
+ addonId: null,
41085
+ access: "delete"
41086
+ },
41087
+ "keychainAdmin.resetKeychain": {
41088
+ capName: "keychain-admin",
41089
+ capScope: "system",
41090
+ addonId: null,
41091
+ access: "delete"
41092
+ },
41093
+ "keychainAdmin.reveal": {
41094
+ capName: "keychain-admin",
41095
+ capScope: "system",
41096
+ addonId: null,
41097
+ access: "create"
41098
+ },
41099
+ "keychainAdmin.rotateMasterKey": {
41100
+ capName: "keychain-admin",
41101
+ capScope: "system",
41102
+ addonId: null,
41103
+ access: "create"
41104
+ },
41105
+ "keychainAdmin.status": {
41106
+ capName: "keychain-admin",
41107
+ capScope: "system",
41108
+ addonId: null,
41109
+ access: "view"
41110
+ },
39422
41111
  "lawnMowerControl.dock": {
39423
41112
  capName: "lawn-mower-control",
39424
41113
  capScope: "device",
@@ -40793,6 +42482,18 @@ Object.freeze({
40793
42482
  addonId: null,
40794
42483
  access: "create"
40795
42484
  },
42485
+ "pipelineAnalytics.addRetrainFrameFromRecording": {
42486
+ capName: "pipeline-analytics",
42487
+ capScope: "device",
42488
+ addonId: null,
42489
+ access: "create"
42490
+ },
42491
+ "pipelineAnalytics.addRetrainFramesToCollection": {
42492
+ capName: "pipeline-analytics",
42493
+ capScope: "device",
42494
+ addonId: null,
42495
+ access: "create"
42496
+ },
40796
42497
  "pipelineAnalytics.applyDeviceSettingsPatch": {
40797
42498
  capName: "pipeline-analytics",
40798
42499
  capScope: "device",
@@ -40841,12 +42542,36 @@ Object.freeze({
40841
42542
  addonId: null,
40842
42543
  access: "view"
40843
42544
  },
42545
+ "pipelineAnalytics.createRetrainCollection": {
42546
+ capName: "pipeline-analytics",
42547
+ capScope: "device",
42548
+ addonId: null,
42549
+ access: "create"
42550
+ },
42551
+ "pipelineAnalytics.createRetrainDatasetVersion": {
42552
+ capName: "pipeline-analytics",
42553
+ capScope: "device",
42554
+ addonId: null,
42555
+ access: "create"
42556
+ },
40844
42557
  "pipelineAnalytics.deleteDeviceEvents": {
40845
42558
  capName: "pipeline-analytics",
40846
42559
  capScope: "device",
40847
42560
  addonId: null,
40848
42561
  access: "delete"
40849
42562
  },
42563
+ "pipelineAnalytics.deleteRetrainCollection": {
42564
+ capName: "pipeline-analytics",
42565
+ capScope: "device",
42566
+ addonId: null,
42567
+ access: "delete"
42568
+ },
42569
+ "pipelineAnalytics.deleteRetrainDatasetVersion": {
42570
+ capName: "pipeline-analytics",
42571
+ capScope: "device",
42572
+ addonId: null,
42573
+ access: "delete"
42574
+ },
40850
42575
  "pipelineAnalytics.deleteTracks": {
40851
42576
  capName: "pipeline-analytics",
40852
42577
  capScope: "device",
@@ -41051,6 +42776,30 @@ Object.freeze({
41051
42776
  addonId: null,
41052
42777
  access: "view"
41053
42778
  },
42779
+ "pipelineAnalytics.listRetrainAssistProfiles": {
42780
+ capName: "pipeline-analytics",
42781
+ capScope: "device",
42782
+ addonId: null,
42783
+ access: "view"
42784
+ },
42785
+ "pipelineAnalytics.listRetrainCollectionFrames": {
42786
+ capName: "pipeline-analytics",
42787
+ capScope: "device",
42788
+ addonId: null,
42789
+ access: "view"
42790
+ },
42791
+ "pipelineAnalytics.listRetrainCollections": {
42792
+ capName: "pipeline-analytics",
42793
+ capScope: "device",
42794
+ addonId: null,
42795
+ access: "view"
42796
+ },
42797
+ "pipelineAnalytics.listRetrainDatasetVersions": {
42798
+ capName: "pipeline-analytics",
42799
+ capScope: "device",
42800
+ addonId: null,
42801
+ access: "view"
42802
+ },
41054
42803
  "pipelineAnalytics.listRetrainFrames": {
41055
42804
  capName: "pipeline-analytics",
41056
42805
  capScope: "device",
@@ -41093,12 +42842,24 @@ Object.freeze({
41093
42842
  addonId: null,
41094
42843
  access: "create"
41095
42844
  },
42845
+ "pipelineAnalytics.previewRetrainDataset": {
42846
+ capName: "pipeline-analytics",
42847
+ capScope: "device",
42848
+ addonId: null,
42849
+ access: "view"
42850
+ },
41096
42851
  "pipelineAnalytics.proposeRetrainAnnotations": {
41097
42852
  capName: "pipeline-analytics",
41098
42853
  capScope: "device",
41099
42854
  addonId: null,
41100
42855
  access: "create"
41101
42856
  },
42857
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": {
42858
+ capName: "pipeline-analytics",
42859
+ capScope: "device",
42860
+ addonId: null,
42861
+ access: "create"
42862
+ },
41102
42863
  "pipelineAnalytics.pruneEvents": {
41103
42864
  capName: "pipeline-analytics",
41104
42865
  capScope: "device",
@@ -41153,6 +42914,18 @@ Object.freeze({
41153
42914
  addonId: null,
41154
42915
  access: "create"
41155
42916
  },
42917
+ "pipelineAnalytics.removeRetrainFrameFromCollection": {
42918
+ capName: "pipeline-analytics",
42919
+ capScope: "device",
42920
+ addonId: null,
42921
+ access: "delete"
42922
+ },
42923
+ "pipelineAnalytics.renameRetrainCollection": {
42924
+ capName: "pipeline-analytics",
42925
+ capScope: "device",
42926
+ addonId: null,
42927
+ access: "create"
42928
+ },
41156
42929
  "pipelineAnalytics.restageRetrainTrack": {
41157
42930
  capName: "pipeline-analytics",
41158
42931
  capScope: "device",
@@ -41213,6 +42986,12 @@ Object.freeze({
41213
42986
  addonId: null,
41214
42987
  access: "create"
41215
42988
  },
42989
+ "pipelineAnalytics.verifyRetrainDatasetVersion": {
42990
+ capName: "pipeline-analytics",
42991
+ capScope: "device",
42992
+ addonId: null,
42993
+ access: "view"
42994
+ },
41216
42995
  "pipelineAnalytics.wipeAllAnalytics": {
41217
42996
  capName: "pipeline-analytics",
41218
42997
  capScope: "device",
@@ -41441,6 +43220,12 @@ Object.freeze({
41441
43220
  addonId: null,
41442
43221
  access: "view"
41443
43222
  },
43223
+ "pipelineOrchestrator.abortNodeBenchmark": {
43224
+ capName: "pipeline-orchestrator",
43225
+ capScope: "system",
43226
+ addonId: null,
43227
+ access: "create"
43228
+ },
41444
43229
  "pipelineOrchestrator.applyAutoTune": {
41445
43230
  capName: "pipeline-orchestrator",
41446
43231
  capScope: "system",
@@ -41465,6 +43250,12 @@ Object.freeze({
41465
43250
  addonId: null,
41466
43251
  access: "create"
41467
43252
  },
43253
+ "pipelineOrchestrator.deleteNodeBenchmarkResult": {
43254
+ capName: "pipeline-orchestrator",
43255
+ capScope: "system",
43256
+ addonId: null,
43257
+ access: "delete"
43258
+ },
41468
43259
  "pipelineOrchestrator.getAgentLoad": {
41469
43260
  capName: "pipeline-orchestrator",
41470
43261
  capScope: "system",
@@ -41573,6 +43364,24 @@ Object.freeze({
41573
43364
  addonId: null,
41574
43365
  access: "view"
41575
43366
  },
43367
+ "pipelineOrchestrator.getNodeBenchmarkCandidates": {
43368
+ capName: "pipeline-orchestrator",
43369
+ capScope: "system",
43370
+ addonId: null,
43371
+ access: "view"
43372
+ },
43373
+ "pipelineOrchestrator.getNodeBenchmarkPreflight": {
43374
+ capName: "pipeline-orchestrator",
43375
+ capScope: "system",
43376
+ addonId: null,
43377
+ access: "view"
43378
+ },
43379
+ "pipelineOrchestrator.getNodeBenchmarkStatus": {
43380
+ capName: "pipeline-orchestrator",
43381
+ capScope: "system",
43382
+ addonId: null,
43383
+ access: "view"
43384
+ },
41576
43385
  "pipelineOrchestrator.getNodeInferenceDevices": {
41577
43386
  capName: "pipeline-orchestrator",
41578
43387
  capScope: "system",
@@ -41615,6 +43424,12 @@ Object.freeze({
41615
43424
  addonId: null,
41616
43425
  access: "view"
41617
43426
  },
43427
+ "pipelineOrchestrator.listNodeBenchmarkResults": {
43428
+ capName: "pipeline-orchestrator",
43429
+ capScope: "system",
43430
+ addonId: null,
43431
+ access: "view"
43432
+ },
41618
43433
  "pipelineOrchestrator.pauseForStorageMigration": {
41619
43434
  capName: "pipeline-orchestrator",
41620
43435
  capScope: "system",
@@ -41759,6 +43574,12 @@ Object.freeze({
41759
43574
  addonId: null,
41760
43575
  access: "create"
41761
43576
  },
43577
+ "pipelineOrchestrator.startNodeBenchmark": {
43578
+ capName: "pipeline-orchestrator",
43579
+ capScope: "system",
43580
+ addonId: null,
43581
+ access: "create"
43582
+ },
41762
43583
  "pipelineOrchestrator.suggestShares": {
41763
43584
  capName: "pipeline-orchestrator",
41764
43585
  capScope: "system",
@@ -41777,6 +43598,12 @@ Object.freeze({
41777
43598
  addonId: null,
41778
43599
  access: "create"
41779
43600
  },
43601
+ "pipelineRunner.abortNodeBench": {
43602
+ capName: "pipeline-runner",
43603
+ capScope: "system",
43604
+ addonId: null,
43605
+ access: "create"
43606
+ },
41780
43607
  "pipelineRunner.attachCamera": {
41781
43608
  capName: "pipeline-runner",
41782
43609
  capScope: "system",
@@ -41825,6 +43652,12 @@ Object.freeze({
41825
43652
  addonId: null,
41826
43653
  access: "view"
41827
43654
  },
43655
+ "pipelineRunner.getNodeBenchStatus": {
43656
+ capName: "pipeline-runner",
43657
+ capScope: "system",
43658
+ addonId: null,
43659
+ access: "view"
43660
+ },
41828
43661
  "pipelineRunner.getParkedTrackFrame": {
41829
43662
  capName: "pipeline-runner",
41830
43663
  capScope: "system",
@@ -41867,6 +43700,12 @@ Object.freeze({
41867
43700
  addonId: null,
41868
43701
  access: "create"
41869
43702
  },
43703
+ "pipelineRunner.startNodeBench": {
43704
+ capName: "pipeline-runner",
43705
+ capScope: "system",
43706
+ addonId: null,
43707
+ access: "create"
43708
+ },
41870
43709
  "plateGallery.assignPlate": {
41871
43710
  capName: "plate-gallery",
41872
43711
  capScope: "system",
@@ -46796,6 +48635,11 @@ Object.freeze({
46796
48635
  form: "single",
46797
48636
  optional: false
46798
48637
  }],
48638
+ "pipelineAnalytics.addRetrainFrameFromRecording": [{
48639
+ name: "deviceId",
48640
+ form: "single",
48641
+ optional: false
48642
+ }],
46799
48643
  "pipelineAnalytics.applyDeviceSettingsPatch": [{
46800
48644
  name: "deviceId",
46801
48645
  form: "single",
@@ -46986,6 +48830,11 @@ Object.freeze({
46986
48830
  form: "single",
46987
48831
  optional: false
46988
48832
  }],
48833
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": [{
48834
+ name: "deviceId",
48835
+ form: "single",
48836
+ optional: false
48837
+ }],
46989
48838
  "pipelineAnalytics.pruneEventsBefore": [{
46990
48839
  name: "deviceId",
46991
48840
  form: "single",
@@ -49112,7 +50961,7 @@ var AgentUIAddon = class extends BaseAddon {
49112
50961
  capability: adminUiCapability,
49113
50962
  provider: {
49114
50963
  getStaticDir: async () => ({ staticDir: path.resolve(__dirname) }),
49115
- getVersion: async () => ({ version: "1.2.191" })
50964
+ getVersion: async () => ({ version: "1.2.193" })
49116
50965
  }
49117
50966
  }];
49118
50967
  }