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