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