@camstack/addon-export-google 0.1.121 → 0.1.123

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.
@@ -5913,7 +5913,7 @@ var ZodIssueCode = {
5913
5913
  var ZodFirstPartyTypeKind;
5914
5914
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5915
5915
  //#endregion
5916
- //#region ../types/dist/sleep-B-vp7x15.mjs
5916
+ //#region ../types/dist/sleep-CdJHPm-k.mjs
5917
5917
  /**
5918
5918
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5919
5919
  * window to float samples (D455).
@@ -6030,7 +6030,7 @@ function isKeychainStoredField(field) {
6030
6030
  var SECRET_CLEAR = { $secretClear: true };
6031
6031
  /** The `'***'` token D634 redaction writes for non-admins. */
6032
6032
  var LEGACY_DEVICE_REDACTION = "***";
6033
- function isRecord$6(value) {
6033
+ function isRecord$7(value) {
6034
6034
  return typeof value === "object" && value !== null && !Array.isArray(value);
6035
6035
  }
6036
6036
  function makeSecretMarker(ref) {
@@ -6041,12 +6041,12 @@ function makeSecretMarker(ref) {
6041
6041
  }
6042
6042
  /** A stored marker: an object whose `$secret` is a non-empty string. */
6043
6043
  function isSecretMarker(value) {
6044
- if (!isRecord$6(value)) return false;
6044
+ if (!isRecord$7(value)) return false;
6045
6045
  const ref = value["$secret"];
6046
6046
  return typeof ref === "string" && ref.length > 0;
6047
6047
  }
6048
6048
  function isSecretClear(value) {
6049
- return isRecord$6(value) && value["$secretClear"] === true;
6049
+ return isRecord$7(value) && value["$secretClear"] === true;
6050
6050
  }
6051
6051
  /**
6052
6052
  * The UI view of a stored secret field value: a marker becomes "set", inline
@@ -6429,6 +6429,53 @@ function emitReadiness(bus, params) {
6429
6429
  ts
6430
6430
  }));
6431
6431
  }
6432
+ /** Why a catalogue entry is not a runnable body of its declared kind. */
6433
+ var AddonMigrationDefinitionError = class extends Error {
6434
+ id;
6435
+ constructor(id, message) {
6436
+ super(`${id}: ${message}`);
6437
+ this.id = id;
6438
+ this.name = "AddonMigrationDefinitionError";
6439
+ }
6440
+ };
6441
+ /**
6442
+ * Bind a catalogue to the addon's ports. Throws {@link AddonMigrationDefinitionError} when
6443
+ * an entry's `bodyKind` does not match the body it carries, or is `sql` (a hub-only
6444
+ * body). A throwing body never escapes `execute`: it is reported as a failed result.
6445
+ */
6446
+ function defineAddonMigrations(catalogue, ports) {
6447
+ return catalogue.map((entry) => {
6448
+ const { meta } = entry;
6449
+ if ("plan" in entry) {
6450
+ if (meta.bodyKind !== "plan") throw new AddonMigrationDefinitionError(meta.id, `carries a plan body but declares "${meta.bodyKind}"`);
6451
+ return {
6452
+ meta,
6453
+ execute: () => guarded(async () => ({
6454
+ kind: "plan",
6455
+ plan: await entry.plan(ports)
6456
+ }))
6457
+ };
6458
+ }
6459
+ if (meta.bodyKind !== "procedure") throw new AddonMigrationDefinitionError(meta.id, `carries a procedure body but declares "${meta.bodyKind}"`);
6460
+ return {
6461
+ meta,
6462
+ execute: () => guarded(async () => ({
6463
+ kind: "procedure",
6464
+ result: await entry.procedure(ports)
6465
+ }))
6466
+ };
6467
+ });
6468
+ }
6469
+ async function guarded(work) {
6470
+ try {
6471
+ return await work();
6472
+ } catch (err) {
6473
+ return {
6474
+ kind: "failed",
6475
+ error: errMsg$1(err)
6476
+ };
6477
+ }
6478
+ }
6432
6479
  var NOT_RUN = {
6433
6480
  declared: false,
6434
6481
  snapshot: null,
@@ -6752,7 +6799,7 @@ var KeychainWriteRefusedError = class extends Error {
6752
6799
  }
6753
6800
  };
6754
6801
  var KEEP = { kind: "keep" };
6755
- function isRecord$5(value) {
6802
+ function isRecord$6(value) {
6756
6803
  return typeof value === "object" && value !== null && !Array.isArray(value);
6757
6804
  }
6758
6805
  function defaultMintId() {
@@ -6765,7 +6812,7 @@ function collectSecretMarkerRefs(value, out = []) {
6765
6812
  return out;
6766
6813
  }
6767
6814
  if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6768
- else if (isRecord$5(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6815
+ else if (isRecord$6(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6769
6816
  return out;
6770
6817
  }
6771
6818
  async function storedValueEquals(secrets, marker, candidate) {
@@ -6820,7 +6867,7 @@ function rowId(row, idKey) {
6820
6867
  return null;
6821
6868
  }
6822
6869
  async function writeArray(ctx, node, incoming, stored, fieldPath) {
6823
- const storedRows = Array.isArray(stored) ? stored.filter(isRecord$5) : [];
6870
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$6) : [];
6824
6871
  if (!Array.isArray(incoming)) {
6825
6872
  ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6826
6873
  return {
@@ -6836,7 +6883,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6836
6883
  const kept = /* @__PURE__ */ new Set();
6837
6884
  const rows = [];
6838
6885
  for (const row of incoming) {
6839
- if (!isRecord$5(row)) {
6886
+ if (!isRecord$6(row)) {
6840
6887
  rows.push(row);
6841
6888
  continue;
6842
6889
  }
@@ -6861,7 +6908,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6861
6908
  case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6862
6909
  case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6863
6910
  case "object": {
6864
- if (!isRecord$5(incoming)) {
6911
+ if (!isRecord$6(incoming)) {
6865
6912
  if (incoming === void 0) return KEEP;
6866
6913
  ctx.deletes.push(...collectSecretMarkerRefs(stored));
6867
6914
  return {
@@ -6869,7 +6916,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6869
6916
  value: incoming
6870
6917
  };
6871
6918
  }
6872
- const storedObj = isRecord$5(stored) ? stored : {};
6919
+ const storedObj = isRecord$6(stored) ? stored : {};
6873
6920
  return {
6874
6921
  kind: "value",
6875
6922
  value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
@@ -6992,7 +7039,7 @@ async function resolveSecretMarkers(value, secrets, options = {}) {
6992
7039
  value: items
6993
7040
  };
6994
7041
  }
6995
- if (isRecord$5(v)) {
7042
+ if (isRecord$6(v)) {
6996
7043
  const out = {};
6997
7044
  for (const [k, child] of Object.entries(v)) {
6998
7045
  const s = substitute(child);
@@ -7024,7 +7071,7 @@ var SecretOverwriteRefusedError = class extends Error {
7024
7071
  this.name = "SecretOverwriteRefusedError";
7025
7072
  }
7026
7073
  };
7027
- function isRecord$4(value) {
7074
+ function isRecord$5(value) {
7028
7075
  return typeof value === "object" && value !== null && !Array.isArray(value);
7029
7076
  }
7030
7077
  function resolvedValue(pass, marker) {
@@ -7053,7 +7100,7 @@ function inArray(pass, incoming, stored) {
7053
7100
  return incoming.map((item, index) => {
7054
7101
  const twin = stored[index];
7055
7102
  if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
7056
- if (isRecord$4(item) && isRecord$4(twin)) return inArrayRow(pass, item, twin);
7103
+ if (isRecord$5(item) && isRecord$5(twin)) return inArrayRow(pass, item, twin);
7057
7104
  if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
7058
7105
  return item;
7059
7106
  });
@@ -7064,7 +7111,7 @@ function inArrayRow(pass, incoming, stored) {
7064
7111
  const twin = stored[key];
7065
7112
  if (isSecretMarker(twin)) {
7066
7113
  if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
7067
- } else if (isRecord$4(value) && isRecord$4(twin)) out[key] = inArrayRow(pass, value, twin);
7114
+ } else if (isRecord$5(value) && isRecord$5(twin)) out[key] = inArrayRow(pass, value, twin);
7068
7115
  else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
7069
7116
  }
7070
7117
  return out;
@@ -7072,7 +7119,7 @@ function inArrayRow(pass, incoming, stored) {
7072
7119
  async function walk(pass, incoming, stored) {
7073
7120
  if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
7074
7121
  if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
7075
- if (!isRecord$4(incoming) || !isRecord$4(stored)) return incoming;
7122
+ if (!isRecord$5(incoming) || !isRecord$5(stored)) return incoming;
7076
7123
  const out = { ...incoming };
7077
7124
  for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
7078
7125
  return out;
@@ -7103,7 +7150,7 @@ async function restoreUnchangedSecrets(input) {
7103
7150
  function isJsonEqual(a, b) {
7104
7151
  if (Object.is(a, b)) return true;
7105
7152
  if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
7106
- if (isRecord$4(a) && isRecord$4(b)) {
7153
+ if (isRecord$5(a) && isRecord$5(b)) {
7107
7154
  const keys = Object.keys(a);
7108
7155
  if (keys.length !== Object.keys(b).length) return false;
7109
7156
  return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
@@ -7127,7 +7174,7 @@ function markerKeysOf(blob, owner) {
7127
7174
  }
7128
7175
  function nodeFromStored(value, owner) {
7129
7176
  if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
7130
- if (!isRecord$4(value)) return null;
7177
+ if (!isRecord$5(value)) return null;
7131
7178
  const children = /* @__PURE__ */ new Map();
7132
7179
  for (const [key, child] of Object.entries(value)) {
7133
7180
  const node = nodeFromStored(child, owner);
@@ -7746,6 +7793,44 @@ var BaseAddon = class {
7746
7793
  return null;
7747
7794
  }
7748
7795
  /**
7796
+ * D986 scoped settings: the form shape of the CLUSTER-wide settings one capability this addon
7797
+ * provides owns, or `null` when it has none. `cap` is a capability name the addon's manifest
7798
+ * declares. Stored as `addon-settings` rows `<addonId>.<field>`. The keys of this schema, of
7799
+ * {@link nodeSettingsSchema} and of {@link deviceDefaultsSchema} are disjoint, and a key never
7800
+ * contains `@` (guard `check-scoped-settings-declared`). SHAPE only: values are read by scope.
7801
+ */
7802
+ async clusterSettingsSchema(_cap) {
7803
+ return null;
7804
+ }
7805
+ /**
7806
+ * D986: the form shape of the settings one capability owns PER NODE, or `null`. Stored as
7807
+ * `addon-settings` rows `<addonId>.<field>@<nodeId>` carrying `nodeId` in the row data, so a
7808
+ * forgotten node's rows go in one central delete.
7809
+ */
7810
+ async nodeSettingsSchema(_cap) {
7811
+ return null;
7812
+ }
7813
+ /**
7814
+ * D986: the form shape of the FLEET DEFAULTS of the per-device settings one capability owns,
7815
+ * or `null`. Stored as `addon-settings` rows `<addonId>.<field>`; a device resolves its value
7816
+ * as device row, then this default, then the schema default (`resolveDeviceSettings`).
7817
+ */
7818
+ async deviceDefaultsSchema(_cap) {
7819
+ return null;
7820
+ }
7821
+ /**
7822
+ * The host's read of the scoped declarations: the schema one capability declares for `scope`,
7823
+ * or `null`. Beside {@link getIntegrationFormSchema}, the same shape: the hook is protected, the
7824
+ * host asks this method.
7825
+ */
7826
+ async getScopedSettingsSchema(scope, cap) {
7827
+ switch (scope) {
7828
+ case "cluster": return this.clusterSettingsSchema(cap);
7829
+ case "node": return this.nodeSettingsSchema(cap);
7830
+ case "device-defaults": return this.deviceDefaultsSchema(cap);
7831
+ }
7832
+ }
7833
+ /**
7749
7834
  * What the create wizard and the integration edit page render for one instance: the addon's
7750
7835
  * per-instance schema when it declares one, else its global schema (what they always showed).
7751
7836
  */
@@ -8539,6 +8624,21 @@ function normalizeAddonInitResult(result) {
8539
8624
  if (Array.isArray(result)) return { providers: result };
8540
8625
  return result;
8541
8626
  }
8627
+ /** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
8628
+ /** The files a kind may live in. `history` is device-history's (D850), never records. */
8629
+ var RECORD_DATABASES = ["settings", "events"];
8630
+ /** The classes of a kind: the `@durable` vocabulary, one authority (replaces the annotation). */
8631
+ var RECORD_CLASSES = [
8632
+ "config",
8633
+ "ledger",
8634
+ "audit",
8635
+ "mirror",
8636
+ "ephemeral"
8637
+ ];
8638
+ var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
8639
+ var RECORD_MAX_DATA_BYTES = 1024 * 1024;
8640
+ var RECORD_BATCH_MAX = 1e3;
8641
+ var RECORD_QUERY_MAX = 1e3;
8542
8642
  /**
8543
8643
  * The share-view scope kinds a share-link token can carry. The hub mints
8544
8644
  * and validates them (`ShareViewGrantSchema` builds its
@@ -8563,21 +8663,6 @@ var PeerBytesTicketSchema = object({
8563
8663
  */
8564
8664
  declaredBytes: number().int().nonnegative().nullable()
8565
8665
  });
8566
- /** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
8567
- /** The files a kind may live in. `history` is device-history's (D850), never records. */
8568
- var RECORD_DATABASES = ["settings", "events"];
8569
- /** The classes of a kind: the `@durable` vocabulary, one authority (replaces the annotation). */
8570
- var RECORD_CLASSES = [
8571
- "config",
8572
- "ledger",
8573
- "audit",
8574
- "mirror",
8575
- "ephemeral"
8576
- ];
8577
- var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
8578
- var RECORD_MAX_DATA_BYTES = 1024 * 1024;
8579
- var RECORD_BATCH_MAX = 1e3;
8580
- var RECORD_QUERY_MAX = 1e3;
8581
8666
  /**
8582
8667
  * Record kinds (D881): the declaration an addon makes of one kind of fact, the
8583
8668
  * Zod row schema that describes it, and the helper that turns the two into the
@@ -9269,28 +9354,6 @@ var PipelineRunResultBridge = custom();
9269
9354
  var StaticDirOutputSchema = object({ staticDir: string() });
9270
9355
  var VersionOutputSchema = object({ version: string() });
9271
9356
  method(_void(), StaticDirOutputSchema, { auth: "admin" }), method(_void(), VersionOutputSchema, { auth: "admin" });
9272
- /**
9273
- * Identity — preserves literal types for downstream inference.
9274
- *
9275
- * The constraint is `Record<string, unknown>` (not `CustomActionsSpec`) so
9276
- * TypeScript does not widen each entry's literal `kind`/`auth` fields to
9277
- * the broader unions declared on `CustomActionSpec`'s default generics.
9278
- * Shape validity is enforced separately by the `customAction(...)` helper
9279
- * whose return type is already a `CustomActionSpec<...>`.
9280
- */
9281
- function defineCustomActions(spec) {
9282
- return spec;
9283
- }
9284
- function customAction(input, output, options) {
9285
- return {
9286
- input,
9287
- output,
9288
- kind: options?.kind ?? "query",
9289
- auth: options?.auth ?? "protected",
9290
- scope: options?.scope ?? { kind: "system" },
9291
- ...options?.caller ? { caller: "required" } : {}
9292
- };
9293
- }
9294
9357
  Object.freeze({ "doorbell": "lastPressedAt" });
9295
9358
  /** Every capability name, so addon code can check a name without the schema graph. */
9296
9359
  var CAP_NAMES = Object.freeze([
@@ -9381,6 +9444,7 @@ var CAP_NAMES = Object.freeze([
9381
9444
  "humidity-sensor",
9382
9445
  "image",
9383
9446
  "image-settings",
9447
+ "integration-instances",
9384
9448
  "integrations",
9385
9449
  "intercom",
9386
9450
  "ir-transmitter",
@@ -11314,7 +11378,7 @@ object({
11314
11378
  params: record(string(), union([string(), number()])).optional()
11315
11379
  });
11316
11380
  //#endregion
11317
- //#region ../types/dist/composition-kKKOdFIG.mjs
11381
+ //#region ../types/dist/composition-BDUoQsw9.mjs
11318
11382
  /**
11319
11383
  * The ffmpeg build every CamStack node downloads, per platform and arch.
11320
11384
  *
@@ -13739,6 +13803,16 @@ var MigrationPlanSchema = object({ edits: array(discriminatedUnion("op", [
13739
13803
  precondition: PreconditionSchema
13740
13804
  })
13741
13805
  ])) });
13806
+ /** `JSON.stringify` with object keys sorted, so equal values spell the same. */
13807
+ function canonicalJson(value) {
13808
+ if (Array.isArray(value)) return `[${value.map((item) => canonicalJson(item)).join(",")}]`;
13809
+ if (typeof value === "object" && value !== null) return `{${Object.entries(value).filter(([, item]) => item !== void 0).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([key, item]) => `${JSON.stringify(key)}:${canonicalJson(item)}`).join(",")}}`;
13810
+ return JSON.stringify(value) ?? "null";
13811
+ }
13812
+ /** The precondition string for a value a plan read (`null` when it read nothing). */
13813
+ function preconditionOf(value) {
13814
+ return canonicalJson(value ?? null);
13815
+ }
13742
13816
  /**
13743
13817
  * What a `procedure` body reports. `already-done` means the rerun observed the
13744
13818
  * work finished (a crash between the work and the ledger row, or a manual fix)
@@ -15687,8 +15761,18 @@ var LogChannelDescriptorSchema = object({
15687
15761
  * the operator narrows to one camera, sees nothing, and concludes the code
15688
15762
  * path was never taken.
15689
15763
  */
15690
- perDevice: boolean()
15691
- });
15764
+ perDevice: boolean(),
15765
+ /**
15766
+ * What the channel is FOR, so the UI can list the channels an addon offers.
15767
+ *
15768
+ * - `diagnostic` (the default): a per-component diagnostic armed from the
15769
+ * Levels page, emitted at its declared level.
15770
+ * - `debug`: a `debug.<channel>` dump watched live for a short window
15771
+ * (`ctx.debug`). Always per-device, and its lines are denied by the log
15772
+ * ring unless somebody is watching that device.
15773
+ */
15774
+ kind: _enum(["diagnostic", "debug"]).default("diagnostic")
15775
+ }).refine((d) => d.kind !== "debug" || d.name.startsWith("debug.") && d.perDevice, { message: "a debug channel is named debug.<channel> and is per-device" });
15692
15776
  /**
15693
15777
  * An armed window over one channel, as the document hands it to a mirror.
15694
15778
  *
@@ -20911,6 +20995,7 @@ var SYSTEM_CAP_VOCABULARY = {
20911
20995
  "load-contribution": system(INTERNAL),
20912
20996
  "local-network": system(NETWORK),
20913
20997
  "log-channels": system(INTERNAL),
20998
+ "integration-instances": system(INTERNAL),
20914
20999
  "log-destination": system(INTERNAL),
20915
21000
  "login-method": system(IDENTITY),
20916
21001
  "mesh-network": system(NETWORK),
@@ -43057,7 +43142,7 @@ var TargetKindCapsSchema = object({
43057
43142
  * the union is large and not meant for runtime validation here; the exported
43058
43143
  * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
43059
43144
  */
43060
- var ConfigSchemaPassthrough$3 = unknown();
43145
+ var ConfigSchemaPassthrough$4 = unknown();
43061
43146
  var TargetKindSchema = object({
43062
43147
  kind: string(),
43063
43148
  label: string(),
@@ -43094,7 +43179,7 @@ var TargetKindSchema = object({
43094
43179
  * its raster path, which is the safe default for an unknown image.
43095
43180
  */
43096
43181
  iconMediaType: string().optional(),
43097
- configSchema: ConfigSchemaPassthrough$3,
43182
+ configSchema: ConfigSchemaPassthrough$4,
43098
43183
  /**
43099
43184
  * The config keys that decide WHERE this kind's secrets are sent (server,
43100
43185
  * base URL, instance, chat, recipient). A save that changes any of them
@@ -49517,6 +49602,45 @@ method(_void(), _void(), { kind: "mutation" }), method(_void(), _void(), { kind:
49517
49602
  auth: "admin"
49518
49603
  });
49519
49604
  /**
49605
+ * What the passive listener of `local-network` saw on the wire, before any
49606
+ * provider classified it. Device-manager turns an observation into the hits
49607
+ * of the providers whose declared discovery modes it matches.
49608
+ */
49609
+ var DiscoveryObservationSchema = discriminatedUnion("kind", [object({
49610
+ kind: literal("mdns"),
49611
+ /** Normalised DNS-SD service type, e.g. `_esphomelib._tcp`. */
49612
+ serviceType: string(),
49613
+ instance: string(),
49614
+ host: string(),
49615
+ /** The A record address when the announcement carried one. */
49616
+ address: string().nullable(),
49617
+ port: number().int(),
49618
+ txt: record(string(), string())
49619
+ }), object({
49620
+ kind: literal("ssdp"),
49621
+ /** Sender address of the datagram. */
49622
+ host: string(),
49623
+ port: number().int(),
49624
+ /** `NT` of a NOTIFY, `ST` of a search response. */
49625
+ target: string(),
49626
+ headers: record(string(), string())
49627
+ })]);
49628
+ object({
49629
+ addonId: string(),
49630
+ candidate: DiscoveryCandidateSchema,
49631
+ firstSeenAt: number(),
49632
+ lastSeenAt: number(),
49633
+ dismissed: boolean()
49634
+ });
49635
+ var DiscoveryProposalSchema = object({
49636
+ id: string(),
49637
+ addonId: string(),
49638
+ candidate: DiscoveryCandidateSchema,
49639
+ firstSeenAt: number(),
49640
+ lastSeenAt: number(),
49641
+ dismissed: boolean()
49642
+ });
49643
+ /**
49520
49644
  * Device Manager capability — hub-side singleton that unifies device persistence,
49521
49645
  * live registry access, and all management operations into a single tRPC surface.
49522
49646
  *
@@ -50245,6 +50369,19 @@ method(object({
50245
50369
  }), object({ candidates: array(DiscoveryCandidateSchema).readonly() }), {
50246
50370
  kind: "mutation",
50247
50371
  auth: "admin"
50372
+ }), method(object({}), object({ proposals: array(DiscoveryProposalSchema).readonly() }), { auth: "admin" }), method(object({ id: string() }), object({ dismissed: boolean() }), {
50373
+ kind: "mutation",
50374
+ auth: "admin"
50375
+ }), method(object({ observations: array(DiscoveryObservationSchema).max(512) }), object({ proposed: number().int() }), {
50376
+ kind: "mutation",
50377
+ auth: "admin"
50378
+ }), method(object({}), object({
50379
+ providers: number().int(),
50380
+ proposed: number().int()
50381
+ }), {
50382
+ kind: "mutation",
50383
+ auth: "admin",
50384
+ timeoutMs: 12e4
50248
50385
  }), method(object({ addonId: string() }), object({ deviceType: _enum(DeviceType).nullable() }), { auth: "admin" }), method(object({ addonId: string() }), unknown(), { auth: "admin" }), method(object({
50249
50386
  deviceId: number(),
50250
50387
  key: string(),
@@ -52790,9 +52927,15 @@ var AvailableIntegrationTypeSchema = object({
52790
52927
  * branch on CAP — never on addon name. `device-adoption` integrations
52791
52928
  * (Home Assistant, …) route through the broker step (Approach A);
52792
52929
  * `device-provider` integrations (Reolink/ONVIF) keep the
52793
- * legacy config → discovery flow.
52930
+ * legacy config → discovery flow. `connection` is an addon that only holds a
52931
+ * connection as typed records (`integration-instances`, D985): no devices,
52932
+ * no discovery.
52794
52933
  */
52795
- kind: _enum(["device-adoption", "device-provider"]),
52934
+ kind: _enum([
52935
+ "device-adoption",
52936
+ "device-provider",
52937
+ "connection"
52938
+ ]),
52796
52939
  /**
52797
52940
  * For `device-adoption` addons: the broker kind to create/link
52798
52941
  * (e.g. `home-assistant`), declared in the addon manifest. `null` for
@@ -52905,6 +53048,67 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
52905
53048
  auth: "admin"
52906
53049
  });
52907
53050
  /**
53051
+ * `integration-instances` - the connection of an addon that holds ONE or SEVERAL
53052
+ * (an account, a relay, a destination) as typed records, shown on the
53053
+ * Integrations page like every other integration (D985, D986).
53054
+ *
53055
+ * A collection of providers: each addon that holds connections registers one
53056
+ * and the hub aggregator (`integrations.*`) reaches a provider with the pinned
53057
+ * `addonId`. It is internal and has no route: the operator-facing surface is
53058
+ * the `integrations` cap, which keeps ONE list.
53059
+ *
53060
+ * Identity: the instance id IS the `integrations` registry id (`int_NNNN`,
53061
+ * immutable, already in the `/integrations/<id>` URL). A second operator-chosen
53062
+ * slug would be a second authority over one identity (D224). `name` is the
53063
+ * editable label.
53064
+ *
53065
+ * Secrets: every field the instance kind marks `.meta({ secret: true })` reaches
53066
+ * the form as a `SecretFieldView`, never text (D789). A patch value omitted, `''`
53067
+ * or the redaction token KEEPS the stored secret; `{ $secretClear: true }`
53068
+ * clears it.
53069
+ */
53070
+ var ConfigSchemaPassthrough$3 = custom();
53071
+ var IntegrationInstanceIdSchema = string().min(1);
53072
+ var IntegrationInstanceDescriptionSchema = object({
53073
+ /** `single`: at most one instance can exist (Loki). `multiple`: an account each. */
53074
+ instanceMode: _enum(["single", "multiple"]),
53075
+ /** What the instance is, for the UI (`destination`, `relay`, `account`). */
53076
+ kind: string(),
53077
+ /** True when `testInstance` really probes the remote. */
53078
+ canTest: boolean()
53079
+ });
53080
+ var IntegrationInstanceStatusSchema = object({
53081
+ state: _enum([
53082
+ "ok",
53083
+ "off",
53084
+ "error",
53085
+ "unknown"
53086
+ ]),
53087
+ detail: string().optional()
53088
+ });
53089
+ var IntegrationInstanceSchema = object({
53090
+ id: IntegrationInstanceIdSchema,
53091
+ name: string(),
53092
+ /** The addon's own rule (an URL is present, a client id is present...). */
53093
+ configured: boolean(),
53094
+ /** Values for the instance form; a secret is a `SecretFieldView`, never text. */
53095
+ formValues: record(string(), unknown()),
53096
+ status: IntegrationInstanceStatusSchema.optional()
53097
+ });
53098
+ var IntegrationInstancePatchSchema = object({
53099
+ id: IntegrationInstanceIdSchema,
53100
+ name: string().min(1).optional(),
53101
+ /** Omitted / '' / redaction token keeps a secret; `{ $secretClear: true }` clears it. */
53102
+ values: record(string(), unknown())
53103
+ });
53104
+ method(_void(), IntegrationInstanceDescriptionSchema), method(object({ id: IntegrationInstanceIdSchema.nullable() }), ConfigSchemaPassthrough$3), method(_void(), array(IntegrationInstanceSchema).readonly()), method(object({ id: IntegrationInstanceIdSchema }), IntegrationInstanceSchema.nullable()), method(object({
53105
+ id: IntegrationInstanceIdSchema,
53106
+ name: string().min(1)
53107
+ }), object({ id: string() }), { kind: "mutation" }), method(IntegrationInstancePatchSchema, object({ ok: literal(true) }), { kind: "mutation" }), method(object({ id: IntegrationInstanceIdSchema }), object({ ok: literal(true) }), { kind: "mutation" }), optionalMethod(object({
53108
+ id: IntegrationInstanceIdSchema.nullable(),
53109
+ values: record(string(), unknown())
53110
+ }), TestConnectionResultSchema$1, { kind: "mutation" });
53111
+ /**
52908
53112
  * Two-way audio / talk-back cap. Clients open a WebRTC audio-only
52909
53113
  * session (server-initiated offer pattern, identical to the main
52910
53114
  * video WebRTC flow) and the browser captures the mic; the server
@@ -72054,6 +72258,40 @@ var LoggingSettingsStateSchema = object({
72054
72258
  opsLogRetentionDays: number().int().min(0),
72055
72259
  persisted: boolean()
72056
72260
  });
72261
+ /**
72262
+ * Debug WATCH — a short, per-device window over `debug.<channel>` lines.
72263
+ *
72264
+ * `start` opens (or re-arms) a 10 minute window; `rearm` extends a LIVE one
72265
+ * and never revives a lapsed one; `stop` closes it; `list` only reads. No
72266
+ * chain of re-arms outlives 60 minutes from the first start. The hub holds the
72267
+ * watches in memory and pushes the interest to every node, so a watch lapses
72268
+ * by itself and survives nothing — a restart is a stop.
72269
+ */
72270
+ var DebugWatchInputSchema = object({
72271
+ action: _enum([
72272
+ "list",
72273
+ "start",
72274
+ "rearm",
72275
+ "stop"
72276
+ ]),
72277
+ /** Full channel names, `debug.<channel>`, each declared with `kind: 'debug'`. */
72278
+ channels: array(string().min(1)).readonly().default([]),
72279
+ /** Numeric device ids. Required (non-empty) for `start`. */
72280
+ deviceIds: array(number().int()).readonly().default([])
72281
+ });
72282
+ var DebugWatchStateSchema = object({
72283
+ channel: string(),
72284
+ deviceIds: array(number().int()).readonly(),
72285
+ startedAtMs: number(),
72286
+ untilMs: number(),
72287
+ capAtMs: number()
72288
+ });
72289
+ var DebugWatchResultSchema = object({
72290
+ nowMs: number(),
72291
+ watches: array(DebugWatchStateSchema).readonly(),
72292
+ /** Channels a `rearm` found already lapsed: nothing was revived. */
72293
+ lapsed: array(string()).readonly()
72294
+ });
72057
72295
  method(_void(), SystemInfoSchema), method(_void(), HealthStatusSchema), method(_void(), FeatureManifestSchema), method(_void(), array(NetworkAddressSchema).readonly()), method(_void(), unknown().nullable(), { auth: "admin" }), method(record(string(), unknown()), _null(), {
72058
72296
  kind: "mutation",
72059
72297
  auth: "admin"
@@ -72069,6 +72307,9 @@ method(_void(), SystemInfoSchema), method(_void(), HealthStatusSchema), method(_
72069
72307
  }), method(_void(), RequestCensusStatusSchema, { auth: "admin" }), method(_void(), array(ReportedLoadContributionSchema).readonly(), { auth: "admin" }), method(_void(), array(ReportedFailureContributionSchema).readonly(), { auth: "admin" }), method(GetLoggingSettingsInputSchema, LoggingSettingsStateSchema, { auth: "admin" }), method(SetLoggingSettingsInputSchema, LoggingSettingsStateSchema, {
72070
72308
  kind: "mutation",
72071
72309
  auth: "admin"
72310
+ }), method(DebugWatchInputSchema, DebugWatchResultSchema, {
72311
+ kind: "mutation",
72312
+ auth: "admin"
72072
72313
  });
72073
72314
  object({
72074
72315
  /** True when the device's tamper switch / case-open contact is
@@ -76942,6 +77183,13 @@ Object.freeze({
76942
77183
  access: "view",
76943
77184
  role: "admin"
76944
77185
  },
77186
+ "deviceManager.dismissDiscoveryProposal": {
77187
+ capName: "device-manager",
77188
+ capScope: "system",
77189
+ addonId: null,
77190
+ access: "create",
77191
+ role: "admin"
77192
+ },
76945
77193
  "deviceManager.enable": {
76946
77194
  capName: "device-manager",
76947
77195
  capScope: "system",
@@ -77124,6 +77372,13 @@ Object.freeze({
77124
77372
  access: "view",
77125
77373
  role: "viewer"
77126
77374
  },
77375
+ "deviceManager.listDiscoveryProposals": {
77376
+ capName: "device-manager",
77377
+ capScope: "system",
77378
+ addonId: null,
77379
+ access: "view",
77380
+ role: "admin"
77381
+ },
77127
77382
  "deviceManager.listLocationDescriptions": {
77128
77383
  capName: "device-manager",
77129
77384
  capScope: "system",
@@ -77278,6 +77533,13 @@ Object.freeze({
77278
77533
  access: "create",
77279
77534
  role: "admin"
77280
77535
  },
77536
+ "deviceManager.reportDiscoveryObservations": {
77537
+ capName: "device-manager",
77538
+ capScope: "system",
77539
+ addonId: null,
77540
+ access: "create",
77541
+ role: "admin"
77542
+ },
77281
77543
  "deviceManager.runDeviceAction": {
77282
77544
  capName: "device-manager",
77283
77545
  capScope: "system",
@@ -77285,6 +77547,13 @@ Object.freeze({
77285
77547
  access: "create",
77286
77548
  role: "admin"
77287
77549
  },
77550
+ "deviceManager.runDiscoverySweep": {
77551
+ capName: "device-manager",
77552
+ capScope: "system",
77553
+ addonId: null,
77554
+ access: "create",
77555
+ role: "admin"
77556
+ },
77288
77557
  "deviceManager.setChildLayout": {
77289
77558
  capName: "device-manager",
77290
77559
  capScope: "system",
@@ -78216,6 +78485,62 @@ Object.freeze({
78216
78485
  access: "create",
78217
78486
  role: "admin"
78218
78487
  },
78488
+ "integrationInstances.createInstance": {
78489
+ capName: "integration-instances",
78490
+ capScope: "system",
78491
+ addonId: null,
78492
+ access: "create",
78493
+ role: "admin"
78494
+ },
78495
+ "integrationInstances.deleteInstance": {
78496
+ capName: "integration-instances",
78497
+ capScope: "system",
78498
+ addonId: null,
78499
+ access: "delete",
78500
+ role: "admin"
78501
+ },
78502
+ "integrationInstances.describe": {
78503
+ capName: "integration-instances",
78504
+ capScope: "system",
78505
+ addonId: null,
78506
+ access: "view",
78507
+ role: "admin"
78508
+ },
78509
+ "integrationInstances.getInstance": {
78510
+ capName: "integration-instances",
78511
+ capScope: "system",
78512
+ addonId: null,
78513
+ access: "view",
78514
+ role: "admin"
78515
+ },
78516
+ "integrationInstances.instanceFormSchema": {
78517
+ capName: "integration-instances",
78518
+ capScope: "system",
78519
+ addonId: null,
78520
+ access: "view",
78521
+ role: "admin"
78522
+ },
78523
+ "integrationInstances.listInstances": {
78524
+ capName: "integration-instances",
78525
+ capScope: "system",
78526
+ addonId: null,
78527
+ access: "view",
78528
+ role: "admin"
78529
+ },
78530
+ "integrationInstances.testInstance": {
78531
+ capName: "integration-instances",
78532
+ capScope: "system",
78533
+ addonId: null,
78534
+ access: "create",
78535
+ role: "admin"
78536
+ },
78537
+ "integrationInstances.updateInstance": {
78538
+ capName: "integration-instances",
78539
+ capScope: "system",
78540
+ addonId: null,
78541
+ access: "create",
78542
+ role: "admin"
78543
+ },
78219
78544
  "integrations.create": {
78220
78545
  capName: "integrations",
78221
78546
  capScope: "system",
@@ -83872,6 +84197,13 @@ Object.freeze({
83872
84197
  access: "create",
83873
84198
  role: "viewer"
83874
84199
  },
84200
+ "system.debugWatch": {
84201
+ capName: "system",
84202
+ capScope: "system",
84203
+ addonId: null,
84204
+ access: "create",
84205
+ role: "admin"
84206
+ },
83875
84207
  "system.detectSiteLocation": {
83876
84208
  capName: "system",
83877
84209
  capScope: "system",
@@ -87815,6 +88147,11 @@ Object.freeze({
87815
88147
  form: "single",
87816
88148
  optional: false
87817
88149
  }],
88150
+ "system.debugWatch": [{
88151
+ name: "deviceIds",
88152
+ form: "array",
88153
+ optional: true
88154
+ }],
87818
88155
  "tamper.getStatus": [{
87819
88156
  name: "deviceId",
87820
88157
  form: "single",
@@ -89707,38 +90044,6 @@ var ActionSceneExports = class {
89707
90044
  }
89708
90045
  };
89709
90046
  //#endregion
89710
- //#region src/custom-actions.ts
89711
- /**
89712
- * Google Home Export — customActions catalog.
89713
- *
89714
- * One entry. The settings form's `addon-action-button` dispatches through the
89715
- * generic `api.addons.custom.mutate({ addonId, action, input })` channel and
89716
- * shows the result under the button, so a button here costs no capability, no
89717
- * codegen and no framework publish train — the catalog travels inside this
89718
- * addon's own bundle. Admin-only: it writes this addon's settings.
89719
- */
89720
- var exportGoogleActions = defineCustomActions({
89721
- /**
89722
- * Re-scan the connected `network-access` providers and refresh the address
89723
- * shown under the field.
89724
- *
89725
- * Deliberately NOT the same contract as `export-alexa`'s action of the same
89726
- * shape: that one replaces a manual override when it is no longer detected,
89727
- * because Alexa ROUTES on the value. Nothing routes on this one — it is what
89728
- * the operator already pasted into Google's console — so this only fills the
89729
- * field when it is empty. `filled` says whether it did.
89730
- */
89731
- detectPublicHubUrl: customAction(object({}).optional(), object({
89732
- publicHubUrl: string(),
89733
- detectedPublicHubUrl: string(),
89734
- filled: boolean(),
89735
- /** One sentence saying what happened, for the button. */
89736
- summary: string()
89737
- }), {
89738
- kind: "mutation",
89739
- auth: "admin"
89740
- }) });
89741
- //#endregion
89742
90047
  //#region src/google-home/trait-catalog.ts
89743
90048
  /**
89744
90049
  * The trait catalog — one ROW per camstack capability, and that row is the
@@ -90535,217 +90840,104 @@ function buildGoogleOauthIntegration() {
90535
90840
  };
90536
90841
  }
90537
90842
  //#endregion
90538
- //#region src/public-hub-url.ts
90539
- /**
90540
- * The hub's public HTTPS origin — detected, never invented.
90541
- *
90542
- * `publicHubUrl` is the single operator-facing value in this addon, and the
90543
- * three URLs pasted into the Google Home Developer Console (fulfillment,
90544
- * authorization, token) are all rendered from it. Nothing ROUTES on it: Google
90545
- * calls the fulfillment URL it was configured with. A wrong value therefore
90546
- * fails at paste time, in the console, hours before anything here notices —
90547
- * which is exactly why the field has to say where its content came from.
90548
- *
90549
- * ## Where the URL comes from
90550
- *
90551
- * The `network-access` capability, same source `addon-export-alexa` uses. It is
90552
- * a codegen'd collection cap with `scope: 'system'`, so it is reachable
90553
- * cross-process through `ctx.api` — unlike the `addons` core router, which a
90554
- * forked addon calling `ctx.api.addons.*` would wait on forever.
90555
- *
90556
- * **Not** the hub's own address from `local-network` (`getAddresses().roles`). That
90557
- * answers a different question — which address an agent or a browser on the
90558
- * LAN reaches — and it is routinely a LAN address; the backend's
90559
- * `publicHubUrl()` fallback is localhost in dev. Google calls from its own
90560
- * cloud, so a LAN answer here is worse than no answer — it produces three
90561
- * console URLs that look complete and can never be reached.
90562
- *
90563
- * ## Why this is a second copy of Alexa's mechanism
90564
- *
90565
- * Alexa's lives in `packages/addon-export-alexa/src/export-alexa.addon.ts` as
90566
- * private methods, and addons never import each other. The only shared home
90567
- * would be `@camstack/types` or `@camstack/server/system` — both stay host-resolved in
90568
- * an addon bundle (`tools/build/vite-lib.preset.ts`), so putting it there would
90569
- * put this addon on the framework publish train and destroy the one property
90570
- * that makes it attractive: `camstack deploy packages/addon-export-google` and
90571
- * nothing else. The SOURCE and the POLICY are Alexa's; two behaviours diverge
90572
- * on purpose and both are named below.
90573
- *
90574
- * ## Two deliberate divergences from Alexa
90575
- *
90576
- * 1. **Refresh never clobbers.** Alexa's `redetectPublicHubUrl` replaces a
90577
- * manual override whenever it is not among the detected endpoints — sound
90578
- * there, because the URL is baked into every Alexa-bound JWT as a routing
90579
- * claim and a stale one breaks routing. Here the value is what the operator
90580
- * already pasted into Google's console; silently rewriting it would leave
90581
- * the console and the hub disagreeing with no visible cause. Detection fills
90582
- * an EMPTY field and does nothing else.
90583
- * 2. **A non-routable origin is dropped.** Alexa forwards whatever the cap
90584
- * reports. See {@link isPubliclyRoutableOrigin}.
90585
- */
90586
- /** Trailing slashes off, surrounding space off. Nothing else is rewritten. */
90587
- var normalisePublicHubUrl = (raw) => raw.trim().replace(/\/+$/, "");
90588
- var LOOPBACK_HOSTS = [
90589
- "localhost",
90590
- "127.0.0.1",
90591
- "::1",
90592
- "[::1]",
90593
- "0.0.0.0"
90594
- ];
90595
- /**
90596
- * Whether Google's cloud could plausibly reach this origin.
90597
- *
90598
- * The `network-access` providers this hub ships (Cloudflare Tunnel, Tailscale
90599
- * Funnel) publish public FQDNs, but the cap does not promise it: a provider is
90600
- * free to report an HTTPS ingress on a private address. Defaulting the field to
90601
- * one of those would hand the operator three console URLs that look finished
90602
- * and can never answer — strictly worse than an empty field, because an empty
90603
- * field is visibly unfinished.
90604
- *
90605
- * Conservative on purpose: only loopback, RFC1918, link-local, `.local` and
90606
- * dotless hostnames are refused. A public tunnel hostname always has a dot.
90607
- */
90608
- var isPubliclyRoutableOrigin = (origin) => {
90609
- let host;
90610
- try {
90611
- host = new URL(origin).hostname.toLowerCase();
90612
- } catch {
90613
- return false;
90614
- }
90615
- if (host.length === 0) return false;
90616
- if (LOOPBACK_HOSTS.includes(host)) return false;
90617
- if (host.startsWith("127.") || host.startsWith("169.254.")) return false;
90618
- if (host.startsWith("10.") || host.startsWith("192.168.")) return false;
90619
- if (/^172\.(1[6-9]|2\d|3[01])\./.test(host)) return false;
90620
- if (host.endsWith(".local") || host.endsWith(".internal") || host.endsWith(".lan")) return false;
90621
- if (!host.includes(".")) return false;
90622
- return true;
90623
- };
90624
- /**
90625
- * Every publicly routable HTTPS origin the `network-access` cap reports, in the
90626
- * cap's own order, deduped. Empty when there is none — the caller leaves the
90627
- * field alone rather than inventing a value.
90628
- */
90629
- var detectPublicHubOrigins = async (deps) => {
90630
- const fromList = await originsFromListEndpoints(deps);
90631
- if (fromList.length > 0) return fromList;
90632
- const fromStatus = await originFromGetStatus(deps);
90633
- if (fromStatus.length > 0) return [fromStatus];
90634
- deps.logger.warn("export-google: no connected HTTPS external address — the public hub URL cannot be derived, so the Google console URLs stay unrendered. Set up remote access (Cloudflare Tunnel, Tailscale Funnel, …) and press \"Detect external address\", or type the URL on the settings form.");
90635
- return [];
90636
- };
90637
- var usableOrigins = (candidates, logger) => {
90638
- const out = /* @__PURE__ */ new Set();
90639
- for (const candidate of candidates) {
90640
- if (candidate.protocol !== "https" || candidate.url.length === 0) continue;
90641
- const origin = normalisePublicHubUrl(candidate.url);
90642
- if (!isPubliclyRoutableOrigin(origin)) {
90643
- logger.info("export-google: ignored an external address that is not reachable from the internet — Google calls the fulfillment URL from its own cloud", { meta: { origin } });
90644
- continue;
90645
- }
90646
- out.add(origin);
90647
- }
90648
- return [...out];
90649
- };
90650
- var originsFromListEndpoints = async (deps) => {
90651
- try {
90652
- return usableOrigins(await deps.network.listEndpoints(), deps.logger);
90653
- } catch (err) {
90654
- deps.logger.debug("export-google: networkAccess.listEndpoints failed", { meta: { error: errMsg$1(err) } });
90655
- return [];
90656
- }
90657
- };
90658
- var originFromGetStatus = async (deps) => {
90659
- try {
90660
- const status = await deps.network.getStatus();
90661
- if (status === null || !status.connected || status.endpoint === null) return "";
90662
- return usableOrigins([status.endpoint], deps.logger)[0] ?? "";
90663
- } catch (err) {
90664
- deps.logger.debug("export-google: networkAccess.getStatus failed", { meta: { error: errMsg$1(err) } });
90665
- return "";
90666
- }
90843
+ //#region src/migrations/drop-public-hub-url.ts
90844
+ /**
90845
+ * The hub's public URL is no longer a setting of this addon (D986 §5): Google reads the
90846
+ * `publicEndpoint` role of the local-network palette on every use. The two keys older
90847
+ * versions persisted are deleted. Every other key is left exactly as stored.
90848
+ *
90849
+ * Idempotent: a store without either key yields an empty plan, which writes nothing.
90850
+ */
90851
+ /** The addon id, the prefix of its rows in the canonical settings table. */
90852
+ var GOOGLE_ADDON_ID = "export-google";
90853
+ /**
90854
+ * Where the addon's global settings live: the canonical `addon-settings` table, one row per
90855
+ * key, id `<addonId>.<key>`, data `{ addonId, key, value }` (never a per-addon scoped table,
90856
+ * which exists only when something lazily declared it).
90857
+ */
90858
+ var ADDON_SETTINGS_TABLE = "addon-settings";
90859
+ var RETIRED_PUBLIC_URL_KEYS = ["publicHubUrl", "detectedPublicHubUrl"];
90860
+ async function planDropPublicHubUrl(ports) {
90861
+ const stored = await ports.readStored();
90862
+ const present = RETIRED_PUBLIC_URL_KEYS.filter((key) => key in stored);
90863
+ if (present.length === 0) return { edits: [] };
90864
+ const rowId = (key) => `${GOOGLE_ADDON_ID}.${key}`;
90865
+ return { edits: [{
90866
+ op: "deleteKeys",
90867
+ scope: ADDON_SETTINGS_TABLE,
90868
+ keys: present.map(rowId),
90869
+ precondition: preconditionOf(Object.fromEntries(present.map((key) => [rowId(key), {
90870
+ addonId: GOOGLE_ADDON_ID,
90871
+ key,
90872
+ value: stored[key]
90873
+ }])))
90874
+ }] };
90875
+ }
90876
+ //#endregion
90877
+ //#region src/migrations/index.ts
90878
+ /** The `export-google` catalogue (D987): offered to the engine when the addon initialises. */
90879
+ var ADDON_MIGRATIONS = [{
90880
+ meta: {
90881
+ id: "export-google/2026-11-02-drop-public-hub-url",
90882
+ owner: "export-google",
90883
+ level: "addon-state",
90884
+ seq: 1,
90885
+ dependsOn: [],
90886
+ store: "settings",
90887
+ scope: "cluster",
90888
+ onFailure: "tolerate",
90889
+ bodyKind: "plan",
90890
+ description: "Delete the retired publicHubUrl and detectedPublicHubUrl settings; the public URL is the publicEndpoint role",
90891
+ fixtureMark: "the exposed device list the migration does not know"
90892
+ },
90893
+ plan: planDropPublicHubUrl
90894
+ }];
90895
+ //#endregion
90896
+ //#region src/public-endpoint.ts
90897
+ /** The typed refusal when the role resolves to nothing. */
90898
+ var NO_PUBLIC_ENDPOINT_REASON = {
90899
+ code: "no-public-endpoint",
90900
+ message: "The hub has no public endpoint. Set up remote access (a tunnel) and flag an address as \"Public endpoint\" on the Network page; Google calls this hub from its own cloud."
90667
90901
  };
90668
- /**
90669
- * Apply the default-not-override policy.
90670
- *
90671
- * The operator's value is never in the returned patch. Detection's own answer
90672
- * always is, because the settings panel needs it to say "you set this one, and
90673
- * a different one is detected".
90674
- */
90675
- var resolvePublicHubUrl = (current, detected) => {
90676
- const detectedPublicHubUrl = detected[0] ?? "";
90677
- if (current.length > 0) return {
90678
- patch: { detectedPublicHubUrl },
90679
- publicHubUrl: current,
90680
- detectedPublicHubUrl,
90681
- defaulted: false
90682
- };
90683
- if (detectedPublicHubUrl.length === 0) return {
90684
- patch: { detectedPublicHubUrl },
90685
- publicHubUrl: "",
90686
- detectedPublicHubUrl,
90687
- defaulted: false
90902
+ /** Trailing slashes off, surrounding space off. Nothing else is rewritten. */
90903
+ var normaliseOrigin = (raw) => raw.trim().replace(/\/+$/, "");
90904
+ var resolvePublicEndpoint = (book) => {
90905
+ const resolved = book.roles.publicEndpoint.resolved;
90906
+ const origin = resolved === null ? "" : normaliseOrigin(resolved);
90907
+ if (origin.length === 0) return {
90908
+ ok: false,
90909
+ reason: NO_PUBLIC_ENDPOINT_REASON
90688
90910
  };
90689
90911
  return {
90690
- patch: {
90691
- publicHubUrl: detectedPublicHubUrl,
90692
- detectedPublicHubUrl
90693
- },
90694
- publicHubUrl: detectedPublicHubUrl,
90695
- detectedPublicHubUrl,
90696
- defaulted: true
90912
+ ok: true,
90913
+ origin
90697
90914
  };
90698
90915
  };
90699
- /** Which of the two authored the value currently in the field. */
90700
- var publicHubUrlSource = (state) => {
90701
- if (state.publicHubUrl.length === 0) return "unset";
90702
- if (state.detectedPublicHubUrl.length > 0 && state.publicHubUrl === state.detectedPublicHubUrl) return "derived";
90703
- return "operator-set";
90704
- };
90705
- /**
90706
- * The line under the field. A URL that appeared by itself with no provenance is
90707
- * worse than a blank field: the operator cannot tell whether it is right.
90708
- */
90709
- var buildPublicHubUrlNotice = (state) => {
90710
- switch (publicHubUrlSource(state)) {
90711
- case "derived": return {
90712
- variant: "info",
90713
- content: `Derived from remote access — ${state.publicHubUrl} is the first HTTPS address the network-access capability reports. Edit the field to override it; nothing here ever overwrites a value you set.`
90714
- };
90715
- case "operator-set": return {
90716
- variant: "info",
90717
- content: state.detectedPublicHubUrl.length > 0 ? `Set by you — ${state.publicHubUrl}. The address currently detected from remote access is ${state.detectedPublicHubUrl}; paste it in yourself if you want to switch, detection will not do it for you.` : `Set by you — ${state.publicHubUrl}. No external HTTPS address is detected right now, so nothing is corroborating it.`
90718
- };
90719
- case "unset": return state.detectedPublicHubUrl.length > 0 ? {
90720
- variant: "info",
90721
- content: `Detected external address: ${state.detectedPublicHubUrl}. Press "Detect external address" to fill the field with it.`
90722
- } : {
90723
- variant: "warning",
90724
- content: "No public HTTPS address detected — no network-access provider on this hub reports a connected HTTPS endpoint, so there is nothing to derive from. Set up remote access (Cloudflare Tunnel, Tailscale Funnel, …) and press \"Detect external address\", or type the URL yourself. An address on your own network will not do: Google calls this URL from its own cloud."
90725
- };
90726
- }
90727
- };
90728
90916
  /**
90729
90917
  * The `device-export` setup block: the three console URLs plus the
90730
- * linked-account count. All three come off the SAME origin, so they can never
90731
- * disagree with each other.
90918
+ * linked-account count, all off the SAME origin so they cannot disagree.
90919
+ * A read that fails is the same refusal as a role that resolves to nothing.
90732
90920
  */
90733
- var buildConsoleSetup = (input) => {
90734
- const origin = normalisePublicHubUrl(input.publicHubUrl);
90921
+ var buildConsoleSetupFromRole = async (input) => {
90735
90922
  const linked = String(input.linkedAccounts);
90736
- if (origin.length === 0) return {
90737
- note: ["Set the public hub URL on the settings form first — every URL Google needs is derived from it.", buildPublicHubUrlNotice(input).content].join("\n"),
90923
+ const result = await input.read().then(resolvePublicEndpoint).catch(() => ({
90924
+ ok: false,
90925
+ reason: NO_PUBLIC_ENDPOINT_REASON
90926
+ }));
90927
+ if (!result.ok) return {
90928
+ note: `Refused (${result.reason.code}): ${result.reason.message}`,
90738
90929
  fields: [{
90739
90930
  label: "Linked Google accounts",
90740
90931
  value: linked
90741
90932
  }]
90742
90933
  };
90934
+ const origin = result.origin;
90743
90935
  return {
90744
90936
  note: [
90745
90937
  "In the Google Home Developer Console create a cloud-to-cloud integration, then paste these three URLs.",
90746
90938
  "The integration stays in test mode: publishing requires Google certification, which a private hub cannot obtain.",
90747
90939
  "This hub pushes nothing to Google — state is read by polling, so a change made outside the Home app appears on the next query, not instantly.",
90748
- buildPublicHubUrlNotice(input).content
90940
+ `The URLs follow the "Public endpoint" role on the Network page (${origin}).`
90749
90941
  ].join("\n"),
90750
90942
  fields: [
90751
90943
  {
@@ -90767,37 +90959,9 @@ var buildConsoleSetup = (input) => {
90767
90959
  ]
90768
90960
  };
90769
90961
  };
90770
- /**
90771
- * Detect, apply the policy, persist, and say out loud what happened.
90772
- *
90773
- * Every branch here logs: a fill names the URL it picked and the source it came
90774
- * from, and a miss that leaves the field empty says so rather than passing for
90775
- * "never ran".
90776
- */
90777
- var refreshPublicHubUrl = async (deps) => {
90778
- const detected = await deps.detect();
90779
- const resolution = resolvePublicHubUrl(deps.current().publicHubUrl, detected);
90780
- await deps.persist(resolution.patch);
90781
- if (resolution.defaulted) deps.logger.info("export-google: defaulted public hub URL to the detected external address", { meta: {
90782
- publicHubUrl: resolution.publicHubUrl,
90783
- source: "network-access"
90784
- } });
90785
- else if (resolution.publicHubUrl.length === 0) deps.logger.warn("export-google: public hub URL still unset after detection — the Google console URLs cannot be rendered until one is available", { meta: { detectedCount: detected.length } });
90786
- return resolution;
90787
- };
90788
- /** What "Detect external address" did, in one sentence for the button. */
90789
- function describeDetectResult(result) {
90790
- const { publicHubUrl, detectedPublicHubUrl, filled } = result;
90791
- if (filled) return `Filled in ${publicHubUrl}.`;
90792
- if (detectedPublicHubUrl.length === 0) return publicHubUrl.length > 0 ? `No public HTTPS address detected; your value ${publicHubUrl} was kept.` : "No public HTTPS address detected. Set up remote access first.";
90793
- if (detectedPublicHubUrl === publicHubUrl) return `Detected ${publicHubUrl}, already in use.`;
90794
- return `Detected ${detectedPublicHubUrl}; your value ${publicHubUrl} was kept.`;
90795
- }
90796
90962
  //#endregion
90797
90963
  //#region src/types.ts
90798
90964
  var DEFAULT_SETTINGS = {
90799
- publicHubUrl: "",
90800
- detectedPublicHubUrl: "",
90801
90965
  exposed: [],
90802
90966
  exposedActions: [],
90803
90967
  linkedAccounts: []
@@ -90852,9 +91016,7 @@ var ExportGoogleAddon = class extends BaseAddon {
90852
91016
  logger: this.ctx.logger
90853
91017
  });
90854
91018
  this.gateway = gateway;
90855
- this.detectPublicHubUrl().catch((err) => {
90856
- this.ctx.logger.warn("export-google: public hub URL auto-detect failed", { meta: { error: errMsg$1(err) } });
90857
- });
91019
+ await this.runMigrations(defineAddonMigrations(ADDON_MIGRATIONS, { readStored: async () => this.resolveGlobalStore() }));
90858
91020
  const actionScenes = new ActionSceneExports({
90859
91021
  api: this.ctx.api,
90860
91022
  logger: this.ctx.logger,
@@ -90870,7 +91032,7 @@ var ExportGoogleAddon = class extends BaseAddon {
90870
91032
  getStatus: async () => ({
90871
91033
  linkState: this.config.linkedAccounts.length > 0 ? "linked" : "unlinked",
90872
91034
  exposedDeviceCount: this.config.exposed.length,
90873
- setup: this.buildSetupBlock()
91035
+ setup: await this.buildSetupBlock()
90874
91036
  }),
90875
91037
  listSupportedDeviceKinds: async () => [...SUPPORTED_DEVICE_KINDS],
90876
91038
  listExposedDevices: async () => this.config.exposed.map((entry) => ({ deviceId: String(entry.deviceId) })),
@@ -90926,97 +91088,25 @@ var ExportGoogleAddon = class extends BaseAddon {
90926
91088
  }
90927
91089
  }));
90928
91090
  const oauthIntegrationProvider = { getDescriptor: async () => buildGoogleOauthIntegration() };
90929
- const offTunnelStarted = this.ctx.eventBus.subscribe({ category: EventCategory.NetworkTunnelStarted }, () => {
90930
- this.detectPublicHubUrl().catch((err) => {
90931
- this.ctx.logger.warn("export-google: public hub URL detect after tunnel connect failed", { meta: { error: errMsg$1(err) } });
90932
- });
90933
- });
90934
- this.ctx.addDisposer(async () => offTunnelStarted());
90935
91091
  this.ctx.logger.info("export-google: initialized", { meta: {
90936
91092
  exposedCount: this.config.exposed.length,
90937
91093
  linkedAccounts: this.config.linkedAccounts.length,
90938
- publicHubUrlSet: this.config.publicHubUrl.length > 0,
90939
91094
  willReportState: false
90940
91095
  } });
90941
- return {
90942
- providers: [
90943
- {
90944
- capability: deviceExportCapability,
90945
- provider: deviceExportProvider
90946
- },
90947
- {
90948
- capability: addonRoutesCapability,
90949
- provider: routeProvider
90950
- },
90951
- {
90952
- capability: oauthIntegrationCapability,
90953
- provider: oauthIntegrationProvider
90954
- }
90955
- ],
90956
- customActions: exportGoogleActions,
90957
- actionHandlers: { detectPublicHubUrl: async () => this.detectPublicHubUrl() }
90958
- };
90959
- }
90960
- /** This addon's slice of `PublicHubUrlState`. */
90961
- publicHubUrlState() {
90962
- return {
90963
- publicHubUrl: this.config.publicHubUrl,
90964
- detectedPublicHubUrl: this.config.detectedPublicHubUrl
90965
- };
90966
- }
90967
- /**
90968
- * Adapter from the codegen'd `network-access` router onto the narrow reader
90969
- * `public-hub-url.ts` consumes. Fields are copied one by one rather than
90970
- * passed through, so the module never depends on the cap's wider shape and a
90971
- * test double for it needs no cast.
90972
- */
90973
- networkAccessReader() {
90974
- return {
90975
- listEndpoints: async () => {
90976
- return (await this.ctx.api.networkAccess.listEndpoints.query({})).map((entry) => ({
90977
- url: entry.url,
90978
- protocol: entry.protocol
90979
- }));
91096
+ return [
91097
+ {
91098
+ capability: deviceExportCapability,
91099
+ provider: deviceExportProvider
90980
91100
  },
90981
- getStatus: async () => {
90982
- const status = await this.ctx.api.networkAccess.getStatus.query({});
90983
- return {
90984
- connected: status.connected,
90985
- endpoint: status.endpoint === null ? null : {
90986
- url: status.endpoint.url,
90987
- protocol: status.endpoint.protocol
90988
- }
90989
- };
91101
+ {
91102
+ capability: addonRoutesCapability,
91103
+ provider: routeProvider
91104
+ },
91105
+ {
91106
+ capability: oauthIntegrationCapability,
91107
+ provider: oauthIntegrationProvider
90990
91108
  }
90991
- };
90992
- }
90993
- /**
90994
- * Refresh the detected address and DEFAULT the field to it when it is empty.
90995
- * Backs both the boot-time detect and the "Detect external address" button.
90996
- *
90997
- * Never replaces a value the operator set — that value is what they already
90998
- * pasted into the Google console, and rewriting it here would leave the two
90999
- * sides disagreeing with nothing on screen to say so.
91000
- */
91001
- async detectPublicHubUrl() {
91002
- const resolution = await refreshPublicHubUrl({
91003
- current: () => this.publicHubUrlState(),
91004
- detect: () => detectPublicHubOrigins({
91005
- network: this.networkAccessReader(),
91006
- logger: this.ctx.logger
91007
- }),
91008
- persist: (patch) => this.updateGlobalSettings(patch),
91009
- logger: this.ctx.logger
91010
- });
91011
- const result = {
91012
- publicHubUrl: resolution.publicHubUrl,
91013
- detectedPublicHubUrl: resolution.detectedPublicHubUrl,
91014
- filled: resolution.defaulted
91015
- };
91016
- return {
91017
- ...result,
91018
- summary: describeDetectResult(result)
91019
- };
91109
+ ];
91020
91110
  }
91021
91111
  async onShutdown() {
91022
91112
  this.gateway = null;
@@ -91085,11 +91175,11 @@ var ExportGoogleAddon = class extends BaseAddon {
91085
91175
  * value still travels in the `getStatus` response — so it would be the wrong
91086
91176
  * tool for a real credential anyway (docs/decisions/adr-0269-a-google-export-that-holds-no-google-credential.md).
91087
91177
  */
91088
- buildSetupBlock() {
91089
- return buildConsoleSetup({
91178
+ async buildSetupBlock() {
91179
+ return buildConsoleSetupFromRole({
91090
91180
  addonId: ADDON_ID,
91091
- ...this.publicHubUrlState(),
91092
- linkedAccounts: this.config.linkedAccounts.length
91181
+ linkedAccounts: this.config.linkedAccounts.length,
91182
+ read: () => this.ctx.api.localNetwork.getAddresses.query()
91093
91183
  });
91094
91184
  }
91095
91185
  globalSettingsSchema() {
@@ -91098,44 +91188,17 @@ var ExportGoogleAddon = class extends BaseAddon {
91098
91188
  title: "Connection",
91099
91189
  description: "Publishes switches, dimmable lights, locks and covers to Google Home. The hub answers Google directly — no cloud function, and no Google credential is stored here.",
91100
91190
  columns: 1,
91101
- fields: [
91102
- {
91103
- type: "info",
91104
- key: "__google-setup-banner",
91105
- label: "Setup overview",
91106
- variant: "info",
91107
- content: [
91108
- "This hub must be reachable from the public internet over HTTPS (Cloudflare Tunnel, Tailscale Funnel, …) — Google calls the fulfillment URL from its own cloud.",
91109
- "Create a cloud-to-cloud integration in the Google Home Developer Console, paste the three URLs from the Export panel, and link your account from the Home app.",
91110
- "Cameras are not exported, and state is not pushed: Google polls. Ask \"Hey Google, sync my devices\" after exposing something new."
91111
- ].join("\n")
91112
- },
91113
- this.field({
91114
- type: "text",
91115
- key: "publicHubUrl",
91116
- label: "Public hub URL",
91117
- description: "HTTPS origin Google reaches this hub on, e.g. https://hub.example.com. Used to render the URLs you paste into the Google console. Left empty, it defaults to the first external address remote access reports; once it holds a value, nothing overwrites it.",
91118
- placeholder: "https://hub.example.com",
91119
- default: DEFAULT_SETTINGS.publicHubUrl
91120
- }),
91121
- {
91122
- type: "info",
91123
- key: "__public-hub-url-source",
91124
- label: "Where this came from",
91125
- ...buildPublicHubUrlNotice(this.publicHubUrlState())
91126
- },
91127
- {
91128
- type: "addon-action-button",
91129
- addonId: ADDON_ID,
91130
- key: "__detect-public-hub-url",
91131
- label: "External address",
91132
- description: "Re-scan the connected remote-access providers. Fills the field above when it is empty; a value you set is left exactly as it is.",
91133
- buttonLabel: "Detect external address",
91134
- action: "detectPublicHubUrl",
91135
- variant: "default",
91136
- successMessage: "{summary}"
91137
- }
91138
- ]
91191
+ fields: [{
91192
+ type: "info",
91193
+ key: "__google-setup-banner",
91194
+ label: "Setup overview",
91195
+ variant: "info",
91196
+ content: [
91197
+ "This hub must be reachable from the public internet over HTTPS (Cloudflare Tunnel, Tailscale Funnel, …) — Google calls the fulfillment URL from its own cloud.",
91198
+ "Create a cloud-to-cloud integration in the Google Home Developer Console, paste the three URLs from the Export panel, and link your account from the Home app.",
91199
+ "Cameras are not exported, and state is not pushed: Google polls. Ask \"Hey Google, sync my devices\" after exposing something new."
91200
+ ].join("\n")
91201
+ }]
91139
91202
  }] });
91140
91203
  }
91141
91204
  /**