@camstack/addon-provider-homematic 1.2.139 → 1.2.141

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
@@ -5556,7 +5556,7 @@ var ZodIssueCode = {
5556
5556
  var ZodFirstPartyTypeKind;
5557
5557
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5558
5558
  //#endregion
5559
- //#region ../types/dist/sleep-BxjU_fJM.mjs
5559
+ //#region ../types/dist/sleep-yKL5gfrH.mjs
5560
5560
  /**
5561
5561
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5562
5562
  * window to float samples (D455).
@@ -7938,6 +7938,12 @@ function normalizeAddonInitResult(result) {
7938
7938
  if (Array.isArray(result)) return { providers: result };
7939
7939
  return result;
7940
7940
  }
7941
+ /**
7942
+ * The share-view scope kinds a share-link token can carry. The hub mints
7943
+ * and validates them (`ShareViewGrantSchema` builds its
7944
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
7945
+ */
7946
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7941
7947
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7942
7948
  var PeerBytesTicketSchema = object({
7943
7949
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12803,6 +12809,280 @@ var ConvertResultSchema = object({
12803
12809
  files: array(string()).readonly()
12804
12810
  })).readonly()
12805
12811
  });
12812
+ /**
12813
+ * Zod schemas for persisted record types.
12814
+ *
12815
+ * These schemas serve as the single source of truth for types that are
12816
+ * stored in the settings-store backend and retrieved via tRPC. They
12817
+ * replace the manual TypeScript interfaces with schema-derived types,
12818
+ * enabling runtime validation when reading from the backend.
12819
+ *
12820
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12821
+ * keeps the original name for backward compatibility.
12822
+ */
12823
+ /**
12824
+ * Auth model (v2 — 2026-05-12 caps-only):
12825
+ *
12826
+ * Two principals:
12827
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12828
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12829
+ *
12830
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12831
+ * `super_admin` — collapsed onto the single boolean because every
12832
+ * non-admin caller is governed by the same scope-check rules; the
12833
+ * distinction was only ever used to route role-specific procedures
12834
+ * which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
12835
+ * with `isAdmin: false` + an explicit scope list.
12836
+ */
12837
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12838
+ var MethodAccessSchema = _enum([
12839
+ "view",
12840
+ "create",
12841
+ "delete"
12842
+ ]);
12843
+ /**
12844
+ * A single scope grant. Three forms — checked in matcher with OR
12845
+ * semantics; the first match decides whether the call passes:
12846
+ *
12847
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12848
+ * cap with the matching `scope` declaration. New caps inherit grants
12849
+ * automatically — adding a device cap to the codebase makes it
12850
+ * reachable to every user with `category:device [...]` without a
12851
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12852
+ *
12853
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12854
+ * useful when an integration needs to interact with one specific
12855
+ * addon's surface regardless of how many caps it exports.
12856
+ *
12857
+ * - `capability` — the most precise form. Single cap name. Use for
12858
+ * integration tokens where you want to grant `addons.installPackage`
12859
+ * and nothing else.
12860
+ *
12861
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12862
+ * "give me everything" escape; there is no wildcard scope.
12863
+ */
12864
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12865
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12866
+ var CapScopeSchema = _enum(["device", "system"]);
12867
+ /**
12868
+ * DeviceSelector (scope model v3 — 2026-08-12).
12869
+ *
12870
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12871
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12872
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12873
+ * AFTER the grant was minted — no re-grant, no re-login.
12874
+ *
12875
+ * - `all` — every device in the deployment. The broad viewer/operator
12876
+ * lever without a `category` grant (a `category` grant also covers device
12877
+ * caps that carry no deviceId; `all` is specifically the device set).
12878
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
12879
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
12880
+ * is NOT covered until the grant is edited.
12881
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
12882
+ * DYNAMIC. A device that changes type, or a new device of the type,
12883
+ * re-resolves on the next request.
12884
+ * - `locations` — every device whose operator-assigned `location` label is
12885
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
12886
+ * null/unset location matches NO `locations` selector.
12887
+ */
12888
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
12889
+ object({ kind: literal("all") }),
12890
+ object({
12891
+ kind: literal("ids"),
12892
+ ids: array(number().int()).min(1)
12893
+ }),
12894
+ object({
12895
+ kind: literal("types"),
12896
+ types: array(_enum(DeviceType)).min(1)
12897
+ }),
12898
+ object({
12899
+ kind: literal("locations"),
12900
+ locations: array(string().min(1)).min(1)
12901
+ })
12902
+ ]);
12903
+ var DeviceTokenScopeSchema = object({
12904
+ type: literal("device"),
12905
+ /** The device SET this grant covers — resolved against the live fleet. */
12906
+ selector: DeviceSelectorSchema,
12907
+ access: array(MethodAccessSchema).min(1),
12908
+ /**
12909
+ * Whether a grant on a PARENT device transparently covers its accessory
12910
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
12911
+ * Direction is parent → children ONLY.
12912
+ *
12913
+ * Absent → the matcher DERIVES it from the access flavour: `view`
12914
+ * inherits (a camera viewer sees the camera's accessories), `create` /
12915
+ * `delete` do NOT (actuating/removing a child is an explicit act the
12916
+ * operator must grant on the child, not inherit from the parent). Set it
12917
+ * explicitly to override that default per grant.
12918
+ */
12919
+ includeLinked: boolean().optional()
12920
+ });
12921
+ /**
12922
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
12923
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
12924
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
12925
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
12926
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
12927
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
12928
+ * migration cannot reach a JWT already in a client's hands; parse-time
12929
+ * migration covers both without a flag day. No cast — the raw object is read
12930
+ * through `Reflect.get` (its static type is `unknown`).
12931
+ */
12932
+ function migrateLegacyTokenScope(raw) {
12933
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
12934
+ if (Reflect.get(raw, "type") !== "device") return raw;
12935
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
12936
+ const targets = Reflect.get(raw, "targets");
12937
+ if (!Array.isArray(targets)) return raw;
12938
+ return {
12939
+ type: "device",
12940
+ selector: {
12941
+ kind: "ids",
12942
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
12943
+ },
12944
+ access: Reflect.get(raw, "access")
12945
+ };
12946
+ }
12947
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
12948
+ object({
12949
+ type: literal("category"),
12950
+ target: CapScopeSchema,
12951
+ access: array(MethodAccessSchema).min(1)
12952
+ }),
12953
+ object({
12954
+ type: literal("capability"),
12955
+ target: string(),
12956
+ access: array(MethodAccessSchema).min(1)
12957
+ }),
12958
+ object({
12959
+ type: literal("addon"),
12960
+ target: string(),
12961
+ access: array(MethodAccessSchema).min(1)
12962
+ }),
12963
+ DeviceTokenScopeSchema
12964
+ ]));
12965
+ object({
12966
+ id: string(),
12967
+ username: string(),
12968
+ passwordHash: string(),
12969
+ /**
12970
+ * Admin bypass. When true, the middleware skips the scope-access
12971
+ * check entirely. There is no other axis of privilege; the legacy
12972
+ * role enum collapsed onto this boolean in v2.
12973
+ */
12974
+ isAdmin: boolean().default(false),
12975
+ allowedProviders: AllowedProviderSchema,
12976
+ allowedDevices: AllowedDevicesSchema,
12977
+ /**
12978
+ * Scopes granted to this user. Admins bypass; their `scopes` is
12979
+ * ignored. Non-admins without scopes are locked out of every
12980
+ * protected call.
12981
+ */
12982
+ scopes: array(TokenScopeSchema).default([]),
12983
+ createdAt: number(),
12984
+ updatedAt: number()
12985
+ });
12986
+ object({
12987
+ id: string(),
12988
+ label: string(),
12989
+ isAdmin: boolean().default(false),
12990
+ allowedProviders: AllowedProviderSchema,
12991
+ allowedDevices: AllowedDevicesSchema,
12992
+ tokenHash: string(),
12993
+ tokenPrefix: string(),
12994
+ createdAt: number(),
12995
+ lastUsedAt: number().optional()
12996
+ });
12997
+ object({
12998
+ id: string(),
12999
+ userId: string(),
13000
+ name: string(),
13001
+ tokenHash: string(),
13002
+ tokenPrefix: string(),
13003
+ scopes: array(TokenScopeSchema),
13004
+ expiresAt: number().nullish(),
13005
+ lastUsedAt: number().nullish(),
13006
+ createdAt: number()
13007
+ });
13008
+ /** What a share-view grant lets its holder see. */
13009
+ var ShareViewGrantSchema = object({
13010
+ kind: _enum(SHARE_VIEW_KINDS),
13011
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
13012
+ /** Talk-back, opt-in at mint time; absent means off. */
13013
+ talk: boolean().optional()
13014
+ });
13015
+ var ShareViewScopeSchema = object({
13016
+ type: literal("share-view"),
13017
+ grant: ShareViewGrantSchema
13018
+ });
13019
+ var AddonRoutesScopeSchema = object({
13020
+ type: literal("addon-routes"),
13021
+ access: array(MethodAccessSchema).min(1)
13022
+ });
13023
+ var PreferencesSelfScopeSchema = object({ type: literal("preferences-self") });
13024
+ var CredentialScopeSchema = union([
13025
+ literal("*"),
13026
+ ShareViewScopeSchema,
13027
+ AddonRoutesScopeSchema,
13028
+ PreferencesSelfScopeSchema,
13029
+ TokenScopeSchema
13030
+ ]);
13031
+ object({
13032
+ kind: literal("credential"),
13033
+ sub: string().min(1),
13034
+ jti: string().min(16),
13035
+ scopes: array(CredentialScopeSchema).min(1)
13036
+ });
13037
+ var PreferenceNamespaceSchema = string().regex(/^[a-z][a-z0-9.-]{0,63}$/);
13038
+ /** A namespace's value: a JSON object, opaque to the hub. */
13039
+ var PreferenceValueSchema = record(string(), unknown());
13040
+ var PreferenceDeviceIdSchema = string().min(1).max(64);
13041
+ /** A stored row, as the owner reads it. */
13042
+ var PreferenceRowSchema = object({
13043
+ namespace: PreferenceNamespaceSchema,
13044
+ value: PreferenceValueSchema,
13045
+ /** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
13046
+ revision: number().int().positive(),
13047
+ updatedAt: number().int(),
13048
+ /** The client id the last writer sent; `null` when it sent none. */
13049
+ updatedByDevice: PreferenceDeviceIdSchema.nullable()
13050
+ });
13051
+ object({
13052
+ /** Absent: every namespace the caller holds. */
13053
+ namespaces: array(PreferenceNamespaceSchema).max(32).optional() });
13054
+ object({ rows: array(PreferenceRowSchema) });
13055
+ object({
13056
+ namespace: PreferenceNamespaceSchema,
13057
+ value: PreferenceValueSchema,
13058
+ /**
13059
+ * The revision the edit was based on. Absent: last write wins. `0`: the
13060
+ * namespace must not exist yet. Any other value that is not the current
13061
+ * revision answers `conflict` and writes nothing.
13062
+ */
13063
+ baseRevision: number().int().nonnegative().optional(),
13064
+ deviceId: PreferenceDeviceIdSchema.optional()
13065
+ });
13066
+ discriminatedUnion("status", [object({
13067
+ status: literal("saved"),
13068
+ row: PreferenceRowSchema
13069
+ }), object({
13070
+ status: literal("conflict"),
13071
+ current: PreferenceRowSchema.nullable()
13072
+ })]);
13073
+ object({ namespace: PreferenceNamespaceSchema });
13074
+ object({
13075
+ /** `false` when the namespace did not exist. */
13076
+ deleted: boolean() });
13077
+ object({
13078
+ /** The revision the client holds per namespace; a namespace it does not list is new to it. */
13079
+ revisionByNamespace: record(PreferenceNamespaceSchema, number().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
13080
+ object({
13081
+ /** Every row whose revision differs from the client's, and every row it did not list. */
13082
+ rows: array(PreferenceRowSchema),
13083
+ /** Namespaces the client listed that no longer exist. */
13084
+ deleted: array(PreferenceNamespaceSchema)
13085
+ });
12806
13086
  _enum(["new-session", "step-up"]);
12807
13087
  /** The languages the hub's app landing pages are written in (D858). */
12808
13088
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -40158,38 +40438,37 @@ method(LlmRuntimeCompleteInputSchema, LlmGenerateResultSchema, {
40158
40438
  auth: "admin",
40159
40439
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
40160
40440
  });
40441
+ var LlmProfileKindSchema = string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "a kind id is lower-case letters, digits and dashes");
40442
+ /** What a model (or, by default, every model of a kind) can do. */
40443
+ var LlmModelFeaturesSchema = object({
40444
+ vision: boolean(),
40445
+ tools: boolean(),
40446
+ streaming: boolean()
40447
+ });
40448
+ /** One model a provider offers. `features` overrides the kind's defaults, per field. */
40449
+ var LlmModelInfoSchema = object({
40450
+ id: string(),
40451
+ label: string().optional(),
40452
+ contextLength: number().int().positive().optional(),
40453
+ features: LlmModelFeaturesSchema.partial().optional()
40454
+ });
40161
40455
  /**
40162
- * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
40163
- * methods concat-fan across providers; single-row methods route to ONE
40164
- * provider by the `addonId` in the call input (the notification-output
40165
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
40166
- * (hub-placed); the cap stays open for future providers.
40167
- *
40168
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
40169
- * `apiKey` is a password field — providers REDACT it on read and merge on
40170
- * write; a stored key NEVER round-trips to a client.
40456
+ * The provider-specific part of a profile, validated by the provider that owns
40457
+ * the kind (`upsertProfile` refuses what it does not accept). A field its
40458
+ * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
40459
+ * keychain, never in the row, and reads back as the redaction marker.
40171
40460
  */
40172
- var LlmProfileKindSchema = _enum([
40173
- "openai-compatible",
40174
- "openai",
40175
- "anthropic",
40176
- "google",
40177
- "managed-local",
40178
- "apple-foundation"
40179
- ]);
40461
+ var LlmProviderConfigSchema = record(string(), unknown());
40180
40462
  var LlmProfileSchema = object({
40181
40463
  id: string(),
40182
40464
  name: string(),
40465
+ /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
40183
40466
  kind: LlmProfileKindSchema,
40184
40467
  /** Stamped by the provider — keeps the fanned catalog routable. */
40185
40468
  addonId: string(),
40186
40469
  enabled: boolean(),
40187
40470
  /** Vendor model id, or the managed runtime's loaded model. */
40188
40471
  model: string(),
40189
- /** Required for openai-compatible; override for cloud kinds. */
40190
- baseUrl: string().optional(),
40191
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
40192
- apiKey: string().optional(),
40193
40472
  /** Vision on/off. A vision call against a `false` profile is REFUSED, never
40194
40473
  * degraded to text — that shipped once and produced a confident answer to a
40195
40474
  * question about a picture nobody sent. */
@@ -40197,15 +40476,11 @@ var LlmProfileSchema = object({
40197
40476
  temperature: number().min(0).max(2).optional(),
40198
40477
  /** Nucleus sampling. Every wire we speak has it. */
40199
40478
  topP: number().min(0).max(1).optional(),
40200
- /** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
40201
- * wire does, and the client drops it there (measured: the request body gets
40202
- * `top_p` and no `top_k`). The profile editor hides the field wherever it
40203
- * would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
40479
+ /** Top-k sampling. Carried only by the wires that have it — a kind offers the
40480
+ * field in its editor only when its descriptor lists it in `profileFields`. */
40204
40481
  topK: number().int().positive().optional(),
40205
40482
  maxTokens: number().int().positive().optional(),
40206
- /** Prompt context window. Advisory for cloud kinds (they enforce their own);
40207
- * for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
40208
- * the model with, so it is the one field that changes a PROCESS. */
40483
+ /** Prompt context window. Advisory for cloud kinds (they enforce their own). */
40209
40484
  contextLength: number().int().positive().optional(),
40210
40485
  /** Default system prompt. A caller's `system` REPLACES it (never appends —
40211
40486
  * two system prompts fighting is worse than either alone). */
@@ -40231,16 +40506,37 @@ var LlmProfileSchema = object({
40231
40506
  * library; the REGISTRY of callable tools is ours and is empty in v1, so a
40232
40507
  * `true` here buys the wiring, not behaviour, until tools are registered. */
40233
40508
  toolsEnabled: boolean().default(false),
40234
- extraHeaders: record(string(), string()).optional(),
40235
- /** kind === 'managed-local' only (spec §4). */
40236
- runtime: ManagedRuntimeConfigSchema.optional(),
40237
- /**
40238
- * kind === 'apple-foundation' only: WHERE it runs — the only thing there is
40239
- * to configure (no key, no URL, no download; `model` is `apple-system`).
40240
- * `supportsVision` on such a row is stamped by the provider from the node's
40241
- * reported `imageInput`, never taken from the operator (D62).
40242
- */
40243
- appleFoundation: object({ nodeId: string() }).optional()
40509
+ /** Everything the kind's provider owns (endpoint, key, node, runtime…). */
40510
+ providerConfig: LlmProviderConfigSchema.default({})
40511
+ });
40512
+ /**
40513
+ * The common profile fields a kind's editor offers. The editor owns how each
40514
+ * one is drawn; the provider says which of them mean something on its wire.
40515
+ */
40516
+ var LlmProfileFieldSchema = _enum([
40517
+ "temperature",
40518
+ "topP",
40519
+ "topK",
40520
+ "maxTokens",
40521
+ "contextLength",
40522
+ "systemPrompt",
40523
+ "timeoutMs",
40524
+ "connectTimeoutMs",
40525
+ "firstTokenTimeoutMs",
40526
+ "idleTimeoutMs",
40527
+ "retry",
40528
+ "toolsEnabled"
40529
+ ]);
40530
+ /**
40531
+ * A provider-drawn part of the editor, by a generic widget id the admin UI
40532
+ * registers (`ai/apple-node`). `placement: 'model'` replaces the generic model
40533
+ * picker: that widget owns the model choice.
40534
+ */
40535
+ var LlmProviderWidgetSchema = object({
40536
+ id: string(),
40537
+ placement: _enum(["connection", "model"]),
40538
+ /** `providerConfig` keys this widget must fill before the profile can be saved. */
40539
+ requires: array(string()).optional()
40244
40540
  });
40245
40541
  /** ConfigUISchema tree passed through untyped on the wire (the
40246
40542
  * notification-output `ConfigSchemaPassthrough` precedent at
@@ -40249,11 +40545,56 @@ var ConfigSchemaPassthrough$3 = unknown();
40249
40545
  var LlmProfileKindDescriptorSchema = object({
40250
40546
  kind: LlmProfileKindSchema,
40251
40547
  label: string(),
40548
+ /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
40252
40549
  icon: string(),
40253
40550
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
40254
40551
  addonId: string(),
40255
- configSchema: ConfigSchemaPassthrough$3
40552
+ /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
40553
+ connectionSchema: ConfigSchemaPassthrough$3,
40554
+ /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
40555
+ advancedSchema: ConfigSchemaPassthrough$3.optional(),
40556
+ /** The kind's defaults; a model from `listModels` may override any of them. */
40557
+ features: LlmModelFeaturesSchema,
40558
+ /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
40559
+ visionEditable: boolean(),
40560
+ /** Where the model list comes from: `listModels`, `staticModels`, or nowhere. */
40561
+ modelCatalog: _enum([
40562
+ "fetch",
40563
+ "static",
40564
+ "none"
40565
+ ]),
40566
+ staticModels: array(LlmModelInfoSchema).optional(),
40567
+ /** The common fields that mean something on this kind's wire. */
40568
+ profileFields: array(LlmProfileFieldSchema),
40569
+ providerWidgets: array(LlmProviderWidgetSchema).optional()
40570
+ });
40571
+ /**
40572
+ * `listModels` input. `connection` is an UNSAVED draft of `providerConfig`
40573
+ * (the editor's form); with `profileId` too, a secret the draft leaves
40574
+ * untouched (absent or the redaction marker) is resolved server-side from the
40575
+ * stored profile — the browser never receives it.
40576
+ */
40577
+ var LlmListModelsInputSchema = object({
40578
+ addonId: string(),
40579
+ kind: LlmProfileKindSchema,
40580
+ profileId: string().optional(),
40581
+ connection: LlmProviderConfigSchema.optional()
40256
40582
  });
40583
+ var LlmListModelsErrorCodeSchema = _enum([
40584
+ "auth",
40585
+ "network",
40586
+ "unsupported",
40587
+ "invalid"
40588
+ ]);
40589
+ /** A RESULT, never a throw: "wrong key" is an answer the editor renders inline. */
40590
+ var LlmListModelsResultSchema = discriminatedUnion("ok", [object({
40591
+ ok: literal(true),
40592
+ models: array(LlmModelInfoSchema)
40593
+ }), object({
40594
+ ok: literal(false),
40595
+ code: LlmListModelsErrorCodeSchema,
40596
+ message: string()
40597
+ })]);
40257
40598
  var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
40258
40599
  var LlmDefaultSchema = object({
40259
40600
  selector: LlmDefaultSelectorSchema,
@@ -40353,7 +40694,10 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
40353
40694
  kind: "mutation",
40354
40695
  auth: "admin",
40355
40696
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
40356
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
40697
+ }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
40698
+ kind: "mutation",
40699
+ auth: "admin"
40700
+ }), method(object({}), array(LlmDefaultSchema)), method(object({
40357
40701
  selector: LlmDefaultSelectorSchema,
40358
40702
  profileId: string().nullable()
40359
40703
  }), _void(), {
@@ -44459,202 +44803,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
44459
44803
  auth: "admin"
44460
44804
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
44461
44805
  /**
44462
- * Zod schemas for persisted record types.
44463
- *
44464
- * These schemas serve as the single source of truth for types that are
44465
- * stored in the settings-store backend and retrieved via tRPC. They
44466
- * replace the manual TypeScript interfaces with schema-derived types,
44467
- * enabling runtime validation when reading from the backend.
44468
- *
44469
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
44470
- * keeps the original name for backward compatibility.
44471
- */
44472
- /**
44473
- * Auth model (v2 — 2026-05-12 caps-only):
44474
- *
44475
- * Two principals:
44476
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
44477
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
44478
- *
44479
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44480
- * `super_admin` — collapsed onto the single boolean because every
44481
- * non-admin caller is governed by the same scope-check rules; the
44482
- * distinction was only ever used to route role-specific procedures
44483
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44484
- * with `isAdmin: false` + an explicit scope list.
44485
- */
44486
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44487
- var MethodAccessSchema = _enum([
44488
- "view",
44489
- "create",
44490
- "delete"
44491
- ]);
44492
- /**
44493
- * A single scope grant. Three forms — checked in matcher with OR
44494
- * semantics; the first match decides whether the call passes:
44495
- *
44496
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44497
- * cap with the matching `scope` declaration. New caps inherit grants
44498
- * automatically — adding a device cap to the codebase makes it
44499
- * reachable to every user with `category:device [...]` without a
44500
- * re-grant. Use this for "family viewer" / "operator" tiers.
44501
- *
44502
- * - `addon` — every cap that ships inside a given addon id. Niche;
44503
- * useful when an integration needs to interact with one specific
44504
- * addon's surface regardless of how many caps it exports.
44505
- *
44506
- * - `capability` — the most precise form. Single cap name. Use for
44507
- * integration tokens where you want to grant `addons.installPackage`
44508
- * and nothing else.
44509
- *
44510
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44511
- * "give me everything" escape; there is no wildcard scope.
44512
- */
44513
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44514
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44515
- var CapScopeSchema = _enum(["device", "system"]);
44516
- /**
44517
- * DeviceSelector (scope model v3 — 2026-08-12).
44518
- *
44519
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44520
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44521
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44522
- * AFTER the grant was minted — no re-grant, no re-login.
44523
- *
44524
- * - `all` — every device in the deployment. The broad viewer/operator
44525
- * lever without a `category` grant (a `category` grant also covers device
44526
- * caps that carry no deviceId; `all` is specifically the device set).
44527
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44528
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44529
- * is NOT covered until the grant is edited.
44530
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44531
- * DYNAMIC. A device that changes type, or a new device of the type,
44532
- * re-resolves on the next request.
44533
- * - `locations` — every device whose operator-assigned `location` label is
44534
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44535
- * null/unset location matches NO `locations` selector.
44536
- */
44537
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44538
- object({ kind: literal("all") }),
44539
- object({
44540
- kind: literal("ids"),
44541
- ids: array(number().int()).min(1)
44542
- }),
44543
- object({
44544
- kind: literal("types"),
44545
- types: array(_enum(DeviceType)).min(1)
44546
- }),
44547
- object({
44548
- kind: literal("locations"),
44549
- locations: array(string().min(1)).min(1)
44550
- })
44551
- ]);
44552
- var DeviceTokenScopeSchema = object({
44553
- type: literal("device"),
44554
- /** The device SET this grant covers — resolved against the live fleet. */
44555
- selector: DeviceSelectorSchema,
44556
- access: array(MethodAccessSchema).min(1),
44557
- /**
44558
- * Whether a grant on a PARENT device transparently covers its accessory
44559
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44560
- * Direction is parent → children ONLY.
44561
- *
44562
- * Absent → the matcher DERIVES it from the access flavour: `view`
44563
- * inherits (a camera viewer sees the camera's accessories), `create` /
44564
- * `delete` do NOT (actuating/removing a child is an explicit act the
44565
- * operator must grant on the child, not inherit from the parent). Set it
44566
- * explicitly to override that default per grant.
44567
- */
44568
- includeLinked: boolean().optional()
44569
- });
44570
- /**
44571
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44572
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44573
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44574
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44575
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44576
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44577
- * migration cannot reach a JWT already in a client's hands; parse-time
44578
- * migration covers both without a flag day. No cast — the raw object is read
44579
- * through `Reflect.get` (its static type is `unknown`).
44580
- */
44581
- function migrateLegacyTokenScope(raw) {
44582
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44583
- if (Reflect.get(raw, "type") !== "device") return raw;
44584
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44585
- const targets = Reflect.get(raw, "targets");
44586
- if (!Array.isArray(targets)) return raw;
44587
- return {
44588
- type: "device",
44589
- selector: {
44590
- kind: "ids",
44591
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44592
- },
44593
- access: Reflect.get(raw, "access")
44594
- };
44595
- }
44596
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44597
- object({
44598
- type: literal("category"),
44599
- target: CapScopeSchema,
44600
- access: array(MethodAccessSchema).min(1)
44601
- }),
44602
- object({
44603
- type: literal("capability"),
44604
- target: string(),
44605
- access: array(MethodAccessSchema).min(1)
44606
- }),
44607
- object({
44608
- type: literal("addon"),
44609
- target: string(),
44610
- access: array(MethodAccessSchema).min(1)
44611
- }),
44612
- DeviceTokenScopeSchema
44613
- ]));
44614
- object({
44615
- id: string(),
44616
- username: string(),
44617
- passwordHash: string(),
44618
- /**
44619
- * Admin bypass. When true, the middleware skips the scope-access
44620
- * check entirely. There is no other axis of privilege; the legacy
44621
- * role enum collapsed onto this boolean in v2.
44622
- */
44623
- isAdmin: boolean().default(false),
44624
- allowedProviders: AllowedProviderSchema,
44625
- allowedDevices: AllowedDevicesSchema,
44626
- /**
44627
- * Scopes granted to this user. Admins bypass; their `scopes` is
44628
- * ignored. Non-admins without scopes are locked out of every
44629
- * protected call.
44630
- */
44631
- scopes: array(TokenScopeSchema).default([]),
44632
- createdAt: number(),
44633
- updatedAt: number()
44634
- });
44635
- object({
44636
- id: string(),
44637
- label: string(),
44638
- isAdmin: boolean().default(false),
44639
- allowedProviders: AllowedProviderSchema,
44640
- allowedDevices: AllowedDevicesSchema,
44641
- tokenHash: string(),
44642
- tokenPrefix: string(),
44643
- createdAt: number(),
44644
- lastUsedAt: number().optional()
44645
- });
44646
- object({
44647
- id: string(),
44648
- userId: string(),
44649
- name: string(),
44650
- tokenHash: string(),
44651
- tokenPrefix: string(),
44652
- scopes: array(TokenScopeSchema),
44653
- expiresAt: number().nullish(),
44654
- lastUsedAt: number().nullish(),
44655
- createdAt: number()
44656
- });
44657
- /**
44658
44806
  * `oauth-integration` — a collection cap by which an addon declares
44659
44807
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44660
44808
  * Each provider returns a static descriptor; the core enumerates them
@@ -64437,26 +64585,6 @@ var ApiKeySummarySchema = object({
64437
64585
  createdAt: number(),
64438
64586
  lastUsedAt: number().optional()
64439
64587
  });
64440
- var ScopedTokenSummarySchema = object({
64441
- id: string(),
64442
- userId: string(),
64443
- name: string(),
64444
- tokenPrefix: string(),
64445
- scopes: array(TokenScopeSchema),
64446
- expiresAt: number().nullish(),
64447
- lastUsedAt: number().nullish(),
64448
- createdAt: number()
64449
- });
64450
- var CreateScopedTokenInputSchema = object({
64451
- userId: string(),
64452
- name: string(),
64453
- scopes: array(TokenScopeSchema),
64454
- expiresAt: number().optional()
64455
- });
64456
- var CreateScopedTokenResultSchema = object({
64457
- token: string(),
64458
- record: ScopedTokenSummarySchema
64459
- });
64460
64588
  var OauthSessionSummarySchema = object({
64461
64589
  id: string(),
64462
64590
  userId: string(),
@@ -64478,11 +64606,11 @@ var TotpStatusSchema = object({
64478
64606
  confirmedAt: number().nullable()
64479
64607
  });
64480
64608
  /**
64481
- * user-management — singleton capability for user accounts, API keys,
64482
- * and scoped tokens.
64609
+ * user-management — singleton capability for user accounts and the
64610
+ * legacy API-key rows.
64483
64611
  *
64484
64612
  * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
64485
- * — the subset check on `setUserScopes` / `createScopedToken` is moot
64613
+ * — the subset check on `setUserScopes` is moot
64486
64614
  * because non-admins never reach these. If/when we open non-admin
64487
64615
  * delegation, structural caller-scope subset check goes inside the
64488
64616
  * provider.
@@ -64539,15 +64667,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
64539
64667
  kind: "mutation",
64540
64668
  auth: "admin",
64541
64669
  access: "delete"
64542
- }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
64543
- kind: "mutation",
64544
- auth: "admin",
64545
- access: "create"
64546
- }), method(object({ id: string() }), object({ success: literal(true) }), {
64547
- kind: "mutation",
64548
- auth: "admin",
64549
- access: "delete"
64550
- }), method(object({ token: string() }), ScopedTokenSummarySchema.nullable(), { access: "view" }), method(object({ userId: string() }), array(ScopedTokenSummarySchema), { auth: "admin" }), method(object({ userId: string() }), TotpSetupResultSchema, {
64670
+ }), method(object({ userId: string() }), TotpSetupResultSchema, {
64551
64671
  kind: "mutation",
64552
64672
  auth: "admin",
64553
64673
  access: "create"
@@ -70637,7 +70757,7 @@ Object.freeze({
70637
70757
  capName: "llm",
70638
70758
  capScope: "system",
70639
70759
  addonId: null,
70640
- access: "view"
70760
+ access: "create"
70641
70761
  },
70642
70762
  "llm.listNodeModels": {
70643
70763
  capName: "llm",
@@ -75301,12 +75421,6 @@ Object.freeze({
75301
75421
  addonId: null,
75302
75422
  access: "create"
75303
75423
  },
75304
- "userManagement.createScopedToken": {
75305
- capName: "user-management",
75306
- capScope: "system",
75307
- addonId: null,
75308
- access: "create"
75309
- },
75310
75424
  "userManagement.createUser": {
75311
75425
  capName: "user-management",
75312
75426
  capScope: "system",
@@ -75355,12 +75469,6 @@ Object.freeze({
75355
75469
  addonId: null,
75356
75470
  access: "view"
75357
75471
  },
75358
- "userManagement.listScopedTokens": {
75359
- capName: "user-management",
75360
- capScope: "system",
75361
- addonId: null,
75362
- access: "view"
75363
- },
75364
75472
  "userManagement.listUsers": {
75365
75473
  capName: "user-management",
75366
75474
  capScope: "system",
@@ -75415,12 +75523,6 @@ Object.freeze({
75415
75523
  addonId: null,
75416
75524
  access: "delete"
75417
75525
  },
75418
- "userManagement.revokeScopedToken": {
75419
- capName: "user-management",
75420
- capScope: "system",
75421
- addonId: null,
75422
- access: "delete"
75423
- },
75424
75526
  "userManagement.setupTotp": {
75425
75527
  capName: "user-management",
75426
75528
  capScope: "system",
@@ -75451,12 +75553,6 @@ Object.freeze({
75451
75553
  addonId: null,
75452
75554
  access: "view"
75453
75555
  },
75454
- "userManagement.validateScopedToken": {
75455
- capName: "user-management",
75456
- capScope: "system",
75457
- addonId: null,
75458
- access: "view"
75459
- },
75460
75556
  "userManagement.verifyTotp": {
75461
75557
  capName: "user-management",
75462
75558
  capScope: "system",