@camstack/addon-provider-velux 0.2.129 → 0.2.131

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
@@ -5413,7 +5413,7 @@ var ZodIssueCode = {
5413
5413
  var ZodFirstPartyTypeKind;
5414
5414
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5415
5415
  //#endregion
5416
- //#region ../types/dist/sleep-BxjU_fJM.mjs
5416
+ //#region ../types/dist/sleep-yKL5gfrH.mjs
5417
5417
  /**
5418
5418
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5419
5419
  * window to float samples (D455).
@@ -7795,6 +7795,12 @@ function normalizeAddonInitResult(result) {
7795
7795
  if (Array.isArray(result)) return { providers: result };
7796
7796
  return result;
7797
7797
  }
7798
+ /**
7799
+ * The share-view scope kinds a share-link token can carry. The hub mints
7800
+ * and validates them (`ShareViewGrantSchema` builds its
7801
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
7802
+ */
7803
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7798
7804
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7799
7805
  var PeerBytesTicketSchema = object({
7800
7806
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12474,6 +12480,280 @@ var ConvertResultSchema = object({
12474
12480
  files: array(string()).readonly()
12475
12481
  })).readonly()
12476
12482
  });
12483
+ /**
12484
+ * Zod schemas for persisted record types.
12485
+ *
12486
+ * These schemas serve as the single source of truth for types that are
12487
+ * stored in the settings-store backend and retrieved via tRPC. They
12488
+ * replace the manual TypeScript interfaces with schema-derived types,
12489
+ * enabling runtime validation when reading from the backend.
12490
+ *
12491
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12492
+ * keeps the original name for backward compatibility.
12493
+ */
12494
+ /**
12495
+ * Auth model (v2 — 2026-05-12 caps-only):
12496
+ *
12497
+ * Two principals:
12498
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12499
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12500
+ *
12501
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12502
+ * `super_admin` — collapsed onto the single boolean because every
12503
+ * non-admin caller is governed by the same scope-check rules; the
12504
+ * distinction was only ever used to route role-specific procedures
12505
+ * which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
12506
+ * with `isAdmin: false` + an explicit scope list.
12507
+ */
12508
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12509
+ var MethodAccessSchema = _enum([
12510
+ "view",
12511
+ "create",
12512
+ "delete"
12513
+ ]);
12514
+ /**
12515
+ * A single scope grant. Three forms — checked in matcher with OR
12516
+ * semantics; the first match decides whether the call passes:
12517
+ *
12518
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12519
+ * cap with the matching `scope` declaration. New caps inherit grants
12520
+ * automatically — adding a device cap to the codebase makes it
12521
+ * reachable to every user with `category:device [...]` without a
12522
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12523
+ *
12524
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12525
+ * useful when an integration needs to interact with one specific
12526
+ * addon's surface regardless of how many caps it exports.
12527
+ *
12528
+ * - `capability` — the most precise form. Single cap name. Use for
12529
+ * integration tokens where you want to grant `addons.installPackage`
12530
+ * and nothing else.
12531
+ *
12532
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12533
+ * "give me everything" escape; there is no wildcard scope.
12534
+ */
12535
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12536
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12537
+ var CapScopeSchema = _enum(["device", "system"]);
12538
+ /**
12539
+ * DeviceSelector (scope model v3 — 2026-08-12).
12540
+ *
12541
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12542
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12543
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12544
+ * AFTER the grant was minted — no re-grant, no re-login.
12545
+ *
12546
+ * - `all` — every device in the deployment. The broad viewer/operator
12547
+ * lever without a `category` grant (a `category` grant also covers device
12548
+ * caps that carry no deviceId; `all` is specifically the device set).
12549
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
12550
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
12551
+ * is NOT covered until the grant is edited.
12552
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
12553
+ * DYNAMIC. A device that changes type, or a new device of the type,
12554
+ * re-resolves on the next request.
12555
+ * - `locations` — every device whose operator-assigned `location` label is
12556
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
12557
+ * null/unset location matches NO `locations` selector.
12558
+ */
12559
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
12560
+ object({ kind: literal("all") }),
12561
+ object({
12562
+ kind: literal("ids"),
12563
+ ids: array(number().int()).min(1)
12564
+ }),
12565
+ object({
12566
+ kind: literal("types"),
12567
+ types: array(_enum(DeviceType)).min(1)
12568
+ }),
12569
+ object({
12570
+ kind: literal("locations"),
12571
+ locations: array(string().min(1)).min(1)
12572
+ })
12573
+ ]);
12574
+ var DeviceTokenScopeSchema = object({
12575
+ type: literal("device"),
12576
+ /** The device SET this grant covers — resolved against the live fleet. */
12577
+ selector: DeviceSelectorSchema,
12578
+ access: array(MethodAccessSchema).min(1),
12579
+ /**
12580
+ * Whether a grant on a PARENT device transparently covers its accessory
12581
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
12582
+ * Direction is parent → children ONLY.
12583
+ *
12584
+ * Absent → the matcher DERIVES it from the access flavour: `view`
12585
+ * inherits (a camera viewer sees the camera's accessories), `create` /
12586
+ * `delete` do NOT (actuating/removing a child is an explicit act the
12587
+ * operator must grant on the child, not inherit from the parent). Set it
12588
+ * explicitly to override that default per grant.
12589
+ */
12590
+ includeLinked: boolean().optional()
12591
+ });
12592
+ /**
12593
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
12594
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
12595
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
12596
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
12597
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
12598
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
12599
+ * migration cannot reach a JWT already in a client's hands; parse-time
12600
+ * migration covers both without a flag day. No cast — the raw object is read
12601
+ * through `Reflect.get` (its static type is `unknown`).
12602
+ */
12603
+ function migrateLegacyTokenScope(raw) {
12604
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
12605
+ if (Reflect.get(raw, "type") !== "device") return raw;
12606
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
12607
+ const targets = Reflect.get(raw, "targets");
12608
+ if (!Array.isArray(targets)) return raw;
12609
+ return {
12610
+ type: "device",
12611
+ selector: {
12612
+ kind: "ids",
12613
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
12614
+ },
12615
+ access: Reflect.get(raw, "access")
12616
+ };
12617
+ }
12618
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
12619
+ object({
12620
+ type: literal("category"),
12621
+ target: CapScopeSchema,
12622
+ access: array(MethodAccessSchema).min(1)
12623
+ }),
12624
+ object({
12625
+ type: literal("capability"),
12626
+ target: string(),
12627
+ access: array(MethodAccessSchema).min(1)
12628
+ }),
12629
+ object({
12630
+ type: literal("addon"),
12631
+ target: string(),
12632
+ access: array(MethodAccessSchema).min(1)
12633
+ }),
12634
+ DeviceTokenScopeSchema
12635
+ ]));
12636
+ object({
12637
+ id: string(),
12638
+ username: string(),
12639
+ passwordHash: string(),
12640
+ /**
12641
+ * Admin bypass. When true, the middleware skips the scope-access
12642
+ * check entirely. There is no other axis of privilege; the legacy
12643
+ * role enum collapsed onto this boolean in v2.
12644
+ */
12645
+ isAdmin: boolean().default(false),
12646
+ allowedProviders: AllowedProviderSchema,
12647
+ allowedDevices: AllowedDevicesSchema,
12648
+ /**
12649
+ * Scopes granted to this user. Admins bypass; their `scopes` is
12650
+ * ignored. Non-admins without scopes are locked out of every
12651
+ * protected call.
12652
+ */
12653
+ scopes: array(TokenScopeSchema).default([]),
12654
+ createdAt: number(),
12655
+ updatedAt: number()
12656
+ });
12657
+ object({
12658
+ id: string(),
12659
+ label: string(),
12660
+ isAdmin: boolean().default(false),
12661
+ allowedProviders: AllowedProviderSchema,
12662
+ allowedDevices: AllowedDevicesSchema,
12663
+ tokenHash: string(),
12664
+ tokenPrefix: string(),
12665
+ createdAt: number(),
12666
+ lastUsedAt: number().optional()
12667
+ });
12668
+ object({
12669
+ id: string(),
12670
+ userId: string(),
12671
+ name: string(),
12672
+ tokenHash: string(),
12673
+ tokenPrefix: string(),
12674
+ scopes: array(TokenScopeSchema),
12675
+ expiresAt: number().nullish(),
12676
+ lastUsedAt: number().nullish(),
12677
+ createdAt: number()
12678
+ });
12679
+ /** What a share-view grant lets its holder see. */
12680
+ var ShareViewGrantSchema = object({
12681
+ kind: _enum(SHARE_VIEW_KINDS),
12682
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
12683
+ /** Talk-back, opt-in at mint time; absent means off. */
12684
+ talk: boolean().optional()
12685
+ });
12686
+ var ShareViewScopeSchema = object({
12687
+ type: literal("share-view"),
12688
+ grant: ShareViewGrantSchema
12689
+ });
12690
+ var AddonRoutesScopeSchema = object({
12691
+ type: literal("addon-routes"),
12692
+ access: array(MethodAccessSchema).min(1)
12693
+ });
12694
+ var PreferencesSelfScopeSchema = object({ type: literal("preferences-self") });
12695
+ var CredentialScopeSchema = union([
12696
+ literal("*"),
12697
+ ShareViewScopeSchema,
12698
+ AddonRoutesScopeSchema,
12699
+ PreferencesSelfScopeSchema,
12700
+ TokenScopeSchema
12701
+ ]);
12702
+ object({
12703
+ kind: literal("credential"),
12704
+ sub: string().min(1),
12705
+ jti: string().min(16),
12706
+ scopes: array(CredentialScopeSchema).min(1)
12707
+ });
12708
+ var PreferenceNamespaceSchema = string().regex(/^[a-z][a-z0-9.-]{0,63}$/);
12709
+ /** A namespace's value: a JSON object, opaque to the hub. */
12710
+ var PreferenceValueSchema = record(string(), unknown());
12711
+ var PreferenceDeviceIdSchema = string().min(1).max(64);
12712
+ /** A stored row, as the owner reads it. */
12713
+ var PreferenceRowSchema = object({
12714
+ namespace: PreferenceNamespaceSchema,
12715
+ value: PreferenceValueSchema,
12716
+ /** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
12717
+ revision: number().int().positive(),
12718
+ updatedAt: number().int(),
12719
+ /** The client id the last writer sent; `null` when it sent none. */
12720
+ updatedByDevice: PreferenceDeviceIdSchema.nullable()
12721
+ });
12722
+ object({
12723
+ /** Absent: every namespace the caller holds. */
12724
+ namespaces: array(PreferenceNamespaceSchema).max(32).optional() });
12725
+ object({ rows: array(PreferenceRowSchema) });
12726
+ object({
12727
+ namespace: PreferenceNamespaceSchema,
12728
+ value: PreferenceValueSchema,
12729
+ /**
12730
+ * The revision the edit was based on. Absent: last write wins. `0`: the
12731
+ * namespace must not exist yet. Any other value that is not the current
12732
+ * revision answers `conflict` and writes nothing.
12733
+ */
12734
+ baseRevision: number().int().nonnegative().optional(),
12735
+ deviceId: PreferenceDeviceIdSchema.optional()
12736
+ });
12737
+ discriminatedUnion("status", [object({
12738
+ status: literal("saved"),
12739
+ row: PreferenceRowSchema
12740
+ }), object({
12741
+ status: literal("conflict"),
12742
+ current: PreferenceRowSchema.nullable()
12743
+ })]);
12744
+ object({ namespace: PreferenceNamespaceSchema });
12745
+ object({
12746
+ /** `false` when the namespace did not exist. */
12747
+ deleted: boolean() });
12748
+ object({
12749
+ /** The revision the client holds per namespace; a namespace it does not list is new to it. */
12750
+ revisionByNamespace: record(PreferenceNamespaceSchema, number().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
12751
+ object({
12752
+ /** Every row whose revision differs from the client's, and every row it did not list. */
12753
+ rows: array(PreferenceRowSchema),
12754
+ /** Namespaces the client listed that no longer exist. */
12755
+ deleted: array(PreferenceNamespaceSchema)
12756
+ });
12477
12757
  _enum(["new-session", "step-up"]);
12478
12758
  /** The languages the hub's app landing pages are written in (D858). */
12479
12759
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -39763,38 +40043,37 @@ method(LlmRuntimeCompleteInputSchema, LlmGenerateResultSchema, {
39763
40043
  auth: "admin",
39764
40044
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39765
40045
  });
40046
+ var LlmProfileKindSchema = string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "a kind id is lower-case letters, digits and dashes");
40047
+ /** What a model (or, by default, every model of a kind) can do. */
40048
+ var LlmModelFeaturesSchema = object({
40049
+ vision: boolean(),
40050
+ tools: boolean(),
40051
+ streaming: boolean()
40052
+ });
40053
+ /** One model a provider offers. `features` overrides the kind's defaults, per field. */
40054
+ var LlmModelInfoSchema = object({
40055
+ id: string(),
40056
+ label: string().optional(),
40057
+ contextLength: number().int().positive().optional(),
40058
+ features: LlmModelFeaturesSchema.partial().optional()
40059
+ });
39766
40060
  /**
39767
- * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
39768
- * methods concat-fan across providers; single-row methods route to ONE
39769
- * provider by the `addonId` in the call input (the notification-output
39770
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
39771
- * (hub-placed); the cap stays open for future providers.
39772
- *
39773
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
39774
- * `apiKey` is a password field — providers REDACT it on read and merge on
39775
- * write; a stored key NEVER round-trips to a client.
40061
+ * The provider-specific part of a profile, validated by the provider that owns
40062
+ * the kind (`upsertProfile` refuses what it does not accept). A field its
40063
+ * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
40064
+ * keychain, never in the row, and reads back as the redaction marker.
39776
40065
  */
39777
- var LlmProfileKindSchema = _enum([
39778
- "openai-compatible",
39779
- "openai",
39780
- "anthropic",
39781
- "google",
39782
- "managed-local",
39783
- "apple-foundation"
39784
- ]);
40066
+ var LlmProviderConfigSchema = record(string(), unknown());
39785
40067
  var LlmProfileSchema = object({
39786
40068
  id: string(),
39787
40069
  name: string(),
40070
+ /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
39788
40071
  kind: LlmProfileKindSchema,
39789
40072
  /** Stamped by the provider — keeps the fanned catalog routable. */
39790
40073
  addonId: string(),
39791
40074
  enabled: boolean(),
39792
40075
  /** Vendor model id, or the managed runtime's loaded model. */
39793
40076
  model: string(),
39794
- /** Required for openai-compatible; override for cloud kinds. */
39795
- baseUrl: string().optional(),
39796
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
39797
- apiKey: string().optional(),
39798
40077
  /** Vision on/off. A vision call against a `false` profile is REFUSED, never
39799
40078
  * degraded to text — that shipped once and produced a confident answer to a
39800
40079
  * question about a picture nobody sent. */
@@ -39802,15 +40081,11 @@ var LlmProfileSchema = object({
39802
40081
  temperature: number().min(0).max(2).optional(),
39803
40082
  /** Nucleus sampling. Every wire we speak has it. */
39804
40083
  topP: number().min(0).max(1).optional(),
39805
- /** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
39806
- * wire does, and the client drops it there (measured: the request body gets
39807
- * `top_p` and no `top_k`). The profile editor hides the field wherever it
39808
- * would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
40084
+ /** Top-k sampling. Carried only by the wires that have it — a kind offers the
40085
+ * field in its editor only when its descriptor lists it in `profileFields`. */
39809
40086
  topK: number().int().positive().optional(),
39810
40087
  maxTokens: number().int().positive().optional(),
39811
- /** Prompt context window. Advisory for cloud kinds (they enforce their own);
39812
- * for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
39813
- * the model with, so it is the one field that changes a PROCESS. */
40088
+ /** Prompt context window. Advisory for cloud kinds (they enforce their own). */
39814
40089
  contextLength: number().int().positive().optional(),
39815
40090
  /** Default system prompt. A caller's `system` REPLACES it (never appends —
39816
40091
  * two system prompts fighting is worse than either alone). */
@@ -39836,16 +40111,37 @@ var LlmProfileSchema = object({
39836
40111
  * library; the REGISTRY of callable tools is ours and is empty in v1, so a
39837
40112
  * `true` here buys the wiring, not behaviour, until tools are registered. */
39838
40113
  toolsEnabled: boolean().default(false),
39839
- extraHeaders: record(string(), string()).optional(),
39840
- /** kind === 'managed-local' only (spec §4). */
39841
- runtime: ManagedRuntimeConfigSchema.optional(),
39842
- /**
39843
- * kind === 'apple-foundation' only: WHERE it runs — the only thing there is
39844
- * to configure (no key, no URL, no download; `model` is `apple-system`).
39845
- * `supportsVision` on such a row is stamped by the provider from the node's
39846
- * reported `imageInput`, never taken from the operator (D62).
39847
- */
39848
- appleFoundation: object({ nodeId: string() }).optional()
40114
+ /** Everything the kind's provider owns (endpoint, key, node, runtime…). */
40115
+ providerConfig: LlmProviderConfigSchema.default({})
40116
+ });
40117
+ /**
40118
+ * The common profile fields a kind's editor offers. The editor owns how each
40119
+ * one is drawn; the provider says which of them mean something on its wire.
40120
+ */
40121
+ var LlmProfileFieldSchema = _enum([
40122
+ "temperature",
40123
+ "topP",
40124
+ "topK",
40125
+ "maxTokens",
40126
+ "contextLength",
40127
+ "systemPrompt",
40128
+ "timeoutMs",
40129
+ "connectTimeoutMs",
40130
+ "firstTokenTimeoutMs",
40131
+ "idleTimeoutMs",
40132
+ "retry",
40133
+ "toolsEnabled"
40134
+ ]);
40135
+ /**
40136
+ * A provider-drawn part of the editor, by a generic widget id the admin UI
40137
+ * registers (`ai/apple-node`). `placement: 'model'` replaces the generic model
40138
+ * picker: that widget owns the model choice.
40139
+ */
40140
+ var LlmProviderWidgetSchema = object({
40141
+ id: string(),
40142
+ placement: _enum(["connection", "model"]),
40143
+ /** `providerConfig` keys this widget must fill before the profile can be saved. */
40144
+ requires: array(string()).optional()
39849
40145
  });
39850
40146
  /** ConfigUISchema tree passed through untyped on the wire (the
39851
40147
  * notification-output `ConfigSchemaPassthrough` precedent at
@@ -39854,11 +40150,56 @@ var ConfigSchemaPassthrough$3 = unknown();
39854
40150
  var LlmProfileKindDescriptorSchema = object({
39855
40151
  kind: LlmProfileKindSchema,
39856
40152
  label: string(),
40153
+ /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
39857
40154
  icon: string(),
39858
40155
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
39859
40156
  addonId: string(),
39860
- configSchema: ConfigSchemaPassthrough$3
40157
+ /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
40158
+ connectionSchema: ConfigSchemaPassthrough$3,
40159
+ /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
40160
+ advancedSchema: ConfigSchemaPassthrough$3.optional(),
40161
+ /** The kind's defaults; a model from `listModels` may override any of them. */
40162
+ features: LlmModelFeaturesSchema,
40163
+ /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
40164
+ visionEditable: boolean(),
40165
+ /** Where the model list comes from: `listModels`, `staticModels`, or nowhere. */
40166
+ modelCatalog: _enum([
40167
+ "fetch",
40168
+ "static",
40169
+ "none"
40170
+ ]),
40171
+ staticModels: array(LlmModelInfoSchema).optional(),
40172
+ /** The common fields that mean something on this kind's wire. */
40173
+ profileFields: array(LlmProfileFieldSchema),
40174
+ providerWidgets: array(LlmProviderWidgetSchema).optional()
40175
+ });
40176
+ /**
40177
+ * `listModels` input. `connection` is an UNSAVED draft of `providerConfig`
40178
+ * (the editor's form); with `profileId` too, a secret the draft leaves
40179
+ * untouched (absent or the redaction marker) is resolved server-side from the
40180
+ * stored profile — the browser never receives it.
40181
+ */
40182
+ var LlmListModelsInputSchema = object({
40183
+ addonId: string(),
40184
+ kind: LlmProfileKindSchema,
40185
+ profileId: string().optional(),
40186
+ connection: LlmProviderConfigSchema.optional()
39861
40187
  });
40188
+ var LlmListModelsErrorCodeSchema = _enum([
40189
+ "auth",
40190
+ "network",
40191
+ "unsupported",
40192
+ "invalid"
40193
+ ]);
40194
+ /** A RESULT, never a throw: "wrong key" is an answer the editor renders inline. */
40195
+ var LlmListModelsResultSchema = discriminatedUnion("ok", [object({
40196
+ ok: literal(true),
40197
+ models: array(LlmModelInfoSchema)
40198
+ }), object({
40199
+ ok: literal(false),
40200
+ code: LlmListModelsErrorCodeSchema,
40201
+ message: string()
40202
+ })]);
39862
40203
  var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
39863
40204
  var LlmDefaultSchema = object({
39864
40205
  selector: LlmDefaultSelectorSchema,
@@ -39958,7 +40299,10 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
39958
40299
  kind: "mutation",
39959
40300
  auth: "admin",
39960
40301
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39961
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
40302
+ }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
40303
+ kind: "mutation",
40304
+ auth: "admin"
40305
+ }), method(object({}), array(LlmDefaultSchema)), method(object({
39962
40306
  selector: LlmDefaultSelectorSchema,
39963
40307
  profileId: string().nullable()
39964
40308
  }), _void(), {
@@ -44064,202 +44408,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
44064
44408
  auth: "admin"
44065
44409
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
44066
44410
  /**
44067
- * Zod schemas for persisted record types.
44068
- *
44069
- * These schemas serve as the single source of truth for types that are
44070
- * stored in the settings-store backend and retrieved via tRPC. They
44071
- * replace the manual TypeScript interfaces with schema-derived types,
44072
- * enabling runtime validation when reading from the backend.
44073
- *
44074
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
44075
- * keeps the original name for backward compatibility.
44076
- */
44077
- /**
44078
- * Auth model (v2 — 2026-05-12 caps-only):
44079
- *
44080
- * Two principals:
44081
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
44082
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
44083
- *
44084
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44085
- * `super_admin` — collapsed onto the single boolean because every
44086
- * non-admin caller is governed by the same scope-check rules; the
44087
- * distinction was only ever used to route role-specific procedures
44088
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44089
- * with `isAdmin: false` + an explicit scope list.
44090
- */
44091
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44092
- var MethodAccessSchema = _enum([
44093
- "view",
44094
- "create",
44095
- "delete"
44096
- ]);
44097
- /**
44098
- * A single scope grant. Three forms — checked in matcher with OR
44099
- * semantics; the first match decides whether the call passes:
44100
- *
44101
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44102
- * cap with the matching `scope` declaration. New caps inherit grants
44103
- * automatically — adding a device cap to the codebase makes it
44104
- * reachable to every user with `category:device [...]` without a
44105
- * re-grant. Use this for "family viewer" / "operator" tiers.
44106
- *
44107
- * - `addon` — every cap that ships inside a given addon id. Niche;
44108
- * useful when an integration needs to interact with one specific
44109
- * addon's surface regardless of how many caps it exports.
44110
- *
44111
- * - `capability` — the most precise form. Single cap name. Use for
44112
- * integration tokens where you want to grant `addons.installPackage`
44113
- * and nothing else.
44114
- *
44115
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44116
- * "give me everything" escape; there is no wildcard scope.
44117
- */
44118
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44119
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44120
- var CapScopeSchema = _enum(["device", "system"]);
44121
- /**
44122
- * DeviceSelector (scope model v3 — 2026-08-12).
44123
- *
44124
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44125
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44126
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44127
- * AFTER the grant was minted — no re-grant, no re-login.
44128
- *
44129
- * - `all` — every device in the deployment. The broad viewer/operator
44130
- * lever without a `category` grant (a `category` grant also covers device
44131
- * caps that carry no deviceId; `all` is specifically the device set).
44132
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44133
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44134
- * is NOT covered until the grant is edited.
44135
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44136
- * DYNAMIC. A device that changes type, or a new device of the type,
44137
- * re-resolves on the next request.
44138
- * - `locations` — every device whose operator-assigned `location` label is
44139
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44140
- * null/unset location matches NO `locations` selector.
44141
- */
44142
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44143
- object({ kind: literal("all") }),
44144
- object({
44145
- kind: literal("ids"),
44146
- ids: array(number().int()).min(1)
44147
- }),
44148
- object({
44149
- kind: literal("types"),
44150
- types: array(_enum(DeviceType)).min(1)
44151
- }),
44152
- object({
44153
- kind: literal("locations"),
44154
- locations: array(string().min(1)).min(1)
44155
- })
44156
- ]);
44157
- var DeviceTokenScopeSchema = object({
44158
- type: literal("device"),
44159
- /** The device SET this grant covers — resolved against the live fleet. */
44160
- selector: DeviceSelectorSchema,
44161
- access: array(MethodAccessSchema).min(1),
44162
- /**
44163
- * Whether a grant on a PARENT device transparently covers its accessory
44164
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44165
- * Direction is parent → children ONLY.
44166
- *
44167
- * Absent → the matcher DERIVES it from the access flavour: `view`
44168
- * inherits (a camera viewer sees the camera's accessories), `create` /
44169
- * `delete` do NOT (actuating/removing a child is an explicit act the
44170
- * operator must grant on the child, not inherit from the parent). Set it
44171
- * explicitly to override that default per grant.
44172
- */
44173
- includeLinked: boolean().optional()
44174
- });
44175
- /**
44176
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44177
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44178
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44179
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44180
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44181
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44182
- * migration cannot reach a JWT already in a client's hands; parse-time
44183
- * migration covers both without a flag day. No cast — the raw object is read
44184
- * through `Reflect.get` (its static type is `unknown`).
44185
- */
44186
- function migrateLegacyTokenScope(raw) {
44187
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44188
- if (Reflect.get(raw, "type") !== "device") return raw;
44189
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44190
- const targets = Reflect.get(raw, "targets");
44191
- if (!Array.isArray(targets)) return raw;
44192
- return {
44193
- type: "device",
44194
- selector: {
44195
- kind: "ids",
44196
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44197
- },
44198
- access: Reflect.get(raw, "access")
44199
- };
44200
- }
44201
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44202
- object({
44203
- type: literal("category"),
44204
- target: CapScopeSchema,
44205
- access: array(MethodAccessSchema).min(1)
44206
- }),
44207
- object({
44208
- type: literal("capability"),
44209
- target: string(),
44210
- access: array(MethodAccessSchema).min(1)
44211
- }),
44212
- object({
44213
- type: literal("addon"),
44214
- target: string(),
44215
- access: array(MethodAccessSchema).min(1)
44216
- }),
44217
- DeviceTokenScopeSchema
44218
- ]));
44219
- object({
44220
- id: string(),
44221
- username: string(),
44222
- passwordHash: string(),
44223
- /**
44224
- * Admin bypass. When true, the middleware skips the scope-access
44225
- * check entirely. There is no other axis of privilege; the legacy
44226
- * role enum collapsed onto this boolean in v2.
44227
- */
44228
- isAdmin: boolean().default(false),
44229
- allowedProviders: AllowedProviderSchema,
44230
- allowedDevices: AllowedDevicesSchema,
44231
- /**
44232
- * Scopes granted to this user. Admins bypass; their `scopes` is
44233
- * ignored. Non-admins without scopes are locked out of every
44234
- * protected call.
44235
- */
44236
- scopes: array(TokenScopeSchema).default([]),
44237
- createdAt: number(),
44238
- updatedAt: number()
44239
- });
44240
- object({
44241
- id: string(),
44242
- label: string(),
44243
- isAdmin: boolean().default(false),
44244
- allowedProviders: AllowedProviderSchema,
44245
- allowedDevices: AllowedDevicesSchema,
44246
- tokenHash: string(),
44247
- tokenPrefix: string(),
44248
- createdAt: number(),
44249
- lastUsedAt: number().optional()
44250
- });
44251
- object({
44252
- id: string(),
44253
- userId: string(),
44254
- name: string(),
44255
- tokenHash: string(),
44256
- tokenPrefix: string(),
44257
- scopes: array(TokenScopeSchema),
44258
- expiresAt: number().nullish(),
44259
- lastUsedAt: number().nullish(),
44260
- createdAt: number()
44261
- });
44262
- /**
44263
44411
  * `oauth-integration` — a collection cap by which an addon declares
44264
44412
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44265
44413
  * Each provider returns a static descriptor; the core enumerates them
@@ -64042,26 +64190,6 @@ var ApiKeySummarySchema = object({
64042
64190
  createdAt: number(),
64043
64191
  lastUsedAt: number().optional()
64044
64192
  });
64045
- var ScopedTokenSummarySchema = object({
64046
- id: string(),
64047
- userId: string(),
64048
- name: string(),
64049
- tokenPrefix: string(),
64050
- scopes: array(TokenScopeSchema),
64051
- expiresAt: number().nullish(),
64052
- lastUsedAt: number().nullish(),
64053
- createdAt: number()
64054
- });
64055
- var CreateScopedTokenInputSchema = object({
64056
- userId: string(),
64057
- name: string(),
64058
- scopes: array(TokenScopeSchema),
64059
- expiresAt: number().optional()
64060
- });
64061
- var CreateScopedTokenResultSchema = object({
64062
- token: string(),
64063
- record: ScopedTokenSummarySchema
64064
- });
64065
64193
  var OauthSessionSummarySchema = object({
64066
64194
  id: string(),
64067
64195
  userId: string(),
@@ -64083,11 +64211,11 @@ var TotpStatusSchema = object({
64083
64211
  confirmedAt: number().nullable()
64084
64212
  });
64085
64213
  /**
64086
- * user-management — singleton capability for user accounts, API keys,
64087
- * and scoped tokens.
64214
+ * user-management — singleton capability for user accounts and the
64215
+ * legacy API-key rows.
64088
64216
  *
64089
64217
  * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
64090
- * — the subset check on `setUserScopes` / `createScopedToken` is moot
64218
+ * — the subset check on `setUserScopes` is moot
64091
64219
  * because non-admins never reach these. If/when we open non-admin
64092
64220
  * delegation, structural caller-scope subset check goes inside the
64093
64221
  * provider.
@@ -64144,15 +64272,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
64144
64272
  kind: "mutation",
64145
64273
  auth: "admin",
64146
64274
  access: "delete"
64147
- }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
64148
- kind: "mutation",
64149
- auth: "admin",
64150
- access: "create"
64151
- }), method(object({ id: string() }), object({ success: literal(true) }), {
64152
- kind: "mutation",
64153
- auth: "admin",
64154
- access: "delete"
64155
- }), method(object({ token: string() }), ScopedTokenSummarySchema.nullable(), { access: "view" }), method(object({ userId: string() }), array(ScopedTokenSummarySchema), { auth: "admin" }), method(object({ userId: string() }), TotpSetupResultSchema, {
64275
+ }), method(object({ userId: string() }), TotpSetupResultSchema, {
64156
64276
  kind: "mutation",
64157
64277
  auth: "admin",
64158
64278
  access: "create"
@@ -70242,7 +70362,7 @@ Object.freeze({
70242
70362
  capName: "llm",
70243
70363
  capScope: "system",
70244
70364
  addonId: null,
70245
- access: "view"
70365
+ access: "create"
70246
70366
  },
70247
70367
  "llm.listNodeModels": {
70248
70368
  capName: "llm",
@@ -74906,12 +75026,6 @@ Object.freeze({
74906
75026
  addonId: null,
74907
75027
  access: "create"
74908
75028
  },
74909
- "userManagement.createScopedToken": {
74910
- capName: "user-management",
74911
- capScope: "system",
74912
- addonId: null,
74913
- access: "create"
74914
- },
74915
75029
  "userManagement.createUser": {
74916
75030
  capName: "user-management",
74917
75031
  capScope: "system",
@@ -74960,12 +75074,6 @@ Object.freeze({
74960
75074
  addonId: null,
74961
75075
  access: "view"
74962
75076
  },
74963
- "userManagement.listScopedTokens": {
74964
- capName: "user-management",
74965
- capScope: "system",
74966
- addonId: null,
74967
- access: "view"
74968
- },
74969
75077
  "userManagement.listUsers": {
74970
75078
  capName: "user-management",
74971
75079
  capScope: "system",
@@ -75020,12 +75128,6 @@ Object.freeze({
75020
75128
  addonId: null,
75021
75129
  access: "delete"
75022
75130
  },
75023
- "userManagement.revokeScopedToken": {
75024
- capName: "user-management",
75025
- capScope: "system",
75026
- addonId: null,
75027
- access: "delete"
75028
- },
75029
75131
  "userManagement.setupTotp": {
75030
75132
  capName: "user-management",
75031
75133
  capScope: "system",
@@ -75056,12 +75158,6 @@ Object.freeze({
75056
75158
  addonId: null,
75057
75159
  access: "view"
75058
75160
  },
75059
- "userManagement.validateScopedToken": {
75060
- capName: "user-management",
75061
- capScope: "system",
75062
- addonId: null,
75063
- access: "view"
75064
- },
75065
75161
  "userManagement.verifyTotp": {
75066
75162
  capName: "user-management",
75067
75163
  capScope: "system",