@camstack/addon-notifiers 1.2.135 → 1.2.601

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/addon.mjs CHANGED
@@ -2,7 +2,7 @@ import { brotliCompressSync, deflateSync, gzipSync } from "node:zlib";
2
2
  import { readFileSync } from "node:fs";
3
3
  import path from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
- //#region ../types/dist/event-category-C4hVnRo8.mjs
5
+ //#region ../types/dist/event-category-BvOFi6PY.mjs
6
6
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
7
7
  EventCategory["SystemBoot"] = "system.boot";
8
8
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -66,6 +66,24 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
66
66
  * consumes this category and maps it to the `addon-crash-loop` kind.
67
67
  */
68
68
  EventCategory["AddonRunnerFailed"] = "addon.runner-failed";
69
+ /**
70
+ * A runner whose addon refused to start with a typed reason (D877) - parked
71
+ * in `refused`, never counted by the crash breaker, retried on operator
72
+ * action. One event per refusal.
73
+ */
74
+ EventCategory["AddonRunnerRefused"] = "addon.runner-refused";
75
+ /**
76
+ * A runner settled on a state (D877): `running` (READY), `crashed`, `failed` or
77
+ * `refused`. In-process telemetry for the boot check (re-evaluate while any
78
+ * runner is still pending) and the alert centre (close a recovered runner).
79
+ */
80
+ EventCategory["ProcessStateChanged"] = "process.state-changed";
81
+ /**
82
+ * The node's one-shot runner boot check (D877): planned runners against the
83
+ * process service, `degraded` when any is failed, refused or missing. The
84
+ * alert centre turns it into one alert and a direct critical push.
85
+ */
86
+ EventCategory["SystemRunnerCheck"] = "system.runner-check";
69
87
  EventCategory["AddonError"] = "addon.error";
70
88
  EventCategory["AddonPageReady"] = "addon.page-ready";
71
89
  EventCategory["AddonWidgetReady"] = "addon.widget-ready";
