@camstack/types 1.2.378 → 1.2.380

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 (36) hide show
  1. package/dist/addon.d.ts +1 -0
  2. package/dist/addon.js +57 -2
  3. package/dist/addon.mjs +5 -3
  4. package/dist/capabilities/caller-stamp.d.ts +12 -0
  5. package/dist/capabilities/core-blocks.cap.d.ts +26 -4
  6. package/dist/capabilities/index.d.ts +7 -2
  7. package/dist/capabilities/llm.cap.d.ts +1 -0
  8. package/dist/capabilities/raw-secret-migration.d.ts +1 -0
  9. package/dist/capabilities/record-entries.cap.d.ts +84 -0
  10. package/dist/capabilities/records.cap.d.ts +399 -0
  11. package/dist/capabilities/storage-admin.cap.d.ts +246 -0
  12. package/dist/capabilities/user-management.cap.d.ts +1 -0
  13. package/dist/client.js +7 -0
  14. package/dist/client.mjs +7 -0
  15. package/dist/generated/addon-api.d.ts +184 -0
  16. package/dist/generated/cap-input-defaults.d.ts +1 -1
  17. package/dist/generated/capability-router-map.d.ts +8 -2
  18. package/dist/generated/method-access-map.d.ts +1 -1
  19. package/dist/generated/method-device-selectors.d.ts +2 -2
  20. package/dist/generated/system-proxy.d.ts +3 -1
  21. package/dist/index.d.ts +2 -1
  22. package/dist/index.js +746 -38
  23. package/dist/index.mjs +677 -39
  24. package/dist/interfaces/addon.d.ts +13 -0
  25. package/dist/interfaces/event-bus.d.ts +32 -3
  26. package/dist/interfaces/storage.d.ts +1 -1
  27. package/dist/records/constants.d.ts +23 -0
  28. package/dist/records/entry-kind.d.ts +31 -0
  29. package/dist/records/errors.d.ts +81 -0
  30. package/dist/records/index.d.ts +6 -0
  31. package/dist/records/record-kind.d.ts +144 -0
  32. package/dist/records/records-access.d.ts +153 -0
  33. package/dist/records/secret-paths.d.ts +52 -0
  34. package/dist/{sleep-gxUz0C9M.js → sleep-CIGOw58l.js} +1520 -309
  35. package/dist/{sleep-bgZLodYc.mjs → sleep-WsrozGDL.mjs} +999 -112
  36. package/package.json +1 -1
@@ -162,7 +162,7 @@ function collectKeychainStoredKeys(schema) {
162
162
  return keys;
163
163
  }
