@camstack/addon-provider-mqtt-ha 0.1.7 → 0.1.9

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
@@ -5449,7 +5449,7 @@ var ZodIssueCode = {
5449
5449
  var ZodFirstPartyTypeKind;
5450
5450
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5451
5451
  //#endregion
5452
- //#region ../types/dist/sleep-BxjU_fJM.mjs
5452
+ //#region ../types/dist/sleep-yKL5gfrH.mjs
5453
5453
  /**
5454
5454
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5455
5455
  * window to float samples (D455).
@@ -7831,6 +7831,12 @@ function normalizeAddonInitResult(result) {
7831
7831
  if (Array.isArray(result)) return { providers: result };
7832
7832
  return result;
7833
7833
  }
7834
+ /**
7835
+ * The share-view scope kinds a share-link token can carry. The hub mints
7836
+ * and validates them (`ShareViewGrantSchema` builds its
7837
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
7838
+ */
7839
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7834
7840
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7835
7841
  var PeerBytesTicketSchema = object({
7836
7842
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12496,6 +12502,280 @@ var ConvertResultSchema = object({
12496
12502
  files: array(string()).readonly()
12497
12503
  })).readonly()
12498
12504
  });
12505
+ /**
12506
+ * Zod schemas for persisted record types.
12507
+ *
12508
+ * These schemas serve as the single source of truth for types that are
12509
+ * stored in the settings-store backend and retrieved via tRPC. They
12510
+ * replace the manual TypeScript interfaces with schema-derived types,
12511
+ * enabling runtime validation when reading from the backend.
12512
+ *
12513
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12514
+ * keeps the original name for backward compatibility.
12515
+ */
12516
+ /**
12517
+ * Auth model (v2 — 2026-05-12 caps-only):
12518
+ *
12519
+ * Two principals:
12520
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12521
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12522
+ *
12523
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12524
+ * `super_admin` — collapsed onto the single boolean because every
12525
+ * non-admin caller is governed by the same scope-check rules; the
12526
+ * distinction was only ever used to route role-specific procedures
12527
+ * which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
12528
+ * with `isAdmin: false` + an explicit scope list.
12529
+ */
12530
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12531
+ var MethodAccessSchema = _enum([
12532
+ "view",
12533
+ "create",
12534
+ "delete"
12535
+ ]);
12536
+ /**
12537
+ * A single scope grant. Three forms — checked in matcher with OR
12538
+ * semantics; the first match decides whether the call passes:
12539
+ *
12540
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12541
+ * cap with the matching `scope` declaration. New caps inherit grants
12542
+ * automatically — adding a device cap to the codebase makes it
12543
+ * reachable to every user with `category:device [...]` without a
12544
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12545
+ *
12546
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12547
+ * useful when an integration needs to interact with one specific
12548
+ * addon's surface regardless of how many caps it exports.
12549
+ *
12550
+ * - `capability` — the most precise form. Single cap name. Use for
12551
+ * integration tokens where you want to grant `addons.installPackage`
12552
+ * and nothing else.
12553
+ *
12554
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12555
+ * "give me everything" escape; there is no wildcard scope.
12556
+ */
12557
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12558
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12559
+ var CapScopeSchema = _enum(["device", "system"]);
12560
+ /**
12561
+ * DeviceSelector (scope model v3 — 2026-08-12).
12562
+ *
12563
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12564
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12565
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12566
+ * AFTER the grant was minted — no re-grant, no re-login.
12567
+ *
12568
+ * - `all` — every device in the deployment. The broad viewer/operator
12569
+ * lever without a `category` grant (a `category` grant also covers device
12570
+ * caps that carry no deviceId; `all` is specifically the device set).
12571
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
12572
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
12573
+ * is NOT covered until the grant is edited.
12574
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
12575
+ * DYNAMIC. A device that changes type, or a new device of the type,
12576
+ * re-resolves on the next request.
12577
+ * - `locations` — every device whose operator-assigned `location` label is
12578
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
12579
+ * null/unset location matches NO `locations` selector.
12580
+ */
12581
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
12582
+ object({ kind: literal("all") }),
12583
+ object({
12584
+ kind: literal("ids"),
12585
+ ids: array(number().int()).min(1)
12586
+ }),
12587
+ object({
12588
+ kind: literal("types"),
12589
+ types: array(_enum(DeviceType)).min(1)
12590
+ }),
12591
+ object({
12592
+ kind: literal("locations"),
12593
+ locations: array(string().min(1)).min(1)
12594
+ })
12595
+ ]);
12596
+ var DeviceTokenScopeSchema = object({
12597
+ type: literal("device"),
12598
+ /** The device SET this grant covers — resolved against the live fleet. */
12599
+ selector: DeviceSelectorSchema,
12600
+ access: array(MethodAccessSchema).min(1),
12601
+ /**
12602
+ * Whether a grant on a PARENT device transparently covers its accessory
12603
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
12604
+ * Direction is parent → children ONLY.
12605
+ *
12606
+ * Absent → the matcher DERIVES it from the access flavour: `view`
12607
+ * inherits (a camera viewer sees the camera's accessories), `create` /
12608
+ * `delete` do NOT (actuating/removing a child is an explicit act the
12609
+ * operator must grant on the child, not inherit from the parent). Set it
12610
+ * explicitly to override that default per grant.
12611
+ */
12612
+ includeLinked: boolean().optional()
12613
+ });
12614
+ /**
12615
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
12616
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
12617
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
12618
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
12619
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
12620
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
12621
+ * migration cannot reach a JWT already in a client's hands; parse-time
12622
+ * migration covers both without a flag day. No cast — the raw object is read
12623
+ * through `Reflect.get` (its static type is `unknown`).
12624
+ */
12625
+ function migrateLegacyTokenScope(raw) {
12626
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
12627
+ if (Reflect.get(raw, "type") !== "device") return raw;
12628
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
12629
+ const targets = Reflect.get(raw, "targets");
12630
+ if (!Array.isArray(targets)) return raw;
12631
+ return {
12632
+ type: "device",
12633
+ selector: {
12634
+ kind: "ids",
12635
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
12636
+ },
12637
+ access: Reflect.get(raw, "access")
12638
+ };
12639
+ }
12640
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
12641
+ object({
12642
+ type: literal("category"),
12643
+ target: CapScopeSchema,
12644
+ access: array(MethodAccessSchema).min(1)
12645
+ }),
12646
+ object({
12647
+ type: literal("capability"),
12648
+ target: string(),
12649
+ access: array(MethodAccessSchema).min(1)
12650
+ }),
12651
+ object({
12652
+ type: literal("addon"),
12653
+ target: string(),
12654
+ access: array(MethodAccessSchema).min(1)
12655
+ }),
12656
+ DeviceTokenScopeSchema
12657
+ ]));
12658
+ object({
12659
+ id: string(),
12660
+ username: string(),
12661
+ passwordHash: string(),
12662
+ /**
12663
+ * Admin bypass. When true, the middleware skips the scope-access
12664
+ * check entirely. There is no other axis of privilege; the legacy
12665
+ * role enum collapsed onto this boolean in v2.
12666
+ */
12667
+ isAdmin: boolean().default(false),
12668
+ allowedProviders: AllowedProviderSchema,
12669
+ allowedDevices: AllowedDevicesSchema,
12670
+ /**
12671
+ * Scopes granted to this user. Admins bypass; their `scopes` is
12672
+ * ignored. Non-admins without scopes are locked out of every
12673
+ * protected call.
12674
+ */
12675
+ scopes: array(TokenScopeSchema).default([]),
12676
+ createdAt: number(),
12677
+ updatedAt: number()
12678
+ });
12679
+ object({
12680
+ id: string(),
12681
+ label: string(),
12682
+ isAdmin: boolean().default(false),
12683
+ allowedProviders: AllowedProviderSchema,
12684
+ allowedDevices: AllowedDevicesSchema,
12685
+ tokenHash: string(),
12686
+ tokenPrefix: string(),
12687
+ createdAt: number(),
12688
+ lastUsedAt: number().optional()
12689
+ });
12690
+ object({
12691
+ id: string(),
12692
+ userId: string(),
12693
+ name: string(),
12694
+ tokenHash: string(),
12695
+ tokenPrefix: string(),
12696
+ scopes: array(TokenScopeSchema),
12697
+ expiresAt: number().nullish(),
12698
+ lastUsedAt: number().nullish(),
12699
+ createdAt: number()
12700
+ });
12701
+ /** What a share-view grant lets its holder see. */
12702
+ var ShareViewGrantSchema = object({
12703
+ kind: _enum(SHARE_VIEW_KINDS),
12704
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
12705
+ /** Talk-back, opt-in at mint time; absent means off. */
12706
+ talk: boolean().optional()
12707
+ });
12708
+ var ShareViewScopeSchema = object({
12709
+ type: literal("share-view"),
12710
+ grant: ShareViewGrantSchema
12711
+ });
12712
+ var AddonRoutesScopeSchema = object({
12713
+ type: literal("addon-routes"),
12714
+ access: array(MethodAccessSchema).min(1)
12715
+ });
12716
+ var PreferencesSelfScopeSchema = object({ type: literal("preferences-self") });
12717
+ var CredentialScopeSchema = union([
12718
+ literal("*"),
12719
+ ShareViewScopeSchema,
12720
+ AddonRoutesScopeSchema,
12721
+ PreferencesSelfScopeSchema,
12722
+ TokenScopeSchema
12723
+ ]);
12724
+ object({
12725
+ kind: literal("credential"),
12726
+ sub: string().min(1),
12727
+ jti: string().min(16),
12728
+ scopes: array(CredentialScopeSchema).min(1)
12729
+ });
12730
+ var PreferenceNamespaceSchema = string().regex(/^[a-z][a-z0-9.-]{0,63}$/);
12731
+ /** A namespace's value: a JSON object, opaque to the hub. */
12732
+ var PreferenceValueSchema = record(string(), unknown());
12733
+ var PreferenceDeviceIdSchema = string().min(1).max(64);
12734
+ /** A stored row, as the owner reads it. */
12735
+ var PreferenceRowSchema = object({
12736
+ namespace: PreferenceNamespaceSchema,
12737
+ value: PreferenceValueSchema,
12738
+ /** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
12739
+ revision: number().int().positive(),
12740
+ updatedAt: number().int(),
12741
+ /** The client id the last writer sent; `null` when it sent none. */
12742
+ updatedByDevice: PreferenceDeviceIdSchema.nullable()
12743
+ });
12744
+ object({
12745
+ /** Absent: every namespace the caller holds. */
12746
+ namespaces: array(PreferenceNamespaceSchema).max(32).optional() });
12747
+ object({ rows: array(PreferenceRowSchema) });
12748
+ object({
12749
+ namespace: PreferenceNamespaceSchema,
12750
+ value: PreferenceValueSchema,
12751
+ /**
12752
+ * The revision the edit was based on. Absent: last write wins. `0`: the
12753
+ * namespace must not exist yet. Any other value that is not the current
12754
+ * revision answers `conflict` and writes nothing.
12755
+ */
12756
+ baseRevision: number().int().nonnegative().optional(),
12757
+ deviceId: PreferenceDeviceIdSchema.optional()
12758
+ });
12759
+ discriminatedUnion("status", [object({
12760
+ status: literal("saved"),
12761
+ row: PreferenceRowSchema
12762
+ }), object({
12763
+ status: literal("conflict"),
12764
+ current: PreferenceRowSchema.nullable()
12765
+ })]);
12766
+ object({ namespace: PreferenceNamespaceSchema });
12767
+ object({
12768
+ /** `false` when the namespace did not exist. */
12769
+ deleted: boolean() });
12770
+ object({
12771
+ /** The revision the client holds per namespace; a namespace it does not list is new to it. */
12772
+ revisionByNamespace: record(PreferenceNamespaceSchema, number().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
12773
+ object({
12774
+ /** Every row whose revision differs from the client's, and every row it did not list. */
12775
+ rows: array(PreferenceRowSchema),
12776
+ /** Namespaces the client listed that no longer exist. */
12777
+ deleted: array(PreferenceNamespaceSchema)
12778
+ });
12499
12779
  _enum(["new-session", "step-up"]);
12500
12780
  /** The languages the hub's app landing pages are written in (D858). */
12501
12781
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -39689,38 +39969,37 @@ method(LlmRuntimeCompleteInputSchema, LlmGenerateResultSchema, {
39689
39969
  auth: "admin",
39690
39970
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39691
39971
  });
39972
+ var LlmProfileKindSchema = string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "a kind id is lower-case letters, digits and dashes");
39973
+ /** What a model (or, by default, every model of a kind) can do. */
39974
+ var LlmModelFeaturesSchema = object({
39975
+ vision: boolean(),
39976
+ tools: boolean(),
39977
+ streaming: boolean()
39978
+ });
39979
+ /** One model a provider offers. `features` overrides the kind's defaults, per field. */
39980
+ var LlmModelInfoSchema = object({
39981
+ id: string(),
39982
+ label: string().optional(),
39983
+ contextLength: number().int().positive().optional(),
39984
+ features: LlmModelFeaturesSchema.partial().optional()
39985
+ });
39692
39986
  /**
39693
- * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
39694
- * methods concat-fan across providers; single-row methods route to ONE
39695
- * provider by the `addonId` in the call input (the notification-output
39696
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
39697
- * (hub-placed); the cap stays open for future providers.
39698
- *
39699
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
39700
- * `apiKey` is a password field — providers REDACT it on read and merge on
39701
- * write; a stored key NEVER round-trips to a client.
39987
+ * The provider-specific part of a profile, validated by the provider that owns
39988
+ * the kind (`upsertProfile` refuses what it does not accept). A field its
39989
+ * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
39990
+ * keychain, never in the row, and reads back as the redaction marker.
39702
39991
  */
39703
- var LlmProfileKindSchema = _enum([
39704
- "openai-compatible",
39705
- "openai",
39706
- "anthropic",
39707
- "google",
39708
- "managed-local",
39709
- "apple-foundation"
39710
- ]);
39992
+ var LlmProviderConfigSchema = record(string(), unknown());
39711
39993
  var LlmProfileSchema = object({
39712
39994
  id: string(),
39713
39995
  name: string(),
39996
+ /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
39714
39997
  kind: LlmProfileKindSchema,
39715
39998
  /** Stamped by the provider — keeps the fanned catalog routable. */
39716
39999
  addonId: string(),
39717
40000
  enabled: boolean(),
39718
40001
  /** Vendor model id, or the managed runtime's loaded model. */
39719
40002
  model: string(),
39720
- /** Required for openai-compatible; override for cloud kinds. */
39721
- baseUrl: string().optional(),
39722
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
39723
- apiKey: string().optional(),
39724
40003
  /** Vision on/off. A vision call against a `false` profile is REFUSED, never
39725
40004
  * degraded to text — that shipped once and produced a confident answer to a
39726
40005
  * question about a picture nobody sent. */
@@ -39728,15 +40007,11 @@ var LlmProfileSchema = object({
39728
40007
  temperature: number().min(0).max(2).optional(),
39729
40008
  /** Nucleus sampling. Every wire we speak has it. */
39730
40009
  topP: number().min(0).max(1).optional(),
39731
- /** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
39732
- * wire does, and the client drops it there (measured: the request body gets
39733
- * `top_p` and no `top_k`). The profile editor hides the field wherever it
39734
- * would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
40010
+ /** Top-k sampling. Carried only by the wires that have it — a kind offers the
40011
+ * field in its editor only when its descriptor lists it in `profileFields`. */
39735
40012
  topK: number().int().positive().optional(),
39736
40013
  maxTokens: number().int().positive().optional(),
39737
- /** Prompt context window. Advisory for cloud kinds (they enforce their own);
39738
- * for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
39739
- * the model with, so it is the one field that changes a PROCESS. */
40014
+ /** Prompt context window. Advisory for cloud kinds (they enforce their own). */
39740
40015
  contextLength: number().int().positive().optional(),
39741
40016
  /** Default system prompt. A caller's `system` REPLACES it (never appends —
39742
40017
  * two system prompts fighting is worse than either alone). */
@@ -39762,16 +40037,37 @@ var LlmProfileSchema = object({
39762
40037
  * library; the REGISTRY of callable tools is ours and is empty in v1, so a
39763
40038
  * `true` here buys the wiring, not behaviour, until tools are registered. */
39764
40039
  toolsEnabled: boolean().default(false),
39765
- extraHeaders: record(string(), string()).optional(),
39766
- /** kind === 'managed-local' only (spec §4). */
39767
- runtime: ManagedRuntimeConfigSchema.optional(),
39768
- /**
39769
- * kind === 'apple-foundation' only: WHERE it runs — the only thing there is
39770
- * to configure (no key, no URL, no download; `model` is `apple-system`).
39771
- * `supportsVision` on such a row is stamped by the provider from the node's
39772
- * reported `imageInput`, never taken from the operator (D62).
39773
- */
39774
- appleFoundation: object({ nodeId: string() }).optional()
40040
+ /** Everything the kind's provider owns (endpoint, key, node, runtime…). */
40041
+ providerConfig: LlmProviderConfigSchema.default({})
40042
+ });
40043
+ /**
40044
+ * The common profile fields a kind's editor offers. The editor owns how each
40045
+ * one is drawn; the provider says which of them mean something on its wire.
40046
+ */
40047
+ var LlmProfileFieldSchema = _enum([
40048
+ "temperature",
40049
+ "topP",
40050
+ "topK",
40051
+ "maxTokens",
40052
+ "contextLength",
40053
+ "systemPrompt",
40054
+ "timeoutMs",
40055
+ "connectTimeoutMs",
40056
+ "firstTokenTimeoutMs",
40057
+ "idleTimeoutMs",
40058
+ "retry",
40059
+ "toolsEnabled"
40060
+ ]);
40061
+ /**
40062
+ * A provider-drawn part of the editor, by a generic widget id the admin UI
40063
+ * registers (`ai/apple-node`). `placement: 'model'` replaces the generic model
40064
+ * picker: that widget owns the model choice.
40065
+ */
40066
+ var LlmProviderWidgetSchema = object({
40067
+ id: string(),
40068
+ placement: _enum(["connection", "model"]),
40069
+ /** `providerConfig` keys this widget must fill before the profile can be saved. */
40070
+ requires: array(string()).optional()
39775
40071
  });
39776
40072
  /** ConfigUISchema tree passed through untyped on the wire (the
39777
40073
  * notification-output `ConfigSchemaPassthrough` precedent at
@@ -39780,11 +40076,56 @@ var ConfigSchemaPassthrough$3 = unknown();
39780
40076
  var LlmProfileKindDescriptorSchema = object({
39781
40077
  kind: LlmProfileKindSchema,
39782
40078
  label: string(),
40079
+ /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
39783
40080
  icon: string(),
39784
40081
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
39785
40082
  addonId: string(),
39786
- configSchema: ConfigSchemaPassthrough$3
40083
+ /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
40084
+ connectionSchema: ConfigSchemaPassthrough$3,
40085
+ /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
40086
+ advancedSchema: ConfigSchemaPassthrough$3.optional(),
40087
+ /** The kind's defaults; a model from `listModels` may override any of them. */
40088
+ features: LlmModelFeaturesSchema,
40089
+ /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
40090
+ visionEditable: boolean(),
40091
+ /** Where the model list comes from: `listModels`, `staticModels`, or nowhere. */
40092
+ modelCatalog: _enum([
40093
+ "fetch",
40094
+ "static",
40095
+ "none"
40096
+ ]),
40097
+ staticModels: array(LlmModelInfoSchema).optional(),
40098
+ /** The common fields that mean something on this kind's wire. */
40099
+ profileFields: array(LlmProfileFieldSchema),
40100
+ providerWidgets: array(LlmProviderWidgetSchema).optional()
40101
+ });
40102
+ /**
40103
+ * `listModels` input. `connection` is an UNSAVED draft of `providerConfig`
40104
+ * (the editor's form); with `profileId` too, a secret the draft leaves
40105
+ * untouched (absent or the redaction marker) is resolved server-side from the
40106
+ * stored profile — the browser never receives it.
40107
+ */
40108
+ var LlmListModelsInputSchema = object({
40109
+ addonId: string(),
40110
+ kind: LlmProfileKindSchema,
40111
+ profileId: string().optional(),
40112
+ connection: LlmProviderConfigSchema.optional()
39787
40113
  });
40114
+ var LlmListModelsErrorCodeSchema = _enum([
40115
+ "auth",
40116
+ "network",
40117
+ "unsupported",
40118
+ "invalid"
40119
+ ]);
40120
+ /** A RESULT, never a throw: "wrong key" is an answer the editor renders inline. */
40121
+ var LlmListModelsResultSchema = discriminatedUnion("ok", [object({
40122
+ ok: literal(true),
40123
+ models: array(LlmModelInfoSchema)
40124
+ }), object({
40125
+ ok: literal(false),
40126
+ code: LlmListModelsErrorCodeSchema,
40127
+ message: string()
40128
+ })]);
39788
40129
  var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
39789
40130
  var LlmDefaultSchema = object({
39790
40131
  selector: LlmDefaultSelectorSchema,
@@ -39884,7 +40225,10 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
39884
40225
  kind: "mutation",
39885
40226
  auth: "admin",
39886
40227
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39887
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
40228
+ }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
40229
+ kind: "mutation",
40230
+ auth: "admin"
40231
+ }), method(object({}), array(LlmDefaultSchema)), method(object({
39888
40232
  selector: LlmDefaultSelectorSchema,
39889
40233
  profileId: string().nullable()
39890
40234
  }), _void(), {
@@ -43990,202 +44334,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
43990
44334
  auth: "admin"
43991
44335
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
43992
44336
  /**
43993
- * Zod schemas for persisted record types.
43994
- *
43995
- * These schemas serve as the single source of truth for types that are
43996
- * stored in the settings-store backend and retrieved via tRPC. They
43997
- * replace the manual TypeScript interfaces with schema-derived types,
43998
- * enabling runtime validation when reading from the backend.
43999
- *
44000
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
44001
- * keeps the original name for backward compatibility.
44002
- */
44003
- /**
44004
- * Auth model (v2 — 2026-05-12 caps-only):
44005
- *
44006
- * Two principals:
44007
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
44008
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
44009
- *
44010
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44011
- * `super_admin` — collapsed onto the single boolean because every
44012
- * non-admin caller is governed by the same scope-check rules; the
44013
- * distinction was only ever used to route role-specific procedures
44014
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44015
- * with `isAdmin: false` + an explicit scope list.
44016
- */
44017
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44018
- var MethodAccessSchema = _enum([
44019
- "view",
44020
- "create",
44021
- "delete"
44022
- ]);
44023
- /**
44024
- * A single scope grant. Three forms — checked in matcher with OR
44025
- * semantics; the first match decides whether the call passes:
44026
- *
44027
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44028
- * cap with the matching `scope` declaration. New caps inherit grants
44029
- * automatically — adding a device cap to the codebase makes it
44030
- * reachable to every user with `category:device [...]` without a
44031
- * re-grant. Use this for "family viewer" / "operator" tiers.
44032
- *
44033
- * - `addon` — every cap that ships inside a given addon id. Niche;
44034
- * useful when an integration needs to interact with one specific
44035
- * addon's surface regardless of how many caps it exports.
44036
- *
44037
- * - `capability` — the most precise form. Single cap name. Use for
44038
- * integration tokens where you want to grant `addons.installPackage`
44039
- * and nothing else.
44040
- *
44041
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44042
- * "give me everything" escape; there is no wildcard scope.
44043
- */
44044
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44045
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44046
- var CapScopeSchema = _enum(["device", "system"]);
44047
- /**
44048
- * DeviceSelector (scope model v3 — 2026-08-12).
44049
- *
44050
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44051
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44052
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44053
- * AFTER the grant was minted — no re-grant, no re-login.
44054
- *
44055
- * - `all` — every device in the deployment. The broad viewer/operator
44056
- * lever without a `category` grant (a `category` grant also covers device
44057
- * caps that carry no deviceId; `all` is specifically the device set).
44058
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44059
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44060
- * is NOT covered until the grant is edited.
44061
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44062
- * DYNAMIC. A device that changes type, or a new device of the type,
44063
- * re-resolves on the next request.
44064
- * - `locations` — every device whose operator-assigned `location` label is
44065
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44066
- * null/unset location matches NO `locations` selector.
44067
- */
44068
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44069
- object({ kind: literal("all") }),
44070
- object({
44071
- kind: literal("ids"),
44072
- ids: array(number().int()).min(1)
44073
- }),
44074
- object({
44075
- kind: literal("types"),
44076
- types: array(_enum(DeviceType)).min(1)
44077
- }),
44078
- object({
44079
- kind: literal("locations"),
44080
- locations: array(string().min(1)).min(1)
44081
- })
44082
- ]);
44083
- var DeviceTokenScopeSchema = object({
44084
- type: literal("device"),
44085
- /** The device SET this grant covers — resolved against the live fleet. */
44086
- selector: DeviceSelectorSchema,
44087
- access: array(MethodAccessSchema).min(1),
44088
- /**
44089
- * Whether a grant on a PARENT device transparently covers its accessory
44090
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44091
- * Direction is parent → children ONLY.
44092
- *
44093
- * Absent → the matcher DERIVES it from the access flavour: `view`
44094
- * inherits (a camera viewer sees the camera's accessories), `create` /
44095
- * `delete` do NOT (actuating/removing a child is an explicit act the
44096
- * operator must grant on the child, not inherit from the parent). Set it
44097
- * explicitly to override that default per grant.
44098
- */
44099
- includeLinked: boolean().optional()
44100
- });
44101
- /**
44102
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44103
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44104
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44105
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44106
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44107
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44108
- * migration cannot reach a JWT already in a client's hands; parse-time
44109
- * migration covers both without a flag day. No cast — the raw object is read
44110
- * through `Reflect.get` (its static type is `unknown`).
44111
- */
44112
- function migrateLegacyTokenScope(raw) {
44113
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44114
- if (Reflect.get(raw, "type") !== "device") return raw;
44115
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44116
- const targets = Reflect.get(raw, "targets");
44117
- if (!Array.isArray(targets)) return raw;
44118
- return {
44119
- type: "device",
44120
- selector: {
44121
- kind: "ids",
44122
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44123
- },
44124
- access: Reflect.get(raw, "access")
44125
- };
44126
- }
44127
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44128
- object({
44129
- type: literal("category"),
44130
- target: CapScopeSchema,
44131
- access: array(MethodAccessSchema).min(1)
44132
- }),
44133
- object({
44134
- type: literal("capability"),
44135
- target: string(),
44136
- access: array(MethodAccessSchema).min(1)
44137
- }),
44138
- object({
44139
- type: literal("addon"),
44140
- target: string(),
44141
- access: array(MethodAccessSchema).min(1)
44142
- }),
44143
- DeviceTokenScopeSchema
44144
- ]));
44145
- object({
44146
- id: string(),
44147
- username: string(),
44148
- passwordHash: string(),
44149
- /**
44150
- * Admin bypass. When true, the middleware skips the scope-access
44151
- * check entirely. There is no other axis of privilege; the legacy
44152
- * role enum collapsed onto this boolean in v2.
44153
- */
44154
- isAdmin: boolean().default(false),
44155
- allowedProviders: AllowedProviderSchema,
44156
- allowedDevices: AllowedDevicesSchema,
44157
- /**
44158
- * Scopes granted to this user. Admins bypass; their `scopes` is
44159
- * ignored. Non-admins without scopes are locked out of every
44160
- * protected call.
44161
- */
44162
- scopes: array(TokenScopeSchema).default([]),
44163
- createdAt: number(),
44164
- updatedAt: number()
44165
- });
44166
- object({
44167
- id: string(),
44168
- label: string(),
44169
- isAdmin: boolean().default(false),
44170
- allowedProviders: AllowedProviderSchema,
44171
- allowedDevices: AllowedDevicesSchema,
44172
- tokenHash: string(),
44173
- tokenPrefix: string(),
44174
- createdAt: number(),
44175
- lastUsedAt: number().optional()
44176
- });
44177
- object({
44178
- id: string(),
44179
- userId: string(),
44180
- name: string(),
44181
- tokenHash: string(),
44182
- tokenPrefix: string(),
44183
- scopes: array(TokenScopeSchema),
44184
- expiresAt: number().nullish(),
44185
- lastUsedAt: number().nullish(),
44186
- createdAt: number()
44187
- });
44188
- /**
44189
44337
  * `oauth-integration` — a collection cap by which an addon declares
44190
44338
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44191
44339
  * Each provider returns a static descriptor; the core enumerates them
@@ -63968,26 +64116,6 @@ var ApiKeySummarySchema = object({
63968
64116
  createdAt: number(),
63969
64117
  lastUsedAt: number().optional()
63970
64118
  });
63971
- var ScopedTokenSummarySchema = object({
63972
- id: string(),
63973
- userId: string(),
63974
- name: string(),
63975
- tokenPrefix: string(),
63976
- scopes: array(TokenScopeSchema),
63977
- expiresAt: number().nullish(),
63978
- lastUsedAt: number().nullish(),
63979
- createdAt: number()
63980
- });
63981
- var CreateScopedTokenInputSchema = object({
63982
- userId: string(),
63983
- name: string(),
63984
- scopes: array(TokenScopeSchema),
63985
- expiresAt: number().optional()
63986
- });
63987
- var CreateScopedTokenResultSchema = object({
63988
- token: string(),
63989
- record: ScopedTokenSummarySchema
63990
- });
63991
64119
  var OauthSessionSummarySchema = object({
63992
64120
  id: string(),
63993
64121
  userId: string(),
@@ -64009,11 +64137,11 @@ var TotpStatusSchema = object({
64009
64137
  confirmedAt: number().nullable()
64010
64138
  });
64011
64139
  /**
64012
- * user-management — singleton capability for user accounts, API keys,
64013
- * and scoped tokens.
64140
+ * user-management — singleton capability for user accounts and the
64141
+ * legacy API-key rows.
64014
64142
  *
64015
64143
  * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
64016
- * — the subset check on `setUserScopes` / `createScopedToken` is moot
64144
+ * — the subset check on `setUserScopes` is moot
64017
64145
  * because non-admins never reach these. If/when we open non-admin
64018
64146
  * delegation, structural caller-scope subset check goes inside the
64019
64147
  * provider.
@@ -64070,15 +64198,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
64070
64198
  kind: "mutation",
64071
64199
  auth: "admin",
64072
64200
  access: "delete"
64073
- }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
64074
- kind: "mutation",
64075
- auth: "admin",
64076
- access: "create"
64077
- }), method(object({ id: string() }), object({ success: literal(true) }), {
64078
- kind: "mutation",
64079
- auth: "admin",
64080
- access: "delete"
64081
- }), method(object({ token: string() }), ScopedTokenSummarySchema.nullable(), { access: "view" }), method(object({ userId: string() }), array(ScopedTokenSummarySchema), { auth: "admin" }), method(object({ userId: string() }), TotpSetupResultSchema, {
64201
+ }), method(object({ userId: string() }), TotpSetupResultSchema, {
64082
64202
  kind: "mutation",
64083
64203
  auth: "admin",
64084
64204
  access: "create"
@@ -70168,7 +70288,7 @@ Object.freeze({
70168
70288
  capName: "llm",
70169
70289
  capScope: "system",
70170
70290
  addonId: null,
70171
- access: "view"
70291
+ access: "create"
70172
70292
  },
70173
70293
  "llm.listNodeModels": {
70174
70294
  capName: "llm",
@@ -74832,12 +74952,6 @@ Object.freeze({
74832
74952
  addonId: null,
74833
74953
  access: "create"
74834
74954
  },
74835
- "userManagement.createScopedToken": {
74836
- capName: "user-management",
74837
- capScope: "system",
74838
- addonId: null,
74839
- access: "create"
74840
- },
74841
74955
  "userManagement.createUser": {
74842
74956
  capName: "user-management",
74843
74957
  capScope: "system",
@@ -74886,12 +75000,6 @@ Object.freeze({
74886
75000
  addonId: null,
74887
75001
  access: "view"
74888
75002
  },
74889
- "userManagement.listScopedTokens": {
74890
- capName: "user-management",
74891
- capScope: "system",
74892
- addonId: null,
74893
- access: "view"
74894
- },
74895
75003
  "userManagement.listUsers": {
74896
75004
  capName: "user-management",
74897
75005
  capScope: "system",
@@ -74946,12 +75054,6 @@ Object.freeze({
74946
75054
  addonId: null,
74947
75055
  access: "delete"
74948
75056
  },
74949
- "userManagement.revokeScopedToken": {
74950
- capName: "user-management",
74951
- capScope: "system",
74952
- addonId: null,
74953
- access: "delete"
74954
- },
74955
75057
  "userManagement.setupTotp": {
74956
75058
  capName: "user-management",
74957
75059
  capScope: "system",
@@ -74982,12 +75084,6 @@ Object.freeze({
74982
75084
  addonId: null,
74983
75085
  access: "view"
74984
75086
  },
74985
- "userManagement.validateScopedToken": {
74986
- capName: "user-management",
74987
- capScope: "system",
74988
- addonId: null,
74989
- access: "view"
74990
- },
74991
75087
  "userManagement.verifyTotp": {
74992
75088
  capName: "user-management",
74993
75089
  capScope: "system",