@camstack/addon-google-services 0.2.8 → 0.2.10

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.
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  let node_crypto = require("node:crypto");
6
- //#region ../types/dist/event-category-C4hVnRo8.mjs
6
+ //#region ../types/dist/event-category-BvOFi6PY.mjs
7
7
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
8
8
  EventCategory["SystemBoot"] = "system.boot";
9
9
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -67,6 +67,24 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
67
67
  * consumes this category and maps it to the `addon-crash-loop` kind.
68
68
  */
69
69
  EventCategory["AddonRunnerFailed"] = "addon.runner-failed";
70
+ /**
71
+ * A runner whose addon refused to start with a typed reason (D877) - parked
72
+ * in `refused`, never counted by the crash breaker, retried on operator
73
+ * action. One event per refusal.
74
+ */
75
+ EventCategory["AddonRunnerRefused"] = "addon.runner-refused";
76
+ /**
77
+ * A runner settled on a state (D877): `running` (READY), `crashed`, `failed` or
78
+ * `refused`. In-process telemetry for the boot check (re-evaluate while any
79
+ * runner is still pending) and the alert centre (close a recovered runner).
80
+ */
81
+ EventCategory["ProcessStateChanged"] = "process.state-changed";
82
+ /**
83
+ * The node's one-shot runner boot check (D877): planned runners against the
84
+ * process service, `degraded` when any is failed, refused or missing. The
85
+ * alert centre turns it into one alert and a direct critical push.
86
+ */
87
+ EventCategory["SystemRunnerCheck"] = "system.runner-check";
70
88
  EventCategory["AddonError"] = "addon.error";
71
89
  EventCategory["AddonPageReady"] = "addon.page-ready";
72
90
  EventCategory["AddonWidgetReady"] = "addon.widget-ready";
