@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.js CHANGED
@@ -5438,7 +5438,7 @@ var ZodIssueCode = {
5438
5438
  var ZodFirstPartyTypeKind;
5439
5439
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5440
5440
  //#endregion
5441
- //#region ../types/dist/sleep-BxjU_fJM.mjs
5441
+ //#region ../types/dist/sleep-yKL5gfrH.mjs
5442
5442
  /**
5443
5443
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5444
5444
  * window to float samples (D455).
@@ -7820,6 +7820,12 @@ function normalizeAddonInitResult(result) {
7820
7820
  if (Array.isArray(result)) return { providers: result };
7821
7821
  return result;
7822
7822
  }
7823
+ /**
7824
+ * The share-view scope kinds a share-link token can carry. The hub mints
7825
+ * and validates them (`ShareViewGrantSchema` builds its
7826
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
7827
+ */
7828
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7823
7829
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7824
7830
  var PeerBytesTicketSchema = object({
7825
7831
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12606,6 +12612,280 @@ var ConvertResultSchema = object({
12606
12612
  files: array(string()).readonly()
12607
12613
  })).readonly()
12608
12614
  });
12615
+ /**
12616
+ * Zod schemas for persisted record types.
12617
+ *
12618
+ * These schemas serve as the single source of truth for types that are
12619
+ * stored in the settings-store backend and retrieved via tRPC. They
12620
+ * replace the manual TypeScript interfaces with schema-derived types,
12621
+ * enabling runtime validation when reading from the backend.
12622
+ *
12623
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12624
+ * keeps the original name for backward compatibility.
12625
+ */
12626
+ /**
12627
+ * Auth model (v2 — 2026-05-12 caps-only):
12628
+ *
12629
+ * Two principals:
12630
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12631
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12632
+ *
12633
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12634
+ * `super_admin` — collapsed onto the single boolean because every
12635
+ * non-admin caller is governed by the same scope-check rules; the
12636
+ * distinction was only ever used to route role-specific procedures
12637
+ * which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
12638
+ * with `isAdmin: false` + an explicit scope list.
12639
+ */
12640
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12641
+ var MethodAccessSchema = _enum([
12642
+ "view",
12643
+ "create",
12644
+ "delete"
12645
+ ]);
12646
+ /**
12647
+ * A single scope grant. Three forms — checked in matcher with OR
12648
+ * semantics; the first match decides whether the call passes:
12649
+ *
12650
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12651
+ * cap with the matching `scope` declaration. New caps inherit grants
12652
+ * automatically — adding a device cap to the codebase makes it
12653
+ * reachable to every user with `category:device [...]` without a
12654
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12655
+ *
12656
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12657
+ * useful when an integration needs to interact with one specific
12658
+ * addon's surface regardless of how many caps it exports.
12659
+ *
12660
+ * - `capability` — the most precise form. Single cap name. Use for
12661
+ * integration tokens where you want to grant `addons.installPackage`
12662
+ * and nothing else.
12663
+ *
12664
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12665
+ * "give me everything" escape; there is no wildcard scope.
12666
+ */
12667
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12668
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12669
+ var CapScopeSchema = _enum(["device", "system"]);
12670
+ /**
12671
+ * DeviceSelector (scope model v3 — 2026-08-12).
12672
+ *
12673
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12674
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12675
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12676
+ * AFTER the grant was minted — no re-grant, no re-login.
12677
+ *
12678
+ * - `all` — every device in the deployment. The broad viewer/operator
12679
+ * lever without a `category` grant (a `category` grant also covers device
12680
+ * caps that carry no deviceId; `all` is specifically the device set).
12681
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
12682
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
12683
+ * is NOT covered until the grant is edited.
12684
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
12685
+ * DYNAMIC. A device that changes type, or a new device of the type,
12686
+ * re-resolves on the next request.
12687
+ * - `locations` — every device whose operator-assigned `location` label is
12688
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
12689
+ * null/unset location matches NO `locations` selector.
12690
+ */
12691
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
12692
+ object({ kind: literal("all") }),
12693
+ object({
12694
+ kind: literal("ids"),
12695
+ ids: array(number().int()).min(1)
12696
+ }),
12697
+ object({
12698
+ kind: literal("types"),
12699
+ types: array(_enum(DeviceType)).min(1)
12700
+ }),
12701
+ object({
12702
+ kind: literal("locations"),
12703
+ locations: array(string().min(1)).min(1)
12704
+ })
12705
+ ]);
12706
+ var DeviceTokenScopeSchema = object({
12707
+ type: literal("device"),
12708
+ /** The device SET this grant covers — resolved against the live fleet. */
12709
+ selector: DeviceSelectorSchema,
12710
+ access: array(MethodAccessSchema).min(1),
12711
+ /**
12712
+ * Whether a grant on a PARENT device transparently covers its accessory
12713
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
12714
+ * Direction is parent → children ONLY.
12715
+ *
12716
+ * Absent → the matcher DERIVES it from the access flavour: `view`
12717
+ * inherits (a camera viewer sees the camera's accessories), `create` /
12718
+ * `delete` do NOT (actuating/removing a child is an explicit act the
12719
+ * operator must grant on the child, not inherit from the parent). Set it
12720
+ * explicitly to override that default per grant.
12721
+ */
12722
+ includeLinked: boolean().optional()
12723
+ });
12724
+ /**
12725
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
12726
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
12727
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
12728
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
12729
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
12730
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
12731
+ * migration cannot reach a JWT already in a client's hands; parse-time
12732
+ * migration covers both without a flag day. No cast — the raw object is read
12733
+ * through `Reflect.get` (its static type is `unknown`).
12734
+ */
12735
+ function migrateLegacyTokenScope(raw) {
12736
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
12737
+ if (Reflect.get(raw, "type") !== "device") return raw;
12738
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
12739
+ const targets = Reflect.get(raw, "targets");
12740
+ if (!Array.isArray(targets)) return raw;
12741
+ return {
12742
+ type: "device",
12743
+ selector: {
12744
+ kind: "ids",
12745
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
12746
+ },
12747
+ access: Reflect.get(raw, "access")
12748
+ };
12749
+ }
12750
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
12751
+ object({
12752
+ type: literal("category"),
12753
+ target: CapScopeSchema,
12754
+ access: array(MethodAccessSchema).min(1)
12755
+ }),
12756
+ object({
12757
+ type: literal("capability"),
12758
+ target: string(),
12759
+ access: array(MethodAccessSchema).min(1)
12760
+ }),
12761
+ object({
12762
+ type: literal("addon"),
12763
+ target: string(),
12764
+ access: array(MethodAccessSchema).min(1)
12765
+ }),
12766
+ DeviceTokenScopeSchema
12767
+ ]));
12768
+ object({
12769
+ id: string(),
12770
+ username: string(),
12771
+ passwordHash: string(),
12772
+ /**
12773
+ * Admin bypass. When true, the middleware skips the scope-access
12774
+ * check entirely. There is no other axis of privilege; the legacy
12775
+ * role enum collapsed onto this boolean in v2.
12776
+ */
12777
+ isAdmin: boolean().default(false),
12778
+ allowedProviders: AllowedProviderSchema,
12779
+ allowedDevices: AllowedDevicesSchema,
12780
+ /**
12781
+ * Scopes granted to this user. Admins bypass; their `scopes` is
12782
+ * ignored. Non-admins without scopes are locked out of every
12783
+ * protected call.
12784
+ */
12785
+ scopes: array(TokenScopeSchema).default([]),
12786
+ createdAt: number(),
12787
+ updatedAt: number()
12788
+ });
12789
+ object({
12790
+ id: string(),
12791
+ label: string(),
12792
+ isAdmin: boolean().default(false),
12793
+ allowedProviders: AllowedProviderSchema,
12794
+ allowedDevices: AllowedDevicesSchema,
12795
+ tokenHash: string(),
12796
+ tokenPrefix: string(),
12797
+ createdAt: number(),
12798
+ lastUsedAt: number().optional()
12799
+ });
12800
+ object({
12801
+ id: string(),
12802
+ userId: string(),
12803
+ name: string(),
12804
+ tokenHash: string(),
12805
+ tokenPrefix: string(),
12806
+ scopes: array(TokenScopeSchema),
12807
+ expiresAt: number().nullish(),
12808
+ lastUsedAt: number().nullish(),
12809
+ createdAt: number()
12810
+ });
12811
+ /** What a share-view grant lets its holder see. */
12812
+ var ShareViewGrantSchema = object({
12813
+ kind: _enum(SHARE_VIEW_KINDS),
12814
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
12815
+ /** Talk-back, opt-in at mint time; absent means off. */
12816
+ talk: boolean().optional()
12817
+ });
12818
+ var ShareViewScopeSchema = object({
12819
+ type: literal("share-view"),
12820
+ grant: ShareViewGrantSchema
12821
+ });
12822
+ var AddonRoutesScopeSchema = object({
12823
+ type: literal("addon-routes"),
12824
+ access: array(MethodAccessSchema).min(1)
12825
+ });
12826
+ var PreferencesSelfScopeSchema = object({ type: literal("preferences-self") });
12827
+ var CredentialScopeSchema = union([
12828
+ literal("*"),
12829
+ ShareViewScopeSchema,
12830
+ AddonRoutesScopeSchema,
12831
+ PreferencesSelfScopeSchema,
12832
+ TokenScopeSchema
12833
+ ]);
12834
+ object({
12835
+ kind: literal("credential"),
12836
+ sub: string().min(1),
12837
+ jti: string().min(16),
12838
+ scopes: array(CredentialScopeSchema).min(1)
12839
+ });
12840
+ var PreferenceNamespaceSchema = string().regex(/^[a-z][a-z0-9.-]{0,63}$/);
12841
+ /** A namespace's value: a JSON object, opaque to the hub. */
12842
+ var PreferenceValueSchema = record(string(), unknown());
12843
+ var PreferenceDeviceIdSchema = string().min(1).max(64);
12844
+ /** A stored row, as the owner reads it. */
12845
+ var PreferenceRowSchema = object({
12846
+ namespace: PreferenceNamespaceSchema,
12847
+ value: PreferenceValueSchema,
12848
+ /** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
12849
+ revision: number().int().positive(),
12850
+ updatedAt: number().int(),
12851
+ /** The client id the last writer sent; `null` when it sent none. */
12852
+ updatedByDevice: PreferenceDeviceIdSchema.nullable()
12853
+ });
12854
+ object({
12855
+ /** Absent: every namespace the caller holds. */
12856
+ namespaces: array(PreferenceNamespaceSchema).max(32).optional() });
12857
+ object({ rows: array(PreferenceRowSchema) });
12858
+ object({
12859
+ namespace: PreferenceNamespaceSchema,
12860
+ value: PreferenceValueSchema,
12861
+ /**
12862
+ * The revision the edit was based on. Absent: last write wins. `0`: the
12863
+ * namespace must not exist yet. Any other value that is not the current
12864
+ * revision answers `conflict` and writes nothing.
12865
+ */
12866
+ baseRevision: number().int().nonnegative().optional(),
12867
+ deviceId: PreferenceDeviceIdSchema.optional()
12868
+ });
12869
+ discriminatedUnion("status", [object({
12870
+ status: literal("saved"),
12871
+ row: PreferenceRowSchema
12872
+ }), object({
12873
+ status: literal("conflict"),
12874
+ current: PreferenceRowSchema.nullable()
12875
+ })]);
12876
+ object({ namespace: PreferenceNamespaceSchema });
12877
+ object({
12878
+ /** `false` when the namespace did not exist. */
12879
+ deleted: boolean() });
12880
+ object({
12881
+ /** The revision the client holds per namespace; a namespace it does not list is new to it. */
12882
+ revisionByNamespace: record(PreferenceNamespaceSchema, number().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
12883
+ object({
12884
+ /** Every row whose revision differs from the client's, and every row it did not list. */
12885
+ rows: array(PreferenceRowSchema),
12886
+ /** Namespaces the client listed that no longer exist. */
12887
+ deleted: array(PreferenceNamespaceSchema)
12888
+ });
12609
12889
  _enum(["new-session", "step-up"]);
12610
12890
  /** The languages the hub's app landing pages are written in (D858). */
12611
12891
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -39782,38 +40062,37 @@ method(LlmRuntimeCompleteInputSchema, LlmGenerateResultSchema, {
39782
40062
  auth: "admin",
39783
40063
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39784
40064
  });
40065
+ var LlmProfileKindSchema = string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "a kind id is lower-case letters, digits and dashes");
40066
+ /** What a model (or, by default, every model of a kind) can do. */
40067
+ var LlmModelFeaturesSchema = object({
40068
+ vision: boolean(),
40069
+ tools: boolean(),
40070
+ streaming: boolean()
40071
+ });
40072
+ /** One model a provider offers. `features` overrides the kind's defaults, per field. */
40073
+ var LlmModelInfoSchema = object({
40074
+ id: string(),
40075
+ label: string().optional(),
40076
+ contextLength: number().int().positive().optional(),
40077
+ features: LlmModelFeaturesSchema.partial().optional()
40078
+ });
39785
40079
  /**
39786
- * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
39787
- * methods concat-fan across providers; single-row methods route to ONE
39788
- * provider by the `addonId` in the call input (the notification-output
39789
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
39790
- * (hub-placed); the cap stays open for future providers.
39791
- *
39792
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
39793
- * `apiKey` is a password field — providers REDACT it on read and merge on
39794
- * write; a stored key NEVER round-trips to a client.
40080
+ * The provider-specific part of a profile, validated by the provider that owns
40081
+ * the kind (`upsertProfile` refuses what it does not accept). A field its
40082
+ * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
40083
+ * keychain, never in the row, and reads back as the redaction marker.
39795
40084
  */
39796
- var LlmProfileKindSchema = _enum([
39797
- "openai-compatible",
39798
- "openai",
39799
- "anthropic",
39800
- "google",
39801
- "managed-local",
39802
- "apple-foundation"
39803
- ]);
40085
+ var LlmProviderConfigSchema = record(string(), unknown());
39804
40086
  var LlmProfileSchema = object({
39805
40087
  id: string(),
39806
40088
  name: string(),
40089
+ /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
39807
40090
  kind: LlmProfileKindSchema,
39808
40091
  /** Stamped by the provider — keeps the fanned catalog routable. */
39809
40092
  addonId: string(),
39810
40093
  enabled: boolean(),
39811
40094
  /** Vendor model id, or the managed runtime's loaded model. */
39812
40095
  model: string(),
39813
- /** Required for openai-compatible; override for cloud kinds. */
39814
- baseUrl: string().optional(),
39815
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
39816
- apiKey: string().optional(),
39817
40096
  /** Vision on/off. A vision call against a `false` profile is REFUSED, never
39818
40097
  * degraded to text — that shipped once and produced a confident answer to a
39819
40098
  * question about a picture nobody sent. */
@@ -39821,15 +40100,11 @@ var LlmProfileSchema = object({
39821
40100
  temperature: number().min(0).max(2).optional(),
39822
40101
  /** Nucleus sampling. Every wire we speak has it. */
39823
40102
  topP: number().min(0).max(1).optional(),
39824
- /** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
39825
- * wire does, and the client drops it there (measured: the request body gets
39826
- * `top_p` and no `top_k`). The profile editor hides the field wherever it
39827
- * would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
40103
+ /** Top-k sampling. Carried only by the wires that have it — a kind offers the
40104
+ * field in its editor only when its descriptor lists it in `profileFields`. */
39828
40105
  topK: number().int().positive().optional(),
39829
40106
  maxTokens: number().int().positive().optional(),
39830
- /** Prompt context window. Advisory for cloud kinds (they enforce their own);
39831
- * for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
39832
- * the model with, so it is the one field that changes a PROCESS. */
40107
+ /** Prompt context window. Advisory for cloud kinds (they enforce their own). */
39833
40108
  contextLength: number().int().positive().optional(),
39834
40109
  /** Default system prompt. A caller's `system` REPLACES it (never appends —
39835
40110
  * two system prompts fighting is worse than either alone). */
@@ -39855,16 +40130,37 @@ var LlmProfileSchema = object({
39855
40130
  * library; the REGISTRY of callable tools is ours and is empty in v1, so a
39856
40131
  * `true` here buys the wiring, not behaviour, until tools are registered. */
39857
40132
  toolsEnabled: boolean().default(false),
39858
- extraHeaders: record(string(), string()).optional(),
39859
- /** kind === 'managed-local' only (spec §4). */
39860
- runtime: ManagedRuntimeConfigSchema.optional(),
39861
- /**
39862
- * kind === 'apple-foundation' only: WHERE it runs — the only thing there is
39863
- * to configure (no key, no URL, no download; `model` is `apple-system`).
39864
- * `supportsVision` on such a row is stamped by the provider from the node's
39865
- * reported `imageInput`, never taken from the operator (D62).
39866
- */
39867
- appleFoundation: object({ nodeId: string() }).optional()
40133
+ /** Everything the kind's provider owns (endpoint, key, node, runtime…). */
40134
+ providerConfig: LlmProviderConfigSchema.default({})
40135
+ });
40136
+ /**
40137
+ * The common profile fields a kind's editor offers. The editor owns how each
40138
+ * one is drawn; the provider says which of them mean something on its wire.
40139
+ */
40140
+ var LlmProfileFieldSchema = _enum([
40141
+ "temperature",
40142
+ "topP",
40143
+ "topK",
40144
+ "maxTokens",
40145
+ "contextLength",
40146
+ "systemPrompt",
40147
+ "timeoutMs",
40148
+ "connectTimeoutMs",
40149
+ "firstTokenTimeoutMs",
40150
+ "idleTimeoutMs",
40151
+ "retry",
40152
+ "toolsEnabled"
40153
+ ]);
40154
+ /**
40155
+ * A provider-drawn part of the editor, by a generic widget id the admin UI
40156
+ * registers (`ai/apple-node`). `placement: 'model'` replaces the generic model
40157
+ * picker: that widget owns the model choice.
40158
+ */
40159
+ var LlmProviderWidgetSchema = object({
40160
+ id: string(),
40161
+ placement: _enum(["connection", "model"]),
40162
+ /** `providerConfig` keys this widget must fill before the profile can be saved. */
40163
+ requires: array(string()).optional()
39868
40164
  });
39869
40165
  /** ConfigUISchema tree passed through untyped on the wire (the
39870
40166
  * notification-output `ConfigSchemaPassthrough` precedent at
@@ -39873,11 +40169,56 @@ var ConfigSchemaPassthrough$3 = unknown();
39873
40169
  var LlmProfileKindDescriptorSchema = object({
39874
40170
  kind: LlmProfileKindSchema,
39875
40171
  label: string(),
40172
+ /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
39876
40173
  icon: string(),
39877
40174
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
39878
40175
  addonId: string(),
39879
- configSchema: ConfigSchemaPassthrough$3
40176
+ /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
40177
+ connectionSchema: ConfigSchemaPassthrough$3,
40178
+ /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
40179
+ advancedSchema: ConfigSchemaPassthrough$3.optional(),
40180
+ /** The kind's defaults; a model from `listModels` may override any of them. */
40181
+ features: LlmModelFeaturesSchema,
40182
+ /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
40183
+ visionEditable: boolean(),
40184
+ /** Where the model list comes from: `listModels`, `staticModels`, or nowhere. */
40185
+ modelCatalog: _enum([
40186
+ "fetch",
40187
+ "static",
40188
+ "none"
40189
+ ]),
40190
+ staticModels: array(LlmModelInfoSchema).optional(),
40191
+ /** The common fields that mean something on this kind's wire. */
40192
+ profileFields: array(LlmProfileFieldSchema),
40193
+ providerWidgets: array(LlmProviderWidgetSchema).optional()
40194
+ });
40195
+ /**
40196
+ * `listModels` input. `connection` is an UNSAVED draft of `providerConfig`
40197
+ * (the editor's form); with `profileId` too, a secret the draft leaves
40198
+ * untouched (absent or the redaction marker) is resolved server-side from the
40199
+ * stored profile — the browser never receives it.
40200
+ */
40201
+ var LlmListModelsInputSchema = object({
40202
+ addonId: string(),
40203
+ kind: LlmProfileKindSchema,
40204
+ profileId: string().optional(),
40205
+ connection: LlmProviderConfigSchema.optional()
39880
40206
  });
40207
+ var LlmListModelsErrorCodeSchema = _enum([
40208
+ "auth",
40209
+ "network",
40210
+ "unsupported",
40211
+ "invalid"
40212
+ ]);
40213
+ /** A RESULT, never a throw: "wrong key" is an answer the editor renders inline. */
40214
+ var LlmListModelsResultSchema = discriminatedUnion("ok", [object({
40215
+ ok: literal(true),
40216
+ models: array(LlmModelInfoSchema)
40217
+ }), object({
40218
+ ok: literal(false),
40219
+ code: LlmListModelsErrorCodeSchema,
40220
+ message: string()
40221
+ })]);
39881
40222
  var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
39882
40223
  var LlmDefaultSchema = object({
39883
40224
  selector: LlmDefaultSelectorSchema,
@@ -39977,7 +40318,10 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
39977
40318
  kind: "mutation",
39978
40319
  auth: "admin",
39979
40320
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39980
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
40321
+ }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
40322
+ kind: "mutation",
40323
+ auth: "admin"
40324
+ }), method(object({}), array(LlmDefaultSchema)), method(object({
39981
40325
  selector: LlmDefaultSelectorSchema,
39982
40326
  profileId: string().nullable()
39983
40327
  }), _void(), {
@@ -44083,202 +44427,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
44083
44427
  auth: "admin"
44084
44428
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
44085
44429
  /**
44086
- * Zod schemas for persisted record types.
44087
- *
44088
- * These schemas serve as the single source of truth for types that are
44089
- * stored in the settings-store backend and retrieved via tRPC. They
44090
- * replace the manual TypeScript interfaces with schema-derived types,
44091
- * enabling runtime validation when reading from the backend.
44092
- *
44093
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
44094
- * keeps the original name for backward compatibility.
44095
- */
44096
- /**
44097
- * Auth model (v2 — 2026-05-12 caps-only):
44098
- *
44099
- * Two principals:
44100
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
44101
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
44102
- *
44103
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44104
- * `super_admin` — collapsed onto the single boolean because every
44105
- * non-admin caller is governed by the same scope-check rules; the
44106
- * distinction was only ever used to route role-specific procedures
44107
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44108
- * with `isAdmin: false` + an explicit scope list.
44109
- */
44110
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44111
- var MethodAccessSchema = _enum([
44112
- "view",
44113
- "create",
44114
- "delete"
44115
- ]);
44116
- /**
44117
- * A single scope grant. Three forms — checked in matcher with OR
44118
- * semantics; the first match decides whether the call passes:
44119
- *
44120
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44121
- * cap with the matching `scope` declaration. New caps inherit grants
44122
- * automatically — adding a device cap to the codebase makes it
44123
- * reachable to every user with `category:device [...]` without a
44124
- * re-grant. Use this for "family viewer" / "operator" tiers.
44125
- *
44126
- * - `addon` — every cap that ships inside a given addon id. Niche;
44127
- * useful when an integration needs to interact with one specific
44128
- * addon's surface regardless of how many caps it exports.
44129
- *
44130
- * - `capability` — the most precise form. Single cap name. Use for
44131
- * integration tokens where you want to grant `addons.installPackage`
44132
- * and nothing else.
44133
- *
44134
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44135
- * "give me everything" escape; there is no wildcard scope.
44136
- */
44137
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44138
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44139
- var CapScopeSchema = _enum(["device", "system"]);
44140
- /**
44141
- * DeviceSelector (scope model v3 — 2026-08-12).
44142
- *
44143
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44144
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44145
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44146
- * AFTER the grant was minted — no re-grant, no re-login.
44147
- *
44148
- * - `all` — every device in the deployment. The broad viewer/operator
44149
- * lever without a `category` grant (a `category` grant also covers device
44150
- * caps that carry no deviceId; `all` is specifically the device set).
44151
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44152
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44153
- * is NOT covered until the grant is edited.
44154
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44155
- * DYNAMIC. A device that changes type, or a new device of the type,
44156
- * re-resolves on the next request.
44157
- * - `locations` — every device whose operator-assigned `location` label is
44158
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44159
- * null/unset location matches NO `locations` selector.
44160
- */
44161
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44162
- object({ kind: literal("all") }),
44163
- object({
44164
- kind: literal("ids"),
44165
- ids: array(number().int()).min(1)
44166
- }),
44167
- object({
44168
- kind: literal("types"),
44169
- types: array(_enum(DeviceType)).min(1)
44170
- }),
44171
- object({
44172
- kind: literal("locations"),
44173
- locations: array(string().min(1)).min(1)
44174
- })
44175
- ]);
44176
- var DeviceTokenScopeSchema = object({
44177
- type: literal("device"),
44178
- /** The device SET this grant covers — resolved against the live fleet. */
44179
- selector: DeviceSelectorSchema,
44180
- access: array(MethodAccessSchema).min(1),
44181
- /**
44182
- * Whether a grant on a PARENT device transparently covers its accessory
44183
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44184
- * Direction is parent → children ONLY.
44185
- *
44186
- * Absent → the matcher DERIVES it from the access flavour: `view`
44187
- * inherits (a camera viewer sees the camera's accessories), `create` /
44188
- * `delete` do NOT (actuating/removing a child is an explicit act the
44189
- * operator must grant on the child, not inherit from the parent). Set it
44190
- * explicitly to override that default per grant.
44191
- */
44192
- includeLinked: boolean().optional()
44193
- });
44194
- /**
44195
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44196
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44197
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44198
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44199
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44200
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44201
- * migration cannot reach a JWT already in a client's hands; parse-time
44202
- * migration covers both without a flag day. No cast — the raw object is read
44203
- * through `Reflect.get` (its static type is `unknown`).
44204
- */
44205
- function migrateLegacyTokenScope(raw) {
44206
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44207
- if (Reflect.get(raw, "type") !== "device") return raw;
44208
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44209
- const targets = Reflect.get(raw, "targets");
44210
- if (!Array.isArray(targets)) return raw;
44211
- return {
44212
- type: "device",
44213
- selector: {
44214
- kind: "ids",
44215
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44216
- },
44217
- access: Reflect.get(raw, "access")
44218
- };
44219
- }
44220
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44221
- object({
44222
- type: literal("category"),
44223
- target: CapScopeSchema,
44224
- access: array(MethodAccessSchema).min(1)
44225
- }),
44226
- object({
44227
- type: literal("capability"),
44228
- target: string(),
44229
- access: array(MethodAccessSchema).min(1)
44230
- }),
44231
- object({
44232
- type: literal("addon"),
44233
- target: string(),
44234
- access: array(MethodAccessSchema).min(1)
44235
- }),
44236
- DeviceTokenScopeSchema
44237
- ]));
44238
- object({
44239
- id: string(),
44240
- username: string(),
44241
- passwordHash: string(),
44242
- /**
44243
- * Admin bypass. When true, the middleware skips the scope-access
44244
- * check entirely. There is no other axis of privilege; the legacy
44245
- * role enum collapsed onto this boolean in v2.
44246
- */
44247
- isAdmin: boolean().default(false),
44248
- allowedProviders: AllowedProviderSchema,
44249
- allowedDevices: AllowedDevicesSchema,
44250
- /**
44251
- * Scopes granted to this user. Admins bypass; their `scopes` is
44252
- * ignored. Non-admins without scopes are locked out of every
44253
- * protected call.
44254
- */
44255
- scopes: array(TokenScopeSchema).default([]),
44256
- createdAt: number(),
44257
- updatedAt: number()
44258
- });
44259
- object({
44260
- id: string(),
44261
- label: string(),
44262
- isAdmin: boolean().default(false),
44263
- allowedProviders: AllowedProviderSchema,
44264
- allowedDevices: AllowedDevicesSchema,
44265
- tokenHash: string(),
44266
- tokenPrefix: string(),
44267
- createdAt: number(),
44268
- lastUsedAt: number().optional()
44269
- });
44270
- object({
44271
- id: string(),
44272
- userId: string(),
44273
- name: string(),
44274
- tokenHash: string(),
44275
- tokenPrefix: string(),
44276
- scopes: array(TokenScopeSchema),
44277
- expiresAt: number().nullish(),
44278
- lastUsedAt: number().nullish(),
44279
- createdAt: number()
44280
- });
44281
- /**
44282
44430
  * `oauth-integration` — a collection cap by which an addon declares
44283
44431
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44284
44432
  * Each provider returns a static descriptor; the core enumerates them
@@ -64173,26 +64321,6 @@ var ApiKeySummarySchema = object({
64173
64321
  createdAt: number(),
64174
64322
  lastUsedAt: number().optional()
64175
64323
  });
64176
- var ScopedTokenSummarySchema = object({
64177
- id: string(),
64178
- userId: string(),
64179
- name: string(),
64180
- tokenPrefix: string(),
64181
- scopes: array(TokenScopeSchema),
64182
- expiresAt: number().nullish(),
64183
- lastUsedAt: number().nullish(),
64184
- createdAt: number()
64185
- });
64186
- var CreateScopedTokenInputSchema = object({
64187
- userId: string(),
64188
- name: string(),
64189
- scopes: array(TokenScopeSchema),
64190
- expiresAt: number().optional()
64191
- });
64192
- var CreateScopedTokenResultSchema = object({
64193
- token: string(),
64194
- record: ScopedTokenSummarySchema
64195
- });
64196
64324
  var OauthSessionSummarySchema = object({
64197
64325
  id: string(),
64198
64326
  userId: string(),
@@ -64214,11 +64342,11 @@ var TotpStatusSchema = object({
64214
64342
  confirmedAt: number().nullable()
64215
64343
  });
64216
64344
  /**
64217
- * user-management — singleton capability for user accounts, API keys,
64218
- * and scoped tokens.
64345
+ * user-management — singleton capability for user accounts and the
64346
+ * legacy API-key rows.
64219
64347
  *
64220
64348
  * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
64221
- * — the subset check on `setUserScopes` / `createScopedToken` is moot
64349
+ * — the subset check on `setUserScopes` is moot
64222
64350
  * because non-admins never reach these. If/when we open non-admin
64223
64351
  * delegation, structural caller-scope subset check goes inside the
64224
64352
  * provider.
@@ -64275,15 +64403,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
64275
64403
  kind: "mutation",
64276
64404
  auth: "admin",
64277
64405
  access: "delete"
64278
- }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
64279
- kind: "mutation",
64280
- auth: "admin",
64281
- access: "create"
64282
- }), method(object({ id: string() }), object({ success: literal(true) }), {
64283
- kind: "mutation",
64284
- auth: "admin",
64285
- access: "delete"
64286
- }), method(object({ token: string() }), ScopedTokenSummarySchema.nullable(), { access: "view" }), method(object({ userId: string() }), array(ScopedTokenSummarySchema), { auth: "admin" }), method(object({ userId: string() }), TotpSetupResultSchema, {
64406
+ }), method(object({ userId: string() }), TotpSetupResultSchema, {
64287
64407
  kind: "mutation",
64288
64408
  auth: "admin",
64289
64409
  access: "create"
@@ -70373,7 +70493,7 @@ Object.freeze({
70373
70493
  capName: "llm",
70374
70494
  capScope: "system",
70375
70495
  addonId: null,
70376
- access: "view"
70496
+ access: "create"
70377
70497
  },
70378
70498
  "llm.listNodeModels": {
70379
70499
  capName: "llm",
@@ -75037,12 +75157,6 @@ Object.freeze({
75037
75157
  addonId: null,
75038
75158
  access: "create"
75039
75159
  },
75040
- "userManagement.createScopedToken": {
75041
- capName: "user-management",
75042
- capScope: "system",
75043
- addonId: null,
75044
- access: "create"
75045
- },
75046
75160
  "userManagement.createUser": {
75047
75161
  capName: "user-management",
75048
75162
  capScope: "system",
@@ -75091,12 +75205,6 @@ Object.freeze({
75091
75205
  addonId: null,
75092
75206
  access: "view"
75093
75207
  },
75094
- "userManagement.listScopedTokens": {
75095
- capName: "user-management",
75096
- capScope: "system",
75097
- addonId: null,
75098
- access: "view"
75099
- },
75100
75208
  "userManagement.listUsers": {
75101
75209
  capName: "user-management",
75102
75210
  capScope: "system",
@@ -75151,12 +75259,6 @@ Object.freeze({
75151
75259
  addonId: null,
75152
75260
  access: "delete"
75153
75261
  },
75154
- "userManagement.revokeScopedToken": {
75155
- capName: "user-management",
75156
- capScope: "system",
75157
- addonId: null,
75158
- access: "delete"
75159
- },
75160
75262
  "userManagement.setupTotp": {
75161
75263
  capName: "user-management",
75162
75264
  capScope: "system",
@@ -75187,12 +75289,6 @@ Object.freeze({
75187
75289
  addonId: null,
75188
75290
  access: "view"
75189
75291
  },
75190
- "userManagement.validateScopedToken": {
75191
- capName: "user-management",
75192
- capScope: "system",
75193
- addonId: null,
75194
- access: "view"
75195
- },
75196
75292
  "userManagement.verifyTotp": {
75197
75293
  capName: "user-management",
75198
75294
  capScope: "system",