@camstack/addon-provider-rtsp 1.2.129 → 1.2.131

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
@@ -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).
@@ -7796,6 +7796,12 @@ function normalizeAddonInitResult(result) {
7796
7796
  if (Array.isArray(result)) return { providers: result };
7797
7797
  return result;
7798
7798
  }
7799
+ /**
7800
+ * The share-view scope kinds a share-link token can carry. The hub mints
7801
+ * and validates them (`ShareViewGrantSchema` builds its
7802
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
7803
+ */
7804
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7799
7805
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7800
7806
  var PeerBytesTicketSchema = object({
7801
7807
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12582,6 +12588,280 @@ var ConvertResultSchema = object({
12582
12588
  files: array(string()).readonly()
12583
12589
  })).readonly()
12584
12590
  });
12591
+ /**
12592
+ * Zod schemas for persisted record types.
12593
+ *
12594
+ * These schemas serve as the single source of truth for types that are
12595
+ * stored in the settings-store backend and retrieved via tRPC. They
12596
+ * replace the manual TypeScript interfaces with schema-derived types,
12597
+ * enabling runtime validation when reading from the backend.
12598
+ *
12599
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12600
+ * keeps the original name for backward compatibility.
12601
+ */
12602
+ /**
12603
+ * Auth model (v2 — 2026-05-12 caps-only):
12604
+ *
12605
+ * Two principals:
12606
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12607
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12608
+ *
12609
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12610
+ * `super_admin` — collapsed onto the single boolean because every
12611
+ * non-admin caller is governed by the same scope-check rules; the
12612
+ * distinction was only ever used to route role-specific procedures
12613
+ * which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
12614
+ * with `isAdmin: false` + an explicit scope list.
12615
+ */
12616
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12617
+ var MethodAccessSchema = _enum([
12618
+ "view",
12619
+ "create",
12620
+ "delete"
12621
+ ]);
12622
+ /**
12623
+ * A single scope grant. Three forms — checked in matcher with OR
12624
+ * semantics; the first match decides whether the call passes:
12625
+ *
12626
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12627
+ * cap with the matching `scope` declaration. New caps inherit grants
12628
+ * automatically — adding a device cap to the codebase makes it
12629
+ * reachable to every user with `category:device [...]` without a
12630
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12631
+ *
12632
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12633
+ * useful when an integration needs to interact with one specific
12634
+ * addon's surface regardless of how many caps it exports.
12635
+ *
12636
+ * - `capability` — the most precise form. Single cap name. Use for
12637
+ * integration tokens where you want to grant `addons.installPackage`
12638
+ * and nothing else.
12639
+ *
12640
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12641
+ * "give me everything" escape; there is no wildcard scope.
12642
+ */
12643
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12644
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12645
+ var CapScopeSchema = _enum(["device", "system"]);
12646
+ /**
12647
+ * DeviceSelector (scope model v3 — 2026-08-12).
12648
+ *
12649
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12650
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12651
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12652
+ * AFTER the grant was minted — no re-grant, no re-login.
12653
+ *
12654
+ * - `all` — every device in the deployment. The broad viewer/operator
12655
+ * lever without a `category` grant (a `category` grant also covers device
12656
+ * caps that carry no deviceId; `all` is specifically the device set).
12657
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
12658
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
12659
+ * is NOT covered until the grant is edited.
12660
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
12661
+ * DYNAMIC. A device that changes type, or a new device of the type,
12662
+ * re-resolves on the next request.
12663
+ * - `locations` — every device whose operator-assigned `location` label is
12664
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
12665
+ * null/unset location matches NO `locations` selector.
12666
+ */
12667
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
12668
+ object({ kind: literal("all") }),
12669
+ object({
12670
+ kind: literal("ids"),
12671
+ ids: array(number().int()).min(1)
12672
+ }),
12673
+ object({
12674
+ kind: literal("types"),
12675
+ types: array(_enum(DeviceType)).min(1)
12676
+ }),
12677
+ object({
12678
+ kind: literal("locations"),
12679
+ locations: array(string().min(1)).min(1)
12680
+ })
12681
+ ]);
12682
+ var DeviceTokenScopeSchema = object({
12683
+ type: literal("device"),
12684
+ /** The device SET this grant covers — resolved against the live fleet. */
12685
+ selector: DeviceSelectorSchema,
12686
+ access: array(MethodAccessSchema).min(1),
12687
+ /**
12688
+ * Whether a grant on a PARENT device transparently covers its accessory
12689
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
12690
+ * Direction is parent → children ONLY.
12691
+ *
12692
+ * Absent → the matcher DERIVES it from the access flavour: `view`
12693
+ * inherits (a camera viewer sees the camera's accessories), `create` /
12694
+ * `delete` do NOT (actuating/removing a child is an explicit act the
12695
+ * operator must grant on the child, not inherit from the parent). Set it
12696
+ * explicitly to override that default per grant.
12697
+ */
12698
+ includeLinked: boolean().optional()
12699
+ });
12700
+ /**
12701
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
12702
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
12703
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
12704
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
12705
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
12706
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
12707
+ * migration cannot reach a JWT already in a client's hands; parse-time
12708
+ * migration covers both without a flag day. No cast — the raw object is read
12709
+ * through `Reflect.get` (its static type is `unknown`).
12710
+ */
12711
+ function migrateLegacyTokenScope(raw) {
12712
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
12713
+ if (Reflect.get(raw, "type") !== "device") return raw;
12714
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
12715
+ const targets = Reflect.get(raw, "targets");
12716
+ if (!Array.isArray(targets)) return raw;
12717
+ return {
12718
+ type: "device",
12719
+ selector: {
12720
+ kind: "ids",
12721
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
12722
+ },
12723
+ access: Reflect.get(raw, "access")
12724
+ };
12725
+ }
12726
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
12727
+ object({
12728
+ type: literal("category"),
12729
+ target: CapScopeSchema,
12730
+ access: array(MethodAccessSchema).min(1)
12731
+ }),
12732
+ object({
12733
+ type: literal("capability"),
12734
+ target: string(),
12735
+ access: array(MethodAccessSchema).min(1)
12736
+ }),
12737
+ object({
12738
+ type: literal("addon"),
12739
+ target: string(),
12740
+ access: array(MethodAccessSchema).min(1)
12741
+ }),
12742
+ DeviceTokenScopeSchema
12743
+ ]));
12744
+ object({
12745
+ id: string(),
12746
+ username: string(),
12747
+ passwordHash: string(),
12748
+ /**
12749
+ * Admin bypass. When true, the middleware skips the scope-access
12750
+ * check entirely. There is no other axis of privilege; the legacy
12751
+ * role enum collapsed onto this boolean in v2.
12752
+ */
12753
+ isAdmin: boolean().default(false),
12754
+ allowedProviders: AllowedProviderSchema,
12755
+ allowedDevices: AllowedDevicesSchema,
12756
+ /**
12757
+ * Scopes granted to this user. Admins bypass; their `scopes` is
12758
+ * ignored. Non-admins without scopes are locked out of every
12759
+ * protected call.
12760
+ */
12761
+ scopes: array(TokenScopeSchema).default([]),
12762
+ createdAt: number(),
12763
+ updatedAt: number()
12764
+ });
12765
+ object({
12766
+ id: string(),
12767
+ label: string(),
12768
+ isAdmin: boolean().default(false),
12769
+ allowedProviders: AllowedProviderSchema,
12770
+ allowedDevices: AllowedDevicesSchema,
12771
+ tokenHash: string(),
12772
+ tokenPrefix: string(),
12773
+ createdAt: number(),
12774
+ lastUsedAt: number().optional()
12775
+ });
12776
+ object({
12777
+ id: string(),
12778
+ userId: string(),
12779
+ name: string(),
12780
+ tokenHash: string(),
12781
+ tokenPrefix: string(),
12782
+ scopes: array(TokenScopeSchema),
12783
+ expiresAt: number().nullish(),
12784
+ lastUsedAt: number().nullish(),
12785
+ createdAt: number()
12786
+ });
12787
+ /** What a share-view grant lets its holder see. */
12788
+ var ShareViewGrantSchema = object({
12789
+ kind: _enum(SHARE_VIEW_KINDS),
12790
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
12791
+ /** Talk-back, opt-in at mint time; absent means off. */
12792
+ talk: boolean().optional()
12793
+ });
12794
+ var ShareViewScopeSchema = object({
12795
+ type: literal("share-view"),
12796
+ grant: ShareViewGrantSchema
12797
+ });
12798
+ var AddonRoutesScopeSchema = object({
12799
+ type: literal("addon-routes"),
12800
+ access: array(MethodAccessSchema).min(1)
12801
+ });
12802
+ var PreferencesSelfScopeSchema = object({ type: literal("preferences-self") });
12803
+ var CredentialScopeSchema = union([
12804
+ literal("*"),
12805
+ ShareViewScopeSchema,
12806
+ AddonRoutesScopeSchema,
12807
+ PreferencesSelfScopeSchema,
12808
+ TokenScopeSchema
12809
+ ]);
12810
+ object({
12811
+ kind: literal("credential"),
12812
+ sub: string().min(1),
12813
+ jti: string().min(16),
12814
+ scopes: array(CredentialScopeSchema).min(1)
12815
+ });
12816
+ var PreferenceNamespaceSchema = string().regex(/^[a-z][a-z0-9.-]{0,63}$/);
12817
+ /** A namespace's value: a JSON object, opaque to the hub. */
12818
+ var PreferenceValueSchema = record(string(), unknown());
12819
+ var PreferenceDeviceIdSchema = string().min(1).max(64);
12820
+ /** A stored row, as the owner reads it. */
12821
+ var PreferenceRowSchema = object({
12822
+ namespace: PreferenceNamespaceSchema,
12823
+ value: PreferenceValueSchema,
12824
+ /** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
12825
+ revision: number().int().positive(),
12826
+ updatedAt: number().int(),
12827
+ /** The client id the last writer sent; `null` when it sent none. */
12828
+ updatedByDevice: PreferenceDeviceIdSchema.nullable()
12829
+ });
12830
+ object({
12831
+ /** Absent: every namespace the caller holds. */
12832
+ namespaces: array(PreferenceNamespaceSchema).max(32).optional() });
12833
+ object({ rows: array(PreferenceRowSchema) });
12834
+ object({
12835
+ namespace: PreferenceNamespaceSchema,
12836
+ value: PreferenceValueSchema,
12837
+ /**
12838
+ * The revision the edit was based on. Absent: last write wins. `0`: the
12839
+ * namespace must not exist yet. Any other value that is not the current
12840
+ * revision answers `conflict` and writes nothing.
12841
+ */
12842
+ baseRevision: number().int().nonnegative().optional(),
12843
+ deviceId: PreferenceDeviceIdSchema.optional()
12844
+ });
12845
+ discriminatedUnion("status", [object({
12846
+ status: literal("saved"),
12847
+ row: PreferenceRowSchema
12848
+ }), object({
12849
+ status: literal("conflict"),
12850
+ current: PreferenceRowSchema.nullable()
12851
+ })]);
12852
+ object({ namespace: PreferenceNamespaceSchema });
12853
+ object({
12854
+ /** `false` when the namespace did not exist. */
12855
+ deleted: boolean() });
12856
+ object({
12857
+ /** The revision the client holds per namespace; a namespace it does not list is new to it. */
12858
+ revisionByNamespace: record(PreferenceNamespaceSchema, number().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
12859
+ object({
12860
+ /** Every row whose revision differs from the client's, and every row it did not list. */
12861
+ rows: array(PreferenceRowSchema),
12862
+ /** Namespaces the client listed that no longer exist. */
12863
+ deleted: array(PreferenceNamespaceSchema)
12864
+ });
12585
12865
  _enum(["new-session", "step-up"]);
12586
12866
  /** The languages the hub's app landing pages are written in (D858). */
12587
12867
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -39758,38 +40038,37 @@ method(LlmRuntimeCompleteInputSchema, LlmGenerateResultSchema, {
39758
40038
  auth: "admin",
39759
40039
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39760
40040
  });
40041
+ var LlmProfileKindSchema = string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "a kind id is lower-case letters, digits and dashes");
40042
+ /** What a model (or, by default, every model of a kind) can do. */
40043
+ var LlmModelFeaturesSchema = object({
40044
+ vision: boolean(),
40045
+ tools: boolean(),
40046
+ streaming: boolean()
40047
+ });
40048
+ /** One model a provider offers. `features` overrides the kind's defaults, per field. */
40049
+ var LlmModelInfoSchema = object({
40050
+ id: string(),
40051
+ label: string().optional(),
40052
+ contextLength: number().int().positive().optional(),
40053
+ features: LlmModelFeaturesSchema.partial().optional()
40054
+ });
39761
40055
  /**
39762
- * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
39763
- * methods concat-fan across providers; single-row methods route to ONE
39764
- * provider by the `addonId` in the call input (the notification-output
39765
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
39766
- * (hub-placed); the cap stays open for future providers.
39767
- *
39768
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
39769
- * `apiKey` is a password field — providers REDACT it on read and merge on
39770
- * write; a stored key NEVER round-trips to a client.
40056
+ * The provider-specific part of a profile, validated by the provider that owns
40057
+ * the kind (`upsertProfile` refuses what it does not accept). A field its
40058
+ * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
40059
+ * keychain, never in the row, and reads back as the redaction marker.
39771
40060
  */
39772
- var LlmProfileKindSchema = _enum([
39773
- "openai-compatible",
39774
- "openai",
39775
- "anthropic",
39776
- "google",
39777
- "managed-local",
39778
- "apple-foundation"
39779
- ]);
40061
+ var LlmProviderConfigSchema = record(string(), unknown());
39780
40062
  var LlmProfileSchema = object({
39781
40063
  id: string(),
39782
40064
  name: string(),
40065
+ /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
39783
40066
  kind: LlmProfileKindSchema,
39784
40067
  /** Stamped by the provider — keeps the fanned catalog routable. */
39785
40068
  addonId: string(),
39786
40069
  enabled: boolean(),
39787
40070
  /** Vendor model id, or the managed runtime's loaded model. */
39788
40071
  model: string(),
39789
- /** Required for openai-compatible; override for cloud kinds. */
39790
- baseUrl: string().optional(),
39791
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
39792
- apiKey: string().optional(),
39793
40072
  /** Vision on/off. A vision call against a `false` profile is REFUSED, never
39794
40073
  * degraded to text — that shipped once and produced a confident answer to a
39795
40074
  * question about a picture nobody sent. */
@@ -39797,15 +40076,11 @@ var LlmProfileSchema = object({
39797
40076
  temperature: number().min(0).max(2).optional(),
39798
40077
  /** Nucleus sampling. Every wire we speak has it. */
39799
40078
  topP: number().min(0).max(1).optional(),
39800
- /** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
39801
- * wire does, and the client drops it there (measured: the request body gets
39802
- * `top_p` and no `top_k`). The profile editor hides the field wherever it
39803
- * would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
40079
+ /** Top-k sampling. Carried only by the wires that have it — a kind offers the
40080
+ * field in its editor only when its descriptor lists it in `profileFields`. */
39804
40081
  topK: number().int().positive().optional(),
39805
40082
  maxTokens: number().int().positive().optional(),
39806
- /** Prompt context window. Advisory for cloud kinds (they enforce their own);
39807
- * for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
39808
- * the model with, so it is the one field that changes a PROCESS. */
40083
+ /** Prompt context window. Advisory for cloud kinds (they enforce their own). */
39809
40084
  contextLength: number().int().positive().optional(),
39810
40085
  /** Default system prompt. A caller's `system` REPLACES it (never appends —
39811
40086
  * two system prompts fighting is worse than either alone). */
@@ -39831,16 +40106,37 @@ var LlmProfileSchema = object({
39831
40106
  * library; the REGISTRY of callable tools is ours and is empty in v1, so a
39832
40107
  * `true` here buys the wiring, not behaviour, until tools are registered. */
39833
40108
  toolsEnabled: boolean().default(false),
39834
- extraHeaders: record(string(), string()).optional(),
39835
- /** kind === 'managed-local' only (spec §4). */
39836
- runtime: ManagedRuntimeConfigSchema.optional(),
39837
- /**
39838
- * kind === 'apple-foundation' only: WHERE it runs — the only thing there is
39839
- * to configure (no key, no URL, no download; `model` is `apple-system`).
39840
- * `supportsVision` on such a row is stamped by the provider from the node's
39841
- * reported `imageInput`, never taken from the operator (D62).
39842
- */
39843
- appleFoundation: object({ nodeId: string() }).optional()
40109
+ /** Everything the kind's provider owns (endpoint, key, node, runtime…). */
40110
+ providerConfig: LlmProviderConfigSchema.default({})
40111
+ });
40112
+ /**
40113
+ * The common profile fields a kind's editor offers. The editor owns how each
40114
+ * one is drawn; the provider says which of them mean something on its wire.
40115
+ */
40116
+ var LlmProfileFieldSchema = _enum([
40117
+ "temperature",
40118
+ "topP",
40119
+ "topK",
40120
+ "maxTokens",
40121
+ "contextLength",
40122
+ "systemPrompt",
40123
+ "timeoutMs",
40124
+ "connectTimeoutMs",
40125
+ "firstTokenTimeoutMs",
40126
+ "idleTimeoutMs",
40127
+ "retry",
40128
+ "toolsEnabled"
40129
+ ]);
40130
+ /**
40131
+ * A provider-drawn part of the editor, by a generic widget id the admin UI
40132
+ * registers (`ai/apple-node`). `placement: 'model'` replaces the generic model
40133
+ * picker: that widget owns the model choice.
40134
+ */
40135
+ var LlmProviderWidgetSchema = object({
40136
+ id: string(),
40137
+ placement: _enum(["connection", "model"]),
40138
+ /** `providerConfig` keys this widget must fill before the profile can be saved. */
40139
+ requires: array(string()).optional()
39844
40140
  });
39845
40141
  /** ConfigUISchema tree passed through untyped on the wire (the
39846
40142
  * notification-output `ConfigSchemaPassthrough` precedent at
@@ -39849,11 +40145,56 @@ var ConfigSchemaPassthrough$3 = unknown();
39849
40145
  var LlmProfileKindDescriptorSchema = object({
39850
40146
  kind: LlmProfileKindSchema,
39851
40147
  label: string(),
40148
+ /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
39852
40149
  icon: string(),
39853
40150
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
39854
40151
  addonId: string(),
39855
- configSchema: ConfigSchemaPassthrough$3
40152
+ /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
40153
+ connectionSchema: ConfigSchemaPassthrough$3,
40154
+ /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
40155
+ advancedSchema: ConfigSchemaPassthrough$3.optional(),
40156
+ /** The kind's defaults; a model from `listModels` may override any of them. */
40157
+ features: LlmModelFeaturesSchema,
40158
+ /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
40159
+ visionEditable: boolean(),
40160
+ /** Where the model list comes from: `listModels`, `staticModels`, or nowhere. */
40161
+ modelCatalog: _enum([
40162
+ "fetch",
40163
+ "static",
40164
+ "none"
40165
+ ]),
40166
+ staticModels: array(LlmModelInfoSchema).optional(),
40167
+ /** The common fields that mean something on this kind's wire. */
40168
+ profileFields: array(LlmProfileFieldSchema),
40169
+ providerWidgets: array(LlmProviderWidgetSchema).optional()
40170
+ });
40171
+ /**
40172
+ * `listModels` input. `connection` is an UNSAVED draft of `providerConfig`
40173
+ * (the editor's form); with `profileId` too, a secret the draft leaves
40174
+ * untouched (absent or the redaction marker) is resolved server-side from the
40175
+ * stored profile — the browser never receives it.
40176
+ */
40177
+ var LlmListModelsInputSchema = object({
40178
+ addonId: string(),
40179
+ kind: LlmProfileKindSchema,
40180
+ profileId: string().optional(),
40181
+ connection: LlmProviderConfigSchema.optional()
39856
40182
  });
40183
+ var LlmListModelsErrorCodeSchema = _enum([
40184
+ "auth",
40185
+ "network",
40186
+ "unsupported",
40187
+ "invalid"
40188
+ ]);
40189
+ /** A RESULT, never a throw: "wrong key" is an answer the editor renders inline. */
40190
+ var LlmListModelsResultSchema = discriminatedUnion("ok", [object({
40191
+ ok: literal(true),
40192
+ models: array(LlmModelInfoSchema)
40193
+ }), object({
40194
+ ok: literal(false),
40195
+ code: LlmListModelsErrorCodeSchema,
40196
+ message: string()
40197
+ })]);
39857
40198
  var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
39858
40199
  var LlmDefaultSchema = object({
39859
40200
  selector: LlmDefaultSelectorSchema,
@@ -39953,7 +40294,10 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
39953
40294
  kind: "mutation",
39954
40295
  auth: "admin",
39955
40296
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39956
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
40297
+ }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
40298
+ kind: "mutation",
40299
+ auth: "admin"
40300
+ }), method(object({}), array(LlmDefaultSchema)), method(object({
39957
40301
  selector: LlmDefaultSelectorSchema,
39958
40302
  profileId: string().nullable()
39959
40303
  }), _void(), {
@@ -44059,202 +44403,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
44059
44403
  auth: "admin"
44060
44404
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
44061
44405
  /**
44062
- * Zod schemas for persisted record types.
44063
- *
44064
- * These schemas serve as the single source of truth for types that are
44065
- * stored in the settings-store backend and retrieved via tRPC. They
44066
- * replace the manual TypeScript interfaces with schema-derived types,
44067
- * enabling runtime validation when reading from the backend.
44068
- *
44069
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
44070
- * keeps the original name for backward compatibility.
44071
- */
44072
- /**
44073
- * Auth model (v2 — 2026-05-12 caps-only):
44074
- *
44075
- * Two principals:
44076
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
44077
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
44078
- *
44079
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44080
- * `super_admin` — collapsed onto the single boolean because every
44081
- * non-admin caller is governed by the same scope-check rules; the
44082
- * distinction was only ever used to route role-specific procedures
44083
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44084
- * with `isAdmin: false` + an explicit scope list.
44085
- */
44086
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44087
- var MethodAccessSchema = _enum([
44088
- "view",
44089
- "create",
44090
- "delete"
44091
- ]);
44092
- /**
44093
- * A single scope grant. Three forms — checked in matcher with OR
44094
- * semantics; the first match decides whether the call passes:
44095
- *
44096
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44097
- * cap with the matching `scope` declaration. New caps inherit grants
44098
- * automatically — adding a device cap to the codebase makes it
44099
- * reachable to every user with `category:device [...]` without a
44100
- * re-grant. Use this for "family viewer" / "operator" tiers.
44101
- *
44102
- * - `addon` — every cap that ships inside a given addon id. Niche;
44103
- * useful when an integration needs to interact with one specific
44104
- * addon's surface regardless of how many caps it exports.
44105
- *
44106
- * - `capability` — the most precise form. Single cap name. Use for
44107
- * integration tokens where you want to grant `addons.installPackage`
44108
- * and nothing else.
44109
- *
44110
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44111
- * "give me everything" escape; there is no wildcard scope.
44112
- */
44113
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44114
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44115
- var CapScopeSchema = _enum(["device", "system"]);
44116
- /**
44117
- * DeviceSelector (scope model v3 — 2026-08-12).
44118
- *
44119
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44120
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44121
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44122
- * AFTER the grant was minted — no re-grant, no re-login.
44123
- *
44124
- * - `all` — every device in the deployment. The broad viewer/operator
44125
- * lever without a `category` grant (a `category` grant also covers device
44126
- * caps that carry no deviceId; `all` is specifically the device set).
44127
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44128
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44129
- * is NOT covered until the grant is edited.
44130
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44131
- * DYNAMIC. A device that changes type, or a new device of the type,
44132
- * re-resolves on the next request.
44133
- * - `locations` — every device whose operator-assigned `location` label is
44134
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44135
- * null/unset location matches NO `locations` selector.
44136
- */
44137
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44138
- object({ kind: literal("all") }),
44139
- object({
44140
- kind: literal("ids"),
44141
- ids: array(number().int()).min(1)
44142
- }),
44143
- object({
44144
- kind: literal("types"),
44145
- types: array(_enum(DeviceType)).min(1)
44146
- }),
44147
- object({
44148
- kind: literal("locations"),
44149
- locations: array(string().min(1)).min(1)
44150
- })
44151
- ]);
44152
- var DeviceTokenScopeSchema = object({
44153
- type: literal("device"),
44154
- /** The device SET this grant covers — resolved against the live fleet. */
44155
- selector: DeviceSelectorSchema,
44156
- access: array(MethodAccessSchema).min(1),
44157
- /**
44158
- * Whether a grant on a PARENT device transparently covers its accessory
44159
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44160
- * Direction is parent → children ONLY.
44161
- *
44162
- * Absent → the matcher DERIVES it from the access flavour: `view`
44163
- * inherits (a camera viewer sees the camera's accessories), `create` /
44164
- * `delete` do NOT (actuating/removing a child is an explicit act the
44165
- * operator must grant on the child, not inherit from the parent). Set it
44166
- * explicitly to override that default per grant.
44167
- */
44168
- includeLinked: boolean().optional()
44169
- });
44170
- /**
44171
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44172
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44173
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44174
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44175
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44176
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44177
- * migration cannot reach a JWT already in a client's hands; parse-time
44178
- * migration covers both without a flag day. No cast — the raw object is read
44179
- * through `Reflect.get` (its static type is `unknown`).
44180
- */
44181
- function migrateLegacyTokenScope(raw) {
44182
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44183
- if (Reflect.get(raw, "type") !== "device") return raw;
44184
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44185
- const targets = Reflect.get(raw, "targets");
44186
- if (!Array.isArray(targets)) return raw;
44187
- return {
44188
- type: "device",
44189
- selector: {
44190
- kind: "ids",
44191
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44192
- },
44193
- access: Reflect.get(raw, "access")
44194
- };
44195
- }
44196
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44197
- object({
44198
- type: literal("category"),
44199
- target: CapScopeSchema,
44200
- access: array(MethodAccessSchema).min(1)
44201
- }),
44202
- object({
44203
- type: literal("capability"),
44204
- target: string(),
44205
- access: array(MethodAccessSchema).min(1)
44206
- }),
44207
- object({
44208
- type: literal("addon"),
44209
- target: string(),
44210
- access: array(MethodAccessSchema).min(1)
44211
- }),
44212
- DeviceTokenScopeSchema
44213
- ]));
44214
- object({
44215
- id: string(),
44216
- username: string(),
44217
- passwordHash: string(),
44218
- /**
44219
- * Admin bypass. When true, the middleware skips the scope-access
44220
- * check entirely. There is no other axis of privilege; the legacy
44221
- * role enum collapsed onto this boolean in v2.
44222
- */
44223
- isAdmin: boolean().default(false),
44224
- allowedProviders: AllowedProviderSchema,
44225
- allowedDevices: AllowedDevicesSchema,
44226
- /**
44227
- * Scopes granted to this user. Admins bypass; their `scopes` is
44228
- * ignored. Non-admins without scopes are locked out of every
44229
- * protected call.
44230
- */
44231
- scopes: array(TokenScopeSchema).default([]),
44232
- createdAt: number(),
44233
- updatedAt: number()
44234
- });
44235
- object({
44236
- id: string(),
44237
- label: string(),
44238
- isAdmin: boolean().default(false),
44239
- allowedProviders: AllowedProviderSchema,
44240
- allowedDevices: AllowedDevicesSchema,
44241
- tokenHash: string(),
44242
- tokenPrefix: string(),
44243
- createdAt: number(),
44244
- lastUsedAt: number().optional()
44245
- });
44246
- object({
44247
- id: string(),
44248
- userId: string(),
44249
- name: string(),
44250
- tokenHash: string(),
44251
- tokenPrefix: string(),
44252
- scopes: array(TokenScopeSchema),
44253
- expiresAt: number().nullish(),
44254
- lastUsedAt: number().nullish(),
44255
- createdAt: number()
44256
- });
44257
- /**
44258
44406
  * `oauth-integration` — a collection cap by which an addon declares
44259
44407
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44260
44408
  * Each provider returns a static descriptor; the core enumerates them
@@ -64149,26 +64297,6 @@ var ApiKeySummarySchema = object({
64149
64297
  createdAt: number(),
64150
64298
  lastUsedAt: number().optional()
64151
64299
  });
64152
- var ScopedTokenSummarySchema = object({
64153
- id: string(),
64154
- userId: string(),
64155
- name: string(),
64156
- tokenPrefix: string(),
64157
- scopes: array(TokenScopeSchema),
64158
- expiresAt: number().nullish(),
64159
- lastUsedAt: number().nullish(),
64160
- createdAt: number()
64161
- });
64162
- var CreateScopedTokenInputSchema = object({
64163
- userId: string(),
64164
- name: string(),
64165
- scopes: array(TokenScopeSchema),
64166
- expiresAt: number().optional()
64167
- });
64168
- var CreateScopedTokenResultSchema = object({
64169
- token: string(),
64170
- record: ScopedTokenSummarySchema
64171
- });
64172
64300
  var OauthSessionSummarySchema = object({
64173
64301
  id: string(),
64174
64302
  userId: string(),
@@ -64190,11 +64318,11 @@ var TotpStatusSchema = object({
64190
64318
  confirmedAt: number().nullable()
64191
64319
  });
64192
64320
  /**
64193
- * user-management — singleton capability for user accounts, API keys,
64194
- * and scoped tokens.
64321
+ * user-management — singleton capability for user accounts and the
64322
+ * legacy API-key rows.
64195
64323
  *
64196
64324
  * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
64197
- * — the subset check on `setUserScopes` / `createScopedToken` is moot
64325
+ * — the subset check on `setUserScopes` is moot
64198
64326
  * because non-admins never reach these. If/when we open non-admin
64199
64327
  * delegation, structural caller-scope subset check goes inside the
64200
64328
  * provider.
@@ -64251,15 +64379,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
64251
64379
  kind: "mutation",
64252
64380
  auth: "admin",
64253
64381
  access: "delete"
64254
- }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
64255
- kind: "mutation",
64256
- auth: "admin",
64257
- access: "create"
64258
- }), method(object({ id: string() }), object({ success: literal(true) }), {
64259
- kind: "mutation",
64260
- auth: "admin",
64261
- access: "delete"
64262
- }), method(object({ token: string() }), ScopedTokenSummarySchema.nullable(), { access: "view" }), method(object({ userId: string() }), array(ScopedTokenSummarySchema), { auth: "admin" }), method(object({ userId: string() }), TotpSetupResultSchema, {
64382
+ }), method(object({ userId: string() }), TotpSetupResultSchema, {
64263
64383
  kind: "mutation",
64264
64384
  auth: "admin",
64265
64385
  access: "create"
@@ -70349,7 +70469,7 @@ Object.freeze({
70349
70469
  capName: "llm",
70350
70470
  capScope: "system",
70351
70471
  addonId: null,
70352
- access: "view"
70472
+ access: "create"
70353
70473
  },
70354
70474
  "llm.listNodeModels": {
70355
70475
  capName: "llm",
@@ -75013,12 +75133,6 @@ Object.freeze({
75013
75133
  addonId: null,
75014
75134
  access: "create"
75015
75135
  },
75016
- "userManagement.createScopedToken": {
75017
- capName: "user-management",
75018
- capScope: "system",
75019
- addonId: null,
75020
- access: "create"
75021
- },
75022
75136
  "userManagement.createUser": {
75023
75137
  capName: "user-management",
75024
75138
  capScope: "system",
@@ -75067,12 +75181,6 @@ Object.freeze({
75067
75181
  addonId: null,
75068
75182
  access: "view"
75069
75183
  },
75070
- "userManagement.listScopedTokens": {
75071
- capName: "user-management",
75072
- capScope: "system",
75073
- addonId: null,
75074
- access: "view"
75075
- },
75076
75184
  "userManagement.listUsers": {
75077
75185
  capName: "user-management",
75078
75186
  capScope: "system",
@@ -75127,12 +75235,6 @@ Object.freeze({
75127
75235
  addonId: null,
75128
75236
  access: "delete"
75129
75237
  },
75130
- "userManagement.revokeScopedToken": {
75131
- capName: "user-management",
75132
- capScope: "system",
75133
- addonId: null,
75134
- access: "delete"
75135
- },
75136
75238
  "userManagement.setupTotp": {
75137
75239
  capName: "user-management",
75138
75240
  capScope: "system",
@@ -75163,12 +75265,6 @@ Object.freeze({
75163
75265
  addonId: null,
75164
75266
  access: "view"
75165
75267
  },
75166
- "userManagement.validateScopedToken": {
75167
- capName: "user-management",
75168
- capScope: "system",
75169
- addonId: null,
75170
- access: "view"
75171
- },
75172
75268
  "userManagement.verifyTotp": {
75173
75269
  capName: "user-management",
75174
75270
  capScope: "system",