164
164
  function walkKeychainField(field, out) {
165
- if (!isRecord$3(field)) return;
165
+ if (!isRecord$5(field)) return;
166
166
  const type = field["type"];
167
167
  const key = field["key"];
168
168
  const isSecret = type === "password" || field["secret"] === true;
@@ -187,21 +187,21 @@ function schemaDeclaresAnyField(schema) {
187
187
  for (const section of sectionsOf(schema)) if (fieldsOf(section).length > 0) return true;
188
188
  return false;
189
189
  }
190
- function isRecord$3(value) {
190
+ function isRecord$5(value) {
191
191
  return typeof value === "object" && value !== null && !Array.isArray(value);
192
192
  }
193
193
  function sectionsOf(schema) {
194
- if (!isRecord$3(schema)) return [];
194
+ if (!isRecord$5(schema)) return [];
195
195
  const sections = schema["sections"];
196
196
  return Array.isArray(sections) ? sections : [];
197
197
  }
198
198
  function fieldsOf(node) {
199
- if (!isRecord$3(node)) return [];
199
+ if (!isRecord$5(node)) return [];
200
200
  const fields = node["fields"];
201
201
  return Array.isArray(fields) ? fields : [];
202
202
  }
203
203
  function walkField(field, out) {
204
- if (!isRecord$3(field)) return;
204
+ if (!isRecord$5(field)) return;
205
205
  const type = field["type"];
206
206
  const key = field["key"];
207
207
  if ((type === "password" || field["secret"] === true) && typeof key === "string" && key.length > 0) out.add(key);
@@ -241,7 +241,7 @@ function walkField(field, out) {
241
241
  var SECRET_CLEAR = { $secretClear: true };
242
242
  /** The `'***'` token D634 redaction writes for non-admins. */
243
243
  var LEGACY_DEVICE_REDACTION = "***";
244
- function isRecord$2(value) {
244
+ function isRecord$4(value) {
245
245
  return typeof value === "object" && value !== null && !Array.isArray(value);
246
246
  }
247
247
  function makeSecretMarker(ref) {
@@ -252,19 +252,19 @@ function makeSecretMarker(ref) {
252
252
  }
253
253
  /** A stored marker: an object whose `$secret` is a non-empty string. */
254
254
  function isSecretMarker(value) {
255
- if (!isRecord$2(value)) return false;
255
+ if (!isRecord$4(value)) return false;
256
256
  const ref = value["$secret"];
257
257
  return typeof ref === "string" && ref.length > 0;
258
258
  }
259
259
  /** Anything carrying a `$secret` key — a stored marker or a UI view of one. */
260
260
  function isSecretMarkerLike(value) {
261
- return isRecord$2(value) && Object.prototype.hasOwnProperty.call(value, "$secret");
261
+ return isRecord$4(value) && Object.prototype.hasOwnProperty.call(value, "$secret");
262
262
  }
263
263
  function isSecretClear(value) {
264
- return isRecord$2(value) && value["$secretClear"] === true;
264
+ return isRecord$4(value) && value["$secretClear"] === true;
265
265
  }
266
266
  function isSecretFieldView(value) {
267
- return isRecord$2(value) && value["set"] === true && isSecretMarkerLike(value);
267
+ return isRecord$4(value) && value["set"] === true && isSecretMarkerLike(value);
268
268
  }
269
269
  /**
270
270
  * The UI view of a stored secret field value: a marker becomes "set", inline
@@ -1018,7 +1018,7 @@ var KeychainWriteRefusedError = class extends Error {
1018
1018
  }
1019
1019
  };
1020
1020
  var KEEP = { kind: "keep" };
1021
- function isRecord$1(value) {
1021
+ function isRecord$3(value) {
1022
1022
  return typeof value === "object" && value !== null && !Array.isArray(value);
1023
1023
  }
1024
1024
  function defaultMintId() {
@@ -1031,7 +1031,7 @@ function collectSecretMarkerRefs(value, out = []) {
1031
1031
  return out;
1032
1032
  }
1033
1033
  if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
1034
- else if (isRecord$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
1034
+ else if (isRecord$3(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
1035
1035
  return out;
1036
1036
  }
1037
1037
  async function storedValueEquals(secrets, marker, candidate) {
@@ -1086,7 +1086,7 @@ function rowId(row, idKey) {
1086
1086
  return null;
1087
1087
  }
1088
1088
  async function writeArray(ctx, node, incoming, stored, fieldPath) {
1089
- const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1) : [];
1089
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$3) : [];
1090
1090
  if (!Array.isArray(incoming)) {
1091
1091
  ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
1092
1092
  return {
@@ -1102,7 +1102,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
1102
1102
  const kept = /* @__PURE__ */ new Set();
1103
1103
  const rows = [];
1104
1104
  for (const row of incoming) {
1105
- if (!isRecord$1(row)) {
1105
+ if (!isRecord$3(row)) {
1106
1106
  rows.push(row);
1107
1107
  continue;
1108
1108
  }
@@ -1127,7 +1127,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
1127
1127
  case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
1128
1128
  case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
1129
1129
  case "object": {
1130
- if (!isRecord$1(incoming)) {
1130
+ if (!isRecord$3(incoming)) {
1131
1131
  if (incoming === void 0) return KEEP;
1132
1132
  ctx.deletes.push(...collectSecretMarkerRefs(stored));
1133
1133
  return {
@@ -1135,7 +1135,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
1135
1135
  value: incoming
1136
1136
  };
1137
1137
  }
1138
- const storedObj = isRecord$1(stored) ? stored : {};
1138
+ const storedObj = isRecord$3(stored) ? stored : {};
1139
1139
  return {
1140
1140
  kind: "value",
1141
1141
  value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
@@ -1258,7 +1258,7 @@ async function resolveSecretMarkers(value, secrets, options = {}) {
1258
1258
  value: items
1259
1259
  };
1260
1260
  }
1261
- if (isRecord$1(v)) {
1261
+ if (isRecord$3(v)) {
1262
1262
  const out = {};
1263
1263
  for (const [k, child] of Object.entries(v)) {
1264
1264
  const s = substitute(child);
@@ -1292,7 +1292,7 @@ var SecretOverwriteRefusedError = class extends Error {
1292
1292
  this.name = "SecretOverwriteRefusedError";
1293
1293
  }
1294
1294
  };
1295
- function isRecord(value) {
1295
+ function isRecord$2(value) {
1296
1296
  return typeof value === "object" && value !== null && !Array.isArray(value);
1297
1297
  }
1298
1298
  function resolvedValue(pass, marker) {
@@ -1321,7 +1321,7 @@ function inArray(pass, incoming, stored) {
1321
1321
  return incoming.map((item, index) => {
1322
1322
  const twin = stored[index];
1323
1323
  if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
1324
- if (isRecord(item) && isRecord(twin)) return inArrayRow(pass, item, twin);
1324
+ if (isRecord$2(item) && isRecord$2(twin)) return inArrayRow(pass, item, twin);
1325
1325
  if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
1326
1326
  return item;
1327
1327
  });
@@ -1332,7 +1332,7 @@ function inArrayRow(pass, incoming, stored) {
1332
1332
  const twin = stored[key];
1333
1333
  if (isSecretMarker(twin)) {
1334
1334
  if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
1335
- } else if (isRecord(value) && isRecord(twin)) out[key] = inArrayRow(pass, value, twin);
1335
+ } else if (isRecord$2(value) && isRecord$2(twin)) out[key] = inArrayRow(pass, value, twin);
1336
1336
  else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
1337
1337
  }
1338
1338
  return out;
@@ -1340,7 +1340,7 @@ function inArrayRow(pass, incoming, stored) {
1340
1340
  async function walk(pass, incoming, stored) {
1341
1341
  if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
1342
1342
  if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
1343
- if (!isRecord(incoming) || !isRecord(stored)) return incoming;
1343
+ if (!isRecord$2(incoming) || !isRecord$2(stored)) return incoming;
1344
1344
  const out = { ...incoming };
1345
1345
  for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
1346
1346
  return out;
@@ -1371,7 +1371,7 @@ async function restoreUnchangedSecrets(input) {
1371
1371
  function isJsonEqual(a, b) {
1372
1372
  if (Object.is(a, b)) return true;
1373
1373
  if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
1374
- if (isRecord(a) && isRecord(b)) {
1374
+ if (isRecord$2(a) && isRecord$2(b)) {
1375
1375
  const keys = Object.keys(a);
1376
1376
  if (keys.length !== Object.keys(b).length) return false;
1377
1377
  return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
@@ -1395,7 +1395,7 @@ function markerKeysOf(blob, owner) {
1395
1395
  }
1396
1396
  function nodeFromStored(value, owner) {
1397
1397
  if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
1398
- if (!isRecord(value)) return null;
1398
+ if (!isRecord$2(value)) return null;
1399
1399
  const children = /* @__PURE__ */ new Map();
1400
1400
  for (const [key, child] of Object.entries(value)) {
1401
1401
  const node = nodeFromStored(child, owner);
@@ -3122,6 +3122,981 @@ async function resolveSecretViewsIn(args, secrets) {
3122
3122
  return swap(args).value;
3123
3123
  }
3124
3124
  //#endregion
3125
+ //#region src/records/constants.ts
3126
+ /** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
3127
+ /** The files a kind may live in. `history` is device-history's (D850), never records. */
3128
+ var RECORD_DATABASES = ["settings", "events"];
3129
+ /** The classes of a kind: the `@durable` vocabulary, one authority (replaces the annotation). */
3130
+ var RECORD_CLASSES = [
3131
+ "config",
3132
+ "ledger",
3133
+ "audit",
3134
+ "mirror",
3135
+ "ephemeral"
3136
+ ];
3137
+ var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
3138
+ var RECORD_MAX_DATA_BYTES = 1024 * 1024;
3139
+ var RECORD_ID_MAX_LENGTH = 256;
3140
+ var RECORD_BATCH_MAX = 1e3;
3141
+ var RECORD_BATCH_MAX_BYTES = 4 * 1024 * 1024;
3142
+ var RECORD_QUERY_MAX = 1e3;
3143
+ /** Rows one DELETE statement removes before the serving thread yields. */
3144
+ var RECORD_DELETE_BATCH = 5e3;
3145
+ /** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
3146
+ var RECORD_SETTINGS_MAX_ROWS = 5e4;
3147
+ var RECORD_MAX_INDEXES = 8;
3148
+ var RECORD_MAX_INDEX_FIELDS = 4;
3149
+ /** The engine's TTL sweep cadence. */
3150
+ var RECORD_SWEEP_INTERVAL_MS = 10 * 6e4;
3151
+ /** The `Column`-free proof prefix: a ref collection for a kind's secret fields. */
3152
+ var RECORD_SECRET_COLLECTION_PREFIX = "records:";
3153
+ //#endregion
3154
+ //#region src/records/errors.ts
3155
+ /**
3156
+ * The named failures of `ctx.records` (D881).
3157
+ *
3158
+ * A records call crosses a worker thread, a UDS channel and a tRPC router, and
3159
+ * an error class does not survive any of them - only its message does. So
3160
+ * every message STARTS with a stable code, `records/<code>: <detail>`, and
3161
+ * {@link recordsErrorFromMessage} rebuilds the typed class on the caller's side.
3162
+ * A failed read is never `[]` or `undefined`: it throws one of these.
3163
+ */
3164
+ /** Every code a records failure carries. */
3165
+ var RECORDS_ERROR_CODES = [
3166
+ "rev-conflict",
3167
+ "too-large",
3168
+ "unindexed-filter",
3169
+ "filter-required",
3170
+ "unknown-kind",
3171
+ "not-found",
3172
+ "unique-violation",
3173
+ "plaintext-secret",
3174
+ "foreign-marker",
3175
+ "secret-unavailable",
3176
+ "invalid-record",
3177
+ "declaration-refused",
3178
+ "adoption-pending",
3179
+ "no-caller",
3180
+ "batch-too-large"
3181
+ ];
3182
+ var PREFIX = "records/";
3183
+ /** The base of every records failure. `detail` is the human part of the message. */
3184
+ var RecordsError = class extends Error {
3185
+ code;
3186
+ detail;
3187
+ constructor(code, detail) {
3188
+ super(`${PREFIX}${code}: ${detail}`);
3189
+ this.name = "RecordsError";
3190
+ this.code = code;
3191
+ this.detail = detail;
3192
+ }
3193
+ };
3194
+ /** A write guarded by `ifRev` found another revision (or an existing row for `ifRev: 0`). */
3195
+ var RevConflictError = class extends RecordsError {
3196
+ constructor(detail) {
3197
+ super("rev-conflict", detail);
3198
+ this.name = "RevConflictError";
3199
+ }
3200
+ };
3201
+ /** `data` exceeds the kind's `maxDataBytes`. Bytes are never record fields (D613). */
3202
+ var RecordTooLargeError = class extends RecordsError {
3203
+ constructor(detail) {
3204
+ super("too-large", detail);
3205
+ this.name = "RecordTooLargeError";
3206
+ }
3207
+ };
3208
+ /** A filter, order or aggregate names a field no declared index serves. */
3209
+ var UnindexedFilterError = class extends RecordsError {
3210
+ constructor(detail) {
3211
+ super("unindexed-filter", detail);
3212
+ this.name = "UnindexedFilterError";
3213
+ }
3214
+ };
3215
+ /** A bulk delete with no predicate at all. */
3216
+ var FilterRequiredError = class extends RecordsError {
3217
+ constructor(detail) {
3218
+ super("filter-required", detail);
3219
+ this.name = "FilterRequiredError";
3220
+ }
3221
+ };
3222
+ /** The caller declared no such kind (another addon's kind is indistinguishable from none). */
3223
+ var UnknownRecordKindError = class extends RecordsError {
3224
+ constructor(detail) {
3225
+ super("unknown-kind", detail);
3226
+ this.name = "UnknownRecordKindError";
3227
+ }
3228
+ };
3229
+ var RecordNotFoundError = class extends RecordsError {
3230
+ constructor(detail) {
3231
+ super("not-found", detail);
3232
+ this.name = "RecordNotFoundError";
3233
+ }
3234
+ };
3235
+ /** A unique index refused the write. */
3236
+ var RecordUniqueViolationError = class extends RecordsError {
3237
+ constructor(detail) {
3238
+ super("unique-violation", detail);
3239
+ this.name = "RecordUniqueViolationError";
3240
+ }
3241
+ };
3242
+ /** A secret field held a plain string where only a keychain marker may be stored. */
3243
+ var PlaintextSecretError = class extends RecordsError {
3244
+ constructor(detail) {
3245
+ super("plaintext-secret", detail);
3246
+ this.name = "PlaintextSecretError";
3247
+ }
3248
+ };
3249
+ /** A marker whose ref is not the row's own (the D878 rule). */
3250
+ var ForeignSecretMarkerError = class extends RecordsError {
3251
+ constructor(detail) {
3252
+ super("foreign-marker", detail);
3253
+ this.name = "ForeignSecretMarkerError";
3254
+ }
3255
+ };
3256
+ /** The keychain could not store or serve a value: explicit, never an empty string. */
3257
+ var RecordSecretUnavailableError = class extends RecordsError {
3258
+ constructor(detail) {
3259
+ super("secret-unavailable", detail);
3260
+ this.name = "RecordSecretUnavailableError";
3261
+ }
3262
+ };
3263
+ var InvalidRecordError = class extends RecordsError {
3264
+ constructor(detail) {
3265
+ super("invalid-record", detail);
3266
+ this.name = "InvalidRecordError";
3267
+ }
3268
+ };
3269
+ /** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
3270
+ var DeclarationRefusedError = class extends RecordsError {
3271
+ constructor(detail) {
3272
+ super("declaration-refused", detail);
3273
+ this.name = "DeclarationRefusedError";
3274
+ }
3275
+ };
3276
+ /** A kind is empty while the legacy table it adopts from still holds rows. */
3277
+ var AdoptionPendingError = class extends RecordsError {
3278
+ constructor(detail) {
3279
+ super("adoption-pending", detail);
3280
+ this.name = "AdoptionPendingError";
3281
+ }
3282
+ };
3283
+ var NoCallerError = class extends RecordsError {
3284
+ constructor(detail) {
3285
+ super("no-caller", detail);
3286
+ this.name = "NoCallerError";
3287
+ }
3288
+ };
3289
+ var BatchTooLargeError = class extends RecordsError {
3290
+ constructor(detail) {
3291
+ super("batch-too-large", detail);
3292
+ this.name = "BatchTooLargeError";
3293
+ }
3294
+ };
3295
+ var FACTORIES = {
3296
+ "rev-conflict": (d) => new RevConflictError(d),
3297
+ "too-large": (d) => new RecordTooLargeError(d),
3298
+ "unindexed-filter": (d) => new UnindexedFilterError(d),
3299
+ "filter-required": (d) => new FilterRequiredError(d),
3300
+ "unknown-kind": (d) => new UnknownRecordKindError(d),
3301
+ "not-found": (d) => new RecordNotFoundError(d),
3302
+ "unique-violation": (d) => new RecordUniqueViolationError(d),
3303
+ "plaintext-secret": (d) => new PlaintextSecretError(d),
3304
+ "foreign-marker": (d) => new ForeignSecretMarkerError(d),
3305
+ "secret-unavailable": (d) => new RecordSecretUnavailableError(d),
3306
+ "invalid-record": (d) => new InvalidRecordError(d),
3307
+ "declaration-refused": (d) => new DeclarationRefusedError(d),
3308
+ "adoption-pending": (d) => new AdoptionPendingError(d),
3309
+ "no-caller": (d) => new NoCallerError(d),
3310
+ "batch-too-large": (d) => new BatchTooLargeError(d)
3311
+ };
3312
+ function isCode(value) {
3313
+ return RECORDS_ERROR_CODES.some((code) => code === value);
3314
+ }
3315
+ /**
3316
+ * Rebuild the typed error from a message that crossed a wire; `null` when the
3317
+ * message is not a records failure.
3318
+ */
3319
+ function recordsErrorFromMessage(message) {
3320
+ if (!message.startsWith(PREFIX)) return null;
3321
+ const colon = message.indexOf(": ");
3322
+ if (colon < 0) return null;
3323
+ const code = message.slice(8, colon);
3324
+ if (!isCode(code)) return null;
3325
+ return FACTORIES[code](message.slice(colon + 2));
3326
+ }
3327
+ /** The records failure inside any thrown value (a wrapped tRPC error included), or the value. */
3328
+ function asRecordsError(err) {
3329
+ if (err instanceof RecordsError) return err;
3330
+ if (err instanceof Error) {
3331
+ const typed = recordsErrorFromMessage(err.message);
3332
+ if (typed !== null) return typed;
3333
+ }
3334
+ return err;
3335
+ }
3336
+ //#endregion
3337
+ //#region src/device/zod-secret.ts
3338
+ /**
3339
+ * Secret declaration on a Zod config schema (D783).
3340
+ *
3341
+ * A field is a secret because its schema SAYS so — `.meta({ secret: true })`,
3342
+ * spelled {@link SECRET_META} — never because its key looks like a credential.
3343
+ * It is the Zod twin of `secret: true` / `type: 'password'` on a config-UI
3344
+ * field (`isSecretConfigField`), and every consumer that treats secrets
3345
+ * specially reads it: the settings form (`zodEntriesToConfigUI`), the paths a
3346
+ * device advertises at `registerDevice` (`secretConfigPaths`, which the
3347
+ * non-admin redaction withholds at any depth), and the keychain later.
3348
+ *
3349
+ * Zod keeps `.meta()` in `z.globalRegistry`, which lives on `globalThis`, so a
3350
+ * declaration made by an addon's own copy of zod is visible here.
3351
+ */
3352
+ /**
3353
+ * `{ secret: true }` — the one spelling of "this field holds a credential".
3354
+ *
3355
+ * Addons write the LITERAL `.meta({ secret: true })` rather than importing
3356
+ * this constant: an addon running against an older `@camstack/types` would
3357
+ * otherwise call `.meta(undefined)`, which in zod v4 is the metadata GETTER
3358
+ * and returns no schema at all.
3359
+ */
3360
+ var SECRET_META = { secret: true };
3361
+ function defOf(schema) {
3362
+ return schema._zod?.def ?? {};
3363
+ }
3364
+ function declaredHere(schema) {
3365
+ return z.globalRegistry.get(schema)?.secret === true;
3366
+ }
3367
+ /** Wrapper kinds whose `innerType` is the field itself. */
3368
+ var WRAPPERS = new Set([
3369
+ "optional",
3370
+ "nullable",
3371
+ "default",
3372
+ "prefault",
3373
+ "catch",
3374
+ "readonly",
3375
+ "nonoptional"
3376
+ ]);
3377
+ /**
3378
+ * The schema layers that make up ONE field: the schema itself and every
3379
+ * wrapper below it (optional / default / nullable / readonly / catch), plus
3380
+ * both sides of a pipe (`z.preprocess` puts the real schema on `out`,
3381
+ * `.transform` on `in`).
3382
+ */
3383
+ function layersOf(schema) {
3384
+ const out = [];
3385
+ const queue = [schema];
3386
+ while (queue.length > 0) {
3387
+ const s = queue.shift();
3388
+ if (!s || out.includes(s)) continue;
3389
+ out.push(s);
3390
+ const def = defOf(s);
3391
+ if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
3392
+ if (def.type === "pipe") {
3393
+ if (def.in) queue.push(def.in);
3394
+ if (def.out) queue.push(def.out);
3395
+ }
3396
+ }
3397
+ return out;
3398
+ }
3399
+ /** True when any layer of this field declares `.meta({ secret: true })`. */
3400
+ function isZodSecret(schema) {
3401
+ return layersOf(schema).some(declaredHere);
3402
+ }
3403
+ /**
3404
+ * Every declared secret path in a config schema: dotted keys, `[]` for "each
3405
+ * element of this array" (`connection.password`, `rows[].token`). A declared
3406
+ * object or array is reported as one path and not descended into — everything
3407
+ * under it is secret.
3408
+ */
3409
+ function collectZodSecretPaths(schema, prefix = "") {
3410
+ if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
3411
+ const paths = [];
3412
+ for (const layer of layersOf(schema)) {
3413
+ const def = defOf(layer);
3414
+ if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
3415
+ else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
3416
+ else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
3417
+ else if (def.type === "intersection") {
3418
+ if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
3419
+ if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
3420
+ }
3421
+ }
3422
+ return [...new Set(paths)];
3423
+ }
3424
+ //#endregion
3425
+ //#region src/records/secret-paths.ts
3426
+ /**
3427
+ * Secret fields of a record, addressed the way a Zod schema declares them
3428
+ * (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
3429
+ * (`auth.accessToken`, `headers[].value`).
3430
+ *
3431
+ * Array elements are matched by a DECLARED id key (`secretArrayKeys`:
3432
+ * `{ headers: 'name' }`), never by index, so reordering a list keeps every
3433
+ * keychain ref (the same rule as `arrayItemFieldPath`). The concrete path of a
3434
+ * leaf names its element: `headers[X-Api].value`.
3435
+ *
3436
+ * Pure and browser-safe. Nothing here mutates: every transform returns a new value.
3437
+ */
3438
+ /** The array prefixes (declared form, e.g. `headers` or `a.headers`) of a path. */
3439
+ function parseSecretPath(path) {
3440
+ if (path.length === 0) throw new InvalidRecordError("an empty secret path");
3441
+ return path.split(".").map((raw) => {
3442
+ const each = raw.endsWith("[]");
3443
+ const key = each ? raw.slice(0, -2) : raw;
3444
+ if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
3445
+ return {
3446
+ key,
3447
+ each
3448
+ };
3449
+ });
3450
+ }
3451
+ /** The declared array prefixes of `path` that need an id key (`headers`, `a.rows`). */
3452
+ function secretArrayPrefixes(path) {
3453
+ const segments = parseSecretPath(path);
3454
+ const prefixes = [];
3455
+ const walked = [];
3456
+ for (const segment of segments) {
3457
+ walked.push(segment.key);
3458
+ if (segment.each) prefixes.push(walked.join("."));
3459
+ }
3460
+ return prefixes;
3461
+ }
3462
+ function isRecord$1(value) {
3463
+ return typeof value === "object" && value !== null && !Array.isArray(value);
3464
+ }
3465
+ function elementId(element, idKey, declared, prefix) {
3466
+ const id = isRecord$1(element) ? element[idKey] : void 0;
3467
+ if (typeof id !== "string" || id.length === 0) throw new InvalidRecordError(`"${declared}": every element of "${prefix}" needs a non-empty string "${idKey}" to carry a secret`);
3468
+ return id;
3469
+ }
3470
+ /**
3471
+ * Visit every secret leaf PRESENT in `data` (an absent branch has nothing to
3472
+ * visit). `replace` returns the new leaf value, or {@link REMOVE_LEAF}; the
3473
+ * result is a new body, `data` is untouched.
3474
+ */
3475
+ var REMOVE_LEAF = Symbol("remove-leaf");
3476
+ function mapAt(node, segments, index, walkedKeys, concretePrefix, declared, arrayKeys, visit) {
3477
+ if (!isRecord$1(node)) return node;
3478
+ const segment = segments[index];
3479
+ if (segment === void 0) return node;
3480
+ if (!Object.prototype.hasOwnProperty.call(node, segment.key)) return node;
3481
+ const child = node[segment.key];
3482
+ const keys = [...walkedKeys, segment.key];
3483
+ const last = index === segments.length - 1;
3484
+ if (segment.each) {
3485
+ if (!Array.isArray(child)) return node;
3486
+ const prefix = keys.join(".");
3487
+ const idKey = arrayKeys[prefix];
3488
+ if (idKey === void 0) throw new InvalidRecordError(`"${declared}": no id key declared for the array "${prefix}"`);
3489
+ const mapped = child.map((element) => {
3490
+ const id = elementId(element, idKey, declared, prefix);
3491
+ const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}[${encodeURIComponent(id)}]`;
3492
+ return last ? element : mapAt(element, segments, index + 1, keys, concrete, declared, arrayKeys, visit);
3493
+ });
3494
+ return {
3495
+ ...node,
3496
+ [segment.key]: mapped
3497
+ };
3498
+ }
3499
+ const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}`;
3500
+ if (last) {
3501
+ const replacement = visit({
3502
+ declared,
3503
+ concrete,
3504
+ value: child
3505
+ });
3506
+ if (replacement === REMOVE_LEAF) return Object.fromEntries(Object.entries(node).filter(([key]) => key !== segment.key));
3507
+ return {
3508
+ ...node,
3509
+ [segment.key]: replacement
3510
+ };
3511
+ }
3512
+ return {
3513
+ ...node,
3514
+ [segment.key]: mapAt(child, segments, index + 1, keys, concrete, declared, arrayKeys, visit)
3515
+ };
3516
+ }
3517
+ /** Replace/remove every present secret leaf; returns a NEW body. */
3518
+ function mapSecretLeaves(data, paths, arrayKeys, visit) {
3519
+ let current = data;
3520
+ for (const declared of paths) current = mapAt(current, parseSecretPath(declared), 0, [], "", declared, arrayKeys, visit);
3521
+ return current;
3522
+ }
3523
+ /** Every present secret leaf, read-only. */
3524
+ function collectSecretLeaves(data, paths, arrayKeys) {
3525
+ const found = [];
3526
+ mapSecretLeaves(data, paths, arrayKeys, (leaf) => {
3527
+ found.push(leaf);
3528
+ return leaf.value;
3529
+ });
3530
+ return found;
3531
+ }
3532
+ /**
3533
+ * The keychain collection name a kind's secrets live under. Prefixed so a
3534
+ * record's refs never collide with the refs a legacy collection of the same name
3535
+ * already holds during an adoption.
3536
+ */
3537
+ function recordSecretCollection(kind) {
3538
+ return `${RECORD_SECRET_COLLECTION_PREFIX}${kind}`;
3539
+ }
3540
+ /** The ONE ref a row's secret field may carry: the engine and the facade both build it here. */
3541
+ function recordSecretRef(owner, kind, rowId, concretePath) {
3542
+ return buildSecretRef({
3543
+ owner,
3544
+ scope: {
3545
+ kind: "row",
3546
+ collection: recordSecretCollection(kind),
3547
+ rowId
3548
+ },
3549
+ fieldPath: concretePath
3550
+ });
3551
+ }
3552
+ /** A concrete path built from a flat array item, re-exported for adoption tooling. */
3553
+ var recordArrayItemPath = arrayItemFieldPath;
3554
+ //#endregion
3555
+ //#region src/records/record-kind.ts
3556
+ /**
3557
+ * Record kinds (D881): the declaration an addon makes of one kind of fact, the
3558
+ * Zod row schema that describes it, and the helper that turns the two into the
3559
+ * JSON the engine stores.
3560
+ *
3561
+ * A kind is declared ONCE, next to the code that owns it, and the engine's
3562
+ * reconciler creates its indexes - nothing creates DDL at runtime from a write.
3563
+ * Everything the generic machinery needs (secret fields, the entry descriptor)
3564
+ * is DERIVED from the Zod schema: `.meta({ secret: true })` marks a credential,
3565
+ * never a field name (D879).
3566
+ */
3567
+ /** A JSON field path: `trackId`, `auth.accessToken`. Charset-restricted: it is rendered into DDL. */
3568
+ var RecordFieldPathSchema = z.string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,63}(\.[A-Za-z_][A-Za-z0-9_]{0,63}){0,3}$/);
3569
+ var RecordIndexSchema = z.object({
3570
+ name: z.string().regex(/^[a-z][a-z0-9_]{0,31}$/),
3571
+ fields: z.array(RecordFieldPathSchema).min(1).max(4),
3572
+ unique: z.boolean().optional()
3573
+ }).strict();
3574
+ var RecordRetentionSchema = z.union([
3575
+ z.object({
3576
+ ttlMs: z.number().int().positive(),
3577
+ from: z.enum(["at", "write"])
3578
+ }).strict(),
3579
+ z.object({
3580
+ maxRows: z.number().int().positive().optional(),
3581
+ maxRowsPerDevice: z.number().int().positive().optional()
3582
+ }).strict().refine((r) => r.maxRows !== void 0 || r.maxRowsPerDevice !== void 0, { message: "name maxRows, maxRowsPerDevice or both" }),
3583
+ z.object({
3584
+ owner: z.string().min(1),
3585
+ reason: z.string().min(1)
3586
+ }).strict(),
3587
+ z.object({ none: z.string().min(1) }).strict()
3588
+ ]);
3589
+ /** The descriptor a generic entries UI reads (D881 "generic entries"). */
3590
+ var EntryDescriptorSchema = z.object({
3591
+ title: z.string().min(1),
3592
+ /** The record body field shown as the entry's name. */
3593
+ nameField: z.string().min(1),
3594
+ /** JSON Schema of the entry body; `secret: true` marks a password field. */
3595
+ fields: z.record(z.string(), z.unknown())
3596
+ }).strict();
3597
+ /** What crosses the wire and sits in the engine's catalog: JSON only, no Zod. */
3598
+ var RecordKindDeclarationSchema = z.object({
3599
+ database: z.enum(RECORD_DATABASES).default("settings"),
3600
+ class: z.enum(RECORD_CLASSES),
3601
+ writeTrigger: z.string().min(1),
3602
+ device: z.enum([
3603
+ "required",
3604
+ "optional",
3605
+ "none"
3606
+ ]).default("none"),
3607
+ at: z.enum(["required", "none"]).default("none"),
3608
+ indexes: z.array(RecordIndexSchema).max(8).default([]),
3609
+ retention: RecordRetentionSchema,
3610
+ deviceRemoval: z.enum(["delete", "none"]).default("none"),
3611
+ maxDataBytes: z.number().int().positive().max(RECORD_MAX_DATA_BYTES).default(RECORD_DEFAULT_MAX_DATA_BYTES),
3612
+ /** Derived from the Zod schema; never written by hand. */
3613
+ secretPaths: z.array(z.string().min(1)).default([]),
3614
+ /** The id key of each array that carries a secret (`{ headers: 'name' }`). */
3615
+ secretArrayKeys: z.record(z.string(), z.string()).default({}),
3616
+ /** The legacy table this kind adopts from; the boot guard reads it (D853: no migration code). */
3617
+ adoptsFrom: z.string().min(1).optional(),
3618
+ /** Kinds that must agree through `transact` sit in one file under one family name. */
3619
+ transactFamily: z.string().min(1).optional(),
3620
+ entry: EntryDescriptorSchema.optional()
3621
+ }).strict();
3622
+ /** The kind names: lower-case, dash separated, short enough for an index name. */
3623
+ var RecordKindNameSchema = z.string().regex(/^[a-z][a-z0-9-]{0,47}$/);
3624
+ /** Cross-field rules a declaration must satisfy. Throws {@link DeclarationRefusedError}. */
3625
+ function assertValidDeclaration(name, decl) {
3626
+ const refuse = (why) => {
3627
+ throw new DeclarationRefusedError(`kind "${name}": ${why}`);
3628
+ };
3629
+ if (!RecordKindNameSchema.safeParse(name).success) refuse("the name must be lower-case-dashed");
3630
+ const seen = /* @__PURE__ */ new Set();
3631
+ for (const index of decl.indexes) {
3632
+ if (seen.has(index.name)) refuse(`index name "${index.name}" is declared twice`);
3633
+ seen.add(index.name);
3634
+ }
3635
+ const { retention } = decl;
3636
+ const hasSecrets = decl.secretPaths.length > 0;
3637
+ if ("ttlMs" in retention) {
3638
+ if (retention.from === "at" && decl.at !== "required") refuse("a ttl from \"at\" needs at: \"required\"");
3639
+ if (hasSecrets) refuse("a kind with secret fields cannot use engine TTL (its keychain values would be orphaned)");
3640
+ }
3641
+ if ("maxRows" in retention || "maxRowsPerDevice" in retention) {
3642
+ if (retention.maxRowsPerDevice !== void 0 && decl.device !== "required") refuse("maxRowsPerDevice needs device: \"required\"");
3643
+ if (decl.at !== "required") refuse("a row bound trims the oldest \"at\": it needs at: \"required\"");
3644
+ if (hasSecrets) refuse("a kind with secret fields cannot use an engine row bound");
3645
+ const bound = Math.max(retention.maxRows ?? 0, retention.maxRowsPerDevice ?? 0);
3646
+ 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)`);
3647
+ }
3648
+ if (decl.deviceRemoval === "delete" && decl.device === "none") refuse("deviceRemoval: \"delete\" needs a device: \"required\" or \"optional\"");
3649
+ 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`);
3650
+ }
3651
+ function bodyFieldsOf(schema) {
3652
+ return { ...z.toJSONSchema(schema, {
3653
+ unrepresentable: "any",
3654
+ io: "input"
3655
+ }) };
3656
+ }
3657
+ function isRecordLike(value) {
3658
+ return typeof value === "object" && value !== null && !Array.isArray(value);
3659
+ }
3660
+ /** Does every branch of the body schema carry `field`? (A discriminated union has several.) */
3661
+ function hasNameField(json, field) {
3662
+ const branches = json["oneOf"] ?? json["anyOf"];
3663
+ if (Array.isArray(branches)) return branches.length > 0 && branches.every((b) => isRecordLike(b) && hasNameField(b, field));
3664
+ const properties = json["properties"];
3665
+ return isRecordLike(properties) && Object.prototype.hasOwnProperty.call(properties, field);
3666
+ }
3667
+ /**
3668
+ * Declare the kinds of a package. The keys are the kind names. The result is
3669
+ * what `ctx.records.declare` sends to the engine and what `ctx.records.kind`
3670
+ * types its handle from.
3671
+ */
3672
+ function defineRecordKinds(specs) {
3673
+ const out = {};
3674
+ for (const [name, spec] of Object.entries(specs)) {
3675
+ const secretPaths = collectZodSecretPaths(spec.schema);
3676
+ const nameField = spec.entry?.nameField ?? "name";
3677
+ const fields = bodyFieldsOf(spec.schema);
3678
+ if (spec.entry !== void 0 && !hasNameField(fields, nameField)) throw new DeclarationRefusedError(`kind "${name}": an entry kind's schema needs a "${nameField}" field`);
3679
+ const parsed = RecordKindDeclarationSchema.parse({
3680
+ database: spec.database,
3681
+ class: spec.class,
3682
+ writeTrigger: spec.writeTrigger,
3683
+ device: spec.device,
3684
+ at: spec.at,
3685
+ indexes: spec.indexes === void 0 ? void 0 : [...spec.indexes],
3686
+ retention: spec.retention,
3687
+ deviceRemoval: spec.deviceRemoval,
3688
+ maxDataBytes: spec.maxDataBytes,
3689
+ secretPaths: [...secretPaths],
3690
+ secretArrayKeys: spec.secretArrayKeys === void 0 ? void 0 : { ...spec.secretArrayKeys },
3691
+ adoptsFrom: spec.adoptsFrom,
3692
+ transactFamily: spec.transactFamily,
3693
+ entry: spec.entry === void 0 ? void 0 : {
3694
+ title: spec.entry.title,
3695
+ nameField,
3696
+ fields
3697
+ }
3698
+ });
3699
+ assertValidDeclaration(name, parsed);
3700
+ out[name] = {
3701
+ name,
3702
+ schema: spec.schema,
3703
+ declaration: parsed
3704
+ };
3705
+ }
3706
+ return out;
3707
+ }
3708
+ /** The wire form of a package's kinds: name -> declaration. */
3709
+ function declarationsOf(kinds) {
3710
+ return Object.fromEntries(Object.entries(kinds).map(([name, kind]) => [name, kind.declaration]));
3711
+ }
3712
+ //#endregion
3713
+ //#region src/records/records-access.ts
3714
+ function isRecord(value) {
3715
+ return typeof value === "object" && value !== null && !Array.isArray(value);
3716
+ }
3717
+ /** Run a transport call and give a wire failure its typed class back. */
3718
+ async function call(fn) {
3719
+ try {
3720
+ return await fn();
3721
+ } catch (err) {
3722
+ throw asRecordsError(err);
3723
+ }
3724
+ }
3725
+ function zodSummary(error) {
3726
+ return error.issues.slice(0, 5).map((issue) => `${issue.path.join(".") || "(root)"}: ${issue.message}`).join("; ");
3727
+ }
3728
+ function toRow(view, data) {
3729
+ return {
3730
+ id: view.id,
3731
+ deviceId: view.deviceId,
3732
+ at: view.at,
3733
+ expiresAt: view.expiresAt,
3734
+ rev: view.rev,
3735
+ updatedAt: view.updatedAt,
3736
+ data
3737
+ };
3738
+ }
3739
+ var KindHandle = class {
3740
+ def;
3741
+ o;
3742
+ name;
3743
+ decl;
3744
+ constructor(def, o) {
3745
+ this.def = def;
3746
+ this.o = o;
3747
+ this.name = def.name;
3748
+ this.decl = def.declaration;
3749
+ }
3750
+ get hasSecrets() {
3751
+ return this.decl.secretPaths.length > 0;
3752
+ }
3753
+ requireSecrets() {
3754
+ if (this.o.secrets === null) throw new RecordSecretUnavailableError(`kind "${this.name}" has secret fields and this process has no keychain door`);
3755
+ return this.o.secrets;
3756
+ }
3757
+ /** Read the body as the schema's type. The engine already redacted the secrets. */
3758
+ typed(view) {
3759
+ return toRow(view, view.data);
3760
+ }
3761
+ /**
3762
+ * Classify and store the secret leaves of a body about to be written. The
3763
+ * keychain is written FIRST (a failure throws before any row is touched), and
3764
+ * what each ref held before is remembered: when the row write is then refused
3765
+ * (a stale `ifRev`, too large, a unique index) `rollback` puts the previous
3766
+ * values back, so a refused write never destroys the secret that was stored.
3767
+ */
3768
+ async storeSecrets(id, body, mode) {
3769
+ if (!this.hasSecrets) return {
3770
+ body,
3771
+ rollback: async () => {}
3772
+ };
3773
+ const secrets = this.requireSecrets();
3774
+ const writes = [];
3775
+ const prepared = mapSecretLeaves(body, this.decl.secretPaths, this.decl.secretArrayKeys, (leaf) => {
3776
+ const intent = classifySecretWrite(leaf.value);
3777
+ if (intent.kind === "clear") return REMOVE_LEAF;
3778
+ if (intent.kind === "keep") {
3779
+ if (mode === "put") return REDACTED_SECRET;
3780
+ if (leaf.value === null) return null;
3781
+ return leaf.concrete.includes("[") ? REDACTED_SECRET : REMOVE_LEAF;
3782
+ }
3783
+ const ref = recordSecretRef(this.o.owner, this.name, id, leaf.concrete);
3784
+ writes.push({
3785
+ ref,
3786
+ value: intent.value
3787
+ });
3788
+ return makeSecretMarker(ref);
3789
+ });
3790
+ const done = [];
3791
+ const rollback = async () => {
3792
+ for (const { ref, previous } of done) try {
3793
+ if (previous === void 0) await secrets.delete([ref]);
3794
+ else await secrets.put(ref, previous);
3795
+ } catch (err) {
3796
+ this.o.logger?.warn("records: could not restore a keychain value after a refused write", { meta: {
3797
+ kind: this.name,
3798
+ error: err instanceof Error ? err.message : "unknown"
3799
+ } });
3800
+ }
3801
+ };
3802
+ for (const write of writes) try {
3803
+ const before = (await secrets.resolve([write.ref]))[write.ref];
3804
+ const previous = before?.kind === "value" ? before.value : void 0;
3805
+ await secrets.put(write.ref, write.value);
3806
+ done.push({
3807
+ ref: write.ref,
3808
+ previous
3809
+ });
3810
+ } catch (err) {
3811
+ await rollback();
3812
+ throw new RecordSecretUnavailableError(`cannot store a secret of ${this.name}/${id}: ${err instanceof Error ? err.message : "the keychain refused"}. Unlock the keychain (System -> Secrets) and save again`);
3813
+ }
3814
+ return {
3815
+ body: prepared,
3816
+ rollback
3817
+ };
3818
+ }
3819
+ async releaseRefs(refs) {
3820
+ if (refs.length === 0 || this.o.secrets === null) return;
3821
+ try {
3822
+ await this.o.secrets.delete(refs);
3823
+ } catch (err) {
3824
+ this.o.logger?.warn("records: could not remove released keychain values", { meta: {
3825
+ kind: this.name,
3826
+ count: refs.length,
3827
+ error: err instanceof Error ? err.message : "unknown"
3828
+ } });
3829
+ }
3830
+ }
3831
+ validate(data, id) {
3832
+ const shaped = this.hasSecrets ? mapSecretLeaves(data, this.decl.secretPaths, this.decl.secretArrayKeys, (leaf) => {
3833
+ const intent = classifySecretWrite(leaf.value);
3834
+ if (intent.kind === "clear") return REMOVE_LEAF;
3835
+ return intent.kind === "keep" ? REDACTED_SECRET : leaf.value;
3836
+ }) : data;
3837
+ const parsed = this.def.schema.safeParse(shaped);
3838
+ if (!parsed.success) throw new InvalidRecordError(`${this.name}/${id}: ${zodSummary(parsed.error)}`);
3839
+ if (!isRecord(parsed.data)) throw new InvalidRecordError(`${this.name}/${id}: the body must be an object`);
3840
+ return parsed.data;
3841
+ }
3842
+ async get(id) {
3843
+ const view = await call(() => this.o.transport.get({
3844
+ kind: this.name,
3845
+ id
3846
+ }));
3847
+ return view === null ? null : this.typed(view);
3848
+ }
3849
+ async getMany(ids) {
3850
+ if (ids.length === 0) return [];
3851
+ return (await call(() => this.o.transport.getMany({
3852
+ kind: this.name,
3853
+ ids: [...ids]
3854
+ }))).map((v) => this.typed(v));
3855
+ }
3856
+ async getResolved(id) {
3857
+ const row = await this.get(id);
3858
+ if (row === null) return null;
3859
+ return (await this.resolveRows([row]))[0] ?? row;
3860
+ }
3861
+ async resolveRows(rows) {
3862
+ if (!this.hasSecrets || rows.length === 0) return rows;
3863
+ const secrets = this.requireSecrets();
3864
+ const refsById = await call(() => this.o.transport.secretRefs({
3865
+ kind: this.name,
3866
+ ids: rows.map((r) => r.id)
3867
+ }));
3868
+ const refs = Object.values(refsById).flatMap((byPath) => Object.values(byPath));
3869
+ if (refs.length === 0) return rows;
3870
+ const answers = await secrets.resolve(refs);
3871
+ return rows.map((row) => {
3872
+ const byPath = refsById[row.id] ?? {};
3873
+ const resolved = mapSecretLeaves(row.data, this.decl.secretPaths, this.decl.secretArrayKeys, (leaf) => {
3874
+ const ref = byPath[leaf.concrete];
3875
+ if (ref === void 0) return leaf.value;
3876
+ const answer = answers[ref];
3877
+ if (answer?.kind === "value") return answer.value;
3878
+ const why = answer?.kind === "unavailable" ? answer.reason : answer?.kind ?? "no answer";
3879
+ throw new RecordSecretUnavailableError(`the secret "${leaf.concrete}" of ${this.name}/${row.id} cannot be served (${why})`);
3880
+ });
3881
+ return {
3882
+ ...row,
3883
+ data: resolved
3884
+ };
3885
+ });
3886
+ }
3887
+ async put(input, opts = {}) {
3888
+ const checked = this.validate(input.data, input.id);
3889
+ const { body, rollback } = await this.storeSecrets(input.id, checked, "put");
3890
+ const result = await call(() => this.o.transport.put({
3891
+ kind: this.name,
3892
+ record: {
3893
+ ...input,
3894
+ data: toBody(body)
3895
+ },
3896
+ ...opts.ifRev === void 0 ? {} : { ifRev: opts.ifRev }
3897
+ })).catch(async (err) => {
3898
+ await rollback();
3899
+ throw err;
3900
+ });
3901
+ await this.releaseRefs(result.releasedRefs);
3902
+ return { rev: result.rev };
3903
+ }
3904
+ async putMany(inputs) {
3905
+ if (inputs.length === 0) return { count: 0 };
3906
+ const prepared = [];
3907
+ const rollbacks = [];
3908
+ try {
3909
+ for (const input of inputs) {
3910
+ const checked = this.validate(input.data, input.id);
3911
+ const { body, rollback } = await this.storeSecrets(input.id, checked, "put");
3912
+ rollbacks.push(rollback);
3913
+ prepared.push({
3914
+ ...input,
3915
+ data: toBody(body)
3916
+ });
3917
+ }
3918
+ } catch (err) {
3919
+ for (const rollback of rollbacks) await rollback();
3920
+ throw err;
3921
+ }
3922
+ const result = await call(() => this.o.transport.putMany({
3923
+ kind: this.name,
3924
+ records: prepared
3925
+ })).catch(async (err) => {
3926
+ for (const rollback of rollbacks) await rollback();
3927
+ throw err;
3928
+ });
3929
+ await this.releaseRefs(result.releasedRefs);
3930
+ return { count: result.count };
3931
+ }
3932
+ async patch(id, partial, opts = {}) {
3933
+ const { body, rollback } = await this.storeSecrets(id, partial, "patch");
3934
+ const result = await call(() => this.o.transport.patch({
3935
+ kind: this.name,
3936
+ id,
3937
+ data: toBody(body),
3938
+ ...opts.at === void 0 ? {} : { at: opts.at },
3939
+ ...opts.expiresAt === void 0 ? {} : { expiresAt: opts.expiresAt },
3940
+ ...opts.ifRev === void 0 ? {} : { ifRev: opts.ifRev }
3941
+ })).catch(async (err) => {
3942
+ await rollback();
3943
+ throw err;
3944
+ });
3945
+ await this.releaseRefs(result.releasedRefs);
3946
+ return { rev: result.rev };
3947
+ }
3948
+ async delete(id) {
3949
+ const result = await call(() => this.o.transport.delete({
3950
+ kind: this.name,
3951
+ id
3952
+ }));
3953
+ await this.releaseRefs(result.secretRefs);
3954
+ return result.deleted;
3955
+ }
3956
+ async deleteMany(ids) {
3957
+ if (ids.length === 0) return 0;
3958
+ const result = await call(() => this.o.transport.deleteMany({
3959
+ kind: this.name,
3960
+ ids: [...ids]
3961
+ }));
3962
+ await this.releaseRefs(result.secretRefs);
3963
+ return result.deleted;
3964
+ }
3965
+ async query(q, opts = {}) {
3966
+ const result = await call(() => this.o.transport.query({
3967
+ ...q,
3968
+ kind: this.name,
3969
+ limit: q.limit ?? 100
3970
+ }));
3971
+ const rows = result.records.map((v) => this.typed(v));
3972
+ return {
3973
+ records: opts.resolveSecrets === true ? await this.resolveRows(rows) : rows,
3974
+ nextCursor: result.nextCursor
3975
+ };
3976
+ }
3977
+ async count(q) {
3978
+ return (await call(() => this.o.transport.count({
3979
+ ...q,
3980
+ kind: this.name
3981
+ }))).count;
3982
+ }
3983
+ async histogram(q) {
3984
+ return (await call(() => this.o.transport.histogram({
3985
+ ...q,
3986
+ kind: this.name
3987
+ }))).buckets;
3988
+ }
3989
+ async aggregate(q) {
3990
+ return (await call(() => this.o.transport.aggregate({
3991
+ ...q,
3992
+ kind: this.name
3993
+ }))).rows;
3994
+ }
3995
+ async deleteWhere(q) {
3996
+ const result = await call(() => this.o.transport.deleteWhere({
3997
+ ...q,
3998
+ kind: this.name
3999
+ }));
4000
+ await this.releaseRefs(result.secretRefs);
4001
+ return result.deleted;
4002
+ }
4003
+ async allocateId() {
4004
+ return (await call(() => this.o.transport.allocateId({ kind: this.name }))).id;
4005
+ }
4006
+ };
4007
+ function toBody(value) {
4008
+ if (!isRecord(value)) throw new InvalidRecordError("the record body must be an object");
4009
+ return value;
4010
+ }
4011
+ /** Build the owner's records handle. */
4012
+ function createRecordsAccess(options) {
4013
+ const handles = /* @__PURE__ */ new WeakMap();
4014
+ const delegates = /* @__PURE__ */ new Map();
4015
+ return {
4016
+ owner: options.owner,
4017
+ forOwner: options.transportForOwner === void 0 ? null : (other) => {
4018
+ const existing = delegates.get(other);
4019
+ if (existing !== void 0) return existing;
4020
+ const build = options.transportForOwner;
4021
+ if (build === void 0) throw new Error("forOwner: no delegate transport");
4022
+ const delegate = createRecordsAccess({
4023
+ owner: other,
4024
+ transport: build(other),
4025
+ secrets: options.secrets?.forOwner?.(other) ?? null,
4026
+ ...options.logger === void 0 ? {} : { logger: options.logger }
4027
+ });
4028
+ delegates.set(other, delegate);
4029
+ return delegate;
4030
+ },
4031
+ async declare(kinds) {
4032
+ const result = await call(() => options.transport.declareKinds({ kinds: { ...declarationsOf(kinds) } }));
4033
+ const pending = Object.entries(result.kinds).filter((entry) => entry[1].adoptionPending !== null);
4034
+ if (pending.length > 0) throw new AdoptionPendingError(`${pending.map(([name, r]) => r.adoptionPending === null ? name : `${name} (legacy table "${r.adoptionPending.legacyTable}" holds ${r.adoptionPending.legacyRows} rows)`).join(", ")}. Stop the addon and run scripts/hub/records-adopt.ts --copy --apply before starting this build`);
4035
+ return result.kinds;
4036
+ },
4037
+ kind(definition) {
4038
+ const existing = handles.get(definition);
4039
+ if (existing !== void 0) return existing;
4040
+ const handle = new KindHandle(definition, options);
4041
+ handles.set(definition, handle);
4042
+ return handle;
4043
+ },
4044
+ async deleteDevice(deviceId, opts = {}) {
4045
+ const result = await call(() => options.transport.deleteDevice({
4046
+ deviceId,
4047
+ ...opts.kinds === void 0 ? {} : { kinds: [...opts.kinds] }
4048
+ }));
4049
+ if (result.secretRefs.length > 0 && options.secrets !== null) try {
4050
+ await options.secrets.delete(result.secretRefs);
4051
+ } catch (err) {
4052
+ options.logger?.warn("records: could not remove released keychain values", { meta: {
4053
+ count: result.secretRefs.length,
4054
+ error: err instanceof Error ? err.message : "unknown"
4055
+ } });
4056
+ }
4057
+ return result.deleted;
4058
+ }
4059
+ };
4060
+ }
4061
+ //#endregion
4062
+ //#region src/records/entry-kind.ts
4063
+ /**
4064
+ * Entry kinds (D881): every list of user-created entries (notification
4065
+ * targets, brokers, LLM profiles) is ONE record kind with an id, a name and a
4066
+ * kind-specific body, and the admin UI lists/adds/edits/deletes all of them
4067
+ * through the `record-entries` capability with password fields derived from
4068
+ * the schema (`.meta({ secret: true })`).
4069
+ */
4070
+ /** The body of a plain entry: a name and the fields the kind adds. */
4071
+ function entryBody(shape) {
4072
+ return z.object({
4073
+ name: z.string().min(1),
4074
+ ...shape
4075
+ });
4076
+ }
4077
+ /**
4078
+ * Declare one entry kind. An entry is configuration: never trimmed by the
4079
+ * engine, never aged, belonging to no device.
4080
+ */
4081
+ function defineEntryKind(name, spec) {
4082
+ const defined = defineRecordKinds({ [name]: {
4083
+ schema: spec.schema,
4084
+ class: "config",
4085
+ writeTrigger: spec.writeTrigger ?? "an operator adds or edits an entry in the entries UI",
4086
+ retention: { none: "an entry goes only when the operator deletes it" },
4087
+ ...spec.database === void 0 ? {} : { database: spec.database },
4088
+ ...spec.indexes === void 0 ? {} : { indexes: spec.indexes },
4089
+ ...spec.secretArrayKeys === void 0 ? {} : { secretArrayKeys: spec.secretArrayKeys },
4090
+ ...spec.adoptsFrom === void 0 ? {} : { adoptsFrom: spec.adoptsFrom },
4091
+ entry: {
4092
+ title: spec.title,
4093
+ ...spec.nameField === void 0 ? {} : { nameField: spec.nameField }
4094
+ }
4095
+ } })[name];
4096
+ if (defined === void 0) throw new DeclarationRefusedError(`entry kind "${name}" was not built`);
4097
+ return defined;
4098
+ }
4099
+ //#endregion
3125
4100
  //#region src/capabilities/schemas/streaming-shared.ts
3126
4101
  /** Shared Zod schemas used across streaming capabilities. */
3127
4102
  var CamProfileSchema = z.enum([
@@ -4537,94 +5512,6 @@ var RUNTIME_DEFAULTS = {
4537
5512
  "auth.tokenExpiry": "30d"
4538
5513
  };
4539
5514
  //#endregion
4540
- //#region src/device/zod-secret.ts
4541
- /**
4542
- * Secret declaration on a Zod config schema (D783).
4543
- *
4544
- * A field is a secret because its schema SAYS so — `.meta({ secret: true })`,
4545
- * spelled {@link SECRET_META} — never because its key looks like a credential.
4546
- * It is the Zod twin of `secret: true` / `type: 'password'` on a config-UI
4547
- * field (`isSecretConfigField`), and every consumer that treats secrets
4548
- * specially reads it: the settings form (`zodEntriesToConfigUI`), the paths a
4549
- * device advertises at `registerDevice` (`secretConfigPaths`, which the
4550
- * non-admin redaction withholds at any depth), and the keychain later.
4551
- *
4552
- * Zod keeps `.meta()` in `z.globalRegistry`, which lives on `globalThis`, so a
4553
- * declaration made by an addon's own copy of zod is visible here.
4554
- */
4555
- /**
4556
- * `{ secret: true }` — the one spelling of "this field holds a credential".
4557
- *
4558
- * Addons write the LITERAL `.meta({ secret: true })` rather than importing
4559
- * this constant: an addon running against an older `@camstack/types` would
4560
- * otherwise call `.meta(undefined)`, which in zod v4 is the metadata GETTER
4561
- * and returns no schema at all.
4562
- */
4563
- var SECRET_META = { secret: true };
4564
- function defOf(schema) {
4565
- return schema._zod?.def ?? {};
4566
- }
4567
- function declaredHere(schema) {
4568
- return z.globalRegistry.get(schema)?.secret === true;
4569
- }
4570
- /** Wrapper kinds whose `innerType` is the field itself. */
4571
- var WRAPPERS = new Set([
4572
- "optional",
4573
- "nullable",
4574
- "default",
4575
- "prefault",
4576
- "catch",
4577
- "readonly",
4578
- "nonoptional"
4579
- ]);
4580
- /**
4581
- * The schema layers that make up ONE field: the schema itself and every
4582
- * wrapper below it (optional / default / nullable / readonly / catch), plus
4583
- * both sides of a pipe (`z.preprocess` puts the real schema on `out`,
4584
- * `.transform` on `in`).
4585
- */
4586
- function layersOf(schema) {
4587
- const out = [];
4588
- const queue = [schema];
4589
- while (queue.length > 0) {
4590
- const s = queue.shift();
4591
- if (!s || out.includes(s)) continue;
4592
- out.push(s);
4593
- const def = defOf(s);
4594
- if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
4595
- if (def.type === "pipe") {
4596
- if (def.in) queue.push(def.in);
4597
- if (def.out) queue.push(def.out);
4598
- }
4599
- }
4600
- return out;
4601
- }
4602
- /** True when any layer of this field declares `.meta({ secret: true })`. */
4603
- function isZodSecret(schema) {
4604
- return layersOf(schema).some(declaredHere);
4605
- }
4606
- /**
4607
- * Every declared secret path in a config schema: dotted keys, `[]` for "each
4608
- * element of this array" (`connection.password`, `rows[].token`). A declared
4609
- * object or array is reported as one path and not descended into — everything
4610
- * under it is secret.
4611
- */
4612
- function collectZodSecretPaths(schema, prefix = "") {
4613
- if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
4614
- const paths = [];
4615
- for (const layer of layersOf(schema)) {
4616
- const def = defOf(layer);
4617
- if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
4618
- else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
4619
- else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
4620
- else if (def.type === "intersection") {
4621
- if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
4622
- if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
4623
- }
4624
- }
4625
- return [...new Set(paths)];
4626
- }
4627
- //#endregion
4628
5515
  //#region src/device/device-state-handle.ts
4629
5516
  var DEVICE_STATE_EVENT_CATEGORY = "device.state-changed";
4630
5517
  /**
@@ -6187,4 +7074,4 @@ function sleepCancellable(ms, signal) {
6187
7074
  });
6188
7075
  }
6189
7076
  //#endregion
6190
- export { resolveCapMount as $, normalizeAddonInitResult as $t, HF_BASE_URL as A, isSecretFieldView as An, makeSourceBrokerId as At, deviceCustomAction as B, schemaDeclaresAnyField as Bn, registerKnownSecret as Bt, createLazyTrpcSource as C, collectHydratedFieldEntries as Cn, ProfileSlotSchema as Ct, collectZodSecretPaths as D, SECRET_CLEAR as Dn, SubscribeAudioChunksInputSchema as Dt, SECRET_META as E, resolveHydratedFieldValue as En, StreamSourceSchema as Et, viewerUiCapability as F, REDACTED_SECRET as Fn, createSecretsAccess as Ft, HISTORY_DEFAULT_MIN_INTERVAL_MS as G, PEER_BYTES_STALL_MS as Gt, DEFAULT_RUNTIME_STATE_DURABILITY as H, audioChunkBytesPerSample as Hn, shortSecretRefHash as Ht, DEVICE_CHILDREN_BATCH_MAX as I, collectKeychainStoredKeys as In, MIN_SCRUBBED_LENGTH as It, event as J, DATAPLANE_SECRET_HEADER as Jt, HISTORY_UNIT_LABELS as K, PEER_BYTES_TICKET_TTL_MS as Kt, customAction as L, collectSecretConfigKeys as Ln, clearKnownSecrets as Lt, RUNTIME_DEFAULTS as M, isSecretMarkerLike as Mn, selectAssignedProfileSlots as Mt, RawStateResultSchema as N, makeSecretMarker as Nn, resolveSecretViewsIn as Nt, isZodSecret as O, classifySecretWrite as On, SubscribeAudioChunksResultSchema as Ot, deviceOpsCapability as P, toSecretFieldView as Pn, REVALIDATE_AFTER_MS as Pt, optionalMethod as Q, classifyStoreError as Qt, defineCustomActions as R, isKeychainStoredField as Rn, forgetKnownSecret as Rt, createEventBusSliceSource as S, WELL_KNOWN_TAB_MAP as Sn, ProfileRtspEntrySchema as St, createSliceHandle as T, hydrateSchema as Tn, StreamSourceEntrySchema$1 as Tt, DEVICE_SETTINGS_CONTRIBUTION_METHODS as U, expandAudioChunkToF32le as Un, PEER_BYTES_CHUNK_BYTES as Ut, adminUiCapability as V, AUDIO_CHUNK_FORMATS as Vn, scrubKnownSecrets as Vt, DEVICE_STATUS_METHOD as W, isAudioChunkFormat as Wn, PEER_BYTES_MAX_OUTSTANDING as Wt, isDeviceConfigCap as X, DisposerChain as Xt, expandCapMethods as Y, SHARE_VIEW_KINDS as Yt, method as Z, BaseAddon as Zt, readErrorI18n as _, createDurableState as _n, CamStreamKindSchema as _t, asJsonArray as a, collectSecretMarkerRefs as an, MODEL_FORMATS as at, isDeviceScopedCap as b, isEvent as bn, DecodedAudioChunkSchema as bt, asString as c, SECRET_REF_SCHEME as cn, emitDownForOwnedCaps as ct, parseJsonUnknown as d, formatSecretScope as dn, AudioChunkFormatSchema as dt, mergeSecretStatePaths as en, systemMethod as et, hfModelUrl as f, globalSecretScope as fn, AudioStreamPickSchema as ft, ErrorI18nPayloadSchema as g, normalizeNodeId as gn, CamProfileSchema as gt, ErrorCodeSchema as h, parseSecretRef as hn, CAM_PROFILE_ORDER as ht, asBoolean as i, KeychainWriteRefusedError as in, toNodeId as it, HF_REPO as j, isSecretMarker as jn, parseProfileBrokerId as jt, DEFAULT_TOKEN_EXPIRY as k, isSecretClear as kn, makeProfileBrokerId as kt, parseJsonArray as l, arrayItemFieldPath as ln, readinessKey as lt, CamstackError as m, normalizeSecretOwner as mn, BrokerStatusSchema as mt, sleepCancellable as n, secretTreeFromPaths as nn, nodePin as nt, asJsonObject as o, resolveSecretMarkers as on, ReadinessRegistry as ot, BOOT_RECOVERY_BACKOFF_MS as p, isSecretRef as pn, BrokerStatsSchema as pt, PROVIDER_PIN_FIELD as q, PeerBytesTicketSchema as qt, maskUrlCredentials as r, secretTreeFromSchema as rn, readNodePin as rt, asNumber as s, transformSecretWrite as sn, ReadinessTimeoutError as st, sleep as t, parseSecretStatePath as tn, CAP_NODE_PIN_CONTEXT_KEY as tt, parseJsonObject as u, buildSecretRef as un, scopeKey as ut, userError as v, createEvent as vn, CamStreamResolutionSchema as vt, createMirrorSource as w, collectHydratedFieldValues as wn, ProfileSlotStatusSchema as wt, createDeviceProxy as x, WELL_KNOWN_TABS as xn, FrameHandleSchema as xt, DEVICE_SCOPED_CAPS as y, emitReadiness as yn, CameraStreamSchema as yt, describeCustomActions as z, isSecretConfigField as zn, knownSecretCount as zt };
7077
+ export { nodePin as $, mergeSecretStatePaths as $n, AdoptionPendingError as $t, RawStateResultSchema as A, RECORD_SETTINGS_MAX_ROWS as An, isSecretFieldView as Ar, defineEntryKind as At, DEVICE_SETTINGS_CONTRIBUTION_METHODS as B, scrubKnownSecrets as Bn, schemaDeclaresAnyField as Br, declarationsOf as Bt, createLazyTrpcSource as C, RECORD_DELETE_BATCH as Cn, collectHydratedFieldEntries as Cr, StreamSourceSchema as Ct, HF_BASE_URL as D, RECORD_MAX_INDEX_FIELDS as Dn, SECRET_CLEAR as Dr, makeSourceBrokerId as Dt, DEFAULT_TOKEN_EXPIRY as E, RECORD_MAX_INDEXES as En, resolveHydratedFieldValue as Er, makeProfileBrokerId as Et, defineCustomActions as F, MIN_SCRUBBED_LENGTH as Fn, REDACTED_SECRET as Fr, RecordIndexSchema as Ft, event as G, PEER_BYTES_TICKET_TTL_MS as Gn, parseSecretPath as Gt, HISTORY_DEFAULT_MIN_INTERVAL_MS as H, PEER_BYTES_CHUNK_BYTES as Hn, audioChunkBytesPerSample as Hr, REMOVE_LEAF as Ht, describeCustomActions as I, clearKnownSecrets as In, collectKeychainStoredKeys as Ir, RecordKindDeclarationSchema as It, method as J, SHARE_VIEW_KINDS as Jn, recordSecretRef as Jt, expandCapMethods as K, PeerBytesTicketSchema as Kn, recordArrayItemPath as Kt, deviceCustomAction as L, forgetKnownSecret as Ln, collectSecretConfigKeys as Lr, RecordKindNameSchema as Lt, viewerUiCapability as M, resolveSecretViewsIn as Mn, isSecretMarkerLike as Mr, createRecordsAccess as Mt, DEVICE_CHILDREN_BATCH_MAX as N, REVALIDATE_AFTER_MS as Nn, makeSecretMarker as Nr, EntryDescriptorSchema as Nt, HF_REPO as O, RECORD_QUERY_MAX as On, classifySecretWrite as Or, parseProfileBrokerId as Ot, customAction as P, createSecretsAccess as Pn, toSecretFieldView as Pr, RecordFieldPathSchema as Pt, CAP_NODE_PIN_CONTEXT_KEY as Q, normalizeAddonInitResult as Qn, isZodSecret as Qt, adminUiCapability as R, knownSecretCount as Rn, isKeychainStoredField as Rr, RecordRetentionSchema as Rt, createEventBusSliceSource as S, RECORD_DEFAULT_MAX_DATA_BYTES as Sn, WELL_KNOWN_TAB_MAP as Sr, StreamSourceEntrySchema$1 as St, createSliceHandle as T, RECORD_MAX_DATA_BYTES as Tn, hydrateSchema as Tr, SubscribeAudioChunksResultSchema as Tt, HISTORY_UNIT_LABELS as U, PEER_BYTES_MAX_OUTSTANDING as Un, expandAudioChunkToF32le as Ur, collectSecretLeaves as Ut, DEVICE_STATUS_METHOD as V, shortSecretRefHash as Vn, AUDIO_CHUNK_FORMATS as Vr, defineRecordKinds as Vt, PROVIDER_PIN_FIELD as W, PEER_BYTES_STALL_MS as Wn, isAudioChunkFormat as Wr, mapSecretLeaves as Wt, resolveCapMount as X, BaseAddon as Xn, SECRET_META as Xt, optionalMethod as Y, DisposerChain as Yn, secretArrayPrefixes as Yt, systemMethod as Z, classifyStoreError as Zn, collectZodSecretPaths as Zt, readErrorI18n as _, recordsErrorFromMessage as _n, createDurableState as _r, DecodedAudioChunkSchema as _t, asJsonArray as a, NoCallerError as an, isSecretRefOwnedBy as ar, emitDownForOwnedCaps as at, isDeviceScopedCap as b, RECORD_CLASSES as bn, isEvent as br, ProfileSlotSchema as bt, asString as c, RecordNotFoundError as cn, SECRET_REF_SCHEME as cr, AudioChunkFormatSchema as ct, parseJsonUnknown as d, RecordUniqueViolationError as dn, formatSecretScope as dr, BrokerStatusSchema as dt, BatchTooLargeError as en, parseSecretStatePath as er, readNodePin as et, hfModelUrl as f, RecordsError as fn, globalSecretScope as fr, CAM_PROFILE_ORDER as ft, ErrorI18nPayloadSchema as g, asRecordsError as gn, normalizeNodeId as gr, CameraStreamSchema as gt, ErrorCodeSchema as h, UnknownRecordKindError as hn, parseSecretRef as hr, CamStreamResolutionSchema as ht, asBoolean as i, InvalidRecordError as in, collectSecretMarkerRefs as ir, ReadinessTimeoutError as it, deviceOpsCapability as j, RECORD_SWEEP_INTERVAL_MS as jn, isSecretMarker as jr, entryBody as jt, RUNTIME_DEFAULTS as k, RECORD_SECRET_COLLECTION_PREFIX as kn, isSecretClear as kr, selectAssignedProfileSlots as kt, parseJsonArray as l, RecordSecretUnavailableError as ln, arrayItemFieldPath as lr, AudioStreamPickSchema as lt, CamstackError as m, UnindexedFilterError as mn, normalizeSecretOwner as mr, CamStreamKindSchema as mt, sleepCancellable as n, FilterRequiredError as nn, secretTreeFromSchema as nr, MODEL_FORMATS as nt, asJsonObject as o, PlaintextSecretError as on, resolveSecretMarkers as or, readinessKey as ot, BOOT_RECOVERY_BACKOFF_MS as p, RevConflictError as pn, isSecretRef as pr, CamProfileSchema as pt, isDeviceConfigCap as q, DATAPLANE_SECRET_HEADER as qn, recordSecretCollection as qt, maskUrlCredentials as r, ForeignSecretMarkerError as rn, KeychainWriteRefusedError as rr, ReadinessRegistry as rt, asNumber as s, RECORDS_ERROR_CODES as sn, transformSecretWrite as sr, scopeKey as st, sleep as t, DeclarationRefusedError as tn, secretTreeFromPaths as tr, toNodeId as tt, parseJsonObject as u, RecordTooLargeError as un, buildSecretRef as ur, BrokerStatsSchema as ut, userError as v, RECORD_BATCH_MAX as vn, createEvent as vr, FrameHandleSchema as vt, createMirrorSource as w, RECORD_ID_MAX_LENGTH as wn, collectHydratedFieldValues as wr, SubscribeAudioChunksInputSchema as wt, createDeviceProxy as x, RECORD_DATABASES as xn, WELL_KNOWN_TABS as xr, ProfileSlotStatusSchema as xt, DEVICE_SCOPED_CAPS as y, RECORD_BATCH_MAX_BYTES as yn, emitReadiness as yr, ProfileRtspEntrySchema as yt, DEFAULT_RUNTIME_STATE_DURABILITY as z, registerKnownSecret as zn, isSecretConfigField as zr, assertValidDeclaration as zt };