@camstack/addon-provider-onvif 1.2.131 → 1.2.133

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
@@ -5418,7 +5418,7 @@ var ZodIssueCode = {
5418
5418
  var ZodFirstPartyTypeKind;
5419
5419
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5420
5420
  //#endregion
5421
- //#region ../types/dist/sleep-BxjU_fJM.mjs
5421
+ //#region ../types/dist/sleep-yKL5gfrH.mjs
5422
5422
  /**
5423
5423
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5424
5424
  * window to float samples (D455).
@@ -7800,6 +7800,12 @@ function normalizeAddonInitResult(result) {
7800
7800
  if (Array.isArray(result)) return { providers: result };
7801
7801
  return result;
7802
7802
  }
7803
+ /**
7804
+ * The share-view scope kinds a share-link token can carry. The hub mints
7805
+ * and validates them (`ShareViewGrantSchema` builds its
7806
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
7807
+ */
7808
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7803
7809
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7804
7810
  var PeerBytesTicketSchema = object({
7805
7811
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12394,6 +12400,280 @@ var ConvertResultSchema = object({
12394
12400
  files: array(string()).readonly()
12395
12401
  })).readonly()
12396
12402
  });
12403
+ /**
12404
+ * Zod schemas for persisted record types.
12405
+ *
12406
+ * These schemas serve as the single source of truth for types that are
12407
+ * stored in the settings-store backend and retrieved via tRPC. They
12408
+ * replace the manual TypeScript interfaces with schema-derived types,
12409
+ * enabling runtime validation when reading from the backend.
12410
+ *
12411
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12412
+ * keeps the original name for backward compatibility.
12413
+ */
12414
+ /**
12415
+ * Auth model (v2 — 2026-05-12 caps-only):
12416
+ *
12417
+ * Two principals:
12418
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12419
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12420
+ *
12421
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12422
+ * `super_admin` — collapsed onto the single boolean because every
12423
+ * non-admin caller is governed by the same scope-check rules; the
12424
+ * distinction was only ever used to route role-specific procedures
12425
+ * which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
12426
+ * with `isAdmin: false` + an explicit scope list.
12427
+ */
12428
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12429
+ var MethodAccessSchema = _enum([
12430
+ "view",
12431
+ "create",
12432
+ "delete"
12433
+ ]);
12434
+ /**
12435
+ * A single scope grant. Three forms — checked in matcher with OR
12436
+ * semantics; the first match decides whether the call passes:
12437
+ *
12438
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12439
+ * cap with the matching `scope` declaration. New caps inherit grants
12440
+ * automatically — adding a device cap to the codebase makes it
12441
+ * reachable to every user with `category:device [...]` without a
12442
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12443
+ *
12444
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12445
+ * useful when an integration needs to interact with one specific
12446
+ * addon's surface regardless of how many caps it exports.
12447
+ *
12448
+ * - `capability` — the most precise form. Single cap name. Use for
12449
+ * integration tokens where you want to grant `addons.installPackage`
12450
+ * and nothing else.
12451
+ *
12452
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12453
+ * "give me everything" escape; there is no wildcard scope.
12454
+ */
12455
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12456
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12457
+ var CapScopeSchema = _enum(["device", "system"]);
12458
+ /**
12459
+ * DeviceSelector (scope model v3 — 2026-08-12).
12460
+ *
12461
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12462
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12463
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12464
+ * AFTER the grant was minted — no re-grant, no re-login.
12465
+ *
12466
+ * - `all` — every device in the deployment. The broad viewer/operator
12467
+ * lever without a `category` grant (a `category` grant also covers device
12468
+ * caps that carry no deviceId; `all` is specifically the device set).
12469
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
12470
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
12471
+ * is NOT covered until the grant is edited.
12472
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
12473
+ * DYNAMIC. A device that changes type, or a new device of the type,
12474
+ * re-resolves on the next request.
12475
+ * - `locations` — every device whose operator-assigned `location` label is
12476
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
12477
+ * null/unset location matches NO `locations` selector.
12478
+ */
12479
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
12480
+ object({ kind: literal("all") }),
12481
+ object({
12482
+ kind: literal("ids"),
12483
+ ids: array(number().int()).min(1)
12484
+ }),
12485
+ object({
12486
+ kind: literal("types"),
12487
+ types: array(_enum(DeviceType)).min(1)
12488
+ }),
12489
+ object({
12490
+ kind: literal("locations"),
12491
+ locations: array(string().min(1)).min(1)
12492
+ })
12493
+ ]);
12494
+ var DeviceTokenScopeSchema = object({
12495
+ type: literal("device"),
12496
+ /** The device SET this grant covers — resolved against the live fleet. */
12497
+ selector: DeviceSelectorSchema,
12498
+ access: array(MethodAccessSchema).min(1),
12499
+ /**
12500
+ * Whether a grant on a PARENT device transparently covers its accessory
12501
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
12502
+ * Direction is parent → children ONLY.
12503
+ *
12504
+ * Absent → the matcher DERIVES it from the access flavour: `view`
12505
+ * inherits (a camera viewer sees the camera's accessories), `create` /
12506
+ * `delete` do NOT (actuating/removing a child is an explicit act the
12507
+ * operator must grant on the child, not inherit from the parent). Set it
12508
+ * explicitly to override that default per grant.
12509
+ */
12510
+ includeLinked: boolean().optional()
12511
+ });
12512
+ /**
12513
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
12514
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
12515
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
12516
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
12517
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
12518
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
12519
+ * migration cannot reach a JWT already in a client's hands; parse-time
12520
+ * migration covers both without a flag day. No cast — the raw object is read
12521
+ * through `Reflect.get` (its static type is `unknown`).
12522
+ */
12523
+ function migrateLegacyTokenScope(raw) {
12524
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
12525
+ if (Reflect.get(raw, "type") !== "device") return raw;
12526
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
12527
+ const targets = Reflect.get(raw, "targets");
12528
+ if (!Array.isArray(targets)) return raw;
12529
+ return {
12530
+ type: "device",
12531
+ selector: {
12532
+ kind: "ids",
12533
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
12534
+ },
12535
+ access: Reflect.get(raw, "access")
12536
+ };
12537
+ }
12538
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
12539
+ object({
12540
+ type: literal("category"),
12541
+ target: CapScopeSchema,
12542
+ access: array(MethodAccessSchema).min(1)
12543
+ }),
12544
+ object({
12545
+ type: literal("capability"),
12546
+ target: string(),
12547
+ access: array(MethodAccessSchema).min(1)
12548
+ }),
12549
+ object({
12550
+ type: literal("addon"),
12551
+ target: string(),
12552
+ access: array(MethodAccessSchema).min(1)
12553
+ }),
12554
+ DeviceTokenScopeSchema
12555
+ ]));
12556
+ object({
12557
+ id: string(),
12558
+ username: string(),
12559
+ passwordHash: string(),
12560
+ /**
12561
+ * Admin bypass. When true, the middleware skips the scope-access
12562
+ * check entirely. There is no other axis of privilege; the legacy
12563
+ * role enum collapsed onto this boolean in v2.
12564
+ */
12565
+ isAdmin: boolean().default(false),
12566
+ allowedProviders: AllowedProviderSchema,
12567
+ allowedDevices: AllowedDevicesSchema,
12568
+ /**
12569
+ * Scopes granted to this user. Admins bypass; their `scopes` is
12570
+ * ignored. Non-admins without scopes are locked out of every
12571
+ * protected call.
12572
+ */
12573
+ scopes: array(TokenScopeSchema).default([]),
12574
+ createdAt: number(),
12575
+ updatedAt: number()
12576
+ });
12577
+ object({
12578
+ id: string(),
12579
+ label: string(),
12580
+ isAdmin: boolean().default(false),
12581
+ allowedProviders: AllowedProviderSchema,
12582
+ allowedDevices: AllowedDevicesSchema,
12583
+ tokenHash: string(),
12584
+ tokenPrefix: string(),
12585
+ createdAt: number(),
12586
+ lastUsedAt: number().optional()
12587
+ });
12588
+ object({
12589
+ id: string(),
12590
+ userId: string(),
12591
+ name: string(),
12592
+ tokenHash: string(),
12593
+ tokenPrefix: string(),
12594
+ scopes: array(TokenScopeSchema),
12595
+ expiresAt: number().nullish(),
12596
+ lastUsedAt: number().nullish(),
12597
+ createdAt: number()
12598
+ });
12599
+ /** What a share-view grant lets its holder see. */
12600
+ var ShareViewGrantSchema = object({
12601
+ kind: _enum(SHARE_VIEW_KINDS),
12602
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
12603
+ /** Talk-back, opt-in at mint time; absent means off. */
12604
+ talk: boolean().optional()
12605
+ });
12606
+ var ShareViewScopeSchema = object({
12607
+ type: literal("share-view"),
12608
+ grant: ShareViewGrantSchema
12609
+ });
12610
+ var AddonRoutesScopeSchema = object({
12611
+ type: literal("addon-routes"),
12612
+ access: array(MethodAccessSchema).min(1)
12613
+ });
12614
+ var PreferencesSelfScopeSchema = object({ type: literal("preferences-self") });
12615
+ var CredentialScopeSchema = union([
12616
+ literal("*"),
12617
+ ShareViewScopeSchema,
12618
+ AddonRoutesScopeSchema,
12619
+ PreferencesSelfScopeSchema,
12620
+ TokenScopeSchema
12621
+ ]);
12622
+ object({
12623
+ kind: literal("credential"),
12624
+ sub: string().min(1),
12625
+ jti: string().min(16),
12626
+ scopes: array(CredentialScopeSchema).min(1)
12627
+ });
12628
+ var PreferenceNamespaceSchema = string().regex(/^[a-z][a-z0-9.-]{0,63}$/);
12629
+ /** A namespace's value: a JSON object, opaque to the hub. */
12630
+ var PreferenceValueSchema = record(string(), unknown());
12631
+ var PreferenceDeviceIdSchema = string().min(1).max(64);
12632
+ /** A stored row, as the owner reads it. */
12633
+ var PreferenceRowSchema = object({
12634
+ namespace: PreferenceNamespaceSchema,
12635
+ value: PreferenceValueSchema,
12636
+ /** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
12637
+ revision: number().int().positive(),
12638
+ updatedAt: number().int(),
12639
+ /** The client id the last writer sent; `null` when it sent none. */
12640
+ updatedByDevice: PreferenceDeviceIdSchema.nullable()
12641
+ });
12642
+ object({
12643
+ /** Absent: every namespace the caller holds. */
12644
+ namespaces: array(PreferenceNamespaceSchema).max(32).optional() });
12645
+ object({ rows: array(PreferenceRowSchema) });
12646
+ object({
12647
+ namespace: PreferenceNamespaceSchema,
12648
+ value: PreferenceValueSchema,
12649
+ /**
12650
+ * The revision the edit was based on. Absent: last write wins. `0`: the
12651
+ * namespace must not exist yet. Any other value that is not the current
12652
+ * revision answers `conflict` and writes nothing.
12653
+ */
12654
+ baseRevision: number().int().nonnegative().optional(),
12655
+ deviceId: PreferenceDeviceIdSchema.optional()
12656
+ });
12657
+ discriminatedUnion("status", [object({
12658
+ status: literal("saved"),
12659
+ row: PreferenceRowSchema
12660
+ }), object({
12661
+ status: literal("conflict"),
12662
+ current: PreferenceRowSchema.nullable()
12663
+ })]);
12664
+ object({ namespace: PreferenceNamespaceSchema });
12665
+ object({
12666
+ /** `false` when the namespace did not exist. */
12667
+ deleted: boolean() });
12668
+ object({
12669
+ /** The revision the client holds per namespace; a namespace it does not list is new to it. */
12670
+ revisionByNamespace: record(PreferenceNamespaceSchema, number().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
12671
+ object({
12672
+ /** Every row whose revision differs from the client's, and every row it did not list. */
12673
+ rows: array(PreferenceRowSchema),
12674
+ /** Namespaces the client listed that no longer exist. */
12675
+ deleted: array(PreferenceNamespaceSchema)
12676
+ });
12397
12677
  _enum(["new-session", "step-up"]);
12398
12678
  /** The languages the hub's app landing pages are written in (D858). */
12399
12679
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -39466,38 +39746,37 @@ method(LlmRuntimeCompleteInputSchema, LlmGenerateResultSchema, {
39466
39746
  auth: "admin",
39467
39747
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39468
39748
  });
39749
+ var LlmProfileKindSchema = string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "a kind id is lower-case letters, digits and dashes");
39750
+ /** What a model (or, by default, every model of a kind) can do. */
39751
+ var LlmModelFeaturesSchema = object({
39752
+ vision: boolean(),
39753
+ tools: boolean(),
39754
+ streaming: boolean()
39755
+ });
39756
+ /** One model a provider offers. `features` overrides the kind's defaults, per field. */
39757
+ var LlmModelInfoSchema = object({
39758
+ id: string(),
39759
+ label: string().optional(),
39760
+ contextLength: number().int().positive().optional(),
39761
+ features: LlmModelFeaturesSchema.partial().optional()
39762
+ });
39469
39763
  /**
39470
- * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
39471
- * methods concat-fan across providers; single-row methods route to ONE
39472
- * provider by the `addonId` in the call input (the notification-output
39473
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
39474
- * (hub-placed); the cap stays open for future providers.
39475
- *
39476
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
39477
- * `apiKey` is a password field — providers REDACT it on read and merge on
39478
- * write; a stored key NEVER round-trips to a client.
39764
+ * The provider-specific part of a profile, validated by the provider that owns
39765
+ * the kind (`upsertProfile` refuses what it does not accept). A field its
39766
+ * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
39767
+ * keychain, never in the row, and reads back as the redaction marker.
39479
39768
  */
39480
- var LlmProfileKindSchema = _enum([
39481
- "openai-compatible",
39482
- "openai",
39483
- "anthropic",
39484
- "google",
39485
- "managed-local",
39486
- "apple-foundation"
39487
- ]);
39769
+ var LlmProviderConfigSchema = record(string(), unknown());
39488
39770
  var LlmProfileSchema = object({
39489
39771
  id: string(),
39490
39772
  name: string(),
39773
+ /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
39491
39774
  kind: LlmProfileKindSchema,
39492
39775
  /** Stamped by the provider — keeps the fanned catalog routable. */
39493
39776
  addonId: string(),
39494
39777
  enabled: boolean(),
39495
39778
  /** Vendor model id, or the managed runtime's loaded model. */
39496
39779
  model: string(),
39497
- /** Required for openai-compatible; override for cloud kinds. */
39498
- baseUrl: string().optional(),
39499
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
39500
- apiKey: string().optional(),
39501
39780
  /** Vision on/off. A vision call against a `false` profile is REFUSED, never
39502
39781
  * degraded to text — that shipped once and produced a confident answer to a
39503
39782
  * question about a picture nobody sent. */
@@ -39505,15 +39784,11 @@ var LlmProfileSchema = object({
39505
39784
  temperature: number().min(0).max(2).optional(),
39506
39785
  /** Nucleus sampling. Every wire we speak has it. */
39507
39786
  topP: number().min(0).max(1).optional(),
39508
- /** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
39509
- * wire does, and the client drops it there (measured: the request body gets
39510
- * `top_p` and no `top_k`). The profile editor hides the field wherever it
39511
- * would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
39787
+ /** Top-k sampling. Carried only by the wires that have it — a kind offers the
39788
+ * field in its editor only when its descriptor lists it in `profileFields`. */
39512
39789
  topK: number().int().positive().optional(),
39513
39790
  maxTokens: number().int().positive().optional(),
39514
- /** Prompt context window. Advisory for cloud kinds (they enforce their own);
39515
- * for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
39516
- * the model with, so it is the one field that changes a PROCESS. */
39791
+ /** Prompt context window. Advisory for cloud kinds (they enforce their own). */
39517
39792
  contextLength: number().int().positive().optional(),
39518
39793
  /** Default system prompt. A caller's `system` REPLACES it (never appends —
39519
39794
  * two system prompts fighting is worse than either alone). */
@@ -39539,16 +39814,37 @@ var LlmProfileSchema = object({
39539
39814
  * library; the REGISTRY of callable tools is ours and is empty in v1, so a
39540
39815
  * `true` here buys the wiring, not behaviour, until tools are registered. */
39541
39816
  toolsEnabled: boolean().default(false),
39542
- extraHeaders: record(string(), string()).optional(),
39543
- /** kind === 'managed-local' only (spec §4). */
39544
- runtime: ManagedRuntimeConfigSchema.optional(),
39545
- /**
39546
- * kind === 'apple-foundation' only: WHERE it runs — the only thing there is
39547
- * to configure (no key, no URL, no download; `model` is `apple-system`).
39548
- * `supportsVision` on such a row is stamped by the provider from the node's
39549
- * reported `imageInput`, never taken from the operator (D62).
39550
- */
39551
- appleFoundation: object({ nodeId: string() }).optional()
39817
+ /** Everything the kind's provider owns (endpoint, key, node, runtime…). */
39818
+ providerConfig: LlmProviderConfigSchema.default({})
39819
+ });
39820
+ /**
39821
+ * The common profile fields a kind's editor offers. The editor owns how each
39822
+ * one is drawn; the provider says which of them mean something on its wire.
39823
+ */
39824
+ var LlmProfileFieldSchema = _enum([
39825
+ "temperature",
39826
+ "topP",
39827
+ "topK",
39828
+ "maxTokens",
39829
+ "contextLength",
39830
+ "systemPrompt",
39831
+ "timeoutMs",
39832
+ "connectTimeoutMs",
39833
+ "firstTokenTimeoutMs",
39834
+ "idleTimeoutMs",
39835
+ "retry",
39836
+ "toolsEnabled"
39837
+ ]);
39838
+ /**
39839
+ * A provider-drawn part of the editor, by a generic widget id the admin UI
39840
+ * registers (`ai/apple-node`). `placement: 'model'` replaces the generic model
39841
+ * picker: that widget owns the model choice.
39842
+ */
39843
+ var LlmProviderWidgetSchema = object({
39844
+ id: string(),
39845
+ placement: _enum(["connection", "model"]),
39846
+ /** `providerConfig` keys this widget must fill before the profile can be saved. */
39847
+ requires: array(string()).optional()
39552
39848
  });
39553
39849
  /** ConfigUISchema tree passed through untyped on the wire (the
39554
39850
  * notification-output `ConfigSchemaPassthrough` precedent at
@@ -39557,11 +39853,56 @@ var ConfigSchemaPassthrough$3 = unknown();
39557
39853
  var LlmProfileKindDescriptorSchema = object({
39558
39854
  kind: LlmProfileKindSchema,
39559
39855
  label: string(),
39856
+ /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
39560
39857
  icon: string(),
39561
39858
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
39562
39859
  addonId: string(),
39563
- configSchema: ConfigSchemaPassthrough$3
39860
+ /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
39861
+ connectionSchema: ConfigSchemaPassthrough$3,
39862
+ /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
39863
+ advancedSchema: ConfigSchemaPassthrough$3.optional(),
39864
+ /** The kind's defaults; a model from `listModels` may override any of them. */
39865
+ features: LlmModelFeaturesSchema,
39866
+ /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
39867
+ visionEditable: boolean(),
39868
+ /** Where the model list comes from: `listModels`, `staticModels`, or nowhere. */
39869
+ modelCatalog: _enum([
39870
+ "fetch",
39871
+ "static",
39872
+ "none"
39873
+ ]),
39874
+ staticModels: array(LlmModelInfoSchema).optional(),
39875
+ /** The common fields that mean something on this kind's wire. */
39876
+ profileFields: array(LlmProfileFieldSchema),
39877
+ providerWidgets: array(LlmProviderWidgetSchema).optional()
39878
+ });
39879
+ /**
39880
+ * `listModels` input. `connection` is an UNSAVED draft of `providerConfig`
39881
+ * (the editor's form); with `profileId` too, a secret the draft leaves
39882
+ * untouched (absent or the redaction marker) is resolved server-side from the
39883
+ * stored profile — the browser never receives it.
39884
+ */
39885
+ var LlmListModelsInputSchema = object({
39886
+ addonId: string(),
39887
+ kind: LlmProfileKindSchema,
39888
+ profileId: string().optional(),
39889
+ connection: LlmProviderConfigSchema.optional()
39564
39890
  });
39891
+ var LlmListModelsErrorCodeSchema = _enum([
39892
+ "auth",
39893
+ "network",
39894
+ "unsupported",
39895
+ "invalid"
39896
+ ]);
39897
+ /** A RESULT, never a throw: "wrong key" is an answer the editor renders inline. */
39898
+ var LlmListModelsResultSchema = discriminatedUnion("ok", [object({
39899
+ ok: literal(true),
39900
+ models: array(LlmModelInfoSchema)
39901
+ }), object({
39902
+ ok: literal(false),
39903
+ code: LlmListModelsErrorCodeSchema,
39904
+ message: string()
39905
+ })]);
39565
39906
  var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
39566
39907
  var LlmDefaultSchema = object({
39567
39908
  selector: LlmDefaultSelectorSchema,
@@ -39661,7 +40002,10 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
39661
40002
  kind: "mutation",
39662
40003
  auth: "admin",
39663
40004
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39664
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
40005
+ }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
40006
+ kind: "mutation",
40007
+ auth: "admin"
40008
+ }), method(object({}), array(LlmDefaultSchema)), method(object({
39665
40009
  selector: LlmDefaultSelectorSchema,
39666
40010
  profileId: string().nullable()
39667
40011
  }), _void(), {
@@ -43725,202 +44069,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
43725
44069
  auth: "admin"
43726
44070
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
43727
44071
  /**
43728
- * Zod schemas for persisted record types.
43729
- *
43730
- * These schemas serve as the single source of truth for types that are
43731
- * stored in the settings-store backend and retrieved via tRPC. They
43732
- * replace the manual TypeScript interfaces with schema-derived types,
43733
- * enabling runtime validation when reading from the backend.
43734
- *
43735
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
43736
- * keeps the original name for backward compatibility.
43737
- */
43738
- /**
43739
- * Auth model (v2 — 2026-05-12 caps-only):
43740
- *
43741
- * Two principals:
43742
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
43743
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
43744
- *
43745
- * No role enum. There used to be `viewer / agent / scoped` and earlier
43746
- * `super_admin` — collapsed onto the single boolean because every
43747
- * non-admin caller is governed by the same scope-check rules; the
43748
- * distinction was only ever used to route role-specific procedures
43749
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
43750
- * with `isAdmin: false` + an explicit scope list.
43751
- */
43752
- /** Per-method access flavour. Materialised on every cap method via codegen. */
43753
- var MethodAccessSchema = _enum([
43754
- "view",
43755
- "create",
43756
- "delete"
43757
- ]);
43758
- /**
43759
- * A single scope grant. Three forms — checked in matcher with OR
43760
- * semantics; the first match decides whether the call passes:
43761
- *
43762
- * - `category` — broadest. `target: 'device' | 'system'` selects every
43763
- * cap with the matching `scope` declaration. New caps inherit grants
43764
- * automatically — adding a device cap to the codebase makes it
43765
- * reachable to every user with `category:device [...]` without a
43766
- * re-grant. Use this for "family viewer" / "operator" tiers.
43767
- *
43768
- * - `addon` — every cap that ships inside a given addon id. Niche;
43769
- * useful when an integration needs to interact with one specific
43770
- * addon's surface regardless of how many caps it exports.
43771
- *
43772
- * - `capability` — the most precise form. Single cap name. Use for
43773
- * integration tokens where you want to grant `addons.installPackage`
43774
- * and nothing else.
43775
- *
43776
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
43777
- * "give me everything" escape; there is no wildcard scope.
43778
- */
43779
- var AllowedProviderSchema = union([literal("*"), array(string())]);
43780
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
43781
- var CapScopeSchema = _enum(["device", "system"]);
43782
- /**
43783
- * DeviceSelector (scope model v3 — 2026-08-12).
43784
- *
43785
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
43786
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
43787
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
43788
- * AFTER the grant was minted — no re-grant, no re-login.
43789
- *
43790
- * - `all` — every device in the deployment. The broad viewer/operator
43791
- * lever without a `category` grant (a `category` grant also covers device
43792
- * caps that carry no deviceId; `all` is specifically the device set).
43793
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
43794
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
43795
- * is NOT covered until the grant is edited.
43796
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
43797
- * DYNAMIC. A device that changes type, or a new device of the type,
43798
- * re-resolves on the next request.
43799
- * - `locations` — every device whose operator-assigned `location` label is
43800
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
43801
- * null/unset location matches NO `locations` selector.
43802
- */
43803
- var DeviceSelectorSchema = discriminatedUnion("kind", [
43804
- object({ kind: literal("all") }),
43805
- object({
43806
- kind: literal("ids"),
43807
- ids: array(number().int()).min(1)
43808
- }),
43809
- object({
43810
- kind: literal("types"),
43811
- types: array(_enum(DeviceType)).min(1)
43812
- }),
43813
- object({
43814
- kind: literal("locations"),
43815
- locations: array(string().min(1)).min(1)
43816
- })
43817
- ]);
43818
- var DeviceTokenScopeSchema = object({
43819
- type: literal("device"),
43820
- /** The device SET this grant covers — resolved against the live fleet. */
43821
- selector: DeviceSelectorSchema,
43822
- access: array(MethodAccessSchema).min(1),
43823
- /**
43824
- * Whether a grant on a PARENT device transparently covers its accessory
43825
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
43826
- * Direction is parent → children ONLY.
43827
- *
43828
- * Absent → the matcher DERIVES it from the access flavour: `view`
43829
- * inherits (a camera viewer sees the camera's accessories), `create` /
43830
- * `delete` do NOT (actuating/removing a child is an explicit act the
43831
- * operator must grant on the child, not inherit from the parent). Set it
43832
- * explicitly to override that default per grant.
43833
- */
43834
- includeLinked: boolean().optional()
43835
- });
43836
- /**
43837
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
43838
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
43839
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
43840
- * EVERY parse path — stored records AND the JWT-carried scope arrays
43841
- * normalised at the request boundary ({@link normalizeTokenScopes} in
43842
- * `device-selector.ts`). Chosen over a one-time DB migration because a
43843
- * migration cannot reach a JWT already in a client's hands; parse-time
43844
- * migration covers both without a flag day. No cast — the raw object is read
43845
- * through `Reflect.get` (its static type is `unknown`).
43846
- */
43847
- function migrateLegacyTokenScope(raw) {
43848
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
43849
- if (Reflect.get(raw, "type") !== "device") return raw;
43850
- if (Reflect.get(raw, "selector") !== void 0) return raw;
43851
- const targets = Reflect.get(raw, "targets");
43852
- if (!Array.isArray(targets)) return raw;
43853
- return {
43854
- type: "device",
43855
- selector: {
43856
- kind: "ids",
43857
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
43858
- },
43859
- access: Reflect.get(raw, "access")
43860
- };
43861
- }
43862
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
43863
- object({
43864
- type: literal("category"),
43865
- target: CapScopeSchema,
43866
- access: array(MethodAccessSchema).min(1)
43867
- }),
43868
- object({
43869
- type: literal("capability"),
43870
- target: string(),
43871
- access: array(MethodAccessSchema).min(1)
43872
- }),
43873
- object({
43874
- type: literal("addon"),
43875
- target: string(),
43876
- access: array(MethodAccessSchema).min(1)
43877
- }),
43878
- DeviceTokenScopeSchema
43879
- ]));
43880
- object({
43881
- id: string(),
43882
- username: string(),
43883
- passwordHash: string(),
43884
- /**
43885
- * Admin bypass. When true, the middleware skips the scope-access
43886
- * check entirely. There is no other axis of privilege; the legacy
43887
- * role enum collapsed onto this boolean in v2.
43888
- */
43889
- isAdmin: boolean().default(false),
43890
- allowedProviders: AllowedProviderSchema,
43891
- allowedDevices: AllowedDevicesSchema,
43892
- /**
43893
- * Scopes granted to this user. Admins bypass; their `scopes` is
43894
- * ignored. Non-admins without scopes are locked out of every
43895
- * protected call.
43896
- */
43897
- scopes: array(TokenScopeSchema).default([]),
43898
- createdAt: number(),
43899
- updatedAt: number()
43900
- });
43901
- object({
43902
- id: string(),
43903
- label: string(),
43904
- isAdmin: boolean().default(false),
43905
- allowedProviders: AllowedProviderSchema,
43906
- allowedDevices: AllowedDevicesSchema,
43907
- tokenHash: string(),
43908
- tokenPrefix: string(),
43909
- createdAt: number(),
43910
- lastUsedAt: number().optional()
43911
- });
43912
- object({
43913
- id: string(),
43914
- userId: string(),
43915
- name: string(),
43916
- tokenHash: string(),
43917
- tokenPrefix: string(),
43918
- scopes: array(TokenScopeSchema),
43919
- expiresAt: number().nullish(),
43920
- lastUsedAt: number().nullish(),
43921
- createdAt: number()
43922
- });
43923
- /**
43924
44072
  * `oauth-integration` — a collection cap by which an addon declares
43925
44073
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
43926
44074
  * Each provider returns a static descriptor; the core enumerates them
@@ -61048,26 +61196,6 @@ var ApiKeySummarySchema = object({
61048
61196
  createdAt: number(),
61049
61197
  lastUsedAt: number().optional()
61050
61198
  });
61051
- var ScopedTokenSummarySchema = object({
61052
- id: string(),
61053
- userId: string(),
61054
- name: string(),
61055
- tokenPrefix: string(),
61056
- scopes: array(TokenScopeSchema),
61057
- expiresAt: number().nullish(),
61058
- lastUsedAt: number().nullish(),
61059
- createdAt: number()
61060
- });
61061
- var CreateScopedTokenInputSchema = object({
61062
- userId: string(),
61063
- name: string(),
61064
- scopes: array(TokenScopeSchema),
61065
- expiresAt: number().optional()
61066
- });
61067
- var CreateScopedTokenResultSchema = object({
61068
- token: string(),
61069
- record: ScopedTokenSummarySchema
61070
- });
61071
61199
  var OauthSessionSummarySchema = object({
61072
61200
  id: string(),
61073
61201
  userId: string(),
@@ -61089,11 +61217,11 @@ var TotpStatusSchema = object({
61089
61217
  confirmedAt: number().nullable()
61090
61218
  });
61091
61219
  /**
61092
- * user-management — singleton capability for user accounts, API keys,
61093
- * and scoped tokens.
61220
+ * user-management — singleton capability for user accounts and the
61221
+ * legacy API-key rows.
61094
61222
  *
61095
61223
  * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
61096
- * — the subset check on `setUserScopes` / `createScopedToken` is moot
61224
+ * — the subset check on `setUserScopes` is moot
61097
61225
  * because non-admins never reach these. If/when we open non-admin
61098
61226
  * delegation, structural caller-scope subset check goes inside the
61099
61227
  * provider.
@@ -61150,15 +61278,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
61150
61278
  kind: "mutation",
61151
61279
  auth: "admin",
61152
61280
  access: "delete"
61153
- }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
61154
- kind: "mutation",
61155
- auth: "admin",
61156
- access: "create"
61157
- }), method(object({ id: string() }), object({ success: literal(true) }), {
61158
- kind: "mutation",
61159
- auth: "admin",
61160
- access: "delete"
61161
- }), method(object({ token: string() }), ScopedTokenSummarySchema.nullable(), { access: "view" }), method(object({ userId: string() }), array(ScopedTokenSummarySchema), { auth: "admin" }), method(object({ userId: string() }), TotpSetupResultSchema, {
61281
+ }), method(object({ userId: string() }), TotpSetupResultSchema, {
61162
61282
  kind: "mutation",
61163
61283
  auth: "admin",
61164
61284
  access: "create"
@@ -66139,7 +66259,7 @@ Object.freeze({
66139
66259
  capName: "llm",
66140
66260
  capScope: "system",
66141
66261
  addonId: null,
66142
- access: "view"
66262
+ access: "create"
66143
66263
  },
66144
66264
  "llm.listNodeModels": {
66145
66265
  capName: "llm",
@@ -70803,12 +70923,6 @@ Object.freeze({
70803
70923
  addonId: null,
70804
70924
  access: "create"
70805
70925
  },
70806
- "userManagement.createScopedToken": {
70807
- capName: "user-management",
70808
- capScope: "system",
70809
- addonId: null,
70810
- access: "create"
70811
- },
70812
70926
  "userManagement.createUser": {
70813
70927
  capName: "user-management",
70814
70928
  capScope: "system",
@@ -70857,12 +70971,6 @@ Object.freeze({
70857
70971
  addonId: null,
70858
70972
  access: "view"
70859
70973
  },
70860
- "userManagement.listScopedTokens": {
70861
- capName: "user-management",
70862
- capScope: "system",
70863
- addonId: null,
70864
- access: "view"
70865
- },
70866
70974
  "userManagement.listUsers": {
70867
70975
  capName: "user-management",
70868
70976
  capScope: "system",
@@ -70917,12 +71025,6 @@ Object.freeze({
70917
71025
  addonId: null,
70918
71026
  access: "delete"
70919
71027
  },
70920
- "userManagement.revokeScopedToken": {
70921
- capName: "user-management",
70922
- capScope: "system",
70923
- addonId: null,
70924
- access: "delete"
70925
- },
70926
71028
  "userManagement.setupTotp": {
70927
71029
  capName: "user-management",
70928
71030
  capScope: "system",
@@ -70953,12 +71055,6 @@ Object.freeze({
70953
71055
  addonId: null,
70954
71056
  access: "view"
70955
71057
  },
70956
- "userManagement.validateScopedToken": {
70957
- capName: "user-management",
70958
- capScope: "system",
70959
- addonId: null,
70960
- access: "view"
70961
- },
70962
71058
  "userManagement.verifyTotp": {
70963
71059
  capName: "user-management",
70964
71060
  capScope: "system",