@camstack/addon-mqtt-broker 1.2.128 → 1.2.130

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.
@@ -5594,7 +5594,7 @@ var ZodIssueCode = {
5594
5594
  var ZodFirstPartyTypeKind;
5595
5595
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5596
5596
  //#endregion
5597
- //#region ../types/dist/sleep-BxjU_fJM.mjs
5597
+ //#region ../types/dist/sleep-yKL5gfrH.mjs
5598
5598
  /**
5599
5599
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5600
5600
  * window to float samples (D455).
@@ -7976,6 +7976,12 @@ function normalizeAddonInitResult(result) {
7976
7976
  if (Array.isArray(result)) return { providers: result };
7977
7977
  return result;
7978
7978
  }
7979
+ /**
7980
+ * The share-view scope kinds a share-link token can carry. The hub mints
7981
+ * and validates them (`ShareViewGrantSchema` builds its
7982
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
7983
+ */
7984
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7979
7985
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7980
7986
  var PeerBytesTicketSchema = object({
7981
7987
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12836,6 +12842,280 @@ var ConvertResultSchema = object({
12836
12842
  files: array(string()).readonly()
12837
12843
  })).readonly()
12838
12844
  });
12845
+ /**
12846
+ * Zod schemas for persisted record types.
12847
+ *
12848
+ * These schemas serve as the single source of truth for types that are
12849
+ * stored in the settings-store backend and retrieved via tRPC. They
12850
+ * replace the manual TypeScript interfaces with schema-derived types,
12851
+ * enabling runtime validation when reading from the backend.
12852
+ *
12853
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12854
+ * keeps the original name for backward compatibility.
12855
+ */
12856
+ /**
12857
+ * Auth model (v2 — 2026-05-12 caps-only):
12858
+ *
12859
+ * Two principals:
12860
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12861
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12862
+ *
12863
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12864
+ * `super_admin` — collapsed onto the single boolean because every
12865
+ * non-admin caller is governed by the same scope-check rules; the
12866
+ * distinction was only ever used to route role-specific procedures
12867
+ * which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
12868
+ * with `isAdmin: false` + an explicit scope list.
12869
+ */
12870
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12871
+ var MethodAccessSchema = _enum([
12872
+ "view",
12873
+ "create",
12874
+ "delete"
12875
+ ]);
12876
+ /**
12877
+ * A single scope grant. Three forms — checked in matcher with OR
12878
+ * semantics; the first match decides whether the call passes:
12879
+ *
12880
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12881
+ * cap with the matching `scope` declaration. New caps inherit grants
12882
+ * automatically — adding a device cap to the codebase makes it
12883
+ * reachable to every user with `category:device [...]` without a
12884
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12885
+ *
12886
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12887
+ * useful when an integration needs to interact with one specific
12888
+ * addon's surface regardless of how many caps it exports.
12889
+ *
12890
+ * - `capability` — the most precise form. Single cap name. Use for
12891
+ * integration tokens where you want to grant `addons.installPackage`
12892
+ * and nothing else.
12893
+ *
12894
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12895
+ * "give me everything" escape; there is no wildcard scope.
12896
+ */
12897
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12898
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12899
+ var CapScopeSchema = _enum(["device", "system"]);
12900
+ /**
12901
+ * DeviceSelector (scope model v3 — 2026-08-12).
12902
+ *
12903
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12904
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12905
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12906
+ * AFTER the grant was minted — no re-grant, no re-login.
12907
+ *
12908
+ * - `all` — every device in the deployment. The broad viewer/operator
12909
+ * lever without a `category` grant (a `category` grant also covers device
12910
+ * caps that carry no deviceId; `all` is specifically the device set).
12911
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
12912
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
12913
+ * is NOT covered until the grant is edited.
12914
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
12915
+ * DYNAMIC. A device that changes type, or a new device of the type,
12916
+ * re-resolves on the next request.
12917
+ * - `locations` — every device whose operator-assigned `location` label is
12918
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
12919
+ * null/unset location matches NO `locations` selector.
12920
+ */
12921
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
12922
+ object({ kind: literal("all") }),
12923
+ object({
12924
+ kind: literal("ids"),
12925
+ ids: array(number().int()).min(1)
12926
+ }),
12927
+ object({
12928
+ kind: literal("types"),
12929
+ types: array(_enum(DeviceType)).min(1)
12930
+ }),
12931
+ object({
12932
+ kind: literal("locations"),
12933
+ locations: array(string().min(1)).min(1)
12934
+ })
12935
+ ]);
12936
+ var DeviceTokenScopeSchema = object({
12937
+ type: literal("device"),
12938
+ /** The device SET this grant covers — resolved against the live fleet. */
12939
+ selector: DeviceSelectorSchema,
12940
+ access: array(MethodAccessSchema).min(1),
12941
+ /**
12942
+ * Whether a grant on a PARENT device transparently covers its accessory
12943
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
12944
+ * Direction is parent → children ONLY.
12945
+ *
12946
+ * Absent → the matcher DERIVES it from the access flavour: `view`
12947
+ * inherits (a camera viewer sees the camera's accessories), `create` /
12948
+ * `delete` do NOT (actuating/removing a child is an explicit act the
12949
+ * operator must grant on the child, not inherit from the parent). Set it
12950
+ * explicitly to override that default per grant.
12951
+ */
12952
+ includeLinked: boolean().optional()
12953
+ });
12954
+ /**
12955
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
12956
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
12957
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
12958
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
12959
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
12960
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
12961
+ * migration cannot reach a JWT already in a client's hands; parse-time
12962
+ * migration covers both without a flag day. No cast — the raw object is read
12963
+ * through `Reflect.get` (its static type is `unknown`).
12964
+ */
12965
+ function migrateLegacyTokenScope(raw) {
12966
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
12967
+ if (Reflect.get(raw, "type") !== "device") return raw;
12968
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
12969
+ const targets = Reflect.get(raw, "targets");
12970
+ if (!Array.isArray(targets)) return raw;
12971
+ return {
12972
+ type: "device",
12973
+ selector: {
12974
+ kind: "ids",
12975
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
12976
+ },
12977
+ access: Reflect.get(raw, "access")
12978
+ };
12979
+ }
12980
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
12981
+ object({
12982
+ type: literal("category"),
12983
+ target: CapScopeSchema,
12984
+ access: array(MethodAccessSchema).min(1)
12985
+ }),
12986
+ object({
12987
+ type: literal("capability"),
12988
+ target: string(),
12989
+ access: array(MethodAccessSchema).min(1)
12990
+ }),
12991
+ object({
12992
+ type: literal("addon"),
12993
+ target: string(),
12994
+ access: array(MethodAccessSchema).min(1)
12995
+ }),
12996
+ DeviceTokenScopeSchema
12997
+ ]));
12998
+ object({
12999
+ id: string(),
13000
+ username: string(),
13001
+ passwordHash: string(),
13002
+ /**
13003
+ * Admin bypass. When true, the middleware skips the scope-access
13004
+ * check entirely. There is no other axis of privilege; the legacy
13005
+ * role enum collapsed onto this boolean in v2.
13006
+ */
13007
+ isAdmin: boolean().default(false),
13008
+ allowedProviders: AllowedProviderSchema,
13009
+ allowedDevices: AllowedDevicesSchema,
13010
+ /**
13011
+ * Scopes granted to this user. Admins bypass; their `scopes` is
13012
+ * ignored. Non-admins without scopes are locked out of every
13013
+ * protected call.
13014
+ */
13015
+ scopes: array(TokenScopeSchema).default([]),
13016
+ createdAt: number(),
13017
+ updatedAt: number()
13018
+ });
13019
+ object({
13020
+ id: string(),
13021
+ label: string(),
13022
+ isAdmin: boolean().default(false),
13023
+ allowedProviders: AllowedProviderSchema,
13024
+ allowedDevices: AllowedDevicesSchema,
13025
+ tokenHash: string(),
13026
+ tokenPrefix: string(),
13027
+ createdAt: number(),
13028
+ lastUsedAt: number().optional()
13029
+ });
13030
+ object({
13031
+ id: string(),
13032
+ userId: string(),
13033
+ name: string(),
13034
+ tokenHash: string(),
13035
+ tokenPrefix: string(),
13036
+ scopes: array(TokenScopeSchema),
13037
+ expiresAt: number().nullish(),
13038
+ lastUsedAt: number().nullish(),
13039
+ createdAt: number()
13040
+ });
13041
+ /** What a share-view grant lets its holder see. */
13042
+ var ShareViewGrantSchema = object({
13043
+ kind: _enum(SHARE_VIEW_KINDS),
13044
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
13045
+ /** Talk-back, opt-in at mint time; absent means off. */
13046
+ talk: boolean().optional()
13047
+ });
13048
+ var ShareViewScopeSchema = object({
13049
+ type: literal("share-view"),
13050
+ grant: ShareViewGrantSchema
13051
+ });
13052
+ var AddonRoutesScopeSchema = object({
13053
+ type: literal("addon-routes"),
13054
+ access: array(MethodAccessSchema).min(1)
13055
+ });
13056
+ var PreferencesSelfScopeSchema = object({ type: literal("preferences-self") });
13057
+ var CredentialScopeSchema = union([
13058
+ literal("*"),
13059
+ ShareViewScopeSchema,
13060
+ AddonRoutesScopeSchema,
13061
+ PreferencesSelfScopeSchema,
13062
+ TokenScopeSchema
13063
+ ]);
13064
+ object({
13065
+ kind: literal("credential"),
13066
+ sub: string().min(1),
13067
+ jti: string().min(16),
13068
+ scopes: array(CredentialScopeSchema).min(1)
13069
+ });
13070
+ var PreferenceNamespaceSchema = string().regex(/^[a-z][a-z0-9.-]{0,63}$/);
13071
+ /** A namespace's value: a JSON object, opaque to the hub. */
13072
+ var PreferenceValueSchema = record(string(), unknown());
13073
+ var PreferenceDeviceIdSchema = string().min(1).max(64);
13074
+ /** A stored row, as the owner reads it. */
13075
+ var PreferenceRowSchema = object({
13076
+ namespace: PreferenceNamespaceSchema,
13077
+ value: PreferenceValueSchema,
13078
+ /** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
13079
+ revision: number().int().positive(),
13080
+ updatedAt: number().int(),
13081
+ /** The client id the last writer sent; `null` when it sent none. */
13082
+ updatedByDevice: PreferenceDeviceIdSchema.nullable()
13083
+ });
13084
+ object({
13085
+ /** Absent: every namespace the caller holds. */
13086
+ namespaces: array(PreferenceNamespaceSchema).max(32).optional() });
13087
+ object({ rows: array(PreferenceRowSchema) });
13088
+ object({
13089
+ namespace: PreferenceNamespaceSchema,
13090
+ value: PreferenceValueSchema,
13091
+ /**
13092
+ * The revision the edit was based on. Absent: last write wins. `0`: the
13093
+ * namespace must not exist yet. Any other value that is not the current
13094
+ * revision answers `conflict` and writes nothing.
13095
+ */
13096
+ baseRevision: number().int().nonnegative().optional(),
13097
+ deviceId: PreferenceDeviceIdSchema.optional()
13098
+ });
13099
+ discriminatedUnion("status", [object({
13100
+ status: literal("saved"),
13101
+ row: PreferenceRowSchema
13102
+ }), object({
13103
+ status: literal("conflict"),
13104
+ current: PreferenceRowSchema.nullable()
13105
+ })]);
13106
+ object({ namespace: PreferenceNamespaceSchema });
13107
+ object({
13108
+ /** `false` when the namespace did not exist. */
13109
+ deleted: boolean() });
13110
+ object({
13111
+ /** The revision the client holds per namespace; a namespace it does not list is new to it. */
13112
+ revisionByNamespace: record(PreferenceNamespaceSchema, number().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
13113
+ object({
13114
+ /** Every row whose revision differs from the client's, and every row it did not list. */
13115
+ rows: array(PreferenceRowSchema),
13116
+ /** Namespaces the client listed that no longer exist. */
13117
+ deleted: array(PreferenceNamespaceSchema)
13118
+ });
12839
13119
  _enum(["new-session", "step-up"]);
12840
13120
  /** The languages the hub's app landing pages are written in (D858). */
12841
13121
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -39763,38 +40043,37 @@ method(LlmRuntimeCompleteInputSchema, LlmGenerateResultSchema, {
39763
40043
  auth: "admin",
39764
40044
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39765
40045
  });
40046
+ var LlmProfileKindSchema = string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "a kind id is lower-case letters, digits and dashes");
40047
+ /** What a model (or, by default, every model of a kind) can do. */
40048
+ var LlmModelFeaturesSchema = object({
40049
+ vision: boolean(),
40050
+ tools: boolean(),
40051
+ streaming: boolean()
40052
+ });
40053
+ /** One model a provider offers. `features` overrides the kind's defaults, per field. */
40054
+ var LlmModelInfoSchema = object({
40055
+ id: string(),
40056
+ label: string().optional(),
40057
+ contextLength: number().int().positive().optional(),
40058
+ features: LlmModelFeaturesSchema.partial().optional()
40059
+ });
39766
40060
  /**
39767
- * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
39768
- * methods concat-fan across providers; single-row methods route to ONE
39769
- * provider by the `addonId` in the call input (the notification-output
39770
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
39771
- * (hub-placed); the cap stays open for future providers.
39772
- *
39773
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
39774
- * `apiKey` is a password field — providers REDACT it on read and merge on
39775
- * write; a stored key NEVER round-trips to a client.
40061
+ * The provider-specific part of a profile, validated by the provider that owns
40062
+ * the kind (`upsertProfile` refuses what it does not accept). A field its
40063
+ * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
40064
+ * keychain, never in the row, and reads back as the redaction marker.
39776
40065
  */
39777
- var LlmProfileKindSchema = _enum([
39778
- "openai-compatible",
39779
- "openai",
39780
- "anthropic",
39781
- "google",
39782
- "managed-local",
39783
- "apple-foundation"
39784
- ]);
40066
+ var LlmProviderConfigSchema = record(string(), unknown());
39785
40067
  var LlmProfileSchema = object({
39786
40068
  id: string(),
39787
40069
  name: string(),
40070
+ /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
39788
40071
  kind: LlmProfileKindSchema,
39789
40072
  /** Stamped by the provider — keeps the fanned catalog routable. */
39790
40073
  addonId: string(),
39791
40074
  enabled: boolean(),
39792
40075
  /** Vendor model id, or the managed runtime's loaded model. */
39793
40076
  model: string(),
39794
- /** Required for openai-compatible; override for cloud kinds. */
39795
- baseUrl: string().optional(),
39796
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
39797
- apiKey: string().optional(),
39798
40077
  /** Vision on/off. A vision call against a `false` profile is REFUSED, never
39799
40078
  * degraded to text — that shipped once and produced a confident answer to a
39800
40079
  * question about a picture nobody sent. */
@@ -39802,15 +40081,11 @@ var LlmProfileSchema = object({
39802
40081
  temperature: number().min(0).max(2).optional(),
39803
40082
  /** Nucleus sampling. Every wire we speak has it. */
39804
40083
  topP: number().min(0).max(1).optional(),
39805
- /** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
39806
- * wire does, and the client drops it there (measured: the request body gets
39807
- * `top_p` and no `top_k`). The profile editor hides the field wherever it
39808
- * would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
40084
+ /** Top-k sampling. Carried only by the wires that have it — a kind offers the
40085
+ * field in its editor only when its descriptor lists it in `profileFields`. */
39809
40086
  topK: number().int().positive().optional(),
39810
40087
  maxTokens: number().int().positive().optional(),
39811
- /** Prompt context window. Advisory for cloud kinds (they enforce their own);
39812
- * for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
39813
- * the model with, so it is the one field that changes a PROCESS. */
40088
+ /** Prompt context window. Advisory for cloud kinds (they enforce their own). */
39814
40089
  contextLength: number().int().positive().optional(),
39815
40090
  /** Default system prompt. A caller's `system` REPLACES it (never appends —
39816
40091
  * two system prompts fighting is worse than either alone). */
@@ -39836,16 +40111,37 @@ var LlmProfileSchema = object({
39836
40111
  * library; the REGISTRY of callable tools is ours and is empty in v1, so a
39837
40112
  * `true` here buys the wiring, not behaviour, until tools are registered. */
39838
40113
  toolsEnabled: boolean().default(false),
39839
- extraHeaders: record(string(), string()).optional(),
39840
- /** kind === 'managed-local' only (spec §4). */
39841
- runtime: ManagedRuntimeConfigSchema.optional(),
39842
- /**
39843
- * kind === 'apple-foundation' only: WHERE it runs — the only thing there is
39844
- * to configure (no key, no URL, no download; `model` is `apple-system`).
39845
- * `supportsVision` on such a row is stamped by the provider from the node's
39846
- * reported `imageInput`, never taken from the operator (D62).
39847
- */
39848
- appleFoundation: object({ nodeId: string() }).optional()
40114
+ /** Everything the kind's provider owns (endpoint, key, node, runtime…). */
40115
+ providerConfig: LlmProviderConfigSchema.default({})
40116
+ });
40117
+ /**
40118
+ * The common profile fields a kind's editor offers. The editor owns how each
40119
+ * one is drawn; the provider says which of them mean something on its wire.
40120
+ */
40121
+ var LlmProfileFieldSchema = _enum([
40122
+ "temperature",
40123
+ "topP",
40124
+ "topK",
40125
+ "maxTokens",
40126
+ "contextLength",
40127
+ "systemPrompt",
40128
+ "timeoutMs",
40129
+ "connectTimeoutMs",
40130
+ "firstTokenTimeoutMs",
40131
+ "idleTimeoutMs",
40132
+ "retry",
40133
+ "toolsEnabled"
40134
+ ]);
40135
+ /**
40136
+ * A provider-drawn part of the editor, by a generic widget id the admin UI
40137
+ * registers (`ai/apple-node`). `placement: 'model'` replaces the generic model
40138
+ * picker: that widget owns the model choice.
40139
+ */
40140
+ var LlmProviderWidgetSchema = object({
40141
+ id: string(),
40142
+ placement: _enum(["connection", "model"]),
40143
+ /** `providerConfig` keys this widget must fill before the profile can be saved. */
40144
+ requires: array(string()).optional()
39849
40145
  });
39850
40146
  /** ConfigUISchema tree passed through untyped on the wire (the
39851
40147
  * notification-output `ConfigSchemaPassthrough` precedent at
@@ -39854,11 +40150,56 @@ var ConfigSchemaPassthrough$3 = unknown();
39854
40150
  var LlmProfileKindDescriptorSchema = object({
39855
40151
  kind: LlmProfileKindSchema,
39856
40152
  label: string(),
40153
+ /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
39857
40154
  icon: string(),
39858
40155
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
39859
40156
  addonId: string(),
39860
- configSchema: ConfigSchemaPassthrough$3
40157
+ /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
40158
+ connectionSchema: ConfigSchemaPassthrough$3,
40159
+ /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
40160
+ advancedSchema: ConfigSchemaPassthrough$3.optional(),
40161
+ /** The kind's defaults; a model from `listModels` may override any of them. */
40162
+ features: LlmModelFeaturesSchema,
40163
+ /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
40164
+ visionEditable: boolean(),
40165
+ /** Where the model list comes from: `listModels`, `staticModels`, or nowhere. */
40166
+ modelCatalog: _enum([
40167
+ "fetch",
40168
+ "static",
40169
+ "none"
40170
+ ]),
40171
+ staticModels: array(LlmModelInfoSchema).optional(),
40172
+ /** The common fields that mean something on this kind's wire. */
40173
+ profileFields: array(LlmProfileFieldSchema),
40174
+ providerWidgets: array(LlmProviderWidgetSchema).optional()
40175
+ });
40176
+ /**
40177
+ * `listModels` input. `connection` is an UNSAVED draft of `providerConfig`
40178
+ * (the editor's form); with `profileId` too, a secret the draft leaves
40179
+ * untouched (absent or the redaction marker) is resolved server-side from the
40180
+ * stored profile — the browser never receives it.
40181
+ */
40182
+ var LlmListModelsInputSchema = object({
40183
+ addonId: string(),
40184
+ kind: LlmProfileKindSchema,
40185
+ profileId: string().optional(),
40186
+ connection: LlmProviderConfigSchema.optional()
39861
40187
  });
40188
+ var LlmListModelsErrorCodeSchema = _enum([
40189
+ "auth",
40190
+ "network",
40191
+ "unsupported",
40192
+ "invalid"
40193
+ ]);
40194
+ /** A RESULT, never a throw: "wrong key" is an answer the editor renders inline. */
40195
+ var LlmListModelsResultSchema = discriminatedUnion("ok", [object({
40196
+ ok: literal(true),
40197
+ models: array(LlmModelInfoSchema)
40198
+ }), object({
40199
+ ok: literal(false),
40200
+ code: LlmListModelsErrorCodeSchema,
40201
+ message: string()
40202
+ })]);
39862
40203
  var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
39863
40204
  var LlmDefaultSchema = object({
39864
40205
  selector: LlmDefaultSelectorSchema,
@@ -39958,7 +40299,10 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
39958
40299
  kind: "mutation",
39959
40300
  auth: "admin",
39960
40301
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39961
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
40302
+ }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
40303
+ kind: "mutation",
40304
+ auth: "admin"
40305
+ }), method(object({}), array(LlmDefaultSchema)), method(object({
39962
40306
  selector: LlmDefaultSelectorSchema,
39963
40307
  profileId: string().nullable()
39964
40308
  }), _void(), {
@@ -44041,202 +44385,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
44041
44385
  auth: "admin"
44042
44386
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
44043
44387
  /**
44044
- * Zod schemas for persisted record types.
44045
- *
44046
- * These schemas serve as the single source of truth for types that are
44047
- * stored in the settings-store backend and retrieved via tRPC. They
44048
- * replace the manual TypeScript interfaces with schema-derived types,
44049
- * enabling runtime validation when reading from the backend.
44050
- *
44051
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
44052
- * keeps the original name for backward compatibility.
44053
- */
44054
- /**
44055
- * Auth model (v2 — 2026-05-12 caps-only):
44056
- *
44057
- * Two principals:
44058
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
44059
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
44060
- *
44061
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44062
- * `super_admin` — collapsed onto the single boolean because every
44063
- * non-admin caller is governed by the same scope-check rules; the
44064
- * distinction was only ever used to route role-specific procedures
44065
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44066
- * with `isAdmin: false` + an explicit scope list.
44067
- */
44068
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44069
- var MethodAccessSchema = _enum([
44070
- "view",
44071
- "create",
44072
- "delete"
44073
- ]);
44074
- /**
44075
- * A single scope grant. Three forms — checked in matcher with OR
44076
- * semantics; the first match decides whether the call passes:
44077
- *
44078
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44079
- * cap with the matching `scope` declaration. New caps inherit grants
44080
- * automatically — adding a device cap to the codebase makes it
44081
- * reachable to every user with `category:device [...]` without a
44082
- * re-grant. Use this for "family viewer" / "operator" tiers.
44083
- *
44084
- * - `addon` — every cap that ships inside a given addon id. Niche;
44085
- * useful when an integration needs to interact with one specific
44086
- * addon's surface regardless of how many caps it exports.
44087
- *
44088
- * - `capability` — the most precise form. Single cap name. Use for
44089
- * integration tokens where you want to grant `addons.installPackage`
44090
- * and nothing else.
44091
- *
44092
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44093
- * "give me everything" escape; there is no wildcard scope.
44094
- */
44095
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44096
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44097
- var CapScopeSchema = _enum(["device", "system"]);
44098
- /**
44099
- * DeviceSelector (scope model v3 — 2026-08-12).
44100
- *
44101
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44102
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44103
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44104
- * AFTER the grant was minted — no re-grant, no re-login.
44105
- *
44106
- * - `all` — every device in the deployment. The broad viewer/operator
44107
- * lever without a `category` grant (a `category` grant also covers device
44108
- * caps that carry no deviceId; `all` is specifically the device set).
44109
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44110
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44111
- * is NOT covered until the grant is edited.
44112
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44113
- * DYNAMIC. A device that changes type, or a new device of the type,
44114
- * re-resolves on the next request.
44115
- * - `locations` — every device whose operator-assigned `location` label is
44116
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44117
- * null/unset location matches NO `locations` selector.
44118
- */
44119
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44120
- object({ kind: literal("all") }),
44121
- object({
44122
- kind: literal("ids"),
44123
- ids: array(number().int()).min(1)
44124
- }),
44125
- object({
44126
- kind: literal("types"),
44127
- types: array(_enum(DeviceType)).min(1)
44128
- }),
44129
- object({
44130
- kind: literal("locations"),
44131
- locations: array(string().min(1)).min(1)
44132
- })
44133
- ]);
44134
- var DeviceTokenScopeSchema = object({
44135
- type: literal("device"),
44136
- /** The device SET this grant covers — resolved against the live fleet. */
44137
- selector: DeviceSelectorSchema,
44138
- access: array(MethodAccessSchema).min(1),
44139
- /**
44140
- * Whether a grant on a PARENT device transparently covers its accessory
44141
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44142
- * Direction is parent → children ONLY.
44143
- *
44144
- * Absent → the matcher DERIVES it from the access flavour: `view`
44145
- * inherits (a camera viewer sees the camera's accessories), `create` /
44146
- * `delete` do NOT (actuating/removing a child is an explicit act the
44147
- * operator must grant on the child, not inherit from the parent). Set it
44148
- * explicitly to override that default per grant.
44149
- */
44150
- includeLinked: boolean().optional()
44151
- });
44152
- /**
44153
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44154
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44155
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44156
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44157
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44158
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44159
- * migration cannot reach a JWT already in a client's hands; parse-time
44160
- * migration covers both without a flag day. No cast — the raw object is read
44161
- * through `Reflect.get` (its static type is `unknown`).
44162
- */
44163
- function migrateLegacyTokenScope(raw) {
44164
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44165
- if (Reflect.get(raw, "type") !== "device") return raw;
44166
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44167
- const targets = Reflect.get(raw, "targets");
44168
- if (!Array.isArray(targets)) return raw;
44169
- return {
44170
- type: "device",
44171
- selector: {
44172
- kind: "ids",
44173
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44174
- },
44175
- access: Reflect.get(raw, "access")
44176
- };
44177
- }
44178
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44179
- object({
44180
- type: literal("category"),
44181
- target: CapScopeSchema,
44182
- access: array(MethodAccessSchema).min(1)
44183
- }),
44184
- object({
44185
- type: literal("capability"),
44186
- target: string(),
44187
- access: array(MethodAccessSchema).min(1)
44188
- }),
44189
- object({
44190
- type: literal("addon"),
44191
- target: string(),
44192
- access: array(MethodAccessSchema).min(1)
44193
- }),
44194
- DeviceTokenScopeSchema
44195
- ]));
44196
- object({
44197
- id: string(),
44198
- username: string(),
44199
- passwordHash: string(),
44200
- /**
44201
- * Admin bypass. When true, the middleware skips the scope-access
44202
- * check entirely. There is no other axis of privilege; the legacy
44203
- * role enum collapsed onto this boolean in v2.
44204
- */
44205
- isAdmin: boolean().default(false),
44206
- allowedProviders: AllowedProviderSchema,
44207
- allowedDevices: AllowedDevicesSchema,
44208
- /**
44209
- * Scopes granted to this user. Admins bypass; their `scopes` is
44210
- * ignored. Non-admins without scopes are locked out of every
44211
- * protected call.
44212
- */
44213
- scopes: array(TokenScopeSchema).default([]),
44214
- createdAt: number(),
44215
- updatedAt: number()
44216
- });
44217
- object({
44218
- id: string(),
44219
- label: string(),
44220
- isAdmin: boolean().default(false),
44221
- allowedProviders: AllowedProviderSchema,
44222
- allowedDevices: AllowedDevicesSchema,
44223
- tokenHash: string(),
44224
- tokenPrefix: string(),
44225
- createdAt: number(),
44226
- lastUsedAt: number().optional()
44227
- });
44228
- object({
44229
- id: string(),
44230
- userId: string(),
44231
- name: string(),
44232
- tokenHash: string(),
44233
- tokenPrefix: string(),
44234
- scopes: array(TokenScopeSchema),
44235
- expiresAt: number().nullish(),
44236
- lastUsedAt: number().nullish(),
44237
- createdAt: number()
44238
- });
44239
- /**
44240
44388
  * `oauth-integration` — a collection cap by which an addon declares
44241
44389
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44242
44390
  * Each provider returns a static descriptor; the core enumerates them
@@ -61168,26 +61316,6 @@ var ApiKeySummarySchema = object({
61168
61316
  createdAt: number(),
61169
61317
  lastUsedAt: number().optional()
61170
61318
  });
61171
- var ScopedTokenSummarySchema = object({
61172
- id: string(),
61173
- userId: string(),
61174
- name: string(),
61175
- tokenPrefix: string(),
61176
- scopes: array(TokenScopeSchema),
61177
- expiresAt: number().nullish(),
61178
- lastUsedAt: number().nullish(),
61179
- createdAt: number()
61180
- });
61181
- var CreateScopedTokenInputSchema = object({
61182
- userId: string(),
61183
- name: string(),
61184
- scopes: array(TokenScopeSchema),
61185
- expiresAt: number().optional()
61186
- });
61187
- var CreateScopedTokenResultSchema = object({
61188
- token: string(),
61189
- record: ScopedTokenSummarySchema
61190
- });
61191
61319
  var OauthSessionSummarySchema = object({
61192
61320
  id: string(),
61193
61321
  userId: string(),
@@ -61209,11 +61337,11 @@ var TotpStatusSchema = object({
61209
61337
  confirmedAt: number().nullable()
61210
61338
  });
61211
61339
  /**
61212
- * user-management — singleton capability for user accounts, API keys,
61213
- * and scoped tokens.
61340
+ * user-management — singleton capability for user accounts and the
61341
+ * legacy API-key rows.
61214
61342
  *
61215
61343
  * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
61216
- * — the subset check on `setUserScopes` / `createScopedToken` is moot
61344
+ * — the subset check on `setUserScopes` is moot
61217
61345
  * because non-admins never reach these. If/when we open non-admin
61218
61346
  * delegation, structural caller-scope subset check goes inside the
61219
61347
  * provider.
@@ -61270,15 +61398,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
61270
61398
  kind: "mutation",
61271
61399
  auth: "admin",
61272
61400
  access: "delete"
61273
- }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
61274
- kind: "mutation",
61275
- auth: "admin",
61276
- access: "create"
61277
- }), method(object({ id: string() }), object({ success: literal(true) }), {
61278
- kind: "mutation",
61279
- auth: "admin",
61280
- access: "delete"
61281
- }), method(object({ token: string() }), ScopedTokenSummarySchema.nullable(), { access: "view" }), method(object({ userId: string() }), array(ScopedTokenSummarySchema), { auth: "admin" }), method(object({ userId: string() }), TotpSetupResultSchema, {
61401
+ }), method(object({ userId: string() }), TotpSetupResultSchema, {
61282
61402
  kind: "mutation",
61283
61403
  auth: "admin",
61284
61404
  access: "create"
@@ -65434,7 +65554,7 @@ Object.freeze({
65434
65554
  capName: "llm",
65435
65555
  capScope: "system",
65436
65556
  addonId: null,
65437
- access: "view"
65557
+ access: "create"
65438
65558
  },
65439
65559
  "llm.listNodeModels": {
65440
65560
  capName: "llm",
@@ -70098,12 +70218,6 @@ Object.freeze({
70098
70218
  addonId: null,
70099
70219
  access: "create"
70100
70220
  },
70101
- "userManagement.createScopedToken": {
70102
- capName: "user-management",
70103
- capScope: "system",
70104
- addonId: null,
70105
- access: "create"
70106
- },
70107
70221
  "userManagement.createUser": {
70108
70222
  capName: "user-management",
70109
70223
  capScope: "system",
@@ -70152,12 +70266,6 @@ Object.freeze({
70152
70266
  addonId: null,
70153
70267
  access: "view"
70154
70268
  },
70155
- "userManagement.listScopedTokens": {
70156
- capName: "user-management",
70157
- capScope: "system",
70158
- addonId: null,
70159
- access: "view"
70160
- },
70161
70269
  "userManagement.listUsers": {
70162
70270
  capName: "user-management",
70163
70271
  capScope: "system",
@@ -70212,12 +70320,6 @@ Object.freeze({
70212
70320
  addonId: null,
70213
70321
  access: "delete"
70214
70322
  },
70215
- "userManagement.revokeScopedToken": {
70216
- capName: "user-management",
70217
- capScope: "system",
70218
- addonId: null,
70219
- access: "delete"
70220
- },
70221
70323
  "userManagement.setupTotp": {
70222
70324
  capName: "user-management",
70223
70325
  capScope: "system",
@@ -70248,12 +70350,6 @@ Object.freeze({
70248
70350
  addonId: null,
70249
70351
  access: "view"
70250
70352
  },
70251
- "userManagement.validateScopedToken": {
70252
- capName: "user-management",
70253
- capScope: "system",
70254
- addonId: null,
70255
- access: "view"
70256
- },
70257
70353
  "userManagement.verifyTotp": {
70258
70354
  capName: "user-management",
70259
70355
  capScope: "system",