@camstack/addon-matter-broker 0.2.130 → 0.2.132

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 (3) hide show
  1. package/dist/addon.js +390 -294
  2. package/dist/addon.mjs +390 -294
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -5561,7 +5561,7 @@ var ZodIssueCode = {
5561
5561
  var ZodFirstPartyTypeKind;
5562
5562
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5563
5563
  //#endregion
5564
- //#region ../types/dist/sleep-BxjU_fJM.mjs
5564
+ //#region ../types/dist/sleep-yKL5gfrH.mjs
5565
5565
  /**
5566
5566
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5567
5567
  * window to float samples (D455).
@@ -7943,6 +7943,12 @@ function normalizeAddonInitResult(result) {
7943
7943
  if (Array.isArray(result)) return { providers: result };
7944
7944
  return result;
7945
7945
  }
7946
+ /**
7947
+ * The share-view scope kinds a share-link token can carry. The hub mints
7948
+ * and validates them (`ShareViewGrantSchema` builds its
7949
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
7950
+ */
7951
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7946
7952
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7947
7953
  var PeerBytesTicketSchema = object({
7948
7954
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12808,6 +12814,280 @@ var ConvertResultSchema = object({
12808
12814
  files: array(string$2()).readonly()
12809
12815
  })).readonly()
12810
12816
  });
