@camstack/addon-pipeline-orchestrator 1.2.662 → 1.2.663

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.
Files changed (18) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/assets/viewer/.viewer-current-files.json +2 -2
  3. package/assets/viewer/.viewer-version +1 -1
  4. package/assets/viewer/_expo/static/js/web/{__common-b582199d5704981fa512087e41f144bb.js → __common-944a1711775677f5c7cba328efbb7eb2.js} +9 -9
  5. package/assets/viewer/_expo/static/js/web/{index-49b436680a10d5eb314daaefff7128b9.js → index-c2e4074d6805fc38a186dd83bd4fd0a2.js} +2 -2
  6. package/assets/viewer/index.html +1 -1
  7. package/dist/_stub.js +2 -2
  8. package/dist/{_virtual_mf-localSharedImportMap___mfe_internal__addon_pipeline_orchestrator_widgets-SE2z6ZPT.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_pipeline_orchestrator_widgets-CbbVC-1B.mjs} +2 -2
  9. package/dist/_virtual_mf___mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-r0TW-BbW.mjs +26 -0
  10. package/dist/_virtual_mf___mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-DkP-6xmg.mjs +26 -0
  11. package/dist/{hostInit-j4Xg1GJl.mjs → hostInit-BQJRnhiE.mjs} +2 -2
  12. package/dist/index.js +587 -560
  13. package/dist/index.mjs +587 -560
  14. package/dist/remoteEntry.js +1 -1
  15. package/package.json +2 -2
  16. package/assets/viewer/_expo/static/js/web/_layout-0fda926e25f08a11cce3143894cd6667.js +0 -29
  17. package/dist/_virtual_mf___mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-CmlOAYRv.mjs +0 -26
  18. package/dist/_virtual_mf___mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-DGQuOA5w.mjs +0 -26
