@camstack/addon-agent-ui 1.2.329 → 1.2.331

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/addon.js CHANGED
@@ -5849,7 +5849,7 @@ var ZodIssueCode = {
5849
5849
  var ZodFirstPartyTypeKind;
5850
5850
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5851
5851
  //#endregion
5852
- //#region ../types/dist/sleep-DEZaLbiu.mjs
5852
+ //#region ../types/dist/sleep-BX_MqzUe.mjs
5853
5853
  /**
5854
5854
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5855
5855
  * window to float samples (D455).
@@ -6381,6 +6381,53 @@ function emitReadiness(bus, params) {
6381
6381
  ts
6382
6382
  }));
6383
6383
  }
6384
+ /** Why a catalogue entry is not a runnable body of its declared kind. */
6385
+ var AddonMigrationDefinitionError = class extends Error {
6386
+ id;
6387
+ constructor(id, message) {
6388
+ super(`${id}: ${message}`);
6389
+ this.id = id;
6390
+ this.name = "AddonMigrationDefinitionError";
6391
+ }
6392
+ };
6393
+ /**
6394
+ * Bind a catalogue to the addon's ports. Throws {@link AddonMigrationDefinitionError} when
6395
+ * an entry's `bodyKind` does not match the body it carries, or is `sql` (a hub-only
6396
+ * body). A throwing body never escapes `execute`: it is reported as a failed result.
6397
+ */
6398
+ function defineAddonMigrations(catalogue, ports) {
6399
+ return catalogue.map((entry) => {
6400
+ const { meta } = entry;
6401
+ if ("plan" in entry) {
6402
+ if (meta.bodyKind !== "plan") throw new AddonMigrationDefinitionError(meta.id, `carries a plan body but declares "${meta.bodyKind}"`);
6403
+ return {
6404
+ meta,
6405
+ execute: () => guarded(async () => ({
6406
+ kind: "plan",
6407
+ plan: await entry.plan(ports)
6408
+ }))
6409
+ };
6410
+ }
6411
+ if (meta.bodyKind !== "procedure") throw new AddonMigrationDefinitionError(meta.id, `carries a procedure body but declares "${meta.bodyKind}"`);
6412
+ return {
6413
+ meta,
6414
+ execute: () => guarded(async () => ({
6415
+ kind: "procedure",
6416
+ result: await entry.procedure(ports)
6417
+ }))
6418
+ };
6419
+ });
6420
+ }
6421
+ async function guarded(work) {
6422
+ try {
6423
+ return await work();
6424
+ } catch (err) {
6425
+ return {
6426
+ kind: "failed",
6427
+ error: errMsg(err)
6428
+ };
6429
+ }
6430
+ }
6384
6431
  var NOT_RUN = {
6385
6432
  declared: false,
6386
6433
  snapshot: null,
@@ -7382,6 +7429,28 @@ var SECRET_RETRY_MAX_MS = 5 * 6e4;
7382
7429
  /** Coalesces a burst of `keychain.changed` events into one re-resolve. */
7383
7430
  var SECRET_CHANGE_DEBOUNCE_MS = 250;
7384
7431
  /**
7432
+ * Pair a catalogue with the function that builds its ports FROM THE MIGRATION API. The one
7433
+ * place a catalogue is bound: a migration reaches nothing a ports binder cannot reach
7434
+ * through `api` (guard `check-migration-ports-surface`).
7435
+ */
7436
+ function migrationSet(catalogue, bindPorts) {
7437
+ return { bind: (api) => defineAddonMigrations(catalogue, bindPorts(api)) };
7438
+ }
7439
+ /** A mixed array is a mistake: the other kind would be dropped without a word. */
7440
+ function refuseMixed(form, kept, dropped) {
7441
+ if (dropped > 0) throw new Error(`runMigrations(${form}): ${dropped} of ${kept + dropped} entries are of the other kind and would be dropped; pass one kind per call`);
7442
+ }
7443
+ function catalogueOf(list) {
7444
+ const kept = list.filter((entry) => !("execute" in entry));
7445
+ refuseMixed("catalogue, (api) => ports", kept.length, list.length - kept.length);
7446
+ return kept;
7447
+ }
7448
+ function boundOf(list) {
7449
+ const kept = list.filter((entry) => "execute" in entry);
7450
+ refuseMixed("bound migrations", kept.length, list.length - kept.length);
7451
+ return kept;
7452
+ }
7453
+ /**
7385
7454
  * Base class for CamStack addons. Eliminates settings boilerplate:
7386
7455
  *
7387
7456
  * - Typed `config` property with automatic resolution from store + defaults
@@ -7548,23 +7617,21 @@ var BaseAddon = class {
7548
7617
  await this.loadScopedSchemas();
7549
7618
  return normalized;
7550
7619
  }
7620
+ async runMigrations(first, second, third) {
7621
+ if (typeof second === "function") return this.runMigrationSets([migrationSet(catalogueOf(first), second)], third);
7622
+ return this.runBound(boundOf(first), second);
7623
+ }
7551
7624
  /**
7552
- * Run this addon's migration catalogue (D987 M3) through the hub's `migrations`
7553
- * engine. Call it at the point of the boot where the data must already have the new
7554
- * shape — `onInitialize`, or `onRestoreDevices` for a migration that needs the
7555
- * restored devices — with the catalogue bound to the addon's ports
7556
- * (`defineAddonMigrations(ADDON_MIGRATIONS, ports)`).
7557
- *
7558
- * An engine that cannot be reached or refuses the catalogue is logged and runs
7559
- * nothing; the boot continues. A migration that FAILED (or was blocked by one)
7560
- * and declares `onFailure: 'block-owner'` makes this throw, so the addon does not
7561
- * serve data whose shape it cannot trust; `tolerate` migrations never do.
7562
- *
7563
- * ALWAYS pass the whole catalogue; a phase that must run only some of it passes
7564
- * `{ only: [ids] }` — never a filtered catalogue (the engine would judge the
7565
- * omitted applied ids "newer").
7625
+ * Several catalogues of ONE owner in one declaration (the engine replaces an owner's
7626
+ * catalogue on every declare, so two calls would each judge the other's ids "newer").
7627
+ * Build each entry with `migrationSet(catalogue, (api) => ports)`.
7566
7628
  */
7567
- async runMigrations(migrations, options) {
7629
+ async runMigrationSets(sets, options) {
7630
+ const api = this.ctx.migrationApi;
7631
+ if (api === void 0) throw new Error(`${this.ctx.id}: the migration API is not available on this context`);
7632
+ return this.runBound(sets.flatMap((set) => set.bind(api)), options);
7633
+ }
7634
+ async runBound(migrations, options) {
7568
7635
  const api = this.ctx.api.migrations;
7569
7636
  const report = await runAddonMigrations({
7570
7637
  declareOwner: (input) => api.declareOwner.mutate(input),
@@ -8748,6 +8815,20 @@ var RecordKindDeclarationSchema = object({
8748
8815
  }).strict();
8749
8816
  /** The kind names: lower-case, dash separated, short enough for an index name. */
8750
8817
  var RecordKindNameSchema = string().regex(/^[a-z][a-z0-9-]{0,47}$/);
8818
+ /**
8819
+ * Entry kinds (D881): every list of user-created entries (notification
8820
+ * targets, brokers, LLM profiles) is ONE record kind with an id, a name and a
8821
+ * kind-specific body, and the admin UI lists/adds/edits/deletes all of them
8822
+ * through the `record-entries` capability with password fields derived from
8823
+ * the schema (`.meta({ secret: true })`).
8824
+ */
8825
+ /** The body of a plain entry: a name and the fields the kind adds. */
8826
+ function entryBody(shape) {
8827
+ return object({
8828
+ name: string().min(1),
8829
+ ...shape
8830
+ });
8831
+ }
8751
8832
  object({
8752
8833
  field: string().min(1),
8753
8834
  on: literal("advance")
@@ -12766,6 +12847,10 @@ var IntegrationInstanceRefSchema = object({
12766
12847
  ]),
12767
12848
  candidateStableId: string().optional()
12768
12849
  });
12850
+ object({
12851
+ cap: string().min(1),
12852
+ kind: string().min(1).optional()
12853
+ });
12769
12854
  var EncodeProfileSchema = object({
12770
12855
  video: object({
12771
12856
  codec: _enum([
@@ -14928,6 +15013,39 @@ var UnstampedEventMediaCountSchema = object({
14928
15013
  /** Sum across both, or `null` when either lane could not be counted. */
14929
15014
  total: number().int().nonnegative().nullable()
14930
15015
  }).nullable();
15016
+ /**
15017
+ * Where the stored event media sits, per storage location: how many media rows
15018
+ * and how many bytes carry each location id, how many carry none (legacy,
15019
+ * resolved to the default `eventMedia` location), and how many name a location
15020
+ * that was not asked about (a deleted or never-listed one).
15021
+ *
15022
+ * One covering-index aggregate per asked location plus the NULL one, and one
15023
+ * unfiltered total that scans the covering index: O(rows), not a walk of the
15024
+ * rows themselves. `unlisted` is total minus the ASKED locations minus NULL, so
15025
+ * it is a deleted location only when every location id was asked.
15026
+ * `null` is "could not be measured", never zero.
15027
+ */
15028
+ var MediaLocationCensusInputSchema = object({ locationIds: array(string().min(1)).max(50).readonly() });
15029
+ var MediaLocationCensusSchema = object({
15030
+ locations: array(object({
15031
+ locationId: string(),
15032
+ rows: number().int().nonnegative(),
15033
+ bytes: number().nonnegative()
15034
+ })).readonly(),
15035
+ unstamped: object({
15036
+ rows: number().int().nonnegative(),
15037
+ bytes: number().nonnegative()
15038
+ }),
15039
+ /** Rows stamped with a location id that was not in the asked list. */
15040
+ unlisted: object({
15041
+ rows: number().int().nonnegative(),
15042
+ bytes: number().nonnegative()
15043
+ }),
15044
+ total: object({
15045
+ rows: number().int().nonnegative(),
15046
+ bytes: number().nonnegative()
15047
+ })
15048
+ });
14931
15049
  var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
14932
15050
  /** The independently selectable logical storage classes — every class
14933
15051
  * `storage.listLocationDeclarations` reports, so an operator never meets a
@@ -45448,52 +45566,7 @@ DeviceType.Light, method(object({
45448
45566
  level: number().min(0).max(100),
45449
45567
  lastChangedAt: number()
45450
45568
  });
45451
- /**
45452
- * `broker` — unified pub/sub broker registry, system-scoped collection.
45453
- *
45454
- * The cap models any kind-tagged message broker the user wants to
45455
- * register and that other addons might consume. The first two kinds
45456
- * are MQTT (mosquitto / aedes embedded / cloud bridge) and
45457
- * Home Assistant (HA WebSocket — subscribe_entities + call_service).
45458
- * Future kinds (Zigbee2MQTT bridge, ZHA, KNX, Telegram, …) plug in
45459
- * the same surface.
45460
- *
45461
- * Why one cap, not one cap per kind:
45462
- * - The integrations page wants a single table of "every broker"
45463
- * across kinds; a unified cap drives it without join logic.
45464
- * - Generic admin operations (add / remove / test / status) are
45465
- * identical across kinds — duplicating them per cap was busywork.
45466
- * - The `network-access` cap precedent: same interface, many
45467
- * `providerKind: 'ingress'` implementations (Tailscale, ngrok, …).
45468
- *
45469
- * What stays kind-specific:
45470
- * - `getBrokerConfig` payload (kind decides whether it returns
45471
- * mqtt URL+creds, HA baseUrl+token, …) — typed as
45472
- * `Record<string, unknown>` at the wire; consumers narrow.
45473
- * - `publish` / `subscribe` / `getState` arguments (target / filter /
45474
- * key) — also typed as `Record<string, unknown>` so each kind can
45475
- * evolve its surface (MQTT topic+qos vs HA entity_id+domain)
45476
- * without rebreaking the cap signature.
45477
- * - `add` `settings` payload (different fields per kind, validated by
45478
- * the kind-specific provider).
45479
- *
45480
- * Bidirectionality:
45481
- * - `publish` is RPC — synchronous result (provider-defined).
45482
- * - `subscribe` returns a subscription handle; the actual message
45483
- * stream flows over the typed event-bus as `broker.message` events
45484
- * keyed by `(brokerId, subscriptionId)`. Consumers filter in their
45485
- * event handler. Subscriptions persist across reconnects — the
45486
- * provider re-subscribes upstream after a transport drop.
45487
- *
45488
- * Why event-bus push (not a subscription RPC stream):
45489
- * - Matches the rest of CamStack's D8 contract — events for telemetry,
45490
- * RPC for loss-is-a-bug. Broker messages are telemetry (a single
45491
- * drop is recoverable via `getState({key})`).
45492
- * - Frees `broker.subscribe` from holding a long-lived RPC channel.
45493
- * - Cross-process: events already route through `$event-bus`; no
45494
- * per-broker wire-shaping needed.
45495
- */
45496
- var BrokerStatusEnum = _enum([
45569
+ _enum([
45497
45570
  "connected",
45498
45571
  "disconnected",
45499
45572
  "connecting",
@@ -45501,141 +45574,12 @@ var BrokerStatusEnum = _enum([
45501
45574
  "unreachable",
45502
45575
  "error"
45503
45576
  ]);
45504
- var BrokerInfoSchema = object({
45505
- /** Stable broker id. Persisted; survives addon restarts. */
45506
- id: string(),
45507
- /** Addon id of the provider that OWNS this broker.
45508
- *
45509
- * The `broker` cap is a system-scoped collection: several addons
45510
- * register a `broker` provider, each owning a DISJOINT set of
45511
- * brokers (mqtt-broker owns `mqtt_*`, provider-homeassistant owns
45512
- * `ha_*`). A broker therefore belongs to exactly one addon — like a
45513
- * device belongs to one integration. The admin UI threads this id
45514
- * back as the `{ addonId }` system-collection selector on every
45515
- * id-keyed call (`get` / `getSettings` / `setSettings` / `remove` /
45516
- * `testConnection`), so the call routes to the OWNING provider
45517
- * instead of defaulting to the first-registered one. */
45518
- addonId: string(),
45519
- /** Human-readable name (operator-chosen at add-time). */
45520
- name: string(),
45521
- /** Provider-defined kind tag — `mqtt` / `home-assistant` / future. */
45522
- kind: string(),
45523
- status: BrokerStatusEnum,
45524
- /** Free-form provider-specific info (HA version, MQTT broker
45525
- * flavour, latency, mTLS active, …). */
45526
- info: record(string(), unknown()),
45527
- /** Ms epoch of the last connection probe / status update. */
45528
- lastCheckedAt: number().nullable(),
45529
- /** Last error message, when `status` indicates failure. */
45530
- error: string().nullable()
45531
- });
45532
45577
  var RegistryStatusSchema = object({
45533
45578
  brokerCount: number().int().nonnegative(),
45534
45579
  connectedCount: number().int().nonnegative()
45535
45580
  });
45536
- /**
45537
- * One entry per `broker` provider — which addon provides which broker
45538
- * kind(s). The unified create picker reads this to know, for each
45539
- * (addonId, kind) pair the operator can pick, where to route the
45540
- * follow-up `getSettingsSchema` / `testSettings` / `add` calls (via the
45541
- * `{ addonId }` selector). A provider only advertises a kind here when
45542
- * it implements `getSettingsSchema` for that kind (so the picker never
45543
- * offers a kind whose creation form can't be rendered).
45544
- */
45545
- var BrokerProviderInfoSchema = object({
45546
- /** Addon id of the `broker` provider this entry describes. */
45547
- addonId: string(),
45548
- /** Broker kinds this provider can create, with a display label. */
45549
- kinds: array(object({
45550
- kind: string(),
45551
- label: string(),
45552
- /**
45553
- * Relative hub path to start an interactive account link (OAuth popup).
45554
- * May include `{{brokerId}}`; admin-ui substitutes and appends `?popup=1`.
45555
- */
45556
- interactiveConnectPath: string().min(1).optional(),
45557
- /** Relative hub path to disconnect the linked account (same popup pattern). */
45558
- interactiveDisconnectPath: string().min(1).optional(),
45559
- /**
45560
- * The kind signs in through a server-held interactive session instead of
45561
- * (or before) typed credentials. `basePath` is a hub-relative route set
45562
- * served by the owning addon (`/addon/<id>/...`) speaking the sign-in
45563
- * contract: `POST {basePath}/start` (body: the form's settings) answers
45564
- * `{ sessionId, loginUrl }`; `GET {basePath}/status?sessionId=` answers
45565
- * `{ phase: 'starting' | 'awaiting-login' | 'captured' | 'error' |
45566
- * 'cancelled', loginUrl, error }`; `POST {basePath}/commit`
45567
- * (`{ sessionId, name, brokerId? }`) stores the credentials on a new or
45568
- * existing broker and answers `{ brokerId }`; `POST {basePath}/cancel`
45569
- * (`{ sessionId }`) drops the session. The dialog that edits a broker
45570
- * offers it as the default path; the fields the session fills are
45571
- * marked `filledBySignIn` in the kind's settings schema.
45572
- *
45573
- * `methods` lists the ways the session can sign in, recommended first:
45574
- * `'device-code'` adds `POST {basePath}/code/start` (body: the form's
45575
- * settings) answering `{ sessionId, userCode, verificationUrl,
45576
- * expiresAt }` — the operator types `userCode` at `verificationUrl` on
45577
- * any device, and the same `status` / `commit` / `cancel` routes follow
45578
- * (status then carries `method`, `userCode`, `verificationUrl`,
45579
- * `expiresAt` and the phases `'awaiting-code'` / `'expired'`);
45580
- * `'proxy'` is the `{basePath}/start` flow above. Absent means
45581
- * `['proxy']`.
45582
- */
45583
- signIn: object({
45584
- basePath: string().min(1),
45585
- methods: array(_enum(["device-code", "proxy"])).optional()
45586
- }).optional()
45587
- }))
45588
- });
45589
- var ListInputSchema = object({
45590
- /** Optional kind filter — `list({kind:'home-assistant'})` returns
45591
- * only HA brokers. Omit to list every broker. */
45592
- kind: string().optional() });
45593
45581
  var GetInputSchema = object({ id: string() });
45594
- var AddInputSchema = object({
45595
- kind: string().min(1),
45596
- name: string().min(1),
45597
- /**
45598
- * ADOPT an existing id instead of minting a new one.
45599
- *
45600
- * Written the day this cost an outage. A broker's id is not a detail: HA
45601
- * devices carry it inside their `stableId` (`ha:ha_004:dev:…`), so a broker
45602
- * lost from config and re-added as `ha_001` leaves every one of its devices
45603
- * bound to a broker that no longer exists. Re-entering the password under the
45604
- * ORIGINAL id turns a multi-step device migration back into re-entering a
45605
- * password.
45606
- *
45607
- * A provider MUST refuse an id that is already in use — adopting a live
45608
- * broker's id would silently take it over.
45609
- */
45610
- id: string().min(1).optional(),
45611
- /** Kind-specific settings (e.g. MQTT `{url,username,password}` or HA
45612
- * `{baseUrl,accessToken}`). Validated by the kind-specific provider
45613
- * branch on receipt — invalid shape rejects the add. */
45614
- settings: record(string(), unknown())
45615
- });
45616
- var AddResultSchema = object({ id: string() });
45617
- var RemoveInputSchema = object({ id: string() });
45618
- var TestConnectionResultSchema = discriminatedUnion("ok", [object({
45619
- ok: literal(true),
45620
- latencyMs: number().nonnegative()
45621
- }), object({
45622
- ok: literal(false),
45623
- error: string()
45624
- })]);
45625
45582
  var SettingsRecordSchema$1 = record(string(), unknown());
45626
- var SettingsSchemaInputSchema = object({ kind: string() });
45627
- var TestSettingsInputSchema = object({
45628
- kind: string(),
45629
- settings: SettingsRecordSchema$1
45630
- });
45631
- var TestSettingsResultSchema = discriminatedUnion("ok", [object({
45632
- ok: literal(true),
45633
- latencyMs: number().nonnegative().optional()
45634
- }).strict(), object({
45635
- ok: literal(false),
45636
- error: string()
45637
- })]);
45638
- var SettingsSchemaResultSchema = unknown().nullable();
45639
45583
  var PublishInputSchema = object({
45640
45584
  brokerId: string(),
45641
45585
  /** Kind-specific routing target.
@@ -45669,25 +45613,7 @@ var GetStateInputSchema = object({
45669
45613
  * HA: entity_id (returns the cached entity state). */
45670
45614
  key: string()
45671
45615
  });
45672
- method(ListInputSchema, array(BrokerInfoSchema)), method(GetInputSchema, BrokerInfoSchema.nullable()), method(_void(), array(BrokerProviderInfoSchema), { auth: "admin" }), method(AddInputSchema, AddResultSchema, {
45673
- kind: "mutation",
45674
- auth: "admin"
45675
- }), method(RemoveInputSchema, _void(), {
45676
- kind: "mutation",
45677
- auth: "admin"
45678
- }), method(GetInputSchema, TestConnectionResultSchema, {
45679
- kind: "mutation",
45680
- auth: "admin"
45681
- }), method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(object({
45682
- id: string(),
45683
- settings: SettingsRecordSchema$1
45684
- }), _void(), {
45685
- kind: "mutation",
45686
- auth: "admin"
45687
- }), method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(SettingsSchemaInputSchema, SettingsSchemaResultSchema, { auth: "admin" }), method(TestSettingsInputSchema, TestSettingsResultSchema, {
45688
- kind: "mutation",
45689
- auth: "admin"
45690
- }), method(PublishInputSchema, unknown(), {
45616
+ method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(PublishInputSchema, unknown(), {
45691
45617
  kind: "mutation",
45692
45618
  auth: "admin"
45693
45619
  }), method(SubscribeInputSchema, SubscribeResultSchema, {
@@ -49813,14 +49739,20 @@ method(_void(), _void(), { kind: "mutation" }), method(_void(), _void(), { kind:
49813
49739
  }), array(DiscoveryCandidateSchema), {
49814
49740
  kind: "mutation",
49815
49741
  auth: "admin"
49816
- }), method(object({}), CreationSchemaOutputSchema), method(object({}), object({ deviceType: _enum(DeviceType).nullable() })), method(object({
49742
+ }), method(object({}), CreationSchemaOutputSchema), method(object({
49743
+ /** The integration asked about; a provider whose integrations differ answers per one. */
49744
+ integrationId: string().optional() }), object({ deviceType: _enum(DeviceType).nullable() })), method(object({
49817
49745
  candidate: DiscoveryCandidateSchema,
49818
49746
  /** The integration the operator adopts into; a provider with several instances needs it. */
49819
49747
  integrationId: string().optional()
49820
49748
  }), DeviceSummarySchema, {
49821
49749
  kind: "mutation",
49822
49750
  auth: "admin"
49823
- }), method(object({}), boolean()), method(object({ type: _enum(DeviceType) }), CreationSchemaOutputSchema), method(object({
49751
+ }), method(object({}), boolean()), method(object({
49752
+ type: _enum(DeviceType),
49753
+ /** The integration asked about; a provider whose integrations differ answers per one. */
49754
+ integrationId: string().optional()
49755
+ }), CreationSchemaOutputSchema), method(object({
49824
49756
  type: _enum(DeviceType),
49825
49757
  config: record(string(), unknown()),
49826
49758
  /** The integration the operator adds the device to; a provider with several instances needs it. */
@@ -50534,7 +50466,10 @@ method(object({
50534
50466
  auth: "admin"
50535
50467
  }), method(object({
50536
50468
  addonId: string(),
50537
- type: _enum(DeviceType)
50469
+ type: _enum(DeviceType),
50470
+ /** The integration the form is for; a provider whose integrations differ (a hub
50471
+ * integration takes no manual add) answers per integration. Absent = the addon's own. */
50472
+ integrationId: string().optional()
50538
50473
  }), unknown().nullable()), method(object({
50539
50474
  addonId: string(),
50540
50475
  type: _enum(DeviceType),
@@ -50618,7 +50553,11 @@ method(object({
50618
50553
  kind: "mutation",
50619
50554
  auth: "admin",
50620
50555
  timeoutMs: 12e4
50621
- }), method(object({ addonId: string() }), object({ deviceType: _enum(DeviceType).nullable() }), { auth: "admin" }), method(object({ addonId: string() }), unknown(), { auth: "admin" }), method(object({
50556
+ }), method(object({
50557
+ addonId: string(),
50558
+ /** The integration the Add-Device dialog is open on; absent = the addon's own. */
50559
+ integrationId: string().optional()
50560
+ }), object({ deviceType: _enum(DeviceType).nullable() }), { auth: "admin" }), method(object({ addonId: string() }), unknown(), { auth: "admin" }), method(object({
50622
50561
  deviceId: number(),
50623
50562
  key: string(),
50624
50563
  value: unknown()
@@ -53214,7 +53153,7 @@ var TestConnectionStatusEnum = _enum([
53214
53153
  "inconclusive",
53215
53154
  "unsupported"
53216
53155
  ]);
53217
- var TestConnectionResultSchema$1 = object({
53156
+ var TestConnectionResultSchema = object({
53218
53157
  /** True ONLY for `validated`. Never true for a test that did not run. */
53219
53158
  success: boolean(),
53220
53159
  error: string().optional(),
@@ -53259,7 +53198,7 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
53259
53198
  }), method(_void(), array(AvailableIntegrationTypeSchema), { auth: "admin" }), method(object({
53260
53199
  addonId: string(),
53261
53200
  settings: record(string(), unknown())
53262
- }), TestConnectionResultSchema$1, {
53201
+ }), TestConnectionResultSchema, {
53263
53202
  kind: "mutation",
53264
53203
  auth: "admin"
53265
53204
  });
@@ -53286,6 +53225,14 @@ var ConfigSchemaPassthrough$3 = custom();
53286
53225
  var IntegrationInstanceIdSchema = string().min(1);
53287
53226
  var IntegrationInstanceModeSchema = _enum(["single", "multiple"]);
53288
53227
  /**
53228
+ * What the addon's instances ARE for the Integrations page (planning#416). `devices`: each
53229
+ * instance is an integration that brings devices (the registry owns its on/off switch);
53230
+ * `services`: a connection configured from the addon's own function page, never listed on
53231
+ * Integrations.
53232
+ * It is the same vocabulary as the manifest's `integrationRole`, which stays as an override.
53233
+ */
53234
+ var IntegrationInstanceRoleSchema = _enum(["devices", "services"]);
53235
+ /**
53289
53236
  * One kind of instance a provider can create (an adapter, an account type). The sign-in and
53290
53237
  * connect fields follow the `broker` contract (`broker.cap.ts`): `signIn.basePath` is a
53291
53238
  * hub-relative route set speaking the sign-in contract, `connectPath` / `disconnectPath` open an
@@ -53296,6 +53243,22 @@ var IntegrationInstanceKindSchema = object({
53296
53243
  /** Stable id of the kind, sent back as `createInstance.kind`. */
53297
53244
  id: string().min(1),
53298
53245
  label: string().min(1),
53246
+ /**
53247
+ * The function capability this kind is configured for (`broker`, `smtp-provider`,
53248
+ * `device-provider`, ...). A page section is the kinds whose `functionCap` it names (D1013); a
53249
+ * provider with more than one section must name it on every kind.
53250
+ */
53251
+ functionCap: string().min(1),
53252
+ /**
53253
+ * For `functionCap: 'broker'`: the registry kind of the broker an instance of this kind is
53254
+ * (`matter`, `home-assistant`, ...). A caller that needs a broker of one kind (a link field)
53255
+ * finds the instances whose kind names it; absent takes the kind `id`.
53256
+ */
53257
+ brokerKind: string().min(1).optional(),
53258
+ /** What instances of this kind are for the Integrations page; absent takes the provider's `role`. */
53259
+ role: IntegrationInstanceRoleSchema.optional(),
53260
+ /** `testInstance` really probes the remote for this kind; absent takes the provider's `canTest`. */
53261
+ canTest: boolean().optional(),
53299
53262
  /** The kind signs in through a server-held interactive session. */
53300
53263
  signIn: object({
53301
53264
  basePath: string().min(1),
@@ -53306,22 +53269,38 @@ var IntegrationInstanceKindSchema = object({
53306
53269
  /** Relative hub path to disconnect that account. */
53307
53270
  disconnectPath: string().min(1).optional()
53308
53271
  });
53272
+ /**
53273
+ * How devices of an instance are found. `none`: the operator adds them by hand; `lan`: the addon
53274
+ * scans the network before any instance exists (the wizard offers the candidates); `account`: the
53275
+ * devices appear after the instance signs in. `scopedToInstance`: a discovery run belongs to ONE
53276
+ * instance and its candidates are claimed by it.
53277
+ */
53278
+ var IntegrationInstanceDiscoverySchema = object({
53279
+ mode: _enum([
53280
+ "none",
53281
+ "lan",
53282
+ "account"
53283
+ ]),
53284
+ scopedToInstance: boolean()
53285
+ });
53286
+ /**
53287
+ * One link a kind of this provider declares (D1013 rule 5): the body `field` of an instance of
53288
+ * `kind` holds the id of an instance of the function cap `to.cap` (of kind `to.kind`, when set).
53289
+ * The hub indexes these so the target's delete is refused while a link names it.
53290
+ */
53291
+ var IntegrationInstanceLinkSchema = object({
53292
+ kind: string().min(1),
53293
+ field: string().min(1),
53294
+ to: object({
53295
+ cap: string().min(1),
53296
+ kind: string().min(1).optional()
53297
+ })
53298
+ });
53309
53299
  var IntegrationInstanceDescriptionSchema = object({
53310
53300
  /** What the instances are for the Integrations page; see {@link IntegrationInstanceRoleSchema}. */
53311
- role: _enum([
53312
- "devices",
53313
- "services",
53314
- "both"
53315
- ]),
53301
+ role: IntegrationInstanceRoleSchema,
53316
53302
  /** How the devices of an instance are found; absent means `{ mode: 'none' }`. */
53317
- discovery: object({
53318
- mode: _enum([
53319
- "none",
53320
- "lan",
53321
- "account"
53322
- ]),
53323
- scopedToInstance: boolean()
53324
- }).optional(),
53303
+ discovery: IntegrationInstanceDiscoverySchema.optional(),
53325
53304
  /** `single`: at most one instance can exist (Loki). `multiple`: an account each. */
53326
53305
  instanceMode: IntegrationInstanceModeSchema,
53327
53306
  /** What the instance is, for the UI (`destination`, `relay`, `account`). */
@@ -53342,7 +53321,9 @@ var IntegrationInstanceDescriptionSchema = object({
53342
53321
  * `createInstance` without an `id` works: the provider mints it. Absent means the caller must
53343
53322
  * send an id (the UI then mints an opaque one).
53344
53323
  */
53345
- mintsId: boolean().optional()
53324
+ mintsId: boolean().optional(),
53325
+ /** The links to other instances the provider's kinds declare; absent means none. */
53326
+ links: array(IntegrationInstanceLinkSchema).optional()
53346
53327
  });
53347
53328
  var IntegrationInstanceStatusSchema = object({
53348
53329
  state: _enum([
@@ -53380,10 +53361,16 @@ var IntegrationInstancePatchSchema = object({
53380
53361
  /** Omitted / '' / redaction token keeps a secret; `{ $secretClear: true }` clears it. */
53381
53362
  values: record(string(), unknown())
53382
53363
  });
53383
- method(_void(), IntegrationInstanceDescriptionSchema, { auth: "admin" }), method(object({ id: IntegrationInstanceIdSchema.nullable() }), ConfigSchemaPassthrough$3, { auth: "admin" }), method(_void(), array(IntegrationInstanceSchema).readonly(), { auth: "admin" }), method(object({ id: IntegrationInstanceIdSchema }), IntegrationInstanceSchema.nullable(), { auth: "admin" }), method(object({
53364
+ method(_void(), IntegrationInstanceDescriptionSchema, { auth: "admin" }), method(object({
53365
+ id: IntegrationInstanceIdSchema.nullable(),
53366
+ /** The kind of the create form (`id: null`) of a provider with several. */
53367
+ kind: string().min(1).optional()
53368
+ }), ConfigSchemaPassthrough$3, { auth: "admin" }), method(_void(), array(IntegrationInstanceSchema).readonly(), { auth: "admin" }), method(object({ id: IntegrationInstanceIdSchema }), IntegrationInstanceSchema.nullable(), { auth: "admin" }), method(object({
53384
53369
  id: IntegrationInstanceIdSchema.optional(),
53385
53370
  name: string().min(1),
53386
- kind: string().min(1).optional()
53371
+ kind: string().min(1).optional(),
53372
+ /** Form values written with the record (a link picked in the create dialog). */
53373
+ values: record(string(), unknown()).optional()
53387
53374
  }), object({ id: string() }), {
53388
53375
  kind: "mutation",
53389
53376
  auth: "admin"
@@ -53401,8 +53388,10 @@ method(_void(), IntegrationInstanceDescriptionSchema, { auth: "admin" }), method
53401
53388
  auth: "admin"
53402
53389
  }), optionalMethod(object({
53403
53390
  id: IntegrationInstanceIdSchema.nullable(),
53404
- values: record(string(), unknown())
53405
- }), TestConnectionResultSchema$1, {
53391
+ values: record(string(), unknown()),
53392
+ /** The kind to test when `id` is null and the provider has several. */
53393
+ kind: string().min(1).optional()
53394
+ }), TestConnectionResultSchema, {
53406
53395
  kind: "mutation",
53407
53396
  auth: "admin"
53408
53397
  });
@@ -55905,6 +55894,380 @@ var SystemMetricsSchema = object({
55905
55894
  gpuMemoryPercent: number().optional()
55906
55895
  });
55907
55896
  method(_void(), SystemResourceSnapshotSchema), method(_void(), SystemResourceSnapshotSchema.nullable()), method(_void(), SystemMetricsSchema), method(object({ dirPath: string() }), DiskSpaceInfoSchema), method(_void(), MetricsGpuInfoSchema.nullable()), method(_void(), number().nullable()), method(object({ pids: array(number()) }), array(PidResourceStatsSchema)), method(_void(), array(AddonInstanceSchema).readonly()), method(object({ addonId: string() }), PidResourceStatsSchema.nullable()), method(_void(), array(NodeProcessSchema).readonly()), method(GetLoadSeriesInputSchema, NodeLoadSeriesSchema);
55897
+ /**
55898
+ * records - an addon's own facts and documents (D881): ledgers, audit rows,
55899
+ * config documents, mirrors. The third storage API next to `ctx.settings`
55900
+ * (operator intent, D870) and device-history (numbers over time, D850).
55901
+ *
55902
+ * Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
55903
+ * crossed a process and stated by a hub in-process caller (`ctx.records` does
55904
+ * that with the addon id closed over). It is deliberately NOT in any input
55905
+ * schema, so a session can never supply it, and a call with no stamp is refused
55906
+ * `records/no-caller`. A kind is readable and writable only by its owner; other
55907
+ * addons go through the owner's capability.
55908
+ *
55909
+ * Every read is three-way: a row, `null`, or the call THROWS. A failed read is
55910
+ * never `[]`. Secret fields are never on the wire: a read shows the
55911
+ * redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
55912
+ * resolves itself, and a write may carry only a keychain marker bound to the
55913
+ * row's own ref.
55914
+ *
55915
+ * Internal: addons reach it through `ctx.records`, never directly.
55916
+ */
55917
+ var RecordIdSchema = string().min(1).max(256);
55918
+ /** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
55919
+ var RecordBodySchema = record(string(), unknown());
55920
+ var RecordInputSchema = object({
55921
+ id: RecordIdSchema,
55922
+ /** The device this row belongs to (D865 removal, per-device reads). */
55923
+ deviceId: number().int().optional(),
55924
+ /** The domain clock, ms: observed / created / opened. */
55925
+ at: number().int().optional(),
55926
+ /** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
55927
+ expiresAt: number().int().optional(),
55928
+ data: RecordBodySchema
55929
+ });
55930
+ var RecordViewSchema = object({
55931
+ id: string(),
55932
+ deviceId: number().int().nullable(),
55933
+ at: number().nullable(),
55934
+ expiresAt: number().nullable(),
55935
+ rev: number().int(),
55936
+ updatedAt: number(),
55937
+ data: RecordBodySchema
55938
+ });
55939
+ /** Declared index fields only. Anything else does not compile, by design. */
55940
+ var RecordWhereSchema = record(RecordFieldPathSchema, union([
55941
+ string(),
55942
+ number(),
55943
+ boolean(),
55944
+ object({ in: array(union([
55945
+ string(),
55946
+ number(),
55947
+ boolean()
55948
+ ])).min(1).max(RECORD_BATCH_MAX) }),
55949
+ object({
55950
+ gt: union([string(), number()]).optional(),
55951
+ gte: union([string(), number()]).optional(),
55952
+ lt: union([string(), number()]).optional(),
55953
+ lte: union([string(), number()]).optional()
55954
+ }).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
55955
+ ]));
55956
+ var KindShape = { kind: RecordKindNameSchema };
55957
+ var TimeWindowShape = {
55958
+ deviceId: number().int().optional(),
55959
+ atFrom: number().optional(),
55960
+ atTo: number().optional()
55961
+ };
55962
+ var RecordQueryInputSchema = object({
55963
+ ...KindShape,
55964
+ ...TimeWindowShape,
55965
+ where: RecordWhereSchema.optional(),
55966
+ /** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
55967
+ order: _enum(["at", "id"]).optional(),
55968
+ desc: boolean().optional(),
55969
+ limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
55970
+ /** Opaque keyset cursor from a previous answer. There is no offset. */
55971
+ cursor: string().min(1).optional()
55972
+ });
55973
+ var RecordQueryResultSchema = object({
55974
+ records: array(RecordViewSchema),
55975
+ nextCursor: string().nullable()
55976
+ });
55977
+ var RecordKindStateSchema = _enum([
55978
+ "created",
55979
+ "unchanged",
55980
+ "updated"
55981
+ ]);
55982
+ var DeclareKindResultSchema = object({
55983
+ kindId: number().int(),
55984
+ state: RecordKindStateSchema,
55985
+ createdIndexes: array(string())
55986
+ });
55987
+ /** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
55988
+ var SecretRefsList = array(string());
55989
+ /**
55990
+ * One op of a `transact`: the single-row writes, each on a kind of the caller.
55991
+ * All ops of one call share ONE database file and ONE `transactFamily`.
55992
+ */
55993
+ var RecordTransactOpSchema = discriminatedUnion("op", [
55994
+ object({
55995
+ op: literal("put"),
55996
+ kind: RecordKindNameSchema,
55997
+ record: RecordInputSchema,
55998
+ ifRev: number().int().min(0).optional()
55999
+ }),
56000
+ object({
56001
+ op: literal("patch"),
56002
+ kind: RecordKindNameSchema,
56003
+ id: RecordIdSchema,
56004
+ data: RecordBodySchema,
56005
+ at: number().int().nullable().optional(),
56006
+ expiresAt: number().int().nullable().optional(),
56007
+ ifRev: number().int().min(1).optional()
56008
+ }),
56009
+ object({
56010
+ op: literal("delete"),
56011
+ kind: RecordKindNameSchema,
56012
+ id: RecordIdSchema
56013
+ })
56014
+ ]);
56015
+ var RecordSecretRefsSchema = record(string(), record(string(), string()));
56016
+ method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
56017
+ kind: "mutation",
56018
+ auth: "admin"
56019
+ }), method(object({
56020
+ ...KindShape,
56021
+ id: RecordIdSchema
56022
+ }), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
56023
+ ...KindShape,
56024
+ ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
56025
+ }), array(RecordViewSchema), { auth: "admin" }), method(object({
56026
+ ...KindShape,
56027
+ ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
56028
+ }), RecordSecretRefsSchema, { auth: "admin" }), method(object({
56029
+ ...KindShape,
56030
+ record: RecordInputSchema,
56031
+ /** Compare-and-set. `0` means "the row must not exist". */
56032
+ ifRev: number().int().min(0).optional()
56033
+ }), object({
56034
+ rev: number().int(),
56035
+ releasedRefs: SecretRefsList
56036
+ }), {
56037
+ kind: "mutation",
56038
+ auth: "admin"
56039
+ }), method(object({
56040
+ ...KindShape,
56041
+ records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
56042
+ }), object({
56043
+ count: number().int(),
56044
+ releasedRefs: SecretRefsList
56045
+ }), {
56046
+ kind: "mutation",
56047
+ auth: "admin"
56048
+ }), method(object({
56049
+ ...KindShape,
56050
+ id: RecordIdSchema,
56051
+ data: RecordBodySchema,
56052
+ at: number().int().nullable().optional(),
56053
+ expiresAt: number().int().nullable().optional(),
56054
+ ifRev: number().int().min(1).optional()
56055
+ }), object({
56056
+ rev: number().int(),
56057
+ releasedRefs: SecretRefsList
56058
+ }), {
56059
+ kind: "mutation",
56060
+ auth: "admin"
56061
+ }), method(object({
56062
+ ...KindShape,
56063
+ id: RecordIdSchema
56064
+ }), object({
56065
+ deleted: boolean(),
56066
+ secretRefs: SecretRefsList
56067
+ }), {
56068
+ kind: "mutation",
56069
+ auth: "admin"
56070
+ }), method(object({
56071
+ ...KindShape,
56072
+ ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
56073
+ }), object({
56074
+ deleted: number().int(),
56075
+ secretRefs: SecretRefsList
56076
+ }), {
56077
+ kind: "mutation",
56078
+ auth: "admin"
56079
+ }), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
56080
+ ...KindShape,
56081
+ ...TimeWindowShape,
56082
+ where: RecordWhereSchema.optional()
56083
+ }), object({ count: number().int() }), { auth: "admin" }), method(object({
56084
+ ...KindShape,
56085
+ deviceId: number().int().optional(),
56086
+ from: number(),
56087
+ to: number(),
56088
+ bucketMs: number().int().positive()
56089
+ }), object({ buckets: array(object({
56090
+ bucketStart: number(),
56091
+ count: number().int()
56092
+ })) }), { auth: "admin" }), method(object({
56093
+ ...KindShape,
56094
+ op: _enum([
56095
+ "sum",
56096
+ "min",
56097
+ "max",
56098
+ "count"
56099
+ ]),
56100
+ field: RecordFieldPathSchema.optional(),
56101
+ groupBy: RecordFieldPathSchema.optional(),
56102
+ where: RecordWhereSchema.optional()
56103
+ }), object({ rows: array(object({
56104
+ group: union([
56105
+ string(),
56106
+ number(),
56107
+ _null()
56108
+ ]),
56109
+ value: number().nullable()
56110
+ })) }), { auth: "admin" }), method(object({
56111
+ ...KindShape,
56112
+ deviceId: number().int().optional(),
56113
+ atBefore: number().optional(),
56114
+ where: RecordWhereSchema.optional()
56115
+ }), object({
56116
+ deleted: number().int(),
56117
+ secretRefs: SecretRefsList
56118
+ }), {
56119
+ kind: "mutation",
56120
+ auth: "admin"
56121
+ }), method(object({ ops: array(RecordTransactOpSchema).min(1).max(RECORD_BATCH_MAX) }), object({
56122
+ results: array(object({
56123
+ rev: number().int().nullable(),
56124
+ deleted: boolean()
56125
+ })),
56126
+ releasedRefs: SecretRefsList,
56127
+ secretRefs: SecretRefsList
56128
+ }), {
56129
+ kind: "mutation",
56130
+ auth: "admin"
56131
+ }), method(object({
56132
+ deviceId: number().int(),
56133
+ kinds: array(RecordKindNameSchema).optional()
56134
+ }), object({
56135
+ deleted: record(string(), number().int()),
56136
+ secretRefs: SecretRefsList
56137
+ }), {
56138
+ kind: "mutation",
56139
+ auth: "admin"
56140
+ }), method(object(KindShape), object({ id: number().int() }), {
56141
+ kind: "mutation",
56142
+ auth: "admin"
56143
+ });
56144
+ /**
56145
+ * The wire shapes of the migration API, version 1 (planning#447).
56146
+ *
56147
+ * A migration is code that outlives the server it was written against: an addon at
56148
+ * version 1.4 that is brought to 1.9 in one jump still runs its 1.4 catalogue, against
56149
+ * the 1.9 kernel. The only thing that code may call is {@link MigrationApiV1}; this file
56150
+ * is the contract of every method of it, one Zod pair per method.
56151
+ *
56152
+ * APPEND-ONLY. A released method is never removed and never changes meaning: an input
56153
+ * field is never removed or made required, an enum never narrows, an output field is
56154
+ * never removed. A change that cannot be expressed that way is `migration-api.v2`, next
56155
+ * to this file. `scripts/check-migration-api-append-only.ts` holds the line against
56156
+ * `scripts/migration-api-contract.json`, and every `behaviours` id below must have an
56157
+ * `it('<id>'` in `migration-api.contract.spec.ts`.
56158
+ */
56159
+ var Rows = record(string(), unknown());
56160
+ var IntegrationId = object({ integrationId: string().min(1) });
56161
+ var RecordId = object({ id: string().min(1) });
56162
+ var RecordRowSchema = object({
56163
+ id: string(),
56164
+ deviceId: number().int().nullable(),
56165
+ at: number().nullable(),
56166
+ expiresAt: number().nullable(),
56167
+ rev: number().int(),
56168
+ updatedAt: number(),
56169
+ data: Rows
56170
+ });
56171
+ var RecordPutShape = {
56172
+ id: string().min(1),
56173
+ deviceId: number().int().optional(),
56174
+ at: number().int().optional(),
56175
+ expiresAt: number().int().optional(),
56176
+ data: Rows
56177
+ };
56178
+ var MigrationIntegrationSchema = object({
56179
+ id: string(),
56180
+ addonId: string(),
56181
+ name: string(),
56182
+ info: Rows,
56183
+ originStableId: string().optional()
56184
+ });
56185
+ var MigrationDeviceSchema = object({
56186
+ id: number().int(),
56187
+ integrationId: string().nullable().optional(),
56188
+ /** The owning device; null or absent for a root. */
56189
+ parentDeviceId: number().int().nullable().optional(),
56190
+ type: string().optional(),
56191
+ name: string().optional(),
56192
+ stableId: string().optional()
56193
+ });
56194
+ /** What the engine says about the migration API it serves: lets an addon notice an older server. */
56195
+ var MigrationApiInfoSchema = object({
56196
+ version: number().int(),
56197
+ methods: array(string())
56198
+ });
56199
+ object({
56200
+ message: string(),
56201
+ meta: Rows.optional(),
56202
+ /** Grouping tags of the line; a line about a device carries `{ deviceId }`. */
56203
+ tags: object({ deviceId: number().int().optional() }).optional()
56204
+ });
56205
+ object({
56206
+ owner: string().min(1),
56207
+ metas: array(MigrationMetaSchema)
56208
+ }), object({
56209
+ bootId: string(),
56210
+ snapshot: _enum([
56211
+ "none",
56212
+ "written",
56213
+ "refused"
56214
+ ]),
56215
+ steps: array(MigrationOwnerStepSchema),
56216
+ /** The migration API the engine serves; absent from a server that predates it. */
56217
+ migrationApi: MigrationApiInfoSchema.optional()
56218
+ }), object({ id: string().min(1) }), object({
56219
+ proceed: boolean(),
56220
+ state: union([literal("pending"), MigrationStatusSchema]),
56221
+ reason: string().nullable()
56222
+ }), object({
56223
+ id: string().min(1),
56224
+ result: MigrationOwnerResultSchema
56225
+ }), object({
56226
+ status: MigrationStatusSchema,
56227
+ error: string().nullable(),
56228
+ rowsChanged: number().int().nonnegative()
56229
+ }), object({
56230
+ rows: number().int().nonnegative(),
56231
+ secrets: number().int().nonnegative()
56232
+ }), IntegrationId.extend({ patch: Rows }), object({ written: boolean() }), IntegrationId.extend({ keys: array(string().min(1)) }), object({
56233
+ present: boolean(),
56234
+ removed: Rows
56235
+ }), RecordRowSchema.nullable(), RecordRowSchema.nullable(), object({
56236
+ ...RecordPutShape,
56237
+ ifRev: number().int().optional()
56238
+ }), object({ rev: number().int() }), object({ records: array(object(RecordPutShape)) }), object({ count: number().int().nonnegative() }), RecordId.extend({
56239
+ partial: Rows,
56240
+ ifRev: number().int().optional()
56241
+ }), object({ rev: number().int() }), object({ deleted: boolean() }), object({
56242
+ deviceId: number().int().optional(),
56243
+ atFrom: number().optional(),
56244
+ atTo: number().optional(),
56245
+ where: RecordWhereSchema.optional(),
56246
+ limit: number().int().min(1).optional(),
56247
+ cursor: string().min(1).optional(),
56248
+ resolveSecrets: boolean().optional()
56249
+ }), object({
56250
+ records: array(RecordRowSchema),
56251
+ nextCursor: string().nullable()
56252
+ }), object({
56253
+ deviceId: number().int().optional(),
56254
+ atBefore: number().optional(),
56255
+ where: RecordWhereSchema.optional()
56256
+ }), object({ count: number().int().nonnegative() }), object({}), object({ store: Rows }), object({ patch: Rows }), object({}), object({ keys: array(string().min(1)) }), object({ removed: array(string()) }), object({ refs: array(string()) }), object({ values: record(string(), string().nullable()) }), object({
56257
+ ref: string().min(1),
56258
+ value: string()
56259
+ }), object({}), object({ refs: array(string()) }), object({ deleted: number().int().nonnegative() }), object({}), object({ integrations: array(MigrationIntegrationSchema) }), object({ id: string().min(1) }), MigrationIntegrationSchema.nullable(), object({
56260
+ addonId: string().min(1),
56261
+ integrationId: string().min(1).optional()
56262
+ }), object({ devices: array(MigrationDeviceSchema) }), object({ deviceId: number().int() }), object({
56263
+ id: number().int(),
56264
+ integrationId: string().nullable(),
56265
+ /** Whether the device carries any stored config; its content is not offered. */
56266
+ hasConfig: boolean()
56267
+ }).nullable(), object({
56268
+ deviceId: number().int(),
56269
+ integrationId: string().min(1)
56270
+ }), object({}), object({}), object({ nodeId: string() }), object({}), object({});
55908
56271
  method(object({}), object({ entries: array(MigrationLedgerEntrySchema) }), { auth: "admin" }), method(object({ owner: string().optional() }), object({ pending: array(MigrationPendingEntrySchema) }), { auth: "admin" }), method(object({ id: string().min(1) }), MigrationDryRunResultSchema, { auth: "admin" }), method(object({
55909
56272
  id: string().min(1),
55910
56273
  error: string().min(1)
@@ -55934,7 +56297,9 @@ method(object({}), object({ entries: array(MigrationLedgerEntrySchema) }), { aut
55934
56297
  "written",
55935
56298
  "refused"
55936
56299
  ]),
55937
- steps: array(MigrationOwnerStepSchema)
56300
+ steps: array(MigrationOwnerStepSchema),
56301
+ /** The migration API this engine serves (additive: a server that predates it omits it). */
56302
+ migrationApi: MigrationApiInfoSchema.optional()
55938
56303
  }), {
55939
56304
  kind: "mutation",
55940
56305
  auth: "admin"
@@ -58601,7 +58966,10 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
58601
58966
  }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
58602
58967
  kind: "mutation",
58603
58968
  auth: "admin"
58604
- }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
58969
+ }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(MediaLocationCensusInputSchema, MediaLocationCensusSchema, {
58970
+ kind: "query",
58971
+ auth: "admin"
58972
+ }), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
58605
58973
  kind: "query",
58606
58974
  auth: "admin"
58607
58975
  }), method(object({}), array(RelocateJobSchema).readonly(), {
@@ -61008,7 +61376,7 @@ var BrokerStatusSchema$1 = _enum([
61008
61376
  "unreachable",
61009
61377
  "tls-error"
61010
61378
  ]);
61011
- var BrokerInfoSchema$1 = object({
61379
+ var BrokerInfoSchema = object({
61012
61380
  id: string(),
61013
61381
  name: string(),
61014
61382
  url: string(),
@@ -61071,7 +61439,7 @@ var StatusSchema = object({
61071
61439
  brokerCount: number(),
61072
61440
  embeddedRunning: boolean()
61073
61441
  });
61074
- method(_void(), array(BrokerInfoSchema$1)), method(IdInputSchema, BrokerConnectionDetailsSchema, { auth: "admin" }), method(AddBrokerInputSchema, AddBrokerResultSchema, {
61442
+ method(_void(), array(BrokerInfoSchema)), method(IdInputSchema, BrokerConnectionDetailsSchema, { auth: "admin" }), method(AddBrokerInputSchema, AddBrokerResultSchema, {
61075
61443
  kind: "mutation",
61076
61444
  auth: "admin"
61077
61445
  }), method(IdInputSchema, _void(), {
@@ -67389,253 +67757,6 @@ DeviceType.Camera, DeviceType.Sensor, DeviceType.Switch, DeviceType.Gateway, met
67389
67757
  auth: "admin"
67390
67758
  });
67391
67759
  /**
67392
- * records - an addon's own facts and documents (D881): ledgers, audit rows,
67393
- * config documents, mirrors. The third storage API next to `ctx.settings`
67394
- * (operator intent, D870) and device-history (numbers over time, D850).
67395
- *
67396
- * Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
67397
- * crossed a process and stated by a hub in-process caller (`ctx.records` does
67398
- * that with the addon id closed over). It is deliberately NOT in any input
67399
- * schema, so a session can never supply it, and a call with no stamp is refused
67400
- * `records/no-caller`. A kind is readable and writable only by its owner; other
67401
- * addons go through the owner's capability.
67402
- *
67403
- * Every read is three-way: a row, `null`, or the call THROWS. A failed read is
67404
- * never `[]`. Secret fields are never on the wire: a read shows the
67405
- * redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
67406
- * resolves itself, and a write may carry only a keychain marker bound to the
67407
- * row's own ref.
67408
- *
67409
- * Internal: addons reach it through `ctx.records`, never directly.
67410
- */
67411
- var RecordIdSchema = string().min(1).max(256);
67412
- /** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
67413
- var RecordBodySchema = record(string(), unknown());
67414
- var RecordInputSchema = object({
67415
- id: RecordIdSchema,
67416
- /** The device this row belongs to (D865 removal, per-device reads). */
67417
- deviceId: number().int().optional(),
67418
- /** The domain clock, ms: observed / created / opened. */
67419
- at: number().int().optional(),
67420
- /** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
67421
- expiresAt: number().int().optional(),
67422
- data: RecordBodySchema
67423
- });
67424
- var RecordViewSchema = object({
67425
- id: string(),
67426
- deviceId: number().int().nullable(),
67427
- at: number().nullable(),
67428
- expiresAt: number().nullable(),
67429
- rev: number().int(),
67430
- updatedAt: number(),
67431
- data: RecordBodySchema
67432
- });
67433
- /** Declared index fields only. Anything else does not compile, by design. */
67434
- var RecordWhereSchema = record(RecordFieldPathSchema, union([
67435
- string(),
67436
- number(),
67437
- boolean(),
67438
- object({ in: array(union([
67439
- string(),
67440
- number(),
67441
- boolean()
67442
- ])).min(1).max(RECORD_BATCH_MAX) }),
67443
- object({
67444
- gt: union([string(), number()]).optional(),
67445
- gte: union([string(), number()]).optional(),
67446
- lt: union([string(), number()]).optional(),
67447
- lte: union([string(), number()]).optional()
67448
- }).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
67449
- ]));
67450
- var KindShape = { kind: RecordKindNameSchema };
67451
- var TimeWindowShape = {
67452
- deviceId: number().int().optional(),
67453
- atFrom: number().optional(),
67454
- atTo: number().optional()
67455
- };
67456
- var RecordQueryInputSchema = object({
67457
- ...KindShape,
67458
- ...TimeWindowShape,
67459
- where: RecordWhereSchema.optional(),
67460
- /** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
67461
- order: _enum(["at", "id"]).optional(),
67462
- desc: boolean().optional(),
67463
- limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
67464
- /** Opaque keyset cursor from a previous answer. There is no offset. */
67465
- cursor: string().min(1).optional()
67466
- });
67467
- var RecordQueryResultSchema = object({
67468
- records: array(RecordViewSchema),
67469
- nextCursor: string().nullable()
67470
- });
67471
- var RecordKindStateSchema = _enum([
67472
- "created",
67473
- "unchanged",
67474
- "updated"
67475
- ]);
67476
- var DeclareKindResultSchema = object({
67477
- kindId: number().int(),
67478
- state: RecordKindStateSchema,
67479
- createdIndexes: array(string())
67480
- });
67481
- /** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
67482
- var SecretRefsList = array(string());
67483
- /**
67484
- * One op of a `transact`: the single-row writes, each on a kind of the caller.
67485
- * All ops of one call share ONE database file and ONE `transactFamily`.
67486
- */
67487
- var RecordTransactOpSchema = discriminatedUnion("op", [
67488
- object({
67489
- op: literal("put"),
67490
- kind: RecordKindNameSchema,
67491
- record: RecordInputSchema,
67492
- ifRev: number().int().min(0).optional()
67493
- }),
67494
- object({
67495
- op: literal("patch"),
67496
- kind: RecordKindNameSchema,
67497
- id: RecordIdSchema,
67498
- data: RecordBodySchema,
67499
- at: number().int().nullable().optional(),
67500
- expiresAt: number().int().nullable().optional(),
67501
- ifRev: number().int().min(1).optional()
67502
- }),
67503
- object({
67504
- op: literal("delete"),
67505
- kind: RecordKindNameSchema,
67506
- id: RecordIdSchema
67507
- })
67508
- ]);
67509
- var RecordSecretRefsSchema = record(string(), record(string(), string()));
67510
- method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
67511
- kind: "mutation",
67512
- auth: "admin"
67513
- }), method(object({
67514
- ...KindShape,
67515
- id: RecordIdSchema
67516
- }), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
67517
- ...KindShape,
67518
- ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
67519
- }), array(RecordViewSchema), { auth: "admin" }), method(object({
67520
- ...KindShape,
67521
- ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
67522
- }), RecordSecretRefsSchema, { auth: "admin" }), method(object({
67523
- ...KindShape,
67524
- record: RecordInputSchema,
67525
- /** Compare-and-set. `0` means "the row must not exist". */
67526
- ifRev: number().int().min(0).optional()
67527
- }), object({
67528
- rev: number().int(),
67529
- releasedRefs: SecretRefsList
67530
- }), {
67531
- kind: "mutation",
67532
- auth: "admin"
67533
- }), method(object({
67534
- ...KindShape,
67535
- records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
67536
- }), object({
67537
- count: number().int(),
67538
- releasedRefs: SecretRefsList
67539
- }), {
67540
- kind: "mutation",
67541
- auth: "admin"
67542
- }), method(object({
67543
- ...KindShape,
67544
- id: RecordIdSchema,
67545
- data: RecordBodySchema,
67546
- at: number().int().nullable().optional(),
67547
- expiresAt: number().int().nullable().optional(),
67548
- ifRev: number().int().min(1).optional()
67549
- }), object({
67550
- rev: number().int(),
67551
- releasedRefs: SecretRefsList
67552
- }), {
67553
- kind: "mutation",
67554
- auth: "admin"
67555
- }), method(object({
67556
- ...KindShape,
67557
- id: RecordIdSchema
67558
- }), object({
67559
- deleted: boolean(),
67560
- secretRefs: SecretRefsList
67561
- }), {
67562
- kind: "mutation",
67563
- auth: "admin"
67564
- }), method(object({
67565
- ...KindShape,
67566
- ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
67567
- }), object({
67568
- deleted: number().int(),
67569
- secretRefs: SecretRefsList
67570
- }), {
67571
- kind: "mutation",
67572
- auth: "admin"
67573
- }), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
67574
- ...KindShape,
67575
- ...TimeWindowShape,
67576
- where: RecordWhereSchema.optional()
67577
- }), object({ count: number().int() }), { auth: "admin" }), method(object({
67578
- ...KindShape,
67579
- deviceId: number().int().optional(),
67580
- from: number(),
67581
- to: number(),
67582
- bucketMs: number().int().positive()
67583
- }), object({ buckets: array(object({
67584
- bucketStart: number(),
67585
- count: number().int()
67586
- })) }), { auth: "admin" }), method(object({
67587
- ...KindShape,
67588
- op: _enum([
67589
- "sum",
67590
- "min",
67591
- "max",
67592
- "count"
67593
- ]),
67594
- field: RecordFieldPathSchema.optional(),
67595
- groupBy: RecordFieldPathSchema.optional(),
67596
- where: RecordWhereSchema.optional()
67597
- }), object({ rows: array(object({
67598
- group: union([
67599
- string(),
67600
- number(),
67601
- _null()
67602
- ]),
67603
- value: number().nullable()
67604
- })) }), { auth: "admin" }), method(object({
67605
- ...KindShape,
67606
- deviceId: number().int().optional(),
67607
- atBefore: number().optional(),
67608
- where: RecordWhereSchema.optional()
67609
- }), object({
67610
- deleted: number().int(),
67611
- secretRefs: SecretRefsList
67612
- }), {
67613
- kind: "mutation",
67614
- auth: "admin"
67615
- }), method(object({ ops: array(RecordTransactOpSchema).min(1).max(RECORD_BATCH_MAX) }), object({
67616
- results: array(object({
67617
- rev: number().int().nullable(),
67618
- deleted: boolean()
67619
- })),
67620
- releasedRefs: SecretRefsList,
67621
- secretRefs: SecretRefsList
67622
- }), {
67623
- kind: "mutation",
67624
- auth: "admin"
67625
- }), method(object({
67626
- deviceId: number().int(),
67627
- kinds: array(RecordKindNameSchema).optional()
67628
- }), object({
67629
- deleted: record(string(), number().int()),
67630
- secretRefs: SecretRefsList
67631
- }), {
67632
- kind: "mutation",
67633
- auth: "admin"
67634
- }), method(object(KindShape), object({ id: number().int() }), {
67635
- kind: "mutation",
67636
- auth: "admin"
67637
- });
67638
- /**
67639
67760
  * record-entries - the ONE admin surface for every list of user-created entries
67640
67761
  * (D881): notification targets, brokers, LLM profiles, anything an addon
67641
67762
  * declares as an ENTRY kind (`entry: { title }` in `defineRecordKinds`).
@@ -76178,20 +76299,6 @@ Object.freeze({
76178
76299
  access: "create",
76179
76300
  role: "viewer"
76180
76301
  },
76181
- "broker.add": {
76182
- capName: "broker",
76183
- capScope: "system",
76184
- addonId: null,
76185
- access: "create",
76186
- role: "admin"
76187
- },
76188
- "broker.get": {
76189
- capName: "broker",
76190
- capScope: "system",
76191
- addonId: null,
76192
- access: "view",
76193
- role: "admin"
76194
- },
76195
76302
  "broker.getBrokerConfig": {
76196
76303
  capName: "broker",
76197
76304
  capScope: "system",
@@ -76199,20 +76306,6 @@ Object.freeze({
76199
76306
  access: "view",
76200
76307
  role: "admin"
76201
76308
  },
76202
- "broker.getSettings": {
76203
- capName: "broker",
76204
- capScope: "system",
76205
- addonId: null,
76206
- access: "view",
76207
- role: "admin"
76208
- },
76209
- "broker.getSettingsSchema": {
76210
- capName: "broker",
76211
- capScope: "system",
76212
- addonId: null,
76213
- access: "view",
76214
- role: "admin"
76215
- },
76216
76309
  "broker.getState": {
76217
76310
  capName: "broker",
76218
76311
  capScope: "system",
@@ -76227,20 +76320,6 @@ Object.freeze({
76227
76320
  access: "view",
76228
76321
  role: "admin"
76229
76322
  },
76230
- "broker.list": {
76231
- capName: "broker",
76232
- capScope: "system",
76233
- addonId: null,
76234
- access: "view",
76235
- role: "admin"
76236
- },
76237
- "broker.listProviders": {
76238
- capName: "broker",
76239
- capScope: "system",
76240
- addonId: null,
76241
- access: "view",
76242
- role: "admin"
76243
- },
76244
76323
  "broker.publish": {
76245
76324
  capName: "broker",
76246
76325
  capScope: "system",
@@ -76248,20 +76327,6 @@ Object.freeze({
76248
76327
  access: "create",
76249
76328
  role: "admin"
76250
76329
  },
76251
- "broker.remove": {
76252
- capName: "broker",
76253
- capScope: "system",
76254
- addonId: null,
76255
- access: "delete",
76256
- role: "admin"
76257
- },
76258
- "broker.setSettings": {
76259
- capName: "broker",
76260
- capScope: "system",
76261
- addonId: null,
76262
- access: "create",
76263
- role: "admin"
76264
- },
76265
76330
  "broker.subscribe": {
76266
76331
  capName: "broker",
76267
76332
  capScope: "system",
@@ -76269,20 +76334,6 @@ Object.freeze({
76269
76334
  access: "create",
76270
76335
  role: "admin"
76271
76336
  },
76272
- "broker.testConnection": {
76273
- capName: "broker",
76274
- capScope: "system",
76275
- addonId: null,
76276
- access: "create",
76277
- role: "admin"
76278
- },
76279
- "broker.testSettings": {
76280
- capName: "broker",
76281
- capScope: "system",
76282
- addonId: null,
76283
- access: "create",
76284
- role: "admin"
76285
- },
76286
76337
  "broker.unsubscribe": {
76287
76338
  capName: "broker",
76288
76339
  capScope: "system",
@@ -81246,6 +81297,13 @@ Object.freeze({
81246
81297
  access: "view",
81247
81298
  role: "viewer"
81248
81299
  },
81300
+ "pipelineAnalytics.getMediaLocationCensus": {
81301
+ capName: "pipeline-analytics",
81302
+ capScope: "device",
81303
+ addonId: null,
81304
+ access: "view",
81305
+ role: "admin"
81306
+ },
81249
81307
  "pipelineAnalytics.getMediaReclaimStatus": {
81250
81308
  capName: "pipeline-analytics",
81251
81309
  capScope: "device",
@@ -90187,6 +90245,7 @@ object({
90187
90245
  delay: number().nonnegative().optional(),
90188
90246
  commands: record(string(), unknown())
90189
90247
  });
90248
+ entryBody({ brokerId: string() });
90190
90249
  //#endregion
90191
90250
  //#region src/addon.ts
90192
90251
  var __dirname = path.dirname(fileURLToPath(import.meta.url));
@@ -90208,7 +90267,7 @@ var AgentUIAddon = class extends BaseAddon {
90208
90267
  capability: adminUiCapability,
90209
90268
  provider: {
90210
90269
  getStaticDir: async () => ({ staticDir: path.resolve(__dirname) }),
90211
- getVersion: async () => ({ version: "1.2.329" })
90270
+ getVersion: async () => ({ version: "1.2.331" })
90212
90271
  }
90213
90272
  }];
90214
90273
  }