@@ -4108,6 +4126,12 @@ var numberProcessor = (schema, ctx, _json, _params) => {
4108
4126
  var booleanProcessor = (_schema, _ctx, json, _params) => {
4109
4127
  json.type = "boolean";
4110
4128
  };
4129
+ var bigintProcessor = (_schema, ctx, _json, _params) => {
4130
+ if (ctx.unrepresentable === "throw") throw new Error("BigInt cannot be represented in JSON Schema");
4131
+ };
4132
+ var symbolProcessor = (_schema, ctx, _json, _params) => {
4133
+ if (ctx.unrepresentable === "throw") throw new Error("Symbols cannot be represented in JSON Schema");
4134
+ };
4111
4135
  var nullProcessor = (_schema, ctx, json, _params) => {
4112
4136
  if (ctx.target === "openapi-3.0") {
4113
4137
  json.type = "string";
@@ -4115,12 +4139,17 @@ var nullProcessor = (_schema, ctx, json, _params) => {
4115
4139
  json.enum = [null];
4116
4140
  } else json.type = "null";
4117
4141
  };
4142
+ var undefinedProcessor = (_schema, ctx, _json, _params) => {
4143
+ if (ctx.unrepresentable === "throw") throw new Error("Undefined cannot be represented in JSON Schema");
4144
+ };
4118
4145
  var voidProcessor = (_schema, ctx, _json, _params) => {
4119
4146
  if (ctx.unrepresentable === "throw") throw new Error("Void cannot be represented in JSON Schema");
4120
4147
  };
4121
4148
  var neverProcessor = (_schema, _ctx, json, _params) => {
4122
4149
  json.not = {};
4123
4150
  };
4151
+ var anyProcessor = (_schema, _ctx, _json, _params) => {};
4152
+ var unknownProcessor = (_schema, _ctx, _json, _params) => {};
4124
4153
  var dateProcessor = (_schema, ctx, _json, _params) => {
4125
4154
  if (ctx.unrepresentable === "throw") throw new Error("Date cannot be represented in JSON Schema");
4126
4155
  };
@@ -4152,12 +4181,53 @@ var literalProcessor = (schema, ctx, json, _params) => {
4152
4181
  json.enum = vals;
4153
4182
  }
4154
4183
  };
4184
+ var nanProcessor = (_schema, ctx, _json, _params) => {
4185
+ if (ctx.unrepresentable === "throw") throw new Error("NaN cannot be represented in JSON Schema");
4186
+ };
4187
+ var templateLiteralProcessor = (schema, _ctx, json, _params) => {
4188
+ const _json = json;
4189
+ const pattern = schema._zod.pattern;
4190
+ if (!pattern) throw new Error("Pattern not found in template literal");
4191
+ _json.type = "string";
4192
+ _json.pattern = pattern.source;
4193
+ };
4194
+ var fileProcessor = (schema, _ctx, json, _params) => {
4195
+ const _json = json;
4196
+ const file = {
4197
+ type: "string",
4198
+ format: "binary",
4199
+ contentEncoding: "binary"
4200
+ };
4201
+ const { minimum, maximum, mime } = schema._zod.bag;
4202
+ if (minimum !== void 0) file.minLength = minimum;
4203
+ if (maximum !== void 0) file.maxLength = maximum;
4204
+ if (mime) if (mime.length === 1) {
4205
+ file.contentMediaType = mime[0];
4206
+ Object.assign(_json, file);
4207
+ } else {
4208
+ Object.assign(_json, file);
4209
+ _json.anyOf = mime.map((m) => ({ contentMediaType: m }));
4210
+ }
4211
+ else Object.assign(_json, file);
4212
+ };
4213
+ var successProcessor = (_schema, _ctx, json, _params) => {
4214
+ json.type = "boolean";
4215
+ };
4155
4216
  var customProcessor = (_schema, ctx, _json, _params) => {
4156
4217
  if (ctx.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
4157
4218
  };
4219
+ var functionProcessor = (_schema, ctx, _json, _params) => {
4220
+ if (ctx.unrepresentable === "throw") throw new Error("Function types cannot be represented in JSON Schema");
4221
+ };
4158
4222
  var transformProcessor = (_schema, ctx, _json, _params) => {
4159
4223
  if (ctx.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
4160
4224
  };
4225
+ var mapProcessor = (_schema, ctx, _json, _params) => {
4226
+ if (ctx.unrepresentable === "throw") throw new Error("Map cannot be represented in JSON Schema");
4227
+ };
4228
+ var setProcessor = (_schema, ctx, _json, _params) => {
4229
+ if (ctx.unrepresentable === "throw") throw new Error("Set cannot be represented in JSON Schema");
4230
+ };
4161
4231
  var arrayProcessor = (schema, ctx, _json, params) => {
4162
4232
  const json = _json;
4163
4233
  const def = schema._zod.def;
@@ -4362,6 +4432,12 @@ var readonlyProcessor = (schema, ctx, json, params) => {
4362
4432
  seen.ref = def.innerType;
4363
4433
  json.readOnly = true;
4364
4434
  };
4435
+ var promiseProcessor = (schema, ctx, _json, params) => {
4436
+ const def = schema._zod.def;
4437
+ process(def.innerType, ctx, params);
4438
+ const seen = ctx.seen.get(schema);
4439
+ seen.ref = def.innerType;
4440
+ };
4365
4441
  var optionalProcessor = (schema, ctx, _json, params) => {
4366
4442
  const def = schema._zod.def;
4367
4443
  process(def.innerType, ctx, params);
@@ -4374,6 +4450,81 @@ var lazyProcessor = (schema, ctx, _json, params) => {
4374
4450
  const seen = ctx.seen.get(schema);
4375
4451
  seen.ref = innerType;
4376
4452
  };
4453
+ var allProcessors = {
4454
+ string: stringProcessor,
4455
+ number: numberProcessor,
4456
+ boolean: booleanProcessor,
4457
+ bigint: bigintProcessor,
4458
+ symbol: symbolProcessor,
4459
+ null: nullProcessor,
4460
+ undefined: undefinedProcessor,
4461
+ void: voidProcessor,
4462
+ never: neverProcessor,
4463
+ any: anyProcessor,
4464
+ unknown: unknownProcessor,
4465
+ date: dateProcessor,
4466
+ enum: enumProcessor,
4467
+ literal: literalProcessor,
4468
+ nan: nanProcessor,
4469
+ template_literal: templateLiteralProcessor,
4470
+ file: fileProcessor,
4471
+ success: successProcessor,
4472
+ custom: customProcessor,
4473
+ function: functionProcessor,
4474
+ transform: transformProcessor,
4475
+ map: mapProcessor,
4476
+ set: setProcessor,
4477
+ array: arrayProcessor,
4478
+ object: objectProcessor,
4479
+ union: unionProcessor,
4480
+ intersection: intersectionProcessor,
4481
+ tuple: tupleProcessor,
4482
+ record: recordProcessor,
4483
+ nullable: nullableProcessor,
4484
+ nonoptional: nonoptionalProcessor,
4485
+ default: defaultProcessor,
4486
+ prefault: prefaultProcessor,
4487
+ catch: catchProcessor,
4488
+ pipe: pipeProcessor,
4489
+ readonly: readonlyProcessor,
4490
+ promise: promiseProcessor,
4491
+ optional: optionalProcessor,
4492
+ lazy: lazyProcessor
4493
+ };
4494
+ function toJSONSchema(input, params) {
4495
+ if ("_idmap" in input) {
4496
+ const registry = input;
4497
+ const ctx = initializeContext({
4498
+ ...params,
4499
+ processors: allProcessors
4500
+ });
4501
+ const defs = {};
4502
+ for (const entry of registry._idmap.entries()) {
4503
+ const [_, schema] = entry;
4504
+ process(schema, ctx);
4505
+ }
4506
+ const schemas = {};
4507
+ ctx.external = {
4508
+ registry,
4509
+ uri: params?.uri,
4510
+ defs
4511
+ };
4512
+ for (const entry of registry._idmap.entries()) {
4513
+ const [key, schema] = entry;
4514
+ extractDefs(ctx, schema);
4515
+ schemas[key] = finalize(ctx, schema);
4516
+ }
4517
+ if (Object.keys(defs).length > 0) schemas.__shared = { [ctx.target === "draft-2020-12" ? "$defs" : "definitions"]: defs };
4518
+ return { schemas };
4519
+ }
4520
+ const ctx = initializeContext({
4521
+ ...params,
4522
+ processors: allProcessors
4523
+ });
4524
+ process(input, ctx);
4525
+ extractDefs(ctx, input);
4526
+ return finalize(ctx, input);
4527
+ }
4377
4528
  //#endregion
4378
4529
  //#region ../../node_modules/zod/v4/classic/iso.js
4379
4530
  var ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
@@ -5390,7 +5541,7 @@ var ZodIssueCode = {
5390
5541
  var ZodFirstPartyTypeKind;
5391
5542
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5392
5543
  //#endregion
5393
- //#region ../types/dist/sleep-DRqxtc0C.mjs
5544
+ //#region ../types/dist/sleep-bZIhUvjd.mjs
5394
5545
  /**
5395
5546
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5396
5547
  * window to float samples (D455).
@@ -5507,7 +5658,7 @@ function isKeychainStoredField(field) {
5507
5658
  var SECRET_CLEAR = { $secretClear: true };
5508
5659
  /** The `'***'` token D634 redaction writes for non-admins. */
5509
5660
  var LEGACY_DEVICE_REDACTION = "***";
5510
- function isRecord$2(value) {
5661
+ function isRecord$5(value) {
5511
5662
  return typeof value === "object" && value !== null && !Array.isArray(value);
5512
5663
  }
5513
5664
  function makeSecretMarker(ref) {
@@ -5518,12 +5669,12 @@ function makeSecretMarker(ref) {
5518
5669
  }
5519
5670
  /** A stored marker: an object whose `$secret` is a non-empty string. */
5520
5671
  function isSecretMarker(value) {
5521
- if (!isRecord$2(value)) return false;
5672
+ if (!isRecord$5(value)) return false;
5522
5673
  const ref = value["$secret"];
5523
5674
  return typeof ref === "string" && ref.length > 0;
5524
5675
  }
5525
5676
  function isSecretClear(value) {
5526
- return isRecord$2(value) && value["$secretClear"] === true;
5677
+ return isRecord$5(value) && value["$secretClear"] === true;
5527
5678
  }
5528
5679
  /**
5529
5680
  * The UI view of a stored secret field value: a marker becomes "set", inline
@@ -6133,7 +6284,7 @@ var KeychainWriteRefusedError = class extends Error {
6133
6284
  }
6134
6285
  };
6135
6286
  var KEEP = { kind: "keep" };
6136
- function isRecord$1(value) {
6287
+ function isRecord$4(value) {
6137
6288
  return typeof value === "object" && value !== null && !Array.isArray(value);
6138
6289
  }
6139
6290
  function defaultMintId() {
@@ -6146,7 +6297,7 @@ function collectSecretMarkerRefs(value, out = []) {
6146
6297
  return out;
6147
6298
  }
6148
6299
  if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6149
- else if (isRecord$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6300
+ else if (isRecord$4(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6150
6301
  return out;
6151
6302
  }
6152
6303
  async function storedValueEquals(secrets, marker, candidate) {
@@ -6201,7 +6352,7 @@ function rowId(row, idKey) {
6201
6352
  return null;
6202
6353
  }
6203
6354
  async function writeArray(ctx, node, incoming, stored, fieldPath) {
6204
- const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1) : [];
6355
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$4) : [];
6205
6356
  if (!Array.isArray(incoming)) {
6206
6357
  ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6207
6358
  return {
@@ -6217,7 +6368,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6217
6368
  const kept = /* @__PURE__ */ new Set();
6218
6369
  const rows = [];
6219
6370
  for (const row of incoming) {
6220
- if (!isRecord$1(row)) {
6371
+ if (!isRecord$4(row)) {
6221
6372
  rows.push(row);
6222
6373
  continue;
6223
6374
  }
@@ -6242,7 +6393,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6242
6393
  case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6243
6394
  case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6244
6395
  case "object": {
6245
- if (!isRecord$1(incoming)) {
6396
+ if (!isRecord$4(incoming)) {
6246
6397
  if (incoming === void 0) return KEEP;
6247
6398
  ctx.deletes.push(...collectSecretMarkerRefs(stored));
6248
6399
  return {
@@ -6250,7 +6401,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6250
6401
  value: incoming
6251
6402
  };
6252
6403
  }
6253
- const storedObj = isRecord$1(stored) ? stored : {};
6404
+ const storedObj = isRecord$4(stored) ? stored : {};
6254
6405
  return {
6255
6406
  kind: "value",
6256
6407
  value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
@@ -6373,7 +6524,7 @@ async function resolveSecretMarkers(value, secrets, options = {}) {
6373
6524
  value: items
6374
6525
  };
6375
6526
  }
6376
- if (isRecord$1(v)) {
6527
+ if (isRecord$4(v)) {
6377
6528
  const out = {};
6378
6529
  for (const [k, child] of Object.entries(v)) {
6379
6530
  const s = substitute(child);
@@ -6641,7 +6792,6 @@ function createHandle(raw, opts) {
6641
6792
  const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
6642
6793
  const readAddonStoreResult = raw.readAddonStoreResult;
6643
6794
  const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
6644
- const readDeviceStoreBatch = raw.readDeviceStoreBatch;
6645
6795
  const overrides = {
6646
6796
  readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
6647
6797
  ...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
@@ -6665,12 +6815,12 @@ function createHandle(raw, opts) {
6665
6815
  };
6666
6816
  } } : {},
6667
6817
  readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
6668
- ...readDeviceStoreBatch !== void 0 ? { readDeviceStoreBatch: async (deviceIds) => {
6669
- const rows = await readDeviceStoreBatch.call(raw, deviceIds);
6818
+ readDeviceStoreBatch: async (deviceIds) => {
6819
+ const rows = await raw.readDeviceStoreBatch(deviceIds);
6670
6820
  const out = /* @__PURE__ */ new Map();
6671
6821
  for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
6672
6822
  return out;
6673
- } } : {},
6823
+ },
6674
6824
  writeAddonStore: async (patch) => {
6675
6825
  await writeAddon(patch);
6676
6826
  },
@@ -7297,7 +7447,7 @@ var BaseAddon = class {
7297
7447
  if (!ctx) return;
7298
7448
  const addonId = ctx.id;
7299
7449
  setImmediate(() => {
7300
- ctx.api.addons?.restartAddon?.mutate({ addonId }).then(() => {
7450
+ ctx.api.addons.restartAddon.mutate({ addonId }).then(() => {
7301
7451
  ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
7302
7452
  }).catch((err) => {
7303
7453
  ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
@@ -7497,7 +7647,7 @@ var BaseAddon = class {
7497
7647
  return this._addonSecretTree;
7498
7648
  }
7499
7649
  deviceSecretTree() {
7500
- this._deviceSecretTree ??= secretTreeFromSchema(this.deviceSettingsSchema());
7650
+ this._deviceSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.deviceSettingsSchema()), this.secretStatePaths);
7501
7651
  return this._deviceSecretTree;
7502
7652
  }
7503
7653
  /**
@@ -7573,42 +7723,135 @@ var BaseAddon = class {
7573
7723
  this[timerOf] = timer;
7574
7724
  }
7575
7725
  /**
7576
- * Wrap `ctx.settings.readAddonStore()` with a short retry budget so a
7577
- * transient settings-store outage (mid-restart of sqlite-settings, tsx-watch
7578
- * swap, or any race where the SqliteSettingsBackend is between shutdown and
7579
- * re-initialize) doesn't propagate up into `initialize()` and leave the
7726
+ * Wrap `ctx.settings.readAddonStore()` with a retry budget so a transient
7727
+ * settings-store outage doesn't propagate up into `initialize()` and leave the
7580
7728
  * addon permanently broken.
7581
7729
  *
7582
- * Retry only the two known infra fingerprints. Anything else propagates so
7583
- * real bugs surface immediately. After the budget expires we fall back to
7584
- * `{}` (defaults) — the addon's first successful patch will rehydrate.
7730
+ * Two kinds of outage, two budgets:
7731
+ * - the store's own restart fingerprints (`SqliteSettingsBackend not
7732
+ * initialized`, `provider not available`): a short budget, then the addon
7733
+ * falls back to `{}` (defaults) - its first successful patch rehydrates;
7734
+ * - a TRANSPORT failure (the hub is restarting while this runner boots:
7735
+ * `discovery deadline exceeded`, `parent could not route`, a refused or
7736
+ * timed-out connection). Since D870 a runner's settings read THROWS instead
7737
+ * of answering `{}`, so without a budget a hub restart ends in a respawn
7738
+ * loop. A long, bounded budget; only after it the error propagates - the
7739
+ * addon never runs on defaults for a store it could not ask.
7740
+ * Anything else propagates immediately so real bugs surface.
7585
7741
  */
7586
7742
  async readAddonStoreWithRetry() {
7587
7743
  const settings = this.rawSettings();
7588
7744
  if (!settings) return {};
7589
- const delaysMs = [
7590
- 150,
7591
- 350,
7592
- 600,
7593
- 900
7594
- ];
7595
7745
  let lastErr;
7596
- for (let attempt = 0; attempt <= delaysMs.length; attempt++) try {
7746
+ for (let attempt = 0;; attempt++) try {
7597
7747
  const stored = await settings.readAddonStore() ?? {};
7598
7748
  this.settingsStoreReady = true;
7599
7749
  return stored;
7600
7750
  } catch (err) {
7601
7751
  lastErr = err;
7602
- const msg = err instanceof Error ? err.message : String(err);
7603
- if (!(msg.includes("SqliteSettingsBackend not initialized") || msg.includes("provider not available"))) throw err;
7604
- if (attempt === delaysMs.length) break;
7605
- await new Promise((r) => setTimeout(r, delaysMs[attempt]));
7752
+ const kind = classifyStoreError(err);
7753
+ if (kind === "permanent") throw err;
7754
+ const delay = (kind === "transport" ? TRANSPORT_RETRY_DELAYS_MS : RESTART_RETRY_DELAYS_MS)[attempt];
7755
+ if (delay === void 0) {
7756
+ if (kind === "transport") throw err;
7757
+ break;
7758
+ }
7759
+ await new Promise((r) => setTimeout(r, delay));
7606
7760
  }
7607
7761
  this.settingsStoreReady = false;
7608
7762
  this._ctx?.logger?.warn?.("readAddonStore: settings-store unavailable after retries — using defaults", { meta: { error: lastErr instanceof Error ? lastErr.message : String(lastErr) } });
7609
7763
  return {};
7610
7764
  }
7611
7765
  };
7766
+ /** The settings store's own restart fingerprints. */
7767
+ var RESTART_RETRY_DELAYS_MS = [
7768
+ 150,
7769
+ 350,
7770
+ 600,
7771
+ 900
7772
+ ];
7773
+ /** A hub restarting under a booting runner: ~100 s in total. */
7774
+ var TRANSPORT_RETRY_DELAYS_MS = [
7775
+ 150,
7776
+ 350,
7777
+ 600,
7778
+ 900,
7779
+ 2e3,
7780
+ 5e3,
7781
+ 1e4,
7782
+ 2e4,
7783
+ 3e4,
7784
+ 3e4
7785
+ ];
7786
+ var RESTART_FINGERPRINTS = ["SqliteSettingsBackend not initialized", "provider not available"];
7787
+ /** Node / socket error codes of a connection that did not happen or broke. */
7788
+ var TRANSPORT_CODES = new Set([
7789
+ "ECONNREFUSED",
7790
+ "ECONNRESET",
7791
+ "ETIMEDOUT",
7792
+ "EPIPE",
7793
+ "EHOSTUNREACH",
7794
+ "ENETUNREACH"
7795
+ ]);
7796
+ /** tRPC error codes that mean "the other side is not answering now", not "your call is wrong". */
7797
+ var UNAVAILABLE_TRPC_CODES = new Set([
7798
+ "TIMEOUT",
7799
+ "SERVICE_UNAVAILABLE",
7800
+ "BAD_GATEWAY",
7801
+ "GATEWAY_TIMEOUT"
7802
+ ]);
7803
+ /** The exact phrases OUR transport raises when it cannot reach the hub. */
7804
+ var TRANSPORT_PHRASES = [
7805
+ "discovery deadline exceeded",
7806
+ "parent could not route child unowned cap call",
7807
+ "UDS request timed out after",
7808
+ "channel closed"
7809
+ ];
7810
+ /** Moleculer error `type`s of a call that could not be served right now. */
7811
+ var MOLECULER_TRANSIENT_TYPES = new Set([
7812
+ "REQUEST_TIMEOUT",
7813
+ "SERVICE_NOT_FOUND",
7814
+ "SERVICE_NOT_AVAILABLE",
7815
+ "REQUEST_REJECTED",
7816
+ "BROKER_DISCONNECTED"
7817
+ ]);
7818
+ function stringProp(value, key) {
7819
+ if (typeof value !== "object" || value === null) return void 0;
7820
+ const found = Reflect.get(value, key);
7821
+ return typeof found === "string" ? found : void 0;
7822
+ }
7823
+ /** The code an error carries: its own, its cause's, or a tRPC `data.code`. */
7824
+ function errorCode(err) {
7825
+ const out = {};
7826
+ const cause = typeof err === "object" && err !== null ? Reflect.get(err, "cause") : void 0;
7827
+ const data = typeof err === "object" && err !== null ? Reflect.get(err, "data") : void 0;
7828
+ const node = stringProp(err, "code") ?? stringProp(cause, "code");
7829
+ if (node !== void 0) out.node = node;
7830
+ const trpc = stringProp(data, "code");
7831
+ if (trpc !== void 0) out.trpc = trpc;
7832
+ return out;
7833
+ }
7834
+ /**
7835
+ * Is a settings read failure worth retrying, and with which budget? Only
7836
+ * EXPLICIT signals count: a socket error code, a tRPC "unavailable" code, or
7837
+ * one of the exact phrases our own transport raises. A message that merely
7838
+ * contains "timed out" or "unreachable" is not evidence of anything, and
7839
+ * `settings store not wired` is a wiring bug that retrying cannot fix.
7840
+ */
7841
+ function classifyStoreError(err) {
7842
+ const message = err instanceof Error ? err.message : String(err);
7843
+ if (RESTART_FINGERPRINTS.some((f) => message.includes(f))) return "restart";
7844
+ const code = errorCode(err);
7845
+ if (code.node !== void 0 && TRANSPORT_CODES.has(code.node)) return "transport";
7846
+ if (code.trpc !== void 0 && UNAVAILABLE_TRPC_CODES.has(code.trpc)) return "transport";
7847
+ if (typeof err === "object" && err !== null) {
7848
+ if (Reflect.get(err, "retryable") === true) return "transport";
7849
+ const type = stringProp(err, "type");
7850
+ if (type !== void 0 && MOLECULER_TRANSIENT_TYPES.has(type)) return "transport";
7851
+ }
7852
+ if (TRANSPORT_PHRASES.some((f) => message.includes(f))) return "transport";
7853
+ return "permanent";
7854
+ }
7612
7855
  /**
7613
7856
  * Collect the keys of every field marked `perNode: true`, recursing into
7614
7857
  * layout containers (`group` fields and `sub-tabs` tabs) the same way
@@ -7698,6 +7941,303 @@ var PeerBytesTicketSchema = object({
7698
7941
  */
7699
7942
  declaredBytes: number().int().nonnegative().nullable()
7700
7943
  });
7944
+ /** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
7945
+ /** The files a kind may live in. `history` is device-history's (D850), never records. */
7946
+ var RECORD_DATABASES = ["settings", "events"];
7947
+ /** The classes of a kind: the `@durable` vocabulary, one authority (replaces the annotation). */
7948
+ var RECORD_CLASSES = [
7949
+ "config",
7950
+ "ledger",
7951
+ "audit",
7952
+ "mirror",
7953
+ "ephemeral"
7954
+ ];
7955
+ var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
7956
+ var RECORD_MAX_DATA_BYTES = 1024 * 1024;
7957
+ var RECORD_BATCH_MAX = 1e3;
7958
+ var RECORD_QUERY_MAX = 1e3;
7959
+ /** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
7960
+ var RECORD_SETTINGS_MAX_ROWS = 5e4;
7961
+ var PREFIX = "records/";
7962
+ /** The base of every records failure. `detail` is the human part of the message. */
7963
+ var RecordsError = class extends Error {
7964
+ code;
7965
+ detail;
7966
+ constructor(code, detail) {
7967
+ super(`${PREFIX}${code}: ${detail}`);
7968
+ this.name = "RecordsError";
7969
+ this.code = code;
7970
+ this.detail = detail;
7971
+ }
7972
+ };
7973
+ var InvalidRecordError = class extends RecordsError {
7974
+ constructor(detail) {
7975
+ super("invalid-record", detail);
7976
+ this.name = "InvalidRecordError";
7977
+ }
7978
+ };
7979
+ /** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
7980
+ var DeclarationRefusedError = class extends RecordsError {
7981
+ constructor(detail) {
7982
+ super("declaration-refused", detail);
7983
+ this.name = "DeclarationRefusedError";
7984
+ }
7985
+ };
7986
+ function defOf(schema) {
7987
+ const zodBag = Reflect.get(schema, "_zod");
7988
+ if (typeof zodBag !== "object" || zodBag === null) return {};
7989
+ const def = Reflect.get(zodBag, "def");
7990
+ if (typeof def !== "object" || def === null) return {};
7991
+ return def;
7992
+ }
7993
+ function declaredHere(schema) {
7994
+ return globalRegistry.get(schema)?.secret === true;
7995
+ }
7996
+ /** Wrapper kinds whose `innerType` is the field itself. */
7997
+ var WRAPPERS = new Set([
7998
+ "optional",
7999
+ "nullable",
8000
+ "default",
8001
+ "prefault",
8002
+ "catch",
8003
+ "readonly",
8004
+ "nonoptional"
8005
+ ]);
8006
+ /**
8007
+ * The schema layers that make up ONE field: the schema itself and every
8008
+ * wrapper below it (optional / default / nullable / readonly / catch), plus
8009
+ * both sides of a pipe (`z.preprocess` puts the real schema on `out`,
8010
+ * `.transform` on `in`).
8011
+ */
8012
+ function layersOf(schema) {
8013
+ const out = [];
8014
+ const queue = [schema];
8015
+ while (queue.length > 0) {
8016
+ const s = queue.shift();
8017
+ if (!s || out.includes(s)) continue;
8018
+ out.push(s);
8019
+ const def = defOf(s);
8020
+ if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
8021
+ if (def.type === "pipe") {
8022
+ if (def.in) queue.push(def.in);
8023
+ if (def.out) queue.push(def.out);
8024
+ }
8025
+ }
8026
+ return out;
8027
+ }
8028
+ /** True when any layer of this field declares `.meta({ secret: true })`. */
8029
+ function isZodSecret(schema) {
8030
+ return layersOf(schema).some(declaredHere);
8031
+ }
8032
+ /**
8033
+ * Every declared secret path in a config schema: dotted keys, `[]` for "each
8034
+ * element of this array" (`connection.password`, `rows[].token`). A declared
8035
+ * object or array is reported as one path and not descended into — everything
8036
+ * under it is secret.
8037
+ */
8038
+ function collectZodSecretPaths(schema, prefix = "") {
8039
+ if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
8040
+ const paths = [];
8041
+ for (const layer of layersOf(schema)) {
8042
+ const def = defOf(layer);
8043
+ if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
8044
+ else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
8045
+ else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
8046
+ else if (def.type === "intersection") {
8047
+ if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
8048
+ if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
8049
+ }
8050
+ }
8051
+ return [...new Set(paths)];
8052
+ }
8053
+ /**
8054
+ * Secret fields of a record, addressed the way a Zod schema declares them
8055
+ * (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
8056
+ * (`auth.accessToken`, `headers[].value`).
8057
+ *
8058
+ * Array elements are matched by a DECLARED id key (`secretArrayKeys`:
8059
+ * `{ headers: 'name' }`), never by index, so reordering a list keeps every
8060
+ * keychain ref (the same rule as `arrayItemFieldPath`). The concrete path of a
8061
+ * leaf names its element: `headers[X-Api].value`.
8062
+ *
8063
+ * Pure and browser-safe. Nothing here mutates: every transform returns a new value.
8064
+ */
8065
+ /** The array prefixes (declared form, e.g. `headers` or `a.headers`) of a path. */
8066
+ function parseSecretPath(path) {
8067
+ if (path.length === 0) throw new InvalidRecordError("an empty secret path");
8068
+ return path.split(".").map((raw) => {
8069
+ const each = raw.endsWith("[]");
8070
+ const key = each ? raw.slice(0, -2) : raw;
8071
+ if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
8072
+ return {
8073
+ key,
8074
+ each
8075
+ };
8076
+ });
8077
+ }
8078
+ /** The declared array prefixes of `path` that need an id key (`headers`, `a.rows`). */
8079
+ function secretArrayPrefixes(path) {
8080
+ const segments = parseSecretPath(path);
8081
+ const prefixes = [];
8082
+ const walked = [];
8083
+ for (const segment of segments) {
8084
+ walked.push(segment.key);
8085
+ if (segment.each) prefixes.push(walked.join("."));
8086
+ }
8087
+ return prefixes;
8088
+ }
8089
+ /**
8090
+ * Record kinds (D881): the declaration an addon makes of one kind of fact, the
8091
+ * Zod row schema that describes it, and the helper that turns the two into the
8092
+ * JSON the engine stores.
8093
+ *
8094
+ * A kind is declared ONCE, next to the code that owns it, and the engine's
8095
+ * reconciler creates its indexes - nothing creates DDL at runtime from a write.
8096
+ * Everything the generic machinery needs (secret fields, the entry descriptor)
8097
+ * is DERIVED from the Zod schema: `.meta({ secret: true })` marks a credential,
8098
+ * never a field name (D879).
8099
+ */
8100
+ /** A JSON field path: `trackId`, `auth.accessToken`. Charset-restricted: it is rendered into DDL. */
8101
+ var RecordFieldPathSchema = string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,63}(\.[A-Za-z_][A-Za-z0-9_]{0,63}){0,3}$/);
8102
+ var RecordIndexSchema = object({
8103
+ name: string().regex(/^[a-z][a-z0-9_]{0,31}$/),
8104
+ fields: array(RecordFieldPathSchema).min(1).max(4),
8105
+ unique: boolean().optional()
8106
+ }).strict();
8107
+ var RecordRetentionSchema = union([
8108
+ object({
8109
+ ttlMs: number().int().positive(),
8110
+ from: _enum(["at", "write"])
8111
+ }).strict(),
8112
+ object({
8113
+ maxRows: number().int().positive().optional(),
8114
+ maxRowsPerDevice: number().int().positive().optional()
8115
+ }).strict().refine((r) => r.maxRows !== void 0 || r.maxRowsPerDevice !== void 0, { message: "name maxRows, maxRowsPerDevice or both" }),
8116
+ object({
8117
+ owner: string().min(1),
8118
+ reason: string().min(1)
8119
+ }).strict(),
8120
+ object({ none: string().min(1) }).strict()
8121
+ ]);
8122
+ /** The descriptor a generic entries UI reads (D881 "generic entries"). */
8123
+ var EntryDescriptorSchema = object({
8124
+ title: string().min(1),
8125
+ /** The record body field shown as the entry's name. */
8126
+ nameField: string().min(1),
8127
+ /** JSON Schema of the entry body; `secret: true` marks a password field. */
8128
+ fields: record(string(), unknown())
8129
+ }).strict();
8130
+ /** What crosses the wire and sits in the engine's catalog: JSON only, no Zod. */
8131
+ var RecordKindDeclarationSchema = object({
8132
+ database: _enum(RECORD_DATABASES).default("settings"),
8133
+ class: _enum(RECORD_CLASSES),
8134
+ writeTrigger: string().min(1),
8135
+ device: _enum([
8136
+ "required",
8137
+ "optional",
8138
+ "none"
8139
+ ]).default("none"),
8140
+ at: _enum(["required", "none"]).default("none"),
8141
+ indexes: array(RecordIndexSchema).max(8).default([]),
8142
+ retention: RecordRetentionSchema,
8143
+ deviceRemoval: _enum(["delete", "none"]).default("none"),
8144
+ maxDataBytes: number().int().positive().max(RECORD_MAX_DATA_BYTES).default(RECORD_DEFAULT_MAX_DATA_BYTES),
8145
+ /** Derived from the Zod schema; never written by hand. */
8146
+ secretPaths: array(string().min(1)).default([]),
8147
+ /** The id key of each array that carries a secret (`{ headers: 'name' }`). */
8148
+ secretArrayKeys: record(string(), string()).default({}),
8149
+ /** The legacy table this kind adopts from; the boot guard reads it (D853: no migration code). */
8150
+ adoptsFrom: string().min(1).optional(),
8151
+ /** Kinds that must agree through `transact` sit in one file under one family name. */
8152
+ transactFamily: string().min(1).optional(),
8153
+ entry: EntryDescriptorSchema.optional()
8154
+ }).strict();
8155
+ /** The kind names: lower-case, dash separated, short enough for an index name. */
8156
+ var RecordKindNameSchema = string().regex(/^[a-z][a-z0-9-]{0,47}$/);
8157
+ /** Cross-field rules a declaration must satisfy. Throws {@link DeclarationRefusedError}. */
8158
+ function assertValidDeclaration(name, decl) {
8159
+ const refuse = (why) => {
8160
+ throw new DeclarationRefusedError(`kind "${name}": ${why}`);
8161
+ };
8162
+ if (!RecordKindNameSchema.safeParse(name).success) refuse("the name must be lower-case-dashed");
8163
+ const seen = /* @__PURE__ */ new Set();
8164
+ for (const index of decl.indexes) {
8165
+ if (seen.has(index.name)) refuse(`index name "${index.name}" is declared twice`);
8166
+ seen.add(index.name);
8167
+ }
8168
+ const { retention } = decl;
8169
+ const hasSecrets = decl.secretPaths.length > 0;
8170
+ if ("ttlMs" in retention) {
8171
+ if (retention.from === "at" && decl.at !== "required") refuse("a ttl from \"at\" needs at: \"required\"");
8172
+ if (hasSecrets) refuse("a kind with secret fields cannot use engine TTL (its keychain values would be orphaned)");
8173
+ }
8174
+ if ("maxRows" in retention || "maxRowsPerDevice" in retention) {
8175
+ if (retention.maxRowsPerDevice !== void 0 && decl.device !== "required") refuse("maxRowsPerDevice needs device: \"required\"");
8176
+ if (decl.at !== "required") refuse("a row bound trims the oldest \"at\": it needs at: \"required\"");
8177
+ if (hasSecrets) refuse("a kind with secret fields cannot use an engine row bound");
8178
+ const bound = Math.max(retention.maxRows ?? 0, retention.maxRowsPerDevice ?? 0);
8179
+ 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)`);
8180
+ }
8181
+ if (decl.deviceRemoval === "delete" && decl.device === "none") refuse("deviceRemoval: \"delete\" needs a device: \"required\" or \"optional\"");
8182
+ 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`);
8183
+ }
8184
+ function bodyFieldsOf(schema) {
8185
+ return { ...toJSONSchema(schema, {
8186
+ unrepresentable: "any",
8187
+ io: "input"
8188
+ }) };
8189
+ }
8190
+ function isRecordLike(value) {
8191
+ return typeof value === "object" && value !== null && !Array.isArray(value);
8192
+ }
8193
+ /** Does every branch of the body schema carry `field`? (A discriminated union has several.) */
8194
+ function hasNameField(json, field) {
8195
+ const branches = json["oneOf"] ?? json["anyOf"];
8196
+ if (Array.isArray(branches)) return branches.length > 0 && branches.every((b) => isRecordLike(b) && hasNameField(b, field));
8197
+ const properties = json["properties"];
8198
+ return isRecordLike(properties) && Object.prototype.hasOwnProperty.call(properties, field);
8199
+ }
8200
+ /**
8201
+ * Declare the kinds of a package. The keys are the kind names. The result is
8202
+ * what `ctx.records.declare` sends to the engine and what `ctx.records.kind`
8203
+ * types its handle from.
8204
+ */
8205
+ function defineRecordKinds(specs) {
8206
+ const out = {};
8207
+ for (const [name, spec] of Object.entries(specs)) {
8208
+ const secretPaths = collectZodSecretPaths(spec.schema);
8209
+ const nameField = spec.entry?.nameField ?? "name";
8210
+ const fields = bodyFieldsOf(spec.schema);
8211
+ if (spec.entry !== void 0 && !hasNameField(fields, nameField)) throw new DeclarationRefusedError(`kind "${name}": an entry kind's schema needs a "${nameField}" field`);
8212
+ const parsed = RecordKindDeclarationSchema.parse({
8213
+ database: spec.database,
8214
+ class: spec.class,
8215
+ writeTrigger: spec.writeTrigger,
8216
+ device: spec.device,
8217
+ at: spec.at,
8218
+ indexes: spec.indexes === void 0 ? void 0 : [...spec.indexes],
8219
+ retention: spec.retention,
8220
+ deviceRemoval: spec.deviceRemoval,
8221
+ maxDataBytes: spec.maxDataBytes,
8222
+ secretPaths: [...secretPaths],
8223
+ secretArrayKeys: spec.secretArrayKeys === void 0 ? void 0 : { ...spec.secretArrayKeys },
8224
+ adoptsFrom: spec.adoptsFrom,
8225
+ transactFamily: spec.transactFamily,
8226
+ entry: spec.entry === void 0 ? void 0 : {
8227
+ title: spec.entry.title,
8228
+ nameField,
8229
+ fields
8230
+ }
8231
+ });
8232
+ assertValidDeclaration(name, parsed);
8233
+ out[name] = {
8234
+ name,
8235
+ schema: spec.schema,
8236
+ declaration: parsed
8237
+ };
8238
+ }
8239
+ return out;
8240
+ }
7701
8241
  /** Shared Zod schemas used across streaming capabilities. */
7702
8242
  var CamProfileSchema = _enum([
7703
8243
  "high",
@@ -8199,7 +8739,7 @@ function userError(code, params, englishFallback) {
8199
8739
  return new CamstackError(code, params, englishFallback);
8200
8740
  }
8201
8741
  //#endregion
8202
- //#region ../types/dist/err-msg-DLerKiVO.mjs
8742
+ //#region ../types/dist/err-msg--2RrYiLO.mjs
8203
8743
  var DeviceType = /* @__PURE__ */ function(DeviceType) {
8204
8744
  DeviceType["Camera"] = "camera";
8205
8745
  DeviceType["Hub"] = "hub";
@@ -8468,6 +9008,9 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
8468
9008
  /** Virtual HA toggle (input_boolean.*) — distinguishable from a
8469
9009
  * real Switch device for UI rendering / export adapters. */
8470
9010
  DeviceRole["BinaryHelper"] = "binary-helper";
9011
+ /** A smart plug: a `switch` whose source says it is an outlet (HA
9012
+ * `device_class: outlet`). The Alexa export shows it as a SMARTPLUG. */
9013
+ DeviceRole["Outlet"] = "outlet";
8471
9014
  /** Generic motion / occupancy / moving event source. Distinct from
8472
9015
  * the camera accessory PirSensor role: that one is a camera child;
8473
9016
  * this is a standalone HA / 3rd-party motion sensor. */
@@ -8535,7 +9078,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
8535
9078
  return DeviceRole;
8536
9079
  }({});
8537
9080
  //#endregion
8538
- //#region ../types/dist/composition-EQ9Ok0Ee.mjs
9081
+ //#region ../types/dist/composition-DOwQB_Ua.mjs
8539
9082
  /**
8540
9083
  * The ffmpeg build every CamStack node downloads, per platform and arch.
8541
9084
  *
@@ -11856,11 +12399,10 @@ var ClipModelMetaSchema = object({
11856
12399
  /**
11857
12400
  * The `vector-store` index this model's vectors live in. ONE feature space
11858
12401
  * per index: two models share an index only when their vectors are ranked
11859
- * against each other, which for CLIP means never across families. MobileCLIP
11860
- * S1 and S2 share `object-clip` for history (separated by the row's
11861
- * `modelId`); any other model gets its own.
12402
+ * against each other, which for CLIP means never across families. Every
12403
+ * model gets its own.
11862
12404
  */
11863
- vectorIndex: string().regex(/^object-clip(-[a-z0-9][a-z0-9-]*)?$/),
12405
+ vectorIndex: string().regex(/^object-clip-[a-z0-9][a-z0-9-]*$/),
11864
12406
  /**
11865
12407
  * The text encoder's tokenizer, a declared SIBLING file of its onnx. The name
11866
12408
  * must be unique per tokenizer: every model's siblings land in ONE flat
@@ -15506,6 +16048,41 @@ var ComposableCapabilitiesSchema = object({ caps: array(object({
15506
16048
  keyField: string()
15507
16049
  }).optional()
15508
16050
  })) });
16051
+ /**
16052
+ * The report of a one-shot "move this owner's plaintext secrets into the
16053
+ * keychain" run (D878). COUNTS only - never a value, never a ref.
16054
+ *
16055
+ * The owner runs it on its own rows, through its own write path; an operator
16056
+ * script (`scripts/hub/migrate-raw-secrets.ts`) calls the owner's cap method.
16057
+ * Dry run (`apply: false`) reports what WOULD move and changes nothing.
16058
+ */
16059
+ var RawSecretMigrationInputSchema = object({
16060
+ /** `false` (the default of the script) = report only. */
16061
+ apply: boolean() });
16062
+ var RawSecretMigrationReportSchema = object({
16063
+ apply: boolean(),
16064
+ /** Rows that can carry a secret (a profile, an enrolment). */
16065
+ rows: number().int(),
16066
+ /** Rows whose secret was plaintext when the run started. */
16067
+ raw: number().int(),
16068
+ /** Rows that already held a keychain marker when the run started. */
16069
+ markers: number().int(),
16070
+ /** Plaintext rows moved by THIS run (always 0 on a dry run). */
16071
+ migrated: number().int(),
16072
+ /** Plaintext rows left in place because the move or its read-back failed. */
16073
+ failed: number().int(),
16074
+ /** After the run: rows still holding plaintext. */
16075
+ remainingRaw: number().int(),
16076
+ /** After the run: markers the keychain could not resolve right now. */
16077
+ unresolvedMarkers: number().int(),
16078
+ /**
16079
+ * A second, redundant copy of the secrets' rows that the run found (and, on
16080
+ * `apply`, deleted after verifying the first). Owners with a single copy omit it.
16081
+ */
16082
+ redundantCopies: number().int().optional(),
16083
+ /** True when nothing is raw and every marker resolves. */
16084
+ verified: boolean()
16085
+ });
15509
16086
  /** Where a block runs. The operator chooses — a block driving a device on an
15510
16087
  * agent is the reason placement is not fixed to the hub. */
15511
16088
  var CoreBlockPlacementSchema = union([literal("hub"), string().min(1)]);
@@ -15732,6 +16309,9 @@ method(object({}), object({ blocks: array(CoreBlockSchema) }), { auth: "admin" }
15732
16309
  }), SettingsUpdateResultSchema, {
15733
16310
  kind: "mutation",
15734
16311
  auth: "admin"
16312
+ }), method(RawSecretMigrationInputSchema, RawSecretMigrationReportSchema, {
16313
+ kind: "mutation",
16314
+ auth: "admin"
15735
16315
  }), method(object({}), object({ libs: array(object({
15736
16316
  filePath: string(),
15737
16317
  content: string()
@@ -15995,6 +16575,347 @@ id: union([string(), number()]) }), {
15995
16575
  auth: "admin"
15996
16576
  });
15997
16577
  /**
16578
+ * records - an addon's own facts and documents (D881): ledgers, audit rows,
16579
+ * config documents, mirrors. The third storage API next to `ctx.settings`
16580
+ * (operator intent, D870) and device-history (numbers over time, D850).
16581
+ *
16582
+ * Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
16583
+ * crossed a process and stated by a hub in-process caller (`ctx.records` does
16584
+ * that with the addon id closed over). It is deliberately NOT in any input
16585
+ * schema, so a session can never supply it, and a call with no stamp is refused
16586
+ * `records/no-caller`. A kind is readable and writable only by its owner; other
16587
+ * addons go through the owner's capability.
16588
+ *
16589
+ * Every read is three-way: a row, `null`, or the call THROWS. A failed read is
16590
+ * never `[]`. Secret fields are never on the wire: a read shows the
16591
+ * redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
16592
+ * resolves itself, and a write may carry only a keychain marker bound to the
16593
+ * row's own ref.
16594
+ *
16595
+ * Internal: addons reach it through `ctx.records`, never directly.
16596
+ */
16597
+ var RecordIdSchema = string().min(1).max(256);
16598
+ /** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
16599
+ var RecordBodySchema = record(string(), unknown());
16600
+ var RecordInputSchema = object({
16601
+ id: RecordIdSchema,
16602
+ /** The device this row belongs to (D865 removal, per-device reads). */
16603
+ deviceId: number().int().optional(),
16604
+ /** The domain clock, ms: observed / created / opened. */
16605
+ at: number().int().optional(),
16606
+ /** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
16607
+ expiresAt: number().int().optional(),
16608
+ data: RecordBodySchema
16609
+ });
16610
+ var RecordViewSchema = object({
16611
+ id: string(),
16612
+ deviceId: number().int().nullable(),
16613
+ at: number().nullable(),
16614
+ expiresAt: number().nullable(),
16615
+ rev: number().int(),
16616
+ updatedAt: number(),
16617
+ data: RecordBodySchema
16618
+ });
16619
+ /** Declared index fields only. Anything else does not compile, by design. */
16620
+ var RecordWhereSchema = record(RecordFieldPathSchema, union([
16621
+ string(),
16622
+ number(),
16623
+ boolean(),
16624
+ object({ in: array(union([
16625
+ string(),
16626
+ number(),
16627
+ boolean()
16628
+ ])).min(1).max(RECORD_BATCH_MAX) }),
16629
+ object({
16630
+ gt: union([string(), number()]).optional(),
16631
+ gte: union([string(), number()]).optional(),
16632
+ lt: union([string(), number()]).optional(),
16633
+ lte: union([string(), number()]).optional()
16634
+ }).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
16635
+ ]));
16636
+ var KindShape = { kind: RecordKindNameSchema };
16637
+ var TimeWindowShape = {
16638
+ deviceId: number().int().optional(),
16639
+ atFrom: number().optional(),
16640
+ atTo: number().optional()
16641
+ };
16642
+ var RecordQueryInputSchema = object({
16643
+ ...KindShape,
16644
+ ...TimeWindowShape,
16645
+ where: RecordWhereSchema.optional(),
16646
+ /** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
16647
+ order: _enum(["at", "id"]).optional(),
16648
+ desc: boolean().optional(),
16649
+ limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
16650
+ /** Opaque keyset cursor from a previous answer. There is no offset. */
16651
+ cursor: string().min(1).optional()
16652
+ });
16653
+ var RecordQueryResultSchema = object({
16654
+ records: array(RecordViewSchema),
16655
+ nextCursor: string().nullable()
16656
+ });
16657
+ var RecordKindStateSchema = _enum([
16658
+ "created",
16659
+ "unchanged",
16660
+ "updated"
16661
+ ]);
16662
+ var DeclareKindResultSchema = object({
16663
+ kindId: number().int(),
16664
+ state: RecordKindStateSchema,
16665
+ createdIndexes: array(string()),
16666
+ /** The boot guard: the kind is empty while its legacy table still holds rows. */
16667
+ adoptionPending: object({
16668
+ legacyTable: string(),
16669
+ legacyRows: number().int()
16670
+ }).nullable()
16671
+ });
16672
+ /** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
16673
+ var SecretRefsList = array(string());
16674
+ var RecordSecretRefsSchema = record(string(), record(string(), string()));
16675
+ method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
16676
+ kind: "mutation",
16677
+ auth: "admin"
16678
+ }), method(object({
16679
+ ...KindShape,
16680
+ id: RecordIdSchema
16681
+ }), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
16682
+ ...KindShape,
16683
+ ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
16684
+ }), array(RecordViewSchema), { auth: "admin" }), method(object({
16685
+ ...KindShape,
16686
+ ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
16687
+ }), RecordSecretRefsSchema, { auth: "admin" }), method(object({
16688
+ ...KindShape,
16689
+ record: RecordInputSchema,
16690
+ /** Compare-and-set. `0` means "the row must not exist". */
16691
+ ifRev: number().int().min(0).optional()
16692
+ }), object({
16693
+ rev: number().int(),
16694
+ releasedRefs: SecretRefsList
16695
+ }), {
16696
+ kind: "mutation",
16697
+ auth: "admin"
16698
+ }), method(object({
16699
+ ...KindShape,
16700
+ records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
16701
+ }), object({
16702
+ count: number().int(),
16703
+ releasedRefs: SecretRefsList
16704
+ }), {
16705
+ kind: "mutation",
16706
+ auth: "admin"
16707
+ }), method(object({
16708
+ ...KindShape,
16709
+ id: RecordIdSchema,
16710
+ data: RecordBodySchema,
16711
+ at: number().int().nullable().optional(),
16712
+ expiresAt: number().int().nullable().optional(),
16713
+ ifRev: number().int().min(1).optional()
16714
+ }), object({
16715
+ rev: number().int(),
16716
+ releasedRefs: SecretRefsList
16717
+ }), {
16718
+ kind: "mutation",
16719
+ auth: "admin"
16720
+ }), method(object({
16721
+ ...KindShape,
16722
+ id: RecordIdSchema
16723
+ }), object({
16724
+ deleted: boolean(),
16725
+ secretRefs: SecretRefsList
16726
+ }), {
16727
+ kind: "mutation",
16728
+ auth: "admin"
16729
+ }), method(object({
16730
+ ...KindShape,
16731
+ ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
16732
+ }), object({
16733
+ deleted: number().int(),
16734
+ secretRefs: SecretRefsList
16735
+ }), {
16736
+ kind: "mutation",
16737
+ auth: "admin"
16738
+ }), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
16739
+ ...KindShape,
16740
+ ...TimeWindowShape,
16741
+ where: RecordWhereSchema.optional()
16742
+ }), object({ count: number().int() }), { auth: "admin" }), method(object({
16743
+ ...KindShape,
16744
+ deviceId: number().int().optional(),
16745
+ from: number(),
16746
+ to: number(),
16747
+ bucketMs: number().int().positive()
16748
+ }), object({ buckets: array(object({
16749
+ bucketStart: number(),
16750
+ count: number().int()
16751
+ })) }), { auth: "admin" }), method(object({
16752
+ ...KindShape,
16753
+ op: _enum([
16754
+ "sum",
16755
+ "min",
16756
+ "max",
16757
+ "count"
16758
+ ]),
16759
+ field: RecordFieldPathSchema.optional(),
16760
+ groupBy: RecordFieldPathSchema.optional(),
16761
+ where: RecordWhereSchema.optional()
16762
+ }), object({ rows: array(object({
16763
+ group: union([
16764
+ string(),
16765
+ number(),
16766
+ _null()
16767
+ ]),
16768
+ value: number().nullable()
16769
+ })) }), { auth: "admin" }), method(object({
16770
+ ...KindShape,
16771
+ deviceId: number().int().optional(),
16772
+ atBefore: number().optional(),
16773
+ where: RecordWhereSchema.optional()
16774
+ }), object({
16775
+ deleted: number().int(),
16776
+ secretRefs: SecretRefsList
16777
+ }), {
16778
+ kind: "mutation",
16779
+ auth: "admin"
16780
+ }), method(object({
16781
+ deviceId: number().int(),
16782
+ kinds: array(RecordKindNameSchema).optional()
16783
+ }), object({
16784
+ deleted: record(string(), number().int()),
16785
+ secretRefs: SecretRefsList
16786
+ }), {
16787
+ kind: "mutation",
16788
+ auth: "admin"
16789
+ }), method(object(KindShape), object({ id: number().int() }), {
16790
+ kind: "mutation",
16791
+ auth: "admin"
16792
+ });
16793
+ /** One table of the settings database. */
16794
+ var StorageTableSchema = object({
16795
+ /** The table's full name, e.g. `recorder:addon-settings` or `addon-device-settings`. */
16796
+ name: string(),
16797
+ /** The owner prefix of a scoped name (`recorder` for `recorder:addon-settings`), else null. */
16798
+ owner: string().nullable(),
16799
+ rows: number().int().nonnegative(),
16800
+ /** Bytes the table's pages occupy (`dbstat`); null when the engine cannot measure. */
16801
+ bytes: number().int().nonnegative().nullable(),
16802
+ /** Declared by an addon since this engine process started (a running addon claims it). */
16803
+ declaredThisBoot: boolean()
16804
+ });
16805
+ /** One declared record kind (D881) as System -> Data shows it. */
16806
+ var StorageKindSchema = object({
16807
+ owner: string(),
16808
+ kind: string(),
16809
+ database: _enum(["settings", "events"]),
16810
+ class: string(),
16811
+ state: _enum([
16812
+ "declared",
16813
+ "orphaned",
16814
+ "dropped"
16815
+ ]),
16816
+ /** `null` when the caller asked for no counts (`counts: false`). */
16817
+ rows: number().int().nonnegative().nullable(),
16818
+ /** Rows x the average size of a sample; null for an empty kind. */
16819
+ bytesEstimate: number().int().nonnegative().nullable(),
16820
+ writeTrigger: string(),
16821
+ retention: RecordRetentionSchema,
16822
+ /** `true` when the kind is an entry kind (the generic entries UI lists it). */
16823
+ entry: boolean(),
16824
+ /** The whole declaration, secret paths and entry descriptor included (the entries service builds its handle from it). */
16825
+ declaration: RecordKindDeclarationSchema
16826
+ });
16827
+ method(object({ ownerPrefix: string().min(1).optional() }), object({ tables: array(StorageTableSchema) }), { auth: "admin" }), method(object({
16828
+ collection: string().min(1),
16829
+ expectRows: number().int().nonnegative()
16830
+ }), object({
16831
+ dropped: literal(true),
16832
+ rows: number().int().nonnegative()
16833
+ }), {
16834
+ kind: "mutation",
16835
+ auth: "admin"
16836
+ }), method(object({
16837
+ owner: string().min(1).optional(),
16838
+ /** `false` skips the per-kind row count (a catalog read only). Default true. */
16839
+ counts: boolean().optional()
16840
+ }), object({ kinds: array(StorageKindSchema) }), { auth: "admin" }), method(RecordQueryInputSchema.extend({
16841
+ owner: string().min(1),
16842
+ kind: RecordKindNameSchema
16843
+ }), RecordQueryResultSchema, { auth: "admin" }), method(object({
16844
+ owner: string().min(1),
16845
+ kind: RecordKindNameSchema,
16846
+ records: array(RecordInputSchema).max(RECORD_BATCH_MAX),
16847
+ /** The LAST batch: the copy is complete, the boot guard stops asking. */
16848
+ complete: boolean().optional()
16849
+ }).refine((input) => input.records.length > 0 || input.complete === true, { message: "records must be non-empty unless complete is true" }), object({ adopted: number().int() }), {
16850
+ kind: "mutation",
16851
+ auth: "admin"
16852
+ }), method(object({
16853
+ collection: string().min(1),
16854
+ cursor: string().optional(),
16855
+ limit: number().int().min(1).max(1e3).optional()
16856
+ }), object({
16857
+ rows: array(object({
16858
+ id: string(),
16859
+ data: record(string(), unknown())
16860
+ })),
16861
+ nextCursor: string().nullable()
16862
+ }), { auth: "admin" }), method(object({ collection: string().min(1) }), object({ adopted: boolean() }), { auth: "admin" });
16863
+ /**
16864
+ * record-entries - the ONE admin surface for every list of user-created entries
16865
+ * (D881): notification targets, brokers, LLM profiles, anything an addon
16866
+ * declares as an ENTRY kind (`entry: { title }` in `defineRecordKinds`).
16867
+ *
16868
+ * The UI is generic. `listEntryKinds` hands it, per kind, the JSON Schema of
16869
+ * the entry body with `secret: true` on every credential field, so a password
16870
+ * field is derived from the schema and never from a name. `putEntry` takes the
16871
+ * redaction token for an untouched secret (the stored value is kept), a string
16872
+ * for a new one, and the clear instruction to remove one. A read never carries
16873
+ * a secret value, and a locked keychain refuses the write with
16874
+ * `records/secret-unavailable` instead of storing plaintext.
16875
+ *
16876
+ * Hub-only, served in-process (it acts for each entry's owner on the keychain).
16877
+ */
16878
+ var EntryKindInfoSchema = object({
16879
+ owner: string(),
16880
+ kind: RecordKindNameSchema,
16881
+ title: string(),
16882
+ nameField: string(),
16883
+ /** JSON Schema of the body; `secret: true` marks a password field. */
16884
+ fields: record(string(), unknown()),
16885
+ secretPaths: array(string()),
16886
+ rows: number().int().nonnegative()
16887
+ });
16888
+ var EntryViewSchema = object({
16889
+ id: RecordIdSchema,
16890
+ name: string(),
16891
+ rev: number().int(),
16892
+ updatedAt: number(),
16893
+ /** Secret fields hold the redaction token. */
16894
+ data: RecordBodySchema
16895
+ });
16896
+ var EntryAddress = {
16897
+ owner: string().min(1),
16898
+ kind: RecordKindNameSchema
16899
+ };
16900
+ method(object({}), object({ kinds: array(EntryKindInfoSchema) }), { auth: "admin" }), method(object({ ...EntryAddress }), object({ entries: array(EntryViewSchema) }), { auth: "admin" }), method(object({
16901
+ ...EntryAddress,
16902
+ id: RecordIdSchema.optional(),
16903
+ data: RecordBodySchema,
16904
+ ifRev: number().int().min(1).optional()
16905
+ }), object({
16906
+ id: string(),
16907
+ rev: number().int()
16908
+ }), {
16909
+ kind: "mutation",
16910
+ auth: "admin"
16911
+ }), method(object({
16912
+ ...EntryAddress,
16913
+ id: RecordIdSchema
16914
+ }), object({ deleted: boolean() }), {
16915
+ kind: "mutation",
16916
+ auth: "admin"
16917
+ });
16918
+ /**
15998
16919
  * `keychain` — the hub's encrypted store of secret values (D787).
15999
16920
  *
16000
16921
  * Settings blobs never hold a secret: they hold a marker
@@ -16535,6 +17456,16 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
16535
17456
  kind: "mutation",
16536
17457
  auth: "admin",
16537
17458
  caller: "required"
17459
+ }), method(object({
17460
+ ref: string().min(1),
17461
+ value: string().min(1)
17462
+ }), object({
17463
+ ref: string(),
17464
+ version: number().int()
17465
+ }), {
17466
+ kind: "mutation",
17467
+ auth: "admin",
17468
+ caller: "required"
16538
17469
  }), method(object({ refs: array(string().min(1)).max(1e3) }), object({
16539
17470
  deleted: array(string()).readonly(),
16540
17471
  kept: array(object({
@@ -39004,6 +39935,9 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
39004
39935
  }), _void(), { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
39005
39936
  kind: "mutation",
39006
39937
  auth: "admin"
39938
+ }), method(RawSecretMigrationInputSchema, RawSecretMigrationReportSchema, {
39939
+ kind: "mutation",
39940
+ auth: "admin"
39007
39941
  }), method(ProfileRefInputSchema, _void(), {
39008
39942
  kind: "mutation",
39009
39943
  auth: "admin"
@@ -49449,6 +50383,41 @@ var ServerRollbackInfoSchema = object({
49449
50383
  atMs: number(),
49450
50384
  reason: string()
49451
50385
  });
50386
+ /**
50387
+ * The runner boot check (D877): the runners this node PLANNED (hub: one per
50388
+ * `resolveRunnerId` over its forked addons; agent: the runners its process
50389
+ * service holds, because only the hub plans) against the states the process
50390
+ * service reports. Kept in memory, recomputed by the same one-shot check after
50391
+ * every boot, served on `getServerPackageStatus`.
50392
+ *
50393
+ * `failed` is the D6 breaker's terminal state, `refused` a deterministic Init
50394
+ * refusal (an addon that said "I will not start, and here is why"), `missing` a
50395
+ * planned runner the process service has no entry for.
50396
+ */
50397
+ var RunnerRefusalSchema = object({
50398
+ runnerId: string(),
50399
+ addonIds: array(string()),
50400
+ reason: string()
50401
+ });
50402
+ var RunnerBootCheckSchema = object({
50403
+ checkedAtMs: number(),
50404
+ /** Runners planned for this node. */
50405
+ expected: number(),
50406
+ /** Planned runners whose process is `running`. */
50407
+ running: number(),
50408
+ failed: array(string()),
50409
+ refused: array(RunnerRefusalSchema),
50410
+ missing: array(string()),
50411
+ /**
50412
+ * Runners still on their way: `starting`, or `crashed` waiting on a backoff
50413
+ * respawn. The check is FINAL only when this is empty; until then nothing is
50414
+ * pushed and the verdict is re-evaluated on the next runner state change.
50415
+ * Optional for version skew (absent = settled).
50416
+ */
50417
+ pending: array(string()).optional(),
50418
+ /** True when the plan is the hub's (`missing` is then meaningful); false on an agent. */
50419
+ planKnown: boolean()
50420
+ });
49452
50421
  var ServerPackageStatusSchema = object({
49453
50422
  /** Root package name (`@camstack/server` on the hub). */
49454
50423
  packageName: string(),
@@ -49511,7 +50480,14 @@ var ServerPackageStatusSchema = object({
49511
50480
  * for version skew: an older provider's payload simply omits it, and an
49512
50481
  * absent wrapper is unknown — never `native`.
49513
50482
  */
49514
- wrapper: WrapperIdentitySchema.optional()
50483
+ wrapper: WrapperIdentitySchema.optional(),
50484
+ /**
50485
+ * What this node PLANNED to run against what its process service reports
50486
+ * (D877). Absent until the one-shot boot check has run (~60 s after boot) and
50487
+ * on a provider that predates it. Absent is "not checked yet", never "all
50488
+ * well": a consumer that needs the answer treats it as pending.
50489
+ */
50490
+ runners: RunnerBootCheckSchema.optional()
49515
50491
  });
49516
50492
  var ServerUpdateCheckResultSchema = object({
49517
50493
  packageName: string(),
@@ -49562,6 +50538,13 @@ var ServerUpdateOutcomeSchema = _enum([
49562
50538
  "refused",
49563
50539
  "failed"
49564
50540
  ]);
50541
+ /** One addon the pre-flight found the target version would refuse (D877). */
50542
+ var UpdateBlockerSchema = object({
50543
+ addonId: string(),
50544
+ reason: string(),
50545
+ /** What the operator does about it. */
50546
+ remedy: string()
50547
+ });
49565
50548
  var ServerUpdateActionResultSchema = object({
49566
50549
  accepted: boolean(),
49567
50550
  targetVersion: string().nullable(),
@@ -49579,14 +50562,27 @@ var ServerUpdateActionResultSchema = object({
49579
50562
  * The failure itself, verbatim enough to act on (the npm output for a
49580
50563
  * staging install). Non-null only for `failed`.
49581
50564
  */
49582
- error: string().nullable().optional()
50565
+ error: string().nullable().optional(),
50566
+ /**
50567
+ * The addons the target version would refuse to start on this node's live
50568
+ * store (D877), present when the pre-flight refused the update
50569
+ * (`reason: 'addon-would-refuse'`). Optional for version skew.
50570
+ */
50571
+ blockers: array(UpdateBlockerSchema).optional()
49583
50572
  });
49584
50573
  method(_void(), ServerPackageStatusSchema, { auth: "admin" }), method(_void(), ServerUpdateCheckResultSchema, {
49585
50574
  kind: "mutation",
49586
50575
  auth: "admin"
49587
- }), method(object({
49588
- /** Explicit target version; omitted = latest from the registry. */
49589
- version: string().optional() }), ServerUpdateActionResultSchema, {
50576
+ }), method(object({
50577
+ /** Explicit target version; omitted = latest from the registry. */
50578
+ version: string().optional(),
50579
+ /**
50580
+ * Apply even though the pre-flight (D877) found addons the target would
50581
+ * refuse to start. Off by default: those addons stay down until the
50582
+ * remedy is run, which is the incident this gate exists to prevent.
50583
+ */
50584
+ acknowledgeRefusals: boolean().optional()
50585
+ }), ServerUpdateActionResultSchema, {
49590
50586
  kind: "mutation",
49591
50587
  auth: "admin",
49592
50588
  timeoutMs: 16 * 6e4
@@ -51999,7 +52995,9 @@ var ManifestShapeSchema = object({
51999
52995
  var AddonProcessSchema = object({
52000
52996
  pid: number().optional(),
52001
52997
  mode: string(),
52002
- state: string()
52998
+ state: string(),
52999
+ /** Why the runner is `refused` (an addon's own words), when it is (D877). */
53000
+ reason: string().optional()
52003
53001
  });
52004
53002
  /**
52005
53003
  * Per-addon health snapshot from the kernel's AddonHealthMonitor.
@@ -53002,6 +54000,12 @@ object({
53002
54000
  /** Horizontal louver swing on/off. Null when the device has no
53003
54001
  * horizontal swing surface (gate with `DeviceFeature.ClimateSwingHorizontal`). */
53004
54002
  swingHorizontal: boolean().nullable(),
54003
+ /** Lowest setpoint the device accepts, Celsius. Absent / null = not reported. */
54004
+ minTemp: number().nullable().optional(),
54005
+ /** Highest setpoint the device accepts, Celsius. Absent / null = not reported. */
54006
+ maxTemp: number().nullable().optional(),
54007
+ /** Setpoint granularity, Celsius (0.5, 1). Absent / null = not reported. */
54008
+ tempStep: number().positive().nullable().optional(),
53005
54009
  /** Ms epoch when the slice was last updated (push or command). */
53006
54010
  lastFetchedAt: number()
53007
54011
  });
@@ -54822,7 +55826,19 @@ var TlsStatusSchema = object({
54822
55826
  sans: array(string()),
54823
55827
  caCertPem: string().nullable(),
54824
55828
  reissueError: string().nullable(),
54825
- restartRequired: boolean()
55829
+ restartRequired: boolean(),
55830
+ /** An uploaded certificate is served but no CA is kept for it and it is not publicly signed (D873). */
55831
+ caMissing: boolean(),
55832
+ /** Does the hub's own generated CA carry a critical name constraint? `null` while it has none. */
55833
+ localCaConstrained: boolean().nullable(),
55834
+ /** ISO time the generated CA was replaced by a constrained one; devices must re-download it. */
55835
+ caReplacedAt: string().nullable(),
55836
+ /** The uploaded certificate kept on disk, selectable again after "Revert to generated". */
55837
+ storedUpload: object({
55838
+ leafFingerprintSha256: string(),
55839
+ validTo: string(),
55840
+ hasCa: boolean()
55841
+ }).nullable()
54826
55842
  });
54827
55843
  method(_void(), ListResultSchema), method(_void(), PreferredSchema), method(object({
54828
55844
  /**
@@ -54878,6 +55894,9 @@ method(_void(), ListResultSchema), method(_void(), PreferredSchema), method(obje
54878
55894
  }), method(_void(), object({ pem: string() })), method(_void(), TlsStatusSchema, {
54879
55895
  kind: "mutation",
54880
55896
  auth: "admin"
55897
+ }), method(_void(), TlsStatusSchema, {
55898
+ kind: "mutation",
55899
+ auth: "admin"
54881
55900
  });
54882
55901
  object({
54883
55902
  /** Lifecycle state of the lock. `jammed` means the motor reported
@@ -60007,7 +61026,11 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
60007
61026
  kind: "mutation",
60008
61027
  auth: "admin",
60009
61028
  access: "delete"
60010
- }), method(object({ userId: string() }), TotpStatusSchema, { auth: "admin" }), method(object({
61029
+ }), method(object({ userId: string() }), TotpStatusSchema, { auth: "admin" }), method(RawSecretMigrationInputSchema, RawSecretMigrationReportSchema, {
61030
+ kind: "mutation",
61031
+ auth: "admin",
61032
+ access: "create"
61033
+ }), method(object({
60011
61034
  userId: string(),
60012
61035
  code: string()
60013
61036
  }), object({ valid: boolean() }), {
@@ -62208,6 +63231,12 @@ Object.freeze({
62208
63231
  addonId: null,
62209
63232
  access: "view"
62210
63233
  },
63234
+ "coreBlocks.migrateRawSecrets": {
63235
+ capName: "core-blocks",
63236
+ capScope: "system",
63237
+ addonId: null,
63238
+ access: "create"
63239
+ },
62211
63240
  "coreBlocks.restart": {
62212
63241
  capName: "core-blocks",
62213
63242
  capScope: "system",
@@ -63894,6 +64923,12 @@ Object.freeze({
63894
64923
  addonId: null,
63895
64924
  access: "create"
63896
64925
  },
64926
+ "keychainAdmin.importSecret": {
64927
+ capName: "keychain-admin",
64928
+ capScope: "system",
64929
+ addonId: null,
64930
+ access: "create"
64931
+ },
63897
64932
  "keychainAdmin.listAudit": {
63898
64933
  capName: "keychain-admin",
63899
64934
  capScope: "system",
@@ -64062,6 +65097,12 @@ Object.freeze({
64062
65097
  addonId: null,
64063
65098
  access: "view"
64064
65099
  },
65100
+ "llm.migrateRawSecrets": {
65101
+ capName: "llm",
65102
+ capScope: "system",
65103
+ addonId: null,
65104
+ access: "create"
65105
+ },
64065
65106
  "llm.resolveModelRef": {
64066
65107
  capName: "llm",
64067
65108
  capScope: "system",
@@ -64290,6 +65331,12 @@ Object.freeze({
64290
65331
  addonId: null,
64291
65332
  access: "create"
64292
65333
  },
65334
+ "localNetwork.useStoredUploadedCertificate": {
65335
+ capName: "local-network",
65336
+ capScope: "system",
65337
+ addonId: null,
65338
+ access: "create"
65339
+ },
64293
65340
  "lockControl.getStatus": {
64294
65341
  capName: "lock-control",
64295
65342
  capScope: "device",
@@ -66942,6 +67989,30 @@ Object.freeze({
66942
67989
  addonId: null,
66943
67990
  access: "create"
66944
67991
  },
67992
+ "recordEntries.deleteEntry": {
67993
+ capName: "record-entries",
67994
+ capScope: "system",
67995
+ addonId: null,
67996
+ access: "delete"
67997
+ },
67998
+ "recordEntries.listEntries": {
67999
+ capName: "record-entries",
68000
+ capScope: "system",
68001
+ addonId: null,
68002
+ access: "view"
68003
+ },
68004
+ "recordEntries.listEntryKinds": {
68005
+ capName: "record-entries",
68006
+ capScope: "system",
68007
+ addonId: null,
68008
+ access: "view"
68009
+ },
68010
+ "recordEntries.putEntry": {
68011
+ capName: "record-entries",
68012
+ capScope: "system",
68013
+ addonId: null,
68014
+ access: "create"
68015
+ },
66945
68016
  "recording.getAvailability": {
66946
68017
  capName: "recording",
66947
68018
  capScope: "device",
@@ -67242,6 +68313,102 @@ Object.freeze({
67242
68313
  addonId: null,
67243
68314
  access: "view"
67244
68315
  },
68316
+ "records.aggregate": {
68317
+ capName: "records",
68318
+ capScope: "system",
68319
+ addonId: null,
68320
+ access: "view"
68321
+ },
68322
+ "records.allocateId": {
68323
+ capName: "records",
68324
+ capScope: "system",
68325
+ addonId: null,
68326
+ access: "create"
68327
+ },
68328
+ "records.count": {
68329
+ capName: "records",
68330
+ capScope: "system",
68331
+ addonId: null,
68332
+ access: "view"
68333
+ },
68334
+ "records.declareKinds": {
68335
+ capName: "records",
68336
+ capScope: "system",
68337
+ addonId: null,
68338
+ access: "create"
68339
+ },
68340
+ "records.delete": {
68341
+ capName: "records",
68342
+ capScope: "system",
68343
+ addonId: null,
68344
+ access: "delete"
68345
+ },
68346
+ "records.deleteDevice": {
68347
+ capName: "records",
68348
+ capScope: "system",
68349
+ addonId: null,
68350
+ access: "delete"
68351
+ },
68352
+ "records.deleteMany": {
68353
+ capName: "records",
68354
+ capScope: "system",
68355
+ addonId: null,
68356
+ access: "delete"
68357
+ },
68358
+ "records.deleteWhere": {
68359
+ capName: "records",
68360
+ capScope: "system",
68361
+ addonId: null,
68362
+ access: "delete"
68363
+ },
68364
+ "records.get": {
68365
+ capName: "records",
68366
+ capScope: "system",
68367
+ addonId: null,
68368
+ access: "view"
68369
+ },
68370
+ "records.getMany": {
68371
+ capName: "records",
68372
+ capScope: "system",
68373
+ addonId: null,
68374
+ access: "view"
68375
+ },
68376
+ "records.histogram": {
68377
+ capName: "records",
68378
+ capScope: "system",
68379
+ addonId: null,
68380
+ access: "view"
68381
+ },
68382
+ "records.patch": {
68383
+ capName: "records",
68384
+ capScope: "system",
68385
+ addonId: null,
68386
+ access: "create"
68387
+ },
68388
+ "records.put": {
68389
+ capName: "records",
68390
+ capScope: "system",
68391
+ addonId: null,
68392
+ access: "create"
68393
+ },
68394
+ "records.putMany": {
68395
+ capName: "records",
68396
+ capScope: "system",
68397
+ addonId: null,
68398
+ access: "create"
68399
+ },
68400
+ "records.query": {
68401
+ capName: "records",
68402
+ capScope: "system",
68403
+ addonId: null,
68404
+ access: "view"
68405
+ },
68406
+ "records.secretRefs": {
68407
+ capName: "records",
68408
+ capScope: "system",
68409
+ addonId: null,
68410
+ access: "view"
68411
+ },
67245
68412
  "sceneMonitor.captureReference": {
67246
68413
  capName: "scene-monitor",
67247
68414
  capScope: "device",
@@ -67674,6 +68841,48 @@ Object.freeze({
67674
68841
  addonId: null,
67675
68842
  access: "create"
67676
68843
  },
68844
+ "storageAdmin.adoptRecords": {
68845
+ capName: "storage-admin",
68846
+ capScope: "system",
68847
+ addonId: null,
68848
+ access: "create"
68849
+ },
68850
+ "storageAdmin.dropCollection": {
68851
+ capName: "storage-admin",
68852
+ capScope: "system",
68853
+ addonId: null,
68854
+ access: "delete"
68855
+ },
68856
+ "storageAdmin.isAdoptedLegacyTable": {
68857
+ capName: "storage-admin",
68858
+ capScope: "system",
68859
+ addonId: null,
68860
+ access: "view"
68861
+ },
68862
+ "storageAdmin.listKinds": {
68863
+ capName: "storage-admin",
68864
+ capScope: "system",
68865
+ addonId: null,
68866
+ access: "view"
68867
+ },
68868
+ "storageAdmin.listTables": {
68869
+ capName: "storage-admin",
68870
+ capScope: "system",
68871
+ addonId: null,
68872
+ access: "view"
68873
+ },
68874
+ "storageAdmin.readLegacyCollection": {
68875
+ capName: "storage-admin",
68876
+ capScope: "system",
68877
+ addonId: null,
68878
+ access: "view"
68879
+ },
68880
+ "storageAdmin.readRecords": {
68881
+ capName: "storage-admin",
68882
+ capScope: "system",
68883
+ addonId: null,
68884
+ access: "view"
68885
+ },
67677
68886
  "storageEvictable.evict": {
67678
68887
  capName: "storage-evictable",
67679
68888
  capScope: "system",
@@ -68586,6 +69795,12 @@ Object.freeze({
68586
69795
  addonId: null,
68587
69796
  access: "view"
68588
69797
  },
69798
+ "userManagement.migrateRawSecrets": {
69799
+ capName: "user-management",
69800
+ capScope: "system",
69801
+ addonId: null,
69802
+ access: "create"
69803
+ },
68589
69804
  "userManagement.oauthExchangeCode": {
68590
69805
  capName: "user-management",
68591
69806
  capScope: "system",
@@ -71262,6 +72477,37 @@ Object.freeze({
71262
72477
  form: "single",
71263
72478
  optional: false
71264
72479
  }],
72480
+ "records.count": [{
72481
+ name: "deviceId",
72482
+ form: "single",
72483
+ optional: true
72484
+ }],
72485
+ "records.deleteDevice": [{
72486
+ name: "deviceId",
72487
+ form: "single",
72488
+ optional: false
72489
+ }],
72490
+ "records.deleteWhere": [{
72491
+ name: "deviceId",
72492
+ form: "single",
72493
+ optional: true
72494
+ }],
72495
+ "records.histogram": [{
72496
+ name: "deviceId",
72497
+ form: "single",
72498
+ optional: true
72499
+ }],
72500
+ "records.putMany": [{
72501
+ name: "records",
72502
+ form: "object-array",
72503
+ optional: false,
72504
+ itemField: "deviceId"
72505
+ }],
72506
+ "records.query": [{
72507
+ name: "deviceId",
72508
+ form: "single",
72509
+ optional: true
72510
+ }],
71265
72511
  "sceneMonitor.captureReference": [{
71266
72512
  name: "deviceId",
71267
72513
  form: "single",
@@ -71378,6 +72624,17 @@ Object.freeze({
71378
72624
  form: "single",
71379
72625
  optional: false
71380
72626
  }],
72627
+ "storageAdmin.adoptRecords": [{
72628
+ name: "records",
72629
+ form: "object-array",
72630
+ optional: false,
72631
+ itemField: "deviceId"
72632
+ }],
72633
+ "storageAdmin.readRecords": [{
72634
+ name: "deviceId",
72635
+ form: "single",
72636
+ optional: true
72637
+ }],
71381
72638
  "streamBroker.acquireEgressTranscode": [{
71382
72639
  name: "deviceId",
71383
72640
  form: "single",
@@ -76667,163 +77924,81 @@ function createNotificationOutputProvider(deps) {
76667
77924
  }
76668
77925
  };
76669
77926
  }
76670
- //#endregion
76671
- //#region src/settings-store-port.ts
76672
- function createApiSettingsStorePort(api) {
76673
- return {
76674
- query: async (collection) => {
76675
- return (await api.settingsStore.query.query({ collection })).map((r) => ({
76676
- id: r.id,
76677
- data: r.data
76678
- }));
76679
- },
76680
- insert: async (collection, record) => {
76681
- await api.settingsStore.insert.mutate({
76682
- collection,
76683
- record: {
76684
- id: record.id,
76685
- data: { ...record.data }
76686
- }
76687
- });
76688
- },
76689
- update: async (collection, id, data) => {
76690
- await api.settingsStore.update.mutate({
76691
- collection,
76692
- id,
76693
- data
76694
- });
76695
- },
76696
- remove: async (collection, id) => {
76697
- await api.settingsStore.delete.mutate({
76698
- collection,
76699
- key: id
76700
- });
76701
- },
76702
- declareCollection: async (collection, columns) => {
76703
- await api.settingsStore.declareCollection.mutate({
76704
- collection,
76705
- columns: columns.map((c) => ({ ...c }))
76706
- });
76707
- }
76708
- };
76709
- }
76710
- /** In-memory port — a resilient fallback when no `api` is available. */
76711
- function createMemorySettingsStorePort() {
76712
- const collections = /* @__PURE__ */ new Map();
76713
- const bucket = (collection) => {
76714
- let map = collections.get(collection);
76715
- if (!map) {
76716
- map = /* @__PURE__ */ new Map();
76717
- collections.set(collection, map);
76718
- }
76719
- return map;
76720
- };
76721
- return {
76722
- query: async (collection) => [...bucket(collection).values()],
76723
- insert: async (collection, record) => {
76724
- bucket(collection).set(record.id, {
76725
- id: record.id,
76726
- data: { ...record.data }
76727
- });
76728
- },
76729
- update: async (collection, id, data) => {
76730
- bucket(collection).set(id, {
76731
- id,
76732
- data: { ...data }
76733
- });
76734
- },
76735
- remove: async (collection, id) => {
76736
- bucket(collection).delete(id);
76737
- },
76738
- declareCollection: async (collection) => {
76739
- bucket(collection);
76740
- }
76741
- };
76742
- }
77927
+ var notifiersRecordKinds = defineRecordKinds({ "notification-targets": {
77928
+ schema: TargetSchema.omit({ id: true }),
77929
+ class: "config",
77930
+ writeTrigger: "an operator creates, updates, enables/disables or deletes a notification target",
77931
+ device: "none",
77932
+ at: "none",
77933
+ retention: { none: "a row goes only on an explicit operator delete; bounded by the number of notification targets the operator configures" },
77934
+ adoptsFrom: "notifiers:notification-targets",
77935
+ entry: { title: "Notification targets" }
77936
+ } });
76743
77937
  //#endregion
76744
77938
  //#region src/target-store.ts
76745
77939
  /**
76746
- * Persistence for notification targets over the `settings-store` cap.
77940
+ * Persistence for notification targets over the `notification-targets` record
77941
+ * kind (records plan phase 2, step 17).
76747
77942
  *
76748
- * The store is addressed through a narrow `SettingsStorePort` (query / insert /
76749
- * update / remove) so the class is trivially fakeable in unit tests and never
76750
- * depends on the tRPC-shaped `AddonApi`. Rows live in the addonId-namespaced
76751
- * `notification-targets` collection (the `settings-store` cap prefixes the
76752
- * calling addon's id automatically — the store-isolation fix).
77943
+ * The store is addressed through a `RecordKindHandle<TargetBody>` — the
77944
+ * records facade handles all transport, boot-guard, and index concerns. No
77945
+ * `init()` or `declareCollection` call: kinds are declared at addon boot via
77946
+ * `ctx.records.declare(notifiersRecordKinds)` before this store is constructed.
76753
77947
  *
76754
- * A row is `{ id, data:{ name, kind, addonId, enabled, config } }`. Secrets are
76755
- * inside `config`; redaction/merge is the provider's concern (`secrets.ts`) —
76756
- * the store persists whatever it is handed verbatim.
77948
+ * A row body is `{ name, kind, addonId, enabled, config }` (the record id IS
77949
+ * the target id). Secrets inside `config` are handled at the provider level by
77950
+ * `secrets.ts` (redact on read, merge on write); the records layer stores
77951
+ * the blob verbatim.
76757
77952
  */
76758
- /** The default collection name (see `settings-store` addonId-prefix note). */
77953
+ /** Legacy collection name — kept for the adoption mapper and docs. */
76759
77954
  var TARGETS_COLLECTION = "notifiers:notification-targets";
76760
- /** KV JSON-blob shape — a single `data` column routes the row through the
76761
- * settings backend's canonical key/value path (id TEXT PK, data TEXT). */
76762
- var KV_BLOB_COLUMNS = [{
76763
- name: "data",
76764
- type: "TEXT",
76765
- notNull: true
76766
- }];
76767
- function rowToTarget(row) {
76768
- const candidate = {
76769
- id: row.id,
76770
- ...row.data
76771
- };
76772
- const parsed = TargetSchema.safeParse(candidate);
77955
+ function rowToTarget(id, data) {
77956
+ const parsed = TargetSchema.safeParse({
77957
+ id,
77958
+ ...data
77959
+ });
76773
77960
  return parsed.success ? parsed.data : null;
76774
77961
  }
76775
- function targetToData(target) {
76776
- return {
76777
- name: target.name,
76778
- kind: target.kind,
76779
- addonId: target.addonId,
76780
- enabled: target.enabled,
76781
- config: target.config
76782
- };
76783
- }
76784
- var TargetStore = class {
76785
- store;
76786
- collection;
76787
- constructor(store, collection = TARGETS_COLLECTION) {
76788
- this.store = store;
76789
- this.collection = collection;
77962
+ var TargetStore = class TargetStore {
77963
+ kind;
77964
+ constructor(kind) {
77965
+ this.kind = kind;
76790
77966
  }
76791
- /** Declare the backing collection before any read/write. The SQLite settings
76792
- * backend rejects undeclared collections (fail-fast), so this MUST run before
76793
- * `list`/`getById`/`upsert`/`delete` — mirrors addon-ai's ProfileStore.init. */
76794
- async init() {
76795
- await this.store.declareCollection(this.collection, KV_BLOB_COLUMNS);
77967
+ /** Factory: build from a declared `RecordsAccess` (after `ctx.records.declare`). */
77968
+ static of(records) {
77969
+ return new TargetStore(records.kind(notifiersRecordKinds["notification-targets"]));
76796
77970
  }
76797
77971
  async list() {
76798
- const rows = await this.store.query(this.collection);
76799
- const targets = [];
76800
- for (const row of rows) {
76801
- const target = rowToTarget(row);
76802
- if (target) targets.push(target);
77972
+ const page = await this.kind.query({ limit: 1e3 });
77973
+ const out = [];
77974
+ for (const record of page.records) {
77975
+ const target = rowToTarget(record.id, record.data);
77976
+ if (target !== null) out.push(target);
76803
77977
  }
76804
- return targets;
77978
+ return out;
76805
77979
  }
76806
77980
  async getById(id) {
76807
- const row = (await this.store.query(this.collection)).find((r) => r.id === id);
76808
- return row ? rowToTarget(row) : null;
77981
+ const row = await this.kind.get(id);
77982
+ if (row === null) return null;
77983
+ return rowToTarget(row.id, row.data);
76809
77984
  }
76810
- /** Upsert by id — inserts a new row or updates the existing one. */
77985
+ /** Upsert by id — inserts a new row or replaces the existing one. */
76811
77986
  async upsert(target) {
76812
- const exists = (await this.store.query(this.collection)).some((r) => r.id === target.id);
76813
- const data = targetToData(target);
76814
- if (exists) await this.store.update(this.collection, target.id, data);
76815
- else await this.store.insert(this.collection, {
76816
- id: target.id,
76817
- data
77987
+ const { id, ...rest } = target;
77988
+ const parsed = notifiersRecordKinds["notification-targets"].schema.safeParse(rest);
77989
+ if (!parsed.success) throw new Error(`invalid target '${id}': ${parsed.error.message}`);
77990
+ await this.kind.put({
77991
+ id,
77992
+ data: parsed.data
76818
77993
  });
76819
77994
  }
76820
77995
  async delete(id) {
76821
- await this.store.remove(this.collection, id);
77996
+ await this.kind.delete(id);
76822
77997
  }
76823
77998
  /** Flip `enabled` on an existing target. Returns the updated target, or null if absent. */
76824
77999
  async setEnabled(id, enabled) {
76825
78000
  const target = await this.getById(id);
76826
- if (!target) return null;
78001
+ if (target === null) return null;
76827
78002
  const next = {
76828
78003
  ...target,
76829
78004
  enabled
@@ -76851,10 +78026,10 @@ var NotifiersAddon = class extends BaseAddon {
76851
78026
  }
76852
78027
  async onInitialize() {
76853
78028
  const api = this.ctx.api;
76854
- const port = api ? createApiSettingsStorePort(api) : createMemorySettingsStorePort();
76855
- if (!api) this.ctx.logger.warn("notifiers: no ctx.api — targets persist in-memory only");
76856
- const store = new TargetStore(port);
76857
- await store.init();
78029
+ const records = this.ctx.records;
78030
+ if (records === void 0) throw new Error("notifiers (hub) needs ctx.records — check execution.placement");
78031
+ await records.declare(notifiersRecordKinds);
78032
+ const store = TargetStore.of(records);
76858
78033
  const listProviders = async () => {
76859
78034
  if (api === void 0) return [];
76860
78035
  const [providers, addons] = await Promise.all([api.addons.listCapabilityProviders.query({ capName: "smtp-provider" }), api.addons.list.query()]);
@@ -76935,4 +78110,4 @@ var NotifiersAddon = class extends BaseAddon {
76935
78110
  }
76936
78111
  };
76937
78112
  //#endregion
76938
- export { NotifiersAddon, NotifiersAddon as default, sendHttpPlan as _, NOTIFIERS_ADDON_ID as a, mergeSecrets as c, makeNcTargetHandlers as d, ncTargetActions as f, fetchWithTimeout as g, fetchAttachmentBytes as h, createMemorySettingsStorePort as i, passwordFieldKeys as l, DEFAULT_OUTPUT_TIMEOUT_MS as m, TargetStore as n, createNotificationOutputProvider as o, DEFAULT_MAX_ATTACHMENT_BYTES as p, createApiSettingsStorePort as r, REDACTED_MARKER as s, TARGETS_COLLECTION as t, redactForRead as u };
78113
+ export { NotifiersAddon, NotifiersAddon as default, REDACTED_MARKER as a, redactForRead as c, DEFAULT_MAX_ATTACHMENT_BYTES as d, DEFAULT_OUTPUT_TIMEOUT_MS as f, sendHttpPlan as h, createNotificationOutputProvider as i, makeNcTargetHandlers as l, fetchWithTimeout as m, TargetStore as n, mergeSecrets as o, fetchAttachmentBytes as p, NOTIFIERS_ADDON_ID as r, passwordFieldKeys as s, TARGETS_COLLECTION as t, ncTargetActions as u };