@camstack/addon-provider-dreame 0.2.136 → 0.2.138

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
@@ -5456,7 +5456,7 @@ var ZodIssueCode$1 = {
5456
5456
  var ZodFirstPartyTypeKind$1;
5457
5457
  ZodFirstPartyTypeKind$1 || (ZodFirstPartyTypeKind$1 = {});
5458
5458
  //#endregion
5459
- //#region ../types/dist/sleep-BxjU_fJM.mjs
5459
+ //#region ../types/dist/sleep-yKL5gfrH.mjs
5460
5460
  /**
5461
5461
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5462
5462
  * window to float samples (D455).
@@ -7838,6 +7838,12 @@ function normalizeAddonInitResult(result) {
7838
7838
  if (Array.isArray(result)) return { providers: result };
7839
7839
  return result;
7840
7840
  }
7841
+ /**
7842
+ * The share-view scope kinds a share-link token can carry. The hub mints
7843
+ * and validates them (`ShareViewGrantSchema` builds its
7844
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
7845
+ */
7846
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7841
7847
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7842
7848
  var PeerBytesTicketSchema = object({
7843
7849
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12517,6 +12523,280 @@ var ConvertResultSchema = object({
12517
12523
  files: array(string()).readonly()
12518
12524
  })).readonly()
12519
12525
  });
