@camstack/addon-training 0.1.53 → 0.1.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (21) hide show
  1. package/dist/{MotionZonesSettings-2L6ZZUzt.mjs → MotionZonesSettings-W5TJMIhz.mjs} +2 -2
  2. package/dist/{PrivacyMaskSettings-z2Lm90YH.mjs → PrivacyMaskSettings-8bCieYP4.mjs} +2 -2
  3. package/dist/{SceneMonitorEditor-NTZadJI1.mjs → SceneMonitorEditor-hfbQKb07.mjs} +1 -1
  4. package/dist/_stub.js +2222 -2222
  5. package/dist/{_virtual_mf-localSharedImportMap___mfe_internal__addon_training_page-BNV-3iai.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_training_page-DtB9ff7l.mjs} +4 -4
  6. package/dist/_virtual_mf___mfe_internal__addon_training_page__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-CdZst5Eh.mjs +26 -0
  7. package/dist/addon-training.css +1 -1
  8. package/dist/{dist-Dw2AZ607.js → dist-DYEQn1Ss.mjs} +1006 -202
  9. package/dist/{dist-DFfQ_Mth.mjs → dist-DnFIVL4Y.js} +1218 -20
  10. package/dist/{hostInit-CCumz-Qi.mjs → hostInit-Duj8IUS7.mjs} +3 -3
  11. package/dist/index.js +1 -1
  12. package/dist/orchestrator/training.addon.js +64 -104
  13. package/dist/orchestrator/training.addon.mjs +64 -104
  14. package/dist/{player-overlays-C3wXNwRM.mjs → player-overlays-DBfpI8h8.mjs} +1 -1
  15. package/dist/providers/modal/training-modal.addon.js +22 -1
  16. package/dist/providers/modal/training-modal.addon.mjs +19 -1
  17. package/dist/remoteEntry.js +1 -1
  18. package/dist/{responsive-9dr-MOnd.mjs → responsive-CVlns2k2.mjs} +1 -1
  19. package/dist/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_training_page__remoteEntry_js-BCUryvJe.mjs → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_training_page__remoteEntry_js-GR9ZahAF.mjs} +1 -1
  20. package/package.json +1 -1
  21. package/dist/_virtual_mf___mfe_internal__addon_training_page__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-QkGe-Wgc.mjs +0 -26
@@ -1,4 +1,37 @@
1
- import "node:crypto";
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __esmMin = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
9
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
10
+ var __exportAll = (all, no_symbols) => {
11
+ let target = {};
12
+ for (var name in all) __defProp(target, name, {
13
+ get: all[name],
14
+ enumerable: true
15
+ });
16
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
17
+ return target;
18
+ };
19
+ var __copyProps = (to, from, except, desc) => {
20
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
21
+ key = keys[i];
22
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
23
+ get: ((k) => from[k]).bind(null, key),
24
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
25
+ });
26
+ }
27
+ return to;
28
+ };
29
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
30
+ value: mod,
31
+ enumerable: true
32
+ }) : target, mod));
33
+ var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod);
34
+ require("node:crypto");
2
35
  //#region ../types/dist/event-category-BvOFi6PY.mjs
3
36
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
4
37
  EventCategory["SystemBoot"] = "system.boot";
