@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.js CHANGED
@@ -5449,7 +5449,7 @@ var ZodIssueCode = {
5449
5449
  var ZodFirstPartyTypeKind;
5450
5450
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5451
5451
  //#endregion
5452
- //#region ../types/dist/sleep-BxjU_fJM.mjs
5452
+ //#region ../types/dist/sleep-yKL5gfrH.mjs
5453
5453
  /**
5454
5454
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5455
5455
  * window to float samples (D455).
@@ -7831,6 +7831,12 @@ function normalizeAddonInitResult(result) {
7831
7831
  if (Array.isArray(result)) return { providers: result };
7832
7832
  return result;
7833
7833
  }
7834
+ /**
7835
+ * The share-view scope kinds a share-link token can carry. The hub mints
7836
+ * and validates them (`ShareViewGrantSchema` builds its
7837
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
7838
+ */
7839
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7834
7840
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7835
7841
  var PeerBytesTicketSchema = object({
7836
7842
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12813,6 +12819,280 @@ var ConvertResultSchema = object({
12813
12819
  files: array(string()).readonly()
12814
12820
  })).readonly()
12815
12821
  });
12822
+ /**
12823
+ * Zod schemas for persisted record types.
12824
+ *
12825
+ * These schemas serve as the single source of truth for types that are
12826
+ * stored in the settings-store backend and retrieved via tRPC. They
12827
+ * replace the manual TypeScript interfaces with schema-derived types,
12828
+ * enabling runtime validation when reading from the backend.
12829
+ *
12830
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12831
+ * keeps the original name for backward compatibility.
12832
+ */
12833
+ /**
12834
+ * Auth model (v2 — 2026-05-12 caps-only):
12835
+ *
12836
+ * Two principals:
12837
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12838
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12839
+ *
12840
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12841
+ * `super_admin` — collapsed onto the single boolean because every
12842
+ * non-admin caller is governed by the same scope-check rules; the
12843
+ * distinction was only ever used to route role-specific procedures
12844
+ * which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
12845
+ * with `isAdmin: false` + an explicit scope list.
12846
+ */
12847
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12848
+ var MethodAccessSchema = _enum([
12849
+ "view",
12850
+ "create",
12851
+ "delete"
12852
+ ]);
12853
+ /**
12854
+ * A single scope grant. Three forms — checked in matcher with OR
12855
+ * semantics; the first match decides whether the call passes:
12856
+ *
12857
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12858
+ * cap with the matching `scope` declaration. New caps inherit grants
12859
+ * automatically — adding a device cap to the codebase makes it
12860
+ * reachable to every user with `category:device [...]` without a
12861
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12862
+ *
12863
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12864
+ * useful when an integration needs to interact with one specific
12865
+ * addon's surface regardless of how many caps it exports.
12866
+ *
12867
+ * - `capability` — the most precise form. Single cap name. Use for
12868
+ * integration tokens where you want to grant `addons.installPackage`
12869
+ * and nothing else.
12870
+ *
12871
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12872
+ * "give me everything" escape; there is no wildcard scope.
12873
+ */
12874
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12875
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12876
+ var CapScopeSchema = _enum(["device", "system"]);
12877
+ /**
12878
+ * DeviceSelector (scope model v3 — 2026-08-12).
12879
+ *
12880
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12881
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12882
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12883
+ * AFTER the grant was minted — no re-grant, no re-login.
12884
+ *
12885
+ * - `all` — every device in the deployment. The broad viewer/operator
12886
+ * lever without a `category` grant (a `category` grant also covers device
12887
+ * caps that carry no deviceId; `all` is specifically the device set).
12888
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
12889
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
12890
+ * is NOT covered until the grant is edited.
12891
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
12892
+ * DYNAMIC. A device that changes type, or a new device of the type,
12893
+ * re-resolves on the next request.
12894
+ * - `locations` — every device whose operator-assigned `location` label is
12895
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
12896
+ * null/unset location matches NO `locations` selector.
12897
+ */
12898
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
12899
+ object({ kind: literal("all") }),
12900
+ object({
12901
+ kind: literal("ids"),
12902
+ ids: array(number().int()).min(1)
12903
+ }),
12904
+ object({
12905
+ kind: literal("types"),
12906
+ types: array(_enum(DeviceType)).min(1)
12907
+ }),
12908
+ object({
12909
+ kind: literal("locations"),
12910
+ locations: array(string().min(1)).min(1)
12911
+ })
12912
+ ]);
12913
+ var DeviceTokenScopeSchema = object({
12914
+ type: literal("device"),
12915
+ /** The device SET this grant covers — resolved against the live fleet. */
12916
+ selector: DeviceSelectorSchema,
12917
+ access: array(MethodAccessSchema).min(1),
12918
+ /**
12919
+ * Whether a grant on a PARENT device transparently covers its accessory
12920
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
12921
+ * Direction is parent → children ONLY.
12922
+ *
12923
+ * Absent → the matcher DERIVES it from the access flavour: `view`
12924
+ * inherits (a camera viewer sees the camera's accessories), `create` /
12925
+ * `delete` do NOT (actuating/removing a child is an explicit act the
12926
+ * operator must grant on the child, not inherit from the parent). Set it
12927
+ * explicitly to override that default per grant.
12928
+ */
12929
+ includeLinked: boolean().optional()
12930
+ });
12931
+ /**
12932
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
12933
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
12934
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
12935
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
12936
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
12937
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
12938
+ * migration cannot reach a JWT already in a client's hands; parse-time
12939
+ * migration covers both without a flag day. No cast — the raw object is read
12940
+ * through `Reflect.get` (its static type is `unknown`).
12941
+ */
12942
+ function migrateLegacyTokenScope(raw) {
12943
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
12944
+ if (Reflect.get(raw, "type") !== "device") return raw;
12945
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
12946
+ const targets = Reflect.get(raw, "targets");
12947
+ if (!Array.isArray(targets)) return raw;
12948
+ return {
12949
+ type: "device",
12950
+ selector: {
12951
+ kind: "ids",
12952
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
12953
+ },
12954
+ access: Reflect.get(raw, "access")
12955
+ };
12956
+ }
12957
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
12958
+ object({
12959
+ type: literal("category"),
12960
+ target: CapScopeSchema,
12961
+ access: array(MethodAccessSchema).min(1)
12962
+ }),
12963
+ object({
12964
+ type: literal("capability"),
12965
+ target: string(),
12966
+ access: array(MethodAccessSchema).min(1)
12967
+ }),
12968
+ object({
12969
+ type: literal("addon"),
12970
+ target: string(),
12971
+ access: array(MethodAccessSchema).min(1)
12972
+ }),
12973
+ DeviceTokenScopeSchema
12974
+ ]));
12975
+ object({
12976
+ id: string(),
12977
+ username: string(),
12978
+ passwordHash: string(),
12979
+ /**
12980
+ * Admin bypass. When true, the middleware skips the scope-access
12981
+ * check entirely. There is no other axis of privilege; the legacy
12982
+ * role enum collapsed onto this boolean in v2.
12983
+ */
12984
+ isAdmin: boolean().default(false),
12985
+ allowedProviders: AllowedProviderSchema,
12986
+ allowedDevices: AllowedDevicesSchema,
12987
+ /**
12988
+ * Scopes granted to this user. Admins bypass; their `scopes` is
12989
+ * ignored. Non-admins without scopes are locked out of every
12990
+ * protected call.
12991
+ */
12992
+ scopes: array(TokenScopeSchema).default([]),
12993
+ createdAt: number(),
12994
+ updatedAt: number()
12995
+ });
12996
+ object({
12997
+ id: string(),
12998
+ label: string(),
12999
+ isAdmin: boolean().default(false),
13000
+ allowedProviders: AllowedProviderSchema,
13001
+ allowedDevices: AllowedDevicesSchema,
13002
+ tokenHash: string(),
13003
+ tokenPrefix: string(),
13004
+ createdAt: number(),
13005
+ lastUsedAt: number().optional()
13006
+ });
13007
+ object({
13008
+ id: string(),
13009
+ userId: string(),
13010
+ name: string(),
13011
+ tokenHash: string(),
13012
+ tokenPrefix: string(),
13013
+ scopes: array(TokenScopeSchema),
13014
+ expiresAt: number().nullish(),
13015
+ lastUsedAt: number().nullish(),
13016
+ createdAt: number()
13017
+ });
13018
+ /** What a share-view grant lets its holder see. */
13019
+ var ShareViewGrantSchema = object({
13020
+ kind: _enum(SHARE_VIEW_KINDS),
13021
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
13022
+ /** Talk-back, opt-in at mint time; absent means off. */
13023
+ talk: boolean().optional()
13024
+ });
13025
+ var ShareViewScopeSchema = object({
13026
+ type: literal("share-view"),
13027
+ grant: ShareViewGrantSchema
13028
+ });
13029
+ var AddonRoutesScopeSchema = object({
13030
+ type: literal("addon-routes"),
13031
+ access: array(MethodAccessSchema).min(1)
13032
+ });
13033
+ var PreferencesSelfScopeSchema = object({ type: literal("preferences-self") });
13034
+ var CredentialScopeSchema = union([
13035
+ literal("*"),
13036
+ ShareViewScopeSchema,
13037
+ AddonRoutesScopeSchema,
13038
+ PreferencesSelfScopeSchema,
13039
+ TokenScopeSchema
13040
+ ]);
13041
+ object({
13042
+ kind: literal("credential"),
13043
+ sub: string().min(1),
13044
+ jti: string().min(16),
13045
+ scopes: array(CredentialScopeSchema).min(1)
13046
+ });
13047
+ var PreferenceNamespaceSchema = string().regex(/^[a-z][a-z0-9.-]{0,63}$/);
13048
+ /** A namespace's value: a JSON object, opaque to the hub. */
13049
+ var PreferenceValueSchema = record(string(), unknown());
13050
+ var PreferenceDeviceIdSchema = string().min(1).max(64);
13051
+ /** A stored row, as the owner reads it. */
13052
+ var PreferenceRowSchema = object({
13053
+ namespace: PreferenceNamespaceSchema,
13054
+ value: PreferenceValueSchema,
13055
+ /** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
13056
+ revision: number().int().positive(),
13057
+ updatedAt: number().int(),
13058
+ /** The client id the last writer sent; `null` when it sent none. */
13059
+ updatedByDevice: PreferenceDeviceIdSchema.nullable()
13060
+ });
13061
+ object({
13062
+ /** Absent: every namespace the caller holds. */
13063
+ namespaces: array(PreferenceNamespaceSchema).max(32).optional() });
13064
+ object({ rows: array(PreferenceRowSchema) });
13065
+ object({
13066
+ namespace: PreferenceNamespaceSchema,
13067
+ value: PreferenceValueSchema,
13068
+ /**
13069
+ * The revision the edit was based on. Absent: last write wins. `0`: the
13070
+ * namespace must not exist yet. Any other value that is not the current
13071
+ * revision answers `conflict` and writes nothing.
13072
+ */
13073
+ baseRevision: number().int().nonnegative().optional(),
13074
+ deviceId: PreferenceDeviceIdSchema.optional()
13075
+ });
13076
+ discriminatedUnion("status", [object({
13077
+ status: literal("saved"),
13078
+ row: PreferenceRowSchema
13079
+ }), object({
13080
+ status: literal("conflict"),
13081
+ current: PreferenceRowSchema.nullable()
13082
+ })]);
13083
+ object({ namespace: PreferenceNamespaceSchema });
13084
+ object({
13085
+ /** `false` when the namespace did not exist. */
13086
+ deleted: boolean() });
13087
+ object({
13088
+ /** The revision the client holds per namespace; a namespace it does not list is new to it. */
13089
+ revisionByNamespace: record(PreferenceNamespaceSchema, number().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
13090
+ object({
13091
+ /** Every row whose revision differs from the client's, and every row it did not list. */
13092
+ rows: array(PreferenceRowSchema),
13093
+ /** Namespaces the client listed that no longer exist. */
13094
+ deleted: array(PreferenceNamespaceSchema)
13095
+ });
12816
13096
  _enum(["new-session", "step-up"]);
12817
13097
  /** The languages the hub's app landing pages are written in (D858). */
12818
13098
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -40121,38 +40401,37 @@ method(LlmRuntimeCompleteInputSchema, LlmGenerateResultSchema, {
40121
40401
  auth: "admin",
40122
40402
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
40123
40403
  });
40404
+ var LlmProfileKindSchema = string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "a kind id is lower-case letters, digits and dashes");
40405
+ /** What a model (or, by default, every model of a kind) can do. */
40406
+ var LlmModelFeaturesSchema = object({
40407
+ vision: boolean(),
40408
+ tools: boolean(),
40409
+ streaming: boolean()
40410
+ });
40411
+ /** One model a provider offers. `features` overrides the kind's defaults, per field. */
40412
+ var LlmModelInfoSchema = object({
40413
+ id: string(),
40414
+ label: string().optional(),
40415
+ contextLength: number().int().positive().optional(),
40416
+ features: LlmModelFeaturesSchema.partial().optional()
40417
+ });
40124
40418
  /**
40125
- * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
40126
- * methods concat-fan across providers; single-row methods route to ONE
40127
- * provider by the `addonId` in the call input (the notification-output
40128
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
40129
- * (hub-placed); the cap stays open for future providers.
40130
- *
40131
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
40132
- * `apiKey` is a password field — providers REDACT it on read and merge on
40133
- * write; a stored key NEVER round-trips to a client.
40419
+ * The provider-specific part of a profile, validated by the provider that owns
40420
+ * the kind (`upsertProfile` refuses what it does not accept). A field its
40421
+ * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
40422
+ * keychain, never in the row, and reads back as the redaction marker.
40134
40423
  */
40135
- var LlmProfileKindSchema = _enum([
40136
- "openai-compatible",
40137
- "openai",
40138
- "anthropic",
40139
- "google",
40140
- "managed-local",
40141
- "apple-foundation"
40142
- ]);
40424
+ var LlmProviderConfigSchema = record(string(), unknown());
40143
40425
  var LlmProfileSchema = object({
40144
40426
  id: string(),
40145
40427
  name: string(),
40428
+ /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
40146
40429
  kind: LlmProfileKindSchema,
40147
40430
  /** Stamped by the provider — keeps the fanned catalog routable. */
40148
40431
  addonId: string(),
40149
40432
  enabled: boolean(),
40150
40433
  /** Vendor model id, or the managed runtime's loaded model. */
40151
40434
  model: string(),
40152
- /** Required for openai-compatible; override for cloud kinds. */
40153
- baseUrl: string().optional(),
40154
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
40155
- apiKey: string().optional(),
40156
40435
  /** Vision on/off. A vision call against a `false` profile is REFUSED, never
40157
40436
  * degraded to text — that shipped once and produced a confident answer to a
40158
40437
  * question about a picture nobody sent. */
@@ -40160,15 +40439,11 @@ var LlmProfileSchema = object({
40160
40439
  temperature: number().min(0).max(2).optional(),
40161
40440
  /** Nucleus sampling. Every wire we speak has it. */
40162
40441
  topP: number().min(0).max(1).optional(),
40163
- /** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
40164
- * wire does, and the client drops it there (measured: the request body gets
40165
- * `top_p` and no `top_k`). The profile editor hides the field wherever it
40166
- * would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
40442
+ /** Top-k sampling. Carried only by the wires that have it — a kind offers the
40443
+ * field in its editor only when its descriptor lists it in `profileFields`. */
40167
40444
  topK: number().int().positive().optional(),
40168
40445
  maxTokens: number().int().positive().optional(),
40169
- /** Prompt context window. Advisory for cloud kinds (they enforce their own);
40170
- * for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
40171
- * the model with, so it is the one field that changes a PROCESS. */
40446
+ /** Prompt context window. Advisory for cloud kinds (they enforce their own). */
40172
40447
  contextLength: number().int().positive().optional(),
40173
40448
  /** Default system prompt. A caller's `system` REPLACES it (never appends —
40174
40449
  * two system prompts fighting is worse than either alone). */
@@ -40194,16 +40469,37 @@ var LlmProfileSchema = object({
40194
40469
  * library; the REGISTRY of callable tools is ours and is empty in v1, so a
40195
40470
  * `true` here buys the wiring, not behaviour, until tools are registered. */
40196
40471
  toolsEnabled: boolean().default(false),
40197
- extraHeaders: record(string(), string()).optional(),
40198
- /** kind === 'managed-local' only (spec §4). */
40199
- runtime: ManagedRuntimeConfigSchema.optional(),
40200
- /**
40201
- * kind === 'apple-foundation' only: WHERE it runs — the only thing there is
40202
- * to configure (no key, no URL, no download; `model` is `apple-system`).
40203
- * `supportsVision` on such a row is stamped by the provider from the node's
40204
- * reported `imageInput`, never taken from the operator (D62).
40205
- */
40206
- appleFoundation: object({ nodeId: string() }).optional()
40472
+ /** Everything the kind's provider owns (endpoint, key, node, runtime…). */
40473
+ providerConfig: LlmProviderConfigSchema.default({})
40474
+ });
40475
+ /**
40476
+ * The common profile fields a kind's editor offers. The editor owns how each
40477
+ * one is drawn; the provider says which of them mean something on its wire.
40478
+ */
40479
+ var LlmProfileFieldSchema = _enum([
40480
+ "temperature",
40481
+ "topP",
40482
+ "topK",
40483
+ "maxTokens",
40484
+ "contextLength",
40485
+ "systemPrompt",
40486
+ "timeoutMs",
40487
+ "connectTimeoutMs",
40488
+ "firstTokenTimeoutMs",
40489
+ "idleTimeoutMs",
40490
+ "retry",
40491
+ "toolsEnabled"
40492
+ ]);
40493
+ /**
40494
+ * A provider-drawn part of the editor, by a generic widget id the admin UI
40495
+ * registers (`ai/apple-node`). `placement: 'model'` replaces the generic model
40496
+ * picker: that widget owns the model choice.
40497
+ */
40498
+ var LlmProviderWidgetSchema = object({
40499
+ id: string(),
40500
+ placement: _enum(["connection", "model"]),
40501
+ /** `providerConfig` keys this widget must fill before the profile can be saved. */
40502
+ requires: array(string()).optional()
40207
40503
  });
40208
40504
  /** ConfigUISchema tree passed through untyped on the wire (the
40209
40505
  * notification-output `ConfigSchemaPassthrough` precedent at
@@ -40212,11 +40508,56 @@ var ConfigSchemaPassthrough$3 = unknown();
40212
40508
  var LlmProfileKindDescriptorSchema = object({
40213
40509
  kind: LlmProfileKindSchema,
40214
40510
  label: string(),
40511
+ /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
40215
40512
  icon: string(),
40216
40513
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
40217
40514
  addonId: string(),
40218
- configSchema: ConfigSchemaPassthrough$3
40515
+ /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
40516
+ connectionSchema: ConfigSchemaPassthrough$3,
40517
+ /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
40518
+ advancedSchema: ConfigSchemaPassthrough$3.optional(),
40519
+ /** The kind's defaults; a model from `listModels` may override any of them. */
40520
+ features: LlmModelFeaturesSchema,
40521
+ /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
40522
+ visionEditable: boolean(),
40523
+ /** Where the model list comes from: `listModels`, `staticModels`, or nowhere. */
40524
+ modelCatalog: _enum([
40525
+ "fetch",
40526
+ "static",
40527
+ "none"
40528
+ ]),
40529
+ staticModels: array(LlmModelInfoSchema).optional(),
40530
+ /** The common fields that mean something on this kind's wire. */
40531
+ profileFields: array(LlmProfileFieldSchema),
40532
+ providerWidgets: array(LlmProviderWidgetSchema).optional()
40533
+ });
40534
+ /**
40535
+ * `listModels` input. `connection` is an UNSAVED draft of `providerConfig`
40536
+ * (the editor's form); with `profileId` too, a secret the draft leaves
40537
+ * untouched (absent or the redaction marker) is resolved server-side from the
40538
+ * stored profile — the browser never receives it.
40539
+ */
40540
+ var LlmListModelsInputSchema = object({
40541
+ addonId: string(),
40542
+ kind: LlmProfileKindSchema,
40543
+ profileId: string().optional(),
40544
+ connection: LlmProviderConfigSchema.optional()
40219
40545
  });
40546
+ var LlmListModelsErrorCodeSchema = _enum([
40547
+ "auth",
40548
+ "network",
40549
+ "unsupported",
40550
+ "invalid"
40551
+ ]);
40552
+ /** A RESULT, never a throw: "wrong key" is an answer the editor renders inline. */
40553
+ var LlmListModelsResultSchema = discriminatedUnion("ok", [object({
40554
+ ok: literal(true),
40555
+ models: array(LlmModelInfoSchema)
40556
+ }), object({
40557
+ ok: literal(false),
40558
+ code: LlmListModelsErrorCodeSchema,
40559
+ message: string()
40560
+ })]);
40220
40561
  var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
40221
40562
  var LlmDefaultSchema = object({
40222
40563
  selector: LlmDefaultSelectorSchema,
@@ -40316,7 +40657,10 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
40316
40657
  kind: "mutation",
40317
40658
  auth: "admin",
40318
40659
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
40319
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
40660
+ }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
40661
+ kind: "mutation",
40662
+ auth: "admin"
40663
+ }), method(object({}), array(LlmDefaultSchema)), method(object({
40320
40664
  selector: LlmDefaultSelectorSchema,
40321
40665
  profileId: string().nullable()
40322
40666
  }), _void(), {
@@ -44422,202 +44766,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
44422
44766
  auth: "admin"
44423
44767
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
44424
44768
  /**
44425
- * Zod schemas for persisted record types.
44426
- *
44427
- * These schemas serve as the single source of truth for types that are
44428
- * stored in the settings-store backend and retrieved via tRPC. They
44429
- * replace the manual TypeScript interfaces with schema-derived types,
44430
- * enabling runtime validation when reading from the backend.
44431
- *
44432
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
44433
- * keeps the original name for backward compatibility.
44434
- */
44435
- /**
44436
- * Auth model (v2 — 2026-05-12 caps-only):
44437
- *
44438
- * Two principals:
44439
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
44440
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
44441
- *
44442
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44443
- * `super_admin` — collapsed onto the single boolean because every
44444
- * non-admin caller is governed by the same scope-check rules; the
44445
- * distinction was only ever used to route role-specific procedures
44446
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44447
- * with `isAdmin: false` + an explicit scope list.
44448
- */
44449
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44450
- var MethodAccessSchema = _enum([
44451
- "view",
44452
- "create",
44453
- "delete"
44454
- ]);
44455
- /**
44456
- * A single scope grant. Three forms — checked in matcher with OR
44457
- * semantics; the first match decides whether the call passes:
44458
- *
44459
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44460
- * cap with the matching `scope` declaration. New caps inherit grants
44461
- * automatically — adding a device cap to the codebase makes it
44462
- * reachable to every user with `category:device [...]` without a
44463
- * re-grant. Use this for "family viewer" / "operator" tiers.
44464
- *
44465
- * - `addon` — every cap that ships inside a given addon id. Niche;
44466
- * useful when an integration needs to interact with one specific
44467
- * addon's surface regardless of how many caps it exports.
44468
- *
44469
- * - `capability` — the most precise form. Single cap name. Use for
44470
- * integration tokens where you want to grant `addons.installPackage`
44471
- * and nothing else.
44472
- *
44473
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44474
- * "give me everything" escape; there is no wildcard scope.
44475
- */
44476
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44477
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44478
- var CapScopeSchema = _enum(["device", "system"]);
44479
- /**
44480
- * DeviceSelector (scope model v3 — 2026-08-12).
44481
- *
44482
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44483
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44484
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44485
- * AFTER the grant was minted — no re-grant, no re-login.
44486
- *
44487
- * - `all` — every device in the deployment. The broad viewer/operator
44488
- * lever without a `category` grant (a `category` grant also covers device
44489
- * caps that carry no deviceId; `all` is specifically the device set).
44490
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44491
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44492
- * is NOT covered until the grant is edited.
44493
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44494
- * DYNAMIC. A device that changes type, or a new device of the type,
44495
- * re-resolves on the next request.
44496
- * - `locations` — every device whose operator-assigned `location` label is
44497
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44498
- * null/unset location matches NO `locations` selector.
44499
- */
44500
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44501
- object({ kind: literal("all") }),
44502
- object({
44503
- kind: literal("ids"),
44504
- ids: array(number().int()).min(1)
44505
- }),
44506
- object({
44507
- kind: literal("types"),
44508
- types: array(_enum(DeviceType)).min(1)
44509
- }),
44510
- object({
44511
- kind: literal("locations"),
44512
- locations: array(string().min(1)).min(1)
44513
- })
44514
- ]);
44515
- var DeviceTokenScopeSchema = object({
44516
- type: literal("device"),
44517
- /** The device SET this grant covers — resolved against the live fleet. */
44518
- selector: DeviceSelectorSchema,
44519
- access: array(MethodAccessSchema).min(1),
44520
- /**
44521
- * Whether a grant on a PARENT device transparently covers its accessory
44522
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44523
- * Direction is parent → children ONLY.
44524
- *
44525
- * Absent → the matcher DERIVES it from the access flavour: `view`
44526
- * inherits (a camera viewer sees the camera's accessories), `create` /
44527
- * `delete` do NOT (actuating/removing a child is an explicit act the
44528
- * operator must grant on the child, not inherit from the parent). Set it
44529
- * explicitly to override that default per grant.
44530
- */
44531
- includeLinked: boolean().optional()
44532
- });
44533
- /**
44534
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44535
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44536
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44537
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44538
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44539
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44540
- * migration cannot reach a JWT already in a client's hands; parse-time
44541
- * migration covers both without a flag day. No cast — the raw object is read
44542
- * through `Reflect.get` (its static type is `unknown`).
44543
- */
44544
- function migrateLegacyTokenScope(raw) {
44545
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44546
- if (Reflect.get(raw, "type") !== "device") return raw;
44547
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44548
- const targets = Reflect.get(raw, "targets");
44549
- if (!Array.isArray(targets)) return raw;
44550
- return {
44551
- type: "device",
44552
- selector: {
44553
- kind: "ids",
44554
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44555
- },
44556
- access: Reflect.get(raw, "access")
44557
- };
44558
- }
44559
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44560
- object({
44561
- type: literal("category"),
44562
- target: CapScopeSchema,
44563
- access: array(MethodAccessSchema).min(1)
44564
- }),
44565
- object({
44566
- type: literal("capability"),
44567
- target: string(),
44568
- access: array(MethodAccessSchema).min(1)
44569
- }),
44570
- object({
44571
- type: literal("addon"),
44572
- target: string(),
44573
- access: array(MethodAccessSchema).min(1)
44574
- }),
44575
- DeviceTokenScopeSchema
44576
- ]));
44577
- object({
44578
- id: string(),
44579
- username: string(),
44580
- passwordHash: string(),
44581
- /**
44582
- * Admin bypass. When true, the middleware skips the scope-access
44583
- * check entirely. There is no other axis of privilege; the legacy
44584
- * role enum collapsed onto this boolean in v2.
44585
- */
44586
- isAdmin: boolean().default(false),
44587
- allowedProviders: AllowedProviderSchema,
44588
- allowedDevices: AllowedDevicesSchema,
44589
- /**
44590
- * Scopes granted to this user. Admins bypass; their `scopes` is
44591
- * ignored. Non-admins without scopes are locked out of every
44592
- * protected call.
44593
- */
44594
- scopes: array(TokenScopeSchema).default([]),
44595
- createdAt: number(),
44596
- updatedAt: number()
44597
- });
44598
- object({
44599
- id: string(),
44600
- label: string(),
44601
- isAdmin: boolean().default(false),
44602
- allowedProviders: AllowedProviderSchema,
44603
- allowedDevices: AllowedDevicesSchema,
44604
- tokenHash: string(),
44605
- tokenPrefix: string(),
44606
- createdAt: number(),
44607
- lastUsedAt: number().optional()
44608
- });
44609
- object({
44610
- id: string(),
44611
- userId: string(),
44612
- name: string(),
44613
- tokenHash: string(),
44614
- tokenPrefix: string(),
44615
- scopes: array(TokenScopeSchema),
44616
- expiresAt: number().nullish(),
44617
- lastUsedAt: number().nullish(),
44618
- createdAt: number()
44619
- });
44620
- /**
44621
44769
  * `oauth-integration` — a collection cap by which an addon declares
44622
44770
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44623
44771
  * Each provider returns a static descriptor; the core enumerates them
@@ -65483,26 +65631,6 @@ var ApiKeySummarySchema = object({
65483
65631
  createdAt: number(),
65484
65632
  lastUsedAt: number().optional()
65485
65633
  });
65486
- var ScopedTokenSummarySchema = object({
65487
- id: string(),
65488
- userId: string(),
65489
- name: string(),
65490
- tokenPrefix: string(),
65491
- scopes: array(TokenScopeSchema),
65492
- expiresAt: number().nullish(),
65493
- lastUsedAt: number().nullish(),
65494
- createdAt: number()
65495
- });
65496
- var CreateScopedTokenInputSchema = object({
65497
- userId: string(),
65498
- name: string(),
65499
- scopes: array(TokenScopeSchema),
65500
- expiresAt: number().optional()
65501
- });
65502
- var CreateScopedTokenResultSchema = object({
65503
- token: string(),
65504
- record: ScopedTokenSummarySchema
65505
- });
65506
65634
  var OauthSessionSummarySchema = object({
65507
65635
  id: string(),
65508
65636
  userId: string(),
@@ -65524,11 +65652,11 @@ var TotpStatusSchema = object({
65524
65652
  confirmedAt: number().nullable()
65525
65653
  });
65526
65654
  /**
65527
- * user-management — singleton capability for user accounts, API keys,
65528
- * and scoped tokens.
65655
+ * user-management — singleton capability for user accounts and the
65656
+ * legacy API-key rows.
65529
65657
  *
65530
65658
  * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
65531
- * — the subset check on `setUserScopes` / `createScopedToken` is moot
65659
+ * — the subset check on `setUserScopes` is moot
65532
65660
  * because non-admins never reach these. If/when we open non-admin
65533
65661
  * delegation, structural caller-scope subset check goes inside the
65534
65662
  * provider.
@@ -65585,15 +65713,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
65585
65713
  kind: "mutation",
65586
65714
  auth: "admin",
65587
65715
  access: "delete"
65588
- }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
65589
- kind: "mutation",
65590
- auth: "admin",
65591
- access: "create"
65592
- }), method(object({ id: string() }), object({ success: literal(true) }), {
65593
- kind: "mutation",
65594
- auth: "admin",
65595
- access: "delete"
65596
- }), method(object({ token: string() }), ScopedTokenSummarySchema.nullable(), { access: "view" }), method(object({ userId: string() }), array(ScopedTokenSummarySchema), { auth: "admin" }), method(object({ userId: string() }), TotpSetupResultSchema, {
65716
+ }), method(object({ userId: string() }), TotpSetupResultSchema, {
65597
65717
  kind: "mutation",
65598
65718
  auth: "admin",
65599
65719
  access: "create"
@@ -71702,7 +71822,7 @@ Object.freeze({
71702
71822
  capName: "llm",
71703
71823
  capScope: "system",
71704
71824
  addonId: null,
71705
- access: "view"
71825
+ access: "create"
71706
71826
  },
71707
71827
  "llm.listNodeModels": {
71708
71828
  capName: "llm",
@@ -76366,12 +76486,6 @@ Object.freeze({
76366
76486
  addonId: null,
76367
76487
  access: "create"
76368
76488
  },
76369
- "userManagement.createScopedToken": {
76370
- capName: "user-management",
76371
- capScope: "system",
76372
- addonId: null,
76373
- access: "create"
76374
- },
76375
76489
  "userManagement.createUser": {
76376
76490
  capName: "user-management",
76377
76491
  capScope: "system",
@@ -76420,12 +76534,6 @@ Object.freeze({
76420
76534
  addonId: null,
76421
76535
  access: "view"
76422
76536
  },
76423
- "userManagement.listScopedTokens": {
76424
- capName: "user-management",
76425
- capScope: "system",
76426
- addonId: null,
76427
- access: "view"
76428
- },
76429
76537
  "userManagement.listUsers": {
76430
76538
  capName: "user-management",
76431
76539
  capScope: "system",
@@ -76480,12 +76588,6 @@ Object.freeze({
76480
76588
  addonId: null,
76481
76589
  access: "delete"
76482
76590
  },
76483
- "userManagement.revokeScopedToken": {
76484
- capName: "user-management",
76485
- capScope: "system",
76486
- addonId: null,
76487
- access: "delete"
76488
- },
76489
76591
  "userManagement.setupTotp": {
76490
76592
  capName: "user-management",
76491
76593
  capScope: "system",
@@ -76516,12 +76618,6 @@ Object.freeze({
76516
76618
  addonId: null,
76517
76619
  access: "view"
76518
76620
  },
76519
- "userManagement.validateScopedToken": {
76520
- capName: "user-management",
76521
- capScope: "system",
76522
- addonId: null,
76523
- access: "view"
76524
- },
76525
76621
  "userManagement.verifyTotp": {
76526
76622
  capName: "user-management",
76527
76623
  capScope: "system",