12526
+ /**
12527
+ * Zod schemas for persisted record types.
12528
+ *
12529
+ * These schemas serve as the single source of truth for types that are
12530
+ * stored in the settings-store backend and retrieved via tRPC. They
12531
+ * replace the manual TypeScript interfaces with schema-derived types,
12532
+ * enabling runtime validation when reading from the backend.
12533
+ *
12534
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12535
+ * keeps the original name for backward compatibility.
12536
+ */
12537
+ /**
12538
+ * Auth model (v2 — 2026-05-12 caps-only):
12539
+ *
12540
+ * Two principals:
12541
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12542
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12543
+ *
12544
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12545
+ * `super_admin` — collapsed onto the single boolean because every
12546
+ * non-admin caller is governed by the same scope-check rules; the
12547
+ * distinction was only ever used to route role-specific procedures
12548
+ * which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
12549
+ * with `isAdmin: false` + an explicit scope list.
12550
+ */
12551
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12552
+ var MethodAccessSchema = _enum([
12553
+ "view",
12554
+ "create",
12555
+ "delete"
12556
+ ]);
12557
+ /**
12558
+ * A single scope grant. Three forms — checked in matcher with OR
12559
+ * semantics; the first match decides whether the call passes:
12560
+ *
12561
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12562
+ * cap with the matching `scope` declaration. New caps inherit grants
12563
+ * automatically — adding a device cap to the codebase makes it
12564
+ * reachable to every user with `category:device [...]` without a
12565
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12566
+ *
12567
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12568
+ * useful when an integration needs to interact with one specific
12569
+ * addon's surface regardless of how many caps it exports.
12570
+ *
12571
+ * - `capability` — the most precise form. Single cap name. Use for
12572
+ * integration tokens where you want to grant `addons.installPackage`
12573
+ * and nothing else.
12574
+ *
12575
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12576
+ * "give me everything" escape; there is no wildcard scope.
12577
+ */
12578
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12579
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12580
+ var CapScopeSchema = _enum(["device", "system"]);
12581
+ /**
12582
+ * DeviceSelector (scope model v3 — 2026-08-12).
12583
+ *
12584
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12585
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12586
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12587
+ * AFTER the grant was minted — no re-grant, no re-login.
12588
+ *
12589
+ * - `all` — every device in the deployment. The broad viewer/operator
12590
+ * lever without a `category` grant (a `category` grant also covers device
12591
+ * caps that carry no deviceId; `all` is specifically the device set).
12592
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
12593
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
12594
+ * is NOT covered until the grant is edited.
12595
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
12596
+ * DYNAMIC. A device that changes type, or a new device of the type,
12597
+ * re-resolves on the next request.
12598
+ * - `locations` — every device whose operator-assigned `location` label is
12599
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
12600
+ * null/unset location matches NO `locations` selector.
12601
+ */
12602
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
12603
+ object({ kind: literal("all") }),
12604
+ object({
12605
+ kind: literal("ids"),
12606
+ ids: array(number().int()).min(1)
12607
+ }),
12608
+ object({
12609
+ kind: literal("types"),
12610
+ types: array(_enum(DeviceType)).min(1)
12611
+ }),
12612
+ object({
12613
+ kind: literal("locations"),
12614
+ locations: array(string().min(1)).min(1)
12615
+ })
12616
+ ]);
12617
+ var DeviceTokenScopeSchema = object({
12618
+ type: literal("device"),
12619
+ /** The device SET this grant covers — resolved against the live fleet. */
12620
+ selector: DeviceSelectorSchema,
12621
+ access: array(MethodAccessSchema).min(1),
12622
+ /**
12623
+ * Whether a grant on a PARENT device transparently covers its accessory
12624
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
12625
+ * Direction is parent → children ONLY.
12626
+ *
12627
+ * Absent → the matcher DERIVES it from the access flavour: `view`
12628
+ * inherits (a camera viewer sees the camera's accessories), `create` /
12629
+ * `delete` do NOT (actuating/removing a child is an explicit act the
12630
+ * operator must grant on the child, not inherit from the parent). Set it
12631
+ * explicitly to override that default per grant.
12632
+ */
12633
+ includeLinked: boolean().optional()
12634
+ });
12635
+ /**
12636
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
12637
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
12638
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
12639
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
12640
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
12641
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
12642
+ * migration cannot reach a JWT already in a client's hands; parse-time
12643
+ * migration covers both without a flag day. No cast — the raw object is read
12644
+ * through `Reflect.get` (its static type is `unknown`).
12645
+ */
12646
+ function migrateLegacyTokenScope(raw) {
12647
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
12648
+ if (Reflect.get(raw, "type") !== "device") return raw;
12649
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
12650
+ const targets = Reflect.get(raw, "targets");
12651
+ if (!Array.isArray(targets)) return raw;
12652
+ return {
12653
+ type: "device",
12654
+ selector: {
12655
+ kind: "ids",
12656
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
12657
+ },
12658
+ access: Reflect.get(raw, "access")
12659
+ };
12660
+ }
12661
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
12662
+ object({
12663
+ type: literal("category"),
12664
+ target: CapScopeSchema,
12665
+ access: array(MethodAccessSchema).min(1)
12666
+ }),
12667
+ object({
12668
+ type: literal("capability"),
12669
+ target: string(),
12670
+ access: array(MethodAccessSchema).min(1)
12671
+ }),
12672
+ object({
12673
+ type: literal("addon"),
12674
+ target: string(),
12675
+ access: array(MethodAccessSchema).min(1)
12676
+ }),
12677
+ DeviceTokenScopeSchema
12678
+ ]));
12679
+ object({
12680
+ id: string(),
12681
+ username: string(),
12682
+ passwordHash: string(),
12683
+ /**
12684
+ * Admin bypass. When true, the middleware skips the scope-access
12685
+ * check entirely. There is no other axis of privilege; the legacy
12686
+ * role enum collapsed onto this boolean in v2.
12687
+ */
12688
+ isAdmin: boolean().default(false),
12689
+ allowedProviders: AllowedProviderSchema,
12690
+ allowedDevices: AllowedDevicesSchema,
12691
+ /**
12692
+ * Scopes granted to this user. Admins bypass; their `scopes` is
12693
+ * ignored. Non-admins without scopes are locked out of every
12694
+ * protected call.
12695
+ */
12696
+ scopes: array(TokenScopeSchema).default([]),
12697
+ createdAt: number(),
12698
+ updatedAt: number()
12699
+ });
12700
+ object({
12701
+ id: string(),
12702
+ label: string(),
12703
+ isAdmin: boolean().default(false),
12704
+ allowedProviders: AllowedProviderSchema,
12705
+ allowedDevices: AllowedDevicesSchema,
12706
+ tokenHash: string(),
12707
+ tokenPrefix: string(),
12708
+ createdAt: number(),
12709
+ lastUsedAt: number().optional()
12710
+ });
12711
+ object({
12712
+ id: string(),
12713
+ userId: string(),
12714
+ name: string(),
12715
+ tokenHash: string(),
12716
+ tokenPrefix: string(),
12717
+ scopes: array(TokenScopeSchema),
12718
+ expiresAt: number().nullish(),
12719
+ lastUsedAt: number().nullish(),
12720
+ createdAt: number()
12721
+ });
12722
+ /** What a share-view grant lets its holder see. */
12723
+ var ShareViewGrantSchema = object({
12724
+ kind: _enum(SHARE_VIEW_KINDS),
12725
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
12726
+ /** Talk-back, opt-in at mint time; absent means off. */
12727
+ talk: boolean().optional()
12728
+ });
12729
+ var ShareViewScopeSchema = object({
12730
+ type: literal("share-view"),
12731
+ grant: ShareViewGrantSchema
12732
+ });
12733
+ var AddonRoutesScopeSchema = object({
12734
+ type: literal("addon-routes"),
12735
+ access: array(MethodAccessSchema).min(1)
12736
+ });
12737
+ var PreferencesSelfScopeSchema = object({ type: literal("preferences-self") });
12738
+ var CredentialScopeSchema = union([
12739
+ literal("*"),
12740
+ ShareViewScopeSchema,
12741
+ AddonRoutesScopeSchema,
12742
+ PreferencesSelfScopeSchema,
12743
+ TokenScopeSchema
12744
+ ]);
12745
+ object({
12746
+ kind: literal("credential"),
12747
+ sub: string().min(1),
12748
+ jti: string().min(16),
12749
+ scopes: array(CredentialScopeSchema).min(1)
12750
+ });
12751
+ var PreferenceNamespaceSchema = string().regex(/^[a-z][a-z0-9.-]{0,63}$/);
12752
+ /** A namespace's value: a JSON object, opaque to the hub. */
12753
+ var PreferenceValueSchema = record(string(), unknown());
12754
+ var PreferenceDeviceIdSchema = string().min(1).max(64);
12755
+ /** A stored row, as the owner reads it. */
12756
+ var PreferenceRowSchema = object({
12757
+ namespace: PreferenceNamespaceSchema,
12758
+ value: PreferenceValueSchema,
12759
+ /** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
12760
+ revision: number().int().positive(),
12761
+ updatedAt: number().int(),
12762
+ /** The client id the last writer sent; `null` when it sent none. */
12763
+ updatedByDevice: PreferenceDeviceIdSchema.nullable()
12764
+ });
12765
+ object({
12766
+ /** Absent: every namespace the caller holds. */
12767
+ namespaces: array(PreferenceNamespaceSchema).max(32).optional() });
12768
+ object({ rows: array(PreferenceRowSchema) });
12769
+ object({
12770
+ namespace: PreferenceNamespaceSchema,
12771
+ value: PreferenceValueSchema,
12772
+ /**
12773
+ * The revision the edit was based on. Absent: last write wins. `0`: the
12774
+ * namespace must not exist yet. Any other value that is not the current
12775
+ * revision answers `conflict` and writes nothing.
12776
+ */
12777
+ baseRevision: number().int().nonnegative().optional(),
12778
+ deviceId: PreferenceDeviceIdSchema.optional()
12779
+ });
12780
+ discriminatedUnion("status", [object({
12781
+ status: literal("saved"),
12782
+ row: PreferenceRowSchema
12783
+ }), object({
12784
+ status: literal("conflict"),
12785
+ current: PreferenceRowSchema.nullable()
12786
+ })]);
12787
+ object({ namespace: PreferenceNamespaceSchema });
12788
+ object({
12789
+ /** `false` when the namespace did not exist. */
12790
+ deleted: boolean() });
12791
+ object({
12792
+ /** The revision the client holds per namespace; a namespace it does not list is new to it. */
12793
+ revisionByNamespace: record(PreferenceNamespaceSchema, number().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
12794
+ object({
12795
+ /** Every row whose revision differs from the client's, and every row it did not list. */
12796
+ rows: array(PreferenceRowSchema),
12797
+ /** Namespaces the client listed that no longer exist. */
12798
+ deleted: array(PreferenceNamespaceSchema)
12799
+ });
12520
12800
  _enum(["new-session", "step-up"]);
12521
12801
  /** The languages the hub's app landing pages are written in (D858). */
12522
12802
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -39722,38 +40002,37 @@ method(LlmRuntimeCompleteInputSchema, LlmGenerateResultSchema, {
39722
40002
  auth: "admin",
39723
40003
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39724
40004
  });
40005
+ var LlmProfileKindSchema = string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "a kind id is lower-case letters, digits and dashes");
40006
+ /** What a model (or, by default, every model of a kind) can do. */
40007
+ var LlmModelFeaturesSchema = object({
40008
+ vision: boolean(),
40009
+ tools: boolean(),
40010
+ streaming: boolean()
40011
+ });
40012
+ /** One model a provider offers. `features` overrides the kind's defaults, per field. */
40013
+ var LlmModelInfoSchema = object({
40014
+ id: string(),
40015
+ label: string().optional(),
40016
+ contextLength: number().int().positive().optional(),
40017
+ features: LlmModelFeaturesSchema.partial().optional()
40018
+ });
39725
40019
  /**
39726
- * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
39727
- * methods concat-fan across providers; single-row methods route to ONE
39728
- * provider by the `addonId` in the call input (the notification-output
39729
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
39730
- * (hub-placed); the cap stays open for future providers.
39731
- *
39732
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
39733
- * `apiKey` is a password field — providers REDACT it on read and merge on
39734
- * write; a stored key NEVER round-trips to a client.
40020
+ * The provider-specific part of a profile, validated by the provider that owns
40021
+ * the kind (`upsertProfile` refuses what it does not accept). A field its
40022
+ * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
40023
+ * keychain, never in the row, and reads back as the redaction marker.
39735
40024
  */
39736
- var LlmProfileKindSchema = _enum([
39737
- "openai-compatible",
39738
- "openai",
39739
- "anthropic",
39740
- "google",
39741
- "managed-local",
39742
- "apple-foundation"
39743
- ]);
40025
+ var LlmProviderConfigSchema = record(string(), unknown());
39744
40026
  var LlmProfileSchema = object({
39745
40027
  id: string(),
39746
40028
  name: string(),
40029
+ /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
39747
40030
  kind: LlmProfileKindSchema,
39748
40031
  /** Stamped by the provider — keeps the fanned catalog routable. */
39749
40032
  addonId: string(),
39750
40033
  enabled: boolean(),
39751
40034
  /** Vendor model id, or the managed runtime's loaded model. */
39752
40035
  model: string(),
39753
- /** Required for openai-compatible; override for cloud kinds. */
39754
- baseUrl: string().optional(),
39755
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
39756
- apiKey: string().optional(),
39757
40036
  /** Vision on/off. A vision call against a `false` profile is REFUSED, never
39758
40037
  * degraded to text — that shipped once and produced a confident answer to a
39759
40038
  * question about a picture nobody sent. */
@@ -39761,15 +40040,11 @@ var LlmProfileSchema = object({
39761
40040
  temperature: number().min(0).max(2).optional(),
39762
40041
  /** Nucleus sampling. Every wire we speak has it. */
39763
40042
  topP: number().min(0).max(1).optional(),
39764
- /** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
39765
- * wire does, and the client drops it there (measured: the request body gets
39766
- * `top_p` and no `top_k`). The profile editor hides the field wherever it
39767
- * would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
40043
+ /** Top-k sampling. Carried only by the wires that have it — a kind offers the
40044
+ * field in its editor only when its descriptor lists it in `profileFields`. */
39768
40045
  topK: number().int().positive().optional(),
39769
40046
  maxTokens: number().int().positive().optional(),
39770
- /** Prompt context window. Advisory for cloud kinds (they enforce their own);
39771
- * for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
39772
- * the model with, so it is the one field that changes a PROCESS. */
40047
+ /** Prompt context window. Advisory for cloud kinds (they enforce their own). */
39773
40048
  contextLength: number().int().positive().optional(),
39774
40049
  /** Default system prompt. A caller's `system` REPLACES it (never appends —
39775
40050
  * two system prompts fighting is worse than either alone). */
@@ -39795,16 +40070,37 @@ var LlmProfileSchema = object({
39795
40070
  * library; the REGISTRY of callable tools is ours and is empty in v1, so a
39796
40071
  * `true` here buys the wiring, not behaviour, until tools are registered. */
39797
40072
  toolsEnabled: boolean().default(false),
39798
- extraHeaders: record(string(), string()).optional(),
39799
- /** kind === 'managed-local' only (spec §4). */
39800
- runtime: ManagedRuntimeConfigSchema.optional(),
39801
- /**
39802
- * kind === 'apple-foundation' only: WHERE it runs — the only thing there is
39803
- * to configure (no key, no URL, no download; `model` is `apple-system`).
39804
- * `supportsVision` on such a row is stamped by the provider from the node's
39805
- * reported `imageInput`, never taken from the operator (D62).
39806
- */
39807
- appleFoundation: object({ nodeId: string() }).optional()
40073
+ /** Everything the kind's provider owns (endpoint, key, node, runtime…). */
40074
+ providerConfig: LlmProviderConfigSchema.default({})
40075
+ });
40076
+ /**
40077
+ * The common profile fields a kind's editor offers. The editor owns how each
40078
+ * one is drawn; the provider says which of them mean something on its wire.
40079
+ */
40080
+ var LlmProfileFieldSchema = _enum([
40081
+ "temperature",
40082
+ "topP",
40083
+ "topK",
40084
+ "maxTokens",
40085
+ "contextLength",
40086
+ "systemPrompt",
40087
+ "timeoutMs",
40088
+ "connectTimeoutMs",
40089
+ "firstTokenTimeoutMs",
40090
+ "idleTimeoutMs",
40091
+ "retry",
40092
+ "toolsEnabled"
40093
+ ]);
40094
+ /**
40095
+ * A provider-drawn part of the editor, by a generic widget id the admin UI
40096
+ * registers (`ai/apple-node`). `placement: 'model'` replaces the generic model
40097
+ * picker: that widget owns the model choice.
40098
+ */
40099
+ var LlmProviderWidgetSchema = object({
40100
+ id: string(),
40101
+ placement: _enum(["connection", "model"]),
40102
+ /** `providerConfig` keys this widget must fill before the profile can be saved. */
40103
+ requires: array(string()).optional()
39808
40104
  });
39809
40105
  /** ConfigUISchema tree passed through untyped on the wire (the
39810
40106
  * notification-output `ConfigSchemaPassthrough` precedent at
@@ -39813,11 +40109,56 @@ var ConfigSchemaPassthrough$3 = unknown();
39813
40109
  var LlmProfileKindDescriptorSchema = object({
39814
40110
  kind: LlmProfileKindSchema,
39815
40111
  label: string(),
40112
+ /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
39816
40113
  icon: string(),
39817
40114
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
39818
40115
  addonId: string(),
39819
- configSchema: ConfigSchemaPassthrough$3
40116
+ /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
40117
+ connectionSchema: ConfigSchemaPassthrough$3,
40118
+ /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
40119
+ advancedSchema: ConfigSchemaPassthrough$3.optional(),
40120
+ /** The kind's defaults; a model from `listModels` may override any of them. */
40121
+ features: LlmModelFeaturesSchema,
40122
+ /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
40123
+ visionEditable: boolean(),
40124
+ /** Where the model list comes from: `listModels`, `staticModels`, or nowhere. */
40125
+ modelCatalog: _enum([
40126
+ "fetch",
40127
+ "static",
40128
+ "none"
40129
+ ]),
40130
+ staticModels: array(LlmModelInfoSchema).optional(),
40131
+ /** The common fields that mean something on this kind's wire. */
40132
+ profileFields: array(LlmProfileFieldSchema),
40133
+ providerWidgets: array(LlmProviderWidgetSchema).optional()
40134
+ });
40135
+ /**
40136
+ * `listModels` input. `connection` is an UNSAVED draft of `providerConfig`
40137
+ * (the editor's form); with `profileId` too, a secret the draft leaves
40138
+ * untouched (absent or the redaction marker) is resolved server-side from the
40139
+ * stored profile — the browser never receives it.
40140
+ */
40141
+ var LlmListModelsInputSchema = object({
40142
+ addonId: string(),
40143
+ kind: LlmProfileKindSchema,
40144
+ profileId: string().optional(),
40145
+ connection: LlmProviderConfigSchema.optional()
39820
40146
  });
40147
+ var LlmListModelsErrorCodeSchema = _enum([
40148
+ "auth",
40149
+ "network",
40150
+ "unsupported",
40151
+ "invalid"
40152
+ ]);
40153
+ /** A RESULT, never a throw: "wrong key" is an answer the editor renders inline. */
40154
+ var LlmListModelsResultSchema = discriminatedUnion("ok", [object({
40155
+ ok: literal(true),
40156
+ models: array(LlmModelInfoSchema)
40157
+ }), object({
40158
+ ok: literal(false),
40159
+ code: LlmListModelsErrorCodeSchema,
40160
+ message: string()
40161
+ })]);
39821
40162
  var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
39822
40163
  var LlmDefaultSchema = object({
39823
40164
  selector: LlmDefaultSelectorSchema,
@@ -39917,7 +40258,10 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
39917
40258
  kind: "mutation",
39918
40259
  auth: "admin",
39919
40260
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39920
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
40261
+ }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
40262
+ kind: "mutation",
40263
+ auth: "admin"
40264
+ }), method(object({}), array(LlmDefaultSchema)), method(object({
39921
40265
  selector: LlmDefaultSelectorSchema,
39922
40266
  profileId: string().nullable()
39923
40267
  }), _void(), {
@@ -44023,202 +44367,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
44023
44367
  auth: "admin"
44024
44368
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
44025
44369
  /**
44026
- * Zod schemas for persisted record types.
44027
- *
44028
- * These schemas serve as the single source of truth for types that are
44029
- * stored in the settings-store backend and retrieved via tRPC. They
44030
- * replace the manual TypeScript interfaces with schema-derived types,
44031
- * enabling runtime validation when reading from the backend.
44032
- *
44033
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
44034
- * keeps the original name for backward compatibility.
44035
- */
44036
- /**
44037
- * Auth model (v2 — 2026-05-12 caps-only):
44038
- *
44039
- * Two principals:
44040
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
44041
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
44042
- *
44043
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44044
- * `super_admin` — collapsed onto the single boolean because every
44045
- * non-admin caller is governed by the same scope-check rules; the
44046
- * distinction was only ever used to route role-specific procedures
44047
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44048
- * with `isAdmin: false` + an explicit scope list.
44049
- */
44050
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44051
- var MethodAccessSchema = _enum([
44052
- "view",
44053
- "create",
44054
- "delete"
44055
- ]);
44056
- /**
44057
- * A single scope grant. Three forms — checked in matcher with OR
44058
- * semantics; the first match decides whether the call passes:
44059
- *
44060
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44061
- * cap with the matching `scope` declaration. New caps inherit grants
44062
- * automatically — adding a device cap to the codebase makes it
44063
- * reachable to every user with `category:device [...]` without a
44064
- * re-grant. Use this for "family viewer" / "operator" tiers.
44065
- *
44066
- * - `addon` — every cap that ships inside a given addon id. Niche;
44067
- * useful when an integration needs to interact with one specific
44068
- * addon's surface regardless of how many caps it exports.
44069
- *
44070
- * - `capability` — the most precise form. Single cap name. Use for
44071
- * integration tokens where you want to grant `addons.installPackage`
44072
- * and nothing else.
44073
- *
44074
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44075
- * "give me everything" escape; there is no wildcard scope.
44076
- */
44077
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44078
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44079
- var CapScopeSchema = _enum(["device", "system"]);
44080
- /**
44081
- * DeviceSelector (scope model v3 — 2026-08-12).
44082
- *
44083
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44084
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44085
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44086
- * AFTER the grant was minted — no re-grant, no re-login.
44087
- *
44088
- * - `all` — every device in the deployment. The broad viewer/operator
44089
- * lever without a `category` grant (a `category` grant also covers device
44090
- * caps that carry no deviceId; `all` is specifically the device set).
44091
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44092
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44093
- * is NOT covered until the grant is edited.
44094
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44095
- * DYNAMIC. A device that changes type, or a new device of the type,
44096
- * re-resolves on the next request.
44097
- * - `locations` — every device whose operator-assigned `location` label is
44098
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44099
- * null/unset location matches NO `locations` selector.
44100
- */
44101
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44102
- object({ kind: literal("all") }),
44103
- object({
44104
- kind: literal("ids"),
44105
- ids: array(number().int()).min(1)
44106
- }),
44107
- object({
44108
- kind: literal("types"),
44109
- types: array(_enum(DeviceType)).min(1)
44110
- }),
44111
- object({
44112
- kind: literal("locations"),
44113
- locations: array(string().min(1)).min(1)
44114
- })
44115
- ]);
44116
- var DeviceTokenScopeSchema = object({
44117
- type: literal("device"),
44118
- /** The device SET this grant covers — resolved against the live fleet. */
44119
- selector: DeviceSelectorSchema,
44120
- access: array(MethodAccessSchema).min(1),
44121
- /**
44122
- * Whether a grant on a PARENT device transparently covers its accessory
44123
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44124
- * Direction is parent → children ONLY.
44125
- *
44126
- * Absent → the matcher DERIVES it from the access flavour: `view`
44127
- * inherits (a camera viewer sees the camera's accessories), `create` /
44128
- * `delete` do NOT (actuating/removing a child is an explicit act the
44129
- * operator must grant on the child, not inherit from the parent). Set it
44130
- * explicitly to override that default per grant.
44131
- */
44132
- includeLinked: boolean().optional()
44133
- });
44134
- /**
44135
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44136
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44137
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44138
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44139
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44140
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44141
- * migration cannot reach a JWT already in a client's hands; parse-time
44142
- * migration covers both without a flag day. No cast — the raw object is read
44143
- * through `Reflect.get` (its static type is `unknown`).
44144
- */
44145
- function migrateLegacyTokenScope(raw) {
44146
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44147
- if (Reflect.get(raw, "type") !== "device") return raw;
44148
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44149
- const targets = Reflect.get(raw, "targets");
44150
- if (!Array.isArray(targets)) return raw;
44151
- return {
44152
- type: "device",
44153
- selector: {
44154
- kind: "ids",
44155
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44156
- },
44157
- access: Reflect.get(raw, "access")
44158
- };
44159
- }
44160
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44161
- object({
44162
- type: literal("category"),
44163
- target: CapScopeSchema,
44164
- access: array(MethodAccessSchema).min(1)
44165
- }),
44166
- object({
44167
- type: literal("capability"),
44168
- target: string(),
44169
- access: array(MethodAccessSchema).min(1)
44170
- }),
44171
- object({
44172
- type: literal("addon"),
44173
- target: string(),
44174
- access: array(MethodAccessSchema).min(1)
44175
- }),
44176
- DeviceTokenScopeSchema
44177
- ]));
44178
- object({
44179
- id: string(),
44180
- username: string(),
44181
- passwordHash: string(),
44182
- /**
44183
- * Admin bypass. When true, the middleware skips the scope-access
44184
- * check entirely. There is no other axis of privilege; the legacy
44185
- * role enum collapsed onto this boolean in v2.
44186
- */
44187
- isAdmin: boolean().default(false),
44188
- allowedProviders: AllowedProviderSchema,
44189
- allowedDevices: AllowedDevicesSchema,
44190
- /**
44191
- * Scopes granted to this user. Admins bypass; their `scopes` is
44192
- * ignored. Non-admins without scopes are locked out of every
44193
- * protected call.
44194
- */
44195
- scopes: array(TokenScopeSchema).default([]),
44196
- createdAt: number(),
44197
- updatedAt: number()
44198
- });
44199
- object({
44200
- id: string(),
44201
- label: string(),
44202
- isAdmin: boolean().default(false),
44203
- allowedProviders: AllowedProviderSchema,
44204
- allowedDevices: AllowedDevicesSchema,
44205
- tokenHash: string(),
44206
- tokenPrefix: string(),
44207
- createdAt: number(),
44208
- lastUsedAt: number().optional()
44209
- });
44210
- object({
44211
- id: string(),
44212
- userId: string(),
44213
- name: string(),
44214
- tokenHash: string(),
44215
- tokenPrefix: string(),
44216
- scopes: array(TokenScopeSchema),
44217
- expiresAt: number().nullish(),
44218
- lastUsedAt: number().nullish(),
44219
- createdAt: number()
44220
- });
44221
- /**
44222
44370
  * `oauth-integration` — a collection cap by which an addon declares
44223
44371
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44224
44372
  * Each provider returns a static descriptor; the core enumerates them
@@ -64174,26 +64322,6 @@ var ApiKeySummarySchema = object({
64174
64322
  createdAt: number(),
64175
64323
  lastUsedAt: number().optional()
64176
64324
  });
64177
- var ScopedTokenSummarySchema = object({
64178
- id: string(),
64179
- userId: string(),
64180
- name: string(),
64181
- tokenPrefix: string(),
64182
- scopes: array(TokenScopeSchema),
64183
- expiresAt: number().nullish(),
64184
- lastUsedAt: number().nullish(),
64185
- createdAt: number()
64186
- });
64187
- var CreateScopedTokenInputSchema = object({
64188
- userId: string(),
64189
- name: string(),
64190
- scopes: array(TokenScopeSchema),
64191
- expiresAt: number().optional()
64192
- });
64193
- var CreateScopedTokenResultSchema = object({
64194
- token: string(),
64195
- record: ScopedTokenSummarySchema
64196
- });
64197
64325
  var OauthSessionSummarySchema = object({
64198
64326
  id: string(),
64199
64327
  userId: string(),
@@ -64215,11 +64343,11 @@ var TotpStatusSchema = object({
64215
64343
  confirmedAt: number().nullable()
64216
64344
  });
64217
64345
  /**
64218
- * user-management — singleton capability for user accounts, API keys,
64219
- * and scoped tokens.
64346
+ * user-management — singleton capability for user accounts and the
64347
+ * legacy API-key rows.
64220
64348
  *
64221
64349
  * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
64222
- * — the subset check on `setUserScopes` / `createScopedToken` is moot
64350
+ * — the subset check on `setUserScopes` is moot
64223
64351
  * because non-admins never reach these. If/when we open non-admin
64224
64352
  * delegation, structural caller-scope subset check goes inside the
64225
64353
  * provider.
@@ -64276,15 +64404,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
64276
64404
  kind: "mutation",
64277
64405
  auth: "admin",
64278
64406
  access: "delete"
64279
- }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
64280
- kind: "mutation",
64281
- auth: "admin",
64282
- access: "create"
64283
- }), method(object({ id: string() }), object({ success: literal(true) }), {
64284
- kind: "mutation",
64285
- auth: "admin",
64286
- access: "delete"
64287
- }), method(object({ token: string() }), ScopedTokenSummarySchema.nullable(), { access: "view" }), method(object({ userId: string() }), array(ScopedTokenSummarySchema), { auth: "admin" }), method(object({ userId: string() }), TotpSetupResultSchema, {
64407
+ }), method(object({ userId: string() }), TotpSetupResultSchema, {
64288
64408
  kind: "mutation",
64289
64409
  auth: "admin",
64290
64410
  access: "create"
@@ -70374,7 +70494,7 @@ Object.freeze({
70374
70494
  capName: "llm",
70375
70495
  capScope: "system",
70376
70496
  addonId: null,
70377
- access: "view"
70497
+ access: "create"
70378
70498
  },
70379
70499
  "llm.listNodeModels": {
70380
70500
  capName: "llm",
@@ -75038,12 +75158,6 @@ Object.freeze({
75038
75158
  addonId: null,
75039
75159
  access: "create"
75040
75160
  },
75041
- "userManagement.createScopedToken": {
75042
- capName: "user-management",
75043
- capScope: "system",
75044
- addonId: null,
75045
- access: "create"
75046
- },
75047
75161
  "userManagement.createUser": {
75048
75162
  capName: "user-management",
75049
75163
  capScope: "system",
@@ -75092,12 +75206,6 @@ Object.freeze({
75092
75206
  addonId: null,
75093
75207
  access: "view"
75094
75208
  },
75095
- "userManagement.listScopedTokens": {
75096
- capName: "user-management",
75097
- capScope: "system",
75098
- addonId: null,
75099
- access: "view"
75100
- },
75101
75209
  "userManagement.listUsers": {
75102
75210
  capName: "user-management",
75103
75211
  capScope: "system",
@@ -75152,12 +75260,6 @@ Object.freeze({
75152
75260
  addonId: null,
75153
75261
  access: "delete"
75154
75262
  },
75155
- "userManagement.revokeScopedToken": {
75156
- capName: "user-management",
75157
- capScope: "system",
75158
- addonId: null,
75159
- access: "delete"
75160
- },
75161
75263
  "userManagement.setupTotp": {
75162
75264
  capName: "user-management",
75163
75265
  capScope: "system",
@@ -75188,12 +75290,6 @@ Object.freeze({
75188
75290
  addonId: null,
75189
75291
  access: "view"
75190
75292
  },
75191
- "userManagement.validateScopedToken": {
75192
- capName: "user-management",
75193
- capScope: "system",
75194
- addonId: null,
75195
- access: "view"
75196
- },
75197
75293
  "userManagement.verifyTotp": {
75198
75294
  capName: "user-management",
75199
75295
  capScope: "system",