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