@camstack/addon-provider-hikvision 1.2.155 → 1.2.157

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
@@ -5428,7 +5428,7 @@ var ZodIssueCode = {
5428
5428
  var ZodFirstPartyTypeKind;
5429
5429
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5430
5430
  //#endregion
5431
- //#region ../types/dist/sleep-BxjU_fJM.mjs
5431
+ //#region ../types/dist/sleep-yKL5gfrH.mjs
5432
5432
  /**
5433
5433
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5434
5434
  * window to float samples (D455).
@@ -7810,6 +7810,12 @@ function normalizeAddonInitResult(result) {
7810
7810
  if (Array.isArray(result)) return { providers: result };
7811
7811
  return result;
7812
7812
  }
7813
+ /**
7814
+ * The share-view scope kinds a share-link token can carry. The hub mints
7815
+ * and validates them (`ShareViewGrantSchema` builds its
7816
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
7817
+ */
7818
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7813
7819
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7814
7820
  var PeerBytesTicketSchema = object({
7815
7821
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12792,6 +12798,280 @@ var ConvertResultSchema = object({
12792
12798
  files: array(string()).readonly()
12793
12799
  })).readonly()
12794
12800
  });
12801
+ /**
12802
+ * Zod schemas for persisted record types.
12803
+ *
12804
+ * These schemas serve as the single source of truth for types that are
12805
+ * stored in the settings-store backend and retrieved via tRPC. They
12806
+ * replace the manual TypeScript interfaces with schema-derived types,
12807
+ * enabling runtime validation when reading from the backend.
12808
+ *
12809
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12810
+ * keeps the original name for backward compatibility.
12811
+ */
12812
+ /**
12813
+ * Auth model (v2 — 2026-05-12 caps-only):
12814
+ *
12815
+ * Two principals:
12816
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12817
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12818
+ *
12819
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12820
+ * `super_admin` — collapsed onto the single boolean because every
12821
+ * non-admin caller is governed by the same scope-check rules; the
12822
+ * distinction was only ever used to route role-specific procedures
12823
+ * which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
12824
+ * with `isAdmin: false` + an explicit scope list.
12825
+ */
12826
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12827
+ var MethodAccessSchema = _enum([
12828
+ "view",
12829
+ "create",
12830
+ "delete"
12831
+ ]);
12832
+ /**
12833
+ * A single scope grant. Three forms — checked in matcher with OR
12834
+ * semantics; the first match decides whether the call passes:
12835
+ *
12836
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12837
+ * cap with the matching `scope` declaration. New caps inherit grants
12838
+ * automatically — adding a device cap to the codebase makes it
12839
+ * reachable to every user with `category:device [...]` without a
12840
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12841
+ *
12842
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12843
+ * useful when an integration needs to interact with one specific
12844
+ * addon's surface regardless of how many caps it exports.
12845
+ *
12846
+ * - `capability` — the most precise form. Single cap name. Use for
12847
+ * integration tokens where you want to grant `addons.installPackage`
12848
+ * and nothing else.
12849
+ *
12850
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12851
+ * "give me everything" escape; there is no wildcard scope.
12852
+ */
12853
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12854
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12855
+ var CapScopeSchema = _enum(["device", "system"]);
12856
+ /**
12857
+ * DeviceSelector (scope model v3 — 2026-08-12).
12858
+ *
12859
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12860
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12861
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12862
+ * AFTER the grant was minted — no re-grant, no re-login.
12863
+ *
12864
+ * - `all` — every device in the deployment. The broad viewer/operator
12865
+ * lever without a `category` grant (a `category` grant also covers device
12866
+ * caps that carry no deviceId; `all` is specifically the device set).
12867
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
12868
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
12869
+ * is NOT covered until the grant is edited.
12870
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
12871
+ * DYNAMIC. A device that changes type, or a new device of the type,
12872
+ * re-resolves on the next request.
12873
+ * - `locations` — every device whose operator-assigned `location` label is
12874
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
12875
+ * null/unset location matches NO `locations` selector.
12876
+ */
12877
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
12878
+ object({ kind: literal("all") }),
12879
+ object({
12880
+ kind: literal("ids"),
12881
+ ids: array(number().int()).min(1)
12882
+ }),
12883
+ object({
12884
+ kind: literal("types"),
12885
+ types: array(_enum(DeviceType)).min(1)
12886
+ }),
12887
+ object({
12888
+ kind: literal("locations"),
12889
+ locations: array(string().min(1)).min(1)
12890
+ })
12891
+ ]);
12892
+ var DeviceTokenScopeSchema = object({
12893
+ type: literal("device"),
12894
+ /** The device SET this grant covers — resolved against the live fleet. */
12895
+ selector: DeviceSelectorSchema,
12896
+ access: array(MethodAccessSchema).min(1),
12897
+ /**
12898
+ * Whether a grant on a PARENT device transparently covers its accessory
12899
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
12900
+ * Direction is parent → children ONLY.
12901
+ *
12902
+ * Absent → the matcher DERIVES it from the access flavour: `view`
12903
+ * inherits (a camera viewer sees the camera's accessories), `create` /
12904
+ * `delete` do NOT (actuating/removing a child is an explicit act the
12905
+ * operator must grant on the child, not inherit from the parent). Set it
12906
+ * explicitly to override that default per grant.
12907
+ */
12908
+ includeLinked: boolean().optional()
12909
+ });
12910
+ /**
12911
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
12912
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
12913
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
12914
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
12915
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
12916
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
12917
+ * migration cannot reach a JWT already in a client's hands; parse-time
12918
+ * migration covers both without a flag day. No cast — the raw object is read
12919
+ * through `Reflect.get` (its static type is `unknown`).
12920
+ */
12921
+ function migrateLegacyTokenScope(raw) {
12922
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
12923
+ if (Reflect.get(raw, "type") !== "device") return raw;
12924
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
12925
+ const targets = Reflect.get(raw, "targets");
12926
+ if (!Array.isArray(targets)) return raw;
12927
+ return {
12928
+ type: "device",
12929
+ selector: {
12930
+ kind: "ids",
12931
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
12932
+ },
12933
+ access: Reflect.get(raw, "access")
12934
+ };
12935
+ }
12936
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
12937
+ object({
12938
+ type: literal("category"),
12939
+ target: CapScopeSchema,
12940
+ access: array(MethodAccessSchema).min(1)
12941
+ }),
12942
+ object({
12943
+ type: literal("capability"),
12944
+ target: string(),
12945
+ access: array(MethodAccessSchema).min(1)
12946
+ }),
12947
+ object({
12948
+ type: literal("addon"),
12949
+ target: string(),
12950
+ access: array(MethodAccessSchema).min(1)
12951
+ }),
12952
+ DeviceTokenScopeSchema
12953
+ ]));
12954
+ object({
12955
+ id: string(),
12956
+ username: string(),
12957
+ passwordHash: string(),
12958
+ /**
12959
+ * Admin bypass. When true, the middleware skips the scope-access
12960
+ * check entirely. There is no other axis of privilege; the legacy
12961
+ * role enum collapsed onto this boolean in v2.
12962
+ */
12963
+ isAdmin: boolean().default(false),
12964
+ allowedProviders: AllowedProviderSchema,
12965
+ allowedDevices: AllowedDevicesSchema,
12966
+ /**
12967
+ * Scopes granted to this user. Admins bypass; their `scopes` is
12968
+ * ignored. Non-admins without scopes are locked out of every
12969
+ * protected call.
12970
+ */
12971
+ scopes: array(TokenScopeSchema).default([]),
12972
+ createdAt: number(),
12973
+ updatedAt: number()
12974
+ });
12975
+ object({
12976
+ id: string(),
12977
+ label: string(),
12978
+ isAdmin: boolean().default(false),
12979
+ allowedProviders: AllowedProviderSchema,
12980
+ allowedDevices: AllowedDevicesSchema,
12981
+ tokenHash: string(),
12982
+ tokenPrefix: string(),
12983
+ createdAt: number(),
12984
+ lastUsedAt: number().optional()
12985
+ });
12986
+ object({
12987
+ id: string(),
12988
+ userId: string(),
12989
+ name: string(),
12990
+ tokenHash: string(),
12991
+ tokenPrefix: string(),
12992
+ scopes: array(TokenScopeSchema),
12993
+ expiresAt: number().nullish(),
12994
+ lastUsedAt: number().nullish(),
12995
+ createdAt: number()
12996
+ });
12997
+ /** What a share-view grant lets its holder see. */
12998
+ var ShareViewGrantSchema = object({
12999
+ kind: _enum(SHARE_VIEW_KINDS),
13000
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
13001
+ /** Talk-back, opt-in at mint time; absent means off. */
13002
+ talk: boolean().optional()
13003
+ });
13004
+ var ShareViewScopeSchema = object({
13005
+ type: literal("share-view"),
13006
+ grant: ShareViewGrantSchema
13007
+ });
13008
+ var AddonRoutesScopeSchema = object({
13009
+ type: literal("addon-routes"),
13010
+ access: array(MethodAccessSchema).min(1)
13011
+ });
13012
+ var PreferencesSelfScopeSchema = object({ type: literal("preferences-self") });
13013
+ var CredentialScopeSchema = union([
13014
+ literal("*"),
13015
+ ShareViewScopeSchema,
13016
+ AddonRoutesScopeSchema,
13017
+ PreferencesSelfScopeSchema,
13018
+ TokenScopeSchema
13019
+ ]);
13020
+ object({
13021
+ kind: literal("credential"),
13022
+ sub: string().min(1),
13023
+ jti: string().min(16),
13024
+ scopes: array(CredentialScopeSchema).min(1)
13025
+ });
13026
+ var PreferenceNamespaceSchema = string().regex(/^[a-z][a-z0-9.-]{0,63}$/);
13027
+ /** A namespace's value: a JSON object, opaque to the hub. */
13028
+ var PreferenceValueSchema = record(string(), unknown());
13029
+ var PreferenceDeviceIdSchema = string().min(1).max(64);
13030
+ /** A stored row, as the owner reads it. */
13031
+ var PreferenceRowSchema = object({
13032
+ namespace: PreferenceNamespaceSchema,
13033
+ value: PreferenceValueSchema,
13034
+ /** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
13035
+ revision: number().int().positive(),
13036
+ updatedAt: number().int(),
13037
+ /** The client id the last writer sent; `null` when it sent none. */
13038
+ updatedByDevice: PreferenceDeviceIdSchema.nullable()
13039
+ });
13040
+ object({
13041
+ /** Absent: every namespace the caller holds. */
13042
+ namespaces: array(PreferenceNamespaceSchema).max(32).optional() });
13043
+ object({ rows: array(PreferenceRowSchema) });
13044
+ object({
13045
+ namespace: PreferenceNamespaceSchema,
13046
+ value: PreferenceValueSchema,
13047
+ /**
13048
+ * The revision the edit was based on. Absent: last write wins. `0`: the
13049
+ * namespace must not exist yet. Any other value that is not the current
13050
+ * revision answers `conflict` and writes nothing.
13051
+ */
13052
+ baseRevision: number().int().nonnegative().optional(),
13053
+ deviceId: PreferenceDeviceIdSchema.optional()
13054
+ });
13055
+ discriminatedUnion("status", [object({
13056
+ status: literal("saved"),
13057
+ row: PreferenceRowSchema
13058
+ }), object({
13059
+ status: literal("conflict"),
13060
+ current: PreferenceRowSchema.nullable()
13061
+ })]);
13062
+ object({ namespace: PreferenceNamespaceSchema });
13063
+ object({
13064
+ /** `false` when the namespace did not exist. */
13065
+ deleted: boolean() });
13066
+ object({
13067
+ /** The revision the client holds per namespace; a namespace it does not list is new to it. */
13068
+ revisionByNamespace: record(PreferenceNamespaceSchema, number().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
13069
+ object({
13070
+ /** Every row whose revision differs from the client's, and every row it did not list. */
13071
+ rows: array(PreferenceRowSchema),
13072
+ /** Namespaces the client listed that no longer exist. */
13073
+ deleted: array(PreferenceNamespaceSchema)
13074
+ });
12795
13075
  _enum(["new-session", "step-up"]);
12796
13076
  /** The languages the hub's app landing pages are written in (D858). */
12797
13077
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -40100,38 +40380,37 @@ method(LlmRuntimeCompleteInputSchema, LlmGenerateResultSchema, {
40100
40380
  auth: "admin",
40101
40381
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
40102
40382
  });
40383
+ var LlmProfileKindSchema = string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "a kind id is lower-case letters, digits and dashes");
40384
+ /** What a model (or, by default, every model of a kind) can do. */
40385
+ var LlmModelFeaturesSchema = object({
40386
+ vision: boolean(),
40387
+ tools: boolean(),
40388
+ streaming: boolean()
40389
+ });
40390
+ /** One model a provider offers. `features` overrides the kind's defaults, per field. */
40391
+ var LlmModelInfoSchema = object({
40392
+ id: string(),
40393
+ label: string().optional(),
40394
+ contextLength: number().int().positive().optional(),
40395
+ features: LlmModelFeaturesSchema.partial().optional()
40396
+ });
40103
40397
  /**
40104
- * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
40105
- * methods concat-fan across providers; single-row methods route to ONE
40106
- * provider by the `addonId` in the call input (the notification-output
40107
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
40108
- * (hub-placed); the cap stays open for future providers.
40109
- *
40110
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
40111
- * `apiKey` is a password field — providers REDACT it on read and merge on
40112
- * write; a stored key NEVER round-trips to a client.
40398
+ * The provider-specific part of a profile, validated by the provider that owns
40399
+ * the kind (`upsertProfile` refuses what it does not accept). A field its
40400
+ * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
40401
+ * keychain, never in the row, and reads back as the redaction marker.
40113
40402
  */
40114
- var LlmProfileKindSchema = _enum([
40115
- "openai-compatible",
40116
- "openai",
40117
- "anthropic",
40118
- "google",
40119
- "managed-local",
40120
- "apple-foundation"
40121
- ]);
40403
+ var LlmProviderConfigSchema = record(string(), unknown());
40122
40404
  var LlmProfileSchema = object({
40123
40405
  id: string(),
40124
40406
  name: string(),
40407
+ /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
40125
40408
  kind: LlmProfileKindSchema,
40126
40409
  /** Stamped by the provider — keeps the fanned catalog routable. */
40127
40410
  addonId: string(),
40128
40411
  enabled: boolean(),
40129
40412
  /** Vendor model id, or the managed runtime's loaded model. */
40130
40413
  model: string(),
40131
- /** Required for openai-compatible; override for cloud kinds. */
40132
- baseUrl: string().optional(),
40133
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
40134
- apiKey: string().optional(),
40135
40414
  /** Vision on/off. A vision call against a `false` profile is REFUSED, never
40136
40415
  * degraded to text — that shipped once and produced a confident answer to a
40137
40416
  * question about a picture nobody sent. */
@@ -40139,15 +40418,11 @@ var LlmProfileSchema = object({
40139
40418
  temperature: number().min(0).max(2).optional(),
40140
40419
  /** Nucleus sampling. Every wire we speak has it. */
40141
40420
  topP: number().min(0).max(1).optional(),
40142
- /** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
40143
- * wire does, and the client drops it there (measured: the request body gets
40144
- * `top_p` and no `top_k`). The profile editor hides the field wherever it
40145
- * would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
40421
+ /** Top-k sampling. Carried only by the wires that have it — a kind offers the
40422
+ * field in its editor only when its descriptor lists it in `profileFields`. */
40146
40423
  topK: number().int().positive().optional(),
40147
40424
  maxTokens: number().int().positive().optional(),
40148
- /** Prompt context window. Advisory for cloud kinds (they enforce their own);
40149
- * for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
40150
- * the model with, so it is the one field that changes a PROCESS. */
40425
+ /** Prompt context window. Advisory for cloud kinds (they enforce their own). */
40151
40426
  contextLength: number().int().positive().optional(),
40152
40427
  /** Default system prompt. A caller's `system` REPLACES it (never appends —
40153
40428
  * two system prompts fighting is worse than either alone). */
@@ -40173,16 +40448,37 @@ var LlmProfileSchema = object({
40173
40448
  * library; the REGISTRY of callable tools is ours and is empty in v1, so a
40174
40449
  * `true` here buys the wiring, not behaviour, until tools are registered. */
40175
40450
  toolsEnabled: boolean().default(false),
40176
- extraHeaders: record(string(), string()).optional(),
40177
- /** kind === 'managed-local' only (spec §4). */
40178
- runtime: ManagedRuntimeConfigSchema.optional(),
40179
- /**
40180
- * kind === 'apple-foundation' only: WHERE it runs — the only thing there is
40181
- * to configure (no key, no URL, no download; `model` is `apple-system`).
40182
- * `supportsVision` on such a row is stamped by the provider from the node's
40183
- * reported `imageInput`, never taken from the operator (D62).
40184
- */
40185
- appleFoundation: object({ nodeId: string() }).optional()
40451
+ /** Everything the kind's provider owns (endpoint, key, node, runtime…). */
40452
+ providerConfig: LlmProviderConfigSchema.default({})
40453
+ });
40454
+ /**
40455
+ * The common profile fields a kind's editor offers. The editor owns how each
40456
+ * one is drawn; the provider says which of them mean something on its wire.
40457
+ */
40458
+ var LlmProfileFieldSchema = _enum([
40459
+ "temperature",
40460
+ "topP",
40461
+ "topK",
40462
+ "maxTokens",
40463
+ "contextLength",
40464
+ "systemPrompt",
40465
+ "timeoutMs",
40466
+ "connectTimeoutMs",
40467
+ "firstTokenTimeoutMs",
40468
+ "idleTimeoutMs",
40469
+ "retry",
40470
+ "toolsEnabled"
40471
+ ]);
40472
+ /**
40473
+ * A provider-drawn part of the editor, by a generic widget id the admin UI
40474
+ * registers (`ai/apple-node`). `placement: 'model'` replaces the generic model
40475
+ * picker: that widget owns the model choice.
40476
+ */
40477
+ var LlmProviderWidgetSchema = object({
40478
+ id: string(),
40479
+ placement: _enum(["connection", "model"]),
40480
+ /** `providerConfig` keys this widget must fill before the profile can be saved. */
40481
+ requires: array(string()).optional()
40186
40482
  });
40187
40483
  /** ConfigUISchema tree passed through untyped on the wire (the
40188
40484
  * notification-output `ConfigSchemaPassthrough` precedent at
@@ -40191,11 +40487,56 @@ var ConfigSchemaPassthrough$3 = unknown();
40191
40487
  var LlmProfileKindDescriptorSchema = object({
40192
40488
  kind: LlmProfileKindSchema,
40193
40489
  label: string(),
40490
+ /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
40194
40491
  icon: string(),
40195
40492
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
40196
40493
  addonId: string(),
40197
- configSchema: ConfigSchemaPassthrough$3
40494
+ /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
40495
+ connectionSchema: ConfigSchemaPassthrough$3,
40496
+ /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
40497
+ advancedSchema: ConfigSchemaPassthrough$3.optional(),
40498
+ /** The kind's defaults; a model from `listModels` may override any of them. */
40499
+ features: LlmModelFeaturesSchema,
40500
+ /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
40501
+ visionEditable: boolean(),
40502
+ /** Where the model list comes from: `listModels`, `staticModels`, or nowhere. */
40503
+ modelCatalog: _enum([
40504
+ "fetch",
40505
+ "static",
40506
+ "none"
40507
+ ]),
40508
+ staticModels: array(LlmModelInfoSchema).optional(),
40509
+ /** The common fields that mean something on this kind's wire. */
40510
+ profileFields: array(LlmProfileFieldSchema),
40511
+ providerWidgets: array(LlmProviderWidgetSchema).optional()
40512
+ });
40513
+ /**
40514
+ * `listModels` input. `connection` is an UNSAVED draft of `providerConfig`
40515
+ * (the editor's form); with `profileId` too, a secret the draft leaves
40516
+ * untouched (absent or the redaction marker) is resolved server-side from the
40517
+ * stored profile — the browser never receives it.
40518
+ */
40519
+ var LlmListModelsInputSchema = object({
40520
+ addonId: string(),
40521
+ kind: LlmProfileKindSchema,
40522
+ profileId: string().optional(),
40523
+ connection: LlmProviderConfigSchema.optional()
40198
40524
  });
40525
+ var LlmListModelsErrorCodeSchema = _enum([
40526
+ "auth",
40527
+ "network",
40528
+ "unsupported",
40529
+ "invalid"
40530
+ ]);
40531
+ /** A RESULT, never a throw: "wrong key" is an answer the editor renders inline. */
40532
+ var LlmListModelsResultSchema = discriminatedUnion("ok", [object({
40533
+ ok: literal(true),
40534
+ models: array(LlmModelInfoSchema)
40535
+ }), object({
40536
+ ok: literal(false),
40537
+ code: LlmListModelsErrorCodeSchema,
40538
+ message: string()
40539
+ })]);
40199
40540
  var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
40200
40541
  var LlmDefaultSchema = object({
40201
40542
  selector: LlmDefaultSelectorSchema,
@@ -40295,7 +40636,10 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
40295
40636
  kind: "mutation",
40296
40637
  auth: "admin",
40297
40638
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
40298
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
40639
+ }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
40640
+ kind: "mutation",
40641
+ auth: "admin"
40642
+ }), method(object({}), array(LlmDefaultSchema)), method(object({
40299
40643
  selector: LlmDefaultSelectorSchema,
40300
40644
  profileId: string().nullable()
40301
40645
  }), _void(), {
@@ -44401,202 +44745,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
44401
44745
  auth: "admin"
44402
44746
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
44403
44747
  /**
44404
- * Zod schemas for persisted record types.
44405
- *
44406
- * These schemas serve as the single source of truth for types that are
44407
- * stored in the settings-store backend and retrieved via tRPC. They
44408
- * replace the manual TypeScript interfaces with schema-derived types,
44409
- * enabling runtime validation when reading from the backend.
44410
- *
44411
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
44412
- * keeps the original name for backward compatibility.
44413
- */
44414
- /**
44415
- * Auth model (v2 — 2026-05-12 caps-only):
44416
- *
44417
- * Two principals:
44418
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
44419
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
44420
- *
44421
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44422
- * `super_admin` — collapsed onto the single boolean because every
44423
- * non-admin caller is governed by the same scope-check rules; the
44424
- * distinction was only ever used to route role-specific procedures
44425
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44426
- * with `isAdmin: false` + an explicit scope list.
44427
- */
44428
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44429
- var MethodAccessSchema = _enum([
44430
- "view",
44431
- "create",
44432
- "delete"
44433
- ]);
44434
- /**
44435
- * A single scope grant. Three forms — checked in matcher with OR
44436
- * semantics; the first match decides whether the call passes:
44437
- *
44438
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44439
- * cap with the matching `scope` declaration. New caps inherit grants
44440
- * automatically — adding a device cap to the codebase makes it
44441
- * reachable to every user with `category:device [...]` without a
44442
- * re-grant. Use this for "family viewer" / "operator" tiers.
44443
- *
44444
- * - `addon` — every cap that ships inside a given addon id. Niche;
44445
- * useful when an integration needs to interact with one specific
44446
- * addon's surface regardless of how many caps it exports.
44447
- *
44448
- * - `capability` — the most precise form. Single cap name. Use for
44449
- * integration tokens where you want to grant `addons.installPackage`
44450
- * and nothing else.
44451
- *
44452
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44453
- * "give me everything" escape; there is no wildcard scope.
44454
- */
44455
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44456
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44457
- var CapScopeSchema = _enum(["device", "system"]);
44458
- /**
44459
- * DeviceSelector (scope model v3 — 2026-08-12).
44460
- *
44461
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44462
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44463
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44464
- * AFTER the grant was minted — no re-grant, no re-login.
44465
- *
44466
- * - `all` — every device in the deployment. The broad viewer/operator
44467
- * lever without a `category` grant (a `category` grant also covers device
44468
- * caps that carry no deviceId; `all` is specifically the device set).
44469
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44470
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44471
- * is NOT covered until the grant is edited.
44472
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44473
- * DYNAMIC. A device that changes type, or a new device of the type,
44474
- * re-resolves on the next request.
44475
- * - `locations` — every device whose operator-assigned `location` label is
44476
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44477
- * null/unset location matches NO `locations` selector.
44478
- */
44479
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44480
- object({ kind: literal("all") }),
44481
- object({
44482
- kind: literal("ids"),
44483
- ids: array(number().int()).min(1)
44484
- }),
44485
- object({
44486
- kind: literal("types"),
44487
- types: array(_enum(DeviceType)).min(1)
44488
- }),
44489
- object({
44490
- kind: literal("locations"),
44491
- locations: array(string().min(1)).min(1)
44492
- })
44493
- ]);
44494
- var DeviceTokenScopeSchema = object({
44495
- type: literal("device"),
44496
- /** The device SET this grant covers — resolved against the live fleet. */
44497
- selector: DeviceSelectorSchema,
44498
- access: array(MethodAccessSchema).min(1),
44499
- /**
44500
- * Whether a grant on a PARENT device transparently covers its accessory
44501
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44502
- * Direction is parent → children ONLY.
44503
- *
44504
- * Absent → the matcher DERIVES it from the access flavour: `view`
44505
- * inherits (a camera viewer sees the camera's accessories), `create` /
44506
- * `delete` do NOT (actuating/removing a child is an explicit act the
44507
- * operator must grant on the child, not inherit from the parent). Set it
44508
- * explicitly to override that default per grant.
44509
- */
44510
- includeLinked: boolean().optional()
44511
- });
44512
- /**
44513
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44514
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44515
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44516
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44517
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44518
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44519
- * migration cannot reach a JWT already in a client's hands; parse-time
44520
- * migration covers both without a flag day. No cast — the raw object is read
44521
- * through `Reflect.get` (its static type is `unknown`).
44522
- */
44523
- function migrateLegacyTokenScope(raw) {
44524
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44525
- if (Reflect.get(raw, "type") !== "device") return raw;
44526
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44527
- const targets = Reflect.get(raw, "targets");
44528
- if (!Array.isArray(targets)) return raw;
44529
- return {
44530
- type: "device",
44531
- selector: {
44532
- kind: "ids",
44533
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44534
- },
44535
- access: Reflect.get(raw, "access")
44536
- };
44537
- }
44538
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44539
- object({
44540
- type: literal("category"),
44541
- target: CapScopeSchema,
44542
- access: array(MethodAccessSchema).min(1)
44543
- }),
44544
- object({
44545
- type: literal("capability"),
44546
- target: string(),
44547
- access: array(MethodAccessSchema).min(1)
44548
- }),
44549
- object({
44550
- type: literal("addon"),
44551
- target: string(),
44552
- access: array(MethodAccessSchema).min(1)
44553
- }),
44554
- DeviceTokenScopeSchema
44555
- ]));
44556
- object({
44557
- id: string(),
44558
- username: string(),
44559
- passwordHash: string(),
44560
- /**
44561
- * Admin bypass. When true, the middleware skips the scope-access
44562
- * check entirely. There is no other axis of privilege; the legacy
44563
- * role enum collapsed onto this boolean in v2.
44564
- */
44565
- isAdmin: boolean().default(false),
44566
- allowedProviders: AllowedProviderSchema,
44567
- allowedDevices: AllowedDevicesSchema,
44568
- /**
44569
- * Scopes granted to this user. Admins bypass; their `scopes` is
44570
- * ignored. Non-admins without scopes are locked out of every
44571
- * protected call.
44572
- */
44573
- scopes: array(TokenScopeSchema).default([]),
44574
- createdAt: number(),
44575
- updatedAt: number()
44576
- });
44577
- object({
44578
- id: string(),
44579
- label: string(),
44580
- isAdmin: boolean().default(false),
44581
- allowedProviders: AllowedProviderSchema,
44582
- allowedDevices: AllowedDevicesSchema,
44583
- tokenHash: string(),
44584
- tokenPrefix: string(),
44585
- createdAt: number(),
44586
- lastUsedAt: number().optional()
44587
- });
44588
- object({
44589
- id: string(),
44590
- userId: string(),
44591
- name: string(),
44592
- tokenHash: string(),
44593
- tokenPrefix: string(),
44594
- scopes: array(TokenScopeSchema),
44595
- expiresAt: number().nullish(),
44596
- lastUsedAt: number().nullish(),
44597
- createdAt: number()
44598
- });
44599
- /**
44600
44748
  * `oauth-integration` — a collection cap by which an addon declares
44601
44749
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44602
44750
  * Each provider returns a static descriptor; the core enumerates them
@@ -65462,26 +65610,6 @@ var ApiKeySummarySchema = object({
65462
65610
  createdAt: number(),
65463
65611
  lastUsedAt: number().optional()
65464
65612
  });
65465
- var ScopedTokenSummarySchema = object({
65466
- id: string(),
65467
- userId: string(),
65468
- name: string(),
65469
- tokenPrefix: string(),
65470
- scopes: array(TokenScopeSchema),
65471
- expiresAt: number().nullish(),
65472
- lastUsedAt: number().nullish(),
65473
- createdAt: number()
65474
- });
65475
- var CreateScopedTokenInputSchema = object({
65476
- userId: string(),
65477
- name: string(),
65478
- scopes: array(TokenScopeSchema),
65479
- expiresAt: number().optional()
65480
- });
65481
- var CreateScopedTokenResultSchema = object({
65482
- token: string(),
65483
- record: ScopedTokenSummarySchema
65484
- });
65485
65613
  var OauthSessionSummarySchema = object({
65486
65614
  id: string(),
65487
65615
  userId: string(),
@@ -65503,11 +65631,11 @@ var TotpStatusSchema = object({
65503
65631
  confirmedAt: number().nullable()
65504
65632
  });
65505
65633
  /**
65506
- * user-management — singleton capability for user accounts, API keys,
65507
- * and scoped tokens.
65634
+ * user-management — singleton capability for user accounts and the
65635
+ * legacy API-key rows.
65508
65636
  *
65509
65637
  * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
65510
- * — the subset check on `setUserScopes` / `createScopedToken` is moot
65638
+ * — the subset check on `setUserScopes` is moot
65511
65639
  * because non-admins never reach these. If/when we open non-admin
65512
65640
  * delegation, structural caller-scope subset check goes inside the
65513
65641
  * provider.
@@ -65564,15 +65692,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
65564
65692
  kind: "mutation",
65565
65693
  auth: "admin",
65566
65694
  access: "delete"
65567
- }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
65568
- kind: "mutation",
65569
- auth: "admin",
65570
- access: "create"
65571
- }), method(object({ id: string() }), object({ success: literal(true) }), {
65572
- kind: "mutation",
65573
- auth: "admin",
65574
- access: "delete"
65575
- }), method(object({ token: string() }), ScopedTokenSummarySchema.nullable(), { access: "view" }), method(object({ userId: string() }), array(ScopedTokenSummarySchema), { auth: "admin" }), method(object({ userId: string() }), TotpSetupResultSchema, {
65695
+ }), method(object({ userId: string() }), TotpSetupResultSchema, {
65576
65696
  kind: "mutation",
65577
65697
  auth: "admin",
65578
65698
  access: "create"
@@ -71681,7 +71801,7 @@ Object.freeze({
71681
71801
  capName: "llm",
71682
71802
  capScope: "system",
71683
71803
  addonId: null,
71684
- access: "view"
71804
+ access: "create"
71685
71805
  },
71686
71806
  "llm.listNodeModels": {
71687
71807
  capName: "llm",
@@ -76345,12 +76465,6 @@ Object.freeze({
76345
76465
  addonId: null,
76346
76466
  access: "create"
76347
76467
  },
76348
- "userManagement.createScopedToken": {
76349
- capName: "user-management",
76350
- capScope: "system",
76351
- addonId: null,
76352
- access: "create"
76353
- },
76354
76468
  "userManagement.createUser": {
76355
76469
  capName: "user-management",
76356
76470
  capScope: "system",
@@ -76399,12 +76513,6 @@ Object.freeze({
76399
76513
  addonId: null,
76400
76514
  access: "view"
76401
76515
  },
76402
- "userManagement.listScopedTokens": {
76403
- capName: "user-management",
76404
- capScope: "system",
76405
- addonId: null,
76406
- access: "view"
76407
- },
76408
76516
  "userManagement.listUsers": {
76409
76517
  capName: "user-management",
76410
76518
  capScope: "system",
@@ -76459,12 +76567,6 @@ Object.freeze({
76459
76567
  addonId: null,
76460
76568
  access: "delete"
76461
76569
  },
76462
- "userManagement.revokeScopedToken": {
76463
- capName: "user-management",
76464
- capScope: "system",
76465
- addonId: null,
76466
- access: "delete"
76467
- },
76468
76570
  "userManagement.setupTotp": {
76469
76571
  capName: "user-management",
76470
76572
  capScope: "system",
@@ -76495,12 +76597,6 @@ Object.freeze({
76495
76597
  addonId: null,
76496
76598
  access: "view"
76497
76599
  },
76498
- "userManagement.validateScopedToken": {
76499
- capName: "user-management",
76500
- capScope: "system",
76501
- addonId: null,
76502
- access: "view"
76503
- },
76504
76600
  "userManagement.verifyTotp": {
76505
76601
  capName: "user-management",
76506
76602
  capScope: "system",