@@ -4109,6 +4127,12 @@ var numberProcessor = (schema, ctx, _json, _params) => {
4109
4127
  var booleanProcessor = (_schema, _ctx, json, _params) => {
4110
4128
  json.type = "boolean";
4111
4129
  };
4130
+ var bigintProcessor = (_schema, ctx, _json, _params) => {
4131
+ if (ctx.unrepresentable === "throw") throw new Error("BigInt cannot be represented in JSON Schema");
4132
+ };
4133
+ var symbolProcessor = (_schema, ctx, _json, _params) => {
4134
+ if (ctx.unrepresentable === "throw") throw new Error("Symbols cannot be represented in JSON Schema");
4135
+ };
4112
4136
  var nullProcessor = (_schema, ctx, json, _params) => {
4113
4137
  if (ctx.target === "openapi-3.0") {
4114
4138
  json.type = "string";
@@ -4116,12 +4140,17 @@ var nullProcessor = (_schema, ctx, json, _params) => {
4116
4140
  json.enum = [null];
4117
4141
  } else json.type = "null";
4118
4142
  };
4143
+ var undefinedProcessor = (_schema, ctx, _json, _params) => {
4144
+ if (ctx.unrepresentable === "throw") throw new Error("Undefined cannot be represented in JSON Schema");
4145
+ };
4119
4146
  var voidProcessor = (_schema, ctx, _json, _params) => {
4120
4147
  if (ctx.unrepresentable === "throw") throw new Error("Void cannot be represented in JSON Schema");
4121
4148
  };
4122
4149
  var neverProcessor = (_schema, _ctx, json, _params) => {
4123
4150
  json.not = {};
4124
4151
  };
4152
+ var anyProcessor = (_schema, _ctx, _json, _params) => {};
4153
+ var unknownProcessor = (_schema, _ctx, _json, _params) => {};
4125
4154
  var dateProcessor = (_schema, ctx, _json, _params) => {
4126
4155
  if (ctx.unrepresentable === "throw") throw new Error("Date cannot be represented in JSON Schema");
4127
4156
  };
@@ -4153,12 +4182,53 @@ var literalProcessor = (schema, ctx, json, _params) => {
4153
4182
  json.enum = vals;
4154
4183
  }
4155
4184
  };
4185
+ var nanProcessor = (_schema, ctx, _json, _params) => {
4186
+ if (ctx.unrepresentable === "throw") throw new Error("NaN cannot be represented in JSON Schema");
4187
+ };
4188
+ var templateLiteralProcessor = (schema, _ctx, json, _params) => {
4189
+ const _json = json;
4190
+ const pattern = schema._zod.pattern;
4191
+ if (!pattern) throw new Error("Pattern not found in template literal");
4192
+ _json.type = "string";
4193
+ _json.pattern = pattern.source;
4194
+ };
4195
+ var fileProcessor = (schema, _ctx, json, _params) => {
4196
+ const _json = json;
4197
+ const file = {
4198
+ type: "string",
4199
+ format: "binary",
4200
+ contentEncoding: "binary"
4201
+ };
4202
+ const { minimum, maximum, mime } = schema._zod.bag;
4203
+ if (minimum !== void 0) file.minLength = minimum;
4204
+ if (maximum !== void 0) file.maxLength = maximum;
4205
+ if (mime) if (mime.length === 1) {
4206
+ file.contentMediaType = mime[0];
4207
+ Object.assign(_json, file);
4208
+ } else {
4209
+ Object.assign(_json, file);
4210
+ _json.anyOf = mime.map((m) => ({ contentMediaType: m }));
4211
+ }
4212
+ else Object.assign(_json, file);
4213
+ };
4214
+ var successProcessor = (_schema, _ctx, json, _params) => {
4215
+ json.type = "boolean";
4216
+ };
4156
4217
  var customProcessor = (_schema, ctx, _json, _params) => {
4157
4218
  if (ctx.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
4158
4219
  };
4220
+ var functionProcessor = (_schema, ctx, _json, _params) => {
4221
+ if (ctx.unrepresentable === "throw") throw new Error("Function types cannot be represented in JSON Schema");
4222
+ };
4159
4223
  var transformProcessor = (_schema, ctx, _json, _params) => {
4160
4224
  if (ctx.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
4161
4225
  };
4226
+ var mapProcessor = (_schema, ctx, _json, _params) => {
4227
+ if (ctx.unrepresentable === "throw") throw new Error("Map cannot be represented in JSON Schema");
4228
+ };
4229
+ var setProcessor = (_schema, ctx, _json, _params) => {
4230
+ if (ctx.unrepresentable === "throw") throw new Error("Set cannot be represented in JSON Schema");
4231
+ };
4162
4232
  var arrayProcessor = (schema, ctx, _json, params) => {
4163
4233
  const json = _json;
4164
4234
  const def = schema._zod.def;
@@ -4363,6 +4433,12 @@ var readonlyProcessor = (schema, ctx, json, params) => {
4363
4433
  seen.ref = def.innerType;
4364
4434
  json.readOnly = true;
4365
4435
  };
4436
+ var promiseProcessor = (schema, ctx, _json, params) => {
4437
+ const def = schema._zod.def;
4438
+ process(def.innerType, ctx, params);
4439
+ const seen = ctx.seen.get(schema);
4440
+ seen.ref = def.innerType;
4441
+ };
4366
4442
  var optionalProcessor = (schema, ctx, _json, params) => {
4367
4443
  const def = schema._zod.def;
4368
4444
  process(def.innerType, ctx, params);
@@ -4375,6 +4451,81 @@ var lazyProcessor = (schema, ctx, _json, params) => {
4375
4451
  const seen = ctx.seen.get(schema);
4376
4452
  seen.ref = innerType;
4377
4453
  };
4454
+ var allProcessors = {
4455
+ string: stringProcessor,
4456
+ number: numberProcessor,
4457
+ boolean: booleanProcessor,
4458
+ bigint: bigintProcessor,
4459
+ symbol: symbolProcessor,
4460
+ null: nullProcessor,
4461
+ undefined: undefinedProcessor,
4462
+ void: voidProcessor,
4463
+ never: neverProcessor,
4464
+ any: anyProcessor,
4465
+ unknown: unknownProcessor,
4466
+ date: dateProcessor,
4467
+ enum: enumProcessor,
4468
+ literal: literalProcessor,
4469
+ nan: nanProcessor,
4470
+ template_literal: templateLiteralProcessor,
4471
+ file: fileProcessor,
4472
+ success: successProcessor,
4473
+ custom: customProcessor,
4474
+ function: functionProcessor,
4475
+ transform: transformProcessor,
4476
+ map: mapProcessor,
4477
+ set: setProcessor,
4478
+ array: arrayProcessor,
4479
+ object: objectProcessor,
4480
+ union: unionProcessor,
4481
+ intersection: intersectionProcessor,
4482
+ tuple: tupleProcessor,
4483
+ record: recordProcessor,
4484
+ nullable: nullableProcessor,
4485
+ nonoptional: nonoptionalProcessor,
4486
+ default: defaultProcessor,
4487
+ prefault: prefaultProcessor,
4488
+ catch: catchProcessor,
4489
+ pipe: pipeProcessor,
4490
+ readonly: readonlyProcessor,
4491
+ promise: promiseProcessor,
4492
+ optional: optionalProcessor,
4493
+ lazy: lazyProcessor
4494
+ };
4495
+ function toJSONSchema(input, params) {
4496
+ if ("_idmap" in input) {
4497
+ const registry = input;
4498
+ const ctx = initializeContext({
4499
+ ...params,
4500
+ processors: allProcessors
4501
+ });
4502
+ const defs = {};
4503
+ for (const entry of registry._idmap.entries()) {
4504
+ const [_, schema] = entry;
4505
+ process(schema, ctx);
4506
+ }
4507
+ const schemas = {};
4508
+ ctx.external = {
4509
+ registry,
4510
+ uri: params?.uri,
4511
+ defs
4512
+ };
4513
+ for (const entry of registry._idmap.entries()) {
4514
+ const [key, schema] = entry;
4515
+ extractDefs(ctx, schema);
4516
+ schemas[key] = finalize(ctx, schema);
4517
+ }
4518
+ if (Object.keys(defs).length > 0) schemas.__shared = { [ctx.target === "draft-2020-12" ? "$defs" : "definitions"]: defs };
4519
+ return { schemas };
4520
+ }
4521
+ const ctx = initializeContext({
4522
+ ...params,
4523
+ processors: allProcessors
4524
+ });
4525
+ process(input, ctx);
4526
+ extractDefs(ctx, input);
4527
+ return finalize(ctx, input);
4528
+ }
4378
4529
  //#endregion
4379
4530
  //#region ../../node_modules/zod/v4/classic/iso.js
4380
4531
  var ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
@@ -5391,7 +5542,7 @@ var ZodIssueCode = {
5391
5542
  var ZodFirstPartyTypeKind;
5392
5543
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5393
5544
  //#endregion
5394
- //#region ../types/dist/sleep-DRqxtc0C.mjs
5545
+ //#region ../types/dist/sleep-BOjuyoPC.mjs
5395
5546
  /**
5396
5547
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5397
5548
  * window to float samples (D455).
@@ -5508,7 +5659,7 @@ function isKeychainStoredField(field) {
5508
5659
  var SECRET_CLEAR = { $secretClear: true };
5509
5660
  /** The `'***'` token D634 redaction writes for non-admins. */
5510
5661
  var LEGACY_DEVICE_REDACTION = "***";
5511
- function isRecord$2(value) {
5662
+ function isRecord$5(value) {
5512
5663
  return typeof value === "object" && value !== null && !Array.isArray(value);
5513
5664
  }
5514
5665
  function makeSecretMarker(ref) {
@@ -5519,12 +5670,12 @@ function makeSecretMarker(ref) {
5519
5670
  }
5520
5671
  /** A stored marker: an object whose `$secret` is a non-empty string. */
5521
5672
  function isSecretMarker(value) {
5522
- if (!isRecord$2(value)) return false;
5673
+ if (!isRecord$5(value)) return false;
5523
5674
  const ref = value["$secret"];
5524
5675
  return typeof ref === "string" && ref.length > 0;
5525
5676
  }
5526
5677
  function isSecretClear(value) {
5527
- return isRecord$2(value) && value["$secretClear"] === true;
5678
+ return isRecord$5(value) && value["$secretClear"] === true;
5528
5679
  }
5529
5680
  /**
5530
5681
  * The UI view of a stored secret field value: a marker becomes "set", inline
@@ -6134,7 +6285,7 @@ var KeychainWriteRefusedError = class extends Error {
6134
6285
  }
6135
6286
  };
6136
6287
  var KEEP = { kind: "keep" };
6137
- function isRecord$1(value) {
6288
+ function isRecord$4(value) {
6138
6289
  return typeof value === "object" && value !== null && !Array.isArray(value);
6139
6290
  }
6140
6291
  function defaultMintId() {
@@ -6147,7 +6298,7 @@ function collectSecretMarkerRefs(value, out = []) {
6147
6298
  return out;
6148
6299
  }
6149
6300
  if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6150
- else if (isRecord$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6301
+ else if (isRecord$4(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6151
6302
  return out;
6152
6303
  }
6153
6304
  async function storedValueEquals(secrets, marker, candidate) {
@@ -6202,7 +6353,7 @@ function rowId(row, idKey) {
6202
6353
  return null;
6203
6354
  }
6204
6355
  async function writeArray(ctx, node, incoming, stored, fieldPath) {
6205
- const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1) : [];
6356
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$4) : [];
6206
6357
  if (!Array.isArray(incoming)) {
6207
6358
  ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6208
6359
  return {
@@ -6218,7 +6369,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6218
6369
  const kept = /* @__PURE__ */ new Set();
6219
6370
  const rows = [];
6220
6371
  for (const row of incoming) {
6221
- if (!isRecord$1(row)) {
6372
+ if (!isRecord$4(row)) {
6222
6373
  rows.push(row);
6223
6374
  continue;
6224
6375
  }
@@ -6243,7 +6394,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6243
6394
  case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6244
6395
  case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6245
6396
  case "object": {
6246
- if (!isRecord$1(incoming)) {
6397
+ if (!isRecord$4(incoming)) {
6247
6398
  if (incoming === void 0) return KEEP;
6248
6399
  ctx.deletes.push(...collectSecretMarkerRefs(stored));
6249
6400
  return {
@@ -6251,7 +6402,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6251
6402
  value: incoming
6252
6403
  };
6253
6404
  }
6254
- const storedObj = isRecord$1(stored) ? stored : {};
6405
+ const storedObj = isRecord$4(stored) ? stored : {};
6255
6406
  return {
6256
6407
  kind: "value",
6257
6408
  value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
@@ -6374,7 +6525,7 @@ async function resolveSecretMarkers(value, secrets, options = {}) {
6374
6525
  value: items
6375
6526
  };
6376
6527
  }
6377
- if (isRecord$1(v)) {
6528
+ if (isRecord$4(v)) {
6378
6529
  const out = {};
6379
6530
  for (const [k, child] of Object.entries(v)) {
6380
6531
  const s = substitute(child);
@@ -6406,7 +6557,7 @@ var SecretOverwriteRefusedError = class extends Error {
6406
6557
  this.name = "SecretOverwriteRefusedError";
6407
6558
  }
6408
6559
  };
6409
- function isRecord(value) {
6560
+ function isRecord$3(value) {
6410
6561
  return typeof value === "object" && value !== null && !Array.isArray(value);
6411
6562
  }
6412
6563
  function resolvedValue(pass, marker) {
@@ -6435,7 +6586,7 @@ function inArray(pass, incoming, stored) {
6435
6586
  return incoming.map((item, index) => {
6436
6587
  const twin = stored[index];
6437
6588
  if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
6438
- if (isRecord(item) && isRecord(twin)) return inArrayRow(pass, item, twin);
6589
+ if (isRecord$3(item) && isRecord$3(twin)) return inArrayRow(pass, item, twin);
6439
6590
  if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
6440
6591
  return item;
6441
6592
  });
@@ -6446,7 +6597,7 @@ function inArrayRow(pass, incoming, stored) {
6446
6597
  const twin = stored[key];
6447
6598
  if (isSecretMarker(twin)) {
6448
6599
  if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
6449
- } else if (isRecord(value) && isRecord(twin)) out[key] = inArrayRow(pass, value, twin);
6600
+ } else if (isRecord$3(value) && isRecord$3(twin)) out[key] = inArrayRow(pass, value, twin);
6450
6601
  else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
6451
6602
  }
6452
6603
  return out;
@@ -6454,7 +6605,7 @@ function inArrayRow(pass, incoming, stored) {
6454
6605
  async function walk(pass, incoming, stored) {
6455
6606
  if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
6456
6607
  if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
6457
- if (!isRecord(incoming) || !isRecord(stored)) return incoming;
6608
+ if (!isRecord$3(incoming) || !isRecord$3(stored)) return incoming;
6458
6609
  const out = { ...incoming };
6459
6610
  for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
6460
6611
  return out;
@@ -6485,7 +6636,7 @@ async function restoreUnchangedSecrets(input) {
6485
6636
  function isJsonEqual(a, b) {
6486
6637
  if (Object.is(a, b)) return true;
6487
6638
  if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
6488
- if (isRecord(a) && isRecord(b)) {
6639
+ if (isRecord$3(a) && isRecord$3(b)) {
6489
6640
  const keys = Object.keys(a);
6490
6641
  if (keys.length !== Object.keys(b).length) return false;
6491
6642
  return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
@@ -6509,7 +6660,7 @@ function markerKeysOf(blob, owner) {
6509
6660
  }
6510
6661
  function nodeFromStored(value, owner) {
6511
6662
  if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
6512
- if (!isRecord(value)) return null;
6663
+ if (!isRecord$3(value)) return null;
6513
6664
  const children = /* @__PURE__ */ new Map();
6514
6665
  for (const [key, child] of Object.entries(value)) {
6515
6666
  const node = nodeFromStored(child, owner);
@@ -6642,7 +6793,6 @@ function createHandle(raw, opts) {
6642
6793
  const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
6643
6794
  const readAddonStoreResult = raw.readAddonStoreResult;
6644
6795
  const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
6645
- const readDeviceStoreBatch = raw.readDeviceStoreBatch;
6646
6796
  const overrides = {
6647
6797
  readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
6648
6798
  ...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
@@ -6666,12 +6816,12 @@ function createHandle(raw, opts) {
6666
6816
  };
6667
6817
  } } : {},
6668
6818
  readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
6669
- ...readDeviceStoreBatch !== void 0 ? { readDeviceStoreBatch: async (deviceIds) => {
6670
- const rows = await readDeviceStoreBatch.call(raw, deviceIds);
6819
+ readDeviceStoreBatch: async (deviceIds) => {
6820
+ const rows = await raw.readDeviceStoreBatch(deviceIds);
6671
6821
  const out = /* @__PURE__ */ new Map();
6672
6822
  for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
6673
6823
  return out;
6674
- } } : {},
6824
+ },
6675
6825
  writeAddonStore: async (patch) => {
6676
6826
  await writeAddon(patch);
6677
6827
  },
@@ -7298,7 +7448,7 @@ var BaseAddon = class {
7298
7448
  if (!ctx) return;
7299
7449
  const addonId = ctx.id;
7300
7450
  setImmediate(() => {
7301
- ctx.api.addons?.restartAddon?.mutate({ addonId }).then(() => {
7451
+ ctx.api.addons.restartAddon.mutate({ addonId }).then(() => {
7302
7452
  ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
7303
7453
  }).catch((err) => {
7304
7454
  ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
@@ -7498,7 +7648,7 @@ var BaseAddon = class {
7498
7648
  return this._addonSecretTree;
7499
7649
  }
7500
7650
  deviceSecretTree() {
7501
- this._deviceSecretTree ??= secretTreeFromSchema(this.deviceSettingsSchema());
7651
+ this._deviceSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.deviceSettingsSchema()), this.secretStatePaths);
7502
7652
  return this._deviceSecretTree;
7503
7653
  }
7504
7654
  /**
@@ -7574,42 +7724,135 @@ var BaseAddon = class {
7574
7724
  this[timerOf] = timer;
7575
7725
  }
7576
7726
  /**
7577
- * Wrap `ctx.settings.readAddonStore()` with a short retry budget so a
7578
- * transient settings-store outage (mid-restart of sqlite-settings, tsx-watch
7579
- * swap, or any race where the SqliteSettingsBackend is between shutdown and
7580
- * re-initialize) doesn't propagate up into `initialize()` and leave the
7727
+ * Wrap `ctx.settings.readAddonStore()` with a retry budget so a transient
7728
+ * settings-store outage doesn't propagate up into `initialize()` and leave the
7581
7729
  * addon permanently broken.
7582
7730
  *
7583
- * Retry only the two known infra fingerprints. Anything else propagates so
7584
- * real bugs surface immediately. After the budget expires we fall back to
7585
- * `{}` (defaults) — the addon's first successful patch will rehydrate.
7731
+ * Two kinds of outage, two budgets:
7732
+ * - the store's own restart fingerprints (`SqliteSettingsBackend not
7733
+ * initialized`, `provider not available`): a short budget, then the addon
7734
+ * falls back to `{}` (defaults) - its first successful patch rehydrates;
7735
+ * - a TRANSPORT failure (the hub is restarting while this runner boots:
7736
+ * `discovery deadline exceeded`, `parent could not route`, a refused or
7737
+ * timed-out connection). Since D870 a runner's settings read THROWS instead
7738
+ * of answering `{}`, so without a budget a hub restart ends in a respawn
7739
+ * loop. A long, bounded budget; only after it the error propagates - the
7740
+ * addon never runs on defaults for a store it could not ask.
7741
+ * Anything else propagates immediately so real bugs surface.
7586
7742
  */
7587
7743
  async readAddonStoreWithRetry() {
7588
7744
  const settings = this.rawSettings();
7589
7745
  if (!settings) return {};
7590
- const delaysMs = [
7591
- 150,
7592
- 350,
7593
- 600,
7594
- 900
7595
- ];
7596
7746
  let lastErr;
7597
- for (let attempt = 0; attempt <= delaysMs.length; attempt++) try {
7747
+ for (let attempt = 0;; attempt++) try {
7598
7748
  const stored = await settings.readAddonStore() ?? {};
7599
7749
  this.settingsStoreReady = true;
7600
7750
  return stored;
7601
7751
  } catch (err) {
7602
7752
  lastErr = err;
7603
- const msg = err instanceof Error ? err.message : String(err);
7604
- if (!(msg.includes("SqliteSettingsBackend not initialized") || msg.includes("provider not available"))) throw err;
7605
- if (attempt === delaysMs.length) break;
7606
- await new Promise((r) => setTimeout(r, delaysMs[attempt]));
7753
+ const kind = classifyStoreError(err);
7754
+ if (kind === "permanent") throw err;
7755
+ const delay = (kind === "transport" ? TRANSPORT_RETRY_DELAYS_MS : RESTART_RETRY_DELAYS_MS)[attempt];
7756
+ if (delay === void 0) {
7757
+ if (kind === "transport") throw err;
7758
+ break;
7759
+ }
7760
+ await new Promise((r) => setTimeout(r, delay));
7607
7761
  }
7608
7762
  this.settingsStoreReady = false;
7609
7763
  this._ctx?.logger?.warn?.("readAddonStore: settings-store unavailable after retries — using defaults", { meta: { error: lastErr instanceof Error ? lastErr.message : String(lastErr) } });
7610
7764
  return {};
7611
7765
  }
7612
7766
  };
7767
+ /** The settings store's own restart fingerprints. */
7768
+ var RESTART_RETRY_DELAYS_MS = [
7769
+ 150,
7770
+ 350,
7771
+ 600,
7772
+ 900
7773
+ ];
7774
+ /** A hub restarting under a booting runner: ~100 s in total. */
7775
+ var TRANSPORT_RETRY_DELAYS_MS = [
7776
+ 150,
7777
+ 350,
7778
+ 600,
7779
+ 900,
7780
+ 2e3,
7781
+ 5e3,
7782
+ 1e4,
7783
+ 2e4,
7784
+ 3e4,
7785
+ 3e4
7786
+ ];
7787
+ var RESTART_FINGERPRINTS = ["SqliteSettingsBackend not initialized", "provider not available"];
7788
+ /** Node / socket error codes of a connection that did not happen or broke. */
7789
+ var TRANSPORT_CODES = new Set([
7790
+ "ECONNREFUSED",
7791
+ "ECONNRESET",
7792
+ "ETIMEDOUT",
7793
+ "EPIPE",
7794
+ "EHOSTUNREACH",
7795
+ "ENETUNREACH"
7796
+ ]);
7797
+ /** tRPC error codes that mean "the other side is not answering now", not "your call is wrong". */
7798
+ var UNAVAILABLE_TRPC_CODES = new Set([
7799
+ "TIMEOUT",
7800
+ "SERVICE_UNAVAILABLE",
7801
+ "BAD_GATEWAY",
7802
+ "GATEWAY_TIMEOUT"
7803
+ ]);
7804
+ /** The exact phrases OUR transport raises when it cannot reach the hub. */
7805
+ var TRANSPORT_PHRASES = [
7806
+ "discovery deadline exceeded",
7807
+ "parent could not route child unowned cap call",
7808
+ "UDS request timed out after",
7809
+ "channel closed"
7810
+ ];
7811
+ /** Moleculer error `type`s of a call that could not be served right now. */
7812
+ var MOLECULER_TRANSIENT_TYPES = new Set([
7813
+ "REQUEST_TIMEOUT",
7814
+ "SERVICE_NOT_FOUND",
7815
+ "SERVICE_NOT_AVAILABLE",
7816
+ "REQUEST_REJECTED",
7817
+ "BROKER_DISCONNECTED"
7818
+ ]);
7819
+ function stringProp(value, key) {
7820
+ if (typeof value !== "object" || value === null) return void 0;
7821
+ const found = Reflect.get(value, key);
7822
+ return typeof found === "string" ? found : void 0;
7823
+ }
7824
+ /** The code an error carries: its own, its cause's, or a tRPC `data.code`. */
7825
+ function errorCode(err) {
7826
+ const out = {};
7827
+ const cause = typeof err === "object" && err !== null ? Reflect.get(err, "cause") : void 0;
7828
+ const data = typeof err === "object" && err !== null ? Reflect.get(err, "data") : void 0;
7829
+ const node = stringProp(err, "code") ?? stringProp(cause, "code");
7830
+ if (node !== void 0) out.node = node;
7831
+ const trpc = stringProp(data, "code");
7832
+ if (trpc !== void 0) out.trpc = trpc;
7833
+ return out;
7834
+ }
7835
+ /**
7836
+ * Is a settings read failure worth retrying, and with which budget? Only
7837
+ * EXPLICIT signals count: a socket error code, a tRPC "unavailable" code, or
7838
+ * one of the exact phrases our own transport raises. A message that merely
7839
+ * contains "timed out" or "unreachable" is not evidence of anything, and
7840
+ * `settings store not wired` is a wiring bug that retrying cannot fix.
7841
+ */
7842
+ function classifyStoreError(err) {
7843
+ const message = err instanceof Error ? err.message : String(err);
7844
+ if (RESTART_FINGERPRINTS.some((f) => message.includes(f))) return "restart";
7845
+ const code = errorCode(err);
7846
+ if (code.node !== void 0 && TRANSPORT_CODES.has(code.node)) return "transport";
7847
+ if (code.trpc !== void 0 && UNAVAILABLE_TRPC_CODES.has(code.trpc)) return "transport";
7848
+ if (typeof err === "object" && err !== null) {
7849
+ if (Reflect.get(err, "retryable") === true) return "transport";
7850
+ const type = stringProp(err, "type");
7851
+ if (type !== void 0 && MOLECULER_TRANSIENT_TYPES.has(type)) return "transport";
7852
+ }
7853
+ if (TRANSPORT_PHRASES.some((f) => message.includes(f))) return "transport";
7854
+ return "permanent";
7855
+ }
7613
7856
  /**
7614
7857
  * Collect the keys of every field marked `perNode: true`, recursing into
7615
7858
  * layout containers (`group` fields and `sub-tabs` tabs) the same way
@@ -7699,6 +7942,356 @@ var PeerBytesTicketSchema = object({
7699
7942
  */
7700
7943
  declaredBytes: number().int().nonnegative().nullable()
7701
7944
  });
7945
+ /** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
7946
+ /** The files a kind may live in. `history` is device-history's (D850), never records. */
7947
+ var RECORD_DATABASES = ["settings", "events"];
7948
+ /** The classes of a kind: the `@durable` vocabulary, one authority (replaces the annotation). */
7949
+ var RECORD_CLASSES = [
7950
+ "config",
7951
+ "ledger",
7952
+ "audit",
7953
+ "mirror",
7954
+ "ephemeral"
7955
+ ];
7956
+ var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
7957
+ var RECORD_MAX_DATA_BYTES = 1024 * 1024;
7958
+ var RECORD_BATCH_MAX = 1e3;
7959
+ var RECORD_QUERY_MAX = 1e3;
7960
+ /** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
7961
+ var RECORD_SETTINGS_MAX_ROWS = 5e4;
7962
+ var PREFIX = "records/";
7963
+ /** The base of every records failure. `detail` is the human part of the message. */
7964
+ var RecordsError = class extends Error {
7965
+ code;
7966
+ detail;
7967
+ constructor(code, detail) {
7968
+ super(`${PREFIX}${code}: ${detail}`);
7969
+ this.name = "RecordsError";
7970
+ this.code = code;
7971
+ this.detail = detail;
7972
+ }
7973
+ };
7974
+ /** The keychain could not store or serve a value: explicit, never an empty string. */
7975
+ var RecordSecretUnavailableError = class extends RecordsError {
7976
+ constructor(detail) {
7977
+ super("secret-unavailable", detail);
7978
+ this.name = "RecordSecretUnavailableError";
7979
+ }
7980
+ };
7981
+ var InvalidRecordError = class extends RecordsError {
7982
+ constructor(detail) {
7983
+ super("invalid-record", detail);
7984
+ this.name = "InvalidRecordError";
7985
+ }
7986
+ };
7987
+ /** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
7988
+ var DeclarationRefusedError = class extends RecordsError {
7989
+ constructor(detail) {
7990
+ super("declaration-refused", detail);
7991
+ this.name = "DeclarationRefusedError";
7992
+ }
7993
+ };
7994
+ function defOf(schema) {
7995
+ const zodBag = Reflect.get(schema, "_zod");
7996
+ if (typeof zodBag !== "object" || zodBag === null) return {};
7997
+ const def = Reflect.get(zodBag, "def");
7998
+ if (typeof def !== "object" || def === null) return {};
7999
+ return def;
8000
+ }
8001
+ function declaredHere(schema) {
8002
+ return globalRegistry.get(schema)?.secret === true;
8003
+ }
8004
+ /** Wrapper kinds whose `innerType` is the field itself. */
8005
+ var WRAPPERS = new Set([
8006
+ "optional",
8007
+ "nullable",
8008
+ "default",
8009
+ "prefault",
8010
+ "catch",
8011
+ "readonly",
8012
+ "nonoptional"
8013
+ ]);
8014
+ /**
8015
+ * The schema layers that make up ONE field: the schema itself and every
8016
+ * wrapper below it (optional / default / nullable / readonly / catch), plus
8017
+ * both sides of a pipe (`z.preprocess` puts the real schema on `out`,
8018
+ * `.transform` on `in`).
8019
+ */
8020
+ function layersOf(schema) {
8021
+ const out = [];
8022
+ const queue = [schema];
8023
+ while (queue.length > 0) {
8024
+ const s = queue.shift();
8025
+ if (!s || out.includes(s)) continue;
8026
+ out.push(s);
8027
+ const def = defOf(s);
8028
+ if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
8029
+ if (def.type === "pipe") {
8030
+ if (def.in) queue.push(def.in);
8031
+ if (def.out) queue.push(def.out);
8032
+ }
8033
+ }
8034
+ return out;
8035
+ }
8036
+ /** True when any layer of this field declares `.meta({ secret: true })`. */
8037
+ function isZodSecret(schema) {
8038
+ return layersOf(schema).some(declaredHere);
8039
+ }
8040
+ /**
8041
+ * Every declared secret path in a config schema: dotted keys, `[]` for "each
8042
+ * element of this array" (`connection.password`, `rows[].token`). A declared
8043
+ * object or array is reported as one path and not descended into — everything
8044
+ * under it is secret.
8045
+ */
8046
+ function collectZodSecretPaths(schema, prefix = "") {
8047
+ if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
8048
+ const paths = [];
8049
+ for (const layer of layersOf(schema)) {
8050
+ const def = defOf(layer);
8051
+ if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
8052
+ else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
8053
+ else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
8054
+ else if (def.type === "intersection") {
8055
+ if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
8056
+ if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
8057
+ }
8058
+ }
8059
+ return [...new Set(paths)];
8060
+ }
8061
+ /**
8062
+ * Secret fields of a record, addressed the way a Zod schema declares them
8063
+ * (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
8064
+ * (`auth.accessToken`, `headers[].value`).
8065
+ *
8066
+ * Array elements are matched by a DECLARED id key (`secretArrayKeys`:
8067
+ * `{ headers: 'name' }`), never by index, so reordering a list keeps every
8068
+ * keychain ref (the same rule as `arrayItemFieldPath`). The concrete path of a
8069
+ * leaf names its element: `headers[X-Api].value`.
8070
+ *
8071
+ * Pure and browser-safe. Nothing here mutates: every transform returns a new value.
8072
+ */
8073
+ /** The array prefixes (declared form, e.g. `headers` or `a.headers`) of a path. */
8074
+ function parseSecretPath(path) {
8075
+ if (path.length === 0) throw new InvalidRecordError("an empty secret path");
8076
+ return path.split(".").map((raw) => {
8077
+ const each = raw.endsWith("[]");
8078
+ const key = each ? raw.slice(0, -2) : raw;
8079
+ if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
8080
+ return {
8081
+ key,
8082
+ each
8083
+ };
8084
+ });
8085
+ }
8086
+ /** The declared array prefixes of `path` that need an id key (`headers`, `a.rows`). */
8087
+ function secretArrayPrefixes(path) {
8088
+ const segments = parseSecretPath(path);
8089
+ const prefixes = [];
8090
+ const walked = [];
8091
+ for (const segment of segments) {
8092
+ walked.push(segment.key);
8093
+ if (segment.each) prefixes.push(walked.join("."));
8094
+ }
8095
+ return prefixes;
8096
+ }
8097
+ /**
8098
+ * Record kinds (D881): the declaration an addon makes of one kind of fact, the
8099
+ * Zod row schema that describes it, and the helper that turns the two into the
8100
+ * JSON the engine stores.
8101
+ *
8102
+ * A kind is declared ONCE, next to the code that owns it, and the engine's
8103
+ * reconciler creates its indexes - nothing creates DDL at runtime from a write.
8104
+ * Everything the generic machinery needs (secret fields, the entry descriptor)
8105
+ * is DERIVED from the Zod schema: `.meta({ secret: true })` marks a credential,
8106
+ * never a field name (D879).
8107
+ */
8108
+ /** A JSON field path: `trackId`, `auth.accessToken`. Charset-restricted: it is rendered into DDL. */
8109
+ var RecordFieldPathSchema = string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,63}(\.[A-Za-z_][A-Za-z0-9_]{0,63}){0,3}$/);
8110
+ var RecordIndexSchema = object({
8111
+ name: string().regex(/^[a-z][a-z0-9_]{0,31}$/),
8112
+ fields: array(RecordFieldPathSchema).min(1).max(4),
8113
+ unique: boolean().optional()
8114
+ }).strict();
8115
+ var RecordRetentionSchema = union([
8116
+ object({
8117
+ ttlMs: number().int().positive(),
8118
+ from: _enum(["at", "write"])
8119
+ }).strict(),
8120
+ object({
8121
+ maxRows: number().int().positive().optional(),
8122
+ maxRowsPerDevice: number().int().positive().optional()
8123
+ }).strict().refine((r) => r.maxRows !== void 0 || r.maxRowsPerDevice !== void 0, { message: "name maxRows, maxRowsPerDevice or both" }),
8124
+ object({
8125
+ owner: string().min(1),
8126
+ reason: string().min(1)
8127
+ }).strict(),
8128
+ object({ none: string().min(1) }).strict()
8129
+ ]);
8130
+ /** The descriptor a generic entries UI reads (D881 "generic entries"). */
8131
+ var EntryDescriptorSchema = object({
8132
+ title: string().min(1),
8133
+ /** The record body field shown as the entry's name. */
8134
+ nameField: string().min(1),
8135
+ /** JSON Schema of the entry body; `secret: true` marks a password field. */
8136
+ fields: record(string(), unknown())
8137
+ }).strict();
8138
+ /** What crosses the wire and sits in the engine's catalog: JSON only, no Zod. */
8139
+ var RecordKindDeclarationSchema = object({
8140
+ database: _enum(RECORD_DATABASES).default("settings"),
8141
+ class: _enum(RECORD_CLASSES),
8142
+ writeTrigger: string().min(1),
8143
+ device: _enum([
8144
+ "required",
8145
+ "optional",
8146
+ "none"
8147
+ ]).default("none"),
8148
+ at: _enum(["required", "none"]).default("none"),
8149
+ indexes: array(RecordIndexSchema).max(8).default([]),
8150
+ retention: RecordRetentionSchema,
8151
+ deviceRemoval: _enum(["delete", "none"]).default("none"),
8152
+ maxDataBytes: number().int().positive().max(RECORD_MAX_DATA_BYTES).default(RECORD_DEFAULT_MAX_DATA_BYTES),
8153
+ /** Derived from the Zod schema; never written by hand. */
8154
+ secretPaths: array(string().min(1)).default([]),
8155
+ /** The id key of each array that carries a secret (`{ headers: 'name' }`). */
8156
+ secretArrayKeys: record(string(), string()).default({}),
8157
+ /** The legacy table this kind adopts from; the boot guard reads it (D853: no migration code). */
8158
+ adoptsFrom: string().min(1).optional(),
8159
+ /** Kinds that must agree through `transact` sit in one file under one family name. */
8160
+ transactFamily: string().min(1).optional(),
8161
+ entry: EntryDescriptorSchema.optional()
8162
+ }).strict();
8163
+ /** The kind names: lower-case, dash separated, short enough for an index name. */
8164
+ var RecordKindNameSchema = string().regex(/^[a-z][a-z0-9-]{0,47}$/);
8165
+ /** Cross-field rules a declaration must satisfy. Throws {@link DeclarationRefusedError}. */
8166
+ function assertValidDeclaration(name, decl) {
8167
+ const refuse = (why) => {
8168
+ throw new DeclarationRefusedError(`kind "${name}": ${why}`);
8169
+ };
8170
+ if (!RecordKindNameSchema.safeParse(name).success) refuse("the name must be lower-case-dashed");
8171
+ const seen = /* @__PURE__ */ new Set();
8172
+ for (const index of decl.indexes) {
8173
+ if (seen.has(index.name)) refuse(`index name "${index.name}" is declared twice`);
8174
+ seen.add(index.name);
8175
+ }
8176
+ const { retention } = decl;
8177
+ const hasSecrets = decl.secretPaths.length > 0;
8178
+ if ("ttlMs" in retention) {
8179
+ if (retention.from === "at" && decl.at !== "required") refuse("a ttl from \"at\" needs at: \"required\"");
8180
+ if (hasSecrets) refuse("a kind with secret fields cannot use engine TTL (its keychain values would be orphaned)");
8181
+ }
8182
+ if ("maxRows" in retention || "maxRowsPerDevice" in retention) {
8183
+ if (retention.maxRowsPerDevice !== void 0 && decl.device !== "required") refuse("maxRowsPerDevice needs device: \"required\"");
8184
+ if (decl.at !== "required") refuse("a row bound trims the oldest \"at\": it needs at: \"required\"");
8185
+ if (hasSecrets) refuse("a kind with secret fields cannot use an engine row bound");
8186
+ const bound = Math.max(retention.maxRows ?? 0, retention.maxRowsPerDevice ?? 0);
8187
+ 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)`);
8188
+ }
8189
+ if (decl.deviceRemoval === "delete" && decl.device === "none") refuse("deviceRemoval: \"delete\" needs a device: \"required\" or \"optional\"");
8190
+ 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`);
8191
+ }
8192
+ function bodyFieldsOf(schema) {
8193
+ return { ...toJSONSchema(schema, {
8194
+ unrepresentable: "any",
8195
+ io: "input"
8196
+ }) };
8197
+ }
8198
+ function isRecordLike(value) {
8199
+ return typeof value === "object" && value !== null && !Array.isArray(value);
8200
+ }
8201
+ /** Does every branch of the body schema carry `field`? (A discriminated union has several.) */
8202
+ function hasNameField(json, field) {
8203
+ const branches = json["oneOf"] ?? json["anyOf"];
8204
+ if (Array.isArray(branches)) return branches.length > 0 && branches.every((b) => isRecordLike(b) && hasNameField(b, field));
8205
+ const properties = json["properties"];
8206
+ return isRecordLike(properties) && Object.prototype.hasOwnProperty.call(properties, field);
8207
+ }
8208
+ /**
8209
+ * Declare the kinds of a package. The keys are the kind names. The result is
8210
+ * what `ctx.records.declare` sends to the engine and what `ctx.records.kind`
8211
+ * types its handle from.
8212
+ */
8213
+ function defineRecordKinds(specs) {
8214
+ const out = {};
8215
+ for (const [name, spec] of Object.entries(specs)) {
8216
+ const secretPaths = collectZodSecretPaths(spec.schema);
8217
+ const nameField = spec.entry?.nameField ?? "name";
8218
+ const fields = bodyFieldsOf(spec.schema);
8219
+ if (spec.entry !== void 0 && !hasNameField(fields, nameField)) throw new DeclarationRefusedError(`kind "${name}": an entry kind's schema needs a "${nameField}" field`);
8220
+ const parsed = RecordKindDeclarationSchema.parse({
8221
+ database: spec.database,
8222
+ class: spec.class,
8223
+ writeTrigger: spec.writeTrigger,
8224
+ device: spec.device,
8225
+ at: spec.at,
8226
+ indexes: spec.indexes === void 0 ? void 0 : [...spec.indexes],
8227
+ retention: spec.retention,
8228
+ deviceRemoval: spec.deviceRemoval,
8229
+ maxDataBytes: spec.maxDataBytes,
8230
+ secretPaths: [...secretPaths],
8231
+ secretArrayKeys: spec.secretArrayKeys === void 0 ? void 0 : { ...spec.secretArrayKeys },
8232
+ adoptsFrom: spec.adoptsFrom,
8233
+ transactFamily: spec.transactFamily,
8234
+ entry: spec.entry === void 0 ? void 0 : {
8235
+ title: spec.entry.title,
8236
+ nameField,
8237
+ fields
8238
+ }
8239
+ });
8240
+ assertValidDeclaration(name, parsed);
8241
+ out[name] = {
8242
+ name,
8243
+ schema: spec.schema,
8244
+ declaration: parsed
8245
+ };
8246
+ }
8247
+ return out;
8248
+ }
8249
+ /**
8250
+ * Entry kinds (D881): every list of user-created entries (notification
8251
+ * targets, brokers, LLM profiles) is ONE record kind with an id, a name and a
8252
+ * kind-specific body, and the admin UI lists/adds/edits/deletes all of them
8253
+ * through the `record-entries` capability with password fields derived from
8254
+ * the schema (`.meta({ secret: true })`).
8255
+ */
8256
+ /** The body of a plain entry: a name and the fields the kind adds. */
8257
+ function entryBody(shape) {
8258
+ return object({
8259
+ name: string().min(1),
8260
+ ...shape
8261
+ });
8262
+ }
8263
+ /**
8264
+ * Declare one entry kind. An entry is configuration: never trimmed by the
8265
+ * engine, never aged, belonging to no device.
8266
+ */
8267
+ function defineEntryKind(name, spec) {
8268
+ const defined = defineRecordKinds({ [name]: {
8269
+ schema: spec.schema,
8270
+ class: "config",
8271
+ writeTrigger: spec.writeTrigger ?? "an operator adds or edits an entry in the entries UI",
8272
+ retention: { none: "an entry goes only when the operator deletes it" },
8273
+ ...spec.database === void 0 ? {} : { database: spec.database },
8274
+ ...spec.indexes === void 0 ? {} : { indexes: spec.indexes },
8275
+ ...spec.secretArrayKeys === void 0 ? {} : { secretArrayKeys: spec.secretArrayKeys },
8276
+ ...spec.adoptsFrom === void 0 ? {} : { adoptsFrom: spec.adoptsFrom },
8277
+ entry: {
8278
+ title: spec.title,
8279
+ ...spec.nameField === void 0 ? {} : { nameField: spec.nameField }
8280
+ }
8281
+ } })[name];
8282
+ if (defined === void 0) throw new DeclarationRefusedError(`entry kind "${name}" was not built`);
8283
+ return defined;
8284
+ }
8285
+ /**
8286
+ * Legacy source for broker entry adoption (B2): brokers live in addon-settings
8287
+ * as one row `<addonId>.brokers` whose value is an array until records-adopt
8288
+ * copies them into the entry kind.
8289
+ */
8290
+ var SETTINGS_BROKERS_ADOPTS_PREFIX = "@settings-brokers/";
8291
+ /** The `adoptsFrom` value for an addon's broker entry kind. */
8292
+ function settingsBrokersAdoptsFrom(addonId) {
8293
+ return `${SETTINGS_BROKERS_ADOPTS_PREFIX}${addonId}`;
8294
+ }
7702
8295
  /** Shared Zod schemas used across streaming capabilities. */
7703
8296
  var CamProfileSchema = _enum([
7704
8297
  "high",
@@ -8178,7 +8771,7 @@ function userError(code, params, englishFallback) {
8178
8771
  return new CamstackError(code, params, englishFallback);
8179
8772
  }
8180
8773
  //#endregion
8181
- //#region ../types/dist/err-msg-DLerKiVO.mjs
8774
+ //#region ../types/dist/err-msg-BXKzRBwg.mjs
8182
8775
  var DeviceType = /* @__PURE__ */ function(DeviceType) {
8183
8776
  DeviceType["Camera"] = "camera";
8184
8777
  DeviceType["Hub"] = "hub";
@@ -8270,6 +8863,10 @@ var DeviceType = /* @__PURE__ */ function(DeviceType) {
8270
8863
  * native PetKit (`nodepetkit` `FeederDevice`), reusable by other feeder
8271
8864
  * integrations sharing the same food/desiccant/hopper surface. */
8272
8865
  DeviceType["PetFeeder"] = "pet-feeder";
8866
+ /** Built-in dishwasher — program lifecycle, door / remote-start gates,
8867
+ * salt and rinse-aid levels. Installed with the `dishwasher` cap.
8868
+ * Sources: native Bosch Home Connect, reusable by similar integrations. */
8869
+ DeviceType["Dishwasher"] = "dishwasher";
8273
8870
  return DeviceType;
8274
8871
  }({});
8275
8872
  var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
@@ -8447,6 +9044,9 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
8447
9044
  /** Virtual HA toggle (input_boolean.*) — distinguishable from a
8448
9045
  * real Switch device for UI rendering / export adapters. */
8449
9046
  DeviceRole["BinaryHelper"] = "binary-helper";
9047
+ /** A smart plug: a `switch` whose source says it is an outlet (HA
9048
+ * `device_class: outlet`). The Alexa export shows it as a SMARTPLUG. */
9049
+ DeviceRole["Outlet"] = "outlet";
8450
9050
  /** Generic motion / occupancy / moving event source. Distinct from
8451
9051
  * the camera accessory PirSensor role: that one is a camera child;
8452
9052
  * this is a standalone HA / 3rd-party motion sensor. */
@@ -8514,7 +9114,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
8514
9114
  return DeviceRole;
8515
9115
  }({});
8516
9116
  //#endregion
8517
- //#region ../types/dist/composition-EQ9Ok0Ee.mjs
9117
+ //#region ../types/dist/composition-CB6PMT9p.mjs
8518
9118
  /**
8519
9119
  * The ffmpeg build every CamStack node downloads, per platform and arch.
8520
9120
  *
@@ -11835,11 +12435,10 @@ var ClipModelMetaSchema = object({
11835
12435
  /**
11836
12436
  * The `vector-store` index this model's vectors live in. ONE feature space
11837
12437
  * per index: two models share an index only when their vectors are ranked
11838
- * against each other, which for CLIP means never across families. MobileCLIP
11839
- * S1 and S2 share `object-clip` for history (separated by the row's
11840
- * `modelId`); any other model gets its own.
12438
+ * against each other, which for CLIP means never across families. Every
12439
+ * model gets its own.
11841
12440
  */
11842
- vectorIndex: string().regex(/^object-clip(-[a-z0-9][a-z0-9-]*)?$/),
12441
+ vectorIndex: string().regex(/^object-clip-[a-z0-9][a-z0-9-]*$/),
11843
12442
  /**
11844
12443
  * The text encoder's tokenizer, a declared SIBLING file of its onnx. The name
11845
12444
  * must be unique per tokenizer: every model's siblings land in ONE flat
@@ -13037,8 +13636,13 @@ var AlertSeveritySchema = _enum([
13037
13636
  "info",
13038
13637
  "success",
13039
13638
  "warning",
13040
- "error"
13639
+ "error",
13640
+ "critical"
13041
13641
  ]);
13642
+ var AlertActionSchema = object({
13643
+ label: string(),
13644
+ href: string().optional()
13645
+ });
13042
13646
  var AlertStatusSchema = _enum([
13043
13647
  "active",
13044
13648
  "in-progress",
@@ -13056,6 +13660,7 @@ var AlertSchema = object({
13056
13660
  severity: AlertSeveritySchema,
13057
13661
  title: string(),
13058
13662
  message: string(),
13663
+ action: AlertActionSchema.optional(),
13059
13664
  status: AlertStatusSchema,
13060
13665
  progress: number().optional(),
13061
13666
  read: boolean(),
@@ -15534,6 +16139,41 @@ var ComposableCapabilitiesSchema = object({ caps: array(object({
15534
16139
  keyField: string()
15535
16140
  }).optional()
15536
16141
  })) });
16142
+ /**
16143
+ * The report of a one-shot "move this owner's plaintext secrets into the
16144
+ * keychain" run (D878). COUNTS only - never a value, never a ref.
16145
+ *
16146
+ * The owner runs it on its own rows, through its own write path; an operator
16147
+ * script (`scripts/hub/migrate-raw-secrets.ts`) calls the owner's cap method.
16148
+ * Dry run (`apply: false`) reports what WOULD move and changes nothing.
16149
+ */
16150
+ var RawSecretMigrationInputSchema = object({
16151
+ /** `false` (the default of the script) = report only. */
16152
+ apply: boolean() });
16153
+ var RawSecretMigrationReportSchema = object({
16154
+ apply: boolean(),
16155
+ /** Rows that can carry a secret (a profile, an enrolment). */
16156
+ rows: number().int(),
16157
+ /** Rows whose secret was plaintext when the run started. */
16158
+ raw: number().int(),
16159
+ /** Rows that already held a keychain marker when the run started. */
16160
+ markers: number().int(),
16161
+ /** Plaintext rows moved by THIS run (always 0 on a dry run). */
16162
+ migrated: number().int(),
16163
+ /** Plaintext rows left in place because the move or its read-back failed. */
16164
+ failed: number().int(),
16165
+ /** After the run: rows still holding plaintext. */
16166
+ remainingRaw: number().int(),
16167
+ /** After the run: markers the keychain could not resolve right now. */
16168
+ unresolvedMarkers: number().int(),
16169
+ /**
16170
+ * A second, redundant copy of the secrets' rows that the run found (and, on
16171
+ * `apply`, deleted after verifying the first). Owners with a single copy omit it.
16172
+ */
16173
+ redundantCopies: number().int().optional(),
16174
+ /** True when nothing is raw and every marker resolves. */
16175
+ verified: boolean()
16176
+ });
15537
16177
  /** Where a block runs. The operator chooses — a block driving a device on an
15538
16178
  * agent is the reason placement is not fixed to the hub. */
15539
16179
  var CoreBlockPlacementSchema = union([literal("hub"), string().min(1)]);
@@ -15760,6 +16400,9 @@ method(object({}), object({ blocks: array(CoreBlockSchema) }), { auth: "admin" }
15760
16400
  }), SettingsUpdateResultSchema, {
15761
16401
  kind: "mutation",
15762
16402
  auth: "admin"
16403
+ }), method(RawSecretMigrationInputSchema, RawSecretMigrationReportSchema, {
16404
+ kind: "mutation",
16405
+ auth: "admin"
15763
16406
  }), method(object({}), object({ libs: array(object({
15764
16407
  filePath: string(),
15765
16408
  content: string()
@@ -16023,6 +16666,347 @@ id: union([string(), number()]) }), {
16023
16666
  auth: "admin"
16024
16667
  });
16025
16668
  /**
16669
+ * records - an addon's own facts and documents (D881): ledgers, audit rows,
16670
+ * config documents, mirrors. The third storage API next to `ctx.settings`
16671
+ * (operator intent, D870) and device-history (numbers over time, D850).
16672
+ *
16673
+ * Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
16674
+ * crossed a process and stated by a hub in-process caller (`ctx.records` does
16675
+ * that with the addon id closed over). It is deliberately NOT in any input
16676
+ * schema, so a session can never supply it, and a call with no stamp is refused
16677
+ * `records/no-caller`. A kind is readable and writable only by its owner; other
16678
+ * addons go through the owner's capability.
16679
+ *
16680
+ * Every read is three-way: a row, `null`, or the call THROWS. A failed read is
16681
+ * never `[]`. Secret fields are never on the wire: a read shows the
16682
+ * redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
16683
+ * resolves itself, and a write may carry only a keychain marker bound to the
16684
+ * row's own ref.
16685
+ *
16686
+ * Internal: addons reach it through `ctx.records`, never directly.
16687
+ */
16688
+ var RecordIdSchema = string().min(1).max(256);
16689
+ /** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
16690
+ var RecordBodySchema = record(string(), unknown());
16691
+ var RecordInputSchema = object({
16692
+ id: RecordIdSchema,
16693
+ /** The device this row belongs to (D865 removal, per-device reads). */
16694
+ deviceId: number().int().optional(),
16695
+ /** The domain clock, ms: observed / created / opened. */
16696
+ at: number().int().optional(),
16697
+ /** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
16698
+ expiresAt: number().int().optional(),
16699
+ data: RecordBodySchema
16700
+ });
16701
+ var RecordViewSchema = object({
16702
+ id: string(),
16703
+ deviceId: number().int().nullable(),
16704
+ at: number().nullable(),
16705
+ expiresAt: number().nullable(),
16706
+ rev: number().int(),
16707
+ updatedAt: number(),
16708
+ data: RecordBodySchema
16709
+ });
16710
+ /** Declared index fields only. Anything else does not compile, by design. */
16711
+ var RecordWhereSchema = record(RecordFieldPathSchema, union([
16712
+ string(),
16713
+ number(),
16714
+ boolean(),
16715
+ object({ in: array(union([
16716
+ string(),
16717
+ number(),
16718
+ boolean()
16719
+ ])).min(1).max(RECORD_BATCH_MAX) }),
16720
+ object({
16721
+ gt: union([string(), number()]).optional(),
16722
+ gte: union([string(), number()]).optional(),
16723
+ lt: union([string(), number()]).optional(),
16724
+ lte: union([string(), number()]).optional()
16725
+ }).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
16726
+ ]));
16727
+ var KindShape = { kind: RecordKindNameSchema };
16728
+ var TimeWindowShape = {
16729
+ deviceId: number().int().optional(),
16730
+ atFrom: number().optional(),
16731
+ atTo: number().optional()
16732
+ };
16733
+ var RecordQueryInputSchema = object({
16734
+ ...KindShape,
16735
+ ...TimeWindowShape,
16736
+ where: RecordWhereSchema.optional(),
16737
+ /** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
16738
+ order: _enum(["at", "id"]).optional(),
16739
+ desc: boolean().optional(),
16740
+ limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
16741
+ /** Opaque keyset cursor from a previous answer. There is no offset. */
16742
+ cursor: string().min(1).optional()
16743
+ });
16744
+ var RecordQueryResultSchema = object({
16745
+ records: array(RecordViewSchema),
16746
+ nextCursor: string().nullable()
16747
+ });
16748
+ var RecordKindStateSchema = _enum([
16749
+ "created",
16750
+ "unchanged",
16751
+ "updated"
16752
+ ]);
16753
+ var DeclareKindResultSchema = object({
16754
+ kindId: number().int(),
16755
+ state: RecordKindStateSchema,
16756
+ createdIndexes: array(string()),
16757
+ /** The boot guard: the kind is empty while its legacy table still holds rows. */
16758
+ adoptionPending: object({
16759
+ legacyTable: string(),
16760
+ legacyRows: number().int()
16761
+ }).nullable()
16762
+ });
16763
+ /** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
16764
+ var SecretRefsList = array(string());
16765
+ var RecordSecretRefsSchema = record(string(), record(string(), string()));
16766
+ method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
16767
+ kind: "mutation",
16768
+ auth: "admin"
16769
+ }), method(object({
16770
+ ...KindShape,
16771
+ id: RecordIdSchema
16772
+ }), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
16773
+ ...KindShape,
16774
+ ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
16775
+ }), array(RecordViewSchema), { auth: "admin" }), method(object({
16776
+ ...KindShape,
16777
+ ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
16778
+ }), RecordSecretRefsSchema, { auth: "admin" }), method(object({
16779
+ ...KindShape,
16780
+ record: RecordInputSchema,
16781
+ /** Compare-and-set. `0` means "the row must not exist". */
16782
+ ifRev: number().int().min(0).optional()
16783
+ }), object({
16784
+ rev: number().int(),
16785
+ releasedRefs: SecretRefsList
16786
+ }), {
16787
+ kind: "mutation",
16788
+ auth: "admin"
16789
+ }), method(object({
16790
+ ...KindShape,
16791
+ records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
16792
+ }), object({
16793
+ count: number().int(),
16794
+ releasedRefs: SecretRefsList
16795
+ }), {
16796
+ kind: "mutation",
16797
+ auth: "admin"
16798
+ }), method(object({
16799
+ ...KindShape,
16800
+ id: RecordIdSchema,
16801
+ data: RecordBodySchema,
16802
+ at: number().int().nullable().optional(),
16803
+ expiresAt: number().int().nullable().optional(),
16804
+ ifRev: number().int().min(1).optional()
16805
+ }), object({
16806
+ rev: number().int(),
16807
+ releasedRefs: SecretRefsList
16808
+ }), {
16809
+ kind: "mutation",
16810
+ auth: "admin"
16811
+ }), method(object({
16812
+ ...KindShape,
16813
+ id: RecordIdSchema
16814
+ }), object({
16815
+ deleted: boolean(),
16816
+ secretRefs: SecretRefsList
16817
+ }), {
16818
+ kind: "mutation",
16819
+ auth: "admin"
16820
+ }), method(object({
16821
+ ...KindShape,
16822
+ ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
16823
+ }), object({
16824
+ deleted: number().int(),
16825
+ secretRefs: SecretRefsList
16826
+ }), {
16827
+ kind: "mutation",
16828
+ auth: "admin"
16829
+ }), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
16830
+ ...KindShape,
16831
+ ...TimeWindowShape,
16832
+ where: RecordWhereSchema.optional()
16833
+ }), object({ count: number().int() }), { auth: "admin" }), method(object({
16834
+ ...KindShape,
16835
+ deviceId: number().int().optional(),
16836
+ from: number(),
16837
+ to: number(),
16838
+ bucketMs: number().int().positive()
16839
+ }), object({ buckets: array(object({
16840
+ bucketStart: number(),
16841
+ count: number().int()
16842
+ })) }), { auth: "admin" }), method(object({
16843
+ ...KindShape,
16844
+ op: _enum([
16845
+ "sum",
16846
+ "min",
16847
+ "max",
16848
+ "count"
16849
+ ]),
16850
+ field: RecordFieldPathSchema.optional(),
16851
+ groupBy: RecordFieldPathSchema.optional(),
16852
+ where: RecordWhereSchema.optional()
16853
+ }), object({ rows: array(object({
16854
+ group: union([
16855
+ string(),
16856
+ number(),
16857
+ _null()
16858
+ ]),
16859
+ value: number().nullable()
16860
+ })) }), { auth: "admin" }), method(object({
16861
+ ...KindShape,
16862
+ deviceId: number().int().optional(),
16863
+ atBefore: number().optional(),
16864
+ where: RecordWhereSchema.optional()
16865
+ }), object({
16866
+ deleted: number().int(),
16867
+ secretRefs: SecretRefsList
16868
+ }), {
16869
+ kind: "mutation",
16870
+ auth: "admin"
16871
+ }), method(object({
16872
+ deviceId: number().int(),
16873
+ kinds: array(RecordKindNameSchema).optional()
16874
+ }), object({
16875
+ deleted: record(string(), number().int()),
16876
+ secretRefs: SecretRefsList
16877
+ }), {
16878
+ kind: "mutation",
16879
+ auth: "admin"
16880
+ }), method(object(KindShape), object({ id: number().int() }), {
16881
+ kind: "mutation",
16882
+ auth: "admin"
16883
+ });
16884
+ /** One table of the settings database. */
16885
+ var StorageTableSchema = object({
16886
+ /** The table's full name, e.g. `recorder:addon-settings` or `addon-device-settings`. */
16887
+ name: string(),
16888
+ /** The owner prefix of a scoped name (`recorder` for `recorder:addon-settings`), else null. */
16889
+ owner: string().nullable(),
16890
+ rows: number().int().nonnegative(),
16891
+ /** Bytes the table's pages occupy (`dbstat`); null when the engine cannot measure. */
16892
+ bytes: number().int().nonnegative().nullable(),
16893
+ /** Declared by an addon since this engine process started (a running addon claims it). */
16894
+ declaredThisBoot: boolean()
16895
+ });
16896
+ /** One declared record kind (D881) as System -> Data shows it. */
16897
+ var StorageKindSchema = object({
16898
+ owner: string(),
16899
+ kind: string(),
16900
+ database: _enum(["settings", "events"]),
16901
+ class: string(),
16902
+ state: _enum([
16903
+ "declared",
16904
+ "orphaned",
16905
+ "dropped"
16906
+ ]),
16907
+ /** `null` when the caller asked for no counts (`counts: false`). */
16908
+ rows: number().int().nonnegative().nullable(),
16909
+ /** Rows x the average size of a sample; null for an empty kind. */
16910
+ bytesEstimate: number().int().nonnegative().nullable(),
16911
+ writeTrigger: string(),
16912
+ retention: RecordRetentionSchema,
16913
+ /** `true` when the kind is an entry kind (the generic entries UI lists it). */
16914
+ entry: boolean(),
16915
+ /** The whole declaration, secret paths and entry descriptor included (the entries service builds its handle from it). */
16916
+ declaration: RecordKindDeclarationSchema
16917
+ });
16918
+ method(object({ ownerPrefix: string().min(1).optional() }), object({ tables: array(StorageTableSchema) }), { auth: "admin" }), method(object({
16919
+ collection: string().min(1),
16920
+ expectRows: number().int().nonnegative()
16921
+ }), object({
16922
+ dropped: literal(true),
16923
+ rows: number().int().nonnegative()
16924
+ }), {
16925
+ kind: "mutation",
16926
+ auth: "admin"
16927
+ }), method(object({
16928
+ owner: string().min(1).optional(),
16929
+ /** `false` skips the per-kind row count (a catalog read only). Default true. */
16930
+ counts: boolean().optional()
16931
+ }), object({ kinds: array(StorageKindSchema) }), { auth: "admin" }), method(RecordQueryInputSchema.extend({
16932
+ owner: string().min(1),
16933
+ kind: RecordKindNameSchema
16934
+ }), RecordQueryResultSchema, { auth: "admin" }), method(object({
16935
+ owner: string().min(1),
16936
+ kind: RecordKindNameSchema,
16937
+ records: array(RecordInputSchema).max(RECORD_BATCH_MAX),
16938
+ /** The LAST batch: the copy is complete, the boot guard stops asking. */
16939
+ complete: boolean().optional()
16940
+ }).refine((input) => input.records.length > 0 || input.complete === true, { message: "records must be non-empty unless complete is true" }), object({ adopted: number().int() }), {
16941
+ kind: "mutation",
16942
+ auth: "admin"
16943
+ }), method(object({
16944
+ collection: string().min(1),
16945
+ cursor: string().optional(),
16946
+ limit: number().int().min(1).max(1e3).optional()
16947
+ }), object({
16948
+ rows: array(object({
16949
+ id: string(),
16950
+ data: record(string(), unknown())
16951
+ })),
16952
+ nextCursor: string().nullable()
16953
+ }), { auth: "admin" }), method(object({ collection: string().min(1) }), object({ adopted: boolean() }), { auth: "admin" });
16954
+ /**
16955
+ * record-entries - the ONE admin surface for every list of user-created entries
16956
+ * (D881): notification targets, brokers, LLM profiles, anything an addon
16957
+ * declares as an ENTRY kind (`entry: { title }` in `defineRecordKinds`).
16958
+ *
16959
+ * The UI is generic. `listEntryKinds` hands it, per kind, the JSON Schema of
16960
+ * the entry body with `secret: true` on every credential field, so a password
16961
+ * field is derived from the schema and never from a name. `putEntry` takes the
16962
+ * redaction token for an untouched secret (the stored value is kept), a string
16963
+ * for a new one, and the clear instruction to remove one. A read never carries
16964
+ * a secret value, and a locked keychain refuses the write with
16965
+ * `records/secret-unavailable` instead of storing plaintext.
16966
+ *
16967
+ * Hub-only, served in-process (it acts for each entry's owner on the keychain).
16968
+ */
16969
+ var EntryKindInfoSchema = object({
16970
+ owner: string(),
16971
+ kind: RecordKindNameSchema,
16972
+ title: string(),
16973
+ nameField: string(),
16974
+ /** JSON Schema of the body; `secret: true` marks a password field. */
16975
+ fields: record(string(), unknown()),
16976
+ secretPaths: array(string()),
16977
+ rows: number().int().nonnegative()
16978
+ });
16979
+ var EntryViewSchema = object({
16980
+ id: RecordIdSchema,
16981
+ name: string(),
16982
+ rev: number().int(),
16983
+ updatedAt: number(),
16984
+ /** Secret fields hold the redaction token. */
16985
+ data: RecordBodySchema
16986
+ });
16987
+ var EntryAddress = {
16988
+ owner: string().min(1),
16989
+ kind: RecordKindNameSchema
16990
+ };
16991
+ method(object({}), object({ kinds: array(EntryKindInfoSchema) }), { auth: "admin" }), method(object({ ...EntryAddress }), object({ entries: array(EntryViewSchema) }), { auth: "admin" }), method(object({
16992
+ ...EntryAddress,
16993
+ id: RecordIdSchema.optional(),
16994
+ data: RecordBodySchema,
16995
+ ifRev: number().int().min(1).optional()
16996
+ }), object({
16997
+ id: string(),
16998
+ rev: number().int()
16999
+ }), {
17000
+ kind: "mutation",
17001
+ auth: "admin"
17002
+ }), method(object({
17003
+ ...EntryAddress,
17004
+ id: RecordIdSchema
17005
+ }), object({ deleted: boolean() }), {
17006
+ kind: "mutation",
17007
+ auth: "admin"
17008
+ });
17009
+ /**
16026
17010
  * `keychain` — the hub's encrypted store of secret values (D787).
16027
17011
  *
16028
17012
  * Settings blobs never hold a secret: they hold a marker
@@ -16563,6 +17547,16 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
16563
17547
  kind: "mutation",
16564
17548
  auth: "admin",
16565
17549
  caller: "required"
17550
+ }), method(object({
17551
+ ref: string().min(1),
17552
+ value: string().min(1)
17553
+ }), object({
17554
+ ref: string(),
17555
+ version: number().int()
17556
+ }), {
17557
+ kind: "mutation",
17558
+ auth: "admin",
17559
+ caller: "required"
16566
17560
  }), method(object({ refs: array(string().min(1)).max(1e3) }), object({
16567
17561
  deleted: array(string()).readonly(),
16568
17562
  kept: array(object({
@@ -39032,6 +40026,9 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
39032
40026
  }), _void(), { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
39033
40027
  kind: "mutation",
39034
40028
  auth: "admin"
40029
+ }), method(RawSecretMigrationInputSchema, RawSecretMigrationReportSchema, {
40030
+ kind: "mutation",
40031
+ auth: "admin"
39035
40032
  }), method(ProfileRefInputSchema, _void(), {
39036
40033
  kind: "mutation",
39037
40034
  auth: "admin"
@@ -49455,6 +50452,41 @@ var ServerRollbackInfoSchema = object({
49455
50452
  atMs: number(),
49456
50453
  reason: string()
49457
50454
  });
50455
+ /**
50456
+ * The runner boot check (D877): the runners this node PLANNED (hub: one per
50457
+ * `resolveRunnerId` over its forked addons; agent: the runners its process
50458
+ * service holds, because only the hub plans) against the states the process
50459
+ * service reports. Kept in memory, recomputed by the same one-shot check after
50460
+ * every boot, served on `getServerPackageStatus`.
50461
+ *
50462
+ * `failed` is the D6 breaker's terminal state, `refused` a deterministic Init
50463
+ * refusal (an addon that said "I will not start, and here is why"), `missing` a
50464
+ * planned runner the process service has no entry for.
50465
+ */
50466
+ var RunnerRefusalSchema = object({
50467
+ runnerId: string(),
50468
+ addonIds: array(string()),
50469
+ reason: string()
50470
+ });
50471
+ var RunnerBootCheckSchema = object({
50472
+ checkedAtMs: number(),
50473
+ /** Runners planned for this node. */
50474
+ expected: number(),
50475
+ /** Planned runners whose process is `running`. */
50476
+ running: number(),
50477
+ failed: array(string()),
50478
+ refused: array(RunnerRefusalSchema),
50479
+ missing: array(string()),
50480
+ /**
50481
+ * Runners still on their way: `starting`, or `crashed` waiting on a backoff
50482
+ * respawn. The check is FINAL only when this is empty; until then nothing is
50483
+ * pushed and the verdict is re-evaluated on the next runner state change.
50484
+ * Optional for version skew (absent = settled).
50485
+ */
50486
+ pending: array(string()).optional(),
50487
+ /** True when the plan is the hub's (`missing` is then meaningful); false on an agent. */
50488
+ planKnown: boolean()
50489
+ });
49458
50490
  var ServerPackageStatusSchema = object({
49459
50491
  /** Root package name (`@camstack/server` on the hub). */
49460
50492
  packageName: string(),
@@ -49517,7 +50549,14 @@ var ServerPackageStatusSchema = object({
49517
50549
  * for version skew: an older provider's payload simply omits it, and an
49518
50550
  * absent wrapper is unknown — never `native`.
49519
50551
  */
49520
- wrapper: WrapperIdentitySchema.optional()
50552
+ wrapper: WrapperIdentitySchema.optional(),
50553
+ /**
50554
+ * What this node PLANNED to run against what its process service reports
50555
+ * (D877). Absent until the one-shot boot check has run (~60 s after boot) and
50556
+ * on a provider that predates it. Absent is "not checked yet", never "all
50557
+ * well": a consumer that needs the answer treats it as pending.
50558
+ */
50559
+ runners: RunnerBootCheckSchema.optional()
49521
50560
  });
49522
50561
  var ServerUpdateCheckResultSchema = object({
49523
50562
  packageName: string(),
@@ -49568,6 +50607,13 @@ var ServerUpdateOutcomeSchema = _enum([
49568
50607
  "refused",
49569
50608
  "failed"
49570
50609
  ]);
50610
+ /** One addon the pre-flight found the target version would refuse (D877). */
50611
+ var UpdateBlockerSchema = object({
50612
+ addonId: string(),
50613
+ reason: string(),
50614
+ /** What the operator does about it. */
50615
+ remedy: string()
50616
+ });
49571
50617
  var ServerUpdateActionResultSchema = object({
49572
50618
  accepted: boolean(),
49573
50619
  targetVersion: string().nullable(),
@@ -49585,14 +50631,27 @@ var ServerUpdateActionResultSchema = object({
49585
50631
  * The failure itself, verbatim enough to act on (the npm output for a
49586
50632
  * staging install). Non-null only for `failed`.
49587
50633
  */
49588
- error: string().nullable().optional()
50634
+ error: string().nullable().optional(),
50635
+ /**
50636
+ * The addons the target version would refuse to start on this node's live
50637
+ * store (D877), present when the pre-flight refused the update
50638
+ * (`reason: 'addon-would-refuse'`). Optional for version skew.
50639
+ */
50640
+ blockers: array(UpdateBlockerSchema).optional()
49589
50641
  });
49590
50642
  method(_void(), ServerPackageStatusSchema, { auth: "admin" }), method(_void(), ServerUpdateCheckResultSchema, {
49591
50643
  kind: "mutation",
49592
50644
  auth: "admin"
49593
- }), method(object({
49594
- /** Explicit target version; omitted = latest from the registry. */
49595
- version: string().optional() }), ServerUpdateActionResultSchema, {
50645
+ }), method(object({
50646
+ /** Explicit target version; omitted = latest from the registry. */
50647
+ version: string().optional(),
50648
+ /**
50649
+ * Apply even though the pre-flight (D877) found addons the target would
50650
+ * refuse to start. Off by default: those addons stay down until the
50651
+ * remedy is run, which is the incident this gate exists to prevent.
50652
+ */
50653
+ acknowledgeRefusals: boolean().optional()
50654
+ }), ServerUpdateActionResultSchema, {
49596
50655
  kind: "mutation",
49597
50656
  auth: "admin",
49598
50657
  timeoutMs: 16 * 6e4
@@ -52018,7 +53077,9 @@ var ManifestShapeSchema = object({
52018
53077
  var AddonProcessSchema = object({
52019
53078
  pid: number().optional(),
52020
53079
  mode: string(),
52021
- state: string()
53080
+ state: string(),
53081
+ /** Why the runner is `refused` (an addon's own words), when it is (D877). */
53082
+ reason: string().optional()
52022
53083
  });
52023
53084
  /**
52024
53085
  * Per-addon health snapshot from the kernel's AddonHealthMonitor.
@@ -52596,7 +53657,7 @@ var BatteryStatusSchema = object({
52596
53657
  */
52597
53658
  binary: boolean().optional()
52598
53659
  });
52599
- DeviceType.Camera, DeviceType.Sensor, DeviceType.Button, DeviceType.Switch, DeviceType.PetFeeder, DeviceType.Container, method(object({
53660
+ DeviceType.Camera, DeviceType.Sensor, DeviceType.Button, DeviceType.Switch, DeviceType.PetFeeder, DeviceType.Container, DeviceType.Thermostat, method(object({
52600
53661
  deviceId: number(),
52601
53662
  /** Bound on the wait. Sensible range 3000–10000ms. */
52602
53663
  timeoutMs: number().int().min(500).max(3e4).default(8e3)
@@ -53031,6 +54092,12 @@ object({
53031
54092
  /** Horizontal louver swing on/off. Null when the device has no
53032
54093
  * horizontal swing surface (gate with `DeviceFeature.ClimateSwingHorizontal`). */
53033
54094
  swingHorizontal: boolean().nullable(),
54095
+ /** Lowest setpoint the device accepts, Celsius. Absent / null = not reported. */
54096
+ minTemp: number().nullable().optional(),
54097
+ /** Highest setpoint the device accepts, Celsius. Absent / null = not reported. */
54098
+ maxTemp: number().nullable().optional(),
54099
+ /** Setpoint granularity, Celsius (0.5, 1). Absent / null = not reported. */
54100
+ tempStep: number().positive().nullable().optional(),
53034
54101
  /** Ms epoch when the slice was last updated (push or command). */
53035
54102
  lastFetchedAt: number()
53036
54103
  });
@@ -53476,6 +54543,98 @@ object({
53476
54543
  deviceId: number(),
53477
54544
  status: DeviceStatusSchema
53478
54545
  });
54546
+ /**
54547
+ * Smart-dishwasher cap — program lifecycle, door / remote-start gates,
54548
+ * consumable levels (salt, rinse aid) and common program options.
54549
+ *
54550
+ * Sources: native Bosch Home Connect (`dishwasher` device type). Reusable
54551
+ * by any integration that exposes the same program / option surface.
54552
+ *
54553
+ * `kind: 'poll'` — cloud REST APIs typically have no push channel; the
54554
+ * provider refreshes the slice on an interval and eagerly after commands.
54555
+ */
54556
+ var DishwasherStateSchema = _enum([
54557
+ "idle",
54558
+ "running",
54559
+ "paused",
54560
+ "finished",
54561
+ "error",
54562
+ "unavailable"
54563
+ ]);
54564
+ var DishwasherConsumableLevelSchema = _enum([
54565
+ "ok",
54566
+ "low",
54567
+ "empty"
54568
+ ]);
54569
+ object({
54570
+ state: DishwasherStateSchema,
54571
+ /** Active program id/name, or null when none selected / unknown. */
54572
+ program: string().nullable(),
54573
+ /** Program tokens the hardware accepts — drives the UI selector. */
54574
+ availablePrograms: array(string()),
54575
+ /** Minutes remaining on the active cycle, or null when not running. */
54576
+ remainingMinutes: number().int().nonnegative().nullable(),
54577
+ /** Cycle completion 0..100, or null when not applicable. */
54578
+ progressPercent: number().min(0).max(100).nullable(),
54579
+ /** True when the door is reported open. */
54580
+ doorOpen: boolean(),
54581
+ /** True when remote start is allowed (door closed, power on, etc.). */
54582
+ remoteStartAllowed: boolean(),
54583
+ /** Main power / switched-on state. */
54584
+ powerOn: boolean(),
54585
+ saltLevel: DishwasherConsumableLevelSchema.nullable(),
54586
+ rinseAidLevel: DishwasherConsumableLevelSchema.nullable(),
54587
+ halfLoad: boolean(),
54588
+ hygienePlus: boolean(),
54589
+ errorCode: number().nullable(),
54590
+ errorLabel: string().nullable(),
54591
+ lastFetchedAt: number()
54592
+ });
54593
+ DeviceType.Dishwasher, method(object({ deviceId: number().int().nonnegative() }), _void(), {
54594
+ kind: "mutation",
54595
+ auth: "protected"
54596
+ }), method(object({ deviceId: number().int().nonnegative() }), _void(), {
54597
+ kind: "mutation",
54598
+ auth: "protected"
54599
+ }), method(object({ deviceId: number().int().nonnegative() }), _void(), {
54600
+ kind: "mutation",
54601
+ auth: "protected"
54602
+ }), method(object({
54603
+ deviceId: number().int().nonnegative(),
54604
+ program: string().min(1)
54605
+ }), _void(), {
54606
+ kind: "mutation",
54607
+ auth: "protected"
54608
+ }), method(object({
54609
+ deviceId: number().int().nonnegative(),
54610
+ on: boolean()
54611
+ }), _void(), {
54612
+ kind: "mutation",
54613
+ auth: "protected"
54614
+ }), method(object({
54615
+ deviceId: number().int().nonnegative(),
54616
+ on: boolean()
54617
+ }), _void(), {
54618
+ kind: "mutation",
54619
+ auth: "protected"
54620
+ }), method(object({
54621
+ deviceId: number().int().nonnegative(),
54622
+ on: boolean()
54623
+ }), _void(), {
54624
+ kind: "mutation",
54625
+ auth: "protected"
54626
+ }), method(object({
54627
+ deviceId: number().int().nonnegative(),
54628
+ key: string().min(1),
54629
+ value: union([
54630
+ boolean(),
54631
+ string(),
54632
+ number()
54633
+ ])
54634
+ }), _void(), {
54635
+ kind: "mutation",
54636
+ auth: "protected"
54637
+ });
53479
54638
  object({
53480
54639
  /** Ms epoch of the last press. null = never observed since this provider started. */
53481
54640
  lastPressedAt: number().nullable(),
@@ -54041,6 +55200,13 @@ object({
54041
55200
  lastChangedAt: number()
54042
55201
  });
54043
55202
  DeviceType.Sensor;
55203
+ object({
55204
+ /** Radiator valve opening 0 (closed) .. 100 (open). Null = not yet known. */
55205
+ position: number().min(0).max(100).nullable(),
55206
+ /** Ms epoch when the slice was last updated (push or poll). */
55207
+ lastFetchedAt: number()
55208
+ });
55209
+ DeviceType.Thermostat;
54044
55210
  object({
54045
55211
  /** Whether the humidifier is currently on. */
54046
55212
  on: boolean(),
@@ -54851,7 +56017,19 @@ var TlsStatusSchema = object({
54851
56017
  sans: array(string()),
54852
56018
  caCertPem: string().nullable(),
54853
56019
  reissueError: string().nullable(),
54854
- restartRequired: boolean()
56020
+ restartRequired: boolean(),
56021
+ /** An uploaded certificate is served but no CA is kept for it and it is not publicly signed (D873). */
56022
+ caMissing: boolean(),
56023
+ /** Does the hub's own generated CA carry a critical name constraint? `null` while it has none. */
56024
+ localCaConstrained: boolean().nullable(),
56025
+ /** ISO time the generated CA was replaced by a constrained one; devices must re-download it. */
56026
+ caReplacedAt: string().nullable(),
56027
+ /** The uploaded certificate kept on disk, selectable again after "Revert to generated". */
56028
+ storedUpload: object({
56029
+ leafFingerprintSha256: string(),
56030
+ validTo: string(),
56031
+ hasCa: boolean()
56032
+ }).nullable()
54855
56033
  });
54856
56034
  method(_void(), ListResultSchema), method(_void(), PreferredSchema), method(object({
54857
56035
  /**
@@ -54907,6 +56085,9 @@ method(_void(), ListResultSchema), method(_void(), PreferredSchema), method(obje
54907
56085
  }), method(_void(), object({ pem: string() })), method(_void(), TlsStatusSchema, {
54908
56086
  kind: "mutation",
54909
56087
  auth: "admin"
56088
+ }), method(_void(), TlsStatusSchema, {
56089
+ kind: "mutation",
56090
+ auth: "admin"
54910
56091
  });
54911
56092
  object({
54912
56093
  /** Lifecycle state of the lock. `jammed` means the motor reported
@@ -60036,7 +61217,11 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
60036
61217
  kind: "mutation",
60037
61218
  auth: "admin",
60038
61219
  access: "delete"
60039
- }), method(object({ userId: string() }), TotpStatusSchema, { auth: "admin" }), method(object({
61220
+ }), method(object({ userId: string() }), TotpStatusSchema, { auth: "admin" }), method(RawSecretMigrationInputSchema, RawSecretMigrationReportSchema, {
61221
+ kind: "mutation",
61222
+ auth: "admin",
61223
+ access: "create"
61224
+ }), method(object({
60040
61225
  userId: string(),
60041
61226
  code: string()
60042
61227
  }), object({ valid: boolean() }), {
@@ -61088,7 +62273,7 @@ var AccessoryKind = {
61088
62273
  PrivacyMask: DeviceRole.PrivacyMask
61089
62274
  };
61090
62275
  AccessoryKind.Siren, AccessoryKind.Floodlight, AccessoryKind.Spotlight, AccessoryKind.PirSensor, AccessoryKind.Chime, AccessoryKind.Autotrack, AccessoryKind.Nightvision, AccessoryKind.PrivacyMask;
61091
- DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.Camera, DeviceType.Hub, DeviceType.Switch, DeviceType.Siren, DeviceType.Light, DeviceType.Fan, DeviceType.Sensor, DeviceType.Thermostat, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder;
62276
+ DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.Camera, DeviceType.Hub, DeviceType.Switch, DeviceType.Siren, DeviceType.Light, DeviceType.Fan, DeviceType.Sensor, DeviceType.Thermostat, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.Dishwasher;
61092
62277
  new Set(Object.values(DeviceType));
61093
62278
  Object.freeze({
61094
62279
  "accessories.getStatus": {
@@ -62237,6 +63422,12 @@ Object.freeze({
62237
63422
  addonId: null,
62238
63423
  access: "view"
62239
63424
  },
63425
+ "coreBlocks.migrateRawSecrets": {
63426
+ capName: "core-blocks",
63427
+ capScope: "system",
63428
+ addonId: null,
63429
+ access: "create"
63430
+ },
62240
63431
  "coreBlocks.restart": {
62241
63432
  capName: "core-blocks",
62242
63433
  capScope: "system",
@@ -63503,6 +64694,60 @@ Object.freeze({
63503
64694
  addonId: null,
63504
64695
  access: "view"
63505
64696
  },
64697
+ "dishwasher.getStatus": {
64698
+ capName: "dishwasher",
64699
+ capScope: "device",
64700
+ addonId: null,
64701
+ access: "view"
64702
+ },
64703
+ "dishwasher.pause": {
64704
+ capName: "dishwasher",
64705
+ capScope: "device",
64706
+ addonId: null,
64707
+ access: "create"
64708
+ },
64709
+ "dishwasher.setHalfLoad": {
64710
+ capName: "dishwasher",
64711
+ capScope: "device",
64712
+ addonId: null,
64713
+ access: "create"
64714
+ },
64715
+ "dishwasher.setHygienePlus": {
64716
+ capName: "dishwasher",
64717
+ capScope: "device",
64718
+ addonId: null,
64719
+ access: "create"
64720
+ },
64721
+ "dishwasher.setOption": {
64722
+ capName: "dishwasher",
64723
+ capScope: "device",
64724
+ addonId: null,
64725
+ access: "create"
64726
+ },
64727
+ "dishwasher.setPower": {
64728
+ capName: "dishwasher",
64729
+ capScope: "device",
64730
+ addonId: null,
64731
+ access: "create"
64732
+ },
64733
+ "dishwasher.setProgram": {
64734
+ capName: "dishwasher",
64735
+ capScope: "device",
64736
+ addonId: null,
64737
+ access: "create"
64738
+ },
64739
+ "dishwasher.start": {
64740
+ capName: "dishwasher",
64741
+ capScope: "device",
64742
+ addonId: null,
64743
+ access: "create"
64744
+ },
64745
+ "dishwasher.stop": {
64746
+ capName: "dishwasher",
64747
+ capScope: "device",
64748
+ addonId: null,
64749
+ access: "create"
64750
+ },
63506
64751
  "doorbell.getStatus": {
63507
64752
  capName: "doorbell",
63508
64753
  capScope: "device",
@@ -63713,6 +64958,12 @@ Object.freeze({
63713
64958
  addonId: null,
63714
64959
  access: "view"
63715
64960
  },
64961
+ "heatingValve.getStatus": {
64962
+ capName: "heating-valve",
64963
+ capScope: "device",
64964
+ addonId: null,
64965
+ access: "view"
64966
+ },
63716
64967
  "humidifier.getStatus": {
63717
64968
  capName: "humidifier",
63718
64969
  capScope: "device",
@@ -63923,6 +65174,12 @@ Object.freeze({
63923
65174
  addonId: null,
63924
65175
  access: "create"
63925
65176
  },
65177
+ "keychainAdmin.importSecret": {
65178
+ capName: "keychain-admin",
65179
+ capScope: "system",
65180
+ addonId: null,
65181
+ access: "create"
65182
+ },
63926
65183
  "keychainAdmin.listAudit": {
63927
65184
  capName: "keychain-admin",
63928
65185
  capScope: "system",
@@ -64091,6 +65348,12 @@ Object.freeze({
64091
65348
  addonId: null,
64092
65349
  access: "view"
64093
65350
  },
65351
+ "llm.migrateRawSecrets": {
65352
+ capName: "llm",
65353
+ capScope: "system",
65354
+ addonId: null,
65355
+ access: "create"
65356
+ },
64094
65357
  "llm.resolveModelRef": {
64095
65358
  capName: "llm",
64096
65359
  capScope: "system",
@@ -64319,6 +65582,12 @@ Object.freeze({
64319
65582
  addonId: null,
64320
65583
  access: "create"
64321
65584
  },
65585
+ "localNetwork.useStoredUploadedCertificate": {
65586
+ capName: "local-network",
65587
+ capScope: "system",
65588
+ addonId: null,
65589
+ access: "create"
65590
+ },
64322
65591
  "lockControl.getStatus": {
64323
65592
  capName: "lock-control",
64324
65593
  capScope: "device",
@@ -66971,6 +68240,30 @@ Object.freeze({
66971
68240
  addonId: null,
66972
68241
  access: "create"
66973
68242
  },
68243
+ "recordEntries.deleteEntry": {
68244
+ capName: "record-entries",
68245
+ capScope: "system",
68246
+ addonId: null,
68247
+ access: "delete"
68248
+ },
68249
+ "recordEntries.listEntries": {
68250
+ capName: "record-entries",
68251
+ capScope: "system",
68252
+ addonId: null,
68253
+ access: "view"
68254
+ },
68255
+ "recordEntries.listEntryKinds": {
68256
+ capName: "record-entries",
68257
+ capScope: "system",
68258
+ addonId: null,
68259
+ access: "view"
68260
+ },
68261
+ "recordEntries.putEntry": {
68262
+ capName: "record-entries",
68263
+ capScope: "system",
68264
+ addonId: null,
68265
+ access: "create"
68266
+ },
66974
68267
  "recording.getAvailability": {
66975
68268
  capName: "recording",
66976
68269
  capScope: "device",
@@ -67271,6 +68564,102 @@ Object.freeze({
67271
68564
  addonId: null,
67272
68565
  access: "view"
67273
68566
  },
68567
+ "records.aggregate": {
68568
+ capName: "records",
68569
+ capScope: "system",
68570
+ addonId: null,
68571
+ access: "view"
68572
+ },
68573
+ "records.allocateId": {
68574
+ capName: "records",
68575
+ capScope: "system",
68576
+ addonId: null,
68577
+ access: "create"
68578
+ },
68579
+ "records.count": {
68580
+ capName: "records",
68581
+ capScope: "system",
68582
+ addonId: null,
68583
+ access: "view"
68584
+ },
68585
+ "records.declareKinds": {
68586
+ capName: "records",
68587
+ capScope: "system",
68588
+ addonId: null,
68589
+ access: "create"
68590
+ },
68591
+ "records.delete": {
68592
+ capName: "records",
68593
+ capScope: "system",
68594
+ addonId: null,
68595
+ access: "delete"
68596
+ },
68597
+ "records.deleteDevice": {
68598
+ capName: "records",
68599
+ capScope: "system",
68600
+ addonId: null,
68601
+ access: "delete"
68602
+ },
68603
+ "records.deleteMany": {
68604
+ capName: "records",
68605
+ capScope: "system",
68606
+ addonId: null,
68607
+ access: "delete"
68608
+ },
68609
+ "records.deleteWhere": {
68610
+ capName: "records",
68611
+ capScope: "system",
68612
+ addonId: null,
68613
+ access: "delete"
68614
+ },
68615
+ "records.get": {
68616
+ capName: "records",
68617
+ capScope: "system",
68618
+ addonId: null,
68619
+ access: "view"
68620
+ },
68621
+ "records.getMany": {
68622
+ capName: "records",
68623
+ capScope: "system",
68624
+ addonId: null,
68625
+ access: "view"
68626
+ },
68627
+ "records.histogram": {
68628
+ capName: "records",
68629
+ capScope: "system",
68630
+ addonId: null,
68631
+ access: "view"
68632
+ },
68633
+ "records.patch": {
68634
+ capName: "records",
68635
+ capScope: "system",
68636
+ addonId: null,
68637
+ access: "create"
68638
+ },
68639
+ "records.put": {
68640
+ capName: "records",
68641
+ capScope: "system",
68642
+ addonId: null,
68643
+ access: "create"
68644
+ },
68645
+ "records.putMany": {
68646
+ capName: "records",
68647
+ capScope: "system",
68648
+ addonId: null,
68649
+ access: "create"
68650
+ },
68651
+ "records.query": {
68652
+ capName: "records",
68653
+ capScope: "system",
68654
+ addonId: null,
68655
+ access: "view"
68656
+ },
68657
+ "records.secretRefs": {
68658
+ capName: "records",
68659
+ capScope: "system",
68660
+ addonId: null,
68661
+ access: "view"
68662
+ },
67274
68663
  "sceneMonitor.captureReference": {
67275
68664
  capName: "scene-monitor",
67276
68665
  capScope: "device",
@@ -67703,6 +69092,48 @@ Object.freeze({
67703
69092
  addonId: null,
67704
69093
  access: "create"
67705
69094
  },
69095
+ "storageAdmin.adoptRecords": {
69096
+ capName: "storage-admin",
69097
+ capScope: "system",
69098
+ addonId: null,
69099
+ access: "create"
69100
+ },
69101
+ "storageAdmin.dropCollection": {
69102
+ capName: "storage-admin",
69103
+ capScope: "system",
69104
+ addonId: null,
69105
+ access: "delete"
69106
+ },
69107
+ "storageAdmin.isAdoptedLegacyTable": {
69108
+ capName: "storage-admin",
69109
+ capScope: "system",
69110
+ addonId: null,
69111
+ access: "view"
69112
+ },
69113
+ "storageAdmin.listKinds": {
69114
+ capName: "storage-admin",
69115
+ capScope: "system",
69116
+ addonId: null,
69117
+ access: "view"
69118
+ },
69119
+ "storageAdmin.listTables": {
69120
+ capName: "storage-admin",
69121
+ capScope: "system",
69122
+ addonId: null,
69123
+ access: "view"
69124
+ },
69125
+ "storageAdmin.readLegacyCollection": {
69126
+ capName: "storage-admin",
69127
+ capScope: "system",
69128
+ addonId: null,
69129
+ access: "view"
69130
+ },
69131
+ "storageAdmin.readRecords": {
69132
+ capName: "storage-admin",
69133
+ capScope: "system",
69134
+ addonId: null,
69135
+ access: "view"
69136
+ },
67706
69137
  "storageEvictable.evict": {
67707
69138
  capName: "storage-evictable",
67708
69139
  capScope: "system",
@@ -68615,6 +70046,12 @@ Object.freeze({
68615
70046
  addonId: null,
68616
70047
  access: "view"
68617
70048
  },
70049
+ "userManagement.migrateRawSecrets": {
70050
+ capName: "user-management",
70051
+ capScope: "system",
70052
+ addonId: null,
70053
+ access: "create"
70054
+ },
68618
70055
  "userManagement.oauthExchangeCode": {
68619
70056
  capName: "user-management",
68620
70057
  capScope: "system",
@@ -69114,7 +70551,7 @@ Object.freeze({
69114
70551
  access: "create"
69115
70552
  }
69116
70553
  });
69117
- DeviceType.Camera, DeviceType.Hub, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Thermostat, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder;
70554
+ DeviceType.Camera, DeviceType.Hub, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Thermostat, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.Dishwasher;
69118
70555
  DeviceFeature.BatteryOperated;
69119
70556
  Object.freeze({
69120
70557
  "accessories.getStatus": [{
@@ -69938,6 +71375,51 @@ Object.freeze({
69938
71375
  form: "single",
69939
71376
  optional: false
69940
71377
  }],
71378
+ "dishwasher.getStatus": [{
71379
+ name: "deviceId",
71380
+ form: "single",
71381
+ optional: false
71382
+ }],
71383
+ "dishwasher.pause": [{
71384
+ name: "deviceId",
71385
+ form: "single",
71386
+ optional: false
71387
+ }],
71388
+ "dishwasher.setHalfLoad": [{
71389
+ name: "deviceId",
71390
+ form: "single",
71391
+ optional: false
71392
+ }],
71393
+ "dishwasher.setHygienePlus": [{
71394
+ name: "deviceId",
71395
+ form: "single",
71396
+ optional: false
71397
+ }],
71398
+ "dishwasher.setOption": [{
71399
+ name: "deviceId",
71400
+ form: "single",
71401
+ optional: false
71402
+ }],
71403
+ "dishwasher.setPower": [{
71404
+ name: "deviceId",
71405
+ form: "single",
71406
+ optional: false
71407
+ }],
71408
+ "dishwasher.setProgram": [{
71409
+ name: "deviceId",
71410
+ form: "single",
71411
+ optional: false
71412
+ }],
71413
+ "dishwasher.start": [{
71414
+ name: "deviceId",
71415
+ form: "single",
71416
+ optional: false
71417
+ }],
71418
+ "dishwasher.stop": [{
71419
+ name: "deviceId",
71420
+ form: "single",
71421
+ optional: false
71422
+ }],
69941
71423
  "doorbell.getStatus": [{
69942
71424
  name: "deviceId",
69943
71425
  form: "single",
@@ -70007,6 +71489,11 @@ Object.freeze({
70007
71489
  form: "single",
70008
71490
  optional: false
70009
71491
  }],
71492
+ "heatingValve.getStatus": [{
71493
+ name: "deviceId",
71494
+ form: "single",
71495
+ optional: false
71496
+ }],
70010
71497
  "humidifier.getStatus": [{
70011
71498
  name: "deviceId",
70012
71499
  form: "single",
@@ -71291,6 +72778,37 @@ Object.freeze({
71291
72778
  form: "single",
71292
72779
  optional: false
71293
72780
  }],
72781
+ "records.count": [{
72782
+ name: "deviceId",
72783
+ form: "single",
72784
+ optional: true
72785
+ }],
72786
+ "records.deleteDevice": [{
72787
+ name: "deviceId",
72788
+ form: "single",
72789
+ optional: false
72790
+ }],
72791
+ "records.deleteWhere": [{
72792
+ name: "deviceId",
72793
+ form: "single",
72794
+ optional: true
72795
+ }],
72796
+ "records.histogram": [{
72797
+ name: "deviceId",
72798
+ form: "single",
72799
+ optional: true
72800
+ }],
72801
+ "records.putMany": [{
72802
+ name: "records",
72803
+ form: "object-array",
72804
+ optional: false,
72805
+ itemField: "deviceId"
72806
+ }],
72807
+ "records.query": [{
72808
+ name: "deviceId",
72809
+ form: "single",
72810
+ optional: true
72811
+ }],
71294
72812
  "sceneMonitor.captureReference": [{
71295
72813
  name: "deviceId",
71296
72814
  form: "single",
@@ -71407,6 +72925,17 @@ Object.freeze({
71407
72925
  form: "single",
71408
72926
  optional: false
71409
72927
  }],
72928
+ "storageAdmin.adoptRecords": [{
72929
+ name: "records",
72930
+ form: "object-array",
72931
+ optional: false,
72932
+ itemField: "deviceId"
72933
+ }],
72934
+ "storageAdmin.readRecords": [{
72935
+ name: "deviceId",
72936
+ form: "single",
72937
+ optional: true
72938
+ }],
71410
72939
  "streamBroker.acquireEgressTranscode": [{
71411
72940
  name: "deviceId",
71412
72941
  form: "single",
@@ -73660,6 +75189,40 @@ function createGmailSmtpProvider(deps) {
73660
75189
  };
73661
75190
  }
73662
75191
  //#endregion
75192
+ //#region src/google-broker-reconnect-alert.ts
75193
+ function googleBrokerReconnectAlertId(brokerId) {
75194
+ return `google-broker:${brokerId}`;
75195
+ }
75196
+ function isInvalidGrantRefreshError(err) {
75197
+ return (err instanceof Error ? err.message : String(err)).includes("invalid_grant");
75198
+ }
75199
+ function buildGoogleBrokerReconnectAlert(brokerId, brokerName) {
75200
+ const pushLine = `${brokerName}: Google session expired — sign in again`;
75201
+ return {
75202
+ id: googleBrokerReconnectAlertId(brokerId),
75203
+ category: "google.broker-reconnect",
75204
+ severity: "critical",
75205
+ title: "Google needs a new sign-in",
75206
+ message: `${brokerName} needs you to sign in to Google again.`,
75207
+ action: {
75208
+ label: "Sign in again",
75209
+ href: `/addon/google-services/oauth/start?brokerId=${encodeURIComponent(brokerId)}`
75210
+ },
75211
+ status: "active",
75212
+ read: false,
75213
+ createdAt: Date.now(),
75214
+ updatedAt: Date.now(),
75215
+ source: {
75216
+ type: "google-broker",
75217
+ id: brokerId
75218
+ },
75219
+ metadata: {
75220
+ episodeKey: "reconnect",
75221
+ pushLine
75222
+ }
75223
+ };
75224
+ }
75225
+ //#endregion
73663
75226
  //#region src/google-oauth.ts
73664
75227
  /**
73665
75228
  * Google OAuth2 authorization-code + refresh for Calendar API.
@@ -73790,6 +75353,74 @@ async function probeGoogleOauthClient(cfg, http = { fetch }) {
73790
75353
  function pickOauthRedirectOrigin(book) {
73791
75354
  return book.roles.publicEndpoint.resolved ?? book.roles.internal.resolved ?? null;
73792
75355
  }
75356
+ var googleBrokersEntryKind = defineEntryKind("brokers", {
75357
+ title: "Google Services brokers",
75358
+ schema: entryBody({
75359
+ clientId: GoogleBrokerEntrySchema.shape.clientId,
75360
+ clientSecret: GoogleBrokerEntrySchema.shape.clientSecret,
75361
+ calendarFilter: GoogleBrokerEntrySchema.shape.calendarFilter,
75362
+ fromAddress: GoogleBrokerEntrySchema.shape.fromAddress,
75363
+ fromName: GoogleBrokerEntrySchema.shape.fromName
75364
+ }),
75365
+ writeTrigger: "an operator adds or edits a Google OAuth broker",
75366
+ adoptsFrom: settingsBrokersAdoptsFrom("google-services")
75367
+ });
75368
+ //#endregion
75369
+ //#region src/google-broker-store.ts
75370
+ function rowToEntry(id, data) {
75371
+ const parsed = GoogleBrokerEntrySchema.safeParse({
75372
+ id,
75373
+ ...data
75374
+ });
75375
+ return parsed.success ? parsed.data : null;
75376
+ }
75377
+ var GoogleBrokerStore = class GoogleBrokerStore {
75378
+ kind;
75379
+ constructor(kind) {
75380
+ this.kind = kind;
75381
+ }
75382
+ static of(records) {
75383
+ return new GoogleBrokerStore(records.kind(googleBrokersEntryKind));
75384
+ }
75385
+ async listResolved() {
75386
+ const page = await this.kind.query({ limit: 1e3 });
75387
+ const out = [];
75388
+ for (const record of page.records) {
75389
+ let data = record.data;
75390
+ try {
75391
+ const resolved = await this.kind.getResolved(record.id);
75392
+ if (resolved !== null) data = resolved.data;
75393
+ } catch (err) {
75394
+ if (!(err instanceof RecordSecretUnavailableError)) throw err;
75395
+ }
75396
+ const entry = rowToEntry(record.id, data);
75397
+ if (entry !== null) out.push(entry);
75398
+ }
75399
+ return out;
75400
+ }
75401
+ async replaceAll(entries) {
75402
+ const page = await this.kind.query({ limit: 1e3 });
75403
+ const nextIds = new Set(entries.map((e) => e.id));
75404
+ for (const row of page.records) if (!nextIds.has(row.id)) await this.kind.delete(row.id);
75405
+ for (const entry of entries) {
75406
+ const { id, name, clientId, clientSecret, calendarFilter, fromAddress, fromName } = entry;
75407
+ const body = {
75408
+ name,
75409
+ clientId,
75410
+ clientSecret,
75411
+ calendarFilter,
75412
+ fromAddress,
75413
+ fromName
75414
+ };
75415
+ const parsed = googleBrokersEntryKind.schema.safeParse(body);
75416
+ if (!parsed.success) throw new Error(`invalid Google broker '${id}': ${parsed.error.message}`);
75417
+ await this.kind.put({
75418
+ id,
75419
+ data: parsed.data
75420
+ });
75421
+ }
75422
+ }
75423
+ };
73793
75424
  //#endregion
73794
75425
  //#region src/google-services.addon.ts
73795
75426
  /**
@@ -73815,6 +75446,8 @@ var GoogleServicesAddon = class extends BaseAddon {
73815
75446
  ];
73816
75447
  oauthAccountsHandle = null;
73817
75448
  registry = new GoogleBrokerRegistry();
75449
+ brokerStore = null;
75450
+ activeBrokers = [];
73818
75451
  /** CSRF state → { brokerId, popup, issuedAt } — popup mirrors OIDC D794. */
73819
75452
  pendingStates = /* @__PURE__ */ new Map();
73820
75453
  publicOrigin = null;
@@ -73856,7 +75489,16 @@ var GoogleServicesAddon = class extends BaseAddon {
73856
75489
  await this.oauthAccountsHandle.set(oauthAccounts);
73857
75490
  await legacyHandle.set({ ...DEFAULT_OAUTH_STATE });
73858
75491
  }
73859
- this.registry.seedFrom(this.config.brokers, oauthAccounts.accounts);
75492
+ const records = this.ctx.records;
75493
+ if (records === void 0) throw new Error("google-services: ctx.records is required (hub-only addon)");
75494
+ await records.declare({ brokers: googleBrokersEntryKind });
75495
+ this.brokerStore = GoogleBrokerStore.of(records);
75496
+ this.activeBrokers = await this.loadPersistedBrokers();
75497
+ if ((await this.brokerStore.listResolved()).length === 0 && this.config.brokers.length > 0) {
75498
+ await this.brokerStore.replaceAll(this.config.brokers);
75499
+ this.activeBrokers = await this.loadPersistedBrokers();
75500
+ }
75501
+ this.registry.seedFrom(this.activeBrokers, oauthAccounts.accounts);
73860
75502
  await this.refreshPublicOrigin();
73861
75503
  const calendarProvider = createGoogleCalendarSource({
73862
75504
  logger: this.ctx.logger,
@@ -73928,7 +75570,8 @@ var GoogleServicesAddon = class extends BaseAddon {
73928
75570
  }
73929
75571
  async onConfigChanged() {
73930
75572
  const accounts = this.registry.listOauthAccounts();
73931
- this.registry.seedFrom(this.config.brokers, accounts);
75573
+ this.activeBrokers = await this.loadPersistedBrokers();
75574
+ this.registry.seedFrom(this.activeBrokers, accounts);
73932
75575
  }
73933
75576
  buildBrokerProvider() {
73934
75577
  const ownerAddonId = this.ctx.id;
@@ -74195,6 +75838,7 @@ var GoogleServicesAddon = class extends BaseAddon {
74195
75838
  };
74196
75839
  this.registry.setOauth(next);
74197
75840
  await this.persistOauthAccounts();
75841
+ if (next.refreshToken.length > 0) this.resolveGoogleBrokerReconnectAlert(brokerId);
74198
75842
  if (next.accountEmail && (entry.name === "Google account" || entry.name.startsWith("google_"))) {
74199
75843
  const renamed = {
74200
75844
  ...entry,
@@ -74281,8 +75925,23 @@ var GoogleServicesAddon = class extends BaseAddon {
74281
75925
  const cutoff = Date.now() - 10 * 6e4;
74282
75926
  for (const [k, v] of this.pendingStates) if (v.issuedAt < cutoff) this.pendingStates.delete(k);
74283
75927
  }
75928
+ async loadPersistedBrokers() {
75929
+ const store = this.brokerStore;
75930
+ if (store !== null) {
75931
+ const fromRecords = await store.listResolved();
75932
+ if (fromRecords.length > 0) return fromRecords;
75933
+ }
75934
+ return this.config.brokers;
75935
+ }
74284
75936
  async persistBrokers() {
74285
- await this.updateGlobalSettings({ brokers: [...this.registry.listEntries()] });
75937
+ const entries = [...this.registry.listEntries()];
75938
+ this.activeBrokers = entries;
75939
+ const store = this.brokerStore;
75940
+ if (store !== null) {
75941
+ await store.replaceAll(entries);
75942
+ return;
75943
+ }
75944
+ await this.updateGlobalSettings({ brokers: entries });
74286
75945
  }
74287
75946
  async persistOauthAccounts() {
74288
75947
  if (!this.oauthAccountsHandle) return;
@@ -74312,6 +75971,39 @@ var GoogleServicesAddon = class extends BaseAddon {
74312
75971
  }
74313
75972
  return out.toSorted((a, b) => a.label.localeCompare(b.label));
74314
75973
  }
75974
+ async emitGoogleBrokerReconnectAlert(brokerId, brokerName) {
75975
+ const emit = this.ctx.api.alerts?.emit;
75976
+ if (emit === void 0) {
75977
+ this.ctx.logger.warn("google broker reconnect alert skipped — alerts capability missing", { meta: { brokerId } });
75978
+ return;
75979
+ }
75980
+ try {
75981
+ await emit.mutate(buildGoogleBrokerReconnectAlert(brokerId, brokerName));
75982
+ } catch (err) {
75983
+ this.ctx.logger.warn("google broker reconnect alert emit failed", { meta: {
75984
+ brokerId,
75985
+ error: err instanceof Error ? err.message : String(err)
75986
+ } });
75987
+ }
75988
+ }
75989
+ async resolveGoogleBrokerReconnectAlert(brokerId) {
75990
+ const update = this.ctx.api.alerts?.update;
75991
+ if (update === void 0) return;
75992
+ try {
75993
+ await update.mutate({
75994
+ alertId: googleBrokerReconnectAlertId(brokerId),
75995
+ patch: {
75996
+ status: "completed",
75997
+ read: true
75998
+ }
75999
+ });
76000
+ } catch (err) {
76001
+ this.ctx.logger.warn("google broker reconnect alert resolve failed", { meta: {
76002
+ brokerId,
76003
+ error: err instanceof Error ? err.message : String(err)
76004
+ } });
76005
+ }
76006
+ }
74315
76007
  async ensureAccessToken(brokerId, opts = {}) {
74316
76008
  const entry = this.registry.getEntry(brokerId);
74317
76009
  const oauth = this.registry.getOauth(brokerId);
@@ -74324,10 +76016,16 @@ var GoogleServicesAddon = class extends BaseAddon {
74324
76016
  accountEmail: oauth.accountEmail
74325
76017
  };
74326
76018
  if (!opts.forceRefresh && !needsRefresh(state)) return state.accessToken;
74327
- const tokens = await refreshAccessToken({
74328
- clientId: entry.clientId.trim(),
74329
- clientSecret: entry.clientSecret.trim()
74330
- }, state.refreshToken);
76019
+ let tokens;
76020
+ try {
76021
+ tokens = await refreshAccessToken({
76022
+ clientId: entry.clientId.trim(),
76023
+ clientSecret: entry.clientSecret.trim()
76024
+ }, state.refreshToken);
76025
+ } catch (err) {
76026
+ if (isInvalidGrantRefreshError(err)) this.emitGoogleBrokerReconnectAlert(brokerId, entry.name);
76027
+ throw err;
76028
+ }
74331
76029
  if (typeof tokens.access_token !== "string" || tokens.access_token.trim().length === 0) throw new Error("Google token refresh returned an empty access_token — Sign out and Sign in again");
74332
76030
  const nextState = applyTokenResponse(state, tokens);
74333
76031
  this.registry.setOauth({