@camstack/addon-auth 1.2.151 → 1.2.153

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.
@@ -5580,7 +5580,7 @@ var ZodIssueCode = {
5580
5580
  var ZodFirstPartyTypeKind;
5581
5581
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5582
5582
  //#endregion
5583
- //#region ../types/dist/sleep-BxjU_fJM.mjs
5583
+ //#region ../types/dist/sleep-yKL5gfrH.mjs
5584
5584
  /**
5585
5585
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5586
5586
  * window to float samples (D455).
@@ -7962,6 +7962,12 @@ function normalizeAddonInitResult(result) {
7962
7962
  if (Array.isArray(result)) return { providers: result };
7963
7963
  return result;
7964
7964
  }
7965
+ /**
7966
+ * The share-view scope kinds a share-link token can carry. The hub mints
7967
+ * and validates them (`ShareViewGrantSchema` builds its
7968
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
7969
+ */
7970
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7965
7971
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7966
7972
  var PeerBytesTicketSchema = object({
7967
7973
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12926,6 +12932,280 @@ var ConvertResultSchema = object({
12926
12932
  })).readonly()
12927
12933
  });
12928
12934
  /**
12935
+ * Zod schemas for persisted record types.
12936
+ *
12937
+ * These schemas serve as the single source of truth for types that are
12938
+ * stored in the settings-store backend and retrieved via tRPC. They
12939
+ * replace the manual TypeScript interfaces with schema-derived types,
12940
+ * enabling runtime validation when reading from the backend.
12941
+ *
12942
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12943
+ * keeps the original name for backward compatibility.
12944
+ */
12945
+ /**
12946
+ * Auth model (v2 — 2026-05-12 caps-only):
12947
+ *
12948
+ * Two principals:
12949
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12950
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12951
+ *
12952
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12953
+ * `super_admin` — collapsed onto the single boolean because every
12954
+ * non-admin caller is governed by the same scope-check rules; the
12955
+ * distinction was only ever used to route role-specific procedures
12956
+ * which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
12957
+ * with `isAdmin: false` + an explicit scope list.
12958
+ */
12959
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12960
+ var MethodAccessSchema = _enum([
12961
+ "view",
12962
+ "create",
12963
+ "delete"
12964
+ ]);
12965
+ /**
12966
+ * A single scope grant. Three forms — checked in matcher with OR
12967
+ * semantics; the first match decides whether the call passes:
12968
+ *
12969
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12970
+ * cap with the matching `scope` declaration. New caps inherit grants
12971
+ * automatically — adding a device cap to the codebase makes it
12972
+ * reachable to every user with `category:device [...]` without a
12973
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12974
+ *
12975
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12976
+ * useful when an integration needs to interact with one specific
12977
+ * addon's surface regardless of how many caps it exports.
12978
+ *
12979
+ * - `capability` — the most precise form. Single cap name. Use for
12980
+ * integration tokens where you want to grant `addons.installPackage`
12981
+ * and nothing else.
12982
+ *
12983
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12984
+ * "give me everything" escape; there is no wildcard scope.
12985
+ */
12986
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12987
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12988
+ var CapScopeSchema = _enum(["device", "system"]);
12989
+ /**
12990
+ * DeviceSelector (scope model v3 — 2026-08-12).
12991
+ *
12992
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12993
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12994
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12995
+ * AFTER the grant was minted — no re-grant, no re-login.
12996
+ *
12997
+ * - `all` — every device in the deployment. The broad viewer/operator
12998
+ * lever without a `category` grant (a `category` grant also covers device
12999
+ * caps that carry no deviceId; `all` is specifically the device set).
13000
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
13001
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
13002
+ * is NOT covered until the grant is edited.
13003
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
13004
+ * DYNAMIC. A device that changes type, or a new device of the type,
13005
+ * re-resolves on the next request.
13006
+ * - `locations` — every device whose operator-assigned `location` label is
13007
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
13008
+ * null/unset location matches NO `locations` selector.
13009
+ */
13010
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
13011
+ object({ kind: literal("all") }),
13012
+ object({
13013
+ kind: literal("ids"),
13014
+ ids: array(number().int()).min(1)
13015
+ }),
13016
+ object({
13017
+ kind: literal("types"),
13018
+ types: array(_enum(DeviceType)).min(1)
13019
+ }),
13020
+ object({
13021
+ kind: literal("locations"),
13022
+ locations: array(string().min(1)).min(1)
13023
+ })
13024
+ ]);
13025
+ var DeviceTokenScopeSchema = object({
13026
+ type: literal("device"),
13027
+ /** The device SET this grant covers — resolved against the live fleet. */
13028
+ selector: DeviceSelectorSchema,
13029
+ access: array(MethodAccessSchema).min(1),
13030
+ /**
13031
+ * Whether a grant on a PARENT device transparently covers its accessory
13032
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
13033
+ * Direction is parent → children ONLY.
13034
+ *
13035
+ * Absent → the matcher DERIVES it from the access flavour: `view`
13036
+ * inherits (a camera viewer sees the camera's accessories), `create` /
13037
+ * `delete` do NOT (actuating/removing a child is an explicit act the
13038
+ * operator must grant on the child, not inherit from the parent). Set it
13039
+ * explicitly to override that default per grant.
13040
+ */
13041
+ includeLinked: boolean().optional()
13042
+ });
13043
+ /**
13044
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
13045
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
13046
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
13047
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
13048
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
13049
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
13050
+ * migration cannot reach a JWT already in a client's hands; parse-time
13051
+ * migration covers both without a flag day. No cast — the raw object is read
13052
+ * through `Reflect.get` (its static type is `unknown`).
13053
+ */
13054
+ function migrateLegacyTokenScope(raw) {
13055
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
13056
+ if (Reflect.get(raw, "type") !== "device") return raw;
13057
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
13058
+ const targets = Reflect.get(raw, "targets");
13059
+ if (!Array.isArray(targets)) return raw;
13060
+ return {
13061
+ type: "device",
13062
+ selector: {
13063
+ kind: "ids",
13064
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
13065
+ },
13066
+ access: Reflect.get(raw, "access")
13067
+ };
13068
+ }
13069
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
13070
+ object({
13071
+ type: literal("category"),
13072
+ target: CapScopeSchema,
13073
+ access: array(MethodAccessSchema).min(1)
13074
+ }),
13075
+ object({
13076
+ type: literal("capability"),
13077
+ target: string(),
13078
+ access: array(MethodAccessSchema).min(1)
13079
+ }),
13080
+ object({
13081
+ type: literal("addon"),
13082
+ target: string(),
13083
+ access: array(MethodAccessSchema).min(1)
13084
+ }),
13085
+ DeviceTokenScopeSchema
13086
+ ]));
13087
+ object({
13088
+ id: string(),
13089
+ username: string(),
13090
+ passwordHash: string(),
13091
+ /**
13092
+ * Admin bypass. When true, the middleware skips the scope-access
13093
+ * check entirely. There is no other axis of privilege; the legacy
13094
+ * role enum collapsed onto this boolean in v2.
13095
+ */
13096
+ isAdmin: boolean().default(false),
13097
+ allowedProviders: AllowedProviderSchema,
13098
+ allowedDevices: AllowedDevicesSchema,
13099
+ /**
13100
+ * Scopes granted to this user. Admins bypass; their `scopes` is
13101
+ * ignored. Non-admins without scopes are locked out of every
13102
+ * protected call.
13103
+ */
13104
+ scopes: array(TokenScopeSchema).default([]),
13105
+ createdAt: number(),
13106
+ updatedAt: number()
13107
+ });
13108
+ object({
13109
+ id: string(),
13110
+ label: string(),
13111
+ isAdmin: boolean().default(false),
13112
+ allowedProviders: AllowedProviderSchema,
13113
+ allowedDevices: AllowedDevicesSchema,
13114
+ tokenHash: string(),
13115
+ tokenPrefix: string(),
13116
+ createdAt: number(),
13117
+ lastUsedAt: number().optional()
13118
+ });
13119
+ object({
13120
+ id: string(),
13121
+ userId: string(),
13122
+ name: string(),
13123
+ tokenHash: string(),
13124
+ tokenPrefix: string(),
13125
+ scopes: array(TokenScopeSchema),
13126
+ expiresAt: number().nullish(),
13127
+ lastUsedAt: number().nullish(),
13128
+ createdAt: number()
13129
+ });
13130
+ /** What a share-view grant lets its holder see. */
13131
+ var ShareViewGrantSchema = object({
13132
+ kind: _enum(SHARE_VIEW_KINDS),
13133
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
13134
+ /** Talk-back, opt-in at mint time; absent means off. */
13135
+ talk: boolean().optional()
13136
+ });
13137
+ var ShareViewScopeSchema = object({
13138
+ type: literal("share-view"),
13139
+ grant: ShareViewGrantSchema
13140
+ });
13141
+ var AddonRoutesScopeSchema = object({
13142
+ type: literal("addon-routes"),
13143
+ access: array(MethodAccessSchema).min(1)
13144
+ });
13145
+ var PreferencesSelfScopeSchema = object({ type: literal("preferences-self") });
13146
+ var CredentialScopeSchema = union([
13147
+ literal("*"),
13148
+ ShareViewScopeSchema,
13149
+ AddonRoutesScopeSchema,
13150
+ PreferencesSelfScopeSchema,
13151
+ TokenScopeSchema
13152
+ ]);
13153
+ object({
13154
+ kind: literal("credential"),
13155
+ sub: string().min(1),
13156
+ jti: string().min(16),
13157
+ scopes: array(CredentialScopeSchema).min(1)
13158
+ });
13159
+ var PreferenceNamespaceSchema = string().regex(/^[a-z][a-z0-9.-]{0,63}$/);
13160
+ /** A namespace's value: a JSON object, opaque to the hub. */
13161
+ var PreferenceValueSchema = record(string(), unknown());
13162
+ var PreferenceDeviceIdSchema = string().min(1).max(64);
13163
+ /** A stored row, as the owner reads it. */
13164
+ var PreferenceRowSchema = object({
13165
+ namespace: PreferenceNamespaceSchema,
13166
+ value: PreferenceValueSchema,
13167
+ /** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
13168
+ revision: number().int().positive(),
13169
+ updatedAt: number().int(),
13170
+ /** The client id the last writer sent; `null` when it sent none. */
13171
+ updatedByDevice: PreferenceDeviceIdSchema.nullable()
13172
+ });
13173
+ object({
13174
+ /** Absent: every namespace the caller holds. */
13175
+ namespaces: array(PreferenceNamespaceSchema).max(32).optional() });
13176
+ object({ rows: array(PreferenceRowSchema) });
13177
+ object({
13178
+ namespace: PreferenceNamespaceSchema,
13179
+ value: PreferenceValueSchema,
13180
+ /**
13181
+ * The revision the edit was based on. Absent: last write wins. `0`: the
13182
+ * namespace must not exist yet. Any other value that is not the current
13183
+ * revision answers `conflict` and writes nothing.
13184
+ */
13185
+ baseRevision: number().int().nonnegative().optional(),
13186
+ deviceId: PreferenceDeviceIdSchema.optional()
13187
+ });
13188
+ discriminatedUnion("status", [object({
13189
+ status: literal("saved"),
13190
+ row: PreferenceRowSchema
13191
+ }), object({
13192
+ status: literal("conflict"),
13193
+ current: PreferenceRowSchema.nullable()
13194
+ })]);
13195
+ object({ namespace: PreferenceNamespaceSchema });
13196
+ object({
13197
+ /** `false` when the namespace did not exist. */
13198
+ deleted: boolean() });
13199
+ object({
13200
+ /** The revision the client holds per namespace; a namespace it does not list is new to it. */
13201
+ revisionByNamespace: record(PreferenceNamespaceSchema, number().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
13202
+ object({
13203
+ /** Every row whose revision differs from the client's, and every row it did not list. */
13204
+ rows: array(PreferenceRowSchema),
13205
+ /** Namespaces the client listed that no longer exist. */
13206
+ deleted: array(PreferenceNamespaceSchema)
13207
+ });
13208
+ /**
12929
13209
  * The viewer app's custom-scheme callback — the ONE list of URLs a hub flow
12930
13210
  * may hand a browser back to the native app at.
12931
13211
  *
@@ -40080,38 +40360,37 @@ method(LlmRuntimeCompleteInputSchema, LlmGenerateResultSchema, {
40080
40360
  auth: "admin",
40081
40361
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
40082
40362
  });
40363
+ var LlmProfileKindSchema = string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "a kind id is lower-case letters, digits and dashes");
40364
+ /** What a model (or, by default, every model of a kind) can do. */
40365
+ var LlmModelFeaturesSchema = object({
40366
+ vision: boolean(),
40367
+ tools: boolean(),
40368
+ streaming: boolean()
40369
+ });
40370
+ /** One model a provider offers. `features` overrides the kind's defaults, per field. */
40371
+ var LlmModelInfoSchema = object({
40372
+ id: string(),
40373
+ label: string().optional(),
40374
+ contextLength: number().int().positive().optional(),
40375
+ features: LlmModelFeaturesSchema.partial().optional()
40376
+ });
40083
40377
  /**
40084
- * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
40085
- * methods concat-fan across providers; single-row methods route to ONE
40086
- * provider by the `addonId` in the call input (the notification-output
40087
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
40088
- * (hub-placed); the cap stays open for future providers.
40089
- *
40090
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
40091
- * `apiKey` is a password field — providers REDACT it on read and merge on
40092
- * write; a stored key NEVER round-trips to a client.
40378
+ * The provider-specific part of a profile, validated by the provider that owns
40379
+ * the kind (`upsertProfile` refuses what it does not accept). A field its
40380
+ * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
40381
+ * keychain, never in the row, and reads back as the redaction marker.
40093
40382
  */
40094
- var LlmProfileKindSchema = _enum([
40095
- "openai-compatible",
40096
- "openai",
40097
- "anthropic",
40098
- "google",
40099
- "managed-local",
40100
- "apple-foundation"
40101
- ]);
40383
+ var LlmProviderConfigSchema = record(string(), unknown());
40102
40384
  var LlmProfileSchema = object({
40103
40385
  id: string(),
40104
40386
  name: string(),
40387
+ /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
40105
40388
  kind: LlmProfileKindSchema,
40106
40389
  /** Stamped by the provider — keeps the fanned catalog routable. */
40107
40390
  addonId: string(),
40108
40391
  enabled: boolean(),
40109
40392
  /** Vendor model id, or the managed runtime's loaded model. */
40110
40393
  model: string(),
40111
- /** Required for openai-compatible; override for cloud kinds. */
40112
- baseUrl: string().optional(),
40113
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
40114
- apiKey: string().optional(),
40115
40394
  /** Vision on/off. A vision call against a `false` profile is REFUSED, never
40116
40395
  * degraded to text — that shipped once and produced a confident answer to a
40117
40396
  * question about a picture nobody sent. */
@@ -40119,15 +40398,11 @@ var LlmProfileSchema = object({
40119
40398
  temperature: number().min(0).max(2).optional(),
40120
40399
  /** Nucleus sampling. Every wire we speak has it. */
40121
40400
  topP: number().min(0).max(1).optional(),
40122
- /** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
40123
- * wire does, and the client drops it there (measured: the request body gets
40124
- * `top_p` and no `top_k`). The profile editor hides the field wherever it
40125
- * would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
40401
+ /** Top-k sampling. Carried only by the wires that have it — a kind offers the
40402
+ * field in its editor only when its descriptor lists it in `profileFields`. */
40126
40403
  topK: number().int().positive().optional(),
40127
40404
  maxTokens: number().int().positive().optional(),
40128
- /** Prompt context window. Advisory for cloud kinds (they enforce their own);
40129
- * for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
40130
- * the model with, so it is the one field that changes a PROCESS. */
40405
+ /** Prompt context window. Advisory for cloud kinds (they enforce their own). */
40131
40406
  contextLength: number().int().positive().optional(),
40132
40407
  /** Default system prompt. A caller's `system` REPLACES it (never appends —
40133
40408
  * two system prompts fighting is worse than either alone). */
@@ -40153,16 +40428,37 @@ var LlmProfileSchema = object({
40153
40428
  * library; the REGISTRY of callable tools is ours and is empty in v1, so a
40154
40429
  * `true` here buys the wiring, not behaviour, until tools are registered. */
40155
40430
  toolsEnabled: boolean().default(false),
40156
- extraHeaders: record(string(), string()).optional(),
40157
- /** kind === 'managed-local' only (spec §4). */
40158
- runtime: ManagedRuntimeConfigSchema.optional(),
40159
- /**
40160
- * kind === 'apple-foundation' only: WHERE it runs — the only thing there is
40161
- * to configure (no key, no URL, no download; `model` is `apple-system`).
40162
- * `supportsVision` on such a row is stamped by the provider from the node's
40163
- * reported `imageInput`, never taken from the operator (D62).
40164
- */
40165
- appleFoundation: object({ nodeId: string() }).optional()
40431
+ /** Everything the kind's provider owns (endpoint, key, node, runtime…). */
40432
+ providerConfig: LlmProviderConfigSchema.default({})
40433
+ });
40434
+ /**
40435
+ * The common profile fields a kind's editor offers. The editor owns how each
40436
+ * one is drawn; the provider says which of them mean something on its wire.
40437
+ */
40438
+ var LlmProfileFieldSchema = _enum([
40439
+ "temperature",
40440
+ "topP",
40441
+ "topK",
40442
+ "maxTokens",
40443
+ "contextLength",
40444
+ "systemPrompt",
40445
+ "timeoutMs",
40446
+ "connectTimeoutMs",
40447
+ "firstTokenTimeoutMs",
40448
+ "idleTimeoutMs",
40449
+ "retry",
40450
+ "toolsEnabled"
40451
+ ]);
40452
+ /**
40453
+ * A provider-drawn part of the editor, by a generic widget id the admin UI
40454
+ * registers (`ai/apple-node`). `placement: 'model'` replaces the generic model
40455
+ * picker: that widget owns the model choice.
40456
+ */
40457
+ var LlmProviderWidgetSchema = object({
40458
+ id: string(),
40459
+ placement: _enum(["connection", "model"]),
40460
+ /** `providerConfig` keys this widget must fill before the profile can be saved. */
40461
+ requires: array(string()).optional()
40166
40462
  });
40167
40463
  /** ConfigUISchema tree passed through untyped on the wire (the
40168
40464
  * notification-output `ConfigSchemaPassthrough` precedent at
@@ -40171,11 +40467,56 @@ var ConfigSchemaPassthrough$3 = unknown();
40171
40467
  var LlmProfileKindDescriptorSchema = object({
40172
40468
  kind: LlmProfileKindSchema,
40173
40469
  label: string(),
40470
+ /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
40174
40471
  icon: string(),
40175
40472
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
40176
40473
  addonId: string(),
40177
- configSchema: ConfigSchemaPassthrough$3
40474
+ /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
40475
+ connectionSchema: ConfigSchemaPassthrough$3,
40476
+ /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
40477
+ advancedSchema: ConfigSchemaPassthrough$3.optional(),
40478
+ /** The kind's defaults; a model from `listModels` may override any of them. */
40479
+ features: LlmModelFeaturesSchema,
40480
+ /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
40481
+ visionEditable: boolean(),
40482
+ /** Where the model list comes from: `listModels`, `staticModels`, or nowhere. */
40483
+ modelCatalog: _enum([
40484
+ "fetch",
40485
+ "static",
40486
+ "none"
40487
+ ]),
40488
+ staticModels: array(LlmModelInfoSchema).optional(),
40489
+ /** The common fields that mean something on this kind's wire. */
40490
+ profileFields: array(LlmProfileFieldSchema),
40491
+ providerWidgets: array(LlmProviderWidgetSchema).optional()
40492
+ });
40493
+ /**
40494
+ * `listModels` input. `connection` is an UNSAVED draft of `providerConfig`
40495
+ * (the editor's form); with `profileId` too, a secret the draft leaves
40496
+ * untouched (absent or the redaction marker) is resolved server-side from the
40497
+ * stored profile — the browser never receives it.
40498
+ */
40499
+ var LlmListModelsInputSchema = object({
40500
+ addonId: string(),
40501
+ kind: LlmProfileKindSchema,
40502
+ profileId: string().optional(),
40503
+ connection: LlmProviderConfigSchema.optional()
40178
40504
  });
40505
+ var LlmListModelsErrorCodeSchema = _enum([
40506
+ "auth",
40507
+ "network",
40508
+ "unsupported",
40509
+ "invalid"
40510
+ ]);
40511
+ /** A RESULT, never a throw: "wrong key" is an answer the editor renders inline. */
40512
+ var LlmListModelsResultSchema = discriminatedUnion("ok", [object({
40513
+ ok: literal(true),
40514
+ models: array(LlmModelInfoSchema)
40515
+ }), object({
40516
+ ok: literal(false),
40517
+ code: LlmListModelsErrorCodeSchema,
40518
+ message: string()
40519
+ })]);
40179
40520
  var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
40180
40521
  var LlmDefaultSchema = object({
40181
40522
  selector: LlmDefaultSelectorSchema,
@@ -40275,7 +40616,10 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
40275
40616
  kind: "mutation",
40276
40617
  auth: "admin",
40277
40618
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
40278
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
40619
+ }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
40620
+ kind: "mutation",
40621
+ auth: "admin"
40622
+ }), method(object({}), array(LlmDefaultSchema)), method(object({
40279
40623
  selector: LlmDefaultSelectorSchema,
40280
40624
  profileId: string().nullable()
40281
40625
  }), _void(), {
@@ -44347,202 +44691,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
44347
44691
  auth: "admin"
44348
44692
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
44349
44693
  /**
44350
- * Zod schemas for persisted record types.
44351
- *
44352
- * These schemas serve as the single source of truth for types that are
44353
- * stored in the settings-store backend and retrieved via tRPC. They
44354
- * replace the manual TypeScript interfaces with schema-derived types,
44355
- * enabling runtime validation when reading from the backend.
44356
- *
44357
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
44358
- * keeps the original name for backward compatibility.
44359
- */
44360
- /**
44361
- * Auth model (v2 — 2026-05-12 caps-only):
44362
- *
44363
- * Two principals:
44364
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
44365
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
44366
- *
44367
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44368
- * `super_admin` — collapsed onto the single boolean because every
44369
- * non-admin caller is governed by the same scope-check rules; the
44370
- * distinction was only ever used to route role-specific procedures
44371
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44372
- * with `isAdmin: false` + an explicit scope list.
44373
- */
44374
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44375
- var MethodAccessSchema = _enum([
44376
- "view",
44377
- "create",
44378
- "delete"
44379
- ]);
44380
- /**
44381
- * A single scope grant. Three forms — checked in matcher with OR
44382
- * semantics; the first match decides whether the call passes:
44383
- *
44384
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44385
- * cap with the matching `scope` declaration. New caps inherit grants
44386
- * automatically — adding a device cap to the codebase makes it
44387
- * reachable to every user with `category:device [...]` without a
44388
- * re-grant. Use this for "family viewer" / "operator" tiers.
44389
- *
44390
- * - `addon` — every cap that ships inside a given addon id. Niche;
44391
- * useful when an integration needs to interact with one specific
44392
- * addon's surface regardless of how many caps it exports.
44393
- *
44394
- * - `capability` — the most precise form. Single cap name. Use for
44395
- * integration tokens where you want to grant `addons.installPackage`
44396
- * and nothing else.
44397
- *
44398
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44399
- * "give me everything" escape; there is no wildcard scope.
44400
- */
44401
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44402
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44403
- var CapScopeSchema = _enum(["device", "system"]);
44404
- /**
44405
- * DeviceSelector (scope model v3 — 2026-08-12).
44406
- *
44407
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44408
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44409
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44410
- * AFTER the grant was minted — no re-grant, no re-login.
44411
- *
44412
- * - `all` — every device in the deployment. The broad viewer/operator
44413
- * lever without a `category` grant (a `category` grant also covers device
44414
- * caps that carry no deviceId; `all` is specifically the device set).
44415
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44416
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44417
- * is NOT covered until the grant is edited.
44418
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44419
- * DYNAMIC. A device that changes type, or a new device of the type,
44420
- * re-resolves on the next request.
44421
- * - `locations` — every device whose operator-assigned `location` label is
44422
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44423
- * null/unset location matches NO `locations` selector.
44424
- */
44425
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44426
- object({ kind: literal("all") }),
44427
- object({
44428
- kind: literal("ids"),
44429
- ids: array(number().int()).min(1)
44430
- }),
44431
- object({
44432
- kind: literal("types"),
44433
- types: array(_enum(DeviceType)).min(1)
44434
- }),
44435
- object({
44436
- kind: literal("locations"),
44437
- locations: array(string().min(1)).min(1)
44438
- })
44439
- ]);
44440
- var DeviceTokenScopeSchema = object({
44441
- type: literal("device"),
44442
- /** The device SET this grant covers — resolved against the live fleet. */
44443
- selector: DeviceSelectorSchema,
44444
- access: array(MethodAccessSchema).min(1),
44445
- /**
44446
- * Whether a grant on a PARENT device transparently covers its accessory
44447
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44448
- * Direction is parent → children ONLY.
44449
- *
44450
- * Absent → the matcher DERIVES it from the access flavour: `view`
44451
- * inherits (a camera viewer sees the camera's accessories), `create` /
44452
- * `delete` do NOT (actuating/removing a child is an explicit act the
44453
- * operator must grant on the child, not inherit from the parent). Set it
44454
- * explicitly to override that default per grant.
44455
- */
44456
- includeLinked: boolean().optional()
44457
- });
44458
- /**
44459
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44460
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44461
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44462
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44463
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44464
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44465
- * migration cannot reach a JWT already in a client's hands; parse-time
44466
- * migration covers both without a flag day. No cast — the raw object is read
44467
- * through `Reflect.get` (its static type is `unknown`).
44468
- */
44469
- function migrateLegacyTokenScope(raw) {
44470
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44471
- if (Reflect.get(raw, "type") !== "device") return raw;
44472
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44473
- const targets = Reflect.get(raw, "targets");
44474
- if (!Array.isArray(targets)) return raw;
44475
- return {
44476
- type: "device",
44477
- selector: {
44478
- kind: "ids",
44479
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44480
- },
44481
- access: Reflect.get(raw, "access")
44482
- };
44483
- }
44484
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44485
- object({
44486
- type: literal("category"),
44487
- target: CapScopeSchema,
44488
- access: array(MethodAccessSchema).min(1)
44489
- }),
44490
- object({
44491
- type: literal("capability"),
44492
- target: string(),
44493
- access: array(MethodAccessSchema).min(1)
44494
- }),
44495
- object({
44496
- type: literal("addon"),
44497
- target: string(),
44498
- access: array(MethodAccessSchema).min(1)
44499
- }),
44500
- DeviceTokenScopeSchema
44501
- ]));
44502
- object({
44503
- id: string(),
44504
- username: string(),
44505
- passwordHash: string(),
44506
- /**
44507
- * Admin bypass. When true, the middleware skips the scope-access
44508
- * check entirely. There is no other axis of privilege; the legacy
44509
- * role enum collapsed onto this boolean in v2.
44510
- */
44511
- isAdmin: boolean().default(false),
44512
- allowedProviders: AllowedProviderSchema,
44513
- allowedDevices: AllowedDevicesSchema,
44514
- /**
44515
- * Scopes granted to this user. Admins bypass; their `scopes` is
44516
- * ignored. Non-admins without scopes are locked out of every
44517
- * protected call.
44518
- */
44519
- scopes: array(TokenScopeSchema).default([]),
44520
- createdAt: number(),
44521
- updatedAt: number()
44522
- });
44523
- object({
44524
- id: string(),
44525
- label: string(),
44526
- isAdmin: boolean().default(false),
44527
- allowedProviders: AllowedProviderSchema,
44528
- allowedDevices: AllowedDevicesSchema,
44529
- tokenHash: string(),
44530
- tokenPrefix: string(),
44531
- createdAt: number(),
44532
- lastUsedAt: number().optional()
44533
- });
44534
- object({
44535
- id: string(),
44536
- userId: string(),
44537
- name: string(),
44538
- tokenHash: string(),
44539
- tokenPrefix: string(),
44540
- scopes: array(TokenScopeSchema),
44541
- expiresAt: number().nullish(),
44542
- lastUsedAt: number().nullish(),
44543
- createdAt: number()
44544
- });
44545
- /**
44546
44694
  * `oauth-integration` — a collection cap by which an addon declares
44547
44695
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44548
44696
  * Each provider returns a static descriptor; the core enumerates them
@@ -61525,26 +61673,6 @@ var ApiKeySummarySchema = object({
61525
61673
  createdAt: number(),
61526
61674
  lastUsedAt: number().optional()
61527
61675
  });
61528
- var ScopedTokenSummarySchema = object({
61529
- id: string(),
61530
- userId: string(),
61531
- name: string(),
61532
- tokenPrefix: string(),
61533
- scopes: array(TokenScopeSchema),
61534
- expiresAt: number().nullish(),
61535
- lastUsedAt: number().nullish(),
61536
- createdAt: number()
61537
- });
61538
- var CreateScopedTokenInputSchema = object({
61539
- userId: string(),
61540
- name: string(),
61541
- scopes: array(TokenScopeSchema),
61542
- expiresAt: number().optional()
61543
- });
61544
- var CreateScopedTokenResultSchema = object({
61545
- token: string(),
61546
- record: ScopedTokenSummarySchema
61547
- });
61548
61676
  var OauthSessionSummarySchema = object({
61549
61677
  id: string(),
61550
61678
  userId: string(),
@@ -61566,11 +61694,11 @@ var TotpStatusSchema = object({
61566
61694
  confirmedAt: number().nullable()
61567
61695
  });
61568
61696
  /**
61569
- * user-management — singleton capability for user accounts, API keys,
61570
- * and scoped tokens.
61697
+ * user-management — singleton capability for user accounts and the
61698
+ * legacy API-key rows.
61571
61699
  *
61572
61700
  * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
61573
- * — the subset check on `setUserScopes` / `createScopedToken` is moot
61701
+ * — the subset check on `setUserScopes` is moot
61574
61702
  * because non-admins never reach these. If/when we open non-admin
61575
61703
  * delegation, structural caller-scope subset check goes inside the
61576
61704
  * provider.
@@ -61627,15 +61755,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
61627
61755
  kind: "mutation",
61628
61756
  auth: "admin",
61629
61757
  access: "delete"
61630
- }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
61631
- kind: "mutation",
61632
- auth: "admin",
61633
- access: "create"
61634
- }), method(object({ id: string() }), object({ success: literal(true) }), {
61635
- kind: "mutation",
61636
- auth: "admin",
61637
- access: "delete"
61638
- }), method(object({ token: string() }), ScopedTokenSummarySchema.nullable(), { access: "view" }), method(object({ userId: string() }), array(ScopedTokenSummarySchema), { auth: "admin" }), method(object({ userId: string() }), TotpSetupResultSchema, {
61758
+ }), method(object({ userId: string() }), TotpSetupResultSchema, {
61639
61759
  kind: "mutation",
61640
61760
  auth: "admin",
61641
61761
  access: "create"
@@ -65791,7 +65911,7 @@ Object.freeze({
65791
65911
  capName: "llm",
65792
65912
  capScope: "system",
65793
65913
  addonId: null,
65794
- access: "view"
65914
+ access: "create"
65795
65915
  },
65796
65916
  "llm.listNodeModels": {
65797
65917
  capName: "llm",
@@ -70455,12 +70575,6 @@ Object.freeze({
70455
70575
  addonId: null,
70456
70576
  access: "create"
70457
70577
  },
70458
- "userManagement.createScopedToken": {
70459
- capName: "user-management",
70460
- capScope: "system",
70461
- addonId: null,
70462
- access: "create"
70463
- },
70464
70578
  "userManagement.createUser": {
70465
70579
  capName: "user-management",
70466
70580
  capScope: "system",
@@ -70509,12 +70623,6 @@ Object.freeze({
70509
70623
  addonId: null,
70510
70624
  access: "view"
70511
70625
  },
70512
- "userManagement.listScopedTokens": {
70513
- capName: "user-management",
70514
- capScope: "system",
70515
- addonId: null,
70516
- access: "view"
70517
- },
70518
70626
  "userManagement.listUsers": {
70519
70627
  capName: "user-management",
70520
70628
  capScope: "system",
@@ -70569,12 +70677,6 @@ Object.freeze({
70569
70677
  addonId: null,
70570
70678
  access: "delete"
70571
70679
  },
70572
- "userManagement.revokeScopedToken": {
70573
- capName: "user-management",
70574
- capScope: "system",
70575
- addonId: null,
70576
- access: "delete"
70577
- },
70578
70680
  "userManagement.setupTotp": {
70579
70681
  capName: "user-management",
70580
70682
  capScope: "system",
@@ -70605,12 +70707,6 @@ Object.freeze({
70605
70707
  addonId: null,
70606
70708
  access: "view"
70607
70709
  },
70608
- "userManagement.validateScopedToken": {
70609
- capName: "user-management",
70610
- capScope: "system",
70611
- addonId: null,
70612
- access: "view"
70613
- },
70614
70710
  "userManagement.verifyTotp": {
70615
70711
  capName: "user-management",
70616
70712
  capScope: "system",