@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,37 +1,4 @@
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");
1
+ import "node:crypto";
35
2
  //#region ../types/dist/event-category-BvOFi6PY.mjs
36
3
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
37
4
  EventCategory["SystemBoot"] = "system.boot";
@@ -4156,6 +4123,12 @@ var numberProcessor = (schema, ctx, _json, _params) => {
4156
4123
  var booleanProcessor = (_schema, _ctx, json, _params) => {
4157
4124
  json.type = "boolean";
4158
4125
  };
4126
+ var bigintProcessor = (_schema, ctx, _json, _params) => {
4127
+ if (ctx.unrepresentable === "throw") throw new Error("BigInt cannot be represented in JSON Schema");
4128
+ };
4129
+ var symbolProcessor = (_schema, ctx, _json, _params) => {
4130
+ if (ctx.unrepresentable === "throw") throw new Error("Symbols cannot be represented in JSON Schema");
4131
+ };
4159
4132
  var nullProcessor = (_schema, ctx, json, _params) => {
4160
4133
  if (ctx.target === "openapi-3.0") {
4161
4134
  json.type = "string";
@@ -4163,12 +4136,17 @@ var nullProcessor = (_schema, ctx, json, _params) => {
4163
4136
  json.enum = [null];
4164
4137
  } else json.type = "null";
4165
4138
  };
4139
+ var undefinedProcessor = (_schema, ctx, _json, _params) => {
4140
+ if (ctx.unrepresentable === "throw") throw new Error("Undefined cannot be represented in JSON Schema");
4141
+ };
4166
4142
  var voidProcessor = (_schema, ctx, _json, _params) => {
4167
4143
  if (ctx.unrepresentable === "throw") throw new Error("Void cannot be represented in JSON Schema");
4168
4144
  };
4169
4145
  var neverProcessor = (_schema, _ctx, json, _params) => {
4170
4146
  json.not = {};
4171
4147
  };
4148
+ var anyProcessor = (_schema, _ctx, _json, _params) => {};
4149
+ var unknownProcessor = (_schema, _ctx, _json, _params) => {};
4172
4150
  var dateProcessor = (_schema, ctx, _json, _params) => {
4173
4151
  if (ctx.unrepresentable === "throw") throw new Error("Date cannot be represented in JSON Schema");
4174
4152
  };
@@ -4200,12 +4178,53 @@ var literalProcessor = (schema, ctx, json, _params) => {
4200
4178
  json.enum = vals;
4201
4179
  }
4202
4180
  };
4181
+ var nanProcessor = (_schema, ctx, _json, _params) => {
4182
+ if (ctx.unrepresentable === "throw") throw new Error("NaN cannot be represented in JSON Schema");
4183
+ };
4184
+ var templateLiteralProcessor = (schema, _ctx, json, _params) => {
4185
+ const _json = json;
4186
+ const pattern = schema._zod.pattern;
4187
+ if (!pattern) throw new Error("Pattern not found in template literal");
4188
+ _json.type = "string";
4189
+ _json.pattern = pattern.source;
4190
+ };
4191
+ var fileProcessor = (schema, _ctx, json, _params) => {
4192
+ const _json = json;
4193
+ const file = {
4194
+ type: "string",
4195
+ format: "binary",
4196
+ contentEncoding: "binary"
4197
+ };
4198
+ const { minimum, maximum, mime } = schema._zod.bag;
4199
+ if (minimum !== void 0) file.minLength = minimum;
4200
+ if (maximum !== void 0) file.maxLength = maximum;
4201
+ if (mime) if (mime.length === 1) {
4202
+ file.contentMediaType = mime[0];
4203
+ Object.assign(_json, file);
4204
+ } else {
4205
+ Object.assign(_json, file);
4206
+ _json.anyOf = mime.map((m) => ({ contentMediaType: m }));
4207
+ }
4208
+ else Object.assign(_json, file);
4209
+ };
4210
+ var successProcessor = (_schema, _ctx, json, _params) => {
4211
+ json.type = "boolean";
4212
+ };
4203
4213
  var customProcessor = (_schema, ctx, _json, _params) => {
4204
4214
  if (ctx.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
4205
4215
  };
4216
+ var functionProcessor = (_schema, ctx, _json, _params) => {
4217
+ if (ctx.unrepresentable === "throw") throw new Error("Function types cannot be represented in JSON Schema");
4218
+ };
4206
4219
  var transformProcessor = (_schema, ctx, _json, _params) => {
4207
4220
  if (ctx.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
4208
4221
  };
4222
+ var mapProcessor = (_schema, ctx, _json, _params) => {
4223
+ if (ctx.unrepresentable === "throw") throw new Error("Map cannot be represented in JSON Schema");
4224
+ };
4225
+ var setProcessor = (_schema, ctx, _json, _params) => {
4226
+ if (ctx.unrepresentable === "throw") throw new Error("Set cannot be represented in JSON Schema");
4227
+ };
4209
4228
  var arrayProcessor = (schema, ctx, _json, params) => {
4210
4229
  const json = _json;
4211
4230
  const def = schema._zod.def;
@@ -4410,6 +4429,12 @@ var readonlyProcessor = (schema, ctx, json, params) => {
4410
4429
  seen.ref = def.innerType;
4411
4430
  json.readOnly = true;
4412
4431
  };
4432
+ var promiseProcessor = (schema, ctx, _json, params) => {
4433
+ const def = schema._zod.def;
4434
+ process(def.innerType, ctx, params);
4435
+ const seen = ctx.seen.get(schema);
4436
+ seen.ref = def.innerType;
4437
+ };
4413
4438
  var optionalProcessor = (schema, ctx, _json, params) => {
4414
4439
  const def = schema._zod.def;
4415
4440
  process(def.innerType, ctx, params);
@@ -4422,6 +4447,81 @@ var lazyProcessor = (schema, ctx, _json, params) => {
4422
4447
  const seen = ctx.seen.get(schema);
4423
4448
  seen.ref = innerType;
4424
4449
  };
4450
+ var allProcessors = {
4451
+ string: stringProcessor,
4452
+ number: numberProcessor,
4453
+ boolean: booleanProcessor,
4454
+ bigint: bigintProcessor,
4455
+ symbol: symbolProcessor,
4456
+ null: nullProcessor,
4457
+ undefined: undefinedProcessor,
4458
+ void: voidProcessor,
4459
+ never: neverProcessor,
4460
+ any: anyProcessor,
4461
+ unknown: unknownProcessor,
4462
+ date: dateProcessor,
4463
+ enum: enumProcessor,
4464
+ literal: literalProcessor,
4465
+ nan: nanProcessor,
4466
+ template_literal: templateLiteralProcessor,
4467
+ file: fileProcessor,
4468
+ success: successProcessor,
4469
+ custom: customProcessor,
4470
+ function: functionProcessor,
4471
+ transform: transformProcessor,
4472
+ map: mapProcessor,
4473
+ set: setProcessor,
4474
+ array: arrayProcessor,
4475
+ object: objectProcessor,
4476
+ union: unionProcessor,
4477
+ intersection: intersectionProcessor,
4478
+ tuple: tupleProcessor,
4479
+ record: recordProcessor,
4480
+ nullable: nullableProcessor,
4481
+ nonoptional: nonoptionalProcessor,
4482
+ default: defaultProcessor,
4483
+ prefault: prefaultProcessor,
4484
+ catch: catchProcessor,
4485
+ pipe: pipeProcessor,
4486
+ readonly: readonlyProcessor,
4487
+ promise: promiseProcessor,
4488
+ optional: optionalProcessor,
4489
+ lazy: lazyProcessor
4490
+ };
4491
+ function toJSONSchema(input, params) {
4492
+ if ("_idmap" in input) {
4493
+ const registry = input;
4494
+ const ctx = initializeContext({
4495
+ ...params,
4496
+ processors: allProcessors
4497
+ });
4498
+ const defs = {};
4499
+ for (const entry of registry._idmap.entries()) {
4500
+ const [_, schema] = entry;
4501
+ process(schema, ctx);
4502
+ }
4503
+ const schemas = {};
4504
+ ctx.external = {
4505
+ registry,
4506
+ uri: params?.uri,
4507
+ defs
4508
+ };
4509
+ for (const entry of registry._idmap.entries()) {
4510
+ const [key, schema] = entry;
4511
+ extractDefs(ctx, schema);
4512
+ schemas[key] = finalize(ctx, schema);
4513
+ }
4514
+ if (Object.keys(defs).length > 0) schemas.__shared = { [ctx.target === "draft-2020-12" ? "$defs" : "definitions"]: defs };
4515
+ return { schemas };
4516
+ }
4517
+ const ctx = initializeContext({
4518
+ ...params,
4519
+ processors: allProcessors
4520
+ });
4521
+ process(input, ctx);
4522
+ extractDefs(ctx, input);
4523
+ return finalize(ctx, input);
4524
+ }
4425
4525
  //#endregion
4426
4526
  //#region ../../node_modules/zod/v4/classic/iso.js
4427
4527
  var ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
@@ -5438,7 +5538,7 @@ var ZodIssueCode = {
5438
5538
  var ZodFirstPartyTypeKind;
5439
5539
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5440
5540
  //#endregion
5441
- //#region ../types/dist/sleep-D-Q2_Mcd.mjs
5541
+ //#region ../types/dist/sleep-bZIhUvjd.mjs
5442
5542
  /**
5443
5543
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5444
5544
  * window to float samples (D455).
@@ -5555,7 +5655,7 @@ function isKeychainStoredField(field) {
5555
5655
  var SECRET_CLEAR = { $secretClear: true };
5556
5656
  /** The `'***'` token D634 redaction writes for non-admins. */
5557
5657
  var LEGACY_DEVICE_REDACTION = "***";
5558
- function isRecord$2(value) {
5658
+ function isRecord$5(value) {
5559
5659
  return typeof value === "object" && value !== null && !Array.isArray(value);
5560
5660
  }
5561
5661
  function makeSecretMarker(ref) {
@@ -5566,12 +5666,12 @@ function makeSecretMarker(ref) {
5566
5666
  }
5567
5667
  /** A stored marker: an object whose `$secret` is a non-empty string. */
5568
5668
  function isSecretMarker(value) {
5569
- if (!isRecord$2(value)) return false;
5669
+ if (!isRecord$5(value)) return false;
5570
5670
  const ref = value["$secret"];
5571
5671
  return typeof ref === "string" && ref.length > 0;
5572
5672
  }
5573
5673
  function isSecretClear(value) {
5574
- return isRecord$2(value) && value["$secretClear"] === true;
5674
+ return isRecord$5(value) && value["$secretClear"] === true;
5575
5675
  }
5576
5676
  /**
5577
5677
  * The UI view of a stored secret field value: a marker becomes "set", inline
@@ -6181,7 +6281,7 @@ var KeychainWriteRefusedError = class extends Error {
6181
6281
  }
6182
6282
  };
6183
6283
  var KEEP = { kind: "keep" };
6184
- function isRecord$1(value) {
6284
+ function isRecord$4(value) {
6185
6285
  return typeof value === "object" && value !== null && !Array.isArray(value);
6186
6286
  }
6187
6287
  function defaultMintId() {
@@ -6194,7 +6294,7 @@ function collectSecretMarkerRefs(value, out = []) {
6194
6294
  return out;
6195
6295
  }
6196
6296
  if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6197
- else if (isRecord$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6297
+ else if (isRecord$4(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6198
6298
  return out;
6199
6299
  }
6200
6300
  async function storedValueEquals(secrets, marker, candidate) {
@@ -6249,7 +6349,7 @@ function rowId(row, idKey) {
6249
6349
  return null;
6250
6350
  }
6251
6351
  async function writeArray(ctx, node, incoming, stored, fieldPath) {
6252
- const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1) : [];
6352
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$4) : [];
6253
6353
  if (!Array.isArray(incoming)) {
6254
6354
  ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6255
6355
  return {
@@ -6265,7 +6365,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6265
6365
  const kept = /* @__PURE__ */ new Set();
6266
6366
  const rows = [];
6267
6367
  for (const row of incoming) {
6268
- if (!isRecord$1(row)) {
6368
+ if (!isRecord$4(row)) {
6269
6369
  rows.push(row);
6270
6370
  continue;
6271
6371
  }
@@ -6290,7 +6390,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6290
6390
  case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6291
6391
  case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6292
6392
  case "object": {
6293
- if (!isRecord$1(incoming)) {
6393
+ if (!isRecord$4(incoming)) {
6294
6394
  if (incoming === void 0) return KEEP;
6295
6395
  ctx.deletes.push(...collectSecretMarkerRefs(stored));
6296
6396
  return {
@@ -6298,7 +6398,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6298
6398
  value: incoming
6299
6399
  };
6300
6400
  }
6301
- const storedObj = isRecord$1(stored) ? stored : {};
6401
+ const storedObj = isRecord$4(stored) ? stored : {};
6302
6402
  return {
6303
6403
  kind: "value",
6304
6404
  value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
@@ -6421,7 +6521,7 @@ async function resolveSecretMarkers(value, secrets, options = {}) {
6421
6521
  value: items
6422
6522
  };
6423
6523
  }
6424
- if (isRecord$1(v)) {
6524
+ if (isRecord$4(v)) {
6425
6525
  const out = {};
6426
6526
  for (const [k, child] of Object.entries(v)) {
6427
6527
  const s = substitute(child);
@@ -6453,7 +6553,7 @@ var SecretOverwriteRefusedError = class extends Error {
6453
6553
  this.name = "SecretOverwriteRefusedError";
6454
6554
  }
6455
6555
  };
6456
- function isRecord(value) {
6556
+ function isRecord$3(value) {
6457
6557
  return typeof value === "object" && value !== null && !Array.isArray(value);
6458
6558
  }
6459
6559
  function resolvedValue(pass, marker) {
@@ -6482,7 +6582,7 @@ function inArray(pass, incoming, stored) {
6482
6582
  return incoming.map((item, index) => {
6483
6583
  const twin = stored[index];
6484
6584
  if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
6485
- if (isRecord(item) && isRecord(twin)) return inArrayRow(pass, item, twin);
6585
+ if (isRecord$3(item) && isRecord$3(twin)) return inArrayRow(pass, item, twin);
6486
6586
  if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
6487
6587
  return item;
6488
6588
  });
@@ -6493,7 +6593,7 @@ function inArrayRow(pass, incoming, stored) {
6493
6593
  const twin = stored[key];
6494
6594
  if (isSecretMarker(twin)) {
6495
6595
  if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
6496
- } else if (isRecord(value) && isRecord(twin)) out[key] = inArrayRow(pass, value, twin);
6596
+ } else if (isRecord$3(value) && isRecord$3(twin)) out[key] = inArrayRow(pass, value, twin);
6497
6597
  else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
6498
6598
  }
6499
6599
  return out;
@@ -6501,7 +6601,7 @@ function inArrayRow(pass, incoming, stored) {
6501
6601
  async function walk(pass, incoming, stored) {
6502
6602
  if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
6503
6603
  if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
6504
- if (!isRecord(incoming) || !isRecord(stored)) return incoming;
6604
+ if (!isRecord$3(incoming) || !isRecord$3(stored)) return incoming;
6505
6605
  const out = { ...incoming };
6506
6606
  for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
6507
6607
  return out;
@@ -6532,7 +6632,7 @@ async function restoreUnchangedSecrets(input) {
6532
6632
  function isJsonEqual(a, b) {
6533
6633
  if (Object.is(a, b)) return true;
6534
6634
  if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
6535
- if (isRecord(a) && isRecord(b)) {
6635
+ if (isRecord$3(a) && isRecord$3(b)) {
6536
6636
  const keys = Object.keys(a);
6537
6637
  if (keys.length !== Object.keys(b).length) return false;
6538
6638
  return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
@@ -6556,7 +6656,7 @@ function markerKeysOf(blob, owner) {
6556
6656
  }
6557
6657
  function nodeFromStored(value, owner) {
6558
6658
  if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
6559
- if (!isRecord(value)) return null;
6659
+ if (!isRecord$3(value)) return null;
6560
6660
  const children = /* @__PURE__ */ new Map();
6561
6661
  for (const [key, child] of Object.entries(value)) {
6562
6662
  const node = nodeFromStored(child, owner);
@@ -7344,7 +7444,7 @@ var BaseAddon = class {
7344
7444
  if (!ctx) return;
7345
7445
  const addonId = ctx.id;
7346
7446
  setImmediate(() => {
7347
- ctx.api.addons?.restartAddon?.mutate({ addonId }).then(() => {
7447
+ ctx.api.addons.restartAddon.mutate({ addonId }).then(() => {
7348
7448
  ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
7349
7449
  }).catch((err) => {
7350
7450
  ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
@@ -7838,6 +7938,348 @@ var PeerBytesTicketSchema = object({
7838
7938
  */
7839
7939
  declaredBytes: number().int().nonnegative().nullable()
7840
7940
  });
7941
+ /** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
7942
+ /** The files a kind may live in. `history` is device-history's (D850), never records. */
7943
+ var RECORD_DATABASES = ["settings", "events"];
7944
+ /** The classes of a kind: the `@durable` vocabulary, one authority (replaces the annotation). */
7945
+ var RECORD_CLASSES = [
7946
+ "config",
7947
+ "ledger",
7948
+ "audit",
7949
+ "mirror",
7950
+ "ephemeral"
7951
+ ];
7952
+ var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
7953
+ var RECORD_MAX_DATA_BYTES = 1024 * 1024;
7954
+ var RECORD_BATCH_MAX = 1e3;
7955
+ var RECORD_QUERY_MAX = 1e3;
7956
+ /** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
7957
+ var RECORD_SETTINGS_MAX_ROWS = 5e4;
7958
+ var PREFIX = "records/";
7959
+ /** The base of every records failure. `detail` is the human part of the message. */
7960
+ var RecordsError = class extends Error {
7961
+ code;
7962
+ detail;
7963
+ constructor(code, detail) {
7964
+ super(`${PREFIX}${code}: ${detail}`);
7965
+ this.name = "RecordsError";
7966
+ this.code = code;
7967
+ this.detail = detail;
7968
+ }
7969
+ };
7970
+ var InvalidRecordError = class extends RecordsError {
7971
+ constructor(detail) {
7972
+ super("invalid-record", detail);
7973
+ this.name = "InvalidRecordError";
7974
+ }
7975
+ };
7976
+ /** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
7977
+ var DeclarationRefusedError = class extends RecordsError {
7978
+ constructor(detail) {
7979
+ super("declaration-refused", detail);
7980
+ this.name = "DeclarationRefusedError";
7981
+ }
7982
+ };
7983
+ function defOf(schema) {
7984
+ const zodBag = Reflect.get(schema, "_zod");
7985
+ if (typeof zodBag !== "object" || zodBag === null) return {};
7986
+ const def = Reflect.get(zodBag, "def");
7987
+ if (typeof def !== "object" || def === null) return {};
7988
+ return def;
7989
+ }
7990
+ function declaredHere(schema) {
7991
+ return globalRegistry.get(schema)?.secret === true;
7992
+ }
7993
+ /** Wrapper kinds whose `innerType` is the field itself. */
7994
+ var WRAPPERS = new Set([
7995
+ "optional",
7996
+ "nullable",
7997
+ "default",
7998
+ "prefault",
7999
+ "catch",
8000
+ "readonly",
8001
+ "nonoptional"
8002
+ ]);
8003
+ /**
8004
+ * The schema layers that make up ONE field: the schema itself and every
8005
+ * wrapper below it (optional / default / nullable / readonly / catch), plus
8006
+ * both sides of a pipe (`z.preprocess` puts the real schema on `out`,
8007
+ * `.transform` on `in`).
8008
+ */
8009
+ function layersOf(schema) {
8010
+ const out = [];
8011
+ const queue = [schema];
8012
+ while (queue.length > 0) {
8013
+ const s = queue.shift();
8014
+ if (!s || out.includes(s)) continue;
8015
+ out.push(s);
8016
+ const def = defOf(s);
8017
+ if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
8018
+ if (def.type === "pipe") {
8019
+ if (def.in) queue.push(def.in);
8020
+ if (def.out) queue.push(def.out);
8021
+ }
8022
+ }
8023
+ return out;
8024
+ }
8025
+ /** True when any layer of this field declares `.meta({ secret: true })`. */
8026
+ function isZodSecret(schema) {
8027
+ return layersOf(schema).some(declaredHere);
8028
+ }
8029
+ /**
8030
+ * Every declared secret path in a config schema: dotted keys, `[]` for "each
8031
+ * element of this array" (`connection.password`, `rows[].token`). A declared
8032
+ * object or array is reported as one path and not descended into — everything
8033
+ * under it is secret.
8034
+ */
8035
+ function collectZodSecretPaths(schema, prefix = "") {
8036
+ if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
8037
+ const paths = [];
8038
+ for (const layer of layersOf(schema)) {
8039
+ const def = defOf(layer);
8040
+ if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
8041
+ else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
8042
+ else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
8043
+ else if (def.type === "intersection") {
8044
+ if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
8045
+ if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
8046
+ }
8047
+ }
8048
+ return [...new Set(paths)];
8049
+ }
8050
+ /**
8051
+ * Secret fields of a record, addressed the way a Zod schema declares them
8052
+ * (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
8053
+ * (`auth.accessToken`, `headers[].value`).
8054
+ *
8055
+ * Array elements are matched by a DECLARED id key (`secretArrayKeys`:
8056
+ * `{ headers: 'name' }`), never by index, so reordering a list keeps every
8057
+ * keychain ref (the same rule as `arrayItemFieldPath`). The concrete path of a
8058
+ * leaf names its element: `headers[X-Api].value`.
8059
+ *
8060
+ * Pure and browser-safe. Nothing here mutates: every transform returns a new value.
8061
+ */
8062
+ /** The array prefixes (declared form, e.g. `headers` or `a.headers`) of a path. */
8063
+ function parseSecretPath(path) {
8064
+ if (path.length === 0) throw new InvalidRecordError("an empty secret path");
8065
+ return path.split(".").map((raw) => {
8066
+ const each = raw.endsWith("[]");
8067
+ const key = each ? raw.slice(0, -2) : raw;
8068
+ if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
8069
+ return {
8070
+ key,
8071
+ each
8072
+ };
8073
+ });
8074
+ }
8075
+ /** The declared array prefixes of `path` that need an id key (`headers`, `a.rows`). */
8076
+ function secretArrayPrefixes(path) {
8077
+ const segments = parseSecretPath(path);
8078
+ const prefixes = [];
8079
+ const walked = [];
8080
+ for (const segment of segments) {
8081
+ walked.push(segment.key);
8082
+ if (segment.each) prefixes.push(walked.join("."));
8083
+ }
8084
+ return prefixes;
8085
+ }
8086
+ /**
8087
+ * Record kinds (D881): the declaration an addon makes of one kind of fact, the
8088
+ * Zod row schema that describes it, and the helper that turns the two into the
8089
+ * JSON the engine stores.
8090
+ *
8091
+ * A kind is declared ONCE, next to the code that owns it, and the engine's
8092
+ * reconciler creates its indexes - nothing creates DDL at runtime from a write.
8093
+ * Everything the generic machinery needs (secret fields, the entry descriptor)
8094
+ * is DERIVED from the Zod schema: `.meta({ secret: true })` marks a credential,
8095
+ * never a field name (D879).
8096
+ */
8097
+ /** A JSON field path: `trackId`, `auth.accessToken`. Charset-restricted: it is rendered into DDL. */
8098
+ var RecordFieldPathSchema = string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,63}(\.[A-Za-z_][A-Za-z0-9_]{0,63}){0,3}$/);
8099
+ var RecordIndexSchema = object({
8100
+ name: string().regex(/^[a-z][a-z0-9_]{0,31}$/),
8101
+ fields: array(RecordFieldPathSchema).min(1).max(4),
8102
+ unique: boolean().optional()
8103
+ }).strict();
8104
+ var RecordRetentionSchema = union([
8105
+ object({
8106
+ ttlMs: number().int().positive(),
8107
+ from: _enum(["at", "write"])
8108
+ }).strict(),
8109
+ object({
8110
+ maxRows: number().int().positive().optional(),
8111
+ maxRowsPerDevice: number().int().positive().optional()
8112
+ }).strict().refine((r) => r.maxRows !== void 0 || r.maxRowsPerDevice !== void 0, { message: "name maxRows, maxRowsPerDevice or both" }),
8113
+ object({
8114
+ owner: string().min(1),
8115
+ reason: string().min(1)
8116
+ }).strict(),
8117
+ object({ none: string().min(1) }).strict()
8118
+ ]);
8119
+ /** The descriptor a generic entries UI reads (D881 "generic entries"). */
8120
+ var EntryDescriptorSchema = object({
8121
+ title: string().min(1),
8122
+ /** The record body field shown as the entry's name. */
8123
+ nameField: string().min(1),
8124
+ /** JSON Schema of the entry body; `secret: true` marks a password field. */
8125
+ fields: record(string(), unknown())
8126
+ }).strict();
8127
+ /** What crosses the wire and sits in the engine's catalog: JSON only, no Zod. */
8128
+ var RecordKindDeclarationSchema = object({
8129
+ database: _enum(RECORD_DATABASES).default("settings"),
8130
+ class: _enum(RECORD_CLASSES),
8131
+ writeTrigger: string().min(1),
8132
+ device: _enum([
8133
+ "required",
8134
+ "optional",
8135
+ "none"
8136
+ ]).default("none"),
8137
+ at: _enum(["required", "none"]).default("none"),
8138
+ indexes: array(RecordIndexSchema).max(8).default([]),
8139
+ retention: RecordRetentionSchema,
8140
+ deviceRemoval: _enum(["delete", "none"]).default("none"),
8141
+ maxDataBytes: number().int().positive().max(RECORD_MAX_DATA_BYTES).default(RECORD_DEFAULT_MAX_DATA_BYTES),
8142
+ /** Derived from the Zod schema; never written by hand. */
8143
+ secretPaths: array(string().min(1)).default([]),
8144
+ /** The id key of each array that carries a secret (`{ headers: 'name' }`). */
8145
+ secretArrayKeys: record(string(), string()).default({}),
8146
+ /** The legacy table this kind adopts from; the boot guard reads it (D853: no migration code). */
8147
+ adoptsFrom: string().min(1).optional(),
8148
+ /** Kinds that must agree through `transact` sit in one file under one family name. */
8149
+ transactFamily: string().min(1).optional(),
8150
+ entry: EntryDescriptorSchema.optional()
8151
+ }).strict();
8152
+ /** The kind names: lower-case, dash separated, short enough for an index name. */
8153
+ var RecordKindNameSchema = string().regex(/^[a-z][a-z0-9-]{0,47}$/);
8154
+ /** Cross-field rules a declaration must satisfy. Throws {@link DeclarationRefusedError}. */
8155
+ function assertValidDeclaration(name, decl) {
8156
+ const refuse = (why) => {
8157
+ throw new DeclarationRefusedError(`kind "${name}": ${why}`);
8158
+ };
8159
+ if (!RecordKindNameSchema.safeParse(name).success) refuse("the name must be lower-case-dashed");
8160
+ const seen = /* @__PURE__ */ new Set();
8161
+ for (const index of decl.indexes) {
8162
+ if (seen.has(index.name)) refuse(`index name "${index.name}" is declared twice`);
8163
+ seen.add(index.name);
8164
+ }
8165
+ const { retention } = decl;
8166
+ const hasSecrets = decl.secretPaths.length > 0;
8167
+ if ("ttlMs" in retention) {
8168
+ if (retention.from === "at" && decl.at !== "required") refuse("a ttl from \"at\" needs at: \"required\"");
8169
+ if (hasSecrets) refuse("a kind with secret fields cannot use engine TTL (its keychain values would be orphaned)");
8170
+ }
8171
+ if ("maxRows" in retention || "maxRowsPerDevice" in retention) {
8172
+ if (retention.maxRowsPerDevice !== void 0 && decl.device !== "required") refuse("maxRowsPerDevice needs device: \"required\"");
8173
+ if (decl.at !== "required") refuse("a row bound trims the oldest \"at\": it needs at: \"required\"");
8174
+ if (hasSecrets) refuse("a kind with secret fields cannot use an engine row bound");
8175
+ const bound = Math.max(retention.maxRows ?? 0, retention.maxRowsPerDevice ?? 0);
8176
+ 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)`);
8177
+ }
8178
+ if (decl.deviceRemoval === "delete" && decl.device === "none") refuse("deviceRemoval: \"delete\" needs a device: \"required\" or \"optional\"");
8179
+ 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`);
8180
+ }
8181
+ function bodyFieldsOf(schema) {
8182
+ return { ...toJSONSchema(schema, {
8183
+ unrepresentable: "any",
8184
+ io: "input"
8185
+ }) };
8186
+ }
8187
+ function isRecordLike(value) {
8188
+ return typeof value === "object" && value !== null && !Array.isArray(value);
8189
+ }
8190
+ /** Does every branch of the body schema carry `field`? (A discriminated union has several.) */
8191
+ function hasNameField(json, field) {
8192
+ const branches = json["oneOf"] ?? json["anyOf"];
8193
+ if (Array.isArray(branches)) return branches.length > 0 && branches.every((b) => isRecordLike(b) && hasNameField(b, field));
8194
+ const properties = json["properties"];
8195
+ return isRecordLike(properties) && Object.prototype.hasOwnProperty.call(properties, field);
8196
+ }
8197
+ /**
8198
+ * Declare the kinds of a package. The keys are the kind names. The result is
8199
+ * what `ctx.records.declare` sends to the engine and what `ctx.records.kind`
8200
+ * types its handle from.
8201
+ */
8202
+ function defineRecordKinds(specs) {
8203
+ const out = {};
8204
+ for (const [name, spec] of Object.entries(specs)) {
8205
+ const secretPaths = collectZodSecretPaths(spec.schema);
8206
+ const nameField = spec.entry?.nameField ?? "name";
8207
+ const fields = bodyFieldsOf(spec.schema);
8208
+ if (spec.entry !== void 0 && !hasNameField(fields, nameField)) throw new DeclarationRefusedError(`kind "${name}": an entry kind's schema needs a "${nameField}" field`);
8209
+ const parsed = RecordKindDeclarationSchema.parse({
8210
+ database: spec.database,
8211
+ class: spec.class,
8212
+ writeTrigger: spec.writeTrigger,
8213
+ device: spec.device,
8214
+ at: spec.at,
8215
+ indexes: spec.indexes === void 0 ? void 0 : [...spec.indexes],
8216
+ retention: spec.retention,
8217
+ deviceRemoval: spec.deviceRemoval,
8218
+ maxDataBytes: spec.maxDataBytes,
8219
+ secretPaths: [...secretPaths],
8220
+ secretArrayKeys: spec.secretArrayKeys === void 0 ? void 0 : { ...spec.secretArrayKeys },
8221
+ adoptsFrom: spec.adoptsFrom,
8222
+ transactFamily: spec.transactFamily,
8223
+ entry: spec.entry === void 0 ? void 0 : {
8224
+ title: spec.entry.title,
8225
+ nameField,
8226
+ fields
8227
+ }
8228
+ });
8229
+ assertValidDeclaration(name, parsed);
8230
+ out[name] = {
8231
+ name,
8232
+ schema: spec.schema,
8233
+ declaration: parsed
8234
+ };
8235
+ }
8236
+ return out;
8237
+ }
8238
+ /**
8239
+ * Entry kinds (D881): every list of user-created entries (notification
8240
+ * targets, brokers, LLM profiles) is ONE record kind with an id, a name and a
8241
+ * kind-specific body, and the admin UI lists/adds/edits/deletes all of them
8242
+ * through the `record-entries` capability with password fields derived from
8243
+ * the schema (`.meta({ secret: true })`).
8244
+ */
8245
+ /** The body of a plain entry: a name and the fields the kind adds. */
8246
+ function entryBody(shape) {
8247
+ return object({
8248
+ name: string().min(1),
8249
+ ...shape
8250
+ });
8251
+ }
8252
+ /**
8253
+ * Declare one entry kind. An entry is configuration: never trimmed by the
8254
+ * engine, never aged, belonging to no device.
8255
+ */
8256
+ function defineEntryKind(name, spec) {
8257
+ const defined = defineRecordKinds({ [name]: {
8258
+ schema: spec.schema,
8259
+ class: "config",
8260
+ writeTrigger: spec.writeTrigger ?? "an operator adds or edits an entry in the entries UI",
8261
+ retention: { none: "an entry goes only when the operator deletes it" },
8262
+ ...spec.database === void 0 ? {} : { database: spec.database },
8263
+ ...spec.indexes === void 0 ? {} : { indexes: spec.indexes },
8264
+ ...spec.secretArrayKeys === void 0 ? {} : { secretArrayKeys: spec.secretArrayKeys },
8265
+ ...spec.adoptsFrom === void 0 ? {} : { adoptsFrom: spec.adoptsFrom },
8266
+ entry: {
8267
+ title: spec.title,
8268
+ ...spec.nameField === void 0 ? {} : { nameField: spec.nameField }
8269
+ }
8270
+ } })[name];
8271
+ if (defined === void 0) throw new DeclarationRefusedError(`entry kind "${name}" was not built`);
8272
+ return defined;
8273
+ }
8274
+ /**
8275
+ * Legacy source for entry adoption (B3): a list stored under addon-settings
8276
+ * `<addonId>.<key>` until records-adopt copies rows into the entry kind.
8277
+ */
8278
+ var SETTINGS_ARRAY_ADOPTS_PREFIX = "@settings-array/";
8279
+ /** The `adoptsFrom` value for an addon-settings array field. */
8280
+ function settingsArrayAdoptsFrom(addonId, settingsKey) {
8281
+ return `${SETTINGS_ARRAY_ADOPTS_PREFIX}${addonId}/${settingsKey}`;
8282
+ }
7841
8283
  /** Shared Zod schemas used across streaming capabilities. */
7842
8284
  var CamProfileSchema = _enum([
7843
8285
  "high",
@@ -16037,6 +16479,222 @@ id: union([string(), number()]) }), {
16037
16479
  kind: "mutation",
16038
16480
  auth: "admin"
16039
16481
  });
16482
+ /**
16483
+ * records - an addon's own facts and documents (D881): ledgers, audit rows,
16484
+ * config documents, mirrors. The third storage API next to `ctx.settings`
16485
+ * (operator intent, D870) and device-history (numbers over time, D850).
16486
+ *
16487
+ * Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
16488
+ * crossed a process and stated by a hub in-process caller (`ctx.records` does
16489
+ * that with the addon id closed over). It is deliberately NOT in any input
16490
+ * schema, so a session can never supply it, and a call with no stamp is refused
16491
+ * `records/no-caller`. A kind is readable and writable only by its owner; other
16492
+ * addons go through the owner's capability.
16493
+ *
16494
+ * Every read is three-way: a row, `null`, or the call THROWS. A failed read is
16495
+ * never `[]`. Secret fields are never on the wire: a read shows the
16496
+ * redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
16497
+ * resolves itself, and a write may carry only a keychain marker bound to the
16498
+ * row's own ref.
16499
+ *
16500
+ * Internal: addons reach it through `ctx.records`, never directly.
16501
+ */
16502
+ var RecordIdSchema = string().min(1).max(256);
16503
+ /** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
16504
+ var RecordBodySchema = record(string(), unknown());
16505
+ var RecordInputSchema = object({
16506
+ id: RecordIdSchema,
16507
+ /** The device this row belongs to (D865 removal, per-device reads). */
16508
+ deviceId: number().int().optional(),
16509
+ /** The domain clock, ms: observed / created / opened. */
16510
+ at: number().int().optional(),
16511
+ /** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
16512
+ expiresAt: number().int().optional(),
16513
+ data: RecordBodySchema
16514
+ });
16515
+ var RecordViewSchema = object({
16516
+ id: string(),
16517
+ deviceId: number().int().nullable(),
16518
+ at: number().nullable(),
16519
+ expiresAt: number().nullable(),
16520
+ rev: number().int(),
16521
+ updatedAt: number(),
16522
+ data: RecordBodySchema
16523
+ });
16524
+ /** Declared index fields only. Anything else does not compile, by design. */
16525
+ var RecordWhereSchema = record(RecordFieldPathSchema, union([
16526
+ string(),
16527
+ number(),
16528
+ boolean(),
16529
+ object({ in: array(union([
16530
+ string(),
16531
+ number(),
16532
+ boolean()
16533
+ ])).min(1).max(RECORD_BATCH_MAX) }),
16534
+ object({
16535
+ gt: union([string(), number()]).optional(),
16536
+ gte: union([string(), number()]).optional(),
16537
+ lt: union([string(), number()]).optional(),
16538
+ lte: union([string(), number()]).optional()
16539
+ }).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
16540
+ ]));
16541
+ var KindShape = { kind: RecordKindNameSchema };
16542
+ var TimeWindowShape = {
16543
+ deviceId: number().int().optional(),
16544
+ atFrom: number().optional(),
16545
+ atTo: number().optional()
16546
+ };
16547
+ var RecordQueryInputSchema = object({
16548
+ ...KindShape,
16549
+ ...TimeWindowShape,
16550
+ where: RecordWhereSchema.optional(),
16551
+ /** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
16552
+ order: _enum(["at", "id"]).optional(),
16553
+ desc: boolean().optional(),
16554
+ limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
16555
+ /** Opaque keyset cursor from a previous answer. There is no offset. */
16556
+ cursor: string().min(1).optional()
16557
+ });
16558
+ var RecordQueryResultSchema = object({
16559
+ records: array(RecordViewSchema),
16560
+ nextCursor: string().nullable()
16561
+ });
16562
+ var RecordKindStateSchema = _enum([
16563
+ "created",
16564
+ "unchanged",
16565
+ "updated"
16566
+ ]);
16567
+ var DeclareKindResultSchema = object({
16568
+ kindId: number().int(),
16569
+ state: RecordKindStateSchema,
16570
+ createdIndexes: array(string()),
16571
+ /** The boot guard: the kind is empty while its legacy table still holds rows. */
16572
+ adoptionPending: object({
16573
+ legacyTable: string(),
16574
+ legacyRows: number().int()
16575
+ }).nullable()
16576
+ });
16577
+ /** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
16578
+ var SecretRefsList = array(string());
16579
+ var RecordSecretRefsSchema = record(string(), record(string(), string()));
16580
+ method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
16581
+ kind: "mutation",
16582
+ auth: "admin"
16583
+ }), method(object({
16584
+ ...KindShape,
16585
+ id: RecordIdSchema
16586
+ }), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
16587
+ ...KindShape,
16588
+ ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
16589
+ }), array(RecordViewSchema), { auth: "admin" }), method(object({
16590
+ ...KindShape,
16591
+ ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
16592
+ }), RecordSecretRefsSchema, { auth: "admin" }), method(object({
16593
+ ...KindShape,
16594
+ record: RecordInputSchema,
16595
+ /** Compare-and-set. `0` means "the row must not exist". */
16596
+ ifRev: number().int().min(0).optional()
16597
+ }), object({
16598
+ rev: number().int(),
16599
+ releasedRefs: SecretRefsList
16600
+ }), {
16601
+ kind: "mutation",
16602
+ auth: "admin"
16603
+ }), method(object({
16604
+ ...KindShape,
16605
+ records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
16606
+ }), object({
16607
+ count: number().int(),
16608
+ releasedRefs: SecretRefsList
16609
+ }), {
16610
+ kind: "mutation",
16611
+ auth: "admin"
16612
+ }), method(object({
16613
+ ...KindShape,
16614
+ id: RecordIdSchema,
16615
+ data: RecordBodySchema,
16616
+ at: number().int().nullable().optional(),
16617
+ expiresAt: number().int().nullable().optional(),
16618
+ ifRev: number().int().min(1).optional()
16619
+ }), object({
16620
+ rev: number().int(),
16621
+ releasedRefs: SecretRefsList
16622
+ }), {
16623
+ kind: "mutation",
16624
+ auth: "admin"
16625
+ }), method(object({
16626
+ ...KindShape,
16627
+ id: RecordIdSchema
16628
+ }), object({
16629
+ deleted: boolean(),
16630
+ secretRefs: SecretRefsList
16631
+ }), {
16632
+ kind: "mutation",
16633
+ auth: "admin"
16634
+ }), method(object({
16635
+ ...KindShape,
16636
+ ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
16637
+ }), object({
16638
+ deleted: number().int(),
16639
+ secretRefs: SecretRefsList
16640
+ }), {
16641
+ kind: "mutation",
16642
+ auth: "admin"
16643
+ }), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
16644
+ ...KindShape,
16645
+ ...TimeWindowShape,
16646
+ where: RecordWhereSchema.optional()
16647
+ }), object({ count: number().int() }), { auth: "admin" }), method(object({
16648
+ ...KindShape,
16649
+ deviceId: number().int().optional(),
16650
+ from: number(),
16651
+ to: number(),
16652
+ bucketMs: number().int().positive()
16653
+ }), object({ buckets: array(object({
16654
+ bucketStart: number(),
16655
+ count: number().int()
16656
+ })) }), { auth: "admin" }), method(object({
16657
+ ...KindShape,
16658
+ op: _enum([
16659
+ "sum",
16660
+ "min",
16661
+ "max",
16662
+ "count"
16663
+ ]),
16664
+ field: RecordFieldPathSchema.optional(),
16665
+ groupBy: RecordFieldPathSchema.optional(),
16666
+ where: RecordWhereSchema.optional()
16667
+ }), object({ rows: array(object({
16668
+ group: union([
16669
+ string(),
16670
+ number(),
16671
+ _null()
16672
+ ]),
16673
+ value: number().nullable()
16674
+ })) }), { auth: "admin" }), method(object({
16675
+ ...KindShape,
16676
+ deviceId: number().int().optional(),
16677
+ atBefore: number().optional(),
16678
+ where: RecordWhereSchema.optional()
16679
+ }), object({
16680
+ deleted: number().int(),
16681
+ secretRefs: SecretRefsList
16682
+ }), {
16683
+ kind: "mutation",
16684
+ auth: "admin"
16685
+ }), method(object({
16686
+ deviceId: number().int(),
16687
+ kinds: array(RecordKindNameSchema).optional()
16688
+ }), object({
16689
+ deleted: record(string(), number().int()),
16690
+ secretRefs: SecretRefsList
16691
+ }), {
16692
+ kind: "mutation",
16693
+ auth: "admin"
16694
+ }), method(object(KindShape), object({ id: number().int() }), {
16695
+ kind: "mutation",
16696
+ auth: "admin"
16697
+ });
16040
16698
  /** One table of the settings database. */
16041
16699
  var StorageTableSchema = object({
16042
16700
  /** The table's full name, e.g. `recorder:addon-settings` or `addon-device-settings`. */
@@ -16049,6 +16707,28 @@ var StorageTableSchema = object({
16049
16707
  /** Declared by an addon since this engine process started (a running addon claims it). */
16050
16708
  declaredThisBoot: boolean()
16051
16709
  });
16710
+ /** One declared record kind (D881) as System -> Data shows it. */
16711
+ var StorageKindSchema = object({
16712
+ owner: string(),
16713
+ kind: string(),
16714
+ database: _enum(["settings", "events"]),
16715
+ class: string(),
16716
+ state: _enum([
16717
+ "declared",
16718
+ "orphaned",
16719
+ "dropped"
16720
+ ]),
16721
+ /** `null` when the caller asked for no counts (`counts: false`). */
16722
+ rows: number().int().nonnegative().nullable(),
16723
+ /** Rows x the average size of a sample; null for an empty kind. */
16724
+ bytesEstimate: number().int().nonnegative().nullable(),
16725
+ writeTrigger: string(),
16726
+ retention: RecordRetentionSchema,
16727
+ /** `true` when the kind is an entry kind (the generic entries UI lists it). */
16728
+ entry: boolean(),
16729
+ /** The whole declaration, secret paths and entry descriptor included (the entries service builds its handle from it). */
16730
+ declaration: RecordKindDeclarationSchema
16731
+ });
16052
16732
  method(object({ ownerPrefix: string().min(1).optional() }), object({ tables: array(StorageTableSchema) }), { auth: "admin" }), method(object({
16053
16733
  collection: string().min(1),
16054
16734
  expectRows: number().int().nonnegative()
@@ -16058,6 +16738,87 @@ method(object({ ownerPrefix: string().min(1).optional() }), object({ tables: arr
16058
16738
  }), {
16059
16739
  kind: "mutation",
16060
16740
  auth: "admin"
16741
+ }), method(object({
16742
+ owner: string().min(1).optional(),
16743
+ /** `false` skips the per-kind row count (a catalog read only). Default true. */
16744
+ counts: boolean().optional()
16745
+ }), object({ kinds: array(StorageKindSchema) }), { auth: "admin" }), method(RecordQueryInputSchema.extend({
16746
+ owner: string().min(1),
16747
+ kind: RecordKindNameSchema
16748
+ }), RecordQueryResultSchema, { auth: "admin" }), method(object({
16749
+ owner: string().min(1),
16750
+ kind: RecordKindNameSchema,
16751
+ records: array(RecordInputSchema).max(RECORD_BATCH_MAX),
16752
+ /** The LAST batch: the copy is complete, the boot guard stops asking. */
16753
+ complete: boolean().optional()
16754
+ }).refine((input) => input.records.length > 0 || input.complete === true, { message: "records must be non-empty unless complete is true" }), object({ adopted: number().int() }), {
16755
+ kind: "mutation",
16756
+ auth: "admin"
16757
+ }), method(object({
16758
+ collection: string().min(1),
16759
+ cursor: string().optional(),
16760
+ limit: number().int().min(1).max(1e3).optional()
16761
+ }), object({
16762
+ rows: array(object({
16763
+ id: string(),
16764
+ data: record(string(), unknown())
16765
+ })),
16766
+ nextCursor: string().nullable()
16767
+ }), { auth: "admin" }), method(object({ collection: string().min(1) }), object({ adopted: boolean() }), { auth: "admin" });
16768
+ /**
16769
+ * record-entries - the ONE admin surface for every list of user-created entries
16770
+ * (D881): notification targets, brokers, LLM profiles, anything an addon
16771
+ * declares as an ENTRY kind (`entry: { title }` in `defineRecordKinds`).
16772
+ *
16773
+ * The UI is generic. `listEntryKinds` hands it, per kind, the JSON Schema of
16774
+ * the entry body with `secret: true` on every credential field, so a password
16775
+ * field is derived from the schema and never from a name. `putEntry` takes the
16776
+ * redaction token for an untouched secret (the stored value is kept), a string
16777
+ * for a new one, and the clear instruction to remove one. A read never carries
16778
+ * a secret value, and a locked keychain refuses the write with
16779
+ * `records/secret-unavailable` instead of storing plaintext.
16780
+ *
16781
+ * Hub-only, served in-process (it acts for each entry's owner on the keychain).
16782
+ */
16783
+ var EntryKindInfoSchema = object({
16784
+ owner: string(),
16785
+ kind: RecordKindNameSchema,
16786
+ title: string(),
16787
+ nameField: string(),
16788
+ /** JSON Schema of the body; `secret: true` marks a password field. */
16789
+ fields: record(string(), unknown()),
16790
+ secretPaths: array(string()),
16791
+ rows: number().int().nonnegative()
16792
+ });
16793
+ var EntryViewSchema = object({
16794
+ id: RecordIdSchema,
16795
+ name: string(),
16796
+ rev: number().int(),
16797
+ updatedAt: number(),
16798
+ /** Secret fields hold the redaction token. */
16799
+ data: RecordBodySchema
16800
+ });
16801
+ var EntryAddress = {
16802
+ owner: string().min(1),
16803
+ kind: RecordKindNameSchema
16804
+ };
16805
+ method(object({}), object({ kinds: array(EntryKindInfoSchema) }), { auth: "admin" }), method(object({ ...EntryAddress }), object({ entries: array(EntryViewSchema) }), { auth: "admin" }), method(object({
16806
+ ...EntryAddress,
16807
+ id: RecordIdSchema.optional(),
16808
+ data: RecordBodySchema,
16809
+ ifRev: number().int().min(1).optional()
16810
+ }), object({
16811
+ id: string(),
16812
+ rev: number().int()
16813
+ }), {
16814
+ kind: "mutation",
16815
+ auth: "admin"
16816
+ }), method(object({
16817
+ ...EntryAddress,
16818
+ id: RecordIdSchema
16819
+ }), object({ deleted: boolean() }), {
16820
+ kind: "mutation",
16821
+ auth: "admin"
16061
16822
  });
16062
16823
  /**
16063
16824
  * `keychain` — the hub's encrypted store of secret values (D787).
@@ -67211,6 +67972,30 @@ Object.freeze({
67211
67972
  addonId: null,
67212
67973
  access: "create"
67213
67974
  },
67975
+ "recordEntries.deleteEntry": {
67976
+ capName: "record-entries",
67977
+ capScope: "system",
67978
+ addonId: null,
67979
+ access: "delete"
67980
+ },
67981
+ "recordEntries.listEntries": {
67982
+ capName: "record-entries",
67983
+ capScope: "system",
67984
+ addonId: null,
67985
+ access: "view"
67986
+ },
67987
+ "recordEntries.listEntryKinds": {
67988
+ capName: "record-entries",
67989
+ capScope: "system",
67990
+ addonId: null,
67991
+ access: "view"
67992
+ },
67993
+ "recordEntries.putEntry": {
67994
+ capName: "record-entries",
67995
+ capScope: "system",
67996
+ addonId: null,
67997
+ access: "create"
67998
+ },
67214
67999
  "recording.getAvailability": {
67215
68000
  capName: "recording",
67216
68001
  capScope: "device",
@@ -67511,6 +68296,102 @@ Object.freeze({
67511
68296
  addonId: null,
67512
68297
  access: "view"
67513
68298
  },
68299
+ "records.aggregate": {
68300
+ capName: "records",
68301
+ capScope: "system",
68302
+ addonId: null,
68303
+ access: "view"
68304
+ },
68305
+ "records.allocateId": {
68306
+ capName: "records",
68307
+ capScope: "system",
68308
+ addonId: null,
68309
+ access: "create"
68310
+ },
68311
+ "records.count": {
68312
+ capName: "records",
68313
+ capScope: "system",
68314
+ addonId: null,
68315
+ access: "view"
68316
+ },
68317
+ "records.declareKinds": {
68318
+ capName: "records",
68319
+ capScope: "system",
68320
+ addonId: null,
68321
+ access: "create"
68322
+ },
68323
+ "records.delete": {
68324
+ capName: "records",
68325
+ capScope: "system",
68326
+ addonId: null,
68327
+ access: "delete"
68328
+ },
68329
+ "records.deleteDevice": {
68330
+ capName: "records",
68331
+ capScope: "system",
68332
+ addonId: null,
68333
+ access: "delete"
68334
+ },
68335
+ "records.deleteMany": {
68336
+ capName: "records",
68337
+ capScope: "system",
68338
+ addonId: null,
68339
+ access: "delete"
68340
+ },
68341
+ "records.deleteWhere": {
68342
+ capName: "records",
68343
+ capScope: "system",
68344
+ addonId: null,
68345
+ access: "delete"
68346
+ },
68347
+ "records.get": {
68348
+ capName: "records",
68349
+ capScope: "system",
68350
+ addonId: null,
68351
+ access: "view"
68352
+ },
68353
+ "records.getMany": {
68354
+ capName: "records",
68355
+ capScope: "system",
68356
+ addonId: null,
68357
+ access: "view"
68358
+ },
68359
+ "records.histogram": {
68360
+ capName: "records",
68361
+ capScope: "system",
68362
+ addonId: null,
68363
+ access: "view"
68364
+ },
68365
+ "records.patch": {
68366
+ capName: "records",
68367
+ capScope: "system",
68368
+ addonId: null,
68369
+ access: "create"
68370
+ },
68371
+ "records.put": {
68372
+ capName: "records",
68373
+ capScope: "system",
68374
+ addonId: null,
68375
+ access: "create"
68376
+ },
68377
+ "records.putMany": {
68378
+ capName: "records",
68379
+ capScope: "system",
68380
+ addonId: null,
68381
+ access: "create"
68382
+ },
68383
+ "records.query": {
68384
+ capName: "records",
68385
+ capScope: "system",
68386
+ addonId: null,
68387
+ access: "view"
68388
+ },
68389
+ "records.secretRefs": {
68390
+ capName: "records",
68391
+ capScope: "system",
68392
+ addonId: null,
68393
+ access: "view"
68394
+ },
67514
68395
  "sceneMonitor.captureReference": {
67515
68396
  capName: "scene-monitor",
67516
68397
  capScope: "device",
@@ -67943,18 +68824,48 @@ Object.freeze({
67943
68824
  addonId: null,
67944
68825
  access: "create"
67945
68826
  },
68827
+ "storageAdmin.adoptRecords": {
68828
+ capName: "storage-admin",
68829
+ capScope: "system",
68830
+ addonId: null,
68831
+ access: "create"
68832
+ },
67946
68833
  "storageAdmin.dropCollection": {
67947
68834
  capName: "storage-admin",
67948
68835
  capScope: "system",
67949
68836
  addonId: null,
67950
68837
  access: "delete"
67951
68838
  },
68839
+ "storageAdmin.isAdoptedLegacyTable": {
68840
+ capName: "storage-admin",
68841
+ capScope: "system",
68842
+ addonId: null,
68843
+ access: "view"
68844
+ },
68845
+ "storageAdmin.listKinds": {
68846
+ capName: "storage-admin",
68847
+ capScope: "system",
68848
+ addonId: null,
68849
+ access: "view"
68850
+ },
67952
68851
  "storageAdmin.listTables": {
67953
68852
  capName: "storage-admin",
67954
68853
  capScope: "system",
67955
68854
  addonId: null,
67956
68855
  access: "view"
67957
68856
  },
68857
+ "storageAdmin.readLegacyCollection": {
68858
+ capName: "storage-admin",
68859
+ capScope: "system",
68860
+ addonId: null,
68861
+ access: "view"
68862
+ },
68863
+ "storageAdmin.readRecords": {
68864
+ capName: "storage-admin",
68865
+ capScope: "system",
68866
+ addonId: null,
68867
+ access: "view"
68868
+ },
67958
68869
  "storageEvictable.evict": {
67959
68870
  capName: "storage-evictable",
67960
68871
  capScope: "system",
@@ -71549,6 +72460,37 @@ Object.freeze({
71549
72460
  form: "single",
71550
72461
  optional: false
71551
72462
  }],
72463
+ "records.count": [{
72464
+ name: "deviceId",
72465
+ form: "single",
72466
+ optional: true
72467
+ }],
72468
+ "records.deleteDevice": [{
72469
+ name: "deviceId",
72470
+ form: "single",
72471
+ optional: false
72472
+ }],
72473
+ "records.deleteWhere": [{
72474
+ name: "deviceId",
72475
+ form: "single",
72476
+ optional: true
72477
+ }],
72478
+ "records.histogram": [{
72479
+ name: "deviceId",
72480
+ form: "single",
72481
+ optional: true
72482
+ }],
72483
+ "records.putMany": [{
72484
+ name: "records",
72485
+ form: "object-array",
72486
+ optional: false,
72487
+ itemField: "deviceId"
72488
+ }],
72489
+ "records.query": [{
72490
+ name: "deviceId",
72491
+ form: "single",
72492
+ optional: true
72493
+ }],
71552
72494
  "sceneMonitor.captureReference": [{
71553
72495
  name: "deviceId",
71554
72496
  form: "single",
@@ -71665,6 +72607,17 @@ Object.freeze({
71665
72607
  form: "single",
71666
72608
  optional: false
71667
72609
  }],
72610
+ "storageAdmin.adoptRecords": [{
72611
+ name: "records",
72612
+ form: "object-array",
72613
+ optional: false,
72614
+ itemField: "deviceId"
72615
+ }],
72616
+ "storageAdmin.readRecords": [{
72617
+ name: "deviceId",
72618
+ form: "single",
72619
+ optional: true
72620
+ }],
71668
72621
  "streamBroker.acquireEgressTranscode": [{
71669
72622
  name: "deviceId",
71670
72623
  form: "single",
@@ -73115,153 +74068,4 @@ DEFAULT_NATIVE_LEASE_SETTINGS.admission;
73115
74068
  var MB = 1024 * 1024;
73116
74069
  1024 * MB, 3072 * MB;
73117
74070
  //#endregion
73118
- Object.defineProperty(exports, "BaseAddon", {
73119
- enumerable: true,
73120
- get: function() {
73121
- return BaseAddon;
73122
- }
73123
- });
73124
- Object.defineProperty(exports, "SECRET_CLEAR", {
73125
- enumerable: true,
73126
- get: function() {
73127
- return SECRET_CLEAR;
73128
- }
73129
- });
73130
- Object.defineProperty(exports, "TRAINING_JOB_SCHEMA", {
73131
- enumerable: true,
73132
- get: function() {
73133
- return TRAINING_JOB_SCHEMA;
73134
- }
73135
- });
73136
- Object.defineProperty(exports, "TrainingJobSchema", {
73137
- enumerable: true,
73138
- get: function() {
73139
- return TrainingJobSchema;
73140
- }
73141
- });
73142
- Object.defineProperty(exports, "TrainingJobSpecSchema", {
73143
- enumerable: true,
73144
- get: function() {
73145
- return TrainingJobSpecSchema;
73146
- }
73147
- });
73148
- Object.defineProperty(exports, "TrainingResultSchema", {
73149
- enumerable: true,
73150
- get: function() {
73151
- return TrainingResultSchema;
73152
- }
73153
- });
73154
- Object.defineProperty(exports, "__commonJSMin", {
73155
- enumerable: true,
73156
- get: function() {
73157
- return __commonJSMin;
73158
- }
73159
- });
73160
- Object.defineProperty(exports, "__esmMin", {
73161
- enumerable: true,
73162
- get: function() {
73163
- return __esmMin;
73164
- }
73165
- });
73166
- Object.defineProperty(exports, "__exportAll", {
73167
- enumerable: true,
73168
- get: function() {
73169
- return __exportAll;
73170
- }
73171
- });
73172
- Object.defineProperty(exports, "__toCommonJS", {
73173
- enumerable: true,
73174
- get: function() {
73175
- return __toCommonJS;
73176
- }
73177
- });
73178
- Object.defineProperty(exports, "__toESM", {
73179
- enumerable: true,
73180
- get: function() {
73181
- return __toESM;
73182
- }
73183
- });
73184
- Object.defineProperty(exports, "addonPagesSourceCapability", {
73185
- enumerable: true,
73186
- get: function() {
73187
- return addonPagesSourceCapability;
73188
- }
73189
- });
73190
- Object.defineProperty(exports, "arrayItemFieldPath", {
73191
- enumerable: true,
73192
- get: function() {
73193
- return arrayItemFieldPath;
73194
- }
73195
- });
73196
- Object.defineProperty(exports, "boolean", {
73197
- enumerable: true,
73198
- get: function() {
73199
- return boolean;
73200
- }
73201
- });
73202
- Object.defineProperty(exports, "globalSecretScope", {
73203
- enumerable: true,
73204
- get: function() {
73205
- return globalSecretScope;
73206
- }
73207
- });
73208
- Object.defineProperty(exports, "isSecretClear", {
73209
- enumerable: true,
73210
- get: function() {
73211
- return isSecretClear;
73212
- }
73213
- });
73214
- Object.defineProperty(exports, "isSecretMarker", {
73215
- enumerable: true,
73216
- get: function() {
73217
- return isSecretMarker;
73218
- }
73219
- });
73220
- Object.defineProperty(exports, "number", {
73221
- enumerable: true,
73222
- get: function() {
73223
- return number;
73224
- }
73225
- });
73226
- Object.defineProperty(exports, "object", {
73227
- enumerable: true,
73228
- get: function() {
73229
- return object;
73230
- }
73231
- });
73232
- Object.defineProperty(exports, "parseTrainingEventLine", {
73233
- enumerable: true,
73234
- get: function() {
73235
- return parseTrainingEventLine;
73236
- }
73237
- });
73238
- Object.defineProperty(exports, "record", {
73239
- enumerable: true,
73240
- get: function() {
73241
- return record;
73242
- }
73243
- });
73244
- Object.defineProperty(exports, "string", {
73245
- enumerable: true,
73246
- get: function() {
73247
- return string;
73248
- }
73249
- });
73250
- Object.defineProperty(exports, "toSecretFieldView", {
73251
- enumerable: true,
73252
- get: function() {
73253
- return toSecretFieldView;
73254
- }
73255
- });
73256
- Object.defineProperty(exports, "trainingCapability", {
73257
- enumerable: true,
73258
- get: function() {
73259
- return trainingCapability;
73260
- }
73261
- });
73262
- Object.defineProperty(exports, "trainingProviderCapability", {
73263
- enumerable: true,
73264
- get: function() {
73265
- return trainingProviderCapability;
73266
- }
73267
- });
74071
+ export { object as C, number as S, string as T, isSecretClear as _, addonPagesSourceCapability as a, toSecretFieldView as b, trainingProviderCapability as c, SECRET_CLEAR as d, arrayItemFieldPath as f, globalSecretScope as g, entryBody as h, TrainingResultSchema as i, BaseAddon as l, defineRecordKinds as m, TrainingJobSchema as n, parseTrainingEventLine as o, defineEntryKind as p, TrainingJobSpecSchema as r, trainingCapability as s, TRAINING_JOB_SCHEMA as t, RECORD_MAX_DATA_BYTES as u, isSecretMarker as v, record as w, boolean as x, settingsArrayAdoptsFrom as y };