@camstack/addon-provider-reolink 1.2.190 → 1.2.192

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/addon.js +390 -294
  2. package/dist/addon.mjs +390 -294
  3. package/package.json +1 -1
package/dist/addon.mjs CHANGED
@@ -5443,7 +5443,7 @@ var ZodIssueCode = {
5443
5443
  var ZodFirstPartyTypeKind;
5444
5444
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5445
5445
  //#endregion
5446
- //#region ../types/dist/sleep-BxjU_fJM.mjs
5446
+ //#region ../types/dist/sleep-yKL5gfrH.mjs
5447
5447
  /**
5448
5448
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5449
5449
  * window to float samples (D455).
@@ -7829,6 +7829,12 @@ function normalizeAddonInitResult(result) {
7829
7829
  if (Array.isArray(result)) return { providers: result };
7830
7830
  return result;
7831
7831
  }
7832
+ /**
7833
+ * The share-view scope kinds a share-link token can carry. The hub mints
7834
+ * and validates them (`ShareViewGrantSchema` builds its
7835
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
7836
+ */
7837
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7832
7838
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7833
7839
  var PeerBytesTicketSchema = object({
7834
7840
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -13108,6 +13114,280 @@ var ConvertResultSchema = object({
13108
13114
  files: array(string()).readonly()
13109
13115
  })).readonly()
13110
13116
  });
