@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.
@@ -1,5 +1,5 @@
1
1
  import { randomBytes } from "node:crypto";
2
- //#region ../types/dist/event-category-C4hVnRo8.mjs
2
+ //#region ../types/dist/event-category-BvOFi6PY.mjs
3
3
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
4
4
  EventCategory["SystemBoot"] = "system.boot";
5
5
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -63,6 +63,24 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
63
63
  * consumes this category and maps it to the `addon-crash-loop` kind.
64
64
  */
65
65
  EventCategory["AddonRunnerFailed"] = "addon.runner-failed";
66
+ /**
67
+ * A runner whose addon refused to start with a typed reason (D877) - parked
68
+ * in `refused`, never counted by the crash breaker, retried on operator
69
+ * action. One event per refusal.
70
+ */
71
+ EventCategory["AddonRunnerRefused"] = "addon.runner-refused";
72
+ /**
73
+ * A runner settled on a state (D877): `running` (READY), `crashed`, `failed` or
74
+ * `refused`. In-process telemetry for the boot check (re-evaluate while any
75
+ * runner is still pending) and the alert centre (close a recovered runner).
76
+ */
77
+ EventCategory["ProcessStateChanged"] = "process.state-changed";
78
+ /**
79
+ * The node's one-shot runner boot check (D877): planned runners against the
80
+ * process service, `degraded` when any is failed, refused or missing. The
81
+ * alert centre turns it into one alert and a direct critical push.
82
+ */
83
+ EventCategory["SystemRunnerCheck"] = "system.runner-check";
66
84
  EventCategory["AddonError"] = "addon.error";
67
85
  EventCategory["AddonPageReady"] = "addon.page-ready";
68
86
  EventCategory["AddonWidgetReady"] = "addon.widget-ready";