12817
+ /**
12818
+ * Zod schemas for persisted record types.
12819
+ *
12820
+ * These schemas serve as the single source of truth for types that are
12821
+ * stored in the settings-store backend and retrieved via tRPC. They
12822
+ * replace the manual TypeScript interfaces with schema-derived types,
12823
+ * enabling runtime validation when reading from the backend.
12824
+ *
12825
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12826
+ * keeps the original name for backward compatibility.
12827
+ */
12828
+ /**
12829
+ * Auth model (v2 — 2026-05-12 caps-only):
12830
+ *
12831
+ * Two principals:
12832
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12833
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12834
+ *
12835
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12836
+ * `super_admin` — collapsed onto the single boolean because every
12837
+ * non-admin caller is governed by the same scope-check rules; the
12838
+ * distinction was only ever used to route role-specific procedures
12839
+ * which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
12840
+ * with `isAdmin: false` + an explicit scope list.
12841
+ */
12842
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12843
+ var MethodAccessSchema = _enum([
12844
+ "view",
12845
+ "create",
12846
+ "delete"
12847
+ ]);
12848
+ /**
12849
+ * A single scope grant. Three forms — checked in matcher with OR
12850
+ * semantics; the first match decides whether the call passes:
12851
+ *
12852
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12853
+ * cap with the matching `scope` declaration. New caps inherit grants
12854
+ * automatically — adding a device cap to the codebase makes it
12855
+ * reachable to every user with `category:device [...]` without a
12856
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12857
+ *
12858
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12859
+ * useful when an integration needs to interact with one specific
12860
+ * addon's surface regardless of how many caps it exports.
12861
+ *
12862
+ * - `capability` — the most precise form. Single cap name. Use for
12863
+ * integration tokens where you want to grant `addons.installPackage`
12864
+ * and nothing else.
12865
+ *
12866
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12867
+ * "give me everything" escape; there is no wildcard scope.
12868
+ */
12869
+ var AllowedProviderSchema = union([literal("*"), array(string$2())]);
12870
+ var AllowedDevicesSchema = record(string$2(), union([literal("*"), array(string$2())]));
12871
+ var CapScopeSchema = _enum(["device", "system"]);
12872
+ /**
12873
+ * DeviceSelector (scope model v3 — 2026-08-12).
12874
+ *
12875
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12876
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12877
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12878
+ * AFTER the grant was minted — no re-grant, no re-login.
12879
+ *
12880
+ * - `all` — every device in the deployment. The broad viewer/operator
12881
+ * lever without a `category` grant (a `category` grant also covers device
12882
+ * caps that carry no deviceId; `all` is specifically the device set).
12883
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
12884
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
12885
+ * is NOT covered until the grant is edited.
12886
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
12887
+ * DYNAMIC. A device that changes type, or a new device of the type,
12888
+ * re-resolves on the next request.
12889
+ * - `locations` — every device whose operator-assigned `location` label is
12890
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
12891
+ * null/unset location matches NO `locations` selector.
12892
+ */
12893
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
12894
+ object({ kind: literal("all") }),
12895
+ object({
12896
+ kind: literal("ids"),
12897
+ ids: array(number().int()).min(1)
12898
+ }),
12899
+ object({
12900
+ kind: literal("types"),
12901
+ types: array(_enum(DeviceType)).min(1)
12902
+ }),
12903
+ object({
12904
+ kind: literal("locations"),
12905
+ locations: array(string$2().min(1)).min(1)
12906
+ })
12907
+ ]);
12908
+ var DeviceTokenScopeSchema = object({
12909
+ type: literal("device"),
12910
+ /** The device SET this grant covers — resolved against the live fleet. */
12911
+ selector: DeviceSelectorSchema,
12912
+ access: array(MethodAccessSchema).min(1),
12913
+ /**
12914
+ * Whether a grant on a PARENT device transparently covers its accessory
12915
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
12916
+ * Direction is parent → children ONLY.
12917
+ *
12918
+ * Absent → the matcher DERIVES it from the access flavour: `view`
12919
+ * inherits (a camera viewer sees the camera's accessories), `create` /
12920
+ * `delete` do NOT (actuating/removing a child is an explicit act the
12921
+ * operator must grant on the child, not inherit from the parent). Set it
12922
+ * explicitly to override that default per grant.
12923
+ */
12924
+ includeLinked: boolean().optional()
12925
+ });
12926
+ /**
12927
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
12928
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
12929
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
12930
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
12931
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
12932
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
12933
+ * migration cannot reach a JWT already in a client's hands; parse-time
12934
+ * migration covers both without a flag day. No cast — the raw object is read
12935
+ * through `Reflect.get` (its static type is `unknown`).
12936
+ */
12937
+ function migrateLegacyTokenScope(raw) {
12938
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
12939
+ if (Reflect.get(raw, "type") !== "device") return raw;
12940
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
12941
+ const targets = Reflect.get(raw, "targets");
12942
+ if (!Array.isArray(targets)) return raw;
12943
+ return {
12944
+ type: "device",
12945
+ selector: {
12946
+ kind: "ids",
12947
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
12948
+ },
12949
+ access: Reflect.get(raw, "access")
12950
+ };
12951
+ }
12952
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
12953
+ object({
12954
+ type: literal("category"),
12955
+ target: CapScopeSchema,
12956
+ access: array(MethodAccessSchema).min(1)
12957
+ }),
12958
+ object({
12959
+ type: literal("capability"),
12960
+ target: string$2(),
12961
+ access: array(MethodAccessSchema).min(1)
12962
+ }),
12963
+ object({
12964
+ type: literal("addon"),
12965
+ target: string$2(),
12966
+ access: array(MethodAccessSchema).min(1)
12967
+ }),
12968
+ DeviceTokenScopeSchema
12969
+ ]));
12970
+ object({
12971
+ id: string$2(),
12972
+ username: string$2(),
12973
+ passwordHash: string$2(),
12974
+ /**
12975
+ * Admin bypass. When true, the middleware skips the scope-access
12976
+ * check entirely. There is no other axis of privilege; the legacy
12977
+ * role enum collapsed onto this boolean in v2.
12978
+ */
12979
+ isAdmin: boolean().default(false),
12980
+ allowedProviders: AllowedProviderSchema,
12981
+ allowedDevices: AllowedDevicesSchema,
12982
+ /**
12983
+ * Scopes granted to this user. Admins bypass; their `scopes` is
12984
+ * ignored. Non-admins without scopes are locked out of every
12985
+ * protected call.
12986
+ */
12987
+ scopes: array(TokenScopeSchema).default([]),
12988
+ createdAt: number(),
12989
+ updatedAt: number()
12990
+ });
12991
+ object({
12992
+ id: string$2(),
12993
+ label: string$2(),
12994
+ isAdmin: boolean().default(false),
12995
+ allowedProviders: AllowedProviderSchema,
12996
+ allowedDevices: AllowedDevicesSchema,
12997
+ tokenHash: string$2(),
12998
+ tokenPrefix: string$2(),
12999
+ createdAt: number(),
13000
+ lastUsedAt: number().optional()
13001
+ });
13002
+ object({
13003
+ id: string$2(),
13004
+ userId: string$2(),
13005
+ name: string$2(),
13006
+ tokenHash: string$2(),
13007
+ tokenPrefix: string$2(),
13008
+ scopes: array(TokenScopeSchema),
13009
+ expiresAt: number().nullish(),
13010
+ lastUsedAt: number().nullish(),
13011
+ createdAt: number()
13012
+ });
13013
+ /** What a share-view grant lets its holder see. */
13014
+ var ShareViewGrantSchema = object({
13015
+ kind: _enum(SHARE_VIEW_KINDS),
13016
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
13017
+ /** Talk-back, opt-in at mint time; absent means off. */
13018
+ talk: boolean().optional()
13019
+ });
13020
+ var ShareViewScopeSchema = object({
13021
+ type: literal("share-view"),
13022
+ grant: ShareViewGrantSchema
13023
+ });
13024
+ var AddonRoutesScopeSchema = object({
13025
+ type: literal("addon-routes"),
13026
+ access: array(MethodAccessSchema).min(1)
13027
+ });
13028
+ var PreferencesSelfScopeSchema = object({ type: literal("preferences-self") });
13029
+ var CredentialScopeSchema = union([
13030
+ literal("*"),
13031
+ ShareViewScopeSchema,
13032
+ AddonRoutesScopeSchema,
13033
+ PreferencesSelfScopeSchema,
13034
+ TokenScopeSchema
13035
+ ]);
13036
+ object({
13037
+ kind: literal("credential"),
13038
+ sub: string$2().min(1),
13039
+ jti: string$2().min(16),
13040
+ scopes: array(CredentialScopeSchema).min(1)
13041
+ });
13042
+ var PreferenceNamespaceSchema = string$2().regex(/^[a-z][a-z0-9.-]{0,63}$/);
13043
+ /** A namespace's value: a JSON object, opaque to the hub. */
13044
+ var PreferenceValueSchema = record(string$2(), unknown());
13045
+ var PreferenceDeviceIdSchema = string$2().min(1).max(64);
13046
+ /** A stored row, as the owner reads it. */
13047
+ var PreferenceRowSchema = object({
13048
+ namespace: PreferenceNamespaceSchema,
13049
+ value: PreferenceValueSchema,
13050
+ /** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
13051
+ revision: number().int().positive(),
13052
+ updatedAt: number().int(),
13053
+ /** The client id the last writer sent; `null` when it sent none. */
13054
+ updatedByDevice: PreferenceDeviceIdSchema.nullable()
13055
+ });
13056
+ object({
13057
+ /** Absent: every namespace the caller holds. */
13058
+ namespaces: array(PreferenceNamespaceSchema).max(32).optional() });
13059
+ object({ rows: array(PreferenceRowSchema) });
13060
+ object({
13061
+ namespace: PreferenceNamespaceSchema,
13062
+ value: PreferenceValueSchema,
13063
+ /**
13064
+ * The revision the edit was based on. Absent: last write wins. `0`: the
13065
+ * namespace must not exist yet. Any other value that is not the current
13066
+ * revision answers `conflict` and writes nothing.
13067
+ */
13068
+ baseRevision: number().int().nonnegative().optional(),
13069
+ deviceId: PreferenceDeviceIdSchema.optional()
13070
+ });
13071
+ discriminatedUnion("status", [object({
13072
+ status: literal("saved"),
13073
+ row: PreferenceRowSchema
13074
+ }), object({
13075
+ status: literal("conflict"),
13076
+ current: PreferenceRowSchema.nullable()
13077
+ })]);
13078
+ object({ namespace: PreferenceNamespaceSchema });
13079
+ object({
13080
+ /** `false` when the namespace did not exist. */
13081
+ deleted: boolean() });
13082
+ object({
13083
+ /** The revision the client holds per namespace; a namespace it does not list is new to it. */
13084
+ revisionByNamespace: record(PreferenceNamespaceSchema, number().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
13085
+ object({
13086
+ /** Every row whose revision differs from the client's, and every row it did not list. */
13087
+ rows: array(PreferenceRowSchema),
13088
+ /** Namespaces the client listed that no longer exist. */
13089
+ deleted: array(PreferenceNamespaceSchema)
13090
+ });
12811
13091
  _enum(["new-session", "step-up"]);
12812
13092
  /** The languages the hub's app landing pages are written in (D858). */
12813
13093
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -40050,38 +40330,37 @@ method(LlmRuntimeCompleteInputSchema, LlmGenerateResultSchema, {
40050
40330
  auth: "admin",
40051
40331
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
40052
40332
  });
40333
+ var LlmProfileKindSchema = string$2().regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "a kind id is lower-case letters, digits and dashes");
40334
+ /** What a model (or, by default, every model of a kind) can do. */
40335
+ var LlmModelFeaturesSchema = object({
40336
+ vision: boolean(),
40337
+ tools: boolean(),
40338
+ streaming: boolean()
40339
+ });
40340
+ /** One model a provider offers. `features` overrides the kind's defaults, per field. */
40341
+ var LlmModelInfoSchema = object({
40342
+ id: string$2(),
40343
+ label: string$2().optional(),
40344
+ contextLength: number().int().positive().optional(),
40345
+ features: LlmModelFeaturesSchema.partial().optional()
40346
+ });
40053
40347
  /**
40054
- * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
40055
- * methods concat-fan across providers; single-row methods route to ONE
40056
- * provider by the `addonId` in the call input (the notification-output
40057
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
40058
- * (hub-placed); the cap stays open for future providers.
40059
- *
40060
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
40061
- * `apiKey` is a password field — providers REDACT it on read and merge on
40062
- * write; a stored key NEVER round-trips to a client.
40348
+ * The provider-specific part of a profile, validated by the provider that owns
40349
+ * the kind (`upsertProfile` refuses what it does not accept). A field its
40350
+ * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
40351
+ * keychain, never in the row, and reads back as the redaction marker.
40063
40352
  */
40064
- var LlmProfileKindSchema = _enum([
40065
- "openai-compatible",
40066
- "openai",
40067
- "anthropic",
40068
- "google",
40069
- "managed-local",
40070
- "apple-foundation"
40071
- ]);
40353
+ var LlmProviderConfigSchema = record(string$2(), unknown());
40072
40354
  var LlmProfileSchema = object({
40073
40355
  id: string$2(),
40074
40356
  name: string$2(),
40357
+ /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
40075
40358
  kind: LlmProfileKindSchema,
40076
40359
  /** Stamped by the provider — keeps the fanned catalog routable. */
40077
40360
  addonId: string$2(),
40078
40361
  enabled: boolean(),
40079
40362
  /** Vendor model id, or the managed runtime's loaded model. */
40080
40363
  model: string$2(),
40081
- /** Required for openai-compatible; override for cloud kinds. */
40082
- baseUrl: string$2().optional(),
40083
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
40084
- apiKey: string$2().optional(),
40085
40364
  /** Vision on/off. A vision call against a `false` profile is REFUSED, never
40086
40365
  * degraded to text — that shipped once and produced a confident answer to a
40087
40366
  * question about a picture nobody sent. */
@@ -40089,15 +40368,11 @@ var LlmProfileSchema = object({
40089
40368
  temperature: number().min(0).max(2).optional(),
40090
40369
  /** Nucleus sampling. Every wire we speak has it. */
40091
40370
  topP: number().min(0).max(1).optional(),
40092
- /** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
40093
- * wire does, and the client drops it there (measured: the request body gets
40094
- * `top_p` and no `top_k`). The profile editor hides the field wherever it
40095
- * would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
40371
+ /** Top-k sampling. Carried only by the wires that have it — a kind offers the
40372
+ * field in its editor only when its descriptor lists it in `profileFields`. */
40096
40373
  topK: number().int().positive().optional(),
40097
40374
  maxTokens: number().int().positive().optional(),
40098
- /** Prompt context window. Advisory for cloud kinds (they enforce their own);
40099
- * for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
40100
- * the model with, so it is the one field that changes a PROCESS. */
40375
+ /** Prompt context window. Advisory for cloud kinds (they enforce their own). */
40101
40376
  contextLength: number().int().positive().optional(),
40102
40377
  /** Default system prompt. A caller's `system` REPLACES it (never appends —
40103
40378
  * two system prompts fighting is worse than either alone). */
@@ -40123,16 +40398,37 @@ var LlmProfileSchema = object({
40123
40398
  * library; the REGISTRY of callable tools is ours and is empty in v1, so a
40124
40399
  * `true` here buys the wiring, not behaviour, until tools are registered. */
40125
40400
  toolsEnabled: boolean().default(false),
40126
- extraHeaders: record(string$2(), string$2()).optional(),
40127
- /** kind === 'managed-local' only (spec §4). */
40128
- runtime: ManagedRuntimeConfigSchema.optional(),
40129
- /**
40130
- * kind === 'apple-foundation' only: WHERE it runs — the only thing there is
40131
- * to configure (no key, no URL, no download; `model` is `apple-system`).
40132
- * `supportsVision` on such a row is stamped by the provider from the node's
40133
- * reported `imageInput`, never taken from the operator (D62).
40134
- */
40135
- appleFoundation: object({ nodeId: string$2() }).optional()
40401
+ /** Everything the kind's provider owns (endpoint, key, node, runtime…). */
40402
+ providerConfig: LlmProviderConfigSchema.default({})
40403
+ });
40404
+ /**
40405
+ * The common profile fields a kind's editor offers. The editor owns how each
40406
+ * one is drawn; the provider says which of them mean something on its wire.
40407
+ */
40408
+ var LlmProfileFieldSchema = _enum([
40409
+ "temperature",
40410
+ "topP",
40411
+ "topK",
40412
+ "maxTokens",
40413
+ "contextLength",
40414
+ "systemPrompt",
40415
+ "timeoutMs",
40416
+ "connectTimeoutMs",
40417
+ "firstTokenTimeoutMs",
40418
+ "idleTimeoutMs",
40419
+ "retry",
40420
+ "toolsEnabled"
40421
+ ]);
40422
+ /**
40423
+ * A provider-drawn part of the editor, by a generic widget id the admin UI
40424
+ * registers (`ai/apple-node`). `placement: 'model'` replaces the generic model
40425
+ * picker: that widget owns the model choice.
40426
+ */
40427
+ var LlmProviderWidgetSchema = object({
40428
+ id: string$2(),
40429
+ placement: _enum(["connection", "model"]),
40430
+ /** `providerConfig` keys this widget must fill before the profile can be saved. */
40431
+ requires: array(string$2()).optional()
40136
40432
  });
40137
40433
  /** ConfigUISchema tree passed through untyped on the wire (the
40138
40434
  * notification-output `ConfigSchemaPassthrough` precedent at
@@ -40141,11 +40437,56 @@ var ConfigSchemaPassthrough$3 = unknown();
40141
40437
  var LlmProfileKindDescriptorSchema = object({
40142
40438
  kind: LlmProfileKindSchema,
40143
40439
  label: string$2(),
40440
+ /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
40144
40441
  icon: string$2(),
40145
40442
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
40146
40443
  addonId: string$2(),
40147
- configSchema: ConfigSchemaPassthrough$3
40444
+ /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
40445
+ connectionSchema: ConfigSchemaPassthrough$3,
40446
+ /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
40447
+ advancedSchema: ConfigSchemaPassthrough$3.optional(),
40448
+ /** The kind's defaults; a model from `listModels` may override any of them. */
40449
+ features: LlmModelFeaturesSchema,
40450
+ /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
40451
+ visionEditable: boolean(),
40452
+ /** Where the model list comes from: `listModels`, `staticModels`, or nowhere. */
40453
+ modelCatalog: _enum([
40454
+ "fetch",
40455
+ "static",
40456
+ "none"
40457
+ ]),
40458
+ staticModels: array(LlmModelInfoSchema).optional(),
40459
+ /** The common fields that mean something on this kind's wire. */
40460
+ profileFields: array(LlmProfileFieldSchema),
40461
+ providerWidgets: array(LlmProviderWidgetSchema).optional()
40462
+ });
40463
+ /**
40464
+ * `listModels` input. `connection` is an UNSAVED draft of `providerConfig`
40465
+ * (the editor's form); with `profileId` too, a secret the draft leaves
40466
+ * untouched (absent or the redaction marker) is resolved server-side from the
40467
+ * stored profile — the browser never receives it.
40468
+ */
40469
+ var LlmListModelsInputSchema = object({
40470
+ addonId: string$2(),
40471
+ kind: LlmProfileKindSchema,
40472
+ profileId: string$2().optional(),
40473
+ connection: LlmProviderConfigSchema.optional()
40148
40474
  });
40475
+ var LlmListModelsErrorCodeSchema = _enum([
40476
+ "auth",
40477
+ "network",
40478
+ "unsupported",
40479
+ "invalid"
40480
+ ]);
40481
+ /** A RESULT, never a throw: "wrong key" is an answer the editor renders inline. */
40482
+ var LlmListModelsResultSchema = discriminatedUnion("ok", [object({
40483
+ ok: literal(true),
40484
+ models: array(LlmModelInfoSchema)
40485
+ }), object({
40486
+ ok: literal(false),
40487
+ code: LlmListModelsErrorCodeSchema,
40488
+ message: string$2()
40489
+ })]);
40149
40490
  var LlmDefaultSelectorSchema = union([object({ consumer: string$2() }), object({ purpose: _enum(["text", "vision"]) })]);
40150
40491
  var LlmDefaultSchema = object({
40151
40492
  selector: LlmDefaultSelectorSchema,
@@ -40245,7 +40586,10 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
40245
40586
  kind: "mutation",
40246
40587
  auth: "admin",
40247
40588
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
40248
- }), method(ProfileRefInputSchema, array(string$2())), method(object({}), array(LlmDefaultSchema)), method(object({
40589
+ }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
40590
+ kind: "mutation",
40591
+ auth: "admin"
40592
+ }), method(object({}), array(LlmDefaultSchema)), method(object({
40249
40593
  selector: LlmDefaultSelectorSchema,
40250
40594
  profileId: string$2().nullable()
40251
40595
  }), _void(), {
@@ -44351,202 +44695,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
44351
44695
  auth: "admin"
44352
44696
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
44353
44697
  /**
44354
- * Zod schemas for persisted record types.
44355
- *
44356
- * These schemas serve as the single source of truth for types that are
44357
- * stored in the settings-store backend and retrieved via tRPC. They
44358
- * replace the manual TypeScript interfaces with schema-derived types,
44359
- * enabling runtime validation when reading from the backend.
44360
- *
44361
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
44362
- * keeps the original name for backward compatibility.
44363
- */
44364
- /**
44365
- * Auth model (v2 — 2026-05-12 caps-only):
44366
- *
44367
- * Two principals:
44368
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
44369
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
44370
- *
44371
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44372
- * `super_admin` — collapsed onto the single boolean because every
44373
- * non-admin caller is governed by the same scope-check rules; the
44374
- * distinction was only ever used to route role-specific procedures
44375
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44376
- * with `isAdmin: false` + an explicit scope list.
44377
- */
44378
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44379
- var MethodAccessSchema = _enum([
44380
- "view",
44381
- "create",
44382
- "delete"
44383
- ]);
44384
- /**
44385
- * A single scope grant. Three forms — checked in matcher with OR
44386
- * semantics; the first match decides whether the call passes:
44387
- *
44388
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44389
- * cap with the matching `scope` declaration. New caps inherit grants
44390
- * automatically — adding a device cap to the codebase makes it
44391
- * reachable to every user with `category:device [...]` without a
44392
- * re-grant. Use this for "family viewer" / "operator" tiers.
44393
- *
44394
- * - `addon` — every cap that ships inside a given addon id. Niche;
44395
- * useful when an integration needs to interact with one specific
44396
- * addon's surface regardless of how many caps it exports.
44397
- *
44398
- * - `capability` — the most precise form. Single cap name. Use for
44399
- * integration tokens where you want to grant `addons.installPackage`
44400
- * and nothing else.
44401
- *
44402
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44403
- * "give me everything" escape; there is no wildcard scope.
44404
- */
44405
- var AllowedProviderSchema = union([literal("*"), array(string$2())]);
44406
- var AllowedDevicesSchema = record(string$2(), union([literal("*"), array(string$2())]));
44407
- var CapScopeSchema = _enum(["device", "system"]);
44408
- /**
44409
- * DeviceSelector (scope model v3 — 2026-08-12).
44410
- *
44411
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44412
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44413
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44414
- * AFTER the grant was minted — no re-grant, no re-login.
44415
- *
44416
- * - `all` — every device in the deployment. The broad viewer/operator
44417
- * lever without a `category` grant (a `category` grant also covers device
44418
- * caps that carry no deviceId; `all` is specifically the device set).
44419
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44420
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44421
- * is NOT covered until the grant is edited.
44422
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44423
- * DYNAMIC. A device that changes type, or a new device of the type,
44424
- * re-resolves on the next request.
44425
- * - `locations` — every device whose operator-assigned `location` label is
44426
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44427
- * null/unset location matches NO `locations` selector.
44428
- */
44429
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44430
- object({ kind: literal("all") }),
44431
- object({
44432
- kind: literal("ids"),
44433
- ids: array(number().int()).min(1)
44434
- }),
44435
- object({
44436
- kind: literal("types"),
44437
- types: array(_enum(DeviceType)).min(1)
44438
- }),
44439
- object({
44440
- kind: literal("locations"),
44441
- locations: array(string$2().min(1)).min(1)
44442
- })
44443
- ]);
44444
- var DeviceTokenScopeSchema = object({
44445
- type: literal("device"),
44446
- /** The device SET this grant covers — resolved against the live fleet. */
44447
- selector: DeviceSelectorSchema,
44448
- access: array(MethodAccessSchema).min(1),
44449
- /**
44450
- * Whether a grant on a PARENT device transparently covers its accessory
44451
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44452
- * Direction is parent → children ONLY.
44453
- *
44454
- * Absent → the matcher DERIVES it from the access flavour: `view`
44455
- * inherits (a camera viewer sees the camera's accessories), `create` /
44456
- * `delete` do NOT (actuating/removing a child is an explicit act the
44457
- * operator must grant on the child, not inherit from the parent). Set it
44458
- * explicitly to override that default per grant.
44459
- */
44460
- includeLinked: boolean().optional()
44461
- });
44462
- /**
44463
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44464
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44465
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44466
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44467
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44468
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44469
- * migration cannot reach a JWT already in a client's hands; parse-time
44470
- * migration covers both without a flag day. No cast — the raw object is read
44471
- * through `Reflect.get` (its static type is `unknown`).
44472
- */
44473
- function migrateLegacyTokenScope(raw) {
44474
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44475
- if (Reflect.get(raw, "type") !== "device") return raw;
44476
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44477
- const targets = Reflect.get(raw, "targets");
44478
- if (!Array.isArray(targets)) return raw;
44479
- return {
44480
- type: "device",
44481
- selector: {
44482
- kind: "ids",
44483
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44484
- },
44485
- access: Reflect.get(raw, "access")
44486
- };
44487
- }
44488
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44489
- object({
44490
- type: literal("category"),
44491
- target: CapScopeSchema,
44492
- access: array(MethodAccessSchema).min(1)
44493
- }),
44494
- object({
44495
- type: literal("capability"),
44496
- target: string$2(),
44497
- access: array(MethodAccessSchema).min(1)
44498
- }),
44499
- object({
44500
- type: literal("addon"),
44501
- target: string$2(),
44502
- access: array(MethodAccessSchema).min(1)
44503
- }),
44504
- DeviceTokenScopeSchema
44505
- ]));
44506
- object({
44507
- id: string$2(),
44508
- username: string$2(),
44509
- passwordHash: string$2(),
44510
- /**
44511
- * Admin bypass. When true, the middleware skips the scope-access
44512
- * check entirely. There is no other axis of privilege; the legacy
44513
- * role enum collapsed onto this boolean in v2.
44514
- */
44515
- isAdmin: boolean().default(false),
44516
- allowedProviders: AllowedProviderSchema,
44517
- allowedDevices: AllowedDevicesSchema,
44518
- /**
44519
- * Scopes granted to this user. Admins bypass; their `scopes` is
44520
- * ignored. Non-admins without scopes are locked out of every
44521
- * protected call.
44522
- */
44523
- scopes: array(TokenScopeSchema).default([]),
44524
- createdAt: number(),
44525
- updatedAt: number()
44526
- });
44527
- object({
44528
- id: string$2(),
44529
- label: string$2(),
44530
- isAdmin: boolean().default(false),
44531
- allowedProviders: AllowedProviderSchema,
44532
- allowedDevices: AllowedDevicesSchema,
44533
- tokenHash: string$2(),
44534
- tokenPrefix: string$2(),
44535
- createdAt: number(),
44536
- lastUsedAt: number().optional()
44537
- });
44538
- object({
44539
- id: string$2(),
44540
- userId: string$2(),
44541
- name: string$2(),
44542
- tokenHash: string$2(),
44543
- tokenPrefix: string$2(),
44544
- scopes: array(TokenScopeSchema),
44545
- expiresAt: number().nullish(),
44546
- lastUsedAt: number().nullish(),
44547
- createdAt: number()
44548
- });
44549
- /**
44550
44698
  * `oauth-integration` — a collection cap by which an addon declares
44551
44699
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44552
44700
  * Each provider returns a static descriptor; the core enumerates them
@@ -64346,26 +64494,6 @@ var ApiKeySummarySchema = object({
64346
64494
  createdAt: number(),
64347
64495
  lastUsedAt: number().optional()
64348
64496
  });
64349
- var ScopedTokenSummarySchema = object({
64350
- id: string$2(),
64351
- userId: string$2(),
64352
- name: string$2(),
64353
- tokenPrefix: string$2(),
64354
- scopes: array(TokenScopeSchema),
64355
- expiresAt: number().nullish(),
64356
- lastUsedAt: number().nullish(),
64357
- createdAt: number()
64358
- });
64359
- var CreateScopedTokenInputSchema = object({
64360
- userId: string$2(),
64361
- name: string$2(),
64362
- scopes: array(TokenScopeSchema),
64363
- expiresAt: number().optional()
64364
- });
64365
- var CreateScopedTokenResultSchema = object({
64366
- token: string$2(),
64367
- record: ScopedTokenSummarySchema
64368
- });
64369
64497
  var OauthSessionSummarySchema = object({
64370
64498
  id: string$2(),
64371
64499
  userId: string$2(),
@@ -64387,11 +64515,11 @@ var TotpStatusSchema = object({
64387
64515
  confirmedAt: number().nullable()
64388
64516
  });
64389
64517
  /**
64390
- * user-management — singleton capability for user accounts, API keys,
64391
- * and scoped tokens.
64518
+ * user-management — singleton capability for user accounts and the
64519
+ * legacy API-key rows.
64392
64520
  *
64393
64521
  * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
64394
- * — the subset check on `setUserScopes` / `createScopedToken` is moot
64522
+ * — the subset check on `setUserScopes` is moot
64395
64523
  * because non-admins never reach these. If/when we open non-admin
64396
64524
  * delegation, structural caller-scope subset check goes inside the
64397
64525
  * provider.
@@ -64448,15 +64576,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
64448
64576
  kind: "mutation",
64449
64577
  auth: "admin",
64450
64578
  access: "delete"
64451
- }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
64452
- kind: "mutation",
64453
- auth: "admin",
64454
- access: "create"
64455
- }), method(object({ id: string$2() }), object({ success: literal(true) }), {
64456
- kind: "mutation",
64457
- auth: "admin",
64458
- access: "delete"
64459
- }), method(object({ token: string$2() }), ScopedTokenSummarySchema.nullable(), { access: "view" }), method(object({ userId: string$2() }), array(ScopedTokenSummarySchema), { auth: "admin" }), method(object({ userId: string$2() }), TotpSetupResultSchema, {
64579
+ }), method(object({ userId: string$2() }), TotpSetupResultSchema, {
64460
64580
  kind: "mutation",
64461
64581
  auth: "admin",
64462
64582
  access: "create"
@@ -70546,7 +70666,7 @@ Object.freeze({
70546
70666
  capName: "llm",
70547
70667
  capScope: "system",
70548
70668
  addonId: null,
70549
- access: "view"
70669
+ access: "create"
70550
70670
  },
70551
70671
  "llm.listNodeModels": {
70552
70672
  capName: "llm",
@@ -75210,12 +75330,6 @@ Object.freeze({
75210
75330
  addonId: null,
75211
75331
  access: "create"
75212
75332
  },
75213
- "userManagement.createScopedToken": {
75214
- capName: "user-management",
75215
- capScope: "system",
75216
- addonId: null,
75217
- access: "create"
75218
- },
75219
75333
  "userManagement.createUser": {
75220
75334
  capName: "user-management",
75221
75335
  capScope: "system",
@@ -75264,12 +75378,6 @@ Object.freeze({
75264
75378
  addonId: null,
75265
75379
  access: "view"
75266
75380
  },
75267
- "userManagement.listScopedTokens": {
75268
- capName: "user-management",
75269
- capScope: "system",
75270
- addonId: null,
75271
- access: "view"
75272
- },
75273
75381
  "userManagement.listUsers": {
75274
75382
  capName: "user-management",
75275
75383
  capScope: "system",
@@ -75324,12 +75432,6 @@ Object.freeze({
75324
75432
  addonId: null,
75325
75433
  access: "delete"
75326
75434
  },
75327
- "userManagement.revokeScopedToken": {
75328
- capName: "user-management",
75329
- capScope: "system",
75330
- addonId: null,
75331
- access: "delete"
75332
- },
75333
75435
  "userManagement.setupTotp": {
75334
75436
  capName: "user-management",
75335
75437
  capScope: "system",
@@ -75360,12 +75462,6 @@ Object.freeze({
75360
75462
  addonId: null,
75361
75463
  access: "view"
75362
75464
  },
75363
- "userManagement.validateScopedToken": {
75364
- capName: "user-management",
75365
- capScope: "system",
75366
- addonId: null,
75367
- access: "view"
75368
- },
75369
75465
  "userManagement.verifyTotp": {
75370
75466
  capName: "user-management",
75371
75467
  capScope: "system",