13117
+ /**
13118
+ * Zod schemas for persisted record types.
13119
+ *
13120
+ * These schemas serve as the single source of truth for types that are
13121
+ * stored in the settings-store backend and retrieved via tRPC. They
13122
+ * replace the manual TypeScript interfaces with schema-derived types,
13123
+ * enabling runtime validation when reading from the backend.
13124
+ *
13125
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
13126
+ * keeps the original name for backward compatibility.
13127
+ */
13128
+ /**
13129
+ * Auth model (v2 — 2026-05-12 caps-only):
13130
+ *
13131
+ * Two principals:
13132
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
13133
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
13134
+ *
13135
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
13136
+ * `super_admin` — collapsed onto the single boolean because every
13137
+ * non-admin caller is governed by the same scope-check rules; the
13138
+ * distinction was only ever used to route role-specific procedures
13139
+ * which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
13140
+ * with `isAdmin: false` + an explicit scope list.
13141
+ */
13142
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
13143
+ var MethodAccessSchema = _enum([
13144
+ "view",
13145
+ "create",
13146
+ "delete"
13147
+ ]);
13148
+ /**
13149
+ * A single scope grant. Three forms — checked in matcher with OR
13150
+ * semantics; the first match decides whether the call passes:
13151
+ *
13152
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
13153
+ * cap with the matching `scope` declaration. New caps inherit grants
13154
+ * automatically — adding a device cap to the codebase makes it
13155
+ * reachable to every user with `category:device [...]` without a
13156
+ * re-grant. Use this for "family viewer" / "operator" tiers.
13157
+ *
13158
+ * - `addon` — every cap that ships inside a given addon id. Niche;
13159
+ * useful when an integration needs to interact with one specific
13160
+ * addon's surface regardless of how many caps it exports.
13161
+ *
13162
+ * - `capability` — the most precise form. Single cap name. Use for
13163
+ * integration tokens where you want to grant `addons.installPackage`
13164
+ * and nothing else.
13165
+ *
13166
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
13167
+ * "give me everything" escape; there is no wildcard scope.
13168
+ */
13169
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
13170
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
13171
+ var CapScopeSchema = _enum(["device", "system"]);
13172
+ /**
13173
+ * DeviceSelector (scope model v3 — 2026-08-12).
13174
+ *
13175
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
13176
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
13177
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
13178
+ * AFTER the grant was minted — no re-grant, no re-login.
13179
+ *
13180
+ * - `all` — every device in the deployment. The broad viewer/operator
13181
+ * lever without a `category` grant (a `category` grant also covers device
13182
+ * caps that carry no deviceId; `all` is specifically the device set).
13183
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
13184
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
13185
+ * is NOT covered until the grant is edited.
13186
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
13187
+ * DYNAMIC. A device that changes type, or a new device of the type,
13188
+ * re-resolves on the next request.
13189
+ * - `locations` — every device whose operator-assigned `location` label is
13190
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
13191
+ * null/unset location matches NO `locations` selector.
13192
+ */
13193
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
13194
+ object({ kind: literal("all") }),
13195
+ object({
13196
+ kind: literal("ids"),
13197
+ ids: array(number().int()).min(1)
13198
+ }),
13199
+ object({
13200
+ kind: literal("types"),
13201
+ types: array(_enum(DeviceType)).min(1)
13202
+ }),
13203
+ object({
13204
+ kind: literal("locations"),
13205
+ locations: array(string().min(1)).min(1)
13206
+ })
13207
+ ]);
13208
+ var DeviceTokenScopeSchema = object({
13209
+ type: literal("device"),
13210
+ /** The device SET this grant covers — resolved against the live fleet. */
13211
+ selector: DeviceSelectorSchema,
13212
+ access: array(MethodAccessSchema).min(1),
13213
+ /**
13214
+ * Whether a grant on a PARENT device transparently covers its accessory
13215
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
13216
+ * Direction is parent → children ONLY.
13217
+ *
13218
+ * Absent → the matcher DERIVES it from the access flavour: `view`
13219
+ * inherits (a camera viewer sees the camera's accessories), `create` /
13220
+ * `delete` do NOT (actuating/removing a child is an explicit act the
13221
+ * operator must grant on the child, not inherit from the parent). Set it
13222
+ * explicitly to override that default per grant.
13223
+ */
13224
+ includeLinked: boolean().optional()
13225
+ });
13226
+ /**
13227
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
13228
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
13229
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
13230
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
13231
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
13232
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
13233
+ * migration cannot reach a JWT already in a client's hands; parse-time
13234
+ * migration covers both without a flag day. No cast — the raw object is read
13235
+ * through `Reflect.get` (its static type is `unknown`).
13236
+ */
13237
+ function migrateLegacyTokenScope(raw) {
13238
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
13239
+ if (Reflect.get(raw, "type") !== "device") return raw;
13240
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
13241
+ const targets = Reflect.get(raw, "targets");
13242
+ if (!Array.isArray(targets)) return raw;
13243
+ return {
13244
+ type: "device",
13245
+ selector: {
13246
+ kind: "ids",
13247
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
13248
+ },
13249
+ access: Reflect.get(raw, "access")
13250
+ };
13251
+ }
13252
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
13253
+ object({
13254
+ type: literal("category"),
13255
+ target: CapScopeSchema,
13256
+ access: array(MethodAccessSchema).min(1)
13257
+ }),
13258
+ object({
13259
+ type: literal("capability"),
13260
+ target: string(),
13261
+ access: array(MethodAccessSchema).min(1)
13262
+ }),
13263
+ object({
13264
+ type: literal("addon"),
13265
+ target: string(),
13266
+ access: array(MethodAccessSchema).min(1)
13267
+ }),
13268
+ DeviceTokenScopeSchema
13269
+ ]));
13270
+ object({
13271
+ id: string(),
13272
+ username: string(),
13273
+ passwordHash: string(),
13274
+ /**
13275
+ * Admin bypass. When true, the middleware skips the scope-access
13276
+ * check entirely. There is no other axis of privilege; the legacy
13277
+ * role enum collapsed onto this boolean in v2.
13278
+ */
13279
+ isAdmin: boolean().default(false),
13280
+ allowedProviders: AllowedProviderSchema,
13281
+ allowedDevices: AllowedDevicesSchema,
13282
+ /**
13283
+ * Scopes granted to this user. Admins bypass; their `scopes` is
13284
+ * ignored. Non-admins without scopes are locked out of every
13285
+ * protected call.
13286
+ */
13287
+ scopes: array(TokenScopeSchema).default([]),
13288
+ createdAt: number(),
13289
+ updatedAt: number()
13290
+ });
13291
+ object({
13292
+ id: string(),
13293
+ label: string(),
13294
+ isAdmin: boolean().default(false),
13295
+ allowedProviders: AllowedProviderSchema,
13296
+ allowedDevices: AllowedDevicesSchema,
13297
+ tokenHash: string(),
13298
+ tokenPrefix: string(),
13299
+ createdAt: number(),
13300
+ lastUsedAt: number().optional()
13301
+ });
13302
+ object({
13303
+ id: string(),
13304
+ userId: string(),
13305
+ name: string(),
13306
+ tokenHash: string(),
13307
+ tokenPrefix: string(),
13308
+ scopes: array(TokenScopeSchema),
13309
+ expiresAt: number().nullish(),
13310
+ lastUsedAt: number().nullish(),
13311
+ createdAt: number()
13312
+ });
13313
+ /** What a share-view grant lets its holder see. */
13314
+ var ShareViewGrantSchema = object({
13315
+ kind: _enum(SHARE_VIEW_KINDS),
13316
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
13317
+ /** Talk-back, opt-in at mint time; absent means off. */
13318
+ talk: boolean().optional()
13319
+ });
13320
+ var ShareViewScopeSchema = object({
13321
+ type: literal("share-view"),
13322
+ grant: ShareViewGrantSchema
13323
+ });
13324
+ var AddonRoutesScopeSchema = object({
13325
+ type: literal("addon-routes"),
13326
+ access: array(MethodAccessSchema).min(1)
13327
+ });
13328
+ var PreferencesSelfScopeSchema = object({ type: literal("preferences-self") });
13329
+ var CredentialScopeSchema = union([
13330
+ literal("*"),
13331
+ ShareViewScopeSchema,
13332
+ AddonRoutesScopeSchema,
13333
+ PreferencesSelfScopeSchema,
13334
+ TokenScopeSchema
13335
+ ]);
13336
+ object({
13337
+ kind: literal("credential"),
13338
+ sub: string().min(1),
13339
+ jti: string().min(16),
13340
+ scopes: array(CredentialScopeSchema).min(1)
13341
+ });
13342
+ var PreferenceNamespaceSchema = string().regex(/^[a-z][a-z0-9.-]{0,63}$/);
13343
+ /** A namespace's value: a JSON object, opaque to the hub. */
13344
+ var PreferenceValueSchema = record(string(), unknown());
13345
+ var PreferenceDeviceIdSchema = string().min(1).max(64);
13346
+ /** A stored row, as the owner reads it. */
13347
+ var PreferenceRowSchema = object({
13348
+ namespace: PreferenceNamespaceSchema,
13349
+ value: PreferenceValueSchema,
13350
+ /** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
13351
+ revision: number().int().positive(),
13352
+ updatedAt: number().int(),
13353
+ /** The client id the last writer sent; `null` when it sent none. */
13354
+ updatedByDevice: PreferenceDeviceIdSchema.nullable()
13355
+ });
13356
+ object({
13357
+ /** Absent: every namespace the caller holds. */
13358
+ namespaces: array(PreferenceNamespaceSchema).max(32).optional() });
13359
+ object({ rows: array(PreferenceRowSchema) });
13360
+ object({
13361
+ namespace: PreferenceNamespaceSchema,
13362
+ value: PreferenceValueSchema,
13363
+ /**
13364
+ * The revision the edit was based on. Absent: last write wins. `0`: the
13365
+ * namespace must not exist yet. Any other value that is not the current
13366
+ * revision answers `conflict` and writes nothing.
13367
+ */
13368
+ baseRevision: number().int().nonnegative().optional(),
13369
+ deviceId: PreferenceDeviceIdSchema.optional()
13370
+ });
13371
+ discriminatedUnion("status", [object({
13372
+ status: literal("saved"),
13373
+ row: PreferenceRowSchema
13374
+ }), object({
13375
+ status: literal("conflict"),
13376
+ current: PreferenceRowSchema.nullable()
13377
+ })]);
13378
+ object({ namespace: PreferenceNamespaceSchema });
13379
+ object({
13380
+ /** `false` when the namespace did not exist. */
13381
+ deleted: boolean() });
13382
+ object({
13383
+ /** The revision the client holds per namespace; a namespace it does not list is new to it. */
13384
+ revisionByNamespace: record(PreferenceNamespaceSchema, number().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
13385
+ object({
13386
+ /** Every row whose revision differs from the client's, and every row it did not list. */
13387
+ rows: array(PreferenceRowSchema),
13388
+ /** Namespaces the client listed that no longer exist. */
13389
+ deleted: array(PreferenceNamespaceSchema)
13390
+ });
13111
13391
  _enum(["new-session", "step-up"]);
13112
13392
  /** The languages the hub's app landing pages are written in (D858). */
13113
13393
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -40416,38 +40696,37 @@ method(LlmRuntimeCompleteInputSchema, LlmGenerateResultSchema, {
40416
40696
  auth: "admin",
40417
40697
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
40418
40698
  });
40699
+ var LlmProfileKindSchema = string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "a kind id is lower-case letters, digits and dashes");
40700
+ /** What a model (or, by default, every model of a kind) can do. */
40701
+ var LlmModelFeaturesSchema = object({
40702
+ vision: boolean(),
40703
+ tools: boolean(),
40704
+ streaming: boolean()
40705
+ });
40706
+ /** One model a provider offers. `features` overrides the kind's defaults, per field. */
40707
+ var LlmModelInfoSchema = object({
40708
+ id: string(),
40709
+ label: string().optional(),
40710
+ contextLength: number().int().positive().optional(),
40711
+ features: LlmModelFeaturesSchema.partial().optional()
40712
+ });
40419
40713
  /**
40420
- * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
40421
- * methods concat-fan across providers; single-row methods route to ONE
40422
- * provider by the `addonId` in the call input (the notification-output
40423
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
40424
- * (hub-placed); the cap stays open for future providers.
40425
- *
40426
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
40427
- * `apiKey` is a password field — providers REDACT it on read and merge on
40428
- * write; a stored key NEVER round-trips to a client.
40714
+ * The provider-specific part of a profile, validated by the provider that owns
40715
+ * the kind (`upsertProfile` refuses what it does not accept). A field its
40716
+ * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
40717
+ * keychain, never in the row, and reads back as the redaction marker.
40429
40718
  */
40430
- var LlmProfileKindSchema = _enum([
40431
- "openai-compatible",
40432
- "openai",
40433
- "anthropic",
40434
- "google",
40435
- "managed-local",
40436
- "apple-foundation"
40437
- ]);
40719
+ var LlmProviderConfigSchema = record(string(), unknown());
40438
40720
  var LlmProfileSchema = object({
40439
40721
  id: string(),
40440
40722
  name: string(),
40723
+ /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
40441
40724
  kind: LlmProfileKindSchema,
40442
40725
  /** Stamped by the provider — keeps the fanned catalog routable. */
40443
40726
  addonId: string(),
40444
40727
  enabled: boolean(),
40445
40728
  /** Vendor model id, or the managed runtime's loaded model. */
40446
40729
  model: string(),
40447
- /** Required for openai-compatible; override for cloud kinds. */
40448
- baseUrl: string().optional(),
40449
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
40450
- apiKey: string().optional(),
40451
40730
  /** Vision on/off. A vision call against a `false` profile is REFUSED, never
40452
40731
  * degraded to text — that shipped once and produced a confident answer to a
40453
40732
  * question about a picture nobody sent. */
@@ -40455,15 +40734,11 @@ var LlmProfileSchema = object({
40455
40734
  temperature: number().min(0).max(2).optional(),
40456
40735
  /** Nucleus sampling. Every wire we speak has it. */
40457
40736
  topP: number().min(0).max(1).optional(),
40458
- /** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
40459
- * wire does, and the client drops it there (measured: the request body gets
40460
- * `top_p` and no `top_k`). The profile editor hides the field wherever it
40461
- * would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
40737
+ /** Top-k sampling. Carried only by the wires that have it — a kind offers the
40738
+ * field in its editor only when its descriptor lists it in `profileFields`. */
40462
40739
  topK: number().int().positive().optional(),
40463
40740
  maxTokens: number().int().positive().optional(),
40464
- /** Prompt context window. Advisory for cloud kinds (they enforce their own);
40465
- * for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
40466
- * the model with, so it is the one field that changes a PROCESS. */
40741
+ /** Prompt context window. Advisory for cloud kinds (they enforce their own). */
40467
40742
  contextLength: number().int().positive().optional(),
40468
40743
  /** Default system prompt. A caller's `system` REPLACES it (never appends —
40469
40744
  * two system prompts fighting is worse than either alone). */
@@ -40489,16 +40764,37 @@ var LlmProfileSchema = object({
40489
40764
  * library; the REGISTRY of callable tools is ours and is empty in v1, so a
40490
40765
  * `true` here buys the wiring, not behaviour, until tools are registered. */
40491
40766
  toolsEnabled: boolean().default(false),
40492
- extraHeaders: record(string(), string()).optional(),
40493
- /** kind === 'managed-local' only (spec §4). */
40494
- runtime: ManagedRuntimeConfigSchema.optional(),
40495
- /**
40496
- * kind === 'apple-foundation' only: WHERE it runs — the only thing there is
40497
- * to configure (no key, no URL, no download; `model` is `apple-system`).
40498
- * `supportsVision` on such a row is stamped by the provider from the node's
40499
- * reported `imageInput`, never taken from the operator (D62).
40500
- */
40501
- appleFoundation: object({ nodeId: string() }).optional()
40767
+ /** Everything the kind's provider owns (endpoint, key, node, runtime…). */
40768
+ providerConfig: LlmProviderConfigSchema.default({})
40769
+ });
40770
+ /**
40771
+ * The common profile fields a kind's editor offers. The editor owns how each
40772
+ * one is drawn; the provider says which of them mean something on its wire.
40773
+ */
40774
+ var LlmProfileFieldSchema = _enum([
40775
+ "temperature",
40776
+ "topP",
40777
+ "topK",
40778
+ "maxTokens",
40779
+ "contextLength",
40780
+ "systemPrompt",
40781
+ "timeoutMs",
40782
+ "connectTimeoutMs",
40783
+ "firstTokenTimeoutMs",
40784
+ "idleTimeoutMs",
40785
+ "retry",
40786
+ "toolsEnabled"
40787
+ ]);
40788
+ /**
40789
+ * A provider-drawn part of the editor, by a generic widget id the admin UI
40790
+ * registers (`ai/apple-node`). `placement: 'model'` replaces the generic model
40791
+ * picker: that widget owns the model choice.
40792
+ */
40793
+ var LlmProviderWidgetSchema = object({
40794
+ id: string(),
40795
+ placement: _enum(["connection", "model"]),
40796
+ /** `providerConfig` keys this widget must fill before the profile can be saved. */
40797
+ requires: array(string()).optional()
40502
40798
  });
40503
40799
  /** ConfigUISchema tree passed through untyped on the wire (the
40504
40800
  * notification-output `ConfigSchemaPassthrough` precedent at
@@ -40507,11 +40803,56 @@ var ConfigSchemaPassthrough$3 = unknown();
40507
40803
  var LlmProfileKindDescriptorSchema = object({
40508
40804
  kind: LlmProfileKindSchema,
40509
40805
  label: string(),
40806
+ /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
40510
40807
  icon: string(),
40511
40808
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
40512
40809
  addonId: string(),
40513
- configSchema: ConfigSchemaPassthrough$3
40810
+ /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
40811
+ connectionSchema: ConfigSchemaPassthrough$3,
40812
+ /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
40813
+ advancedSchema: ConfigSchemaPassthrough$3.optional(),
40814
+ /** The kind's defaults; a model from `listModels` may override any of them. */
40815
+ features: LlmModelFeaturesSchema,
40816
+ /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
40817
+ visionEditable: boolean(),
40818
+ /** Where the model list comes from: `listModels`, `staticModels`, or nowhere. */
40819
+ modelCatalog: _enum([
40820
+ "fetch",
40821
+ "static",
40822
+ "none"
40823
+ ]),
40824
+ staticModels: array(LlmModelInfoSchema).optional(),
40825
+ /** The common fields that mean something on this kind's wire. */
40826
+ profileFields: array(LlmProfileFieldSchema),
40827
+ providerWidgets: array(LlmProviderWidgetSchema).optional()
40828
+ });
40829
+ /**
40830
+ * `listModels` input. `connection` is an UNSAVED draft of `providerConfig`
40831
+ * (the editor's form); with `profileId` too, a secret the draft leaves
40832
+ * untouched (absent or the redaction marker) is resolved server-side from the
40833
+ * stored profile — the browser never receives it.
40834
+ */
40835
+ var LlmListModelsInputSchema = object({
40836
+ addonId: string(),
40837
+ kind: LlmProfileKindSchema,
40838
+ profileId: string().optional(),
40839
+ connection: LlmProviderConfigSchema.optional()
40514
40840
  });
40841
+ var LlmListModelsErrorCodeSchema = _enum([
40842
+ "auth",
40843
+ "network",
40844
+ "unsupported",
40845
+ "invalid"
40846
+ ]);
40847
+ /** A RESULT, never a throw: "wrong key" is an answer the editor renders inline. */
40848
+ var LlmListModelsResultSchema = discriminatedUnion("ok", [object({
40849
+ ok: literal(true),
40850
+ models: array(LlmModelInfoSchema)
40851
+ }), object({
40852
+ ok: literal(false),
40853
+ code: LlmListModelsErrorCodeSchema,
40854
+ message: string()
40855
+ })]);
40515
40856
  var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
40516
40857
  var LlmDefaultSchema = object({
40517
40858
  selector: LlmDefaultSelectorSchema,
@@ -40611,7 +40952,10 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
40611
40952
  kind: "mutation",
40612
40953
  auth: "admin",
40613
40954
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
40614
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
40955
+ }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
40956
+ kind: "mutation",
40957
+ auth: "admin"
40958
+ }), method(object({}), array(LlmDefaultSchema)), method(object({
40615
40959
  selector: LlmDefaultSelectorSchema,
40616
40960
  profileId: string().nullable()
40617
40961
  }), _void(), {
@@ -44738,202 +45082,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
44738
45082
  auth: "admin"
44739
45083
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
44740
45084
  /**
44741
- * Zod schemas for persisted record types.
44742
- *
44743
- * These schemas serve as the single source of truth for types that are
44744
- * stored in the settings-store backend and retrieved via tRPC. They
44745
- * replace the manual TypeScript interfaces with schema-derived types,
44746
- * enabling runtime validation when reading from the backend.
44747
- *
44748
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
44749
- * keeps the original name for backward compatibility.
44750
- */
44751
- /**
44752
- * Auth model (v2 — 2026-05-12 caps-only):
44753
- *
44754
- * Two principals:
44755
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
44756
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
44757
- *
44758
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44759
- * `super_admin` — collapsed onto the single boolean because every
44760
- * non-admin caller is governed by the same scope-check rules; the
44761
- * distinction was only ever used to route role-specific procedures
44762
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44763
- * with `isAdmin: false` + an explicit scope list.
44764
- */
44765
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44766
- var MethodAccessSchema = _enum([
44767
- "view",
44768
- "create",
44769
- "delete"
44770
- ]);
44771
- /**
44772
- * A single scope grant. Three forms — checked in matcher with OR
44773
- * semantics; the first match decides whether the call passes:
44774
- *
44775
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44776
- * cap with the matching `scope` declaration. New caps inherit grants
44777
- * automatically — adding a device cap to the codebase makes it
44778
- * reachable to every user with `category:device [...]` without a
44779
- * re-grant. Use this for "family viewer" / "operator" tiers.
44780
- *
44781
- * - `addon` — every cap that ships inside a given addon id. Niche;
44782
- * useful when an integration needs to interact with one specific
44783
- * addon's surface regardless of how many caps it exports.
44784
- *
44785
- * - `capability` — the most precise form. Single cap name. Use for
44786
- * integration tokens where you want to grant `addons.installPackage`
44787
- * and nothing else.
44788
- *
44789
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44790
- * "give me everything" escape; there is no wildcard scope.
44791
- */
44792
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44793
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44794
- var CapScopeSchema = _enum(["device", "system"]);
44795
- /**
44796
- * DeviceSelector (scope model v3 — 2026-08-12).
44797
- *
44798
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44799
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44800
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44801
- * AFTER the grant was minted — no re-grant, no re-login.
44802
- *
44803
- * - `all` — every device in the deployment. The broad viewer/operator
44804
- * lever without a `category` grant (a `category` grant also covers device
44805
- * caps that carry no deviceId; `all` is specifically the device set).
44806
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44807
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44808
- * is NOT covered until the grant is edited.
44809
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44810
- * DYNAMIC. A device that changes type, or a new device of the type,
44811
- * re-resolves on the next request.
44812
- * - `locations` — every device whose operator-assigned `location` label is
44813
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44814
- * null/unset location matches NO `locations` selector.
44815
- */
44816
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44817
- object({ kind: literal("all") }),
44818
- object({
44819
- kind: literal("ids"),
44820
- ids: array(number().int()).min(1)
44821
- }),
44822
- object({
44823
- kind: literal("types"),
44824
- types: array(_enum(DeviceType)).min(1)
44825
- }),
44826
- object({
44827
- kind: literal("locations"),
44828
- locations: array(string().min(1)).min(1)
44829
- })
44830
- ]);
44831
- var DeviceTokenScopeSchema = object({
44832
- type: literal("device"),
44833
- /** The device SET this grant covers — resolved against the live fleet. */
44834
- selector: DeviceSelectorSchema,
44835
- access: array(MethodAccessSchema).min(1),
44836
- /**
44837
- * Whether a grant on a PARENT device transparently covers its accessory
44838
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44839
- * Direction is parent → children ONLY.
44840
- *
44841
- * Absent → the matcher DERIVES it from the access flavour: `view`
44842
- * inherits (a camera viewer sees the camera's accessories), `create` /
44843
- * `delete` do NOT (actuating/removing a child is an explicit act the
44844
- * operator must grant on the child, not inherit from the parent). Set it
44845
- * explicitly to override that default per grant.
44846
- */
44847
- includeLinked: boolean().optional()
44848
- });
44849
- /**
44850
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44851
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44852
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44853
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44854
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44855
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44856
- * migration cannot reach a JWT already in a client's hands; parse-time
44857
- * migration covers both without a flag day. No cast — the raw object is read
44858
- * through `Reflect.get` (its static type is `unknown`).
44859
- */
44860
- function migrateLegacyTokenScope(raw) {
44861
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44862
- if (Reflect.get(raw, "type") !== "device") return raw;
44863
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44864
- const targets = Reflect.get(raw, "targets");
44865
- if (!Array.isArray(targets)) return raw;
44866
- return {
44867
- type: "device",
44868
- selector: {
44869
- kind: "ids",
44870
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44871
- },
44872
- access: Reflect.get(raw, "access")
44873
- };
44874
- }
44875
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44876
- object({
44877
- type: literal("category"),
44878
- target: CapScopeSchema,
44879
- access: array(MethodAccessSchema).min(1)
44880
- }),
44881
- object({
44882
- type: literal("capability"),
44883
- target: string(),
44884
- access: array(MethodAccessSchema).min(1)
44885
- }),
44886
- object({
44887
- type: literal("addon"),
44888
- target: string(),
44889
- access: array(MethodAccessSchema).min(1)
44890
- }),
44891
- DeviceTokenScopeSchema
44892
- ]));
44893
- object({
44894
- id: string(),
44895
- username: string(),
44896
- passwordHash: string(),
44897
- /**
44898
- * Admin bypass. When true, the middleware skips the scope-access
44899
- * check entirely. There is no other axis of privilege; the legacy
44900
- * role enum collapsed onto this boolean in v2.
44901
- */
44902
- isAdmin: boolean().default(false),
44903
- allowedProviders: AllowedProviderSchema,
44904
- allowedDevices: AllowedDevicesSchema,
44905
- /**
44906
- * Scopes granted to this user. Admins bypass; their `scopes` is
44907
- * ignored. Non-admins without scopes are locked out of every
44908
- * protected call.
44909
- */
44910
- scopes: array(TokenScopeSchema).default([]),
44911
- createdAt: number(),
44912
- updatedAt: number()
44913
- });
44914
- object({
44915
- id: string(),
44916
- label: string(),
44917
- isAdmin: boolean().default(false),
44918
- allowedProviders: AllowedProviderSchema,
44919
- allowedDevices: AllowedDevicesSchema,
44920
- tokenHash: string(),
44921
- tokenPrefix: string(),
44922
- createdAt: number(),
44923
- lastUsedAt: number().optional()
44924
- });
44925
- object({
44926
- id: string(),
44927
- userId: string(),
44928
- name: string(),
44929
- tokenHash: string(),
44930
- tokenPrefix: string(),
44931
- scopes: array(TokenScopeSchema),
44932
- expiresAt: number().nullish(),
44933
- lastUsedAt: number().nullish(),
44934
- createdAt: number()
44935
- });
44936
- /**
44937
45085
  * `oauth-integration` — a collection cap by which an addon declares
44938
45086
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44939
45087
  * Each provider returns a static descriptor; the core enumerates them
@@ -65808,26 +65956,6 @@ var ApiKeySummarySchema = object({
65808
65956
  createdAt: number(),
65809
65957
  lastUsedAt: number().optional()
65810
65958
  });
65811
- var ScopedTokenSummarySchema = object({
65812
- id: string(),
65813
- userId: string(),
65814
- name: string(),
65815
- tokenPrefix: string(),
65816
- scopes: array(TokenScopeSchema),
65817
- expiresAt: number().nullish(),
65818
- lastUsedAt: number().nullish(),
65819
- createdAt: number()
65820
- });
65821
- var CreateScopedTokenInputSchema = object({
65822
- userId: string(),
65823
- name: string(),
65824
- scopes: array(TokenScopeSchema),
65825
- expiresAt: number().optional()
65826
- });
65827
- var CreateScopedTokenResultSchema = object({
65828
- token: string(),
65829
- record: ScopedTokenSummarySchema
65830
- });
65831
65959
  var OauthSessionSummarySchema = object({
65832
65960
  id: string(),
65833
65961
  userId: string(),
@@ -65849,11 +65977,11 @@ var TotpStatusSchema = object({
65849
65977
  confirmedAt: number().nullable()
65850
65978
  });
65851
65979
  /**
65852
- * user-management — singleton capability for user accounts, API keys,
65853
- * and scoped tokens.
65980
+ * user-management — singleton capability for user accounts and the
65981
+ * legacy API-key rows.
65854
65982
  *
65855
65983
  * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
65856
- * — the subset check on `setUserScopes` / `createScopedToken` is moot
65984
+ * — the subset check on `setUserScopes` is moot
65857
65985
  * because non-admins never reach these. If/when we open non-admin
65858
65986
  * delegation, structural caller-scope subset check goes inside the
65859
65987
  * provider.
@@ -65910,15 +66038,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
65910
66038
  kind: "mutation",
65911
66039
  auth: "admin",
65912
66040
  access: "delete"
65913
- }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
65914
- kind: "mutation",
65915
- auth: "admin",
65916
- access: "create"
65917
- }), method(object({ id: string() }), object({ success: literal(true) }), {
65918
- kind: "mutation",
65919
- auth: "admin",
65920
- access: "delete"
65921
- }), method(object({ token: string() }), ScopedTokenSummarySchema.nullable(), { access: "view" }), method(object({ userId: string() }), array(ScopedTokenSummarySchema), { auth: "admin" }), method(object({ userId: string() }), TotpSetupResultSchema, {
66041
+ }), method(object({ userId: string() }), TotpSetupResultSchema, {
65922
66042
  kind: "mutation",
65923
66043
  auth: "admin",
65924
66044
  access: "create"
@@ -72023,7 +72143,7 @@ Object.freeze({
72023
72143
  capName: "llm",
72024
72144
  capScope: "system",
72025
72145
  addonId: null,
72026
- access: "view"
72146
+ access: "create"
72027
72147
  },
72028
72148
  "llm.listNodeModels": {
72029
72149
  capName: "llm",
@@ -76687,12 +76807,6 @@ Object.freeze({
76687
76807
  addonId: null,
76688
76808
  access: "create"
76689
76809
  },
76690
- "userManagement.createScopedToken": {
76691
- capName: "user-management",
76692
- capScope: "system",
76693
- addonId: null,
76694
- access: "create"
76695
- },
76696
76810
  "userManagement.createUser": {
76697
76811
  capName: "user-management",
76698
76812
  capScope: "system",
@@ -76741,12 +76855,6 @@ Object.freeze({
76741
76855
  addonId: null,
76742
76856
  access: "view"
76743
76857
  },
76744
- "userManagement.listScopedTokens": {
76745
- capName: "user-management",
76746
- capScope: "system",
76747
- addonId: null,
76748
- access: "view"
76749
- },
76750
76858
  "userManagement.listUsers": {
76751
76859
  capName: "user-management",
76752
76860
  capScope: "system",
@@ -76801,12 +76909,6 @@ Object.freeze({
76801
76909
  addonId: null,
76802
76910
  access: "delete"
76803
76911
  },
76804
- "userManagement.revokeScopedToken": {
76805
- capName: "user-management",
76806
- capScope: "system",
76807
- addonId: null,
76808
- access: "delete"
76809
- },
76810
76912
  "userManagement.setupTotp": {
76811
76913
  capName: "user-management",
76812
76914
  capScope: "system",
@@ -76837,12 +76939,6 @@ Object.freeze({
76837
76939
  addonId: null,
76838
76940
  access: "view"
76839
76941
  },
76840
- "userManagement.validateScopedToken": {
76841
- capName: "user-management",
76842
- capScope: "system",
76843
- addonId: null,
76844
- access: "view"
76845
- },
76846
76942
  "userManagement.verifyTotp": {
76847
76943
  capName: "user-management",
76848
76944
  capScope: "system",