@@ -4105,6 +4123,12 @@ var numberProcessor = (schema, ctx, _json, _params) => {
4105
4123
  var booleanProcessor = (_schema, _ctx, json, _params) => {
4106
4124
  json.type = "boolean";
4107
4125
  };
4126
+ var bigintProcessor = (_schema, ctx, _json, _params) => {
4127
+ if (ctx.unrepresentable === "throw") throw new Error("BigInt cannot be represented in JSON Schema");
4128
+ };
4129
+ var symbolProcessor = (_schema, ctx, _json, _params) => {
4130
+ if (ctx.unrepresentable === "throw") throw new Error("Symbols cannot be represented in JSON Schema");
4131
+ };
4108
4132
  var nullProcessor = (_schema, ctx, json, _params) => {
4109
4133
  if (ctx.target === "openapi-3.0") {
4110
4134
  json.type = "string";
@@ -4112,12 +4136,17 @@ var nullProcessor = (_schema, ctx, json, _params) => {
4112
4136
  json.enum = [null];
4113
4137
  } else json.type = "null";
4114
4138
  };
4139
+ var undefinedProcessor = (_schema, ctx, _json, _params) => {
4140
+ if (ctx.unrepresentable === "throw") throw new Error("Undefined cannot be represented in JSON Schema");
4141
+ };
4115
4142
  var voidProcessor = (_schema, ctx, _json, _params) => {
4116
4143
  if (ctx.unrepresentable === "throw") throw new Error("Void cannot be represented in JSON Schema");
4117
4144
  };
4118
4145
  var neverProcessor = (_schema, _ctx, json, _params) => {
4119
4146
  json.not = {};
4120
4147
  };
4148
+ var anyProcessor = (_schema, _ctx, _json, _params) => {};
4149
+ var unknownProcessor = (_schema, _ctx, _json, _params) => {};
4121
4150
  var dateProcessor = (_schema, ctx, _json, _params) => {
4122
4151
  if (ctx.unrepresentable === "throw") throw new Error("Date cannot be represented in JSON Schema");
4123
4152
  };
@@ -4149,12 +4178,53 @@ var literalProcessor = (schema, ctx, json, _params) => {
4149
4178
  json.enum = vals;
4150
4179
  }
4151
4180
  };
4181
+ var nanProcessor = (_schema, ctx, _json, _params) => {
4182
+ if (ctx.unrepresentable === "throw") throw new Error("NaN cannot be represented in JSON Schema");
4183
+ };
4184
+ var templateLiteralProcessor = (schema, _ctx, json, _params) => {
4185
+ const _json = json;
4186
+ const pattern = schema._zod.pattern;
4187
+ if (!pattern) throw new Error("Pattern not found in template literal");
4188
+ _json.type = "string";
4189
+ _json.pattern = pattern.source;
4190
+ };
4191
+ var fileProcessor = (schema, _ctx, json, _params) => {
4192
+ const _json = json;
4193
+ const file = {
4194
+ type: "string",
4195
+ format: "binary",
4196
+ contentEncoding: "binary"
4197
+ };
4198
+ const { minimum, maximum, mime } = schema._zod.bag;
4199
+ if (minimum !== void 0) file.minLength = minimum;
4200
+ if (maximum !== void 0) file.maxLength = maximum;
4201
+ if (mime) if (mime.length === 1) {
4202
+ file.contentMediaType = mime[0];
4203
+ Object.assign(_json, file);
4204
+ } else {
4205
+ Object.assign(_json, file);
4206
+ _json.anyOf = mime.map((m) => ({ contentMediaType: m }));
4207
+ }
4208
+ else Object.assign(_json, file);
4209
+ };
4210
+ var successProcessor = (_schema, _ctx, json, _params) => {
4211
+ json.type = "boolean";
4212
+ };
4152
4213
  var customProcessor = (_schema, ctx, _json, _params) => {
4153
4214
  if (ctx.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
4154
4215
  };
4216
+ var functionProcessor = (_schema, ctx, _json, _params) => {
4217
+ if (ctx.unrepresentable === "throw") throw new Error("Function types cannot be represented in JSON Schema");
4218
+ };
4155
4219
  var transformProcessor = (_schema, ctx, _json, _params) => {
4156
4220
  if (ctx.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
4157
4221
  };
4222
+ var mapProcessor = (_schema, ctx, _json, _params) => {
4223
+ if (ctx.unrepresentable === "throw") throw new Error("Map cannot be represented in JSON Schema");
4224
+ };
4225
+ var setProcessor = (_schema, ctx, _json, _params) => {
4226
+ if (ctx.unrepresentable === "throw") throw new Error("Set cannot be represented in JSON Schema");
4227
+ };
4158
4228
  var arrayProcessor = (schema, ctx, _json, params) => {
4159
4229
  const json = _json;
4160
4230
  const def = schema._zod.def;
@@ -4359,6 +4429,12 @@ var readonlyProcessor = (schema, ctx, json, params) => {
4359
4429
  seen.ref = def.innerType;
4360
4430
  json.readOnly = true;
4361
4431
  };
4432
+ var promiseProcessor = (schema, ctx, _json, params) => {
4433
+ const def = schema._zod.def;
4434
+ process(def.innerType, ctx, params);
4435
+ const seen = ctx.seen.get(schema);
4436
+ seen.ref = def.innerType;
4437
+ };
4362
4438
  var optionalProcessor = (schema, ctx, _json, params) => {
4363
4439
  const def = schema._zod.def;
4364
4440
  process(def.innerType, ctx, params);
@@ -4371,6 +4447,81 @@ var lazyProcessor = (schema, ctx, _json, params) => {
4371
4447
  const seen = ctx.seen.get(schema);
4372
4448
  seen.ref = innerType;
4373
4449
  };
4450
+ var allProcessors = {
4451
+ string: stringProcessor,
4452
+ number: numberProcessor,
4453
+ boolean: booleanProcessor,
4454
+ bigint: bigintProcessor,
4455
+ symbol: symbolProcessor,
4456
+ null: nullProcessor,
4457
+ undefined: undefinedProcessor,
4458
+ void: voidProcessor,
4459
+ never: neverProcessor,
4460
+ any: anyProcessor,
4461
+ unknown: unknownProcessor,
4462
+ date: dateProcessor,
4463
+ enum: enumProcessor,
4464
+ literal: literalProcessor,
4465
+ nan: nanProcessor,
4466
+ template_literal: templateLiteralProcessor,
4467
+ file: fileProcessor,
4468
+ success: successProcessor,
4469
+ custom: customProcessor,
4470
+ function: functionProcessor,
4471
+ transform: transformProcessor,
4472
+ map: mapProcessor,
4473
+ set: setProcessor,
4474
+ array: arrayProcessor,
4475
+ object: objectProcessor,
4476
+ union: unionProcessor,
4477
+ intersection: intersectionProcessor,
4478
+ tuple: tupleProcessor,
4479
+ record: recordProcessor,
4480
+ nullable: nullableProcessor,
4481
+ nonoptional: nonoptionalProcessor,
4482
+ default: defaultProcessor,
4483
+ prefault: prefaultProcessor,
4484
+ catch: catchProcessor,
4485
+ pipe: pipeProcessor,
4486
+ readonly: readonlyProcessor,
4487
+ promise: promiseProcessor,
4488
+ optional: optionalProcessor,
4489
+ lazy: lazyProcessor
4490
+ };
4491
+ function toJSONSchema(input, params) {
4492
+ if ("_idmap" in input) {
4493
+ const registry = input;
4494
+ const ctx = initializeContext({
4495
+ ...params,
4496
+ processors: allProcessors
4497
+ });
4498
+ const defs = {};
4499
+ for (const entry of registry._idmap.entries()) {
4500
+ const [_, schema] = entry;
4501
+ process(schema, ctx);
4502
+ }
4503
+ const schemas = {};
4504
+ ctx.external = {
4505
+ registry,
4506
+ uri: params?.uri,
4507
+ defs
4508
+ };
4509
+ for (const entry of registry._idmap.entries()) {
4510
+ const [key, schema] = entry;
4511
+ extractDefs(ctx, schema);
4512
+ schemas[key] = finalize(ctx, schema);
4513
+ }
4514
+ if (Object.keys(defs).length > 0) schemas.__shared = { [ctx.target === "draft-2020-12" ? "$defs" : "definitions"]: defs };
4515
+ return { schemas };
4516
+ }
4517
+ const ctx = initializeContext({
4518
+ ...params,
4519
+ processors: allProcessors
4520
+ });
4521
+ process(input, ctx);
4522
+ extractDefs(ctx, input);
4523
+ return finalize(ctx, input);
4524
+ }
4374
4525
  //#endregion
4375
4526
  //#region ../../node_modules/zod/v4/classic/iso.js
4376
4527
  var ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
@@ -5387,7 +5538,7 @@ var ZodIssueCode = {
5387
5538
  var ZodFirstPartyTypeKind;
5388
5539
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5389
5540
  //#endregion
5390
- //#region ../types/dist/sleep-DRqxtc0C.mjs
5541
+ //#region ../types/dist/sleep-BOjuyoPC.mjs
5391
5542
  /**
5392
5543
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5393
5544
  * window to float samples (D455).
@@ -5504,7 +5655,7 @@ function isKeychainStoredField(field) {
5504
5655
  var SECRET_CLEAR = { $secretClear: true };
5505
5656
  /** The `'***'` token D634 redaction writes for non-admins. */
5506
5657
  var LEGACY_DEVICE_REDACTION = "***";
5507
- function isRecord$2(value) {
5658
+ function isRecord$5(value) {
5508
5659
  return typeof value === "object" && value !== null && !Array.isArray(value);
5509
5660
  }
5510
5661
  function makeSecretMarker(ref) {
@@ -5515,12 +5666,12 @@ function makeSecretMarker(ref) {
5515
5666
  }
5516
5667
  /** A stored marker: an object whose `$secret` is a non-empty string. */
5517
5668
  function isSecretMarker(value) {
5518
- if (!isRecord$2(value)) return false;
5669
+ if (!isRecord$5(value)) return false;
5519
5670
  const ref = value["$secret"];
5520
5671
  return typeof ref === "string" && ref.length > 0;
5521
5672
  }
5522
5673
  function isSecretClear(value) {
5523
- return isRecord$2(value) && value["$secretClear"] === true;
5674
+ return isRecord$5(value) && value["$secretClear"] === true;
5524
5675
  }
5525
5676
  /**
5526
5677
  * The UI view of a stored secret field value: a marker becomes "set", inline
@@ -6130,7 +6281,7 @@ var KeychainWriteRefusedError = class extends Error {
6130
6281
  }
6131
6282
  };
6132
6283
  var KEEP = { kind: "keep" };
6133
- function isRecord$1(value) {
6284
+ function isRecord$4(value) {
6134
6285
  return typeof value === "object" && value !== null && !Array.isArray(value);
6135
6286
  }
6136
6287
  function defaultMintId() {
@@ -6143,7 +6294,7 @@ function collectSecretMarkerRefs(value, out = []) {
6143
6294
  return out;
6144
6295
  }
6145
6296
  if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6146
- else if (isRecord$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6297
+ else if (isRecord$4(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6147
6298
  return out;
6148
6299
  }
6149
6300
  async function storedValueEquals(secrets, marker, candidate) {
@@ -6198,7 +6349,7 @@ function rowId(row, idKey) {
6198
6349
  return null;
6199
6350
  }
6200
6351
  async function writeArray(ctx, node, incoming, stored, fieldPath) {
6201
- const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1) : [];
6352
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$4) : [];
6202
6353
  if (!Array.isArray(incoming)) {
6203
6354
  ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6204
6355
  return {
@@ -6214,7 +6365,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6214
6365
  const kept = /* @__PURE__ */ new Set();
6215
6366
  const rows = [];
6216
6367
  for (const row of incoming) {
6217
- if (!isRecord$1(row)) {
6368
+ if (!isRecord$4(row)) {
6218
6369
  rows.push(row);
6219
6370
  continue;
6220
6371
  }
@@ -6239,7 +6390,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6239
6390
  case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6240
6391
  case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6241
6392
  case "object": {
6242
- if (!isRecord$1(incoming)) {
6393
+ if (!isRecord$4(incoming)) {
6243
6394
  if (incoming === void 0) return KEEP;
6244
6395
  ctx.deletes.push(...collectSecretMarkerRefs(stored));
6245
6396
  return {
@@ -6247,7 +6398,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6247
6398
  value: incoming
6248
6399
  };
6249
6400
  }
6250
- const storedObj = isRecord$1(stored) ? stored : {};
6401
+ const storedObj = isRecord$4(stored) ? stored : {};
6251
6402
  return {
6252
6403
  kind: "value",
6253
6404
  value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
@@ -6370,7 +6521,7 @@ async function resolveSecretMarkers(value, secrets, options = {}) {
6370
6521
  value: items
6371
6522
  };
6372
6523
  }
6373
- if (isRecord$1(v)) {
6524
+ if (isRecord$4(v)) {
6374
6525
  const out = {};
6375
6526
  for (const [k, child] of Object.entries(v)) {
6376
6527
  const s = substitute(child);
@@ -6402,7 +6553,7 @@ var SecretOverwriteRefusedError = class extends Error {
6402
6553
  this.name = "SecretOverwriteRefusedError";
6403
6554
  }
6404
6555
  };
6405
- function isRecord(value) {
6556
+ function isRecord$3(value) {
6406
6557
  return typeof value === "object" && value !== null && !Array.isArray(value);
6407
6558
  }
6408
6559
  function resolvedValue(pass, marker) {
@@ -6431,7 +6582,7 @@ function inArray(pass, incoming, stored) {
6431
6582
  return incoming.map((item, index) => {
6432
6583
  const twin = stored[index];
6433
6584
  if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
6434
- if (isRecord(item) && isRecord(twin)) return inArrayRow(pass, item, twin);
6585
+ if (isRecord$3(item) && isRecord$3(twin)) return inArrayRow(pass, item, twin);
6435
6586
  if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
6436
6587
  return item;
6437
6588
  });
@@ -6442,7 +6593,7 @@ function inArrayRow(pass, incoming, stored) {
6442
6593
  const twin = stored[key];
6443
6594
  if (isSecretMarker(twin)) {
6444
6595
  if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
6445
- } else if (isRecord(value) && isRecord(twin)) out[key] = inArrayRow(pass, value, twin);
6596
+ } else if (isRecord$3(value) && isRecord$3(twin)) out[key] = inArrayRow(pass, value, twin);
6446
6597
  else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
6447
6598
  }
6448
6599
  return out;
@@ -6450,7 +6601,7 @@ function inArrayRow(pass, incoming, stored) {
6450
6601
  async function walk(pass, incoming, stored) {
6451
6602
  if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
6452
6603
  if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
6453
- if (!isRecord(incoming) || !isRecord(stored)) return incoming;
6604
+ if (!isRecord$3(incoming) || !isRecord$3(stored)) return incoming;
6454
6605
  const out = { ...incoming };
6455
6606
  for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
6456
6607
  return out;
@@ -6481,7 +6632,7 @@ async function restoreUnchangedSecrets(input) {
6481
6632
  function isJsonEqual(a, b) {
6482
6633
  if (Object.is(a, b)) return true;
6483
6634
  if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
6484
- if (isRecord(a) && isRecord(b)) {
6635
+ if (isRecord$3(a) && isRecord$3(b)) {
6485
6636
  const keys = Object.keys(a);
6486
6637
  if (keys.length !== Object.keys(b).length) return false;
6487
6638
  return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
@@ -6505,7 +6656,7 @@ function markerKeysOf(blob, owner) {
6505
6656
  }
6506
6657
  function nodeFromStored(value, owner) {
6507
6658
  if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
6508
- if (!isRecord(value)) return null;
6659
+ if (!isRecord$3(value)) return null;
6509
6660
  const children = /* @__PURE__ */ new Map();
6510
6661
  for (const [key, child] of Object.entries(value)) {
6511
6662
  const node = nodeFromStored(child, owner);
@@ -6638,7 +6789,6 @@ function createHandle(raw, opts) {
6638
6789
  const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
6639
6790
  const readAddonStoreResult = raw.readAddonStoreResult;
6640
6791
  const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
6641
- const readDeviceStoreBatch = raw.readDeviceStoreBatch;
6642
6792
  const overrides = {
6643
6793
  readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
6644
6794
  ...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
@@ -6662,12 +6812,12 @@ function createHandle(raw, opts) {
6662
6812
  };
6663
6813
  } } : {},
6664
6814
  readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
6665
- ...readDeviceStoreBatch !== void 0 ? { readDeviceStoreBatch: async (deviceIds) => {
6666
- const rows = await readDeviceStoreBatch.call(raw, deviceIds);
6815
+ readDeviceStoreBatch: async (deviceIds) => {
6816
+ const rows = await raw.readDeviceStoreBatch(deviceIds);
6667
6817
  const out = /* @__PURE__ */ new Map();
6668
6818
  for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
6669
6819
  return out;
6670
- } } : {},
6820
+ },
6671
6821
  writeAddonStore: async (patch) => {
6672
6822
  await writeAddon(patch);
6673
6823
  },
@@ -7294,7 +7444,7 @@ var BaseAddon = class {
7294
7444
  if (!ctx) return;
7295
7445
  const addonId = ctx.id;
7296
7446
  setImmediate(() => {
7297
- ctx.api.addons?.restartAddon?.mutate({ addonId }).then(() => {
7447
+ ctx.api.addons.restartAddon.mutate({ addonId }).then(() => {
7298
7448
  ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
7299
7449
  }).catch((err) => {
7300
7450
  ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
@@ -7494,7 +7644,7 @@ var BaseAddon = class {
7494
7644
  return this._addonSecretTree;
7495
7645
  }
7496
7646
  deviceSecretTree() {
7497
- this._deviceSecretTree ??= secretTreeFromSchema(this.deviceSettingsSchema());
7647
+ this._deviceSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.deviceSettingsSchema()), this.secretStatePaths);
7498
7648
  return this._deviceSecretTree;
7499
7649
  }
7500
7650
  /**
@@ -7570,42 +7720,135 @@ var BaseAddon = class {
7570
7720
  this[timerOf] = timer;
7571
7721
  }
7572
7722
  /**
7573
- * Wrap `ctx.settings.readAddonStore()` with a short retry budget so a
7574
- * transient settings-store outage (mid-restart of sqlite-settings, tsx-watch
7575
- * swap, or any race where the SqliteSettingsBackend is between shutdown and
7576
- * re-initialize) doesn't propagate up into `initialize()` and leave the
7723
+ * Wrap `ctx.settings.readAddonStore()` with a retry budget so a transient
7724
+ * settings-store outage doesn't propagate up into `initialize()` and leave the
7577
7725
  * addon permanently broken.
7578
7726
  *
7579
- * Retry only the two known infra fingerprints. Anything else propagates so
7580
- * real bugs surface immediately. After the budget expires we fall back to
7581
- * `{}` (defaults) — the addon's first successful patch will rehydrate.
7727
+ * Two kinds of outage, two budgets:
7728
+ * - the store's own restart fingerprints (`SqliteSettingsBackend not
7729
+ * initialized`, `provider not available`): a short budget, then the addon
7730
+ * falls back to `{}` (defaults) - its first successful patch rehydrates;
7731
+ * - a TRANSPORT failure (the hub is restarting while this runner boots:
7732
+ * `discovery deadline exceeded`, `parent could not route`, a refused or
7733
+ * timed-out connection). Since D870 a runner's settings read THROWS instead
7734
+ * of answering `{}`, so without a budget a hub restart ends in a respawn
7735
+ * loop. A long, bounded budget; only after it the error propagates - the
7736
+ * addon never runs on defaults for a store it could not ask.
7737
+ * Anything else propagates immediately so real bugs surface.
7582
7738
  */
7583
7739
  async readAddonStoreWithRetry() {
7584
7740
  const settings = this.rawSettings();
7585
7741
  if (!settings) return {};
7586
- const delaysMs = [
7587
- 150,
7588
- 350,
7589
- 600,
7590
- 900
7591
- ];
7592
7742
  let lastErr;
7593
- for (let attempt = 0; attempt <= delaysMs.length; attempt++) try {
7743
+ for (let attempt = 0;; attempt++) try {
7594
7744
  const stored = await settings.readAddonStore() ?? {};
7595
7745
  this.settingsStoreReady = true;
7596
7746
  return stored;
7597
7747
  } catch (err) {
7598
7748
  lastErr = err;
7599
- const msg = err instanceof Error ? err.message : String(err);
7600
- if (!(msg.includes("SqliteSettingsBackend not initialized") || msg.includes("provider not available"))) throw err;
7601
- if (attempt === delaysMs.length) break;
7602
- await new Promise((r) => setTimeout(r, delaysMs[attempt]));
7749
+ const kind = classifyStoreError(err);
7750
+ if (kind === "permanent") throw err;
7751
+ const delay = (kind === "transport" ? TRANSPORT_RETRY_DELAYS_MS : RESTART_RETRY_DELAYS_MS)[attempt];
7752
+ if (delay === void 0) {
7753
+ if (kind === "transport") throw err;
7754
+ break;
7755
+ }
7756
+ await new Promise((r) => setTimeout(r, delay));
7603
7757
  }
7604
7758
  this.settingsStoreReady = false;
7605
7759
  this._ctx?.logger?.warn?.("readAddonStore: settings-store unavailable after retries — using defaults", { meta: { error: lastErr instanceof Error ? lastErr.message : String(lastErr) } });
7606
7760
  return {};
7607
7761
  }
7608
7762
  };
7763
+ /** The settings store's own restart fingerprints. */
7764
+ var RESTART_RETRY_DELAYS_MS = [
7765
+ 150,
7766
+ 350,
7767
+ 600,
7768
+ 900
7769
+ ];
7770
+ /** A hub restarting under a booting runner: ~100 s in total. */
7771
+ var TRANSPORT_RETRY_DELAYS_MS = [
7772
+ 150,
7773
+ 350,
7774
+ 600,
7775
+ 900,
7776
+ 2e3,
7777
+ 5e3,
7778
+ 1e4,
7779
+ 2e4,
7780
+ 3e4,
7781
+ 3e4
7782
+ ];
7783
+ var RESTART_FINGERPRINTS = ["SqliteSettingsBackend not initialized", "provider not available"];
7784
+ /** Node / socket error codes of a connection that did not happen or broke. */
7785
+ var TRANSPORT_CODES = new Set([
7786
+ "ECONNREFUSED",
7787
+ "ECONNRESET",
7788
+ "ETIMEDOUT",
7789
+ "EPIPE",
7790
+ "EHOSTUNREACH",
7791
+ "ENETUNREACH"
7792
+ ]);
7793
+ /** tRPC error codes that mean "the other side is not answering now", not "your call is wrong". */
7794
+ var UNAVAILABLE_TRPC_CODES = new Set([
7795
+ "TIMEOUT",
7796
+ "SERVICE_UNAVAILABLE",
7797
+ "BAD_GATEWAY",
7798
+ "GATEWAY_TIMEOUT"
7799
+ ]);
7800
+ /** The exact phrases OUR transport raises when it cannot reach the hub. */
7801
+ var TRANSPORT_PHRASES = [
7802
+ "discovery deadline exceeded",
7803
+ "parent could not route child unowned cap call",
7804
+ "UDS request timed out after",
7805
+ "channel closed"
7806
+ ];
7807
+ /** Moleculer error `type`s of a call that could not be served right now. */
7808
+ var MOLECULER_TRANSIENT_TYPES = new Set([
7809
+ "REQUEST_TIMEOUT",
7810
+ "SERVICE_NOT_FOUND",
7811
+ "SERVICE_NOT_AVAILABLE",
7812
+ "REQUEST_REJECTED",
7813
+ "BROKER_DISCONNECTED"
7814
+ ]);
7815
+ function stringProp(value, key) {
7816
+ if (typeof value !== "object" || value === null) return void 0;
7817
+ const found = Reflect.get(value, key);
7818
+ return typeof found === "string" ? found : void 0;
7819
+ }
7820
+ /** The code an error carries: its own, its cause's, or a tRPC `data.code`. */
7821
+ function errorCode(err) {
7822
+ const out = {};
7823
+ const cause = typeof err === "object" && err !== null ? Reflect.get(err, "cause") : void 0;
7824
+ const data = typeof err === "object" && err !== null ? Reflect.get(err, "data") : void 0;
7825
+ const node = stringProp(err, "code") ?? stringProp(cause, "code");
7826
+ if (node !== void 0) out.node = node;
7827
+ const trpc = stringProp(data, "code");
7828
+ if (trpc !== void 0) out.trpc = trpc;
7829
+ return out;
7830
+ }
7831
+ /**
7832
+ * Is a settings read failure worth retrying, and with which budget? Only
7833
+ * EXPLICIT signals count: a socket error code, a tRPC "unavailable" code, or
7834
+ * one of the exact phrases our own transport raises. A message that merely
7835
+ * contains "timed out" or "unreachable" is not evidence of anything, and
7836
+ * `settings store not wired` is a wiring bug that retrying cannot fix.
7837
+ */
7838
+ function classifyStoreError(err) {
7839
+ const message = err instanceof Error ? err.message : String(err);
7840
+ if (RESTART_FINGERPRINTS.some((f) => message.includes(f))) return "restart";
7841
+ const code = errorCode(err);
7842
+ if (code.node !== void 0 && TRANSPORT_CODES.has(code.node)) return "transport";
7843
+ if (code.trpc !== void 0 && UNAVAILABLE_TRPC_CODES.has(code.trpc)) return "transport";
7844
+ if (typeof err === "object" && err !== null) {
7845
+ if (Reflect.get(err, "retryable") === true) return "transport";
7846
+ const type = stringProp(err, "type");
7847
+ if (type !== void 0 && MOLECULER_TRANSIENT_TYPES.has(type)) return "transport";
7848
+ }
7849
+ if (TRANSPORT_PHRASES.some((f) => message.includes(f))) return "transport";
7850
+ return "permanent";
7851
+ }
7609
7852
  /**
7610
7853
  * Collect the keys of every field marked `perNode: true`, recursing into
7611
7854
  * layout containers (`group` fields and `sub-tabs` tabs) the same way
@@ -7695,6 +7938,356 @@ var PeerBytesTicketSchema = object({
7695
7938
  */
7696
7939
  declaredBytes: number().int().nonnegative().nullable()
7697
7940
  });
7941
+ /** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
7942
+ /** The files a kind may live in. `history` is device-history's (D850), never records. */
7943
+ var RECORD_DATABASES = ["settings", "events"];
7944
+ /** The classes of a kind: the `@durable` vocabulary, one authority (replaces the annotation). */
7945
+ var RECORD_CLASSES = [
7946
+ "config",
7947
+ "ledger",
7948
+ "audit",
7949
+ "mirror",
7950
+ "ephemeral"
7951
+ ];
7952
+ var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
7953
+ var RECORD_MAX_DATA_BYTES = 1024 * 1024;
7954
+ var RECORD_BATCH_MAX = 1e3;
7955
+ var RECORD_QUERY_MAX = 1e3;
7956
+ /** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
7957
+ var RECORD_SETTINGS_MAX_ROWS = 5e4;
7958
+ var PREFIX = "records/";
7959
+ /** The base of every records failure. `detail` is the human part of the message. */
7960
+ var RecordsError = class extends Error {
7961
+ code;
7962
+ detail;
7963
+ constructor(code, detail) {
7964
+ super(`${PREFIX}${code}: ${detail}`);
7965
+ this.name = "RecordsError";
7966
+ this.code = code;
7967
+ this.detail = detail;
7968
+ }
7969
+ };
7970
+ /** The keychain could not store or serve a value: explicit, never an empty string. */
7971
+ var RecordSecretUnavailableError = class extends RecordsError {
7972
+ constructor(detail) {
7973
+ super("secret-unavailable", detail);
7974
+ this.name = "RecordSecretUnavailableError";
7975
+ }
7976
+ };
7977
+ var InvalidRecordError = class extends RecordsError {
7978
+ constructor(detail) {
7979
+ super("invalid-record", detail);
7980
+ this.name = "InvalidRecordError";
7981
+ }
7982
+ };
7983
+ /** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
7984
+ var DeclarationRefusedError = class extends RecordsError {
7985
+ constructor(detail) {
7986
+ super("declaration-refused", detail);
7987
+ this.name = "DeclarationRefusedError";
7988
+ }
7989
+ };
7990
+ function defOf(schema) {
7991
+ const zodBag = Reflect.get(schema, "_zod");
7992
+ if (typeof zodBag !== "object" || zodBag === null) return {};
7993
+ const def = Reflect.get(zodBag, "def");
7994
+ if (typeof def !== "object" || def === null) return {};
7995
+ return def;
7996
+ }
7997
+ function declaredHere(schema) {
7998
+ return globalRegistry.get(schema)?.secret === true;
7999
+ }
8000
+ /** Wrapper kinds whose `innerType` is the field itself. */
8001
+ var WRAPPERS = new Set([
8002
+ "optional",
8003
+ "nullable",
8004
+ "default",
8005
+ "prefault",
8006
+ "catch",
8007
+ "readonly",
8008
+ "nonoptional"
8009
+ ]);
8010
+ /**
8011
+ * The schema layers that make up ONE field: the schema itself and every
8012
+ * wrapper below it (optional / default / nullable / readonly / catch), plus
8013
+ * both sides of a pipe (`z.preprocess` puts the real schema on `out`,
8014
+ * `.transform` on `in`).
8015
+ */
8016
+ function layersOf(schema) {
8017
+ const out = [];
8018
+ const queue = [schema];
8019
+ while (queue.length > 0) {
8020
+ const s = queue.shift();
8021
+ if (!s || out.includes(s)) continue;
8022
+ out.push(s);
8023
+ const def = defOf(s);
8024
+ if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
8025
+ if (def.type === "pipe") {
8026
+ if (def.in) queue.push(def.in);
8027
+ if (def.out) queue.push(def.out);
8028
+ }
8029
+ }
8030
+ return out;
8031
+ }
8032
+ /** True when any layer of this field declares `.meta({ secret: true })`. */
8033
+ function isZodSecret(schema) {
8034
+ return layersOf(schema).some(declaredHere);
8035
+ }
8036
+ /**
8037
+ * Every declared secret path in a config schema: dotted keys, `[]` for "each
8038
+ * element of this array" (`connection.password`, `rows[].token`). A declared
8039
+ * object or array is reported as one path and not descended into — everything
8040
+ * under it is secret.
8041
+ */
8042
+ function collectZodSecretPaths(schema, prefix = "") {
8043
+ if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
8044
+ const paths = [];
8045
+ for (const layer of layersOf(schema)) {
8046
+ const def = defOf(layer);
8047
+ if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
8048
+ else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
8049
+ else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
8050
+ else if (def.type === "intersection") {
8051
+ if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
8052
+ if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
8053
+ }
8054
+ }
8055
+ return [...new Set(paths)];
8056
+ }
8057
+ /**
8058
+ * Secret fields of a record, addressed the way a Zod schema declares them
8059
+ * (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
8060
+ * (`auth.accessToken`, `headers[].value`).
8061
+ *
8062
+ * Array elements are matched by a DECLARED id key (`secretArrayKeys`:
8063
+ * `{ headers: 'name' }`), never by index, so reordering a list keeps every
8064
+ * keychain ref (the same rule as `arrayItemFieldPath`). The concrete path of a
8065
+ * leaf names its element: `headers[X-Api].value`.
8066
+ *
8067
+ * Pure and browser-safe. Nothing here mutates: every transform returns a new value.
8068
+ */
8069
+ /** The array prefixes (declared form, e.g. `headers` or `a.headers`) of a path. */
8070
+ function parseSecretPath(path) {
8071
+ if (path.length === 0) throw new InvalidRecordError("an empty secret path");
8072
+ return path.split(".").map((raw) => {
8073
+ const each = raw.endsWith("[]");
8074
+ const key = each ? raw.slice(0, -2) : raw;
8075
+ if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
8076
+ return {
8077
+ key,
8078
+ each
8079
+ };
8080
+ });
8081
+ }
8082
+ /** The declared array prefixes of `path` that need an id key (`headers`, `a.rows`). */
8083
+ function secretArrayPrefixes(path) {
8084
+ const segments = parseSecretPath(path);
8085
+ const prefixes = [];
8086
+ const walked = [];
8087
+ for (const segment of segments) {
8088
+ walked.push(segment.key);
8089
+ if (segment.each) prefixes.push(walked.join("."));
8090
+ }
8091
+ return prefixes;
8092
+ }
8093
+ /**
8094
+ * Record kinds (D881): the declaration an addon makes of one kind of fact, the
8095
+ * Zod row schema that describes it, and the helper that turns the two into the
8096
+ * JSON the engine stores.
8097
+ *
8098
+ * A kind is declared ONCE, next to the code that owns it, and the engine's
8099
+ * reconciler creates its indexes - nothing creates DDL at runtime from a write.
8100
+ * Everything the generic machinery needs (secret fields, the entry descriptor)
8101
+ * is DERIVED from the Zod schema: `.meta({ secret: true })` marks a credential,
8102
+ * never a field name (D879).
8103
+ */
8104
+ /** A JSON field path: `trackId`, `auth.accessToken`. Charset-restricted: it is rendered into DDL. */
8105
+ var RecordFieldPathSchema = string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,63}(\.[A-Za-z_][A-Za-z0-9_]{0,63}){0,3}$/);
8106
+ var RecordIndexSchema = object({
8107
+ name: string().regex(/^[a-z][a-z0-9_]{0,31}$/),
8108
+ fields: array(RecordFieldPathSchema).min(1).max(4),
8109
+ unique: boolean().optional()
8110
+ }).strict();
8111
+ var RecordRetentionSchema = union([
8112
+ object({
8113
+ ttlMs: number().int().positive(),
8114
+ from: _enum(["at", "write"])
8115
+ }).strict(),
8116
+ object({
8117
+ maxRows: number().int().positive().optional(),
8118
+ maxRowsPerDevice: number().int().positive().optional()
8119
+ }).strict().refine((r) => r.maxRows !== void 0 || r.maxRowsPerDevice !== void 0, { message: "name maxRows, maxRowsPerDevice or both" }),
8120
+ object({
8121
+ owner: string().min(1),
8122
+ reason: string().min(1)
8123
+ }).strict(),
8124
+ object({ none: string().min(1) }).strict()
8125
+ ]);
8126
+ /** The descriptor a generic entries UI reads (D881 "generic entries"). */
8127
+ var EntryDescriptorSchema = object({
8128
+ title: string().min(1),
8129
+ /** The record body field shown as the entry's name. */
8130
+ nameField: string().min(1),
8131
+ /** JSON Schema of the entry body; `secret: true` marks a password field. */
8132
+ fields: record(string(), unknown())
8133
+ }).strict();
8134
+ /** What crosses the wire and sits in the engine's catalog: JSON only, no Zod. */
8135
+ var RecordKindDeclarationSchema = object({
8136
+ database: _enum(RECORD_DATABASES).default("settings"),
8137
+ class: _enum(RECORD_CLASSES),
8138
+ writeTrigger: string().min(1),
8139
+ device: _enum([
8140
+ "required",
8141
+ "optional",
8142
+ "none"
8143
+ ]).default("none"),
8144
+ at: _enum(["required", "none"]).default("none"),
8145
+ indexes: array(RecordIndexSchema).max(8).default([]),
8146
+ retention: RecordRetentionSchema,
8147
+ deviceRemoval: _enum(["delete", "none"]).default("none"),
8148
+ maxDataBytes: number().int().positive().max(RECORD_MAX_DATA_BYTES).default(RECORD_DEFAULT_MAX_DATA_BYTES),
8149
+ /** Derived from the Zod schema; never written by hand. */
8150
+ secretPaths: array(string().min(1)).default([]),
8151
+ /** The id key of each array that carries a secret (`{ headers: 'name' }`). */
8152
+ secretArrayKeys: record(string(), string()).default({}),
8153
+ /** The legacy table this kind adopts from; the boot guard reads it (D853: no migration code). */
8154
+ adoptsFrom: string().min(1).optional(),
8155
+ /** Kinds that must agree through `transact` sit in one file under one family name. */
8156
+ transactFamily: string().min(1).optional(),
8157
+ entry: EntryDescriptorSchema.optional()
8158
+ }).strict();
8159
+ /** The kind names: lower-case, dash separated, short enough for an index name. */
8160
+ var RecordKindNameSchema = string().regex(/^[a-z][a-z0-9-]{0,47}$/);
8161
+ /** Cross-field rules a declaration must satisfy. Throws {@link DeclarationRefusedError}. */
8162
+ function assertValidDeclaration(name, decl) {
8163
+ const refuse = (why) => {
8164
+ throw new DeclarationRefusedError(`kind "${name}": ${why}`);
8165
+ };
8166
+ if (!RecordKindNameSchema.safeParse(name).success) refuse("the name must be lower-case-dashed");
8167
+ const seen = /* @__PURE__ */ new Set();
8168
+ for (const index of decl.indexes) {
8169
+ if (seen.has(index.name)) refuse(`index name "${index.name}" is declared twice`);
8170
+ seen.add(index.name);
8171
+ }
8172
+ const { retention } = decl;
8173
+ const hasSecrets = decl.secretPaths.length > 0;
8174
+ if ("ttlMs" in retention) {
8175
+ if (retention.from === "at" && decl.at !== "required") refuse("a ttl from \"at\" needs at: \"required\"");
8176
+ if (hasSecrets) refuse("a kind with secret fields cannot use engine TTL (its keychain values would be orphaned)");
8177
+ }
8178
+ if ("maxRows" in retention || "maxRowsPerDevice" in retention) {
8179
+ if (retention.maxRowsPerDevice !== void 0 && decl.device !== "required") refuse("maxRowsPerDevice needs device: \"required\"");
8180
+ if (decl.at !== "required") refuse("a row bound trims the oldest \"at\": it needs at: \"required\"");
8181
+ if (hasSecrets) refuse("a kind with secret fields cannot use an engine row bound");
8182
+ const bound = Math.max(retention.maxRows ?? 0, retention.maxRowsPerDevice ?? 0);
8183
+ 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)`);
8184
+ }
8185
+ if (decl.deviceRemoval === "delete" && decl.device === "none") refuse("deviceRemoval: \"delete\" needs a device: \"required\" or \"optional\"");
8186
+ 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`);
8187
+ }
8188
+ function bodyFieldsOf(schema) {
8189
+ return { ...toJSONSchema(schema, {
8190
+ unrepresentable: "any",
8191
+ io: "input"
8192
+ }) };
8193
+ }
8194
+ function isRecordLike(value) {
8195
+ return typeof value === "object" && value !== null && !Array.isArray(value);
8196
+ }
8197
+ /** Does every branch of the body schema carry `field`? (A discriminated union has several.) */
8198
+ function hasNameField(json, field) {
8199
+ const branches = json["oneOf"] ?? json["anyOf"];
8200
+ if (Array.isArray(branches)) return branches.length > 0 && branches.every((b) => isRecordLike(b) && hasNameField(b, field));
8201
+ const properties = json["properties"];
8202
+ return isRecordLike(properties) && Object.prototype.hasOwnProperty.call(properties, field);
8203
+ }
8204
+ /**
8205
+ * Declare the kinds of a package. The keys are the kind names. The result is
8206
+ * what `ctx.records.declare` sends to the engine and what `ctx.records.kind`
8207
+ * types its handle from.
8208
+ */
8209
+ function defineRecordKinds(specs) {
8210
+ const out = {};
8211
+ for (const [name, spec] of Object.entries(specs)) {
8212
+ const secretPaths = collectZodSecretPaths(spec.schema);
8213
+ const nameField = spec.entry?.nameField ?? "name";
8214
+ const fields = bodyFieldsOf(spec.schema);
8215
+ if (spec.entry !== void 0 && !hasNameField(fields, nameField)) throw new DeclarationRefusedError(`kind "${name}": an entry kind's schema needs a "${nameField}" field`);
8216
+ const parsed = RecordKindDeclarationSchema.parse({
8217
+ database: spec.database,
8218
+ class: spec.class,
8219
+ writeTrigger: spec.writeTrigger,
8220
+ device: spec.device,
8221
+ at: spec.at,
8222
+ indexes: spec.indexes === void 0 ? void 0 : [...spec.indexes],
8223
+ retention: spec.retention,
8224
+ deviceRemoval: spec.deviceRemoval,
8225
+ maxDataBytes: spec.maxDataBytes,
8226
+ secretPaths: [...secretPaths],
8227
+ secretArrayKeys: spec.secretArrayKeys === void 0 ? void 0 : { ...spec.secretArrayKeys },
8228
+ adoptsFrom: spec.adoptsFrom,
8229
+ transactFamily: spec.transactFamily,
8230
+ entry: spec.entry === void 0 ? void 0 : {
8231
+ title: spec.entry.title,
8232
+ nameField,
8233
+ fields
8234
+ }
8235
+ });
8236
+ assertValidDeclaration(name, parsed);
8237
+ out[name] = {
8238
+ name,
8239
+ schema: spec.schema,
8240
+ declaration: parsed
8241
+ };
8242
+ }
8243
+ return out;
8244
+ }
8245
+ /**
8246
+ * Entry kinds (D881): every list of user-created entries (notification
8247
+ * targets, brokers, LLM profiles) is ONE record kind with an id, a name and a
8248
+ * kind-specific body, and the admin UI lists/adds/edits/deletes all of them
8249
+ * through the `record-entries` capability with password fields derived from
8250
+ * the schema (`.meta({ secret: true })`).
8251
+ */
8252
+ /** The body of a plain entry: a name and the fields the kind adds. */
8253
+ function entryBody(shape) {
8254
+ return object({
8255
+ name: string().min(1),
8256
+ ...shape
8257
+ });
8258
+ }
8259
+ /**
8260
+ * Declare one entry kind. An entry is configuration: never trimmed by the
8261
+ * engine, never aged, belonging to no device.
8262
+ */
8263
+ function defineEntryKind(name, spec) {
8264
+ const defined = defineRecordKinds({ [name]: {
8265
+ schema: spec.schema,
8266
+ class: "config",
8267
+ writeTrigger: spec.writeTrigger ?? "an operator adds or edits an entry in the entries UI",
8268
+ retention: { none: "an entry goes only when the operator deletes it" },
8269
+ ...spec.database === void 0 ? {} : { database: spec.database },
8270
+ ...spec.indexes === void 0 ? {} : { indexes: spec.indexes },
8271
+ ...spec.secretArrayKeys === void 0 ? {} : { secretArrayKeys: spec.secretArrayKeys },
8272
+ ...spec.adoptsFrom === void 0 ? {} : { adoptsFrom: spec.adoptsFrom },
8273
+ entry: {
8274
+ title: spec.title,
8275
+ ...spec.nameField === void 0 ? {} : { nameField: spec.nameField }
8276
+ }
8277
+ } })[name];
8278
+ if (defined === void 0) throw new DeclarationRefusedError(`entry kind "${name}" was not built`);
8279
+ return defined;
8280
+ }
8281
+ /**
8282
+ * Legacy source for broker entry adoption (B2): brokers live in addon-settings
8283
+ * as one row `<addonId>.brokers` whose value is an array until records-adopt
8284
+ * copies them into the entry kind.
8285
+ */
8286
+ var SETTINGS_BROKERS_ADOPTS_PREFIX = "@settings-brokers/";
8287
+ /** The `adoptsFrom` value for an addon's broker entry kind. */
8288
+ function settingsBrokersAdoptsFrom(addonId) {
8289
+ return `${SETTINGS_BROKERS_ADOPTS_PREFIX}${addonId}`;
8290
+ }
7698
8291
  /** Shared Zod schemas used across streaming capabilities. */
7699
8292
  var CamProfileSchema = _enum([
7700
8293
  "high",
@@ -8174,7 +8767,7 @@ function userError(code, params, englishFallback) {
8174
8767
  return new CamstackError(code, params, englishFallback);
8175
8768
  }
8176
8769
  //#endregion
8177
- //#region ../types/dist/err-msg-DLerKiVO.mjs
8770
+ //#region ../types/dist/err-msg-BXKzRBwg.mjs
8178
8771
  var DeviceType = /* @__PURE__ */ function(DeviceType) {
8179
8772
  DeviceType["Camera"] = "camera";
8180
8773
  DeviceType["Hub"] = "hub";
@@ -8266,6 +8859,10 @@ var DeviceType = /* @__PURE__ */ function(DeviceType) {
8266
8859
  * native PetKit (`nodepetkit` `FeederDevice`), reusable by other feeder
8267
8860
  * integrations sharing the same food/desiccant/hopper surface. */
8268
8861
  DeviceType["PetFeeder"] = "pet-feeder";
8862
+ /** Built-in dishwasher — program lifecycle, door / remote-start gates,
8863
+ * salt and rinse-aid levels. Installed with the `dishwasher` cap.
8864
+ * Sources: native Bosch Home Connect, reusable by similar integrations. */
8865
+ DeviceType["Dishwasher"] = "dishwasher";
8269
8866
  return DeviceType;
8270
8867
  }({});
8271
8868
  var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
@@ -8443,6 +9040,9 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
8443
9040
  /** Virtual HA toggle (input_boolean.*) — distinguishable from a
8444
9041
  * real Switch device for UI rendering / export adapters. */
8445
9042
  DeviceRole["BinaryHelper"] = "binary-helper";
9043
+ /** A smart plug: a `switch` whose source says it is an outlet (HA
9044
+ * `device_class: outlet`). The Alexa export shows it as a SMARTPLUG. */
9045
+ DeviceRole["Outlet"] = "outlet";
8446
9046
  /** Generic motion / occupancy / moving event source. Distinct from
8447
9047
  * the camera accessory PirSensor role: that one is a camera child;
8448
9048
  * this is a standalone HA / 3rd-party motion sensor. */
@@ -8510,7 +9110,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
8510
9110
  return DeviceRole;
8511
9111
  }({});
8512
9112
  //#endregion
8513
- //#region ../types/dist/composition-EQ9Ok0Ee.mjs
9113
+ //#region ../types/dist/composition-CB6PMT9p.mjs
8514
9114
  /**
8515
9115
  * The ffmpeg build every CamStack node downloads, per platform and arch.
8516
9116
  *
@@ -11831,11 +12431,10 @@ var ClipModelMetaSchema = object({
11831
12431
  /**
11832
12432
  * The `vector-store` index this model's vectors live in. ONE feature space
11833
12433
  * per index: two models share an index only when their vectors are ranked
11834
- * against each other, which for CLIP means never across families. MobileCLIP
11835
- * S1 and S2 share `object-clip` for history (separated by the row's
11836
- * `modelId`); any other model gets its own.
12434
+ * against each other, which for CLIP means never across families. Every
12435
+ * model gets its own.
11837
12436
  */
11838
- vectorIndex: string().regex(/^object-clip(-[a-z0-9][a-z0-9-]*)?$/),
12437
+ vectorIndex: string().regex(/^object-clip-[a-z0-9][a-z0-9-]*$/),
11839
12438
  /**
11840
12439
  * The text encoder's tokenizer, a declared SIBLING file of its onnx. The name
11841
12440
  * must be unique per tokenizer: every model's siblings land in ONE flat
@@ -13033,8 +13632,13 @@ var AlertSeveritySchema = _enum([
13033
13632
  "info",
13034
13633
  "success",
13035
13634
  "warning",
13036
- "error"
13635
+ "error",
13636
+ "critical"
13037
13637
  ]);
13638
+ var AlertActionSchema = object({
13639
+ label: string(),
13640
+ href: string().optional()
13641
+ });
13038
13642
  var AlertStatusSchema = _enum([
13039
13643
  "active",
13040
13644
  "in-progress",
@@ -13052,6 +13656,7 @@ var AlertSchema = object({
13052
13656
  severity: AlertSeveritySchema,
13053
13657
  title: string(),
13054
13658
  message: string(),
13659
+ action: AlertActionSchema.optional(),
13055
13660
  status: AlertStatusSchema,
13056
13661
  progress: number().optional(),
13057
13662
  read: boolean(),
@@ -15530,6 +16135,41 @@ var ComposableCapabilitiesSchema = object({ caps: array(object({
15530
16135
  keyField: string()
15531
16136
  }).optional()
15532
16137
  })) });
16138
+ /**
16139
+ * The report of a one-shot "move this owner's plaintext secrets into the
16140
+ * keychain" run (D878). COUNTS only - never a value, never a ref.
16141
+ *
16142
+ * The owner runs it on its own rows, through its own write path; an operator
16143
+ * script (`scripts/hub/migrate-raw-secrets.ts`) calls the owner's cap method.
16144
+ * Dry run (`apply: false`) reports what WOULD move and changes nothing.
16145
+ */
16146
+ var RawSecretMigrationInputSchema = object({
16147
+ /** `false` (the default of the script) = report only. */
16148
+ apply: boolean() });
16149
+ var RawSecretMigrationReportSchema = object({
16150
+ apply: boolean(),
16151
+ /** Rows that can carry a secret (a profile, an enrolment). */
16152
+ rows: number().int(),
16153
+ /** Rows whose secret was plaintext when the run started. */
16154
+ raw: number().int(),
16155
+ /** Rows that already held a keychain marker when the run started. */
16156
+ markers: number().int(),
16157
+ /** Plaintext rows moved by THIS run (always 0 on a dry run). */
16158
+ migrated: number().int(),
16159
+ /** Plaintext rows left in place because the move or its read-back failed. */
16160
+ failed: number().int(),
16161
+ /** After the run: rows still holding plaintext. */
16162
+ remainingRaw: number().int(),
16163
+ /** After the run: markers the keychain could not resolve right now. */
16164
+ unresolvedMarkers: number().int(),
16165
+ /**
16166
+ * A second, redundant copy of the secrets' rows that the run found (and, on
16167
+ * `apply`, deleted after verifying the first). Owners with a single copy omit it.
16168
+ */
16169
+ redundantCopies: number().int().optional(),
16170
+ /** True when nothing is raw and every marker resolves. */
16171
+ verified: boolean()
16172
+ });
15533
16173
  /** Where a block runs. The operator chooses — a block driving a device on an
15534
16174
  * agent is the reason placement is not fixed to the hub. */
15535
16175
  var CoreBlockPlacementSchema = union([literal("hub"), string().min(1)]);
@@ -15756,6 +16396,9 @@ method(object({}), object({ blocks: array(CoreBlockSchema) }), { auth: "admin" }
15756
16396
  }), SettingsUpdateResultSchema, {
15757
16397
  kind: "mutation",
15758
16398
  auth: "admin"
16399
+ }), method(RawSecretMigrationInputSchema, RawSecretMigrationReportSchema, {
16400
+ kind: "mutation",
16401
+ auth: "admin"
15759
16402
  }), method(object({}), object({ libs: array(object({
15760
16403
  filePath: string(),
15761
16404
  content: string()
@@ -16019,6 +16662,347 @@ id: union([string(), number()]) }), {
16019
16662
  auth: "admin"
16020
16663
  });
16021
16664
  /**
16665
+ * records - an addon's own facts and documents (D881): ledgers, audit rows,
16666
+ * config documents, mirrors. The third storage API next to `ctx.settings`
16667
+ * (operator intent, D870) and device-history (numbers over time, D850).
16668
+ *
16669
+ * Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
16670
+ * crossed a process and stated by a hub in-process caller (`ctx.records` does
16671
+ * that with the addon id closed over). It is deliberately NOT in any input
16672
+ * schema, so a session can never supply it, and a call with no stamp is refused
16673
+ * `records/no-caller`. A kind is readable and writable only by its owner; other
16674
+ * addons go through the owner's capability.
16675
+ *
16676
+ * Every read is three-way: a row, `null`, or the call THROWS. A failed read is
16677
+ * never `[]`. Secret fields are never on the wire: a read shows the
16678
+ * redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
16679
+ * resolves itself, and a write may carry only a keychain marker bound to the
16680
+ * row's own ref.
16681
+ *
16682
+ * Internal: addons reach it through `ctx.records`, never directly.
16683
+ */
16684
+ var RecordIdSchema = string().min(1).max(256);
16685
+ /** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
16686
+ var RecordBodySchema = record(string(), unknown());
16687
+ var RecordInputSchema = object({
16688
+ id: RecordIdSchema,
16689
+ /** The device this row belongs to (D865 removal, per-device reads). */
16690
+ deviceId: number().int().optional(),
16691
+ /** The domain clock, ms: observed / created / opened. */
16692
+ at: number().int().optional(),
16693
+ /** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
16694
+ expiresAt: number().int().optional(),
16695
+ data: RecordBodySchema
16696
+ });
16697
+ var RecordViewSchema = object({
16698
+ id: string(),
16699
+ deviceId: number().int().nullable(),
16700
+ at: number().nullable(),
16701
+ expiresAt: number().nullable(),
16702
+ rev: number().int(),
16703
+ updatedAt: number(),
16704
+ data: RecordBodySchema
16705
+ });
16706
+ /** Declared index fields only. Anything else does not compile, by design. */
16707
+ var RecordWhereSchema = record(RecordFieldPathSchema, union([
16708
+ string(),
16709
+ number(),
16710
+ boolean(),
16711
+ object({ in: array(union([
16712
+ string(),
16713
+ number(),
16714
+ boolean()
16715
+ ])).min(1).max(RECORD_BATCH_MAX) }),
16716
+ object({
16717
+ gt: union([string(), number()]).optional(),
16718
+ gte: union([string(), number()]).optional(),
16719
+ lt: union([string(), number()]).optional(),
16720
+ lte: union([string(), number()]).optional()
16721
+ }).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
16722
+ ]));
16723
+ var KindShape = { kind: RecordKindNameSchema };
16724
+ var TimeWindowShape = {
16725
+ deviceId: number().int().optional(),
16726
+ atFrom: number().optional(),
16727
+ atTo: number().optional()
16728
+ };
16729
+ var RecordQueryInputSchema = object({
16730
+ ...KindShape,
16731
+ ...TimeWindowShape,
16732
+ where: RecordWhereSchema.optional(),
16733
+ /** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
16734
+ order: _enum(["at", "id"]).optional(),
16735
+ desc: boolean().optional(),
16736
+ limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
16737
+ /** Opaque keyset cursor from a previous answer. There is no offset. */
16738
+ cursor: string().min(1).optional()
16739
+ });
16740
+ var RecordQueryResultSchema = object({
16741
+ records: array(RecordViewSchema),
16742
+ nextCursor: string().nullable()
16743
+ });
16744
+ var RecordKindStateSchema = _enum([
16745
+ "created",
16746
+ "unchanged",
16747
+ "updated"
16748
+ ]);
16749
+ var DeclareKindResultSchema = object({
16750
+ kindId: number().int(),
16751
+ state: RecordKindStateSchema,
16752
+ createdIndexes: array(string()),
16753
+ /** The boot guard: the kind is empty while its legacy table still holds rows. */
16754
+ adoptionPending: object({
16755
+ legacyTable: string(),
16756
+ legacyRows: number().int()
16757
+ }).nullable()
16758
+ });
16759
+ /** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
16760
+ var SecretRefsList = array(string());
16761
+ var RecordSecretRefsSchema = record(string(), record(string(), string()));
16762
+ method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
16763
+ kind: "mutation",
16764
+ auth: "admin"
16765
+ }), method(object({
16766
+ ...KindShape,
16767
+ id: RecordIdSchema
16768
+ }), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
16769
+ ...KindShape,
16770
+ ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
16771
+ }), array(RecordViewSchema), { auth: "admin" }), method(object({
16772
+ ...KindShape,
16773
+ ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
16774
+ }), RecordSecretRefsSchema, { auth: "admin" }), method(object({
16775
+ ...KindShape,
16776
+ record: RecordInputSchema,
16777
+ /** Compare-and-set. `0` means "the row must not exist". */
16778
+ ifRev: number().int().min(0).optional()
16779
+ }), object({
16780
+ rev: number().int(),
16781
+ releasedRefs: SecretRefsList
16782
+ }), {
16783
+ kind: "mutation",
16784
+ auth: "admin"
16785
+ }), method(object({
16786
+ ...KindShape,
16787
+ records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
16788
+ }), object({
16789
+ count: number().int(),
16790
+ releasedRefs: SecretRefsList
16791
+ }), {
16792
+ kind: "mutation",
16793
+ auth: "admin"
16794
+ }), method(object({
16795
+ ...KindShape,
16796
+ id: RecordIdSchema,
16797
+ data: RecordBodySchema,
16798
+ at: number().int().nullable().optional(),
16799
+ expiresAt: number().int().nullable().optional(),
16800
+ ifRev: number().int().min(1).optional()
16801
+ }), object({
16802
+ rev: number().int(),
16803
+ releasedRefs: SecretRefsList
16804
+ }), {
16805
+ kind: "mutation",
16806
+ auth: "admin"
16807
+ }), method(object({
16808
+ ...KindShape,
16809
+ id: RecordIdSchema
16810
+ }), object({
16811
+ deleted: boolean(),
16812
+ secretRefs: SecretRefsList
16813
+ }), {
16814
+ kind: "mutation",
16815
+ auth: "admin"
16816
+ }), method(object({
16817
+ ...KindShape,
16818
+ ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
16819
+ }), object({
16820
+ deleted: number().int(),
16821
+ secretRefs: SecretRefsList
16822
+ }), {
16823
+ kind: "mutation",
16824
+ auth: "admin"
16825
+ }), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
16826
+ ...KindShape,
16827
+ ...TimeWindowShape,
16828
+ where: RecordWhereSchema.optional()
16829
+ }), object({ count: number().int() }), { auth: "admin" }), method(object({
16830
+ ...KindShape,
16831
+ deviceId: number().int().optional(),
16832
+ from: number(),
16833
+ to: number(),
16834
+ bucketMs: number().int().positive()
16835
+ }), object({ buckets: array(object({
16836
+ bucketStart: number(),
16837
+ count: number().int()
16838
+ })) }), { auth: "admin" }), method(object({
16839
+ ...KindShape,
16840
+ op: _enum([
16841
+ "sum",
16842
+ "min",
16843
+ "max",
16844
+ "count"
16845
+ ]),
16846
+ field: RecordFieldPathSchema.optional(),
16847
+ groupBy: RecordFieldPathSchema.optional(),
16848
+ where: RecordWhereSchema.optional()
16849
+ }), object({ rows: array(object({
16850
+ group: union([
16851
+ string(),
16852
+ number(),
16853
+ _null()
16854
+ ]),
16855
+ value: number().nullable()
16856
+ })) }), { auth: "admin" }), method(object({
16857
+ ...KindShape,
16858
+ deviceId: number().int().optional(),
16859
+ atBefore: number().optional(),
16860
+ where: RecordWhereSchema.optional()
16861
+ }), object({
16862
+ deleted: number().int(),
16863
+ secretRefs: SecretRefsList
16864
+ }), {
16865
+ kind: "mutation",
16866
+ auth: "admin"
16867
+ }), method(object({
16868
+ deviceId: number().int(),
16869
+ kinds: array(RecordKindNameSchema).optional()
16870
+ }), object({
16871
+ deleted: record(string(), number().int()),
16872
+ secretRefs: SecretRefsList
16873
+ }), {
16874
+ kind: "mutation",
16875
+ auth: "admin"
16876
+ }), method(object(KindShape), object({ id: number().int() }), {
16877
+ kind: "mutation",
16878
+ auth: "admin"
16879
+ });
16880
+ /** One table of the settings database. */
16881
+ var StorageTableSchema = object({
16882
+ /** The table's full name, e.g. `recorder:addon-settings` or `addon-device-settings`. */
16883
+ name: string(),
16884
+ /** The owner prefix of a scoped name (`recorder` for `recorder:addon-settings`), else null. */
16885
+ owner: string().nullable(),
16886
+ rows: number().int().nonnegative(),
16887
+ /** Bytes the table's pages occupy (`dbstat`); null when the engine cannot measure. */
16888
+ bytes: number().int().nonnegative().nullable(),
16889
+ /** Declared by an addon since this engine process started (a running addon claims it). */
16890
+ declaredThisBoot: boolean()
16891
+ });
16892
+ /** One declared record kind (D881) as System -> Data shows it. */
16893
+ var StorageKindSchema = object({
16894
+ owner: string(),
16895
+ kind: string(),
16896
+ database: _enum(["settings", "events"]),
16897
+ class: string(),
16898
+ state: _enum([
16899
+ "declared",
16900
+ "orphaned",
16901
+ "dropped"
16902
+ ]),
16903
+ /** `null` when the caller asked for no counts (`counts: false`). */
16904
+ rows: number().int().nonnegative().nullable(),
16905
+ /** Rows x the average size of a sample; null for an empty kind. */
16906
+ bytesEstimate: number().int().nonnegative().nullable(),
16907
+ writeTrigger: string(),
16908
+ retention: RecordRetentionSchema,
16909
+ /** `true` when the kind is an entry kind (the generic entries UI lists it). */
16910
+ entry: boolean(),
16911
+ /** The whole declaration, secret paths and entry descriptor included (the entries service builds its handle from it). */
16912
+ declaration: RecordKindDeclarationSchema
16913
+ });
16914
+ method(object({ ownerPrefix: string().min(1).optional() }), object({ tables: array(StorageTableSchema) }), { auth: "admin" }), method(object({
16915
+ collection: string().min(1),
16916
+ expectRows: number().int().nonnegative()
16917
+ }), object({
16918
+ dropped: literal(true),
16919
+ rows: number().int().nonnegative()
16920
+ }), {
16921
+ kind: "mutation",
16922
+ auth: "admin"
16923
+ }), method(object({
16924
+ owner: string().min(1).optional(),
16925
+ /** `false` skips the per-kind row count (a catalog read only). Default true. */
16926
+ counts: boolean().optional()
16927
+ }), object({ kinds: array(StorageKindSchema) }), { auth: "admin" }), method(RecordQueryInputSchema.extend({
16928
+ owner: string().min(1),
16929
+ kind: RecordKindNameSchema
16930
+ }), RecordQueryResultSchema, { auth: "admin" }), method(object({
16931
+ owner: string().min(1),
16932
+ kind: RecordKindNameSchema,
16933
+ records: array(RecordInputSchema).max(RECORD_BATCH_MAX),
16934
+ /** The LAST batch: the copy is complete, the boot guard stops asking. */
16935
+ complete: boolean().optional()
16936
+ }).refine((input) => input.records.length > 0 || input.complete === true, { message: "records must be non-empty unless complete is true" }), object({ adopted: number().int() }), {
16937
+ kind: "mutation",
16938
+ auth: "admin"
16939
+ }), method(object({
16940
+ collection: string().min(1),
16941
+ cursor: string().optional(),
16942
+ limit: number().int().min(1).max(1e3).optional()
16943
+ }), object({
16944
+ rows: array(object({
16945
+ id: string(),
16946
+ data: record(string(), unknown())
16947
+ })),
16948
+ nextCursor: string().nullable()
16949
+ }), { auth: "admin" }), method(object({ collection: string().min(1) }), object({ adopted: boolean() }), { auth: "admin" });
16950
+ /**
16951
+ * record-entries - the ONE admin surface for every list of user-created entries
16952
+ * (D881): notification targets, brokers, LLM profiles, anything an addon
16953
+ * declares as an ENTRY kind (`entry: { title }` in `defineRecordKinds`).
16954
+ *
16955
+ * The UI is generic. `listEntryKinds` hands it, per kind, the JSON Schema of
16956
+ * the entry body with `secret: true` on every credential field, so a password
16957
+ * field is derived from the schema and never from a name. `putEntry` takes the
16958
+ * redaction token for an untouched secret (the stored value is kept), a string
16959
+ * for a new one, and the clear instruction to remove one. A read never carries
16960
+ * a secret value, and a locked keychain refuses the write with
16961
+ * `records/secret-unavailable` instead of storing plaintext.
16962
+ *
16963
+ * Hub-only, served in-process (it acts for each entry's owner on the keychain).
16964
+ */
16965
+ var EntryKindInfoSchema = object({
16966
+ owner: string(),
16967
+ kind: RecordKindNameSchema,
16968
+ title: string(),
16969
+ nameField: string(),
16970
+ /** JSON Schema of the body; `secret: true` marks a password field. */
16971
+ fields: record(string(), unknown()),
16972
+ secretPaths: array(string()),
16973
+ rows: number().int().nonnegative()
16974
+ });
16975
+ var EntryViewSchema = object({
16976
+ id: RecordIdSchema,
16977
+ name: string(),
16978
+ rev: number().int(),
16979
+ updatedAt: number(),
16980
+ /** Secret fields hold the redaction token. */
16981
+ data: RecordBodySchema
16982
+ });
16983
+ var EntryAddress = {
16984
+ owner: string().min(1),
16985
+ kind: RecordKindNameSchema
16986
+ };
16987
+ method(object({}), object({ kinds: array(EntryKindInfoSchema) }), { auth: "admin" }), method(object({ ...EntryAddress }), object({ entries: array(EntryViewSchema) }), { auth: "admin" }), method(object({
16988
+ ...EntryAddress,
16989
+ id: RecordIdSchema.optional(),
16990
+ data: RecordBodySchema,
16991
+ ifRev: number().int().min(1).optional()
16992
+ }), object({
16993
+ id: string(),
16994
+ rev: number().int()
16995
+ }), {
16996
+ kind: "mutation",
16997
+ auth: "admin"
16998
+ }), method(object({
16999
+ ...EntryAddress,
17000
+ id: RecordIdSchema
17001
+ }), object({ deleted: boolean() }), {
17002
+ kind: "mutation",
17003
+ auth: "admin"
17004
+ });
17005
+ /**
16022
17006
  * `keychain` — the hub's encrypted store of secret values (D787).
16023
17007
  *
16024
17008
  * Settings blobs never hold a secret: they hold a marker
@@ -16559,6 +17543,16 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
16559
17543
  kind: "mutation",
16560
17544
  auth: "admin",
16561
17545
  caller: "required"
17546
+ }), method(object({
17547
+ ref: string().min(1),
17548
+ value: string().min(1)
17549
+ }), object({
17550
+ ref: string(),
17551
+ version: number().int()
17552
+ }), {
17553
+ kind: "mutation",
17554
+ auth: "admin",
17555
+ caller: "required"
16562
17556
  }), method(object({ refs: array(string().min(1)).max(1e3) }), object({
16563
17557
  deleted: array(string()).readonly(),
16564
17558
  kept: array(object({
@@ -39028,6 +40022,9 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
39028
40022
  }), _void(), { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
39029
40023
  kind: "mutation",
39030
40024
  auth: "admin"
40025
+ }), method(RawSecretMigrationInputSchema, RawSecretMigrationReportSchema, {
40026
+ kind: "mutation",
40027
+ auth: "admin"
39031
40028
  }), method(ProfileRefInputSchema, _void(), {
39032
40029
  kind: "mutation",
39033
40030
  auth: "admin"
@@ -49451,6 +50448,41 @@ var ServerRollbackInfoSchema = object({
49451
50448
  atMs: number(),
49452
50449
  reason: string()
49453
50450
  });
50451
+ /**
50452
+ * The runner boot check (D877): the runners this node PLANNED (hub: one per
50453
+ * `resolveRunnerId` over its forked addons; agent: the runners its process
50454
+ * service holds, because only the hub plans) against the states the process
50455
+ * service reports. Kept in memory, recomputed by the same one-shot check after
50456
+ * every boot, served on `getServerPackageStatus`.
50457
+ *
50458
+ * `failed` is the D6 breaker's terminal state, `refused` a deterministic Init
50459
+ * refusal (an addon that said "I will not start, and here is why"), `missing` a
50460
+ * planned runner the process service has no entry for.
50461
+ */
50462
+ var RunnerRefusalSchema = object({
50463
+ runnerId: string(),
50464
+ addonIds: array(string()),
50465
+ reason: string()
50466
+ });
50467
+ var RunnerBootCheckSchema = object({
50468
+ checkedAtMs: number(),
50469
+ /** Runners planned for this node. */
50470
+ expected: number(),
50471
+ /** Planned runners whose process is `running`. */
50472
+ running: number(),
50473
+ failed: array(string()),
50474
+ refused: array(RunnerRefusalSchema),
50475
+ missing: array(string()),
50476
+ /**
50477
+ * Runners still on their way: `starting`, or `crashed` waiting on a backoff
50478
+ * respawn. The check is FINAL only when this is empty; until then nothing is
50479
+ * pushed and the verdict is re-evaluated on the next runner state change.
50480
+ * Optional for version skew (absent = settled).
50481
+ */
50482
+ pending: array(string()).optional(),
50483
+ /** True when the plan is the hub's (`missing` is then meaningful); false on an agent. */
50484
+ planKnown: boolean()
50485
+ });
49454
50486
  var ServerPackageStatusSchema = object({
49455
50487
  /** Root package name (`@camstack/server` on the hub). */
49456
50488
  packageName: string(),
@@ -49513,7 +50545,14 @@ var ServerPackageStatusSchema = object({
49513
50545
  * for version skew: an older provider's payload simply omits it, and an
49514
50546
  * absent wrapper is unknown — never `native`.
49515
50547
  */
49516
- wrapper: WrapperIdentitySchema.optional()
50548
+ wrapper: WrapperIdentitySchema.optional(),
50549
+ /**
50550
+ * What this node PLANNED to run against what its process service reports
50551
+ * (D877). Absent until the one-shot boot check has run (~60 s after boot) and
50552
+ * on a provider that predates it. Absent is "not checked yet", never "all
50553
+ * well": a consumer that needs the answer treats it as pending.
50554
+ */
50555
+ runners: RunnerBootCheckSchema.optional()
49517
50556
  });
49518
50557
  var ServerUpdateCheckResultSchema = object({
49519
50558
  packageName: string(),
@@ -49564,6 +50603,13 @@ var ServerUpdateOutcomeSchema = _enum([
49564
50603
  "refused",
49565
50604
  "failed"
49566
50605
  ]);
50606
+ /** One addon the pre-flight found the target version would refuse (D877). */
50607
+ var UpdateBlockerSchema = object({
50608
+ addonId: string(),
50609
+ reason: string(),
50610
+ /** What the operator does about it. */
50611
+ remedy: string()
50612
+ });
49567
50613
  var ServerUpdateActionResultSchema = object({
49568
50614
  accepted: boolean(),
49569
50615
  targetVersion: string().nullable(),
@@ -49581,14 +50627,27 @@ var ServerUpdateActionResultSchema = object({
49581
50627
  * The failure itself, verbatim enough to act on (the npm output for a
49582
50628
  * staging install). Non-null only for `failed`.
49583
50629
  */
49584
- error: string().nullable().optional()
50630
+ error: string().nullable().optional(),
50631
+ /**
50632
+ * The addons the target version would refuse to start on this node's live
50633
+ * store (D877), present when the pre-flight refused the update
50634
+ * (`reason: 'addon-would-refuse'`). Optional for version skew.
50635
+ */
50636
+ blockers: array(UpdateBlockerSchema).optional()
49585
50637
  });
49586
50638
  method(_void(), ServerPackageStatusSchema, { auth: "admin" }), method(_void(), ServerUpdateCheckResultSchema, {
49587
50639
  kind: "mutation",
49588
50640
  auth: "admin"
49589
- }), method(object({
49590
- /** Explicit target version; omitted = latest from the registry. */
49591
- version: string().optional() }), ServerUpdateActionResultSchema, {
50641
+ }), method(object({
50642
+ /** Explicit target version; omitted = latest from the registry. */
50643
+ version: string().optional(),
50644
+ /**
50645
+ * Apply even though the pre-flight (D877) found addons the target would
50646
+ * refuse to start. Off by default: those addons stay down until the
50647
+ * remedy is run, which is the incident this gate exists to prevent.
50648
+ */
50649
+ acknowledgeRefusals: boolean().optional()
50650
+ }), ServerUpdateActionResultSchema, {
49592
50651
  kind: "mutation",
49593
50652
  auth: "admin",
49594
50653
  timeoutMs: 16 * 6e4
@@ -52014,7 +53073,9 @@ var ManifestShapeSchema = object({
52014
53073
  var AddonProcessSchema = object({
52015
53074
  pid: number().optional(),
52016
53075
  mode: string(),
52017
- state: string()
53076
+ state: string(),
53077
+ /** Why the runner is `refused` (an addon's own words), when it is (D877). */
53078
+ reason: string().optional()
52018
53079
  });
52019
53080
  /**
52020
53081
  * Per-addon health snapshot from the kernel's AddonHealthMonitor.
@@ -52592,7 +53653,7 @@ var BatteryStatusSchema = object({
52592
53653
  */
52593
53654
  binary: boolean().optional()
52594
53655
  });
52595
- DeviceType.Camera, DeviceType.Sensor, DeviceType.Button, DeviceType.Switch, DeviceType.PetFeeder, DeviceType.Container, method(object({
53656
+ DeviceType.Camera, DeviceType.Sensor, DeviceType.Button, DeviceType.Switch, DeviceType.PetFeeder, DeviceType.Container, DeviceType.Thermostat, method(object({
52596
53657
  deviceId: number(),
52597
53658
  /** Bound on the wait. Sensible range 3000–10000ms. */
52598
53659
  timeoutMs: number().int().min(500).max(3e4).default(8e3)
@@ -53027,6 +54088,12 @@ object({
53027
54088
  /** Horizontal louver swing on/off. Null when the device has no
53028
54089
  * horizontal swing surface (gate with `DeviceFeature.ClimateSwingHorizontal`). */
53029
54090
  swingHorizontal: boolean().nullable(),
54091
+ /** Lowest setpoint the device accepts, Celsius. Absent / null = not reported. */
54092
+ minTemp: number().nullable().optional(),
54093
+ /** Highest setpoint the device accepts, Celsius. Absent / null = not reported. */
54094
+ maxTemp: number().nullable().optional(),
54095
+ /** Setpoint granularity, Celsius (0.5, 1). Absent / null = not reported. */
54096
+ tempStep: number().positive().nullable().optional(),
53030
54097
  /** Ms epoch when the slice was last updated (push or command). */
53031
54098
  lastFetchedAt: number()
53032
54099
  });
@@ -53472,6 +54539,98 @@ object({
53472
54539
  deviceId: number(),
53473
54540
  status: DeviceStatusSchema
53474
54541
  });
54542
+ /**
54543
+ * Smart-dishwasher cap — program lifecycle, door / remote-start gates,
54544
+ * consumable levels (salt, rinse aid) and common program options.
54545
+ *
54546
+ * Sources: native Bosch Home Connect (`dishwasher` device type). Reusable
54547
+ * by any integration that exposes the same program / option surface.
54548
+ *
54549
+ * `kind: 'poll'` — cloud REST APIs typically have no push channel; the
54550
+ * provider refreshes the slice on an interval and eagerly after commands.
54551
+ */
54552
+ var DishwasherStateSchema = _enum([
54553
+ "idle",
54554
+ "running",
54555
+ "paused",
54556
+ "finished",
54557
+ "error",
54558
+ "unavailable"
54559
+ ]);
54560
+ var DishwasherConsumableLevelSchema = _enum([
54561
+ "ok",
54562
+ "low",
54563
+ "empty"
54564
+ ]);
54565
+ object({
54566
+ state: DishwasherStateSchema,
54567
+ /** Active program id/name, or null when none selected / unknown. */
54568
+ program: string().nullable(),
54569
+ /** Program tokens the hardware accepts — drives the UI selector. */
54570
+ availablePrograms: array(string()),
54571
+ /** Minutes remaining on the active cycle, or null when not running. */
54572
+ remainingMinutes: number().int().nonnegative().nullable(),
54573
+ /** Cycle completion 0..100, or null when not applicable. */
54574
+ progressPercent: number().min(0).max(100).nullable(),
54575
+ /** True when the door is reported open. */
54576
+ doorOpen: boolean(),
54577
+ /** True when remote start is allowed (door closed, power on, etc.). */
54578
+ remoteStartAllowed: boolean(),
54579
+ /** Main power / switched-on state. */
54580
+ powerOn: boolean(),
54581
+ saltLevel: DishwasherConsumableLevelSchema.nullable(),
54582
+ rinseAidLevel: DishwasherConsumableLevelSchema.nullable(),
54583
+ halfLoad: boolean(),
54584
+ hygienePlus: boolean(),
54585
+ errorCode: number().nullable(),
54586
+ errorLabel: string().nullable(),
54587
+ lastFetchedAt: number()
54588
+ });
54589
+ DeviceType.Dishwasher, method(object({ deviceId: number().int().nonnegative() }), _void(), {
54590
+ kind: "mutation",
54591
+ auth: "protected"
54592
+ }), method(object({ deviceId: number().int().nonnegative() }), _void(), {
54593
+ kind: "mutation",
54594
+ auth: "protected"
54595
+ }), method(object({ deviceId: number().int().nonnegative() }), _void(), {
54596
+ kind: "mutation",
54597
+ auth: "protected"
54598
+ }), method(object({
54599
+ deviceId: number().int().nonnegative(),
54600
+ program: string().min(1)
54601
+ }), _void(), {
54602
+ kind: "mutation",
54603
+ auth: "protected"
54604
+ }), method(object({
54605
+ deviceId: number().int().nonnegative(),
54606
+ on: boolean()
54607
+ }), _void(), {
54608
+ kind: "mutation",
54609
+ auth: "protected"
54610
+ }), method(object({
54611
+ deviceId: number().int().nonnegative(),
54612
+ on: boolean()
54613
+ }), _void(), {
54614
+ kind: "mutation",
54615
+ auth: "protected"
54616
+ }), method(object({
54617
+ deviceId: number().int().nonnegative(),
54618
+ on: boolean()
54619
+ }), _void(), {
54620
+ kind: "mutation",
54621
+ auth: "protected"
54622
+ }), method(object({
54623
+ deviceId: number().int().nonnegative(),
54624
+ key: string().min(1),
54625
+ value: union([
54626
+ boolean(),
54627
+ string(),
54628
+ number()
54629
+ ])
54630
+ }), _void(), {
54631
+ kind: "mutation",
54632
+ auth: "protected"
54633
+ });
53475
54634
  object({
53476
54635
  /** Ms epoch of the last press. null = never observed since this provider started. */
53477
54636
  lastPressedAt: number().nullable(),
@@ -54037,6 +55196,13 @@ object({
54037
55196
  lastChangedAt: number()
54038
55197
  });
54039
55198
  DeviceType.Sensor;
55199
+ object({
55200
+ /** Radiator valve opening 0 (closed) .. 100 (open). Null = not yet known. */
55201
+ position: number().min(0).max(100).nullable(),
55202
+ /** Ms epoch when the slice was last updated (push or poll). */
55203
+ lastFetchedAt: number()
55204
+ });
55205
+ DeviceType.Thermostat;
54040
55206
  object({
54041
55207
  /** Whether the humidifier is currently on. */
54042
55208
  on: boolean(),
@@ -54847,7 +56013,19 @@ var TlsStatusSchema = object({
54847
56013
  sans: array(string()),
54848
56014
  caCertPem: string().nullable(),
54849
56015
  reissueError: string().nullable(),
54850
- restartRequired: boolean()
56016
+ restartRequired: boolean(),
56017
+ /** An uploaded certificate is served but no CA is kept for it and it is not publicly signed (D873). */
56018
+ caMissing: boolean(),
56019
+ /** Does the hub's own generated CA carry a critical name constraint? `null` while it has none. */
56020
+ localCaConstrained: boolean().nullable(),
56021
+ /** ISO time the generated CA was replaced by a constrained one; devices must re-download it. */
56022
+ caReplacedAt: string().nullable(),
56023
+ /** The uploaded certificate kept on disk, selectable again after "Revert to generated". */
56024
+ storedUpload: object({
56025
+ leafFingerprintSha256: string(),
56026
+ validTo: string(),
56027
+ hasCa: boolean()
56028
+ }).nullable()
54851
56029
  });
54852
56030
  method(_void(), ListResultSchema), method(_void(), PreferredSchema), method(object({
54853
56031
  /**
@@ -54903,6 +56081,9 @@ method(_void(), ListResultSchema), method(_void(), PreferredSchema), method(obje
54903
56081
  }), method(_void(), object({ pem: string() })), method(_void(), TlsStatusSchema, {
54904
56082
  kind: "mutation",
54905
56083
  auth: "admin"
56084
+ }), method(_void(), TlsStatusSchema, {
56085
+ kind: "mutation",
56086
+ auth: "admin"
54906
56087
  });
54907
56088
  object({
54908
56089
  /** Lifecycle state of the lock. `jammed` means the motor reported
@@ -60032,7 +61213,11 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
60032
61213
  kind: "mutation",
60033
61214
  auth: "admin",
60034
61215
  access: "delete"
60035
- }), method(object({ userId: string() }), TotpStatusSchema, { auth: "admin" }), method(object({
61216
+ }), method(object({ userId: string() }), TotpStatusSchema, { auth: "admin" }), method(RawSecretMigrationInputSchema, RawSecretMigrationReportSchema, {
61217
+ kind: "mutation",
61218
+ auth: "admin",
61219
+ access: "create"
61220
+ }), method(object({
60036
61221
  userId: string(),
60037
61222
  code: string()
60038
61223
  }), object({ valid: boolean() }), {
@@ -61084,7 +62269,7 @@ var AccessoryKind = {
61084
62269
  PrivacyMask: DeviceRole.PrivacyMask
61085
62270
  };
61086
62271
  AccessoryKind.Siren, AccessoryKind.Floodlight, AccessoryKind.Spotlight, AccessoryKind.PirSensor, AccessoryKind.Chime, AccessoryKind.Autotrack, AccessoryKind.Nightvision, AccessoryKind.PrivacyMask;
61087
- 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;
62272
+ 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;
61088
62273
  new Set(Object.values(DeviceType));
61089
62274
  Object.freeze({
61090
62275
  "accessories.getStatus": {
@@ -62233,6 +63418,12 @@ Object.freeze({
62233
63418
  addonId: null,
62234
63419
  access: "view"
62235
63420
  },
63421
+ "coreBlocks.migrateRawSecrets": {
63422
+ capName: "core-blocks",
63423
+ capScope: "system",
63424
+ addonId: null,
63425
+ access: "create"
63426
+ },
62236
63427
  "coreBlocks.restart": {
62237
63428
  capName: "core-blocks",
62238
63429
  capScope: "system",
@@ -63499,6 +64690,60 @@ Object.freeze({
63499
64690
  addonId: null,
63500
64691
  access: "view"
63501
64692
  },
64693
+ "dishwasher.getStatus": {
64694
+ capName: "dishwasher",
64695
+ capScope: "device",
64696
+ addonId: null,
64697
+ access: "view"
64698
+ },
64699
+ "dishwasher.pause": {
64700
+ capName: "dishwasher",
64701
+ capScope: "device",
64702
+ addonId: null,
64703
+ access: "create"
64704
+ },
64705
+ "dishwasher.setHalfLoad": {
64706
+ capName: "dishwasher",
64707
+ capScope: "device",
64708
+ addonId: null,
64709
+ access: "create"
64710
+ },
64711
+ "dishwasher.setHygienePlus": {
64712
+ capName: "dishwasher",
64713
+ capScope: "device",
64714
+ addonId: null,
64715
+ access: "create"
64716
+ },
64717
+ "dishwasher.setOption": {
64718
+ capName: "dishwasher",
64719
+ capScope: "device",
64720
+ addonId: null,
64721
+ access: "create"
64722
+ },
64723
+ "dishwasher.setPower": {
64724
+ capName: "dishwasher",
64725
+ capScope: "device",
64726
+ addonId: null,
64727
+ access: "create"
64728
+ },
64729
+ "dishwasher.setProgram": {
64730
+ capName: "dishwasher",
64731
+ capScope: "device",
64732
+ addonId: null,
64733
+ access: "create"
64734
+ },
64735
+ "dishwasher.start": {
64736
+ capName: "dishwasher",
64737
+ capScope: "device",
64738
+ addonId: null,
64739
+ access: "create"
64740
+ },
64741
+ "dishwasher.stop": {
64742
+ capName: "dishwasher",
64743
+ capScope: "device",
64744
+ addonId: null,
64745
+ access: "create"
64746
+ },
63502
64747
  "doorbell.getStatus": {
63503
64748
  capName: "doorbell",
63504
64749
  capScope: "device",
@@ -63709,6 +64954,12 @@ Object.freeze({
63709
64954
  addonId: null,
63710
64955
  access: "view"
63711
64956
  },
64957
+ "heatingValve.getStatus": {
64958
+ capName: "heating-valve",
64959
+ capScope: "device",
64960
+ addonId: null,
64961
+ access: "view"
64962
+ },
63712
64963
  "humidifier.getStatus": {
63713
64964
  capName: "humidifier",
63714
64965
  capScope: "device",
@@ -63919,6 +65170,12 @@ Object.freeze({
63919
65170
  addonId: null,
63920
65171
  access: "create"
63921
65172
  },
65173
+ "keychainAdmin.importSecret": {
65174
+ capName: "keychain-admin",
65175
+ capScope: "system",
65176
+ addonId: null,
65177
+ access: "create"
65178
+ },
63922
65179
  "keychainAdmin.listAudit": {
63923
65180
  capName: "keychain-admin",
63924
65181
  capScope: "system",
@@ -64087,6 +65344,12 @@ Object.freeze({
64087
65344
  addonId: null,
64088
65345
  access: "view"
64089
65346
  },
65347
+ "llm.migrateRawSecrets": {
65348
+ capName: "llm",
65349
+ capScope: "system",
65350
+ addonId: null,
65351
+ access: "create"
65352
+ },
64090
65353
  "llm.resolveModelRef": {
64091
65354
  capName: "llm",
64092
65355
  capScope: "system",
@@ -64315,6 +65578,12 @@ Object.freeze({
64315
65578
  addonId: null,
64316
65579
  access: "create"
64317
65580
  },
65581
+ "localNetwork.useStoredUploadedCertificate": {
65582
+ capName: "local-network",
65583
+ capScope: "system",
65584
+ addonId: null,
65585
+ access: "create"
65586
+ },
64318
65587
  "lockControl.getStatus": {
64319
65588
  capName: "lock-control",
64320
65589
  capScope: "device",
@@ -66967,6 +68236,30 @@ Object.freeze({
66967
68236
  addonId: null,
66968
68237
  access: "create"
66969
68238
  },
68239
+ "recordEntries.deleteEntry": {
68240
+ capName: "record-entries",
68241
+ capScope: "system",
68242
+ addonId: null,
68243
+ access: "delete"
68244
+ },
68245
+ "recordEntries.listEntries": {
68246
+ capName: "record-entries",
68247
+ capScope: "system",
68248
+ addonId: null,
68249
+ access: "view"
68250
+ },
68251
+ "recordEntries.listEntryKinds": {
68252
+ capName: "record-entries",
68253
+ capScope: "system",
68254
+ addonId: null,
68255
+ access: "view"
68256
+ },
68257
+ "recordEntries.putEntry": {
68258
+ capName: "record-entries",
68259
+ capScope: "system",
68260
+ addonId: null,
68261
+ access: "create"
68262
+ },
66970
68263
  "recording.getAvailability": {
66971
68264
  capName: "recording",
66972
68265
  capScope: "device",
@@ -67267,6 +68560,102 @@ Object.freeze({
67267
68560
  addonId: null,
67268
68561
  access: "view"
67269
68562
  },
68563
+ "records.aggregate": {
68564
+ capName: "records",
68565
+ capScope: "system",
68566
+ addonId: null,
68567
+ access: "view"
68568
+ },
68569
+ "records.allocateId": {
68570
+ capName: "records",
68571
+ capScope: "system",
68572
+ addonId: null,
68573
+ access: "create"
68574
+ },
68575
+ "records.count": {
68576
+ capName: "records",
68577
+ capScope: "system",
68578
+ addonId: null,
68579
+ access: "view"
68580
+ },
68581
+ "records.declareKinds": {
68582
+ capName: "records",
68583
+ capScope: "system",
68584
+ addonId: null,
68585
+ access: "create"
68586
+ },
68587
+ "records.delete": {
68588
+ capName: "records",
68589
+ capScope: "system",
68590
+ addonId: null,
68591
+ access: "delete"
68592
+ },
68593
+ "records.deleteDevice": {
68594
+ capName: "records",
68595
+ capScope: "system",
68596
+ addonId: null,
68597
+ access: "delete"
68598
+ },
68599
+ "records.deleteMany": {
68600
+ capName: "records",
68601
+ capScope: "system",
68602
+ addonId: null,
68603
+ access: "delete"
68604
+ },
68605
+ "records.deleteWhere": {
68606
+ capName: "records",
68607
+ capScope: "system",
68608
+ addonId: null,
68609
+ access: "delete"
68610
+ },
68611
+ "records.get": {
68612
+ capName: "records",
68613
+ capScope: "system",
68614
+ addonId: null,
68615
+ access: "view"
68616
+ },
68617
+ "records.getMany": {
68618
+ capName: "records",
68619
+ capScope: "system",
68620
+ addonId: null,
68621
+ access: "view"
68622
+ },
68623
+ "records.histogram": {
68624
+ capName: "records",
68625
+ capScope: "system",
68626
+ addonId: null,
68627
+ access: "view"
68628
+ },
68629
+ "records.patch": {
68630
+ capName: "records",
68631
+ capScope: "system",
68632
+ addonId: null,
68633
+ access: "create"
68634
+ },
68635
+ "records.put": {
68636
+ capName: "records",
68637
+ capScope: "system",
68638
+ addonId: null,
68639
+ access: "create"
68640
+ },
68641
+ "records.putMany": {
68642
+ capName: "records",
68643
+ capScope: "system",
68644
+ addonId: null,
68645
+ access: "create"
68646
+ },
68647
+ "records.query": {
68648
+ capName: "records",
68649
+ capScope: "system",
68650
+ addonId: null,
68651
+ access: "view"
68652
+ },
68653
+ "records.secretRefs": {
68654
+ capName: "records",
68655
+ capScope: "system",
68656
+ addonId: null,
68657
+ access: "view"
68658
+ },
67270
68659
  "sceneMonitor.captureReference": {
67271
68660
  capName: "scene-monitor",
67272
68661
  capScope: "device",
@@ -67699,6 +69088,48 @@ Object.freeze({
67699
69088
  addonId: null,
67700
69089
  access: "create"
67701
69090
  },
69091
+ "storageAdmin.adoptRecords": {
69092
+ capName: "storage-admin",
69093
+ capScope: "system",
69094
+ addonId: null,
69095
+ access: "create"
69096
+ },
69097
+ "storageAdmin.dropCollection": {
69098
+ capName: "storage-admin",
69099
+ capScope: "system",
69100
+ addonId: null,
69101
+ access: "delete"
69102
+ },
69103
+ "storageAdmin.isAdoptedLegacyTable": {
69104
+ capName: "storage-admin",
69105
+ capScope: "system",
69106
+ addonId: null,
69107
+ access: "view"
69108
+ },
69109
+ "storageAdmin.listKinds": {
69110
+ capName: "storage-admin",
69111
+ capScope: "system",
69112
+ addonId: null,
69113
+ access: "view"
69114
+ },
69115
+ "storageAdmin.listTables": {
69116
+ capName: "storage-admin",
69117
+ capScope: "system",
69118
+ addonId: null,
69119
+ access: "view"
69120
+ },
69121
+ "storageAdmin.readLegacyCollection": {
69122
+ capName: "storage-admin",
69123
+ capScope: "system",
69124
+ addonId: null,
69125
+ access: "view"
69126
+ },
69127
+ "storageAdmin.readRecords": {
69128
+ capName: "storage-admin",
69129
+ capScope: "system",
69130
+ addonId: null,
69131
+ access: "view"
69132
+ },
67702
69133
  "storageEvictable.evict": {
67703
69134
  capName: "storage-evictable",
67704
69135
  capScope: "system",
@@ -68611,6 +70042,12 @@ Object.freeze({
68611
70042
  addonId: null,
68612
70043
  access: "view"
68613
70044
  },
70045
+ "userManagement.migrateRawSecrets": {
70046
+ capName: "user-management",
70047
+ capScope: "system",
70048
+ addonId: null,
70049
+ access: "create"
70050
+ },
68614
70051
  "userManagement.oauthExchangeCode": {
68615
70052
  capName: "user-management",
68616
70053
  capScope: "system",
@@ -69110,7 +70547,7 @@ Object.freeze({
69110
70547
  access: "create"
69111
70548
  }
69112
70549
  });
69113
- 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;
70550
+ 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;
69114
70551
  DeviceFeature.BatteryOperated;
69115
70552
  Object.freeze({
69116
70553
  "accessories.getStatus": [{
@@ -69934,6 +71371,51 @@ Object.freeze({
69934
71371
  form: "single",
69935
71372
  optional: false
69936
71373
  }],
71374
+ "dishwasher.getStatus": [{
71375
+ name: "deviceId",
71376
+ form: "single",
71377
+ optional: false
71378
+ }],
71379
+ "dishwasher.pause": [{
71380
+ name: "deviceId",
71381
+ form: "single",
71382
+ optional: false
71383
+ }],
71384
+ "dishwasher.setHalfLoad": [{
71385
+ name: "deviceId",
71386
+ form: "single",
71387
+ optional: false
71388
+ }],
71389
+ "dishwasher.setHygienePlus": [{
71390
+ name: "deviceId",
71391
+ form: "single",
71392
+ optional: false
71393
+ }],
71394
+ "dishwasher.setOption": [{
71395
+ name: "deviceId",
71396
+ form: "single",
71397
+ optional: false
71398
+ }],
71399
+ "dishwasher.setPower": [{
71400
+ name: "deviceId",
71401
+ form: "single",
71402
+ optional: false
71403
+ }],
71404
+ "dishwasher.setProgram": [{
71405
+ name: "deviceId",
71406
+ form: "single",
71407
+ optional: false
71408
+ }],
71409
+ "dishwasher.start": [{
71410
+ name: "deviceId",
71411
+ form: "single",
71412
+ optional: false
71413
+ }],
71414
+ "dishwasher.stop": [{
71415
+ name: "deviceId",
71416
+ form: "single",
71417
+ optional: false
71418
+ }],
69937
71419
  "doorbell.getStatus": [{
69938
71420
  name: "deviceId",
69939
71421
  form: "single",
@@ -70003,6 +71485,11 @@ Object.freeze({
70003
71485
  form: "single",
70004
71486
  optional: false
70005
71487
  }],
71488
+ "heatingValve.getStatus": [{
71489
+ name: "deviceId",
71490
+ form: "single",
71491
+ optional: false
71492
+ }],
70006
71493
  "humidifier.getStatus": [{
70007
71494
  name: "deviceId",
70008
71495
  form: "single",
@@ -71287,6 +72774,37 @@ Object.freeze({
71287
72774
  form: "single",
71288
72775
  optional: false
71289
72776
  }],
72777
+ "records.count": [{
72778
+ name: "deviceId",
72779
+ form: "single",
72780
+ optional: true
72781
+ }],
72782
+ "records.deleteDevice": [{
72783
+ name: "deviceId",
72784
+ form: "single",
72785
+ optional: false
72786
+ }],
72787
+ "records.deleteWhere": [{
72788
+ name: "deviceId",
72789
+ form: "single",
72790
+ optional: true
72791
+ }],
72792
+ "records.histogram": [{
72793
+ name: "deviceId",
72794
+ form: "single",
72795
+ optional: true
72796
+ }],
72797
+ "records.putMany": [{
72798
+ name: "records",
72799
+ form: "object-array",
72800
+ optional: false,
72801
+ itemField: "deviceId"
72802
+ }],
72803
+ "records.query": [{
72804
+ name: "deviceId",
72805
+ form: "single",
72806
+ optional: true
72807
+ }],
71290
72808
  "sceneMonitor.captureReference": [{
71291
72809
  name: "deviceId",
71292
72810
  form: "single",
@@ -71403,6 +72921,17 @@ Object.freeze({
71403
72921
  form: "single",
71404
72922
  optional: false
71405
72923
  }],
72924
+ "storageAdmin.adoptRecords": [{
72925
+ name: "records",
72926
+ form: "object-array",
72927
+ optional: false,
72928
+ itemField: "deviceId"
72929
+ }],
72930
+ "storageAdmin.readRecords": [{
72931
+ name: "deviceId",
72932
+ form: "single",
72933
+ optional: true
72934
+ }],
71406
72935
  "streamBroker.acquireEgressTranscode": [{
71407
72936
  name: "deviceId",
71408
72937
  form: "single",
@@ -73656,6 +75185,40 @@ function createGmailSmtpProvider(deps) {
73656
75185
  };
73657
75186
  }
73658
75187
  //#endregion
75188
+ //#region src/google-broker-reconnect-alert.ts
75189
+ function googleBrokerReconnectAlertId(brokerId) {
75190
+ return `google-broker:${brokerId}`;
75191
+ }
75192
+ function isInvalidGrantRefreshError(err) {
75193
+ return (err instanceof Error ? err.message : String(err)).includes("invalid_grant");
75194
+ }
75195
+ function buildGoogleBrokerReconnectAlert(brokerId, brokerName) {
75196
+ const pushLine = `${brokerName}: Google session expired — sign in again`;
75197
+ return {
75198
+ id: googleBrokerReconnectAlertId(brokerId),
75199
+ category: "google.broker-reconnect",
75200
+ severity: "critical",
75201
+ title: "Google needs a new sign-in",
75202
+ message: `${brokerName} needs you to sign in to Google again.`,
75203
+ action: {
75204
+ label: "Sign in again",
75205
+ href: `/addon/google-services/oauth/start?brokerId=${encodeURIComponent(brokerId)}`
75206
+ },
75207
+ status: "active",
75208
+ read: false,
75209
+ createdAt: Date.now(),
75210
+ updatedAt: Date.now(),
75211
+ source: {
75212
+ type: "google-broker",
75213
+ id: brokerId
75214
+ },
75215
+ metadata: {
75216
+ episodeKey: "reconnect",
75217
+ pushLine
75218
+ }
75219
+ };
75220
+ }
75221
+ //#endregion
73659
75222
  //#region src/google-oauth.ts
73660
75223
  /**
73661
75224
  * Google OAuth2 authorization-code + refresh for Calendar API.
@@ -73786,6 +75349,74 @@ async function probeGoogleOauthClient(cfg, http = { fetch }) {
73786
75349
  function pickOauthRedirectOrigin(book) {
73787
75350
  return book.roles.publicEndpoint.resolved ?? book.roles.internal.resolved ?? null;
73788
75351
  }
75352
+ var googleBrokersEntryKind = defineEntryKind("brokers", {
75353
+ title: "Google Services brokers",
75354
+ schema: entryBody({
75355
+ clientId: GoogleBrokerEntrySchema.shape.clientId,
75356
+ clientSecret: GoogleBrokerEntrySchema.shape.clientSecret,
75357
+ calendarFilter: GoogleBrokerEntrySchema.shape.calendarFilter,
75358
+ fromAddress: GoogleBrokerEntrySchema.shape.fromAddress,
75359
+ fromName: GoogleBrokerEntrySchema.shape.fromName
75360
+ }),
75361
+ writeTrigger: "an operator adds or edits a Google OAuth broker",
75362
+ adoptsFrom: settingsBrokersAdoptsFrom("google-services")
75363
+ });
75364
+ //#endregion
75365
+ //#region src/google-broker-store.ts
75366
+ function rowToEntry(id, data) {
75367
+ const parsed = GoogleBrokerEntrySchema.safeParse({
75368
+ id,
75369
+ ...data
75370
+ });
75371
+ return parsed.success ? parsed.data : null;
75372
+ }
75373
+ var GoogleBrokerStore = class GoogleBrokerStore {
75374
+ kind;
75375
+ constructor(kind) {
75376
+ this.kind = kind;
75377
+ }
75378
+ static of(records) {
75379
+ return new GoogleBrokerStore(records.kind(googleBrokersEntryKind));
75380
+ }
75381
+ async listResolved() {
75382
+ const page = await this.kind.query({ limit: 1e3 });
75383
+ const out = [];
75384
+ for (const record of page.records) {
75385
+ let data = record.data;
75386
+ try {
75387
+ const resolved = await this.kind.getResolved(record.id);
75388
+ if (resolved !== null) data = resolved.data;
75389
+ } catch (err) {
75390
+ if (!(err instanceof RecordSecretUnavailableError)) throw err;
75391
+ }
75392
+ const entry = rowToEntry(record.id, data);
75393
+ if (entry !== null) out.push(entry);
75394
+ }
75395
+ return out;
75396
+ }
75397
+ async replaceAll(entries) {
75398
+ const page = await this.kind.query({ limit: 1e3 });
75399
+ const nextIds = new Set(entries.map((e) => e.id));
75400
+ for (const row of page.records) if (!nextIds.has(row.id)) await this.kind.delete(row.id);
75401
+ for (const entry of entries) {
75402
+ const { id, name, clientId, clientSecret, calendarFilter, fromAddress, fromName } = entry;
75403
+ const body = {
75404
+ name,
75405
+ clientId,
75406
+ clientSecret,
75407
+ calendarFilter,
75408
+ fromAddress,
75409
+ fromName
75410
+ };
75411
+ const parsed = googleBrokersEntryKind.schema.safeParse(body);
75412
+ if (!parsed.success) throw new Error(`invalid Google broker '${id}': ${parsed.error.message}`);
75413
+ await this.kind.put({
75414
+ id,
75415
+ data: parsed.data
75416
+ });
75417
+ }
75418
+ }
75419
+ };
73789
75420
  //#endregion
73790
75421
  //#region src/google-services.addon.ts
73791
75422
  /**
@@ -73811,6 +75442,8 @@ var GoogleServicesAddon = class extends BaseAddon {
73811
75442
  ];
73812
75443
  oauthAccountsHandle = null;
73813
75444
  registry = new GoogleBrokerRegistry();
75445
+ brokerStore = null;
75446
+ activeBrokers = [];
73814
75447
  /** CSRF state → { brokerId, popup, issuedAt } — popup mirrors OIDC D794. */
73815
75448
  pendingStates = /* @__PURE__ */ new Map();
73816
75449
  publicOrigin = null;
@@ -73852,7 +75485,16 @@ var GoogleServicesAddon = class extends BaseAddon {
73852
75485
  await this.oauthAccountsHandle.set(oauthAccounts);
73853
75486
  await legacyHandle.set({ ...DEFAULT_OAUTH_STATE });
73854
75487
  }
73855
- this.registry.seedFrom(this.config.brokers, oauthAccounts.accounts);
75488
+ const records = this.ctx.records;
75489
+ if (records === void 0) throw new Error("google-services: ctx.records is required (hub-only addon)");
75490
+ await records.declare({ brokers: googleBrokersEntryKind });
75491
+ this.brokerStore = GoogleBrokerStore.of(records);
75492
+ this.activeBrokers = await this.loadPersistedBrokers();
75493
+ if ((await this.brokerStore.listResolved()).length === 0 && this.config.brokers.length > 0) {
75494
+ await this.brokerStore.replaceAll(this.config.brokers);
75495
+ this.activeBrokers = await this.loadPersistedBrokers();
75496
+ }
75497
+ this.registry.seedFrom(this.activeBrokers, oauthAccounts.accounts);
73856
75498
  await this.refreshPublicOrigin();
73857
75499
  const calendarProvider = createGoogleCalendarSource({
73858
75500
  logger: this.ctx.logger,
@@ -73924,7 +75566,8 @@ var GoogleServicesAddon = class extends BaseAddon {
73924
75566
  }
73925
75567
  async onConfigChanged() {
73926
75568
  const accounts = this.registry.listOauthAccounts();
73927
- this.registry.seedFrom(this.config.brokers, accounts);
75569
+ this.activeBrokers = await this.loadPersistedBrokers();
75570
+ this.registry.seedFrom(this.activeBrokers, accounts);
73928
75571
  }
73929
75572
  buildBrokerProvider() {
73930
75573
  const ownerAddonId = this.ctx.id;
@@ -74191,6 +75834,7 @@ var GoogleServicesAddon = class extends BaseAddon {
74191
75834
  };
74192
75835
  this.registry.setOauth(next);
74193
75836
  await this.persistOauthAccounts();
75837
+ if (next.refreshToken.length > 0) this.resolveGoogleBrokerReconnectAlert(brokerId);
74194
75838
  if (next.accountEmail && (entry.name === "Google account" || entry.name.startsWith("google_"))) {
74195
75839
  const renamed = {
74196
75840
  ...entry,
@@ -74277,8 +75921,23 @@ var GoogleServicesAddon = class extends BaseAddon {
74277
75921
  const cutoff = Date.now() - 10 * 6e4;
74278
75922
  for (const [k, v] of this.pendingStates) if (v.issuedAt < cutoff) this.pendingStates.delete(k);
74279
75923
  }
75924
+ async loadPersistedBrokers() {
75925
+ const store = this.brokerStore;
75926
+ if (store !== null) {
75927
+ const fromRecords = await store.listResolved();
75928
+ if (fromRecords.length > 0) return fromRecords;
75929
+ }
75930
+ return this.config.brokers;
75931
+ }
74280
75932
  async persistBrokers() {
74281
- await this.updateGlobalSettings({ brokers: [...this.registry.listEntries()] });
75933
+ const entries = [...this.registry.listEntries()];
75934
+ this.activeBrokers = entries;
75935
+ const store = this.brokerStore;
75936
+ if (store !== null) {
75937
+ await store.replaceAll(entries);
75938
+ return;
75939
+ }
75940
+ await this.updateGlobalSettings({ brokers: entries });
74282
75941
  }
74283
75942
  async persistOauthAccounts() {
74284
75943
  if (!this.oauthAccountsHandle) return;
@@ -74308,6 +75967,39 @@ var GoogleServicesAddon = class extends BaseAddon {
74308
75967
  }
74309
75968
  return out.toSorted((a, b) => a.label.localeCompare(b.label));
74310
75969
  }
75970
+ async emitGoogleBrokerReconnectAlert(brokerId, brokerName) {
75971
+ const emit = this.ctx.api.alerts?.emit;
75972
+ if (emit === void 0) {
75973
+ this.ctx.logger.warn("google broker reconnect alert skipped — alerts capability missing", { meta: { brokerId } });
75974
+ return;
75975
+ }
75976
+ try {
75977
+ await emit.mutate(buildGoogleBrokerReconnectAlert(brokerId, brokerName));
75978
+ } catch (err) {
75979
+ this.ctx.logger.warn("google broker reconnect alert emit failed", { meta: {
75980
+ brokerId,
75981
+ error: err instanceof Error ? err.message : String(err)
75982
+ } });
75983
+ }
75984
+ }
75985
+ async resolveGoogleBrokerReconnectAlert(brokerId) {
75986
+ const update = this.ctx.api.alerts?.update;
75987
+ if (update === void 0) return;
75988
+ try {
75989
+ await update.mutate({
75990
+ alertId: googleBrokerReconnectAlertId(brokerId),
75991
+ patch: {
75992
+ status: "completed",
75993
+ read: true
75994
+ }
75995
+ });
75996
+ } catch (err) {
75997
+ this.ctx.logger.warn("google broker reconnect alert resolve failed", { meta: {
75998
+ brokerId,
75999
+ error: err instanceof Error ? err.message : String(err)
76000
+ } });
76001
+ }
76002
+ }
74311
76003
  async ensureAccessToken(brokerId, opts = {}) {
74312
76004
  const entry = this.registry.getEntry(brokerId);
74313
76005
  const oauth = this.registry.getOauth(brokerId);
@@ -74320,10 +76012,16 @@ var GoogleServicesAddon = class extends BaseAddon {
74320
76012
  accountEmail: oauth.accountEmail
74321
76013
  };
74322
76014
  if (!opts.forceRefresh && !needsRefresh(state)) return state.accessToken;
74323
- const tokens = await refreshAccessToken({
74324
- clientId: entry.clientId.trim(),
74325
- clientSecret: entry.clientSecret.trim()
74326
- }, state.refreshToken);
76015
+ let tokens;
76016
+ try {
76017
+ tokens = await refreshAccessToken({
76018
+ clientId: entry.clientId.trim(),
76019
+ clientSecret: entry.clientSecret.trim()
76020
+ }, state.refreshToken);
76021
+ } catch (err) {
76022
+ if (isInvalidGrantRefreshError(err)) this.emitGoogleBrokerReconnectAlert(brokerId, entry.name);
76023
+ throw err;
76024
+ }
74327
76025
  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");
74328
76026
  const nextState = applyTokenResponse(state, tokens);
74329
76027
  this.registry.setOauth({