@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.js CHANGED
@@ -5451,7 +5451,7 @@ var ZodIssueCode = {
5451
5451
  var ZodFirstPartyTypeKind;
5452
5452
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5453
5453
  //#endregion
5454
- //#region ../types/dist/sleep-BxjU_fJM.mjs
5454
+ //#region ../types/dist/sleep-yKL5gfrH.mjs
5455
5455
  /**
5456
5456
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5457
5457
  * window to float samples (D455).
@@ -7837,6 +7837,12 @@ function normalizeAddonInitResult(result) {
7837
7837
  if (Array.isArray(result)) return { providers: result };
7838
7838
  return result;
7839
7839
  }
7840
+ /**
7841
+ * The share-view scope kinds a share-link token can carry. The hub mints
7842
+ * and validates them (`ShareViewGrantSchema` builds its
7843
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
7844
+ */
7845
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7840
7846
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7841
7847
  var PeerBytesTicketSchema = object({
7842
7848
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -13116,6 +13122,280 @@ var ConvertResultSchema = object({
13116
13122
  files: array(string()).readonly()
13117
13123
  })).readonly()
13118
13124
  });
13125
+ /**
13126
+ * Zod schemas for persisted record types.
13127
+ *
13128
+ * These schemas serve as the single source of truth for types that are
13129
+ * stored in the settings-store backend and retrieved via tRPC. They
13130
+ * replace the manual TypeScript interfaces with schema-derived types,
13131
+ * enabling runtime validation when reading from the backend.
13132
+ *
13133
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
13134
+ * keeps the original name for backward compatibility.
13135
+ */
13136
+ /**
13137
+ * Auth model (v2 — 2026-05-12 caps-only):
13138
+ *
13139
+ * Two principals:
13140
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
13141
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
13142
+ *
13143
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
13144
+ * `super_admin` — collapsed onto the single boolean because every
13145
+ * non-admin caller is governed by the same scope-check rules; the
13146
+ * distinction was only ever used to route role-specific procedures
13147
+ * which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
13148
+ * with `isAdmin: false` + an explicit scope list.
13149
+ */
13150
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
13151
+ var MethodAccessSchema = _enum([
13152
+ "view",
13153
+ "create",
13154
+ "delete"
13155
+ ]);
13156
+ /**
13157
+ * A single scope grant. Three forms — checked in matcher with OR
13158
+ * semantics; the first match decides whether the call passes:
13159
+ *
13160
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
13161
+ * cap with the matching `scope` declaration. New caps inherit grants
13162
+ * automatically — adding a device cap to the codebase makes it
13163
+ * reachable to every user with `category:device [...]` without a
13164
+ * re-grant. Use this for "family viewer" / "operator" tiers.
13165
+ *
13166
+ * - `addon` — every cap that ships inside a given addon id. Niche;
13167
+ * useful when an integration needs to interact with one specific
13168
+ * addon's surface regardless of how many caps it exports.
13169
+ *
13170
+ * - `capability` — the most precise form. Single cap name. Use for
13171
+ * integration tokens where you want to grant `addons.installPackage`
13172
+ * and nothing else.
13173
+ *
13174
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
13175
+ * "give me everything" escape; there is no wildcard scope.
13176
+ */
13177
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
13178
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
13179
+ var CapScopeSchema = _enum(["device", "system"]);
13180
+ /**
13181
+ * DeviceSelector (scope model v3 — 2026-08-12).
13182
+ *
13183
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
13184
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
13185
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
13186
+ * AFTER the grant was minted — no re-grant, no re-login.
13187
+ *
13188
+ * - `all` — every device in the deployment. The broad viewer/operator
13189
+ * lever without a `category` grant (a `category` grant also covers device
13190
+ * caps that carry no deviceId; `all` is specifically the device set).
13191
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
13192
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
13193
+ * is NOT covered until the grant is edited.
13194
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
13195
+ * DYNAMIC. A device that changes type, or a new device of the type,
13196
+ * re-resolves on the next request.
13197
+ * - `locations` — every device whose operator-assigned `location` label is
13198
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
13199
+ * null/unset location matches NO `locations` selector.
13200
+ */
13201
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
13202
+ object({ kind: literal("all") }),
13203
+ object({
13204
+ kind: literal("ids"),
13205
+ ids: array(number().int()).min(1)
13206
+ }),
13207
+ object({
13208
+ kind: literal("types"),
13209
+ types: array(_enum(DeviceType)).min(1)
13210
+ }),
13211
+ object({
13212
+ kind: literal("locations"),
13213
+ locations: array(string().min(1)).min(1)
13214
+ })
13215
+ ]);
13216
+ var DeviceTokenScopeSchema = object({
13217
+ type: literal("device"),
13218
+ /** The device SET this grant covers — resolved against the live fleet. */
13219
+ selector: DeviceSelectorSchema,
13220
+ access: array(MethodAccessSchema).min(1),
13221
+ /**
13222
+ * Whether a grant on a PARENT device transparently covers its accessory
13223
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
13224
+ * Direction is parent → children ONLY.
13225
+ *
13226
+ * Absent → the matcher DERIVES it from the access flavour: `view`
13227
+ * inherits (a camera viewer sees the camera's accessories), `create` /
13228
+ * `delete` do NOT (actuating/removing a child is an explicit act the
13229
+ * operator must grant on the child, not inherit from the parent). Set it
13230
+ * explicitly to override that default per grant.
13231
+ */
13232
+ includeLinked: boolean().optional()
13233
+ });
13234
+ /**
13235
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
13236
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
13237
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
13238
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
13239
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
13240
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
13241
+ * migration cannot reach a JWT already in a client's hands; parse-time
13242
+ * migration covers both without a flag day. No cast — the raw object is read
13243
+ * through `Reflect.get` (its static type is `unknown`).
13244
+ */
13245
+ function migrateLegacyTokenScope(raw) {
13246
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
13247
+ if (Reflect.get(raw, "type") !== "device") return raw;
13248
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
13249
+ const targets = Reflect.get(raw, "targets");
13250
+ if (!Array.isArray(targets)) return raw;
13251
+ return {
13252
+ type: "device",
13253
+ selector: {
13254
+ kind: "ids",
13255
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
13256
+ },
13257
+ access: Reflect.get(raw, "access")
13258
+ };
13259
+ }
13260
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
13261
+ object({
13262
+ type: literal("category"),
13263
+ target: CapScopeSchema,
13264
+ access: array(MethodAccessSchema).min(1)
13265
+ }),
13266
+ object({
13267
+ type: literal("capability"),
13268
+ target: string(),
13269
+ access: array(MethodAccessSchema).min(1)
13270
+ }),
13271
+ object({
13272
+ type: literal("addon"),
13273
+ target: string(),
13274
+ access: array(MethodAccessSchema).min(1)
13275
+ }),
13276
+ DeviceTokenScopeSchema
13277
+ ]));
13278
+ object({
13279
+ id: string(),
13280
+ username: string(),
13281
+ passwordHash: string(),
13282
+ /**
13283
+ * Admin bypass. When true, the middleware skips the scope-access
13284
+ * check entirely. There is no other axis of privilege; the legacy
13285
+ * role enum collapsed onto this boolean in v2.
13286
+ */
13287
+ isAdmin: boolean().default(false),
13288
+ allowedProviders: AllowedProviderSchema,
13289
+ allowedDevices: AllowedDevicesSchema,
13290
+ /**
13291
+ * Scopes granted to this user. Admins bypass; their `scopes` is
13292
+ * ignored. Non-admins without scopes are locked out of every
13293
+ * protected call.
13294
+ */
13295
+ scopes: array(TokenScopeSchema).default([]),
13296
+ createdAt: number(),
13297
+ updatedAt: number()
13298
+ });
13299
+ object({
13300
+ id: string(),
13301
+ label: string(),
13302
+ isAdmin: boolean().default(false),
13303
+ allowedProviders: AllowedProviderSchema,
13304
+ allowedDevices: AllowedDevicesSchema,
13305
+ tokenHash: string(),
13306
+ tokenPrefix: string(),
13307
+ createdAt: number(),
13308
+ lastUsedAt: number().optional()
13309
+ });
13310
+ object({
13311
+ id: string(),
13312
+ userId: string(),
13313
+ name: string(),
13314
+ tokenHash: string(),
13315
+ tokenPrefix: string(),
13316
+ scopes: array(TokenScopeSchema),
13317
+ expiresAt: number().nullish(),
13318
+ lastUsedAt: number().nullish(),
13319
+ createdAt: number()
13320
+ });
13321
+ /** What a share-view grant lets its holder see. */
13322
+ var ShareViewGrantSchema = object({
13323
+ kind: _enum(SHARE_VIEW_KINDS),
13324
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
13325
+ /** Talk-back, opt-in at mint time; absent means off. */
13326
+ talk: boolean().optional()
13327
+ });
13328
+ var ShareViewScopeSchema = object({
13329
+ type: literal("share-view"),
13330
+ grant: ShareViewGrantSchema
13331
+ });
13332
+ var AddonRoutesScopeSchema = object({
13333
+ type: literal("addon-routes"),
13334
+ access: array(MethodAccessSchema).min(1)
13335
+ });
13336
+ var PreferencesSelfScopeSchema = object({ type: literal("preferences-self") });
13337
+ var CredentialScopeSchema = union([
13338
+ literal("*"),
13339
+ ShareViewScopeSchema,
13340
+ AddonRoutesScopeSchema,
13341
+ PreferencesSelfScopeSchema,
13342
+ TokenScopeSchema
13343
+ ]);
13344
+ object({
13345
+ kind: literal("credential"),
13346
+ sub: string().min(1),
13347
+ jti: string().min(16),
13348
+ scopes: array(CredentialScopeSchema).min(1)
13349
+ });
13350
+ var PreferenceNamespaceSchema = string().regex(/^[a-z][a-z0-9.-]{0,63}$/);
13351
+ /** A namespace's value: a JSON object, opaque to the hub. */
13352
+ var PreferenceValueSchema = record(string(), unknown());
13353
+ var PreferenceDeviceIdSchema = string().min(1).max(64);
13354
+ /** A stored row, as the owner reads it. */
13355
+ var PreferenceRowSchema = object({
13356
+ namespace: PreferenceNamespaceSchema,
13357
+ value: PreferenceValueSchema,
13358
+ /** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
13359
+ revision: number().int().positive(),
13360
+ updatedAt: number().int(),
13361
+ /** The client id the last writer sent; `null` when it sent none. */
13362
+ updatedByDevice: PreferenceDeviceIdSchema.nullable()
13363
+ });
13364
+ object({
13365
+ /** Absent: every namespace the caller holds. */
13366
+ namespaces: array(PreferenceNamespaceSchema).max(32).optional() });
13367
+ object({ rows: array(PreferenceRowSchema) });
13368
+ object({
13369
+ namespace: PreferenceNamespaceSchema,
13370
+ value: PreferenceValueSchema,
13371
+ /**
13372
+ * The revision the edit was based on. Absent: last write wins. `0`: the
13373
+ * namespace must not exist yet. Any other value that is not the current
13374
+ * revision answers `conflict` and writes nothing.
13375
+ */
13376
+ baseRevision: number().int().nonnegative().optional(),
13377
+ deviceId: PreferenceDeviceIdSchema.optional()
13378
+ });
13379
+ discriminatedUnion("status", [object({
13380
+ status: literal("saved"),
13381
+ row: PreferenceRowSchema
13382
+ }), object({
13383
+ status: literal("conflict"),
13384
+ current: PreferenceRowSchema.nullable()
13385
+ })]);
13386
+ object({ namespace: PreferenceNamespaceSchema });
13387
+ object({
13388
+ /** `false` when the namespace did not exist. */
13389
+ deleted: boolean() });
13390
+ object({
13391
+ /** The revision the client holds per namespace; a namespace it does not list is new to it. */
13392
+ revisionByNamespace: record(PreferenceNamespaceSchema, number().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
13393
+ object({
13394
+ /** Every row whose revision differs from the client's, and every row it did not list. */
13395
+ rows: array(PreferenceRowSchema),
13396
+ /** Namespaces the client listed that no longer exist. */
13397
+ deleted: array(PreferenceNamespaceSchema)
13398
+ });
13119
13399
  _enum(["new-session", "step-up"]);
13120
13400
  /** The languages the hub's app landing pages are written in (D858). */
13121
13401
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -40424,38 +40704,37 @@ method(LlmRuntimeCompleteInputSchema, LlmGenerateResultSchema, {
40424
40704
  auth: "admin",
40425
40705
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
40426
40706
  });
40707
+ var LlmProfileKindSchema = string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "a kind id is lower-case letters, digits and dashes");
40708
+ /** What a model (or, by default, every model of a kind) can do. */
40709
+ var LlmModelFeaturesSchema = object({
40710
+ vision: boolean(),
40711
+ tools: boolean(),
40712
+ streaming: boolean()
40713
+ });
40714
+ /** One model a provider offers. `features` overrides the kind's defaults, per field. */
40715
+ var LlmModelInfoSchema = object({
40716
+ id: string(),
40717
+ label: string().optional(),
40718
+ contextLength: number().int().positive().optional(),
40719
+ features: LlmModelFeaturesSchema.partial().optional()
40720
+ });
40427
40721
  /**
40428
- * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
40429
- * methods concat-fan across providers; single-row methods route to ONE
40430
- * provider by the `addonId` in the call input (the notification-output
40431
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
40432
- * (hub-placed); the cap stays open for future providers.
40433
- *
40434
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
40435
- * `apiKey` is a password field — providers REDACT it on read and merge on
40436
- * write; a stored key NEVER round-trips to a client.
40722
+ * The provider-specific part of a profile, validated by the provider that owns
40723
+ * the kind (`upsertProfile` refuses what it does not accept). A field its
40724
+ * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
40725
+ * keychain, never in the row, and reads back as the redaction marker.
40437
40726
  */
40438
- var LlmProfileKindSchema = _enum([
40439
- "openai-compatible",
40440
- "openai",
40441
- "anthropic",
40442
- "google",
40443
- "managed-local",
40444
- "apple-foundation"
40445
- ]);
40727
+ var LlmProviderConfigSchema = record(string(), unknown());
40446
40728
  var LlmProfileSchema = object({
40447
40729
  id: string(),
40448
40730
  name: string(),
40731
+ /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
40449
40732
  kind: LlmProfileKindSchema,
40450
40733
  /** Stamped by the provider — keeps the fanned catalog routable. */
40451
40734
  addonId: string(),
40452
40735
  enabled: boolean(),
40453
40736
  /** Vendor model id, or the managed runtime's loaded model. */
40454
40737
  model: string(),
40455
- /** Required for openai-compatible; override for cloud kinds. */
40456
- baseUrl: string().optional(),
40457
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
40458
- apiKey: string().optional(),
40459
40738
  /** Vision on/off. A vision call against a `false` profile is REFUSED, never
40460
40739
  * degraded to text — that shipped once and produced a confident answer to a
40461
40740
  * question about a picture nobody sent. */
@@ -40463,15 +40742,11 @@ var LlmProfileSchema = object({
40463
40742
  temperature: number().min(0).max(2).optional(),
40464
40743
  /** Nucleus sampling. Every wire we speak has it. */
40465
40744
  topP: number().min(0).max(1).optional(),
40466
- /** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
40467
- * wire does, and the client drops it there (measured: the request body gets
40468
- * `top_p` and no `top_k`). The profile editor hides the field wherever it
40469
- * would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
40745
+ /** Top-k sampling. Carried only by the wires that have it — a kind offers the
40746
+ * field in its editor only when its descriptor lists it in `profileFields`. */
40470
40747
  topK: number().int().positive().optional(),
40471
40748
  maxTokens: number().int().positive().optional(),
40472
- /** Prompt context window. Advisory for cloud kinds (they enforce their own);
40473
- * for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
40474
- * the model with, so it is the one field that changes a PROCESS. */
40749
+ /** Prompt context window. Advisory for cloud kinds (they enforce their own). */
40475
40750
  contextLength: number().int().positive().optional(),
40476
40751
  /** Default system prompt. A caller's `system` REPLACES it (never appends —
40477
40752
  * two system prompts fighting is worse than either alone). */
@@ -40497,16 +40772,37 @@ var LlmProfileSchema = object({
40497
40772
  * library; the REGISTRY of callable tools is ours and is empty in v1, so a
40498
40773
  * `true` here buys the wiring, not behaviour, until tools are registered. */
40499
40774
  toolsEnabled: boolean().default(false),
40500
- extraHeaders: record(string(), string()).optional(),
40501
- /** kind === 'managed-local' only (spec §4). */
40502
- runtime: ManagedRuntimeConfigSchema.optional(),
40503
- /**
40504
- * kind === 'apple-foundation' only: WHERE it runs — the only thing there is
40505
- * to configure (no key, no URL, no download; `model` is `apple-system`).
40506
- * `supportsVision` on such a row is stamped by the provider from the node's
40507
- * reported `imageInput`, never taken from the operator (D62).
40508
- */
40509
- appleFoundation: object({ nodeId: string() }).optional()
40775
+ /** Everything the kind's provider owns (endpoint, key, node, runtime…). */
40776
+ providerConfig: LlmProviderConfigSchema.default({})
40777
+ });
40778
+ /**
40779
+ * The common profile fields a kind's editor offers. The editor owns how each
40780
+ * one is drawn; the provider says which of them mean something on its wire.
40781
+ */
40782
+ var LlmProfileFieldSchema = _enum([
40783
+ "temperature",
40784
+ "topP",
40785
+ "topK",
40786
+ "maxTokens",
40787
+ "contextLength",
40788
+ "systemPrompt",
40789
+ "timeoutMs",
40790
+ "connectTimeoutMs",
40791
+ "firstTokenTimeoutMs",
40792
+ "idleTimeoutMs",
40793
+ "retry",
40794
+ "toolsEnabled"
40795
+ ]);
40796
+ /**
40797
+ * A provider-drawn part of the editor, by a generic widget id the admin UI
40798
+ * registers (`ai/apple-node`). `placement: 'model'` replaces the generic model
40799
+ * picker: that widget owns the model choice.
40800
+ */
40801
+ var LlmProviderWidgetSchema = object({
40802
+ id: string(),
40803
+ placement: _enum(["connection", "model"]),
40804
+ /** `providerConfig` keys this widget must fill before the profile can be saved. */
40805
+ requires: array(string()).optional()
40510
40806
  });
40511
40807
  /** ConfigUISchema tree passed through untyped on the wire (the
40512
40808
  * notification-output `ConfigSchemaPassthrough` precedent at
@@ -40515,11 +40811,56 @@ var ConfigSchemaPassthrough$3 = unknown();
40515
40811
  var LlmProfileKindDescriptorSchema = object({
40516
40812
  kind: LlmProfileKindSchema,
40517
40813
  label: string(),
40814
+ /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
40518
40815
  icon: string(),
40519
40816
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
40520
40817
  addonId: string(),
40521
- configSchema: ConfigSchemaPassthrough$3
40818
+ /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
40819
+ connectionSchema: ConfigSchemaPassthrough$3,
40820
+ /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
40821
+ advancedSchema: ConfigSchemaPassthrough$3.optional(),
40822
+ /** The kind's defaults; a model from `listModels` may override any of them. */
40823
+ features: LlmModelFeaturesSchema,
40824
+ /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
40825
+ visionEditable: boolean(),
40826
+ /** Where the model list comes from: `listModels`, `staticModels`, or nowhere. */
40827
+ modelCatalog: _enum([
40828
+ "fetch",
40829
+ "static",
40830
+ "none"
40831
+ ]),
40832
+ staticModels: array(LlmModelInfoSchema).optional(),
40833
+ /** The common fields that mean something on this kind's wire. */
40834
+ profileFields: array(LlmProfileFieldSchema),
40835
+ providerWidgets: array(LlmProviderWidgetSchema).optional()
40836
+ });
40837
+ /**
40838
+ * `listModels` input. `connection` is an UNSAVED draft of `providerConfig`
40839
+ * (the editor's form); with `profileId` too, a secret the draft leaves
40840
+ * untouched (absent or the redaction marker) is resolved server-side from the
40841
+ * stored profile — the browser never receives it.
40842
+ */
40843
+ var LlmListModelsInputSchema = object({
40844
+ addonId: string(),
40845
+ kind: LlmProfileKindSchema,
40846
+ profileId: string().optional(),
40847
+ connection: LlmProviderConfigSchema.optional()
40522
40848
  });
40849
+ var LlmListModelsErrorCodeSchema = _enum([
40850
+ "auth",
40851
+ "network",
40852
+ "unsupported",
40853
+ "invalid"
40854
+ ]);
40855
+ /** A RESULT, never a throw: "wrong key" is an answer the editor renders inline. */
40856
+ var LlmListModelsResultSchema = discriminatedUnion("ok", [object({
40857
+ ok: literal(true),
40858
+ models: array(LlmModelInfoSchema)
40859
+ }), object({
40860
+ ok: literal(false),
40861
+ code: LlmListModelsErrorCodeSchema,
40862
+ message: string()
40863
+ })]);
40523
40864
  var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
40524
40865
  var LlmDefaultSchema = object({
40525
40866
  selector: LlmDefaultSelectorSchema,
@@ -40619,7 +40960,10 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
40619
40960
  kind: "mutation",
40620
40961
  auth: "admin",
40621
40962
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
40622
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
40963
+ }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
40964
+ kind: "mutation",
40965
+ auth: "admin"
40966
+ }), method(object({}), array(LlmDefaultSchema)), method(object({
40623
40967
  selector: LlmDefaultSelectorSchema,
40624
40968
  profileId: string().nullable()
40625
40969
  }), _void(), {
@@ -44746,202 +45090,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
44746
45090
  auth: "admin"
44747
45091
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
44748
45092
  /**
44749
- * Zod schemas for persisted record types.
44750
- *
44751
- * These schemas serve as the single source of truth for types that are
44752
- * stored in the settings-store backend and retrieved via tRPC. They
44753
- * replace the manual TypeScript interfaces with schema-derived types,
44754
- * enabling runtime validation when reading from the backend.
44755
- *
44756
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
44757
- * keeps the original name for backward compatibility.
44758
- */
44759
- /**
44760
- * Auth model (v2 — 2026-05-12 caps-only):
44761
- *
44762
- * Two principals:
44763
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
44764
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
44765
- *
44766
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44767
- * `super_admin` — collapsed onto the single boolean because every
44768
- * non-admin caller is governed by the same scope-check rules; the
44769
- * distinction was only ever used to route role-specific procedures
44770
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44771
- * with `isAdmin: false` + an explicit scope list.
44772
- */
44773
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44774
- var MethodAccessSchema = _enum([
44775
- "view",
44776
- "create",
44777
- "delete"
44778
- ]);
44779
- /**
44780
- * A single scope grant. Three forms — checked in matcher with OR
44781
- * semantics; the first match decides whether the call passes:
44782
- *
44783
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44784
- * cap with the matching `scope` declaration. New caps inherit grants
44785
- * automatically — adding a device cap to the codebase makes it
44786
- * reachable to every user with `category:device [...]` without a
44787
- * re-grant. Use this for "family viewer" / "operator" tiers.
44788
- *
44789
- * - `addon` — every cap that ships inside a given addon id. Niche;
44790
- * useful when an integration needs to interact with one specific
44791
- * addon's surface regardless of how many caps it exports.
44792
- *
44793
- * - `capability` — the most precise form. Single cap name. Use for
44794
- * integration tokens where you want to grant `addons.installPackage`
44795
- * and nothing else.
44796
- *
44797
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44798
- * "give me everything" escape; there is no wildcard scope.
44799
- */
44800
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44801
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44802
- var CapScopeSchema = _enum(["device", "system"]);
44803
- /**
44804
- * DeviceSelector (scope model v3 — 2026-08-12).
44805
- *
44806
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44807
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44808
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44809
- * AFTER the grant was minted — no re-grant, no re-login.
44810
- *
44811
- * - `all` — every device in the deployment. The broad viewer/operator
44812
- * lever without a `category` grant (a `category` grant also covers device
44813
- * caps that carry no deviceId; `all` is specifically the device set).
44814
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44815
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44816
- * is NOT covered until the grant is edited.
44817
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44818
- * DYNAMIC. A device that changes type, or a new device of the type,
44819
- * re-resolves on the next request.
44820
- * - `locations` — every device whose operator-assigned `location` label is
44821
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44822
- * null/unset location matches NO `locations` selector.
44823
- */
44824
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44825
- object({ kind: literal("all") }),
44826
- object({
44827
- kind: literal("ids"),
44828
- ids: array(number().int()).min(1)
44829
- }),
44830
- object({
44831
- kind: literal("types"),
44832
- types: array(_enum(DeviceType)).min(1)
44833
- }),
44834
- object({
44835
- kind: literal("locations"),
44836
- locations: array(string().min(1)).min(1)
44837
- })
44838
- ]);
44839
- var DeviceTokenScopeSchema = object({
44840
- type: literal("device"),
44841
- /** The device SET this grant covers — resolved against the live fleet. */
44842
- selector: DeviceSelectorSchema,
44843
- access: array(MethodAccessSchema).min(1),
44844
- /**
44845
- * Whether a grant on a PARENT device transparently covers its accessory
44846
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44847
- * Direction is parent → children ONLY.
44848
- *
44849
- * Absent → the matcher DERIVES it from the access flavour: `view`
44850
- * inherits (a camera viewer sees the camera's accessories), `create` /
44851
- * `delete` do NOT (actuating/removing a child is an explicit act the
44852
- * operator must grant on the child, not inherit from the parent). Set it
44853
- * explicitly to override that default per grant.
44854
- */
44855
- includeLinked: boolean().optional()
44856
- });
44857
- /**
44858
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44859
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44860
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44861
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44862
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44863
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44864
- * migration cannot reach a JWT already in a client's hands; parse-time
44865
- * migration covers both without a flag day. No cast — the raw object is read
44866
- * through `Reflect.get` (its static type is `unknown`).
44867
- */
44868
- function migrateLegacyTokenScope(raw) {
44869
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44870
- if (Reflect.get(raw, "type") !== "device") return raw;
44871
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44872
- const targets = Reflect.get(raw, "targets");
44873
- if (!Array.isArray(targets)) return raw;
44874
- return {
44875
- type: "device",
44876
- selector: {
44877
- kind: "ids",
44878
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44879
- },
44880
- access: Reflect.get(raw, "access")
44881
- };
44882
- }
44883
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44884
- object({
44885
- type: literal("category"),
44886
- target: CapScopeSchema,
44887
- access: array(MethodAccessSchema).min(1)
44888
- }),
44889
- object({
44890
- type: literal("capability"),
44891
- target: string(),
44892
- access: array(MethodAccessSchema).min(1)
44893
- }),
44894
- object({
44895
- type: literal("addon"),
44896
- target: string(),
44897
- access: array(MethodAccessSchema).min(1)
44898
- }),
44899
- DeviceTokenScopeSchema
44900
- ]));
44901
- object({
44902
- id: string(),
44903
- username: string(),
44904
- passwordHash: string(),
44905
- /**
44906
- * Admin bypass. When true, the middleware skips the scope-access
44907
- * check entirely. There is no other axis of privilege; the legacy
44908
- * role enum collapsed onto this boolean in v2.
44909
- */
44910
- isAdmin: boolean().default(false),
44911
- allowedProviders: AllowedProviderSchema,
44912
- allowedDevices: AllowedDevicesSchema,
44913
- /**
44914
- * Scopes granted to this user. Admins bypass; their `scopes` is
44915
- * ignored. Non-admins without scopes are locked out of every
44916
- * protected call.
44917
- */
44918
- scopes: array(TokenScopeSchema).default([]),
44919
- createdAt: number(),
44920
- updatedAt: number()
44921
- });
44922
- object({
44923
- id: string(),
44924
- label: string(),
44925
- isAdmin: boolean().default(false),
44926
- allowedProviders: AllowedProviderSchema,
44927
- allowedDevices: AllowedDevicesSchema,
44928
- tokenHash: string(),
44929
- tokenPrefix: string(),
44930
- createdAt: number(),
44931
- lastUsedAt: number().optional()
44932
- });
44933
- object({
44934
- id: string(),
44935
- userId: string(),
44936
- name: string(),
44937
- tokenHash: string(),
44938
- tokenPrefix: string(),
44939
- scopes: array(TokenScopeSchema),
44940
- expiresAt: number().nullish(),
44941
- lastUsedAt: number().nullish(),
44942
- createdAt: number()
44943
- });
44944
- /**
44945
45093
  * `oauth-integration` — a collection cap by which an addon declares
44946
45094
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44947
45095
  * Each provider returns a static descriptor; the core enumerates them
@@ -65816,26 +65964,6 @@ var ApiKeySummarySchema = object({
65816
65964
  createdAt: number(),
65817
65965
  lastUsedAt: number().optional()
65818
65966
  });
65819
- var ScopedTokenSummarySchema = object({
65820
- id: string(),
65821
- userId: string(),
65822
- name: string(),
65823
- tokenPrefix: string(),
65824
- scopes: array(TokenScopeSchema),
65825
- expiresAt: number().nullish(),
65826
- lastUsedAt: number().nullish(),
65827
- createdAt: number()
65828
- });
65829
- var CreateScopedTokenInputSchema = object({
65830
- userId: string(),
65831
- name: string(),
65832
- scopes: array(TokenScopeSchema),
65833
- expiresAt: number().optional()
65834
- });
65835
- var CreateScopedTokenResultSchema = object({
65836
- token: string(),
65837
- record: ScopedTokenSummarySchema
65838
- });
65839
65967
  var OauthSessionSummarySchema = object({
65840
65968
  id: string(),
65841
65969
  userId: string(),
@@ -65857,11 +65985,11 @@ var TotpStatusSchema = object({
65857
65985
  confirmedAt: number().nullable()
65858
65986
  });
65859
65987
  /**
65860
- * user-management — singleton capability for user accounts, API keys,
65861
- * and scoped tokens.
65988
+ * user-management — singleton capability for user accounts and the
65989
+ * legacy API-key rows.
65862
65990
  *
65863
65991
  * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
65864
- * — the subset check on `setUserScopes` / `createScopedToken` is moot
65992
+ * — the subset check on `setUserScopes` is moot
65865
65993
  * because non-admins never reach these. If/when we open non-admin
65866
65994
  * delegation, structural caller-scope subset check goes inside the
65867
65995
  * provider.
@@ -65918,15 +66046,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
65918
66046
  kind: "mutation",
65919
66047
  auth: "admin",
65920
66048
  access: "delete"
65921
- }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
65922
- kind: "mutation",
65923
- auth: "admin",
65924
- access: "create"
65925
- }), method(object({ id: string() }), object({ success: literal(true) }), {
65926
- kind: "mutation",
65927
- auth: "admin",
65928
- access: "delete"
65929
- }), method(object({ token: string() }), ScopedTokenSummarySchema.nullable(), { access: "view" }), method(object({ userId: string() }), array(ScopedTokenSummarySchema), { auth: "admin" }), method(object({ userId: string() }), TotpSetupResultSchema, {
66049
+ }), method(object({ userId: string() }), TotpSetupResultSchema, {
65930
66050
  kind: "mutation",
65931
66051
  auth: "admin",
65932
66052
  access: "create"
@@ -72031,7 +72151,7 @@ Object.freeze({
72031
72151
  capName: "llm",
72032
72152
  capScope: "system",
72033
72153
  addonId: null,
72034
- access: "view"
72154
+ access: "create"
72035
72155
  },
72036
72156
  "llm.listNodeModels": {
72037
72157
  capName: "llm",
@@ -76695,12 +76815,6 @@ Object.freeze({
76695
76815
  addonId: null,
76696
76816
  access: "create"
76697
76817
  },
76698
- "userManagement.createScopedToken": {
76699
- capName: "user-management",
76700
- capScope: "system",
76701
- addonId: null,
76702
- access: "create"
76703
- },
76704
76818
  "userManagement.createUser": {
76705
76819
  capName: "user-management",
76706
76820
  capScope: "system",
@@ -76749,12 +76863,6 @@ Object.freeze({
76749
76863
  addonId: null,
76750
76864
  access: "view"
76751
76865
  },
76752
- "userManagement.listScopedTokens": {
76753
- capName: "user-management",
76754
- capScope: "system",
76755
- addonId: null,
76756
- access: "view"
76757
- },
76758
76866
  "userManagement.listUsers": {
76759
76867
  capName: "user-management",
76760
76868
  capScope: "system",
@@ -76809,12 +76917,6 @@ Object.freeze({
76809
76917
  addonId: null,
76810
76918
  access: "delete"
76811
76919
  },
76812
- "userManagement.revokeScopedToken": {
76813
- capName: "user-management",
76814
- capScope: "system",
76815
- addonId: null,
76816
- access: "delete"
76817
- },
76818
76920
  "userManagement.setupTotp": {
76819
76921
  capName: "user-management",
76820
76922
  capScope: "system",
@@ -76845,12 +76947,6 @@ Object.freeze({
76845
76947
  addonId: null,
76846
76948
  access: "view"
76847
76949
  },
76848
- "userManagement.validateScopedToken": {
76849
- capName: "user-management",
76850
- capScope: "system",
76851
- addonId: null,
76852
- access: "view"
76853
- },
76854
76950
  "userManagement.verifyTotp": {
76855
76951
  capName: "user-management",
76856
76952
  capScope: "system",