package/dist/index.mjs CHANGED
@@ -5984,7 +5984,7 @@ var ZodIssueCode = {
5984
5984
  var ZodFirstPartyTypeKind;
5985
5985
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5986
5986
  //#endregion
5987
- //#region ../types/dist/sleep-DEZaLbiu.mjs
5987
+ //#region ../types/dist/sleep-BX_MqzUe.mjs
5988
5988
  /**
5989
5989
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5990
5990
  * window to float samples (D455).
@@ -7580,6 +7580,28 @@ var SECRET_RETRY_MAX_MS = 5 * 6e4;
7580
7580
  /** Coalesces a burst of `keychain.changed` events into one re-resolve. */
7581
7581
  var SECRET_CHANGE_DEBOUNCE_MS = 250;
7582
7582
  /**
7583
+ * Pair a catalogue with the function that builds its ports FROM THE MIGRATION API. The one
7584
+ * place a catalogue is bound: a migration reaches nothing a ports binder cannot reach
7585
+ * through `api` (guard `check-migration-ports-surface`).
7586
+ */
7587
+ function migrationSet(catalogue, bindPorts) {
7588
+ return { bind: (api) => defineAddonMigrations(catalogue, bindPorts(api)) };
7589
+ }
7590
+ /** A mixed array is a mistake: the other kind would be dropped without a word. */
7591
+ function refuseMixed(form, kept, dropped) {
7592
+ 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`);
7593
+ }
7594
+ function catalogueOf(list) {
7595
+ const kept = list.filter((entry) => !("execute" in entry));
7596
+ refuseMixed("catalogue, (api) => ports", kept.length, list.length - kept.length);
7597
+ return kept;
7598
+ }
7599
+ function boundOf(list) {
7600
+ const kept = list.filter((entry) => "execute" in entry);
7601
+ refuseMixed("bound migrations", kept.length, list.length - kept.length);
7602
+ return kept;
7603
+ }
7604
+ /**
7583
7605
  * Base class for CamStack addons. Eliminates settings boilerplate:
7584
7606
  *
7585
7607
  * - Typed `config` property with automatic resolution from store + defaults
@@ -7746,23 +7768,21 @@ var BaseAddon = class {
7746
7768
  await this.loadScopedSchemas();
7747
7769
  return normalized;
7748
7770
  }
7771
+ async runMigrations(first, second, third) {
7772
+ if (typeof second === "function") return this.runMigrationSets([migrationSet(catalogueOf(first), second)], third);
7773
+ return this.runBound(boundOf(first), second);
7774
+ }
7749
7775
  /**
7750
- * Run this addon's migration catalogue (D987 M3) through the hub's `migrations`
7751
- * engine. Call it at the point of the boot where the data must already have the new
7752
- * shape — `onInitialize`, or `onRestoreDevices` for a migration that needs the
7753
- * restored devices — with the catalogue bound to the addon's ports
7754
- * (`defineAddonMigrations(ADDON_MIGRATIONS, ports)`).
7755
- *
7756
- * An engine that cannot be reached or refuses the catalogue is logged and runs
7757
- * nothing; the boot continues. A migration that FAILED (or was blocked by one)
7758
- * and declares `onFailure: 'block-owner'` makes this throw, so the addon does not
7759
- * serve data whose shape it cannot trust; `tolerate` migrations never do.
7760
- *
7761
- * ALWAYS pass the whole catalogue; a phase that must run only some of it passes
7762
- * `{ only: [ids] }` — never a filtered catalogue (the engine would judge the
7763
- * omitted applied ids "newer").
7776
+ * Several catalogues of ONE owner in one declaration (the engine replaces an owner's
7777
+ * catalogue on every declare, so two calls would each judge the other's ids "newer").
7778
+ * Build each entry with `migrationSet(catalogue, (api) => ports)`.
7764
7779
  */
7765
- async runMigrations(migrations, options) {
7780
+ async runMigrationSets(sets, options) {
7781
+ const api = this.ctx.migrationApi;
7782
+ if (api === void 0) throw new Error(`${this.ctx.id}: the migration API is not available on this context`);
7783
+ return this.runBound(sets.flatMap((set) => set.bind(api)), options);
7784
+ }
7785
+ async runBound(migrations, options) {
7766
7786
  const api = this.ctx.api.migrations;
7767
7787
  const report = await runAddonMigrations({
7768
7788
  declareOwner: (input) => api.declareOwner.mutate(input),
@@ -9167,6 +9187,20 @@ function defineRecordKinds(specs) {
9167
9187
  }
9168
9188
  return out;
9169
9189
  }
9190
+ /**
9191
+ * Entry kinds (D881): every list of user-created entries (notification
9192
+ * targets, brokers, LLM profiles) is ONE record kind with an id, a name and a
9193
+ * kind-specific body, and the admin UI lists/adds/edits/deletes all of them
9194
+ * through the `record-entries` capability with password fields derived from
9195
+ * the schema (`.meta({ secret: true })`).
9196
+ */
9197
+ /** The body of a plain entry: a name and the fields the kind adds. */
9198
+ function entryBody(shape) {
9199
+ return object({
9200
+ name: string().min(1),
9201
+ ...shape
9202
+ });
9203
+ }
9170
9204
  object({
9171
9205
  field: string().min(1),
9172
9206
  on: literal("advance")
@@ -12400,7 +12434,7 @@ function sleep(ms) {
12400
12434
  return new Promise((resolve) => setTimeout(resolve, Math.max(0, ms)));
12401
12435
  }
12402
12436
  //#endregion
12403
- //#region ../types/dist/composition-pOHbTzRB.mjs
12437
+ //#region ../types/dist/composition-BmBHuDTQ.mjs
12404
12438
  /**
12405
12439
  * The ffmpeg build every CamStack node downloads, per platform and arch.
12406
12440
  *
@@ -12833,7 +12867,7 @@ var table = {
12833
12867
  },
12834
12868
  dwell: {
12835
12869
  minArgs: 3,
12836
- maxArgs: 3,
12870
+ maxArgs: 4,
12837
12871
  apply: () => {
12838
12872
  throw new ExpressionEvalError("dwell: stateful evaluation context is required");
12839
12873
  }
@@ -13915,6 +13949,10 @@ var IntegrationInstanceRefSchema = object({
13915
13949
  ]),
13916
13950
  candidateStableId: string().optional()
13917
13951
  });
13952
+ object({
13953
+ cap: string().min(1),
13954
+ kind: string().min(1).optional()
13955
+ });
13918
13956
  var EncodeProfileSchema = object({
13919
13957
  video: object({
13920
13958
  codec: _enum([
@@ -16380,6 +16418,39 @@ var UnstampedEventMediaCountSchema = object({
16380
16418
  /** Sum across both, or `null` when either lane could not be counted. */
16381
16419
  total: number().int().nonnegative().nullable()
16382
16420
  }).nullable();
16421
+ /**
16422
+ * Where the stored event media sits, per storage location: how many media rows
16423
+ * and how many bytes carry each location id, how many carry none (legacy,
16424
+ * resolved to the default `eventMedia` location), and how many name a location
16425
+ * that was not asked about (a deleted or never-listed one).
16426
+ *
16427
+ * One covering-index aggregate per asked location plus the NULL one, and one
16428
+ * unfiltered total that scans the covering index: O(rows), not a walk of the
16429
+ * rows themselves. `unlisted` is total minus the ASKED locations minus NULL, so
16430
+ * it is a deleted location only when every location id was asked.
16431
+ * `null` is "could not be measured", never zero.
16432
+ */
16433
+ var MediaLocationCensusInputSchema = object({ locationIds: array(string().min(1)).max(50).readonly() });
16434
+ var MediaLocationCensusSchema = object({
16435
+ locations: array(object({
16436
+ locationId: string(),
16437
+ rows: number().int().nonnegative(),
16438
+ bytes: number().nonnegative()
16439
+ })).readonly(),
16440
+ unstamped: object({
16441
+ rows: number().int().nonnegative(),
16442
+ bytes: number().nonnegative()
16443
+ }),
16444
+ /** Rows stamped with a location id that was not in the asked list. */
16445
+ unlisted: object({
16446
+ rows: number().int().nonnegative(),
16447
+ bytes: number().nonnegative()
16448
+ }),
16449
+ total: object({
16450
+ rows: number().int().nonnegative(),
16451
+ bytes: number().nonnegative()
16452
+ })
16453
+ });
16383
16454
  var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
16384
16455
  /** The independently selectable logical storage classes — every class
16385
16456
  * `storage.listLocationDeclarations` reports, so an operator never meets a
@@ -46938,52 +47009,7 @@ DeviceType.Light, method(object({
46938
47009
  level: number().min(0).max(100),
46939
47010
  lastChangedAt: number()
46940
47011
  });
46941
- /**
46942
- * `broker` — unified pub/sub broker registry, system-scoped collection.
46943
- *
46944
- * The cap models any kind-tagged message broker the user wants to
46945
- * register and that other addons might consume. The first two kinds
46946
- * are MQTT (mosquitto / aedes embedded / cloud bridge) and
46947
- * Home Assistant (HA WebSocket — subscribe_entities + call_service).
46948
- * Future kinds (Zigbee2MQTT bridge, ZHA, KNX, Telegram, …) plug in
46949
- * the same surface.
46950
- *
46951
- * Why one cap, not one cap per kind:
46952
- * - The integrations page wants a single table of "every broker"
46953
- * across kinds; a unified cap drives it without join logic.
46954
- * - Generic admin operations (add / remove / test / status) are
46955
- * identical across kinds — duplicating them per cap was busywork.
46956
- * - The `network-access` cap precedent: same interface, many
46957
- * `providerKind: 'ingress'` implementations (Tailscale, ngrok, …).
46958
- *
46959
- * What stays kind-specific:
46960
- * - `getBrokerConfig` payload (kind decides whether it returns
46961
- * mqtt URL+creds, HA baseUrl+token, …) — typed as
46962
- * `Record<string, unknown>` at the wire; consumers narrow.
46963
- * - `publish` / `subscribe` / `getState` arguments (target / filter /
46964
- * key) — also typed as `Record<string, unknown>` so each kind can
46965
- * evolve its surface (MQTT topic+qos vs HA entity_id+domain)
46966
- * without rebreaking the cap signature.
46967
- * - `add` `settings` payload (different fields per kind, validated by
46968
- * the kind-specific provider).
46969
- *
46970
- * Bidirectionality:
46971
- * - `publish` is RPC — synchronous result (provider-defined).
46972
- * - `subscribe` returns a subscription handle; the actual message
46973
- * stream flows over the typed event-bus as `broker.message` events
46974
- * keyed by `(brokerId, subscriptionId)`. Consumers filter in their
46975
- * event handler. Subscriptions persist across reconnects — the
46976
- * provider re-subscribes upstream after a transport drop.
46977
- *
46978
- * Why event-bus push (not a subscription RPC stream):
46979
- * - Matches the rest of CamStack's D8 contract — events for telemetry,
46980
- * RPC for loss-is-a-bug. Broker messages are telemetry (a single
46981
- * drop is recoverable via `getState({key})`).
46982
- * - Frees `broker.subscribe` from holding a long-lived RPC channel.
46983
- * - Cross-process: events already route through `$event-bus`; no
46984
- * per-broker wire-shaping needed.
46985
- */
46986
- var BrokerStatusEnum = _enum([
47012
+ _enum([
46987
47013
  "connected",
46988
47014
  "disconnected",
46989
47015
  "connecting",
@@ -46991,141 +47017,12 @@ var BrokerStatusEnum = _enum([
46991
47017
  "unreachable",
46992
47018
  "error"
46993
47019
  ]);
46994
- var BrokerInfoSchema = object({
46995
- /** Stable broker id. Persisted; survives addon restarts. */
46996
- id: string(),
46997
- /** Addon id of the provider that OWNS this broker.
46998
- *
46999
- * The `broker` cap is a system-scoped collection: several addons
47000
- * register a `broker` provider, each owning a DISJOINT set of
47001
- * brokers (mqtt-broker owns `mqtt_*`, provider-homeassistant owns
47002
- * `ha_*`). A broker therefore belongs to exactly one addon — like a
47003
- * device belongs to one integration. The admin UI threads this id
47004
- * back as the `{ addonId }` system-collection selector on every
47005
- * id-keyed call (`get` / `getSettings` / `setSettings` / `remove` /
47006
- * `testConnection`), so the call routes to the OWNING provider
47007
- * instead of defaulting to the first-registered one. */
47008
- addonId: string(),
47009
- /** Human-readable name (operator-chosen at add-time). */
47010
- name: string(),
47011
- /** Provider-defined kind tag — `mqtt` / `home-assistant` / future. */
47012
- kind: string(),
47013
- status: BrokerStatusEnum,
47014
- /** Free-form provider-specific info (HA version, MQTT broker
47015
- * flavour, latency, mTLS active, …). */
47016
- info: record(string(), unknown()),
47017
- /** Ms epoch of the last connection probe / status update. */
47018
- lastCheckedAt: number().nullable(),
47019
- /** Last error message, when `status` indicates failure. */
47020
- error: string().nullable()
47021
- });
47022
47020
  var RegistryStatusSchema = object({
47023
47021
  brokerCount: number().int().nonnegative(),
47024
47022
  connectedCount: number().int().nonnegative()
47025
47023
  });
47026
- /**
47027
- * One entry per `broker` provider — which addon provides which broker
47028
- * kind(s). The unified create picker reads this to know, for each
47029
- * (addonId, kind) pair the operator can pick, where to route the
47030
- * follow-up `getSettingsSchema` / `testSettings` / `add` calls (via the
47031
- * `{ addonId }` selector). A provider only advertises a kind here when
47032
- * it implements `getSettingsSchema` for that kind (so the picker never
47033
- * offers a kind whose creation form can't be rendered).
47034
- */
47035
- var BrokerProviderInfoSchema = object({
47036
- /** Addon id of the `broker` provider this entry describes. */
47037
- addonId: string(),
47038
- /** Broker kinds this provider can create, with a display label. */
47039
- kinds: array(object({
47040
- kind: string(),
47041
- label: string(),
47042
- /**
47043
- * Relative hub path to start an interactive account link (OAuth popup).
47044
- * May include `{{brokerId}}`; admin-ui substitutes and appends `?popup=1`.
47045
- */
47046
- interactiveConnectPath: string().min(1).optional(),
47047
- /** Relative hub path to disconnect the linked account (same popup pattern). */
47048
- interactiveDisconnectPath: string().min(1).optional(),
47049
- /**
47050
- * The kind signs in through a server-held interactive session instead of
47051
- * (or before) typed credentials. `basePath` is a hub-relative route set
47052
- * served by the owning addon (`/addon/<id>/...`) speaking the sign-in
47053
- * contract: `POST {basePath}/start` (body: the form's settings) answers
47054
- * `{ sessionId, loginUrl }`; `GET {basePath}/status?sessionId=` answers
47055
- * `{ phase: 'starting' | 'awaiting-login' | 'captured' | 'error' |
47056
- * 'cancelled', loginUrl, error }`; `POST {basePath}/commit`
47057
- * (`{ sessionId, name, brokerId? }`) stores the credentials on a new or
47058
- * existing broker and answers `{ brokerId }`; `POST {basePath}/cancel`
47059
- * (`{ sessionId }`) drops the session. The dialog that edits a broker
47060
- * offers it as the default path; the fields the session fills are
47061
- * marked `filledBySignIn` in the kind's settings schema.
47062
- *
47063
- * `methods` lists the ways the session can sign in, recommended first:
47064
- * `'device-code'` adds `POST {basePath}/code/start` (body: the form's
47065
- * settings) answering `{ sessionId, userCode, verificationUrl,
47066
- * expiresAt }` — the operator types `userCode` at `verificationUrl` on
47067
- * any device, and the same `status` / `commit` / `cancel` routes follow
47068
- * (status then carries `method`, `userCode`, `verificationUrl`,
47069
- * `expiresAt` and the phases `'awaiting-code'` / `'expired'`);
47070
- * `'proxy'` is the `{basePath}/start` flow above. Absent means
47071
- * `['proxy']`.
47072
- */
47073
- signIn: object({
47074
- basePath: string().min(1),
47075
- methods: array(_enum(["device-code", "proxy"])).optional()
47076
- }).optional()
47077
- }))
47078
- });
47079
- var ListInputSchema = object({
47080
- /** Optional kind filter — `list({kind:'home-assistant'})` returns
47081
- * only HA brokers. Omit to list every broker. */
47082
- kind: string().optional() });
47083
47024
  var GetInputSchema = object({ id: string() });
47084
- var AddInputSchema = object({
47085
- kind: string().min(1),
47086
- name: string().min(1),
47087
- /**
47088
- * ADOPT an existing id instead of minting a new one.
47089
- *
47090
- * Written the day this cost an outage. A broker's id is not a detail: HA
47091
- * devices carry it inside their `stableId` (`ha:ha_004:dev:…`), so a broker
47092
- * lost from config and re-added as `ha_001` leaves every one of its devices
47093
- * bound to a broker that no longer exists. Re-entering the password under the
47094
- * ORIGINAL id turns a multi-step device migration back into re-entering a
47095
- * password.
47096
- *
47097
- * A provider MUST refuse an id that is already in use — adopting a live
47098
- * broker's id would silently take it over.
47099
- */
47100
- id: string().min(1).optional(),
47101
- /** Kind-specific settings (e.g. MQTT `{url,username,password}` or HA
47102
- * `{baseUrl,accessToken}`). Validated by the kind-specific provider
47103
- * branch on receipt — invalid shape rejects the add. */
47104
- settings: record(string(), unknown())
47105
- });
47106
- var AddResultSchema = object({ id: string() });
47107
- var RemoveInputSchema = object({ id: string() });
47108
- var TestConnectionResultSchema = discriminatedUnion("ok", [object({
47109
- ok: literal(true),
47110
- latencyMs: number().nonnegative()
47111
- }), object({
47112
- ok: literal(false),
47113
- error: string()
47114
- })]);
47115
47025
  var SettingsRecordSchema$1 = record(string(), unknown());
47116
- var SettingsSchemaInputSchema = object({ kind: string() });
47117
- var TestSettingsInputSchema = object({
47118
- kind: string(),
47119
- settings: SettingsRecordSchema$1
47120
- });
47121
- var TestSettingsResultSchema = discriminatedUnion("ok", [object({
47122
- ok: literal(true),
47123
- latencyMs: number().nonnegative().optional()
47124
- }).strict(), object({
47125
- ok: literal(false),
47126
- error: string()
47127
- })]);
47128
- var SettingsSchemaResultSchema = unknown().nullable();
47129
47026
  var PublishInputSchema = object({
47130
47027
  brokerId: string(),
47131
47028
  /** Kind-specific routing target.
@@ -47159,25 +47056,7 @@ var GetStateInputSchema = object({
47159
47056
  * HA: entity_id (returns the cached entity state). */
47160
47057
  key: string()
47161
47058
  });
47162
- method(ListInputSchema, array(BrokerInfoSchema)), method(GetInputSchema, BrokerInfoSchema.nullable()), method(_void(), array(BrokerProviderInfoSchema), { auth: "admin" }), method(AddInputSchema, AddResultSchema, {
47163
- kind: "mutation",
47164
- auth: "admin"
47165
- }), method(RemoveInputSchema, _void(), {
47166
- kind: "mutation",
47167
- auth: "admin"
47168
- }), method(GetInputSchema, TestConnectionResultSchema, {
47169
- kind: "mutation",
47170
- auth: "admin"
47171
- }), method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(object({
47172
- id: string(),
47173
- settings: SettingsRecordSchema$1
47174
- }), _void(), {
47175
- kind: "mutation",
47176
- auth: "admin"
47177
- }), method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(SettingsSchemaInputSchema, SettingsSchemaResultSchema, { auth: "admin" }), method(TestSettingsInputSchema, TestSettingsResultSchema, {
47178
- kind: "mutation",
47179
- auth: "admin"
47180
- }), method(PublishInputSchema, unknown(), {
47059
+ method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(PublishInputSchema, unknown(), {
47181
47060
  kind: "mutation",
47182
47061
  auth: "admin"
47183
47062
  }), method(SubscribeInputSchema, SubscribeResultSchema, {
@@ -49708,7 +49587,9 @@ var ThresholdTransformDraftSchema = object({
49708
49587
  comparison: _enum(["gte", "lte"]),
49709
49588
  threshold: number(),
49710
49589
  startDwellMs: number().nonnegative(),
49711
- stopDwellMs: number().nonnegative()
49590
+ stopDwellMs: number().nonnegative(),
49591
+ /** Samples a start needs; absent = the compiler's default for the source (2 for running power, else 1). */
49592
+ minSamples: number().int().min(1).optional()
49712
49593
  });
49713
49594
  var CustomizeTransformDraftSchema = discriminatedUnion("kind", [
49714
49595
  IdentityTransformDraftSchema,
@@ -51275,7 +51156,14 @@ var DiscoveryCandidateSchema = object({
51275
51156
  /** `stableId` of the gateway candidate this device was found BEHIND. */
51276
51157
  parentStableId: string().optional(),
51277
51158
  /** `false` = shown for context but not pickable. Default true. */
51278
- selectable: boolean().optional()
51159
+ selectable: boolean().optional(),
51160
+ /**
51161
+ * Keys of the provider's creation form (`getChildCreationSchema`) this candidate
51162
+ * cannot be adopted without — a key for an encrypted board, a pairing code. The
51163
+ * admin asks for exactly these, on the creation form prefilled with
51164
+ * `prefilledConfig`, before it adopts. Absent or empty = adopt as it is.
51165
+ */
51166
+ needsParams: array(string()).optional()
51279
51167
  });
51280
51168
  /**
51281
51169
  * Flat device summary returned by `createDevice` / `adoptDiscoveredDevice`.
@@ -51334,12 +51222,24 @@ method(_void(), _void(), { kind: "mutation" }), method(_void(), _void(), { kind:
51334
51222
  }), array(DiscoveryCandidateSchema), {
51335
51223
  kind: "mutation",
51336
51224
  auth: "admin"
51337
- }), method(object({}), CreationSchemaOutputSchema), method(object({}), object({ deviceType: _enum(DeviceType).nullable() })), method(object({ candidate: DiscoveryCandidateSchema }), DeviceSummarySchema, {
51225
+ }), method(object({}), CreationSchemaOutputSchema), method(object({
51226
+ /** The integration asked about; a provider whose integrations differ answers per one. */
51227
+ integrationId: string().optional() }), object({ deviceType: _enum(DeviceType).nullable() })), method(object({
51228
+ candidate: DiscoveryCandidateSchema,
51229
+ /** The integration the operator adopts into; a provider with several instances needs it. */
51230
+ integrationId: string().optional()
51231
+ }), DeviceSummarySchema, {
51338
51232
  kind: "mutation",
51339
51233
  auth: "admin"
51340
- }), method(object({}), boolean()), method(object({ type: _enum(DeviceType) }), CreationSchemaOutputSchema), method(object({
51234
+ }), method(object({}), boolean()), method(object({
51341
51235
  type: _enum(DeviceType),
51342
- config: record(string(), unknown())
51236
+ /** The integration asked about; a provider whose integrations differ answers per one. */
51237
+ integrationId: string().optional()
51238
+ }), CreationSchemaOutputSchema), method(object({
51239
+ type: _enum(DeviceType),
51240
+ config: record(string(), unknown()),
51241
+ /** The integration the operator adds the device to; a provider with several instances needs it. */
51242
+ integrationId: string().optional()
51343
51243
  }), DeviceSummarySchema, {
51344
51244
  kind: "mutation",
51345
51245
  auth: "admin"
@@ -52049,7 +51949,10 @@ method(object({
52049
51949
  auth: "admin"
52050
51950
  }), method(object({
52051
51951
  addonId: string(),
52052
- type: _enum(DeviceType)
51952
+ type: _enum(DeviceType),
51953
+ /** The integration the form is for; a provider whose integrations differ (a hub
51954
+ * integration takes no manual add) answers per integration. Absent = the addon's own. */
51955
+ integrationId: string().optional()
52053
51956
  }), unknown().nullable()), method(object({
52054
51957
  addonId: string(),
52055
51958
  type: _enum(DeviceType),
@@ -52133,7 +52036,11 @@ method(object({
52133
52036
  kind: "mutation",
52134
52037
  auth: "admin",
52135
52038
  timeoutMs: 12e4
52136
- }), method(object({ addonId: string() }), object({ deviceType: _enum(DeviceType).nullable() }), { auth: "admin" }), method(object({ addonId: string() }), unknown(), { auth: "admin" }), method(object({
52039
+ }), method(object({
52040
+ addonId: string(),
52041
+ /** The integration the Add-Device dialog is open on; absent = the addon's own. */
52042
+ integrationId: string().optional()
52043
+ }), object({ deviceType: _enum(DeviceType).nullable() }), { auth: "admin" }), method(object({ addonId: string() }), unknown(), { auth: "admin" }), method(object({
52137
52044
  deviceId: number(),
52138
52045
  key: string(),
52139
52046
  value: unknown()
@@ -55006,7 +54913,7 @@ var TestConnectionStatusEnum = _enum([
55006
54913
  "inconclusive",
55007
54914
  "unsupported"
55008
54915
  ]);
55009
- var TestConnectionResultSchema$1 = object({
54916
+ var TestConnectionResultSchema = object({
55010
54917
  /** True ONLY for `validated`. Never true for a test that did not run. */
55011
54918
  success: boolean(),
55012
54919
  error: string().optional(),
@@ -55051,7 +54958,7 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
55051
54958
  }), method(_void(), array(AvailableIntegrationTypeSchema), { auth: "admin" }), method(object({
55052
54959
  addonId: string(),
55053
54960
  settings: record(string(), unknown())
55054
- }), TestConnectionResultSchema$1, {
54961
+ }), TestConnectionResultSchema, {
55055
54962
  kind: "mutation",
55056
54963
  auth: "admin"
55057
54964
  });
@@ -55078,6 +54985,14 @@ var ConfigSchemaPassthrough$3 = custom();
55078
54985
  var IntegrationInstanceIdSchema = string().min(1);
55079
54986
  var IntegrationInstanceModeSchema = _enum(["single", "multiple"]);
55080
54987
  /**
54988
+ * What the addon's instances ARE for the Integrations page (planning#416). `devices`: each
54989
+ * instance is an integration that brings devices (the registry owns its on/off switch);
54990
+ * `services`: a connection configured from the addon's own function page, never listed on
54991
+ * Integrations.
54992
+ * It is the same vocabulary as the manifest's `integrationRole`, which stays as an override.
54993
+ */
54994
+ var IntegrationInstanceRoleSchema = _enum(["devices", "services"]);
54995
+ /**
55081
54996
  * One kind of instance a provider can create (an adapter, an account type). The sign-in and
55082
54997
  * connect fields follow the `broker` contract (`broker.cap.ts`): `signIn.basePath` is a
55083
54998
  * hub-relative route set speaking the sign-in contract, `connectPath` / `disconnectPath` open an
@@ -55088,6 +55003,22 @@ var IntegrationInstanceKindSchema = object({
55088
55003
  /** Stable id of the kind, sent back as `createInstance.kind`. */
55089
55004
  id: string().min(1),
55090
55005
  label: string().min(1),
55006
+ /**
55007
+ * The function capability this kind is configured for (`broker`, `smtp-provider`,
55008
+ * `device-provider`, ...). A page section is the kinds whose `functionCap` it names (D1013); a
55009
+ * provider with more than one section must name it on every kind.
55010
+ */
55011
+ functionCap: string().min(1),
55012
+ /**
55013
+ * For `functionCap: 'broker'`: the registry kind of the broker an instance of this kind is
55014
+ * (`matter`, `home-assistant`, ...). A caller that needs a broker of one kind (a link field)
55015
+ * finds the instances whose kind names it; absent takes the kind `id`.
55016
+ */
55017
+ brokerKind: string().min(1).optional(),
55018
+ /** What instances of this kind are for the Integrations page; absent takes the provider's `role`. */
55019
+ role: IntegrationInstanceRoleSchema.optional(),
55020
+ /** `testInstance` really probes the remote for this kind; absent takes the provider's `canTest`. */
55021
+ canTest: boolean().optional(),
55091
55022
  /** The kind signs in through a server-held interactive session. */
55092
55023
  signIn: object({
55093
55024
  basePath: string().min(1),
@@ -55098,22 +55029,38 @@ var IntegrationInstanceKindSchema = object({
55098
55029
  /** Relative hub path to disconnect that account. */
55099
55030
  disconnectPath: string().min(1).optional()
55100
55031
  });
55032
+ /**
55033
+ * How devices of an instance are found. `none`: the operator adds them by hand; `lan`: the addon
55034
+ * scans the network before any instance exists (the wizard offers the candidates); `account`: the
55035
+ * devices appear after the instance signs in. `scopedToInstance`: a discovery run belongs to ONE
55036
+ * instance and its candidates are claimed by it.
55037
+ */
55038
+ var IntegrationInstanceDiscoverySchema = object({
55039
+ mode: _enum([
55040
+ "none",
55041
+ "lan",
55042
+ "account"
55043
+ ]),
55044
+ scopedToInstance: boolean()
55045
+ });
55046
+ /**
55047
+ * One link a kind of this provider declares (D1013 rule 5): the body `field` of an instance of
55048
+ * `kind` holds the id of an instance of the function cap `to.cap` (of kind `to.kind`, when set).
55049
+ * The hub indexes these so the target's delete is refused while a link names it.
55050
+ */
55051
+ var IntegrationInstanceLinkSchema = object({
55052
+ kind: string().min(1),
55053
+ field: string().min(1),
55054
+ to: object({
55055
+ cap: string().min(1),
55056
+ kind: string().min(1).optional()
55057
+ })
55058
+ });
55101
55059
  var IntegrationInstanceDescriptionSchema = object({
55102
55060
  /** What the instances are for the Integrations page; see {@link IntegrationInstanceRoleSchema}. */
55103
- role: _enum([
55104
- "devices",
55105
- "services",
55106
- "both"
55107
- ]),
55061
+ role: IntegrationInstanceRoleSchema,
55108
55062
  /** How the devices of an instance are found; absent means `{ mode: 'none' }`. */
55109
- discovery: object({
55110
- mode: _enum([
55111
- "none",
55112
- "lan",
55113
- "account"
55114
- ]),
55115
- scopedToInstance: boolean()
55116
- }).optional(),
55063
+ discovery: IntegrationInstanceDiscoverySchema.optional(),
55117
55064
  /** `single`: at most one instance can exist (Loki). `multiple`: an account each. */
55118
55065
  instanceMode: IntegrationInstanceModeSchema,
55119
55066
  /** What the instance is, for the UI (`destination`, `relay`, `account`). */
@@ -55134,7 +55081,9 @@ var IntegrationInstanceDescriptionSchema = object({
55134
55081
  * `createInstance` without an `id` works: the provider mints it. Absent means the caller must
55135
55082
  * send an id (the UI then mints an opaque one).
55136
55083
  */
55137
- mintsId: boolean().optional()
55084
+ mintsId: boolean().optional(),
55085
+ /** The links to other instances the provider's kinds declare; absent means none. */
55086
+ links: array(IntegrationInstanceLinkSchema).optional()
55138
55087
  });
55139
55088
  var IntegrationInstanceStatusSchema = object({
55140
55089
  state: _enum([
@@ -55172,10 +55121,16 @@ var IntegrationInstancePatchSchema = object({
55172
55121
  /** Omitted / '' / redaction token keeps a secret; `{ $secretClear: true }` clears it. */
55173
55122
  values: record(string(), unknown())
55174
55123
  });
55175
- 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({
55124
+ method(_void(), IntegrationInstanceDescriptionSchema, { auth: "admin" }), method(object({
55125
+ id: IntegrationInstanceIdSchema.nullable(),
55126
+ /** The kind of the create form (`id: null`) of a provider with several. */
55127
+ kind: string().min(1).optional()
55128
+ }), ConfigSchemaPassthrough$3, { auth: "admin" }), method(_void(), array(IntegrationInstanceSchema).readonly(), { auth: "admin" }), method(object({ id: IntegrationInstanceIdSchema }), IntegrationInstanceSchema.nullable(), { auth: "admin" }), method(object({
55176
55129
  id: IntegrationInstanceIdSchema.optional(),
55177
55130
  name: string().min(1),
55178
- kind: string().min(1).optional()
55131
+ kind: string().min(1).optional(),
55132
+ /** Form values written with the record (a link picked in the create dialog). */
55133
+ values: record(string(), unknown()).optional()
55179
55134
  }), object({ id: string() }), {
55180
55135
  kind: "mutation",
55181
55136
  auth: "admin"
@@ -55193,8 +55148,10 @@ method(_void(), IntegrationInstanceDescriptionSchema, { auth: "admin" }), method
55193
55148
  auth: "admin"
55194
55149
  }), optionalMethod(object({
55195
55150
  id: IntegrationInstanceIdSchema.nullable(),
55196
- values: record(string(), unknown())
55197
- }), TestConnectionResultSchema$1, {
55151
+ values: record(string(), unknown()),
55152
+ /** The kind to test when `id` is null and the provider has several. */
55153
+ kind: string().min(1).optional()
55154
+ }), TestConnectionResultSchema, {
55198
55155
  kind: "mutation",
55199
55156
  auth: "admin"
55200
55157
  });
@@ -57697,6 +57654,380 @@ var SystemMetricsSchema = object({
57697
57654
  gpuMemoryPercent: number().optional()
57698
57655
  });
57699
57656
  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);
57657
+ /**
57658
+ * records - an addon's own facts and documents (D881): ledgers, audit rows,
57659
+ * config documents, mirrors. The third storage API next to `ctx.settings`
57660
+ * (operator intent, D870) and device-history (numbers over time, D850).
57661
+ *
57662
+ * Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
57663
+ * crossed a process and stated by a hub in-process caller (`ctx.records` does
57664
+ * that with the addon id closed over). It is deliberately NOT in any input
57665
+ * schema, so a session can never supply it, and a call with no stamp is refused
57666
+ * `records/no-caller`. A kind is readable and writable only by its owner; other
57667
+ * addons go through the owner's capability.
57668
+ *
57669
+ * Every read is three-way: a row, `null`, or the call THROWS. A failed read is
57670
+ * never `[]`. Secret fields are never on the wire: a read shows the
57671
+ * redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
57672
+ * resolves itself, and a write may carry only a keychain marker bound to the
57673
+ * row's own ref.
57674
+ *
57675
+ * Internal: addons reach it through `ctx.records`, never directly.
57676
+ */
57677
+ var RecordIdSchema = string().min(1).max(256);
57678
+ /** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
57679
+ var RecordBodySchema = record(string(), unknown());
57680
+ var RecordInputSchema = object({
57681
+ id: RecordIdSchema,
57682
+ /** The device this row belongs to (D865 removal, per-device reads). */
57683
+ deviceId: number().int().optional(),
57684
+ /** The domain clock, ms: observed / created / opened. */
57685
+ at: number().int().optional(),
57686
+ /** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
57687
+ expiresAt: number().int().optional(),
57688
+ data: RecordBodySchema
57689
+ });
57690
+ var RecordViewSchema = object({
57691
+ id: string(),
57692
+ deviceId: number().int().nullable(),
57693
+ at: number().nullable(),
57694
+ expiresAt: number().nullable(),
57695
+ rev: number().int(),
57696
+ updatedAt: number(),
57697
+ data: RecordBodySchema
57698
+ });
57699
+ /** Declared index fields only. Anything else does not compile, by design. */
57700
+ var RecordWhereSchema = record(RecordFieldPathSchema, union([
57701
+ string(),
57702
+ number(),
57703
+ boolean(),
57704
+ object({ in: array(union([
57705
+ string(),
57706
+ number(),
57707
+ boolean()
57708
+ ])).min(1).max(RECORD_BATCH_MAX) }),
57709
+ object({
57710
+ gt: union([string(), number()]).optional(),
57711
+ gte: union([string(), number()]).optional(),
57712
+ lt: union([string(), number()]).optional(),
57713
+ lte: union([string(), number()]).optional()
57714
+ }).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
57715
+ ]));
57716
+ var KindShape = { kind: RecordKindNameSchema };
57717
+ var TimeWindowShape = {
57718
+ deviceId: number().int().optional(),
57719
+ atFrom: number().optional(),
57720
+ atTo: number().optional()
57721
+ };
57722
+ var RecordQueryInputSchema = object({
57723
+ ...KindShape,
57724
+ ...TimeWindowShape,
57725
+ where: RecordWhereSchema.optional(),
57726
+ /** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
57727
+ order: _enum(["at", "id"]).optional(),
57728
+ desc: boolean().optional(),
57729
+ limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
57730
+ /** Opaque keyset cursor from a previous answer. There is no offset. */
57731
+ cursor: string().min(1).optional()
57732
+ });
57733
+ var RecordQueryResultSchema = object({
57734
+ records: array(RecordViewSchema),
57735
+ nextCursor: string().nullable()
57736
+ });
57737
+ var RecordKindStateSchema = _enum([
57738
+ "created",
57739
+ "unchanged",
57740
+ "updated"
57741
+ ]);
57742
+ var DeclareKindResultSchema = object({
57743
+ kindId: number().int(),
57744
+ state: RecordKindStateSchema,
57745
+ createdIndexes: array(string())
57746
+ });
57747
+ /** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
57748
+ var SecretRefsList = array(string());
57749
+ /**
57750
+ * One op of a `transact`: the single-row writes, each on a kind of the caller.
57751
+ * All ops of one call share ONE database file and ONE `transactFamily`.
57752
+ */
57753
+ var RecordTransactOpSchema = discriminatedUnion("op", [
57754
+ object({
57755
+ op: literal("put"),
57756
+ kind: RecordKindNameSchema,
57757
+ record: RecordInputSchema,
57758
+ ifRev: number().int().min(0).optional()
57759
+ }),
57760
+ object({
57761
+ op: literal("patch"),
57762
+ kind: RecordKindNameSchema,
57763
+ id: RecordIdSchema,
57764
+ data: RecordBodySchema,
57765
+ at: number().int().nullable().optional(),
57766
+ expiresAt: number().int().nullable().optional(),
57767
+ ifRev: number().int().min(1).optional()
57768
+ }),
57769
+ object({
57770
+ op: literal("delete"),
57771
+ kind: RecordKindNameSchema,
57772
+ id: RecordIdSchema
57773
+ })
57774
+ ]);
57775
+ var RecordSecretRefsSchema = record(string(), record(string(), string()));
57776
+ method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
57777
+ kind: "mutation",
57778
+ auth: "admin"
57779
+ }), method(object({
57780
+ ...KindShape,
57781
+ id: RecordIdSchema
57782
+ }), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
57783
+ ...KindShape,
57784
+ ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
57785
+ }), array(RecordViewSchema), { auth: "admin" }), method(object({
57786
+ ...KindShape,
57787
+ ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
57788
+ }), RecordSecretRefsSchema, { auth: "admin" }), method(object({
57789
+ ...KindShape,
57790
+ record: RecordInputSchema,
57791
+ /** Compare-and-set. `0` means "the row must not exist". */
57792
+ ifRev: number().int().min(0).optional()
57793
+ }), object({
57794
+ rev: number().int(),
57795
+ releasedRefs: SecretRefsList
57796
+ }), {
57797
+ kind: "mutation",
57798
+ auth: "admin"
57799
+ }), method(object({
57800
+ ...KindShape,
57801
+ records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
57802
+ }), object({
57803
+ count: number().int(),
57804
+ releasedRefs: SecretRefsList
57805
+ }), {
57806
+ kind: "mutation",
57807
+ auth: "admin"
57808
+ }), method(object({
57809
+ ...KindShape,
57810
+ id: RecordIdSchema,
57811
+ data: RecordBodySchema,
57812
+ at: number().int().nullable().optional(),
57813
+ expiresAt: number().int().nullable().optional(),
57814
+ ifRev: number().int().min(1).optional()
57815
+ }), object({
57816
+ rev: number().int(),
57817
+ releasedRefs: SecretRefsList
57818
+ }), {
57819
+ kind: "mutation",
57820
+ auth: "admin"
57821
+ }), method(object({
57822
+ ...KindShape,
57823
+ id: RecordIdSchema
57824
+ }), object({
57825
+ deleted: boolean(),
57826
+ secretRefs: SecretRefsList
57827
+ }), {
57828
+ kind: "mutation",
57829
+ auth: "admin"
57830
+ }), method(object({
57831
+ ...KindShape,
57832
+ ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
57833
+ }), object({
57834
+ deleted: number().int(),
57835
+ secretRefs: SecretRefsList
57836
+ }), {
57837
+ kind: "mutation",
57838
+ auth: "admin"
57839
+ }), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
57840
+ ...KindShape,
57841
+ ...TimeWindowShape,
57842
+ where: RecordWhereSchema.optional()
57843
+ }), object({ count: number().int() }), { auth: "admin" }), method(object({
57844
+ ...KindShape,
57845
+ deviceId: number().int().optional(),
57846
+ from: number(),
57847
+ to: number(),
57848
+ bucketMs: number().int().positive()
57849
+ }), object({ buckets: array(object({
57850
+ bucketStart: number(),
57851
+ count: number().int()
57852
+ })) }), { auth: "admin" }), method(object({
57853
+ ...KindShape,
57854
+ op: _enum([
57855
+ "sum",
57856
+ "min",
57857
+ "max",
57858
+ "count"
57859
+ ]),
57860
+ field: RecordFieldPathSchema.optional(),
57861
+ groupBy: RecordFieldPathSchema.optional(),
57862
+ where: RecordWhereSchema.optional()
57863
+ }), object({ rows: array(object({
57864
+ group: union([
57865
+ string(),
57866
+ number(),
57867
+ _null()
57868
+ ]),
57869
+ value: number().nullable()
57870
+ })) }), { auth: "admin" }), method(object({
57871
+ ...KindShape,
57872
+ deviceId: number().int().optional(),
57873
+ atBefore: number().optional(),
57874
+ where: RecordWhereSchema.optional()
57875
+ }), object({
57876
+ deleted: number().int(),
57877
+ secretRefs: SecretRefsList
57878
+ }), {
57879
+ kind: "mutation",
57880
+ auth: "admin"
57881
+ }), method(object({ ops: array(RecordTransactOpSchema).min(1).max(RECORD_BATCH_MAX) }), object({
57882
+ results: array(object({
57883
+ rev: number().int().nullable(),
57884
+ deleted: boolean()
57885
+ })),
57886
+ releasedRefs: SecretRefsList,
57887
+ secretRefs: SecretRefsList
57888
+ }), {
57889
+ kind: "mutation",
57890
+ auth: "admin"
57891
+ }), method(object({
57892
+ deviceId: number().int(),
57893
+ kinds: array(RecordKindNameSchema).optional()
57894
+ }), object({
57895
+ deleted: record(string(), number().int()),
57896
+ secretRefs: SecretRefsList
57897
+ }), {
57898
+ kind: "mutation",
57899
+ auth: "admin"
57900
+ }), method(object(KindShape), object({ id: number().int() }), {
57901
+ kind: "mutation",
57902
+ auth: "admin"
57903
+ });
57904
+ /**
57905
+ * The wire shapes of the migration API, version 1 (planning#447).
57906
+ *
57907
+ * A migration is code that outlives the server it was written against: an addon at
57908
+ * version 1.4 that is brought to 1.9 in one jump still runs its 1.4 catalogue, against
57909
+ * the 1.9 kernel. The only thing that code may call is {@link MigrationApiV1}; this file
57910
+ * is the contract of every method of it, one Zod pair per method.
57911
+ *
57912
+ * APPEND-ONLY. A released method is never removed and never changes meaning: an input
57913
+ * field is never removed or made required, an enum never narrows, an output field is
57914
+ * never removed. A change that cannot be expressed that way is `migration-api.v2`, next
57915
+ * to this file. `scripts/check-migration-api-append-only.ts` holds the line against
57916
+ * `scripts/migration-api-contract.json`, and every `behaviours` id below must have an
57917
+ * `it('<id>'` in `migration-api.contract.spec.ts`.
57918
+ */
57919
+ var Rows = record(string(), unknown());
57920
+ var IntegrationId = object({ integrationId: string().min(1) });
57921
+ var RecordId = object({ id: string().min(1) });
57922
+ var RecordRowSchema = object({
57923
+ id: string(),
57924
+ deviceId: number().int().nullable(),
57925
+ at: number().nullable(),
57926
+ expiresAt: number().nullable(),
57927
+ rev: number().int(),
57928
+ updatedAt: number(),
57929
+ data: Rows
57930
+ });
57931
+ var RecordPutShape = {
57932
+ id: string().min(1),
57933
+ deviceId: number().int().optional(),
57934
+ at: number().int().optional(),
57935
+ expiresAt: number().int().optional(),
57936
+ data: Rows
57937
+ };
57938
+ var MigrationIntegrationSchema = object({
57939
+ id: string(),
57940
+ addonId: string(),
57941
+ name: string(),
57942
+ info: Rows,
57943
+ originStableId: string().optional()
57944
+ });
57945
+ var MigrationDeviceSchema = object({
57946
+ id: number().int(),
57947
+ integrationId: string().nullable().optional(),
57948
+ /** The owning device; null or absent for a root. */
57949
+ parentDeviceId: number().int().nullable().optional(),
57950
+ type: string().optional(),
57951
+ name: string().optional(),
57952
+ stableId: string().optional()
57953
+ });
57954
+ /** What the engine says about the migration API it serves: lets an addon notice an older server. */
57955
+ var MigrationApiInfoSchema = object({
57956
+ version: number().int(),
57957
+ methods: array(string())
57958
+ });
57959
+ object({
57960
+ message: string(),
57961
+ meta: Rows.optional(),
57962
+ /** Grouping tags of the line; a line about a device carries `{ deviceId }`. */
57963
+ tags: object({ deviceId: number().int().optional() }).optional()
57964
+ });
57965
+ object({
57966
+ owner: string().min(1),
57967
+ metas: array(MigrationMetaSchema)
57968
+ }), object({
57969
+ bootId: string(),
57970
+ snapshot: _enum([
57971
+ "none",
57972
+ "written",
57973
+ "refused"
57974
+ ]),
57975
+ steps: array(MigrationOwnerStepSchema),
57976
+ /** The migration API the engine serves; absent from a server that predates it. */
57977
+ migrationApi: MigrationApiInfoSchema.optional()
57978
+ }), object({ id: string().min(1) }), object({
57979
+ proceed: boolean(),
57980
+ state: union([literal("pending"), MigrationStatusSchema]),
57981
+ reason: string().nullable()
57982
+ }), object({
57983
+ id: string().min(1),
57984
+ result: MigrationOwnerResultSchema
57985
+ }), object({
57986
+ status: MigrationStatusSchema,
57987
+ error: string().nullable(),
57988
+ rowsChanged: number().int().nonnegative()
57989
+ }), object({
57990
+ rows: number().int().nonnegative(),
57991
+ secrets: number().int().nonnegative()
57992
+ }), IntegrationId.extend({ patch: Rows }), object({ written: boolean() }), IntegrationId.extend({ keys: array(string().min(1)) }), object({
57993
+ present: boolean(),
57994
+ removed: Rows
57995
+ }), RecordRowSchema.nullable(), RecordRowSchema.nullable(), object({
57996
+ ...RecordPutShape,
57997
+ ifRev: number().int().optional()
57998
+ }), object({ rev: number().int() }), object({ records: array(object(RecordPutShape)) }), object({ count: number().int().nonnegative() }), RecordId.extend({
57999
+ partial: Rows,
58000
+ ifRev: number().int().optional()
58001
+ }), object({ rev: number().int() }), object({ deleted: boolean() }), object({
58002
+ deviceId: number().int().optional(),
58003
+ atFrom: number().optional(),
58004
+ atTo: number().optional(),
58005
+ where: RecordWhereSchema.optional(),
58006
+ limit: number().int().min(1).optional(),
58007
+ cursor: string().min(1).optional(),
58008
+ resolveSecrets: boolean().optional()
58009
+ }), object({
58010
+ records: array(RecordRowSchema),
58011
+ nextCursor: string().nullable()
58012
+ }), object({
58013
+ deviceId: number().int().optional(),
58014
+ atBefore: number().optional(),
58015
+ where: RecordWhereSchema.optional()
58016
+ }), 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({
58017
+ ref: string().min(1),
58018
+ value: string()
58019
+ }), object({}), object({ refs: array(string()) }), object({ deleted: number().int().nonnegative() }), object({}), object({ integrations: array(MigrationIntegrationSchema) }), object({ id: string().min(1) }), MigrationIntegrationSchema.nullable(), object({
58020
+ addonId: string().min(1),
58021
+ integrationId: string().min(1).optional()
58022
+ }), object({ devices: array(MigrationDeviceSchema) }), object({ deviceId: number().int() }), object({
58023
+ id: number().int(),
58024
+ integrationId: string().nullable(),
58025
+ /** Whether the device carries any stored config; its content is not offered. */
58026
+ hasConfig: boolean()
58027
+ }).nullable(), object({
58028
+ deviceId: number().int(),
58029
+ integrationId: string().min(1)
58030
+ }), object({}), object({}), object({ nodeId: string() }), object({}), object({});
57700
58031
  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({
57701
58032
  id: string().min(1),
57702
58033
  error: string().min(1)
@@ -57726,7 +58057,9 @@ method(object({}), object({ entries: array(MigrationLedgerEntrySchema) }), { aut
57726
58057
  "written",
57727
58058
  "refused"
57728
58059
  ]),
57729
- steps: array(MigrationOwnerStepSchema)
58060
+ steps: array(MigrationOwnerStepSchema),
58061
+ /** The migration API this engine serves (additive: a server that predates it omits it). */
58062
+ migrationApi: MigrationApiInfoSchema.optional()
57730
58063
  }), {
57731
58064
  kind: "mutation",
57732
58065
  auth: "admin"
@@ -60443,7 +60776,10 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
60443
60776
  }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
60444
60777
  kind: "mutation",
60445
60778
  auth: "admin"
60446
- }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
60779
+ }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(MediaLocationCensusInputSchema, MediaLocationCensusSchema, {
60780
+ kind: "query",
60781
+ auth: "admin"
60782
+ }), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
60447
60783
  kind: "query",
60448
60784
  auth: "admin"
60449
60785
  }), method(object({}), array(RelocateJobSchema).readonly(), {
@@ -63268,7 +63604,7 @@ var BrokerStatusSchema$1 = _enum([
63268
63604
  "unreachable",
63269
63605
  "tls-error"
63270
63606
  ]);
63271
- var BrokerInfoSchema$1 = object({
63607
+ var BrokerInfoSchema = object({
63272
63608
  id: string(),
63273
63609
  name: string(),
63274
63610
  url: string(),
@@ -63331,7 +63667,7 @@ var StatusSchema = object({
63331
63667
  brokerCount: number(),
63332
63668
  embeddedRunning: boolean()
63333
63669
  });
63334
- method(_void(), array(BrokerInfoSchema$1)), method(IdInputSchema, BrokerConnectionDetailsSchema, { auth: "admin" }), method(AddBrokerInputSchema, AddBrokerResultSchema, {
63670
+ method(_void(), array(BrokerInfoSchema)), method(IdInputSchema, BrokerConnectionDetailsSchema, { auth: "admin" }), method(AddBrokerInputSchema, AddBrokerResultSchema, {
63335
63671
  kind: "mutation",
63336
63672
  auth: "admin"
63337
63673
  }), method(IdInputSchema, _void(), {
@@ -70854,253 +71190,6 @@ DeviceType.Camera, DeviceType.Sensor, DeviceType.Switch, DeviceType.Gateway, met
70854
71190
  auth: "admin"
70855
71191
  });
70856
71192
  /**
70857
- * records - an addon's own facts and documents (D881): ledgers, audit rows,
70858
- * config documents, mirrors. The third storage API next to `ctx.settings`
70859
- * (operator intent, D870) and device-history (numbers over time, D850).
70860
- *
70861
- * Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
70862
- * crossed a process and stated by a hub in-process caller (`ctx.records` does
70863
- * that with the addon id closed over). It is deliberately NOT in any input
70864
- * schema, so a session can never supply it, and a call with no stamp is refused
70865
- * `records/no-caller`. A kind is readable and writable only by its owner; other
70866
- * addons go through the owner's capability.
70867
- *
70868
- * Every read is three-way: a row, `null`, or the call THROWS. A failed read is
70869
- * never `[]`. Secret fields are never on the wire: a read shows the
70870
- * redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
70871
- * resolves itself, and a write may carry only a keychain marker bound to the
70872
- * row's own ref.
70873
- *
70874
- * Internal: addons reach it through `ctx.records`, never directly.
70875
- */
70876
- var RecordIdSchema = string().min(1).max(256);
70877
- /** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
70878
- var RecordBodySchema = record(string(), unknown());
70879
- var RecordInputSchema = object({
70880
- id: RecordIdSchema,
70881
- /** The device this row belongs to (D865 removal, per-device reads). */
70882
- deviceId: number().int().optional(),
70883
- /** The domain clock, ms: observed / created / opened. */
70884
- at: number().int().optional(),
70885
- /** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
70886
- expiresAt: number().int().optional(),
70887
- data: RecordBodySchema
70888
- });
70889
- var RecordViewSchema = object({
70890
- id: string(),
70891
- deviceId: number().int().nullable(),
70892
- at: number().nullable(),
70893
- expiresAt: number().nullable(),
70894
- rev: number().int(),
70895
- updatedAt: number(),
70896
- data: RecordBodySchema
70897
- });
70898
- /** Declared index fields only. Anything else does not compile, by design. */
70899
- var RecordWhereSchema = record(RecordFieldPathSchema, union([
70900
- string(),
70901
- number(),
70902
- boolean(),
70903
- object({ in: array(union([
70904
- string(),
70905
- number(),
70906
- boolean()
70907
- ])).min(1).max(RECORD_BATCH_MAX) }),
70908
- object({
70909
- gt: union([string(), number()]).optional(),
70910
- gte: union([string(), number()]).optional(),
70911
- lt: union([string(), number()]).optional(),
70912
- lte: union([string(), number()]).optional()
70913
- }).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
70914
- ]));
70915
- var KindShape = { kind: RecordKindNameSchema };
70916
- var TimeWindowShape = {
70917
- deviceId: number().int().optional(),
70918
- atFrom: number().optional(),
70919
- atTo: number().optional()
70920
- };
70921
- var RecordQueryInputSchema = object({
70922
- ...KindShape,
70923
- ...TimeWindowShape,
70924
- where: RecordWhereSchema.optional(),
70925
- /** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
70926
- order: _enum(["at", "id"]).optional(),
70927
- desc: boolean().optional(),
70928
- limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
70929
- /** Opaque keyset cursor from a previous answer. There is no offset. */
70930
- cursor: string().min(1).optional()
70931
- });
70932
- var RecordQueryResultSchema = object({
70933
- records: array(RecordViewSchema),
70934
- nextCursor: string().nullable()
70935
- });
70936
- var RecordKindStateSchema = _enum([
70937
- "created",
70938
- "unchanged",
70939
- "updated"
70940
- ]);
70941
- var DeclareKindResultSchema = object({
70942
- kindId: number().int(),
70943
- state: RecordKindStateSchema,
70944
- createdIndexes: array(string())
70945
- });
70946
- /** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
70947
- var SecretRefsList = array(string());
70948
- /**
70949
- * One op of a `transact`: the single-row writes, each on a kind of the caller.
70950
- * All ops of one call share ONE database file and ONE `transactFamily`.
70951
- */
70952
- var RecordTransactOpSchema = discriminatedUnion("op", [
70953
- object({
70954
- op: literal("put"),
70955
- kind: RecordKindNameSchema,
70956
- record: RecordInputSchema,
70957
- ifRev: number().int().min(0).optional()
70958
- }),
70959
- object({
70960
- op: literal("patch"),
70961
- kind: RecordKindNameSchema,
70962
- id: RecordIdSchema,
70963
- data: RecordBodySchema,
70964
- at: number().int().nullable().optional(),
70965
- expiresAt: number().int().nullable().optional(),
70966
- ifRev: number().int().min(1).optional()
70967
- }),
70968
- object({
70969
- op: literal("delete"),
70970
- kind: RecordKindNameSchema,
70971
- id: RecordIdSchema
70972
- })
70973
- ]);
70974
- var RecordSecretRefsSchema = record(string(), record(string(), string()));
70975
- method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
70976
- kind: "mutation",
70977
- auth: "admin"
70978
- }), method(object({
70979
- ...KindShape,
70980
- id: RecordIdSchema
70981
- }), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
70982
- ...KindShape,
70983
- ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
70984
- }), array(RecordViewSchema), { auth: "admin" }), method(object({
70985
- ...KindShape,
70986
- ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
70987
- }), RecordSecretRefsSchema, { auth: "admin" }), method(object({
70988
- ...KindShape,
70989
- record: RecordInputSchema,
70990
- /** Compare-and-set. `0` means "the row must not exist". */
70991
- ifRev: number().int().min(0).optional()
70992
- }), object({
70993
- rev: number().int(),
70994
- releasedRefs: SecretRefsList
70995
- }), {
70996
- kind: "mutation",
70997
- auth: "admin"
70998
- }), method(object({
70999
- ...KindShape,
71000
- records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
71001
- }), object({
71002
- count: number().int(),
71003
- releasedRefs: SecretRefsList
71004
- }), {
71005
- kind: "mutation",
71006
- auth: "admin"
71007
- }), method(object({
71008
- ...KindShape,
71009
- id: RecordIdSchema,
71010
- data: RecordBodySchema,
71011
- at: number().int().nullable().optional(),
71012
- expiresAt: number().int().nullable().optional(),
71013
- ifRev: number().int().min(1).optional()
71014
- }), object({
71015
- rev: number().int(),
71016
- releasedRefs: SecretRefsList
71017
- }), {
71018
- kind: "mutation",
71019
- auth: "admin"
71020
- }), method(object({
71021
- ...KindShape,
71022
- id: RecordIdSchema
71023
- }), object({
71024
- deleted: boolean(),
71025
- secretRefs: SecretRefsList
71026
- }), {
71027
- kind: "mutation",
71028
- auth: "admin"
71029
- }), method(object({
71030
- ...KindShape,
71031
- ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
71032
- }), object({
71033
- deleted: number().int(),
71034
- secretRefs: SecretRefsList
71035
- }), {
71036
- kind: "mutation",
71037
- auth: "admin"
71038
- }), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
71039
- ...KindShape,
71040
- ...TimeWindowShape,
71041
- where: RecordWhereSchema.optional()
71042
- }), object({ count: number().int() }), { auth: "admin" }), method(object({
71043
- ...KindShape,
71044
- deviceId: number().int().optional(),
71045
- from: number(),
71046
- to: number(),
71047
- bucketMs: number().int().positive()
71048
- }), object({ buckets: array(object({
71049
- bucketStart: number(),
71050
- count: number().int()
71051
- })) }), { auth: "admin" }), method(object({
71052
- ...KindShape,
71053
- op: _enum([
71054
- "sum",
71055
- "min",
71056
- "max",
71057
- "count"
71058
- ]),
71059
- field: RecordFieldPathSchema.optional(),
71060
- groupBy: RecordFieldPathSchema.optional(),
71061
- where: RecordWhereSchema.optional()
71062
- }), object({ rows: array(object({
71063
- group: union([
71064
- string(),
71065
- number(),
71066
- _null()
71067
- ]),
71068
- value: number().nullable()
71069
- })) }), { auth: "admin" }), method(object({
71070
- ...KindShape,
71071
- deviceId: number().int().optional(),
71072
- atBefore: number().optional(),
71073
- where: RecordWhereSchema.optional()
71074
- }), object({
71075
- deleted: number().int(),
71076
- secretRefs: SecretRefsList
71077
- }), {
71078
- kind: "mutation",
71079
- auth: "admin"
71080
- }), method(object({ ops: array(RecordTransactOpSchema).min(1).max(RECORD_BATCH_MAX) }), object({
71081
- results: array(object({
71082
- rev: number().int().nullable(),
71083
- deleted: boolean()
71084
- })),
71085
- releasedRefs: SecretRefsList,
71086
- secretRefs: SecretRefsList
71087
- }), {
71088
- kind: "mutation",
71089
- auth: "admin"
71090
- }), method(object({
71091
- deviceId: number().int(),
71092
- kinds: array(RecordKindNameSchema).optional()
71093
- }), object({
71094
- deleted: record(string(), number().int()),
71095
- secretRefs: SecretRefsList
71096
- }), {
71097
- kind: "mutation",
71098
- auth: "admin"
71099
- }), method(object(KindShape), object({ id: number().int() }), {
71100
- kind: "mutation",
71101
- auth: "admin"
71102
- });
71103
- /**
71104
71193
  * record-entries - the ONE admin surface for every list of user-created entries
71105
71194
  * (D881): notification targets, brokers, LLM profiles, anything an addon
71106
71195
  * declares as an ENTRY kind (`entry: { title }` in `defineRecordKinds`).
@@ -79737,20 +79826,6 @@ Object.freeze({
79737
79826
  access: "create",
79738
79827
  role: "viewer"
79739
79828
  },
79740
- "broker.add": {
79741
- capName: "broker",
79742
- capScope: "system",
79743
- addonId: null,
79744
- access: "create",
79745
- role: "admin"
79746
- },
79747
- "broker.get": {
79748
- capName: "broker",
79749
- capScope: "system",
79750
- addonId: null,
79751
- access: "view",
79752
- role: "admin"
79753
- },
79754
79829
  "broker.getBrokerConfig": {
79755
79830
  capName: "broker",
79756
79831
  capScope: "system",
@@ -79758,20 +79833,6 @@ Object.freeze({
79758
79833
  access: "view",
79759
79834
  role: "admin"
79760
79835
  },
79761
- "broker.getSettings": {
79762
- capName: "broker",
79763
- capScope: "system",
79764
- addonId: null,
79765
- access: "view",
79766
- role: "admin"
79767
- },
79768
- "broker.getSettingsSchema": {
79769
- capName: "broker",
79770
- capScope: "system",
79771
- addonId: null,
79772
- access: "view",
79773
- role: "admin"
79774
- },
79775
79836
  "broker.getState": {
79776
79837
  capName: "broker",
79777
79838
  capScope: "system",
@@ -79786,20 +79847,6 @@ Object.freeze({
79786
79847
  access: "view",
79787
79848
  role: "admin"
79788
79849
  },
79789
- "broker.list": {
79790
- capName: "broker",
79791
- capScope: "system",
79792
- addonId: null,
79793
- access: "view",
79794
- role: "admin"
79795
- },
79796
- "broker.listProviders": {
79797
- capName: "broker",
79798
- capScope: "system",
79799
- addonId: null,
79800
- access: "view",
79801
- role: "admin"
79802
- },
79803
79850
  "broker.publish": {
79804
79851
  capName: "broker",
79805
79852
  capScope: "system",
@@ -79807,20 +79854,6 @@ Object.freeze({
79807
79854
  access: "create",
79808
79855
  role: "admin"
79809
79856
  },
79810
- "broker.remove": {
79811
- capName: "broker",
79812
- capScope: "system",
79813
- addonId: null,
79814
- access: "delete",
79815
- role: "admin"
79816
- },
79817
- "broker.setSettings": {
79818
- capName: "broker",
79819
- capScope: "system",
79820
- addonId: null,
79821
- access: "create",
79822
- role: "admin"
79823
- },
79824
79857
  "broker.subscribe": {
79825
79858
  capName: "broker",
79826
79859
  capScope: "system",
@@ -79828,20 +79861,6 @@ Object.freeze({
79828
79861
  access: "create",
79829
79862
  role: "admin"
79830
79863
  },
79831
- "broker.testConnection": {
79832
- capName: "broker",
79833
- capScope: "system",
79834
- addonId: null,
79835
- access: "create",
79836
- role: "admin"
79837
- },
79838
- "broker.testSettings": {
79839
- capName: "broker",
79840
- capScope: "system",
79841
- addonId: null,
79842
- access: "create",
79843
- role: "admin"
79844
- },
79845
79864
  "broker.unsubscribe": {
79846
79865
  capName: "broker",
79847
79866
  capScope: "system",
@@ -84805,6 +84824,13 @@ Object.freeze({
84805
84824
  access: "view",
84806
84825
  role: "viewer"
84807
84826
  },
84827
+ "pipelineAnalytics.getMediaLocationCensus": {
84828
+ capName: "pipeline-analytics",
84829
+ capScope: "device",
84830
+ addonId: null,
84831
+ access: "view",
84832
+ role: "admin"
84833
+ },
84808
84834
  "pipelineAnalytics.getMediaReclaimStatus": {
84809
84835
  capName: "pipeline-analytics",
84810
84836
  capScope: "device",
@@ -95106,6 +95132,7 @@ object({
95106
95132
  delay: number().nonnegative().optional(),
95107
95133
  commands: record(string(), unknown())
95108
95134
  });
95135
+ entryBody({ brokerId: string() });
95109
95136
  //#endregion
95110
95137
  //#region src/migrations/drop-keys.ts
95111
95138
  /** The canonical settings table: one row per key, id `<addonId>.<key>`. */