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