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