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