@camstack/addon-provider-homeassistant 1.2.604 → 1.2.606

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.
@@ -5547,7 +5547,7 @@ var ZodIssueCode = {
5547
5547
  var ZodFirstPartyTypeKind;
5548
5548
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5549
5549
  //#endregion
5550
- //#region ../types/dist/sleep-BxjU_fJM.mjs
5550
+ //#region ../types/dist/sleep-yKL5gfrH.mjs
5551
5551
  /**
5552
5552
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5553
5553
  * window to float samples (D455).
@@ -7929,6 +7929,12 @@ function normalizeAddonInitResult(result) {
7929
7929
  if (Array.isArray(result)) return { providers: result };
7930
7930
  return result;
7931
7931
  }
7932
+ /**
7933
+ * The share-view scope kinds a share-link token can carry. The hub mints
7934
+ * and validates them (`ShareViewGrantSchema` builds its
7935
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
7936
+ */
7937
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7932
7938
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7933
7939
  var PeerBytesTicketSchema = object({
7934
7940
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12997,6 +13003,280 @@ var ConvertResultSchema = object({
12997
13003
  files: array(string()).readonly()
12998
13004
  })).readonly()
12999
13005
  });
13006
+ /**
13007
+ * Zod schemas for persisted record types.
13008
+ *
13009
+ * These schemas serve as the single source of truth for types that are
13010
+ * stored in the settings-store backend and retrieved via tRPC. They
13011
+ * replace the manual TypeScript interfaces with schema-derived types,
13012
+ * enabling runtime validation when reading from the backend.
13013
+ *
13014
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
13015
+ * keeps the original name for backward compatibility.
13016
+ */
13017
+ /**
13018
+ * Auth model (v2 — 2026-05-12 caps-only):
13019
+ *
13020
+ * Two principals:
13021
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
13022
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
13023
+ *
13024
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
13025
+ * `super_admin` — collapsed onto the single boolean because every
13026
+ * non-admin caller is governed by the same scope-check rules; the
13027
+ * distinction was only ever used to route role-specific procedures
13028
+ * which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
13029
+ * with `isAdmin: false` + an explicit scope list.
13030
+ */
13031
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
13032
+ var MethodAccessSchema = _enum([
13033
+ "view",
13034
+ "create",
13035
+ "delete"
13036
+ ]);
13037
+ /**
13038
+ * A single scope grant. Three forms — checked in matcher with OR
13039
+ * semantics; the first match decides whether the call passes:
13040
+ *
13041
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
13042
+ * cap with the matching `scope` declaration. New caps inherit grants
13043
+ * automatically — adding a device cap to the codebase makes it
13044
+ * reachable to every user with `category:device [...]` without a
13045
+ * re-grant. Use this for "family viewer" / "operator" tiers.
13046
+ *
13047
+ * - `addon` — every cap that ships inside a given addon id. Niche;
13048
+ * useful when an integration needs to interact with one specific
13049
+ * addon's surface regardless of how many caps it exports.
13050
+ *
13051
+ * - `capability` — the most precise form. Single cap name. Use for
13052
+ * integration tokens where you want to grant `addons.installPackage`
13053
+ * and nothing else.
13054
+ *
13055
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
13056
+ * "give me everything" escape; there is no wildcard scope.
13057
+ */
13058
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
13059
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
13060
+ var CapScopeSchema = _enum(["device", "system"]);
13061
+ /**
13062
+ * DeviceSelector (scope model v3 — 2026-08-12).
13063
+ *
13064
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
13065
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
13066
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
13067
+ * AFTER the grant was minted — no re-grant, no re-login.
13068
+ *
13069
+ * - `all` — every device in the deployment. The broad viewer/operator
13070
+ * lever without a `category` grant (a `category` grant also covers device
13071
+ * caps that carry no deviceId; `all` is specifically the device set).
13072
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
13073
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
13074
+ * is NOT covered until the grant is edited.
13075
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
13076
+ * DYNAMIC. A device that changes type, or a new device of the type,
13077
+ * re-resolves on the next request.
13078
+ * - `locations` — every device whose operator-assigned `location` label is
13079
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
13080
+ * null/unset location matches NO `locations` selector.
13081
+ */
13082
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
13083
+ object({ kind: literal("all") }),
13084
+ object({
13085
+ kind: literal("ids"),
13086
+ ids: array(number().int()).min(1)
13087
+ }),
13088
+ object({
13089
+ kind: literal("types"),
13090
+ types: array(_enum(DeviceType)).min(1)
13091
+ }),
13092
+ object({
13093
+ kind: literal("locations"),
13094
+ locations: array(string().min(1)).min(1)
13095
+ })
13096
+ ]);
13097
+ var DeviceTokenScopeSchema = object({
13098
+ type: literal("device"),
13099
+ /** The device SET this grant covers — resolved against the live fleet. */
13100
+ selector: DeviceSelectorSchema,
13101
+ access: array(MethodAccessSchema).min(1),
13102
+ /**
13103
+ * Whether a grant on a PARENT device transparently covers its accessory
13104
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
13105
+ * Direction is parent → children ONLY.
13106
+ *
13107
+ * Absent → the matcher DERIVES it from the access flavour: `view`
13108
+ * inherits (a camera viewer sees the camera's accessories), `create` /
13109
+ * `delete` do NOT (actuating/removing a child is an explicit act the
13110
+ * operator must grant on the child, not inherit from the parent). Set it
13111
+ * explicitly to override that default per grant.
13112
+ */
13113
+ includeLinked: boolean().optional()
13114
+ });
13115
+ /**
13116
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
13117
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
13118
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
13119
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
13120
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
13121
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
13122
+ * migration cannot reach a JWT already in a client's hands; parse-time
13123
+ * migration covers both without a flag day. No cast — the raw object is read
13124
+ * through `Reflect.get` (its static type is `unknown`).
13125
+ */
13126
+ function migrateLegacyTokenScope(raw) {
13127
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
13128
+ if (Reflect.get(raw, "type") !== "device") return raw;
13129
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
13130
+ const targets = Reflect.get(raw, "targets");
13131
+ if (!Array.isArray(targets)) return raw;
13132
+ return {
13133
+ type: "device",
13134
+ selector: {
13135
+ kind: "ids",
13136
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
13137
+ },
13138
+ access: Reflect.get(raw, "access")
13139
+ };
13140
+ }
13141
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
13142
+ object({
13143
+ type: literal("category"),
13144
+ target: CapScopeSchema,
13145
+ access: array(MethodAccessSchema).min(1)
13146
+ }),
13147
+ object({
13148
+ type: literal("capability"),
13149
+ target: string(),
13150
+ access: array(MethodAccessSchema).min(1)
13151
+ }),
13152
+ object({
13153
+ type: literal("addon"),
13154
+ target: string(),
13155
+ access: array(MethodAccessSchema).min(1)
13156
+ }),
13157
+ DeviceTokenScopeSchema
13158
+ ]));
13159
+ object({
13160
+ id: string(),
13161
+ username: string(),
13162
+ passwordHash: string(),
13163
+ /**
13164
+ * Admin bypass. When true, the middleware skips the scope-access
13165
+ * check entirely. There is no other axis of privilege; the legacy
13166
+ * role enum collapsed onto this boolean in v2.
13167
+ */
13168
+ isAdmin: boolean().default(false),
13169
+ allowedProviders: AllowedProviderSchema,
13170
+ allowedDevices: AllowedDevicesSchema,
13171
+ /**
13172
+ * Scopes granted to this user. Admins bypass; their `scopes` is
13173
+ * ignored. Non-admins without scopes are locked out of every
13174
+ * protected call.
13175
+ */
13176
+ scopes: array(TokenScopeSchema).default([]),
13177
+ createdAt: number(),
13178
+ updatedAt: number()
13179
+ });
13180
+ object({
13181
+ id: string(),
13182
+ label: string(),
13183
+ isAdmin: boolean().default(false),
13184
+ allowedProviders: AllowedProviderSchema,
13185
+ allowedDevices: AllowedDevicesSchema,
13186
+ tokenHash: string(),
13187
+ tokenPrefix: string(),
13188
+ createdAt: number(),
13189
+ lastUsedAt: number().optional()
13190
+ });
13191
+ object({
13192
+ id: string(),
13193
+ userId: string(),
13194
+ name: string(),
13195
+ tokenHash: string(),
13196
+ tokenPrefix: string(),
13197
+ scopes: array(TokenScopeSchema),
13198
+ expiresAt: number().nullish(),
13199
+ lastUsedAt: number().nullish(),
13200
+ createdAt: number()
13201
+ });
13202
+ /** What a share-view grant lets its holder see. */
13203
+ var ShareViewGrantSchema = object({
13204
+ kind: _enum(SHARE_VIEW_KINDS),
13205
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
13206
+ /** Talk-back, opt-in at mint time; absent means off. */
13207
+ talk: boolean().optional()
13208
+ });
13209
+ var ShareViewScopeSchema = object({
13210
+ type: literal("share-view"),
13211
+ grant: ShareViewGrantSchema
13212
+ });
13213
+ var AddonRoutesScopeSchema = object({
13214
+ type: literal("addon-routes"),
13215
+ access: array(MethodAccessSchema).min(1)
13216
+ });
13217
+ var PreferencesSelfScopeSchema = object({ type: literal("preferences-self") });
13218
+ var CredentialScopeSchema = union([
13219
+ literal("*"),
13220
+ ShareViewScopeSchema,
13221
+ AddonRoutesScopeSchema,
13222
+ PreferencesSelfScopeSchema,
13223
+ TokenScopeSchema
13224
+ ]);
13225
+ object({
13226
+ kind: literal("credential"),
13227
+ sub: string().min(1),
13228
+ jti: string().min(16),
13229
+ scopes: array(CredentialScopeSchema).min(1)
13230
+ });
13231
+ var PreferenceNamespaceSchema = string().regex(/^[a-z][a-z0-9.-]{0,63}$/);
13232
+ /** A namespace's value: a JSON object, opaque to the hub. */
13233
+ var PreferenceValueSchema = record(string(), unknown());
13234
+ var PreferenceDeviceIdSchema = string().min(1).max(64);
13235
+ /** A stored row, as the owner reads it. */
13236
+ var PreferenceRowSchema = object({
13237
+ namespace: PreferenceNamespaceSchema,
13238
+ value: PreferenceValueSchema,
13239
+ /** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
13240
+ revision: number().int().positive(),
13241
+ updatedAt: number().int(),
13242
+ /** The client id the last writer sent; `null` when it sent none. */
13243
+ updatedByDevice: PreferenceDeviceIdSchema.nullable()
13244
+ });
13245
+ object({
13246
+ /** Absent: every namespace the caller holds. */
13247
+ namespaces: array(PreferenceNamespaceSchema).max(32).optional() });
13248
+ object({ rows: array(PreferenceRowSchema) });
13249
+ object({
13250
+ namespace: PreferenceNamespaceSchema,
13251
+ value: PreferenceValueSchema,
13252
+ /**
13253
+ * The revision the edit was based on. Absent: last write wins. `0`: the
13254
+ * namespace must not exist yet. Any other value that is not the current
13255
+ * revision answers `conflict` and writes nothing.
13256
+ */
13257
+ baseRevision: number().int().nonnegative().optional(),
13258
+ deviceId: PreferenceDeviceIdSchema.optional()
13259
+ });
13260
+ discriminatedUnion("status", [object({
13261
+ status: literal("saved"),
13262
+ row: PreferenceRowSchema
13263
+ }), object({
13264
+ status: literal("conflict"),
13265
+ current: PreferenceRowSchema.nullable()
13266
+ })]);
13267
+ object({ namespace: PreferenceNamespaceSchema });
13268
+ object({
13269
+ /** `false` when the namespace did not exist. */
13270
+ deleted: boolean() });
13271
+ object({
13272
+ /** The revision the client holds per namespace; a namespace it does not list is new to it. */
13273
+ revisionByNamespace: record(PreferenceNamespaceSchema, number().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
13274
+ object({
13275
+ /** Every row whose revision differs from the client's, and every row it did not list. */
13276
+ rows: array(PreferenceRowSchema),
13277
+ /** Namespaces the client listed that no longer exist. */
13278
+ deleted: array(PreferenceNamespaceSchema)
13279
+ });
13000
13280
  _enum(["new-session", "step-up"]);
13001
13281
  /** The languages the hub's app landing pages are written in (D858). */
13002
13282
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -40475,38 +40755,37 @@ method(LlmRuntimeCompleteInputSchema, LlmGenerateResultSchema, {
40475
40755
  auth: "admin",
40476
40756
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
40477
40757
  });
40758
+ var LlmProfileKindSchema = string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "a kind id is lower-case letters, digits and dashes");
40759
+ /** What a model (or, by default, every model of a kind) can do. */
40760
+ var LlmModelFeaturesSchema = object({
40761
+ vision: boolean(),
40762
+ tools: boolean(),
40763
+ streaming: boolean()
40764
+ });
40765
+ /** One model a provider offers. `features` overrides the kind's defaults, per field. */
40766
+ var LlmModelInfoSchema = object({
40767
+ id: string(),
40768
+ label: string().optional(),
40769
+ contextLength: number().int().positive().optional(),
40770
+ features: LlmModelFeaturesSchema.partial().optional()
40771
+ });
40478
40772
  /**
40479
- * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
40480
- * methods concat-fan across providers; single-row methods route to ONE
40481
- * provider by the `addonId` in the call input (the notification-output
40482
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
40483
- * (hub-placed); the cap stays open for future providers.
40484
- *
40485
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
40486
- * `apiKey` is a password field — providers REDACT it on read and merge on
40487
- * write; a stored key NEVER round-trips to a client.
40773
+ * The provider-specific part of a profile, validated by the provider that owns
40774
+ * the kind (`upsertProfile` refuses what it does not accept). A field its
40775
+ * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
40776
+ * keychain, never in the row, and reads back as the redaction marker.
40488
40777
  */
40489
- var LlmProfileKindSchema = _enum([
40490
- "openai-compatible",
40491
- "openai",
40492
- "anthropic",
40493
- "google",
40494
- "managed-local",
40495
- "apple-foundation"
40496
- ]);
40778
+ var LlmProviderConfigSchema = record(string(), unknown());
40497
40779
  var LlmProfileSchema = object({
40498
40780
  id: string(),
40499
40781
  name: string(),
40782
+ /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
40500
40783
  kind: LlmProfileKindSchema,
40501
40784
  /** Stamped by the provider — keeps the fanned catalog routable. */
40502
40785
  addonId: string(),
40503
40786
  enabled: boolean(),
40504
40787
  /** Vendor model id, or the managed runtime's loaded model. */
40505
40788
  model: string(),
40506
- /** Required for openai-compatible; override for cloud kinds. */
40507
- baseUrl: string().optional(),
40508
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
40509
- apiKey: string().optional(),
40510
40789
  /** Vision on/off. A vision call against a `false` profile is REFUSED, never
40511
40790
  * degraded to text — that shipped once and produced a confident answer to a
40512
40791
  * question about a picture nobody sent. */
@@ -40514,15 +40793,11 @@ var LlmProfileSchema = object({
40514
40793
  temperature: number().min(0).max(2).optional(),
40515
40794
  /** Nucleus sampling. Every wire we speak has it. */
40516
40795
  topP: number().min(0).max(1).optional(),
40517
- /** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
40518
- * wire does, and the client drops it there (measured: the request body gets
40519
- * `top_p` and no `top_k`). The profile editor hides the field wherever it
40520
- * would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
40796
+ /** Top-k sampling. Carried only by the wires that have it — a kind offers the
40797
+ * field in its editor only when its descriptor lists it in `profileFields`. */
40521
40798
  topK: number().int().positive().optional(),
40522
40799
  maxTokens: number().int().positive().optional(),
40523
- /** Prompt context window. Advisory for cloud kinds (they enforce their own);
40524
- * for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
40525
- * the model with, so it is the one field that changes a PROCESS. */
40800
+ /** Prompt context window. Advisory for cloud kinds (they enforce their own). */
40526
40801
  contextLength: number().int().positive().optional(),
40527
40802
  /** Default system prompt. A caller's `system` REPLACES it (never appends —
40528
40803
  * two system prompts fighting is worse than either alone). */
@@ -40548,16 +40823,37 @@ var LlmProfileSchema = object({
40548
40823
  * library; the REGISTRY of callable tools is ours and is empty in v1, so a
40549
40824
  * `true` here buys the wiring, not behaviour, until tools are registered. */
40550
40825
  toolsEnabled: boolean().default(false),
40551
- extraHeaders: record(string(), string()).optional(),
40552
- /** kind === 'managed-local' only (spec §4). */
40553
- runtime: ManagedRuntimeConfigSchema.optional(),
40554
- /**
40555
- * kind === 'apple-foundation' only: WHERE it runs — the only thing there is
40556
- * to configure (no key, no URL, no download; `model` is `apple-system`).
40557
- * `supportsVision` on such a row is stamped by the provider from the node's
40558
- * reported `imageInput`, never taken from the operator (D62).
40559
- */
40560
- appleFoundation: object({ nodeId: string() }).optional()
40826
+ /** Everything the kind's provider owns (endpoint, key, node, runtime…). */
40827
+ providerConfig: LlmProviderConfigSchema.default({})
40828
+ });
40829
+ /**
40830
+ * The common profile fields a kind's editor offers. The editor owns how each
40831
+ * one is drawn; the provider says which of them mean something on its wire.
40832
+ */
40833
+ var LlmProfileFieldSchema = _enum([
40834
+ "temperature",
40835
+ "topP",
40836
+ "topK",
40837
+ "maxTokens",
40838
+ "contextLength",
40839
+ "systemPrompt",
40840
+ "timeoutMs",
40841
+ "connectTimeoutMs",
40842
+ "firstTokenTimeoutMs",
40843
+ "idleTimeoutMs",
40844
+ "retry",
40845
+ "toolsEnabled"
40846
+ ]);
40847
+ /**
40848
+ * A provider-drawn part of the editor, by a generic widget id the admin UI
40849
+ * registers (`ai/apple-node`). `placement: 'model'` replaces the generic model
40850
+ * picker: that widget owns the model choice.
40851
+ */
40852
+ var LlmProviderWidgetSchema = object({
40853
+ id: string(),
40854
+ placement: _enum(["connection", "model"]),
40855
+ /** `providerConfig` keys this widget must fill before the profile can be saved. */
40856
+ requires: array(string()).optional()
40561
40857
  });
40562
40858
  /** ConfigUISchema tree passed through untyped on the wire (the
40563
40859
  * notification-output `ConfigSchemaPassthrough` precedent at
@@ -40566,11 +40862,56 @@ var ConfigSchemaPassthrough$3 = unknown();
40566
40862
  var LlmProfileKindDescriptorSchema = object({
40567
40863
  kind: LlmProfileKindSchema,
40568
40864
  label: string(),
40865
+ /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
40569
40866
  icon: string(),
40570
40867
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
40571
40868
  addonId: string(),
40572
- configSchema: ConfigSchemaPassthrough$3
40869
+ /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
40870
+ connectionSchema: ConfigSchemaPassthrough$3,
40871
+ /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
40872
+ advancedSchema: ConfigSchemaPassthrough$3.optional(),
40873
+ /** The kind's defaults; a model from `listModels` may override any of them. */
40874
+ features: LlmModelFeaturesSchema,
40875
+ /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
40876
+ visionEditable: boolean(),
40877
+ /** Where the model list comes from: `listModels`, `staticModels`, or nowhere. */
40878
+ modelCatalog: _enum([
40879
+ "fetch",
40880
+ "static",
40881
+ "none"
40882
+ ]),
40883
+ staticModels: array(LlmModelInfoSchema).optional(),
40884
+ /** The common fields that mean something on this kind's wire. */
40885
+ profileFields: array(LlmProfileFieldSchema),
40886
+ providerWidgets: array(LlmProviderWidgetSchema).optional()
40887
+ });
40888
+ /**
40889
+ * `listModels` input. `connection` is an UNSAVED draft of `providerConfig`
40890
+ * (the editor's form); with `profileId` too, a secret the draft leaves
40891
+ * untouched (absent or the redaction marker) is resolved server-side from the
40892
+ * stored profile — the browser never receives it.
40893
+ */
40894
+ var LlmListModelsInputSchema = object({
40895
+ addonId: string(),
40896
+ kind: LlmProfileKindSchema,
40897
+ profileId: string().optional(),
40898
+ connection: LlmProviderConfigSchema.optional()
40573
40899
  });
40900
+ var LlmListModelsErrorCodeSchema = _enum([
40901
+ "auth",
40902
+ "network",
40903
+ "unsupported",
40904
+ "invalid"
40905
+ ]);
40906
+ /** A RESULT, never a throw: "wrong key" is an answer the editor renders inline. */
40907
+ var LlmListModelsResultSchema = discriminatedUnion("ok", [object({
40908
+ ok: literal(true),
40909
+ models: array(LlmModelInfoSchema)
40910
+ }), object({
40911
+ ok: literal(false),
40912
+ code: LlmListModelsErrorCodeSchema,
40913
+ message: string()
40914
+ })]);
40574
40915
  var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
40575
40916
  var LlmDefaultSchema = object({
40576
40917
  selector: LlmDefaultSelectorSchema,
@@ -40670,7 +41011,10 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
40670
41011
  kind: "mutation",
40671
41012
  auth: "admin",
40672
41013
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
40673
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
41014
+ }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
41015
+ kind: "mutation",
41016
+ auth: "admin"
41017
+ }), method(object({}), array(LlmDefaultSchema)), method(object({
40674
41018
  selector: LlmDefaultSelectorSchema,
40675
41019
  profileId: string().nullable()
40676
41020
  }), _void(), {
@@ -44798,202 +45142,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
44798
45142
  auth: "admin"
44799
45143
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
44800
45144
  /**
44801
- * Zod schemas for persisted record types.
44802
- *
44803
- * These schemas serve as the single source of truth for types that are
44804
- * stored in the settings-store backend and retrieved via tRPC. They
44805
- * replace the manual TypeScript interfaces with schema-derived types,
44806
- * enabling runtime validation when reading from the backend.
44807
- *
44808
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
44809
- * keeps the original name for backward compatibility.
44810
- */
44811
- /**
44812
- * Auth model (v2 — 2026-05-12 caps-only):
44813
- *
44814
- * Two principals:
44815
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
44816
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
44817
- *
44818
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44819
- * `super_admin` — collapsed onto the single boolean because every
44820
- * non-admin caller is governed by the same scope-check rules; the
44821
- * distinction was only ever used to route role-specific procedures
44822
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44823
- * with `isAdmin: false` + an explicit scope list.
44824
- */
44825
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44826
- var MethodAccessSchema = _enum([
44827
- "view",
44828
- "create",
44829
- "delete"
44830
- ]);
44831
- /**
44832
- * A single scope grant. Three forms — checked in matcher with OR
44833
- * semantics; the first match decides whether the call passes:
44834
- *
44835
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44836
- * cap with the matching `scope` declaration. New caps inherit grants
44837
- * automatically — adding a device cap to the codebase makes it
44838
- * reachable to every user with `category:device [...]` without a
44839
- * re-grant. Use this for "family viewer" / "operator" tiers.
44840
- *
44841
- * - `addon` — every cap that ships inside a given addon id. Niche;
44842
- * useful when an integration needs to interact with one specific
44843
- * addon's surface regardless of how many caps it exports.
44844
- *
44845
- * - `capability` — the most precise form. Single cap name. Use for
44846
- * integration tokens where you want to grant `addons.installPackage`
44847
- * and nothing else.
44848
- *
44849
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44850
- * "give me everything" escape; there is no wildcard scope.
44851
- */
44852
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44853
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44854
- var CapScopeSchema = _enum(["device", "system"]);
44855
- /**
44856
- * DeviceSelector (scope model v3 — 2026-08-12).
44857
- *
44858
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44859
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44860
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44861
- * AFTER the grant was minted — no re-grant, no re-login.
44862
- *
44863
- * - `all` — every device in the deployment. The broad viewer/operator
44864
- * lever without a `category` grant (a `category` grant also covers device
44865
- * caps that carry no deviceId; `all` is specifically the device set).
44866
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44867
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44868
- * is NOT covered until the grant is edited.
44869
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44870
- * DYNAMIC. A device that changes type, or a new device of the type,
44871
- * re-resolves on the next request.
44872
- * - `locations` — every device whose operator-assigned `location` label is
44873
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44874
- * null/unset location matches NO `locations` selector.
44875
- */
44876
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44877
- object({ kind: literal("all") }),
44878
- object({
44879
- kind: literal("ids"),
44880
- ids: array(number().int()).min(1)
44881
- }),
44882
- object({
44883
- kind: literal("types"),
44884
- types: array(_enum(DeviceType)).min(1)
44885
- }),
44886
- object({
44887
- kind: literal("locations"),
44888
- locations: array(string().min(1)).min(1)
44889
- })
44890
- ]);
44891
- var DeviceTokenScopeSchema = object({
44892
- type: literal("device"),
44893
- /** The device SET this grant covers — resolved against the live fleet. */
44894
- selector: DeviceSelectorSchema,
44895
- access: array(MethodAccessSchema).min(1),
44896
- /**
44897
- * Whether a grant on a PARENT device transparently covers its accessory
44898
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44899
- * Direction is parent → children ONLY.
44900
- *
44901
- * Absent → the matcher DERIVES it from the access flavour: `view`
44902
- * inherits (a camera viewer sees the camera's accessories), `create` /
44903
- * `delete` do NOT (actuating/removing a child is an explicit act the
44904
- * operator must grant on the child, not inherit from the parent). Set it
44905
- * explicitly to override that default per grant.
44906
- */
44907
- includeLinked: boolean().optional()
44908
- });
44909
- /**
44910
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44911
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44912
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44913
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44914
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44915
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44916
- * migration cannot reach a JWT already in a client's hands; parse-time
44917
- * migration covers both without a flag day. No cast — the raw object is read
44918
- * through `Reflect.get` (its static type is `unknown`).
44919
- */
44920
- function migrateLegacyTokenScope(raw) {
44921
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44922
- if (Reflect.get(raw, "type") !== "device") return raw;
44923
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44924
- const targets = Reflect.get(raw, "targets");
44925
- if (!Array.isArray(targets)) return raw;
44926
- return {
44927
- type: "device",
44928
- selector: {
44929
- kind: "ids",
44930
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44931
- },
44932
- access: Reflect.get(raw, "access")
44933
- };
44934
- }
44935
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44936
- object({
44937
- type: literal("category"),
44938
- target: CapScopeSchema,
44939
- access: array(MethodAccessSchema).min(1)
44940
- }),
44941
- object({
44942
- type: literal("capability"),
44943
- target: string(),
44944
- access: array(MethodAccessSchema).min(1)
44945
- }),
44946
- object({
44947
- type: literal("addon"),
44948
- target: string(),
44949
- access: array(MethodAccessSchema).min(1)
44950
- }),
44951
- DeviceTokenScopeSchema
44952
- ]));
44953
- object({
44954
- id: string(),
44955
- username: string(),
44956
- passwordHash: string(),
44957
- /**
44958
- * Admin bypass. When true, the middleware skips the scope-access
44959
- * check entirely. There is no other axis of privilege; the legacy
44960
- * role enum collapsed onto this boolean in v2.
44961
- */
44962
- isAdmin: boolean().default(false),
44963
- allowedProviders: AllowedProviderSchema,
44964
- allowedDevices: AllowedDevicesSchema,
44965
- /**
44966
- * Scopes granted to this user. Admins bypass; their `scopes` is
44967
- * ignored. Non-admins without scopes are locked out of every
44968
- * protected call.
44969
- */
44970
- scopes: array(TokenScopeSchema).default([]),
44971
- createdAt: number(),
44972
- updatedAt: number()
44973
- });
44974
- object({
44975
- id: string(),
44976
- label: string(),
44977
- isAdmin: boolean().default(false),
44978
- allowedProviders: AllowedProviderSchema,
44979
- allowedDevices: AllowedDevicesSchema,
44980
- tokenHash: string(),
44981
- tokenPrefix: string(),
44982
- createdAt: number(),
44983
- lastUsedAt: number().optional()
44984
- });
44985
- object({
44986
- id: string(),
44987
- userId: string(),
44988
- name: string(),
44989
- tokenHash: string(),
44990
- tokenPrefix: string(),
44991
- scopes: array(TokenScopeSchema),
44992
- expiresAt: number().nullish(),
44993
- lastUsedAt: number().nullish(),
44994
- createdAt: number()
44995
- });
44996
- /**
44997
45145
  * `oauth-integration` — a collection cap by which an addon declares
44998
45146
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44999
45147
  * Each provider returns a static descriptor; the core enumerates them
@@ -64891,26 +65039,6 @@ var ApiKeySummarySchema = object({
64891
65039
  createdAt: number(),
64892
65040
  lastUsedAt: number().optional()
64893
65041
  });
64894
- var ScopedTokenSummarySchema = object({
64895
- id: string(),
64896
- userId: string(),
64897
- name: string(),
64898
- tokenPrefix: string(),
64899
- scopes: array(TokenScopeSchema),
64900
- expiresAt: number().nullish(),
64901
- lastUsedAt: number().nullish(),
64902
- createdAt: number()
64903
- });
64904
- var CreateScopedTokenInputSchema = object({
64905
- userId: string(),
64906
- name: string(),
64907
- scopes: array(TokenScopeSchema),
64908
- expiresAt: number().optional()
64909
- });
64910
- var CreateScopedTokenResultSchema = object({
64911
- token: string(),
64912
- record: ScopedTokenSummarySchema
64913
- });
64914
65042
  var OauthSessionSummarySchema = object({
64915
65043
  id: string(),
64916
65044
  userId: string(),
@@ -64932,11 +65060,11 @@ var TotpStatusSchema = object({
64932
65060
  confirmedAt: number().nullable()
64933
65061
  });
64934
65062
  /**
64935
- * user-management — singleton capability for user accounts, API keys,
64936
- * and scoped tokens.
65063
+ * user-management — singleton capability for user accounts and the
65064
+ * legacy API-key rows.
64937
65065
  *
64938
65066
  * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
64939
- * — the subset check on `setUserScopes` / `createScopedToken` is moot
65067
+ * — the subset check on `setUserScopes` is moot
64940
65068
  * because non-admins never reach these. If/when we open non-admin
64941
65069
  * delegation, structural caller-scope subset check goes inside the
64942
65070
  * provider.
@@ -64993,15 +65121,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
64993
65121
  kind: "mutation",
64994
65122
  auth: "admin",
64995
65123
  access: "delete"
64996
- }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
64997
- kind: "mutation",
64998
- auth: "admin",
64999
- access: "create"
65000
- }), method(object({ id: string() }), object({ success: literal(true) }), {
65001
- kind: "mutation",
65002
- auth: "admin",
65003
- access: "delete"
65004
- }), method(object({ token: string() }), ScopedTokenSummarySchema.nullable(), { access: "view" }), method(object({ userId: string() }), array(ScopedTokenSummarySchema), { auth: "admin" }), method(object({ userId: string() }), TotpSetupResultSchema, {
65124
+ }), method(object({ userId: string() }), TotpSetupResultSchema, {
65005
65125
  kind: "mutation",
65006
65126
  auth: "admin",
65007
65127
  access: "create"
@@ -71091,7 +71211,7 @@ Object.freeze({
71091
71211
  capName: "llm",
71092
71212
  capScope: "system",
71093
71213
  addonId: null,
71094
- access: "view"
71214
+ access: "create"
71095
71215
  },
71096
71216
  "llm.listNodeModels": {
71097
71217
  capName: "llm",
@@ -75755,12 +75875,6 @@ Object.freeze({
75755
75875
  addonId: null,
75756
75876
  access: "create"
75757
75877
  },
75758
- "userManagement.createScopedToken": {
75759
- capName: "user-management",
75760
- capScope: "system",
75761
- addonId: null,
75762
- access: "create"
75763
- },
75764
75878
  "userManagement.createUser": {
75765
75879
  capName: "user-management",
75766
75880
  capScope: "system",
@@ -75809,12 +75923,6 @@ Object.freeze({
75809
75923
  addonId: null,
75810
75924
  access: "view"
75811
75925
  },
75812
- "userManagement.listScopedTokens": {
75813
- capName: "user-management",
75814
- capScope: "system",
75815
- addonId: null,
75816
- access: "view"
75817
- },
75818
75926
  "userManagement.listUsers": {
75819
75927
  capName: "user-management",
75820
75928
  capScope: "system",
@@ -75869,12 +75977,6 @@ Object.freeze({
75869
75977
  addonId: null,
75870
75978
  access: "delete"
75871
75979
  },
75872
- "userManagement.revokeScopedToken": {
75873
- capName: "user-management",
75874
- capScope: "system",
75875
- addonId: null,
75876
- access: "delete"
75877
- },
75878
75980
  "userManagement.setupTotp": {
75879
75981
  capName: "user-management",
75880
75982
  capScope: "system",
@@ -75905,12 +76007,6 @@ Object.freeze({
75905
76007
  addonId: null,
75906
76008
  access: "view"
75907
76009
  },
75908
- "userManagement.validateScopedToken": {
75909
- capName: "user-management",
75910
- capScope: "system",
75911
- addonId: null,
75912
- access: "view"
75913
- },
75914
76010
  "userManagement.verifyTotp": {
75915
76011
  capName: "user-management",
75916
76012
  capScope: "system",