@@ -4123,6 +4156,12 @@ var numberProcessor = (schema, ctx, _json, _params) => {
4123
4156
  var booleanProcessor = (_schema, _ctx, json, _params) => {
4124
4157
  json.type = "boolean";
4125
4158
  };
4159
+ var bigintProcessor = (_schema, ctx, _json, _params) => {
4160
+ if (ctx.unrepresentable === "throw") throw new Error("BigInt cannot be represented in JSON Schema");
4161
+ };
4162
+ var symbolProcessor = (_schema, ctx, _json, _params) => {
4163
+ if (ctx.unrepresentable === "throw") throw new Error("Symbols cannot be represented in JSON Schema");
4164
+ };
4126
4165
  var nullProcessor = (_schema, ctx, json, _params) => {
4127
4166
  if (ctx.target === "openapi-3.0") {
4128
4167
  json.type = "string";
@@ -4130,12 +4169,17 @@ var nullProcessor = (_schema, ctx, json, _params) => {
4130
4169
  json.enum = [null];
4131
4170
  } else json.type = "null";
4132
4171
  };
4172
+ var undefinedProcessor = (_schema, ctx, _json, _params) => {
4173
+ if (ctx.unrepresentable === "throw") throw new Error("Undefined cannot be represented in JSON Schema");
4174
+ };
4133
4175
  var voidProcessor = (_schema, ctx, _json, _params) => {
4134
4176
  if (ctx.unrepresentable === "throw") throw new Error("Void cannot be represented in JSON Schema");
4135
4177
  };
4136
4178
  var neverProcessor = (_schema, _ctx, json, _params) => {
4137
4179
  json.not = {};
4138
4180
  };
4181
+ var anyProcessor = (_schema, _ctx, _json, _params) => {};
4182
+ var unknownProcessor = (_schema, _ctx, _json, _params) => {};
4139
4183
  var dateProcessor = (_schema, ctx, _json, _params) => {
4140
4184
  if (ctx.unrepresentable === "throw") throw new Error("Date cannot be represented in JSON Schema");
4141
4185
  };
@@ -4167,12 +4211,53 @@ var literalProcessor = (schema, ctx, json, _params) => {
4167
4211
  json.enum = vals;
4168
4212
  }
4169
4213
  };
4214
+ var nanProcessor = (_schema, ctx, _json, _params) => {
4215
+ if (ctx.unrepresentable === "throw") throw new Error("NaN cannot be represented in JSON Schema");
4216
+ };
4217
+ var templateLiteralProcessor = (schema, _ctx, json, _params) => {
4218
+ const _json = json;
4219
+ const pattern = schema._zod.pattern;
4220
+ if (!pattern) throw new Error("Pattern not found in template literal");
4221
+ _json.type = "string";
4222
+ _json.pattern = pattern.source;
4223
+ };
4224
+ var fileProcessor = (schema, _ctx, json, _params) => {
4225
+ const _json = json;
4226
+ const file = {
4227
+ type: "string",
4228
+ format: "binary",
4229
+ contentEncoding: "binary"
4230
+ };
4231
+ const { minimum, maximum, mime } = schema._zod.bag;
4232
+ if (minimum !== void 0) file.minLength = minimum;
4233
+ if (maximum !== void 0) file.maxLength = maximum;
4234
+ if (mime) if (mime.length === 1) {
4235
+ file.contentMediaType = mime[0];
4236
+ Object.assign(_json, file);
4237
+ } else {
4238
+ Object.assign(_json, file);
4239
+ _json.anyOf = mime.map((m) => ({ contentMediaType: m }));
4240
+ }
4241
+ else Object.assign(_json, file);
4242
+ };
4243
+ var successProcessor = (_schema, _ctx, json, _params) => {
4244
+ json.type = "boolean";
4245
+ };
4170
4246
  var customProcessor = (_schema, ctx, _json, _params) => {
4171
4247
  if (ctx.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
4172
4248
  };
4249
+ var functionProcessor = (_schema, ctx, _json, _params) => {
4250
+ if (ctx.unrepresentable === "throw") throw new Error("Function types cannot be represented in JSON Schema");
4251
+ };
4173
4252
  var transformProcessor = (_schema, ctx, _json, _params) => {
4174
4253
  if (ctx.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
4175
4254
  };
4255
+ var mapProcessor = (_schema, ctx, _json, _params) => {
4256
+ if (ctx.unrepresentable === "throw") throw new Error("Map cannot be represented in JSON Schema");
4257
+ };
4258
+ var setProcessor = (_schema, ctx, _json, _params) => {
4259
+ if (ctx.unrepresentable === "throw") throw new Error("Set cannot be represented in JSON Schema");
4260
+ };
4176
4261
  var arrayProcessor = (schema, ctx, _json, params) => {
4177
4262
  const json = _json;
4178
4263
  const def = schema._zod.def;
@@ -4377,6 +4462,12 @@ var readonlyProcessor = (schema, ctx, json, params) => {
4377
4462
  seen.ref = def.innerType;
4378
4463
  json.readOnly = true;
4379
4464
  };
4465
+ var promiseProcessor = (schema, ctx, _json, params) => {
4466
+ const def = schema._zod.def;
4467
+ process(def.innerType, ctx, params);
4468
+ const seen = ctx.seen.get(schema);
4469
+ seen.ref = def.innerType;
4470
+ };
4380
4471
  var optionalProcessor = (schema, ctx, _json, params) => {
4381
4472
  const def = schema._zod.def;
4382
4473
  process(def.innerType, ctx, params);
@@ -4389,6 +4480,81 @@ var lazyProcessor = (schema, ctx, _json, params) => {
4389
4480
  const seen = ctx.seen.get(schema);
4390
4481
  seen.ref = innerType;
4391
4482
  };
4483
+ var allProcessors = {
4484
+ string: stringProcessor,
4485
+ number: numberProcessor,
4486
+ boolean: booleanProcessor,
4487
+ bigint: bigintProcessor,
4488
+ symbol: symbolProcessor,
4489
+ null: nullProcessor,
4490
+ undefined: undefinedProcessor,
4491
+ void: voidProcessor,
4492
+ never: neverProcessor,
4493
+ any: anyProcessor,
4494
+ unknown: unknownProcessor,
4495
+ date: dateProcessor,
4496
+ enum: enumProcessor,
4497
+ literal: literalProcessor,
4498
+ nan: nanProcessor,
4499
+ template_literal: templateLiteralProcessor,
4500
+ file: fileProcessor,
4501
+ success: successProcessor,
4502
+ custom: customProcessor,
4503
+ function: functionProcessor,
4504
+ transform: transformProcessor,
4505
+ map: mapProcessor,
4506
+ set: setProcessor,
4507
+ array: arrayProcessor,
4508
+ object: objectProcessor,
4509
+ union: unionProcessor,
4510
+ intersection: intersectionProcessor,
4511
+ tuple: tupleProcessor,
4512
+ record: recordProcessor,
4513
+ nullable: nullableProcessor,
4514
+ nonoptional: nonoptionalProcessor,
4515
+ default: defaultProcessor,
4516
+ prefault: prefaultProcessor,
4517
+ catch: catchProcessor,
4518
+ pipe: pipeProcessor,
4519
+ readonly: readonlyProcessor,
4520
+ promise: promiseProcessor,
4521
+ optional: optionalProcessor,
4522
+ lazy: lazyProcessor
4523
+ };
4524
+ function toJSONSchema(input, params) {
4525
+ if ("_idmap" in input) {
4526
+ const registry = input;
4527
+ const ctx = initializeContext({
4528
+ ...params,
4529
+ processors: allProcessors
4530
+ });
4531
+ const defs = {};
4532
+ for (const entry of registry._idmap.entries()) {
4533
+ const [_, schema] = entry;
4534
+ process(schema, ctx);
4535
+ }
4536
+ const schemas = {};
4537
+ ctx.external = {
4538
+ registry,
4539
+ uri: params?.uri,
4540
+ defs
4541
+ };
4542
+ for (const entry of registry._idmap.entries()) {
4543
+ const [key, schema] = entry;
4544
+ extractDefs(ctx, schema);
4545
+ schemas[key] = finalize(ctx, schema);
4546
+ }
4547
+ if (Object.keys(defs).length > 0) schemas.__shared = { [ctx.target === "draft-2020-12" ? "$defs" : "definitions"]: defs };
4548
+ return { schemas };
4549
+ }
4550
+ const ctx = initializeContext({
4551
+ ...params,
4552
+ processors: allProcessors
4553
+ });
4554
+ process(input, ctx);
4555
+ extractDefs(ctx, input);
4556
+ return finalize(ctx, input);
4557
+ }
4392
4558
  //#endregion
4393
4559
  //#region ../../node_modules/zod/v4/classic/iso.js
4394
4560
  var ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
@@ -5405,7 +5571,7 @@ var ZodIssueCode = {
5405
5571
  var ZodFirstPartyTypeKind;
5406
5572
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5407
5573
  //#endregion
5408
- //#region ../types/dist/sleep-D-Q2_Mcd.mjs
5574
+ //#region ../types/dist/sleep-bZIhUvjd.mjs
5409
5575
  /**
5410
5576
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5411
5577
  * window to float samples (D455).
@@ -5522,7 +5688,7 @@ function isKeychainStoredField(field) {
5522
5688
  var SECRET_CLEAR = { $secretClear: true };
5523
5689
  /** The `'***'` token D634 redaction writes for non-admins. */
5524
5690
  var LEGACY_DEVICE_REDACTION = "***";
5525
- function isRecord$2(value) {
5691
+ function isRecord$5(value) {
5526
5692
  return typeof value === "object" && value !== null && !Array.isArray(value);
5527
5693
  }
5528
5694
  function makeSecretMarker(ref) {
@@ -5533,12 +5699,12 @@ function makeSecretMarker(ref) {
5533
5699
  }
5534
5700
  /** A stored marker: an object whose `$secret` is a non-empty string. */
5535
5701
  function isSecretMarker(value) {
5536
- if (!isRecord$2(value)) return false;
5702
+ if (!isRecord$5(value)) return false;
5537
5703
  const ref = value["$secret"];
5538
5704
  return typeof ref === "string" && ref.length > 0;
5539
5705
  }
5540
5706
  function isSecretClear(value) {
5541
- return isRecord$2(value) && value["$secretClear"] === true;
5707
+ return isRecord$5(value) && value["$secretClear"] === true;
5542
5708
  }
5543
5709
  /**
5544
5710
  * The UI view of a stored secret field value: a marker becomes "set", inline
@@ -6148,7 +6314,7 @@ var KeychainWriteRefusedError = class extends Error {
6148
6314
  }
6149
6315
  };
6150
6316
  var KEEP = { kind: "keep" };
6151
- function isRecord$1(value) {
6317
+ function isRecord$4(value) {
6152
6318
  return typeof value === "object" && value !== null && !Array.isArray(value);
6153
6319
  }
6154
6320
  function defaultMintId() {
@@ -6161,7 +6327,7 @@ function collectSecretMarkerRefs(value, out = []) {
6161
6327
  return out;
6162
6328
  }
6163
6329
  if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6164
- else if (isRecord$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6330
+ else if (isRecord$4(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6165
6331
  return out;
6166
6332
  }
6167
6333
  async function storedValueEquals(secrets, marker, candidate) {
@@ -6216,7 +6382,7 @@ function rowId(row, idKey) {
6216
6382
  return null;
6217
6383
  }
6218
6384
  async function writeArray(ctx, node, incoming, stored, fieldPath) {
6219
- const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1) : [];
6385
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$4) : [];
6220
6386
  if (!Array.isArray(incoming)) {
6221
6387
  ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6222
6388
  return {
@@ -6232,7 +6398,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6232
6398
  const kept = /* @__PURE__ */ new Set();
6233
6399
  const rows = [];
6234
6400
  for (const row of incoming) {
6235
- if (!isRecord$1(row)) {
6401
+ if (!isRecord$4(row)) {
6236
6402
  rows.push(row);
6237
6403
  continue;
6238
6404
  }
@@ -6257,7 +6423,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6257
6423
  case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6258
6424
  case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6259
6425
  case "object": {
6260
- if (!isRecord$1(incoming)) {
6426
+ if (!isRecord$4(incoming)) {
6261
6427
  if (incoming === void 0) return KEEP;
6262
6428
  ctx.deletes.push(...collectSecretMarkerRefs(stored));
6263
6429
  return {
@@ -6265,7 +6431,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6265
6431
  value: incoming
6266
6432
  };
6267
6433
  }
6268
- const storedObj = isRecord$1(stored) ? stored : {};
6434
+ const storedObj = isRecord$4(stored) ? stored : {};
6269
6435
  return {
6270
6436
  kind: "value",
6271
6437
  value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
@@ -6388,7 +6554,7 @@ async function resolveSecretMarkers(value, secrets, options = {}) {
6388
6554
  value: items
6389
6555
  };
6390
6556
  }
6391
- if (isRecord$1(v)) {
6557
+ if (isRecord$4(v)) {
6392
6558
  const out = {};
6393
6559
  for (const [k, child] of Object.entries(v)) {
6394
6560
  const s = substitute(child);
@@ -6420,7 +6586,7 @@ var SecretOverwriteRefusedError = class extends Error {
6420
6586
  this.name = "SecretOverwriteRefusedError";
6421
6587
  }
6422
6588
  };
6423
- function isRecord(value) {
6589
+ function isRecord$3(value) {
6424
6590
  return typeof value === "object" && value !== null && !Array.isArray(value);
6425
6591
  }
6426
6592
  function resolvedValue(pass, marker) {
@@ -6449,7 +6615,7 @@ function inArray(pass, incoming, stored) {
6449
6615
  return incoming.map((item, index) => {
6450
6616
  const twin = stored[index];
6451
6617
  if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
6452
- if (isRecord(item) && isRecord(twin)) return inArrayRow(pass, item, twin);
6618
+ if (isRecord$3(item) && isRecord$3(twin)) return inArrayRow(pass, item, twin);
6453
6619
  if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
6454
6620
  return item;
6455
6621
  });
@@ -6460,7 +6626,7 @@ function inArrayRow(pass, incoming, stored) {
6460
6626
  const twin = stored[key];
6461
6627
  if (isSecretMarker(twin)) {
6462
6628
  if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
6463
- } else if (isRecord(value) && isRecord(twin)) out[key] = inArrayRow(pass, value, twin);
6629
+ } else if (isRecord$3(value) && isRecord$3(twin)) out[key] = inArrayRow(pass, value, twin);
6464
6630
  else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
6465
6631
  }
6466
6632
  return out;
@@ -6468,7 +6634,7 @@ function inArrayRow(pass, incoming, stored) {
6468
6634
  async function walk(pass, incoming, stored) {
6469
6635
  if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
6470
6636
  if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
6471
- if (!isRecord(incoming) || !isRecord(stored)) return incoming;
6637
+ if (!isRecord$3(incoming) || !isRecord$3(stored)) return incoming;
6472
6638
  const out = { ...incoming };
6473
6639
  for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
6474
6640
  return out;
@@ -6499,7 +6665,7 @@ async function restoreUnchangedSecrets(input) {
6499
6665
  function isJsonEqual(a, b) {
6500
6666
  if (Object.is(a, b)) return true;
6501
6667
  if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
6502
- if (isRecord(a) && isRecord(b)) {
6668
+ if (isRecord$3(a) && isRecord$3(b)) {
6503
6669
  const keys = Object.keys(a);
6504
6670
  if (keys.length !== Object.keys(b).length) return false;
6505
6671
  return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
@@ -6523,7 +6689,7 @@ function markerKeysOf(blob, owner) {
6523
6689
  }
6524
6690
  function nodeFromStored(value, owner) {
6525
6691
  if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
6526
- if (!isRecord(value)) return null;
6692
+ if (!isRecord$3(value)) return null;
6527
6693
  const children = /* @__PURE__ */ new Map();
6528
6694
  for (const [key, child] of Object.entries(value)) {
6529
6695
  const node = nodeFromStored(child, owner);
@@ -7311,7 +7477,7 @@ var BaseAddon = class {
7311
7477
  if (!ctx) return;
7312
7478
  const addonId = ctx.id;
7313
7479
  setImmediate(() => {
7314
- ctx.api.addons?.restartAddon?.mutate({ addonId }).then(() => {
7480
+ ctx.api.addons.restartAddon.mutate({ addonId }).then(() => {
7315
7481
  ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
7316
7482
  }).catch((err) => {
7317
7483
  ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
@@ -7805,6 +7971,348 @@ var PeerBytesTicketSchema = object({
7805
7971
  */
7806
7972
  declaredBytes: number().int().nonnegative().nullable()
7807
7973
  });
7974
+ /** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
7975
+ /** The files a kind may live in. `history` is device-history's (D850), never records. */
7976
+ var RECORD_DATABASES = ["settings", "events"];
7977
+ /** The classes of a kind: the `@durable` vocabulary, one authority (replaces the annotation). */
7978
+ var RECORD_CLASSES = [
7979
+ "config",
7980
+ "ledger",
7981
+ "audit",
7982
+ "mirror",
7983
+ "ephemeral"
7984
+ ];
7985
+ var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
7986
+ var RECORD_MAX_DATA_BYTES = 1024 * 1024;
7987
+ var RECORD_BATCH_MAX = 1e3;
7988
+ var RECORD_QUERY_MAX = 1e3;
7989
+ /** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
7990
+ var RECORD_SETTINGS_MAX_ROWS = 5e4;
7991
+ var PREFIX = "records/";
7992
+ /** The base of every records failure. `detail` is the human part of the message. */
7993
+ var RecordsError = class extends Error {
7994
+ code;
7995
+ detail;
7996
+ constructor(code, detail) {
7997
+ super(`${PREFIX}${code}: ${detail}`);
7998
+ this.name = "RecordsError";
7999
+ this.code = code;
8000
+ this.detail = detail;
8001
+ }
8002
+ };
8003
+ var InvalidRecordError = class extends RecordsError {
8004
+ constructor(detail) {
8005
+ super("invalid-record", detail);
8006
+ this.name = "InvalidRecordError";
8007
+ }
8008
+ };
8009
+ /** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
8010
+ var DeclarationRefusedError = class extends RecordsError {
8011
+ constructor(detail) {
8012
+ super("declaration-refused", detail);
8013
+ this.name = "DeclarationRefusedError";
8014
+ }
8015
+ };
8016
+ function defOf(schema) {
8017
+ const zodBag = Reflect.get(schema, "_zod");
8018
+ if (typeof zodBag !== "object" || zodBag === null) return {};
8019
+ const def = Reflect.get(zodBag, "def");
8020
+ if (typeof def !== "object" || def === null) return {};
8021
+ return def;
8022
+ }
8023
+ function declaredHere(schema) {
8024
+ return globalRegistry.get(schema)?.secret === true;
8025
+ }
8026
+ /** Wrapper kinds whose `innerType` is the field itself. */
8027
+ var WRAPPERS = new Set([
8028
+ "optional",
8029
+ "nullable",
8030
+ "default",
8031
+ "prefault",
8032
+ "catch",
8033
+ "readonly",
8034
+ "nonoptional"
8035
+ ]);
8036
+ /**
8037
+ * The schema layers that make up ONE field: the schema itself and every
8038
+ * wrapper below it (optional / default / nullable / readonly / catch), plus
8039
+ * both sides of a pipe (`z.preprocess` puts the real schema on `out`,
8040
+ * `.transform` on `in`).
8041
+ */
8042
+ function layersOf(schema) {
8043
+ const out = [];
8044
+ const queue = [schema];
8045
+ while (queue.length > 0) {
8046
+ const s = queue.shift();
8047
+ if (!s || out.includes(s)) continue;
8048
+ out.push(s);
8049
+ const def = defOf(s);
8050
+ if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
8051
+ if (def.type === "pipe") {
8052
+ if (def.in) queue.push(def.in);
8053
+ if (def.out) queue.push(def.out);
8054
+ }
8055
+ }
8056
+ return out;
8057
+ }
8058
+ /** True when any layer of this field declares `.meta({ secret: true })`. */
8059
+ function isZodSecret(schema) {
8060
+ return layersOf(schema).some(declaredHere);
8061
+ }
8062
+ /**
8063
+ * Every declared secret path in a config schema: dotted keys, `[]` for "each
8064
+ * element of this array" (`connection.password`, `rows[].token`). A declared
8065
+ * object or array is reported as one path and not descended into — everything
8066
+ * under it is secret.
8067
+ */
8068
+ function collectZodSecretPaths(schema, prefix = "") {
8069
+ if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
8070
+ const paths = [];
8071
+ for (const layer of layersOf(schema)) {
8072
+ const def = defOf(layer);
8073
+ if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
8074
+ else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
8075
+ else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
8076
+ else if (def.type === "intersection") {
8077
+ if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
8078
+ if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
8079
+ }
8080
+ }
8081
+ return [...new Set(paths)];
8082
+ }
8083
+ /**
8084
+ * Secret fields of a record, addressed the way a Zod schema declares them
8085
+ * (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
8086
+ * (`auth.accessToken`, `headers[].value`).
8087
+ *
8088
+ * Array elements are matched by a DECLARED id key (`secretArrayKeys`:
8089
+ * `{ headers: 'name' }`), never by index, so reordering a list keeps every
8090
+ * keychain ref (the same rule as `arrayItemFieldPath`). The concrete path of a
8091
+ * leaf names its element: `headers[X-Api].value`.
8092
+ *
8093
+ * Pure and browser-safe. Nothing here mutates: every transform returns a new value.
8094
+ */
8095
+ /** The array prefixes (declared form, e.g. `headers` or `a.headers`) of a path. */
8096
+ function parseSecretPath(path) {
8097
+ if (path.length === 0) throw new InvalidRecordError("an empty secret path");
8098
+ return path.split(".").map((raw) => {
8099
+ const each = raw.endsWith("[]");
8100
+ const key = each ? raw.slice(0, -2) : raw;
8101
+ if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
8102
+ return {
8103
+ key,
8104
+ each
8105
+ };
8106
+ });
8107
+ }
8108
+ /** The declared array prefixes of `path` that need an id key (`headers`, `a.rows`). */
8109
+ function secretArrayPrefixes(path) {
8110
+ const segments = parseSecretPath(path);
8111
+ const prefixes = [];
8112
+ const walked = [];
8113
+ for (const segment of segments) {
8114
+ walked.push(segment.key);
8115
+ if (segment.each) prefixes.push(walked.join("."));
8116
+ }
8117
+ return prefixes;
8118
+ }
8119
+ /**
8120
+ * Record kinds (D881): the declaration an addon makes of one kind of fact, the
8121
+ * Zod row schema that describes it, and the helper that turns the two into the
8122
+ * JSON the engine stores.
8123
+ *
8124
+ * A kind is declared ONCE, next to the code that owns it, and the engine's
8125
+ * reconciler creates its indexes - nothing creates DDL at runtime from a write.
8126
+ * Everything the generic machinery needs (secret fields, the entry descriptor)
8127
+ * is DERIVED from the Zod schema: `.meta({ secret: true })` marks a credential,
8128
+ * never a field name (D879).
8129
+ */
8130
+ /** A JSON field path: `trackId`, `auth.accessToken`. Charset-restricted: it is rendered into DDL. */
8131
+ var RecordFieldPathSchema = string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,63}(\.[A-Za-z_][A-Za-z0-9_]{0,63}){0,3}$/);
8132
+ var RecordIndexSchema = object({
8133
+ name: string().regex(/^[a-z][a-z0-9_]{0,31}$/),
8134
+ fields: array(RecordFieldPathSchema).min(1).max(4),
8135
+ unique: boolean().optional()
8136
+ }).strict();
8137
+ var RecordRetentionSchema = union([
8138
+ object({
8139
+ ttlMs: number().int().positive(),
8140
+ from: _enum(["at", "write"])
8141
+ }).strict(),
8142
+ object({
8143
+ maxRows: number().int().positive().optional(),
8144
+ maxRowsPerDevice: number().int().positive().optional()
8145
+ }).strict().refine((r) => r.maxRows !== void 0 || r.maxRowsPerDevice !== void 0, { message: "name maxRows, maxRowsPerDevice or both" }),
8146
+ object({
8147
+ owner: string().min(1),
8148
+ reason: string().min(1)
8149
+ }).strict(),
8150
+ object({ none: string().min(1) }).strict()
8151
+ ]);
8152
+ /** The descriptor a generic entries UI reads (D881 "generic entries"). */
8153
+ var EntryDescriptorSchema = object({
8154
+ title: string().min(1),
8155
+ /** The record body field shown as the entry's name. */
8156
+ nameField: string().min(1),
8157
+ /** JSON Schema of the entry body; `secret: true` marks a password field. */
8158
+ fields: record(string(), unknown())
8159
+ }).strict();
8160
+ /** What crosses the wire and sits in the engine's catalog: JSON only, no Zod. */
8161
+ var RecordKindDeclarationSchema = object({
8162
+ database: _enum(RECORD_DATABASES).default("settings"),
8163
+ class: _enum(RECORD_CLASSES),
8164
+ writeTrigger: string().min(1),
8165
+ device: _enum([
8166
+ "required",
8167
+ "optional",
8168
+ "none"
8169
+ ]).default("none"),
8170
+ at: _enum(["required", "none"]).default("none"),
8171
+ indexes: array(RecordIndexSchema).max(8).default([]),
8172
+ retention: RecordRetentionSchema,
8173
+ deviceRemoval: _enum(["delete", "none"]).default("none"),
8174
+ maxDataBytes: number().int().positive().max(RECORD_MAX_DATA_BYTES).default(RECORD_DEFAULT_MAX_DATA_BYTES),
8175
+ /** Derived from the Zod schema; never written by hand. */
8176
+ secretPaths: array(string().min(1)).default([]),
8177
+ /** The id key of each array that carries a secret (`{ headers: 'name' }`). */
8178
+ secretArrayKeys: record(string(), string()).default({}),
8179
+ /** The legacy table this kind adopts from; the boot guard reads it (D853: no migration code). */
8180
+ adoptsFrom: string().min(1).optional(),
8181
+ /** Kinds that must agree through `transact` sit in one file under one family name. */
8182
+ transactFamily: string().min(1).optional(),
8183
+ entry: EntryDescriptorSchema.optional()
8184
+ }).strict();
8185
+ /** The kind names: lower-case, dash separated, short enough for an index name. */
8186
+ var RecordKindNameSchema = string().regex(/^[a-z][a-z0-9-]{0,47}$/);
8187
+ /** Cross-field rules a declaration must satisfy. Throws {@link DeclarationRefusedError}. */
8188
+ function assertValidDeclaration(name, decl) {
8189
+ const refuse = (why) => {
8190
+ throw new DeclarationRefusedError(`kind "${name}": ${why}`);
8191
+ };
8192
+ if (!RecordKindNameSchema.safeParse(name).success) refuse("the name must be lower-case-dashed");
8193
+ const seen = /* @__PURE__ */ new Set();
8194
+ for (const index of decl.indexes) {
8195
+ if (seen.has(index.name)) refuse(`index name "${index.name}" is declared twice`);
8196
+ seen.add(index.name);
8197
+ }
8198
+ const { retention } = decl;
8199
+ const hasSecrets = decl.secretPaths.length > 0;
8200
+ if ("ttlMs" in retention) {
8201
+ if (retention.from === "at" && decl.at !== "required") refuse("a ttl from \"at\" needs at: \"required\"");
8202
+ if (hasSecrets) refuse("a kind with secret fields cannot use engine TTL (its keychain values would be orphaned)");
8203
+ }
8204
+ if ("maxRows" in retention || "maxRowsPerDevice" in retention) {
8205
+ if (retention.maxRowsPerDevice !== void 0 && decl.device !== "required") refuse("maxRowsPerDevice needs device: \"required\"");
8206
+ if (decl.at !== "required") refuse("a row bound trims the oldest \"at\": it needs at: \"required\"");
8207
+ if (hasSecrets) refuse("a kind with secret fields cannot use an engine row bound");
8208
+ const bound = Math.max(retention.maxRows ?? 0, retention.maxRowsPerDevice ?? 0);
8209
+ if (decl.database === "settings" && bound > 5e4) refuse(`a row bound above ${RECORD_SETTINGS_MAX_ROWS} belongs in database: "events" (a big delete on the settings thread stalls every configuration read)`);
8210
+ }
8211
+ if (decl.deviceRemoval === "delete" && decl.device === "none") refuse("deviceRemoval: \"delete\" needs a device: \"required\" or \"optional\"");
8212
+ for (const path of decl.secretPaths) for (const prefix of secretArrayPrefixes(path)) if (decl.secretArrayKeys[prefix] === void 0) refuse(`secret path "${path}" crosses the array "${prefix}": declare its id key in secretArrayKeys`);
8213
+ }
8214
+ function bodyFieldsOf(schema) {
8215
+ return { ...toJSONSchema(schema, {
8216
+ unrepresentable: "any",
8217
+ io: "input"
8218
+ }) };
8219
+ }
8220
+ function isRecordLike(value) {
8221
+ return typeof value === "object" && value !== null && !Array.isArray(value);
8222
+ }
8223
+ /** Does every branch of the body schema carry `field`? (A discriminated union has several.) */
8224
+ function hasNameField(json, field) {
8225
+ const branches = json["oneOf"] ?? json["anyOf"];
8226
+ if (Array.isArray(branches)) return branches.length > 0 && branches.every((b) => isRecordLike(b) && hasNameField(b, field));
8227
+ const properties = json["properties"];
8228
+ return isRecordLike(properties) && Object.prototype.hasOwnProperty.call(properties, field);
8229
+ }
8230
+ /**
8231
+ * Declare the kinds of a package. The keys are the kind names. The result is
8232
+ * what `ctx.records.declare` sends to the engine and what `ctx.records.kind`
8233
+ * types its handle from.
8234
+ */
8235
+ function defineRecordKinds(specs) {
8236
+ const out = {};
8237
+ for (const [name, spec] of Object.entries(specs)) {
8238
+ const secretPaths = collectZodSecretPaths(spec.schema);
8239
+ const nameField = spec.entry?.nameField ?? "name";
8240
+ const fields = bodyFieldsOf(spec.schema);
8241
+ if (spec.entry !== void 0 && !hasNameField(fields, nameField)) throw new DeclarationRefusedError(`kind "${name}": an entry kind's schema needs a "${nameField}" field`);
8242
+ const parsed = RecordKindDeclarationSchema.parse({
8243
+ database: spec.database,
8244
+ class: spec.class,
8245
+ writeTrigger: spec.writeTrigger,
8246
+ device: spec.device,
8247
+ at: spec.at,
8248
+ indexes: spec.indexes === void 0 ? void 0 : [...spec.indexes],
8249
+ retention: spec.retention,
8250
+ deviceRemoval: spec.deviceRemoval,
8251
+ maxDataBytes: spec.maxDataBytes,
8252
+ secretPaths: [...secretPaths],
8253
+ secretArrayKeys: spec.secretArrayKeys === void 0 ? void 0 : { ...spec.secretArrayKeys },
8254
+ adoptsFrom: spec.adoptsFrom,
8255
+ transactFamily: spec.transactFamily,
8256
+ entry: spec.entry === void 0 ? void 0 : {
8257
+ title: spec.entry.title,
8258
+ nameField,
8259
+ fields
8260
+ }
8261
+ });
8262
+ assertValidDeclaration(name, parsed);
8263
+ out[name] = {
8264
+ name,
8265
+ schema: spec.schema,
8266
+ declaration: parsed
8267
+ };
8268
+ }
8269
+ return out;
8270
+ }
8271
+ /**
8272
+ * Entry kinds (D881): every list of user-created entries (notification
8273
+ * targets, brokers, LLM profiles) is ONE record kind with an id, a name and a
8274
+ * kind-specific body, and the admin UI lists/adds/edits/deletes all of them
8275
+ * through the `record-entries` capability with password fields derived from
8276
+ * the schema (`.meta({ secret: true })`).
8277
+ */
8278
+ /** The body of a plain entry: a name and the fields the kind adds. */
8279
+ function entryBody(shape) {
8280
+ return object({
8281
+ name: string().min(1),
8282
+ ...shape
8283
+ });
8284
+ }
8285
+ /**
8286
+ * Declare one entry kind. An entry is configuration: never trimmed by the
8287
+ * engine, never aged, belonging to no device.
8288
+ */
8289
+ function defineEntryKind(name, spec) {
8290
+ const defined = defineRecordKinds({ [name]: {
8291
+ schema: spec.schema,
8292
+ class: "config",
8293
+ writeTrigger: spec.writeTrigger ?? "an operator adds or edits an entry in the entries UI",
8294
+ retention: { none: "an entry goes only when the operator deletes it" },
8295
+ ...spec.database === void 0 ? {} : { database: spec.database },
8296
+ ...spec.indexes === void 0 ? {} : { indexes: spec.indexes },
8297
+ ...spec.secretArrayKeys === void 0 ? {} : { secretArrayKeys: spec.secretArrayKeys },
8298
+ ...spec.adoptsFrom === void 0 ? {} : { adoptsFrom: spec.adoptsFrom },
8299
+ entry: {
8300
+ title: spec.title,
8301
+ ...spec.nameField === void 0 ? {} : { nameField: spec.nameField }
8302
+ }
8303
+ } })[name];
8304
+ if (defined === void 0) throw new DeclarationRefusedError(`entry kind "${name}" was not built`);
8305
+ return defined;
8306
+ }
8307
+ /**
8308
+ * Legacy source for entry adoption (B3): a list stored under addon-settings
8309
+ * `<addonId>.<key>` until records-adopt copies rows into the entry kind.
8310
+ */
8311
+ var SETTINGS_ARRAY_ADOPTS_PREFIX = "@settings-array/";
8312
+ /** The `adoptsFrom` value for an addon-settings array field. */
8313
+ function settingsArrayAdoptsFrom(addonId, settingsKey) {
8314
+ return `${SETTINGS_ARRAY_ADOPTS_PREFIX}${addonId}/${settingsKey}`;
8315
+ }
7808
8316
  /** Shared Zod schemas used across streaming capabilities. */
7809
8317
  var CamProfileSchema = _enum([
7810
8318
  "high",
@@ -16004,6 +16512,222 @@ id: union([string(), number()]) }), {
16004
16512
  kind: "mutation",
16005
16513
  auth: "admin"
16006
16514
  });
16515
+ /**
16516
+ * records - an addon's own facts and documents (D881): ledgers, audit rows,
16517
+ * config documents, mirrors. The third storage API next to `ctx.settings`
16518
+ * (operator intent, D870) and device-history (numbers over time, D850).
16519
+ *
16520
+ * Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
16521
+ * crossed a process and stated by a hub in-process caller (`ctx.records` does
16522
+ * that with the addon id closed over). It is deliberately NOT in any input
16523
+ * schema, so a session can never supply it, and a call with no stamp is refused
16524
+ * `records/no-caller`. A kind is readable and writable only by its owner; other
16525
+ * addons go through the owner's capability.
16526
+ *
16527
+ * Every read is three-way: a row, `null`, or the call THROWS. A failed read is
16528
+ * never `[]`. Secret fields are never on the wire: a read shows the
16529
+ * redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
16530
+ * resolves itself, and a write may carry only a keychain marker bound to the
16531
+ * row's own ref.
16532
+ *
16533
+ * Internal: addons reach it through `ctx.records`, never directly.
16534
+ */
16535
+ var RecordIdSchema = string().min(1).max(256);
16536
+ /** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
16537
+ var RecordBodySchema = record(string(), unknown());
16538
+ var RecordInputSchema = object({
16539
+ id: RecordIdSchema,
16540
+ /** The device this row belongs to (D865 removal, per-device reads). */
16541
+ deviceId: number().int().optional(),
16542
+ /** The domain clock, ms: observed / created / opened. */
16543
+ at: number().int().optional(),
16544
+ /** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
16545
+ expiresAt: number().int().optional(),
16546
+ data: RecordBodySchema
16547
+ });
16548
+ var RecordViewSchema = object({
16549
+ id: string(),
16550
+ deviceId: number().int().nullable(),
16551
+ at: number().nullable(),
16552
+ expiresAt: number().nullable(),
16553
+ rev: number().int(),
16554
+ updatedAt: number(),
16555
+ data: RecordBodySchema
16556
+ });
16557
+ /** Declared index fields only. Anything else does not compile, by design. */
16558
+ var RecordWhereSchema = record(RecordFieldPathSchema, union([
16559
+ string(),
16560
+ number(),
16561
+ boolean(),
16562
+ object({ in: array(union([
16563
+ string(),
16564
+ number(),
16565
+ boolean()
16566
+ ])).min(1).max(RECORD_BATCH_MAX) }),
16567
+ object({
16568
+ gt: union([string(), number()]).optional(),
16569
+ gte: union([string(), number()]).optional(),
16570
+ lt: union([string(), number()]).optional(),
16571
+ lte: union([string(), number()]).optional()
16572
+ }).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
16573
+ ]));
16574
+ var KindShape = { kind: RecordKindNameSchema };
16575
+ var TimeWindowShape = {
16576
+ deviceId: number().int().optional(),
16577
+ atFrom: number().optional(),
16578
+ atTo: number().optional()
16579
+ };
16580
+ var RecordQueryInputSchema = object({
16581
+ ...KindShape,
16582
+ ...TimeWindowShape,
16583
+ where: RecordWhereSchema.optional(),
16584
+ /** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
16585
+ order: _enum(["at", "id"]).optional(),
16586
+ desc: boolean().optional(),
16587
+ limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
16588
+ /** Opaque keyset cursor from a previous answer. There is no offset. */
16589
+ cursor: string().min(1).optional()
16590
+ });
16591
+ var RecordQueryResultSchema = object({
16592
+ records: array(RecordViewSchema),
16593
+ nextCursor: string().nullable()
16594
+ });
16595
+ var RecordKindStateSchema = _enum([
16596
+ "created",
16597
+ "unchanged",
16598
+ "updated"
16599
+ ]);
16600
+ var DeclareKindResultSchema = object({
16601
+ kindId: number().int(),
16602
+ state: RecordKindStateSchema,
16603
+ createdIndexes: array(string()),
16604
+ /** The boot guard: the kind is empty while its legacy table still holds rows. */
16605
+ adoptionPending: object({
16606
+ legacyTable: string(),
16607
+ legacyRows: number().int()
16608
+ }).nullable()
16609
+ });
16610
+ /** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
16611
+ var SecretRefsList = array(string());
16612
+ var RecordSecretRefsSchema = record(string(), record(string(), string()));
16613
+ method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
16614
+ kind: "mutation",
16615
+ auth: "admin"
16616
+ }), method(object({
16617
+ ...KindShape,
16618
+ id: RecordIdSchema
16619
+ }), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
16620
+ ...KindShape,
16621
+ ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
16622
+ }), array(RecordViewSchema), { auth: "admin" }), method(object({
16623
+ ...KindShape,
16624
+ ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
16625
+ }), RecordSecretRefsSchema, { auth: "admin" }), method(object({
16626
+ ...KindShape,
16627
+ record: RecordInputSchema,
16628
+ /** Compare-and-set. `0` means "the row must not exist". */
16629
+ ifRev: number().int().min(0).optional()
16630
+ }), object({
16631
+ rev: number().int(),
16632
+ releasedRefs: SecretRefsList
16633
+ }), {
16634
+ kind: "mutation",
16635
+ auth: "admin"
16636
+ }), method(object({
16637
+ ...KindShape,
16638
+ records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
16639
+ }), object({
16640
+ count: number().int(),
16641
+ releasedRefs: SecretRefsList
16642
+ }), {
16643
+ kind: "mutation",
16644
+ auth: "admin"
16645
+ }), method(object({
16646
+ ...KindShape,
16647
+ id: RecordIdSchema,
16648
+ data: RecordBodySchema,
16649
+ at: number().int().nullable().optional(),
16650
+ expiresAt: number().int().nullable().optional(),
16651
+ ifRev: number().int().min(1).optional()
16652
+ }), object({
16653
+ rev: number().int(),
16654
+ releasedRefs: SecretRefsList
16655
+ }), {
16656
+ kind: "mutation",
16657
+ auth: "admin"
16658
+ }), method(object({
16659
+ ...KindShape,
16660
+ id: RecordIdSchema
16661
+ }), object({
16662
+ deleted: boolean(),
16663
+ secretRefs: SecretRefsList
16664
+ }), {
16665
+ kind: "mutation",
16666
+ auth: "admin"
16667
+ }), method(object({
16668
+ ...KindShape,
16669
+ ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
16670
+ }), object({
16671
+ deleted: number().int(),
16672
+ secretRefs: SecretRefsList
16673
+ }), {
16674
+ kind: "mutation",
16675
+ auth: "admin"
16676
+ }), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
16677
+ ...KindShape,
16678
+ ...TimeWindowShape,
16679
+ where: RecordWhereSchema.optional()
16680
+ }), object({ count: number().int() }), { auth: "admin" }), method(object({
16681
+ ...KindShape,
16682
+ deviceId: number().int().optional(),
16683
+ from: number(),
16684
+ to: number(),
16685
+ bucketMs: number().int().positive()
16686
+ }), object({ buckets: array(object({
16687
+ bucketStart: number(),
16688
+ count: number().int()
16689
+ })) }), { auth: "admin" }), method(object({
16690
+ ...KindShape,
16691
+ op: _enum([
16692
+ "sum",
16693
+ "min",
16694
+ "max",
16695
+ "count"
16696
+ ]),
16697
+ field: RecordFieldPathSchema.optional(),
16698
+ groupBy: RecordFieldPathSchema.optional(),
16699
+ where: RecordWhereSchema.optional()
16700
+ }), object({ rows: array(object({
16701
+ group: union([
16702
+ string(),
16703
+ number(),
16704
+ _null()
16705
+ ]),
16706
+ value: number().nullable()
16707
+ })) }), { auth: "admin" }), method(object({
16708
+ ...KindShape,
16709
+ deviceId: number().int().optional(),
16710
+ atBefore: number().optional(),
16711
+ where: RecordWhereSchema.optional()
16712
+ }), object({
16713
+ deleted: number().int(),
16714
+ secretRefs: SecretRefsList
16715
+ }), {
16716
+ kind: "mutation",
16717
+ auth: "admin"
16718
+ }), method(object({
16719
+ deviceId: number().int(),
16720
+ kinds: array(RecordKindNameSchema).optional()
16721
+ }), object({
16722
+ deleted: record(string(), number().int()),
16723
+ secretRefs: SecretRefsList
16724
+ }), {
16725
+ kind: "mutation",
16726
+ auth: "admin"
16727
+ }), method(object(KindShape), object({ id: number().int() }), {
16728
+ kind: "mutation",
16729
+ auth: "admin"
16730
+ });
16007
16731
  /** One table of the settings database. */
16008
16732
  var StorageTableSchema = object({
16009
16733
  /** The table's full name, e.g. `recorder:addon-settings` or `addon-device-settings`. */
@@ -16016,6 +16740,28 @@ var StorageTableSchema = object({
16016
16740
  /** Declared by an addon since this engine process started (a running addon claims it). */
16017
16741
  declaredThisBoot: boolean()
16018
16742
  });
16743
+ /** One declared record kind (D881) as System -> Data shows it. */
16744
+ var StorageKindSchema = object({
16745
+ owner: string(),
16746
+ kind: string(),
16747
+ database: _enum(["settings", "events"]),
16748
+ class: string(),
16749
+ state: _enum([
16750
+ "declared",
16751
+ "orphaned",
16752
+ "dropped"
16753
+ ]),
16754
+ /** `null` when the caller asked for no counts (`counts: false`). */
16755
+ rows: number().int().nonnegative().nullable(),
16756
+ /** Rows x the average size of a sample; null for an empty kind. */
16757
+ bytesEstimate: number().int().nonnegative().nullable(),
16758
+ writeTrigger: string(),
16759
+ retention: RecordRetentionSchema,
16760
+ /** `true` when the kind is an entry kind (the generic entries UI lists it). */
16761
+ entry: boolean(),
16762
+ /** The whole declaration, secret paths and entry descriptor included (the entries service builds its handle from it). */
16763
+ declaration: RecordKindDeclarationSchema
16764
+ });
16019
16765
  method(object({ ownerPrefix: string().min(1).optional() }), object({ tables: array(StorageTableSchema) }), { auth: "admin" }), method(object({
16020
16766
  collection: string().min(1),
16021
16767
  expectRows: number().int().nonnegative()
@@ -16025,6 +16771,87 @@ method(object({ ownerPrefix: string().min(1).optional() }), object({ tables: arr
16025
16771
  }), {
16026
16772
  kind: "mutation",
16027
16773
  auth: "admin"
16774
+ }), method(object({
16775
+ owner: string().min(1).optional(),
16776
+ /** `false` skips the per-kind row count (a catalog read only). Default true. */
16777
+ counts: boolean().optional()
16778
+ }), object({ kinds: array(StorageKindSchema) }), { auth: "admin" }), method(RecordQueryInputSchema.extend({
16779
+ owner: string().min(1),
16780
+ kind: RecordKindNameSchema
16781
+ }), RecordQueryResultSchema, { auth: "admin" }), method(object({
16782
+ owner: string().min(1),
16783
+ kind: RecordKindNameSchema,
16784
+ records: array(RecordInputSchema).max(RECORD_BATCH_MAX),
16785
+ /** The LAST batch: the copy is complete, the boot guard stops asking. */
16786
+ complete: boolean().optional()
16787
+ }).refine((input) => input.records.length > 0 || input.complete === true, { message: "records must be non-empty unless complete is true" }), object({ adopted: number().int() }), {
16788
+ kind: "mutation",
16789
+ auth: "admin"
16790
+ }), method(object({
16791
+ collection: string().min(1),
16792
+ cursor: string().optional(),
16793
+ limit: number().int().min(1).max(1e3).optional()
16794
+ }), object({
16795
+ rows: array(object({
16796
+ id: string(),
16797
+ data: record(string(), unknown())
16798
+ })),
16799
+ nextCursor: string().nullable()
16800
+ }), { auth: "admin" }), method(object({ collection: string().min(1) }), object({ adopted: boolean() }), { auth: "admin" });
16801
+ /**
16802
+ * record-entries - the ONE admin surface for every list of user-created entries
16803
+ * (D881): notification targets, brokers, LLM profiles, anything an addon
16804
+ * declares as an ENTRY kind (`entry: { title }` in `defineRecordKinds`).
16805
+ *
16806
+ * The UI is generic. `listEntryKinds` hands it, per kind, the JSON Schema of
16807
+ * the entry body with `secret: true` on every credential field, so a password
16808
+ * field is derived from the schema and never from a name. `putEntry` takes the
16809
+ * redaction token for an untouched secret (the stored value is kept), a string
16810
+ * for a new one, and the clear instruction to remove one. A read never carries
16811
+ * a secret value, and a locked keychain refuses the write with
16812
+ * `records/secret-unavailable` instead of storing plaintext.
16813
+ *
16814
+ * Hub-only, served in-process (it acts for each entry's owner on the keychain).
16815
+ */
16816
+ var EntryKindInfoSchema = object({
16817
+ owner: string(),
16818
+ kind: RecordKindNameSchema,
16819
+ title: string(),
16820
+ nameField: string(),
16821
+ /** JSON Schema of the body; `secret: true` marks a password field. */
16822
+ fields: record(string(), unknown()),
16823
+ secretPaths: array(string()),
16824
+ rows: number().int().nonnegative()
16825
+ });
16826
+ var EntryViewSchema = object({
16827
+ id: RecordIdSchema,
16828
+ name: string(),
16829
+ rev: number().int(),
16830
+ updatedAt: number(),
16831
+ /** Secret fields hold the redaction token. */
16832
+ data: RecordBodySchema
16833
+ });
16834
+ var EntryAddress = {
16835
+ owner: string().min(1),
16836
+ kind: RecordKindNameSchema
16837
+ };
16838
+ method(object({}), object({ kinds: array(EntryKindInfoSchema) }), { auth: "admin" }), method(object({ ...EntryAddress }), object({ entries: array(EntryViewSchema) }), { auth: "admin" }), method(object({
16839
+ ...EntryAddress,
16840
+ id: RecordIdSchema.optional(),
16841
+ data: RecordBodySchema,
16842
+ ifRev: number().int().min(1).optional()
16843
+ }), object({
16844
+ id: string(),
16845
+ rev: number().int()
16846
+ }), {
16847
+ kind: "mutation",
16848
+ auth: "admin"
16849
+ }), method(object({
16850
+ ...EntryAddress,
16851
+ id: RecordIdSchema
16852
+ }), object({ deleted: boolean() }), {
16853
+ kind: "mutation",
16854
+ auth: "admin"
16028
16855
  });
16029
16856
  /**
16030
16857
  * `keychain` — the hub's encrypted store of secret values (D787).
@@ -67178,6 +68005,30 @@ Object.freeze({
67178
68005
  addonId: null,
67179
68006
  access: "create"
67180
68007
  },
68008
+ "recordEntries.deleteEntry": {
68009
+ capName: "record-entries",
68010
+ capScope: "system",
68011
+ addonId: null,
68012
+ access: "delete"
68013
+ },
68014
+ "recordEntries.listEntries": {
68015
+ capName: "record-entries",
68016
+ capScope: "system",
68017
+ addonId: null,
68018
+ access: "view"
68019
+ },
68020
+ "recordEntries.listEntryKinds": {
68021
+ capName: "record-entries",
68022
+ capScope: "system",
68023
+ addonId: null,
68024
+ access: "view"
68025
+ },
68026
+ "recordEntries.putEntry": {
68027
+ capName: "record-entries",
68028
+ capScope: "system",
68029
+ addonId: null,
68030
+ access: "create"
68031
+ },
67181
68032
  "recording.getAvailability": {
67182
68033
  capName: "recording",
67183
68034
  capScope: "device",
@@ -67478,6 +68329,102 @@ Object.freeze({
67478
68329
  addonId: null,
67479
68330
  access: "view"
67480
68331
  },
68332
+ "records.aggregate": {
68333
+ capName: "records",
68334
+ capScope: "system",
68335
+ addonId: null,
68336
+ access: "view"
68337
+ },
68338
+ "records.allocateId": {
68339
+ capName: "records",
68340
+ capScope: "system",
68341
+ addonId: null,
68342
+ access: "create"
68343
+ },
68344
+ "records.count": {
68345
+ capName: "records",
68346
+ capScope: "system",
68347
+ addonId: null,
68348
+ access: "view"
68349
+ },
68350
+ "records.declareKinds": {
68351
+ capName: "records",
68352
+ capScope: "system",
68353
+ addonId: null,
68354
+ access: "create"
68355
+ },
68356
+ "records.delete": {
68357
+ capName: "records",
68358
+ capScope: "system",
68359
+ addonId: null,
68360
+ access: "delete"
68361
+ },
68362
+ "records.deleteDevice": {
68363
+ capName: "records",
68364
+ capScope: "system",
68365
+ addonId: null,
68366
+ access: "delete"
68367
+ },
68368
+ "records.deleteMany": {
68369
+ capName: "records",
68370
+ capScope: "system",
68371
+ addonId: null,
68372
+ access: "delete"
68373
+ },
68374
+ "records.deleteWhere": {
68375
+ capName: "records",
68376
+ capScope: "system",
68377
+ addonId: null,
68378
+ access: "delete"
68379
+ },
68380
+ "records.get": {
68381
+ capName: "records",
68382
+ capScope: "system",
68383
+ addonId: null,
68384
+ access: "view"
68385
+ },
68386
+ "records.getMany": {
68387
+ capName: "records",
68388
+ capScope: "system",
68389
+ addonId: null,
68390
+ access: "view"
68391
+ },
68392
+ "records.histogram": {
68393
+ capName: "records",
68394
+ capScope: "system",
68395
+ addonId: null,
68396
+ access: "view"
68397
+ },
68398
+ "records.patch": {
68399
+ capName: "records",
68400
+ capScope: "system",
68401
+ addonId: null,
68402
+ access: "create"
68403
+ },
68404
+ "records.put": {
68405
+ capName: "records",
68406
+ capScope: "system",
68407
+ addonId: null,
68408
+ access: "create"
68409
+ },
68410
+ "records.putMany": {
68411
+ capName: "records",
68412
+ capScope: "system",
68413
+ addonId: null,
68414
+ access: "create"
68415
+ },
68416
+ "records.query": {
68417
+ capName: "records",
68418
+ capScope: "system",
68419
+ addonId: null,
68420
+ access: "view"
68421
+ },
68422
+ "records.secretRefs": {
68423
+ capName: "records",
68424
+ capScope: "system",
68425
+ addonId: null,
68426
+ access: "view"
68427
+ },
67481
68428
  "sceneMonitor.captureReference": {
67482
68429
  capName: "scene-monitor",
67483
68430
  capScope: "device",
@@ -67910,18 +68857,48 @@ Object.freeze({
67910
68857
  addonId: null,
67911
68858
  access: "create"
67912
68859
  },
68860
+ "storageAdmin.adoptRecords": {
68861
+ capName: "storage-admin",
68862
+ capScope: "system",
68863
+ addonId: null,
68864
+ access: "create"
68865
+ },
67913
68866
  "storageAdmin.dropCollection": {
67914
68867
  capName: "storage-admin",
67915
68868
  capScope: "system",
67916
68869
  addonId: null,
67917
68870
  access: "delete"
67918
68871
  },
68872
+ "storageAdmin.isAdoptedLegacyTable": {
68873
+ capName: "storage-admin",
68874
+ capScope: "system",
68875
+ addonId: null,
68876
+ access: "view"
68877
+ },
68878
+ "storageAdmin.listKinds": {
68879
+ capName: "storage-admin",
68880
+ capScope: "system",
68881
+ addonId: null,
68882
+ access: "view"
68883
+ },
67919
68884
  "storageAdmin.listTables": {
67920
68885
  capName: "storage-admin",
67921
68886
  capScope: "system",
67922
68887
  addonId: null,
67923
68888
  access: "view"
67924
68889
  },
68890
+ "storageAdmin.readLegacyCollection": {
68891
+ capName: "storage-admin",
68892
+ capScope: "system",
68893
+ addonId: null,
68894
+ access: "view"
68895
+ },
68896
+ "storageAdmin.readRecords": {
68897
+ capName: "storage-admin",
68898
+ capScope: "system",
68899
+ addonId: null,
68900
+ access: "view"
68901
+ },
67925
68902
  "storageEvictable.evict": {
67926
68903
  capName: "storage-evictable",
67927
68904
  capScope: "system",
@@ -71516,6 +72493,37 @@ Object.freeze({
71516
72493
  form: "single",
71517
72494
  optional: false
71518
72495
  }],
72496
+ "records.count": [{
72497
+ name: "deviceId",
72498
+ form: "single",
72499
+ optional: true
72500
+ }],
72501
+ "records.deleteDevice": [{
72502
+ name: "deviceId",
72503
+ form: "single",
72504
+ optional: false
72505
+ }],
72506
+ "records.deleteWhere": [{
72507
+ name: "deviceId",
72508
+ form: "single",
72509
+ optional: true
72510
+ }],
72511
+ "records.histogram": [{
72512
+ name: "deviceId",
72513
+ form: "single",
72514
+ optional: true
72515
+ }],
72516
+ "records.putMany": [{
72517
+ name: "records",
72518
+ form: "object-array",
72519
+ optional: false,
72520
+ itemField: "deviceId"
72521
+ }],
72522
+ "records.query": [{
72523
+ name: "deviceId",
72524
+ form: "single",
72525
+ optional: true
72526
+ }],
71519
72527
  "sceneMonitor.captureReference": [{
71520
72528
  name: "deviceId",
71521
72529
  form: "single",
@@ -71632,6 +72640,17 @@ Object.freeze({
71632
72640
  form: "single",
71633
72641
  optional: false
71634
72642
  }],
72643
+ "storageAdmin.adoptRecords": [{
72644
+ name: "records",
72645
+ form: "object-array",
72646
+ optional: false,
72647
+ itemField: "deviceId"
72648
+ }],
72649
+ "storageAdmin.readRecords": [{
72650
+ name: "deviceId",
72651
+ form: "single",
72652
+ optional: true
72653
+ }],
71635
72654
  "streamBroker.acquireEgressTranscode": [{
71636
72655
  name: "deviceId",
71637
72656
  form: "single",
@@ -73082,4 +74101,183 @@ DEFAULT_NATIVE_LEASE_SETTINGS.admission;
73082
74101
  var MB = 1024 * 1024;
73083
74102
  1024 * MB, 3072 * MB;
73084
74103
  //#endregion
73085
- export { number as _, addonPagesSourceCapability as a, string as b, trainingProviderCapability as c, arrayItemFieldPath as d, globalSecretScope as f, boolean as g, toSecretFieldView as h, TrainingResultSchema as i, BaseAddon as l, isSecretMarker as m, TrainingJobSchema as n, parseTrainingEventLine as o, isSecretClear as p, TrainingJobSpecSchema as r, trainingCapability as s, TRAINING_JOB_SCHEMA as t, SECRET_CLEAR as u, object as v, record as y };
74104
+ Object.defineProperty(exports, "BaseAddon", {
74105
+ enumerable: true,
74106
+ get: function() {
74107
+ return BaseAddon;
74108
+ }
74109
+ });
74110
+ Object.defineProperty(exports, "RECORD_MAX_DATA_BYTES", {
74111
+ enumerable: true,
74112
+ get: function() {
74113
+ return RECORD_MAX_DATA_BYTES;
74114
+ }
74115
+ });
74116
+ Object.defineProperty(exports, "SECRET_CLEAR", {
74117
+ enumerable: true,
74118
+ get: function() {
74119
+ return SECRET_CLEAR;
74120
+ }
74121
+ });
74122
+ Object.defineProperty(exports, "TRAINING_JOB_SCHEMA", {
74123
+ enumerable: true,
74124
+ get: function() {
74125
+ return TRAINING_JOB_SCHEMA;
74126
+ }
74127
+ });
74128
+ Object.defineProperty(exports, "TrainingJobSchema", {
74129
+ enumerable: true,
74130
+ get: function() {
74131
+ return TrainingJobSchema;
74132
+ }
74133
+ });
74134
+ Object.defineProperty(exports, "TrainingJobSpecSchema", {
74135
+ enumerable: true,
74136
+ get: function() {
74137
+ return TrainingJobSpecSchema;
74138
+ }
74139
+ });
74140
+ Object.defineProperty(exports, "TrainingResultSchema", {
74141
+ enumerable: true,
74142
+ get: function() {
74143
+ return TrainingResultSchema;
74144
+ }
74145
+ });
74146
+ Object.defineProperty(exports, "__commonJSMin", {
74147
+ enumerable: true,
74148
+ get: function() {
74149
+ return __commonJSMin;
74150
+ }
74151
+ });
74152
+ Object.defineProperty(exports, "__esmMin", {
74153
+ enumerable: true,
74154
+ get: function() {
74155
+ return __esmMin;
74156
+ }
74157
+ });
74158
+ Object.defineProperty(exports, "__exportAll", {
74159
+ enumerable: true,
74160
+ get: function() {
74161
+ return __exportAll;
74162
+ }
74163
+ });
74164
+ Object.defineProperty(exports, "__toCommonJS", {
74165
+ enumerable: true,
74166
+ get: function() {
74167
+ return __toCommonJS;
74168
+ }
74169
+ });
74170
+ Object.defineProperty(exports, "__toESM", {
74171
+ enumerable: true,
74172
+ get: function() {
74173
+ return __toESM;
74174
+ }
74175
+ });
74176
+ Object.defineProperty(exports, "addonPagesSourceCapability", {
74177
+ enumerable: true,
74178
+ get: function() {
74179
+ return addonPagesSourceCapability;
74180
+ }
74181
+ });
74182
+ Object.defineProperty(exports, "arrayItemFieldPath", {
74183
+ enumerable: true,
74184
+ get: function() {
74185
+ return arrayItemFieldPath;
74186
+ }
74187
+ });
74188
+ Object.defineProperty(exports, "boolean", {
74189
+ enumerable: true,
74190
+ get: function() {
74191
+ return boolean;
74192
+ }
74193
+ });
74194
+ Object.defineProperty(exports, "defineEntryKind", {
74195
+ enumerable: true,
74196
+ get: function() {
74197
+ return defineEntryKind;
74198
+ }
74199
+ });
74200
+ Object.defineProperty(exports, "defineRecordKinds", {
74201
+ enumerable: true,
74202
+ get: function() {
74203
+ return defineRecordKinds;
74204
+ }
74205
+ });
74206
+ Object.defineProperty(exports, "entryBody", {
74207
+ enumerable: true,
74208
+ get: function() {
74209
+ return entryBody;
74210
+ }
74211
+ });
74212
+ Object.defineProperty(exports, "globalSecretScope", {
74213
+ enumerable: true,
74214
+ get: function() {
74215
+ return globalSecretScope;
74216
+ }
74217
+ });
74218
+ Object.defineProperty(exports, "isSecretClear", {
74219
+ enumerable: true,
74220
+ get: function() {
74221
+ return isSecretClear;
74222
+ }
74223
+ });
74224
+ Object.defineProperty(exports, "isSecretMarker", {
74225
+ enumerable: true,
74226
+ get: function() {
74227
+ return isSecretMarker;
74228
+ }
74229
+ });
74230
+ Object.defineProperty(exports, "number", {
74231
+ enumerable: true,
74232
+ get: function() {
74233
+ return number;
74234
+ }
74235
+ });
74236
+ Object.defineProperty(exports, "object", {
74237
+ enumerable: true,
74238
+ get: function() {
74239
+ return object;
74240
+ }
74241
+ });
74242
+ Object.defineProperty(exports, "parseTrainingEventLine", {
74243
+ enumerable: true,
74244
+ get: function() {
74245
+ return parseTrainingEventLine;
74246
+ }
74247
+ });
74248
+ Object.defineProperty(exports, "record", {
74249
+ enumerable: true,
74250
+ get: function() {
74251
+ return record;
74252
+ }
74253
+ });
74254
+ Object.defineProperty(exports, "settingsArrayAdoptsFrom", {
74255
+ enumerable: true,
74256
+ get: function() {
74257
+ return settingsArrayAdoptsFrom;
74258
+ }
74259
+ });
74260
+ Object.defineProperty(exports, "string", {
74261
+ enumerable: true,
74262
+ get: function() {
74263
+ return string;
74264
+ }
74265
+ });
74266
+ Object.defineProperty(exports, "toSecretFieldView", {
74267
+ enumerable: true,
74268
+ get: function() {
74269
+ return toSecretFieldView;
74270
+ }
74271
+ });
74272
+ Object.defineProperty(exports, "trainingCapability", {
74273
+ enumerable: true,
74274
+ get: function() {
74275
+ return trainingCapability;
74276
+ }
74277
+ });
74278
+ Object.defineProperty(exports, "trainingProviderCapability", {
74279
+ enumerable: true,
74280
+ get: function() {
74281
+ return trainingProviderCapability;
74282
+ }
74283
+ });