@camstack/addon-provider-bosch 0.1.3 → 0.1.5

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