@camstack/addon-decoder-nodeav 1.2.125 → 1.2.127

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/index.js +390 -294
  2. package/dist/index.mjs +390 -294
  3. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -5414,7 +5414,7 @@ var ZodIssueCode = {
5414
5414
  var ZodFirstPartyTypeKind;
5415
5415
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5416
5416
  //#endregion
5417
- //#region ../types/dist/sleep-BxjU_fJM.mjs
5417
+ //#region ../types/dist/sleep-yKL5gfrH.mjs
5418
5418
  /**
5419
5419
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5420
5420
  * window to float samples (D455).
@@ -7796,6 +7796,12 @@ function normalizeAddonInitResult(result) {
7796
7796
  if (Array.isArray(result)) return { providers: result };
7797
7797
  return result;
7798
7798
  }
7799
+ /**
7800
+ * The share-view scope kinds a share-link token can carry. The hub mints
7801
+ * and validates them (`ShareViewGrantSchema` builds its
7802
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
7803
+ */
7804
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7799
7805
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7800
7806
  var PeerBytesTicketSchema = object({
7801
7807
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12390,6 +12396,280 @@ var ConvertResultSchema = object({
12390
12396
  files: array(string()).readonly()
12391
12397
  })).readonly()
12392
12398
  });
12399
+ /**
12400
+ * Zod schemas for persisted record types.
12401
+ *
12402
+ * These schemas serve as the single source of truth for types that are
12403
+ * stored in the settings-store backend and retrieved via tRPC. They
12404
+ * replace the manual TypeScript interfaces with schema-derived types,
12405
+ * enabling runtime validation when reading from the backend.
12406
+ *
12407
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12408
+ * keeps the original name for backward compatibility.
12409
+ */
12410
+ /**
12411
+ * Auth model (v2 — 2026-05-12 caps-only):
12412
+ *
12413
+ * Two principals:
12414
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12415
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12416
+ *
12417
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12418
+ * `super_admin` — collapsed onto the single boolean because every
12419
+ * non-admin caller is governed by the same scope-check rules; the
12420
+ * distinction was only ever used to route role-specific procedures
12421
+ * which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
12422
+ * with `isAdmin: false` + an explicit scope list.
12423
+ */
12424
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12425
+ var MethodAccessSchema = _enum([
12426
+ "view",
12427
+ "create",
12428
+ "delete"
12429
+ ]);
12430
+ /**
12431
+ * A single scope grant. Three forms — checked in matcher with OR
12432
+ * semantics; the first match decides whether the call passes:
12433
+ *
12434
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12435
+ * cap with the matching `scope` declaration. New caps inherit grants
12436
+ * automatically — adding a device cap to the codebase makes it
12437
+ * reachable to every user with `category:device [...]` without a
12438
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12439
+ *
12440
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12441
+ * useful when an integration needs to interact with one specific
12442
+ * addon's surface regardless of how many caps it exports.
12443
+ *
12444
+ * - `capability` — the most precise form. Single cap name. Use for
12445
+ * integration tokens where you want to grant `addons.installPackage`
12446
+ * and nothing else.
12447
+ *
12448
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12449
+ * "give me everything" escape; there is no wildcard scope.
12450
+ */
12451
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12452
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12453
+ var CapScopeSchema = _enum(["device", "system"]);
12454
+ /**
12455
+ * DeviceSelector (scope model v3 — 2026-08-12).
12456
+ *
12457
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12458
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12459
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12460
+ * AFTER the grant was minted — no re-grant, no re-login.
12461
+ *
12462
+ * - `all` — every device in the deployment. The broad viewer/operator
12463
+ * lever without a `category` grant (a `category` grant also covers device
12464
+ * caps that carry no deviceId; `all` is specifically the device set).
12465
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
12466
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
12467
+ * is NOT covered until the grant is edited.
12468
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
12469
+ * DYNAMIC. A device that changes type, or a new device of the type,
12470
+ * re-resolves on the next request.
12471
+ * - `locations` — every device whose operator-assigned `location` label is
12472
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
12473
+ * null/unset location matches NO `locations` selector.
12474
+ */
12475
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
12476
+ object({ kind: literal("all") }),
12477
+ object({
12478
+ kind: literal("ids"),
12479
+ ids: array(number().int()).min(1)
12480
+ }),
12481
+ object({
12482
+ kind: literal("types"),
12483
+ types: array(_enum(DeviceType)).min(1)
12484
+ }),
12485
+ object({
12486
+ kind: literal("locations"),
12487
+ locations: array(string().min(1)).min(1)
12488
+ })
12489
+ ]);
12490
+ var DeviceTokenScopeSchema = object({
12491
+ type: literal("device"),
12492
+ /** The device SET this grant covers — resolved against the live fleet. */
12493
+ selector: DeviceSelectorSchema,
12494
+ access: array(MethodAccessSchema).min(1),
12495
+ /**
12496
+ * Whether a grant on a PARENT device transparently covers its accessory
12497
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
12498
+ * Direction is parent → children ONLY.
12499
+ *
12500
+ * Absent → the matcher DERIVES it from the access flavour: `view`
12501
+ * inherits (a camera viewer sees the camera's accessories), `create` /
12502
+ * `delete` do NOT (actuating/removing a child is an explicit act the
12503
+ * operator must grant on the child, not inherit from the parent). Set it
12504
+ * explicitly to override that default per grant.
12505
+ */
12506
+ includeLinked: boolean().optional()
12507
+ });
12508
+ /**
12509
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
12510
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
12511
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
12512
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
12513
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
12514
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
12515
+ * migration cannot reach a JWT already in a client's hands; parse-time
12516
+ * migration covers both without a flag day. No cast — the raw object is read
12517
+ * through `Reflect.get` (its static type is `unknown`).
12518
+ */
12519
+ function migrateLegacyTokenScope(raw) {
12520
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
12521
+ if (Reflect.get(raw, "type") !== "device") return raw;
12522
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
12523
+ const targets = Reflect.get(raw, "targets");
12524
+ if (!Array.isArray(targets)) return raw;
12525
+ return {
12526
+ type: "device",
12527
+ selector: {
12528
+ kind: "ids",
12529
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
12530
+ },
12531
+ access: Reflect.get(raw, "access")
12532
+ };
12533
+ }
12534
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
12535
+ object({
12536
+ type: literal("category"),
12537
+ target: CapScopeSchema,
12538
+ access: array(MethodAccessSchema).min(1)
12539
+ }),
12540
+ object({
12541
+ type: literal("capability"),
12542
+ target: string(),
12543
+ access: array(MethodAccessSchema).min(1)
12544
+ }),
12545
+ object({
12546
+ type: literal("addon"),
12547
+ target: string(),
12548
+ access: array(MethodAccessSchema).min(1)
12549
+ }),
12550
+ DeviceTokenScopeSchema
12551
+ ]));
12552
+ object({
12553
+ id: string(),
12554
+ username: string(),
12555
+ passwordHash: string(),
12556
+ /**
12557
+ * Admin bypass. When true, the middleware skips the scope-access
12558
+ * check entirely. There is no other axis of privilege; the legacy
12559
+ * role enum collapsed onto this boolean in v2.
12560
+ */
12561
+ isAdmin: boolean().default(false),
12562
+ allowedProviders: AllowedProviderSchema,
12563
+ allowedDevices: AllowedDevicesSchema,
12564
+ /**
12565
+ * Scopes granted to this user. Admins bypass; their `scopes` is
12566
+ * ignored. Non-admins without scopes are locked out of every
12567
+ * protected call.
12568
+ */
12569
+ scopes: array(TokenScopeSchema).default([]),
12570
+ createdAt: number(),
12571
+ updatedAt: number()
12572
+ });
12573
+ object({
12574
+ id: string(),
12575
+ label: string(),
12576
+ isAdmin: boolean().default(false),
12577
+ allowedProviders: AllowedProviderSchema,
12578
+ allowedDevices: AllowedDevicesSchema,
12579
+ tokenHash: string(),
12580
+ tokenPrefix: string(),
12581
+ createdAt: number(),
12582
+ lastUsedAt: number().optional()
12583
+ });
12584
+ object({
12585
+ id: string(),
12586
+ userId: string(),
12587
+ name: string(),
12588
+ tokenHash: string(),
12589
+ tokenPrefix: string(),
12590
+ scopes: array(TokenScopeSchema),
12591
+ expiresAt: number().nullish(),
12592
+ lastUsedAt: number().nullish(),
12593
+ createdAt: number()
12594
+ });
12595
+ /** What a share-view grant lets its holder see. */
12596
+ var ShareViewGrantSchema = object({
12597
+ kind: _enum(SHARE_VIEW_KINDS),
12598
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
12599
+ /** Talk-back, opt-in at mint time; absent means off. */
12600
+ talk: boolean().optional()
12601
+ });
12602
+ var ShareViewScopeSchema = object({
12603
+ type: literal("share-view"),
12604
+ grant: ShareViewGrantSchema
12605
+ });
12606
+ var AddonRoutesScopeSchema = object({
12607
+ type: literal("addon-routes"),
12608
+ access: array(MethodAccessSchema).min(1)
12609
+ });
12610
+ var PreferencesSelfScopeSchema = object({ type: literal("preferences-self") });
12611
+ var CredentialScopeSchema = union([
12612
+ literal("*"),
12613
+ ShareViewScopeSchema,
12614
+ AddonRoutesScopeSchema,
12615
+ PreferencesSelfScopeSchema,
12616
+ TokenScopeSchema
12617
+ ]);
12618
+ object({
12619
+ kind: literal("credential"),
12620
+ sub: string().min(1),
12621
+ jti: string().min(16),
12622
+ scopes: array(CredentialScopeSchema).min(1)
12623
+ });
12624
+ var PreferenceNamespaceSchema = string().regex(/^[a-z][a-z0-9.-]{0,63}$/);
12625
+ /** A namespace's value: a JSON object, opaque to the hub. */
12626
+ var PreferenceValueSchema = record(string(), unknown());
12627
+ var PreferenceDeviceIdSchema = string().min(1).max(64);
12628
+ /** A stored row, as the owner reads it. */
12629
+ var PreferenceRowSchema = object({
12630
+ namespace: PreferenceNamespaceSchema,
12631
+ value: PreferenceValueSchema,
12632
+ /** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
12633
+ revision: number().int().positive(),
12634
+ updatedAt: number().int(),
12635
+ /** The client id the last writer sent; `null` when it sent none. */
12636
+ updatedByDevice: PreferenceDeviceIdSchema.nullable()
12637
+ });
12638
+ object({
12639
+ /** Absent: every namespace the caller holds. */
12640
+ namespaces: array(PreferenceNamespaceSchema).max(32).optional() });
12641
+ object({ rows: array(PreferenceRowSchema) });
12642
+ object({
12643
+ namespace: PreferenceNamespaceSchema,
12644
+ value: PreferenceValueSchema,
12645
+ /**
12646
+ * The revision the edit was based on. Absent: last write wins. `0`: the
12647
+ * namespace must not exist yet. Any other value that is not the current
12648
+ * revision answers `conflict` and writes nothing.
12649
+ */
12650
+ baseRevision: number().int().nonnegative().optional(),
12651
+ deviceId: PreferenceDeviceIdSchema.optional()
12652
+ });
12653
+ discriminatedUnion("status", [object({
12654
+ status: literal("saved"),
12655
+ row: PreferenceRowSchema
12656
+ }), object({
12657
+ status: literal("conflict"),
12658
+ current: PreferenceRowSchema.nullable()
12659
+ })]);
12660
+ object({ namespace: PreferenceNamespaceSchema });
12661
+ object({
12662
+ /** `false` when the namespace did not exist. */
12663
+ deleted: boolean() });
12664
+ object({
12665
+ /** The revision the client holds per namespace; a namespace it does not list is new to it. */
12666
+ revisionByNamespace: record(PreferenceNamespaceSchema, number().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
12667
+ object({
12668
+ /** Every row whose revision differs from the client's, and every row it did not list. */
12669
+ rows: array(PreferenceRowSchema),
12670
+ /** Namespaces the client listed that no longer exist. */
12671
+ deleted: array(PreferenceNamespaceSchema)
12672
+ });
12393
12673
  _enum(["new-session", "step-up"]);
12394
12674
  /** The languages the hub's app landing pages are written in (D858). */
12395
12675
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -39386,38 +39666,37 @@ method(LlmRuntimeCompleteInputSchema, LlmGenerateResultSchema, {
39386
39666
  auth: "admin",
39387
39667
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39388
39668
  });
39669
+ var LlmProfileKindSchema = string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "a kind id is lower-case letters, digits and dashes");
39670
+ /** What a model (or, by default, every model of a kind) can do. */
39671
+ var LlmModelFeaturesSchema = object({
39672
+ vision: boolean(),
39673
+ tools: boolean(),
39674
+ streaming: boolean()
39675
+ });
39676
+ /** One model a provider offers. `features` overrides the kind's defaults, per field. */
39677
+ var LlmModelInfoSchema = object({
39678
+ id: string(),
39679
+ label: string().optional(),
39680
+ contextLength: number().int().positive().optional(),
39681
+ features: LlmModelFeaturesSchema.partial().optional()
39682
+ });
39389
39683
  /**
39390
- * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
39391
- * methods concat-fan across providers; single-row methods route to ONE
39392
- * provider by the `addonId` in the call input (the notification-output
39393
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
39394
- * (hub-placed); the cap stays open for future providers.
39395
- *
39396
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
39397
- * `apiKey` is a password field — providers REDACT it on read and merge on
39398
- * write; a stored key NEVER round-trips to a client.
39684
+ * The provider-specific part of a profile, validated by the provider that owns
39685
+ * the kind (`upsertProfile` refuses what it does not accept). A field its
39686
+ * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
39687
+ * keychain, never in the row, and reads back as the redaction marker.
39399
39688
  */
39400
- var LlmProfileKindSchema = _enum([
39401
- "openai-compatible",
39402
- "openai",
39403
- "anthropic",
39404
- "google",
39405
- "managed-local",
39406
- "apple-foundation"
39407
- ]);
39689
+ var LlmProviderConfigSchema = record(string(), unknown());
39408
39690
  var LlmProfileSchema = object({
39409
39691
  id: string(),
39410
39692
  name: string(),
39693
+ /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
39411
39694
  kind: LlmProfileKindSchema,
39412
39695
  /** Stamped by the provider — keeps the fanned catalog routable. */
39413
39696
  addonId: string(),
39414
39697
  enabled: boolean(),
39415
39698
  /** Vendor model id, or the managed runtime's loaded model. */
39416
39699
  model: string(),
39417
- /** Required for openai-compatible; override for cloud kinds. */
39418
- baseUrl: string().optional(),
39419
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
39420
- apiKey: string().optional(),
39421
39700
  /** Vision on/off. A vision call against a `false` profile is REFUSED, never
39422
39701
  * degraded to text — that shipped once and produced a confident answer to a
39423
39702
  * question about a picture nobody sent. */
@@ -39425,15 +39704,11 @@ var LlmProfileSchema = object({
39425
39704
  temperature: number().min(0).max(2).optional(),
39426
39705
  /** Nucleus sampling. Every wire we speak has it. */
39427
39706
  topP: number().min(0).max(1).optional(),
39428
- /** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
39429
- * wire does, and the client drops it there (measured: the request body gets
39430
- * `top_p` and no `top_k`). The profile editor hides the field wherever it
39431
- * would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
39707
+ /** Top-k sampling. Carried only by the wires that have it — a kind offers the
39708
+ * field in its editor only when its descriptor lists it in `profileFields`. */
39432
39709
  topK: number().int().positive().optional(),
39433
39710
  maxTokens: number().int().positive().optional(),
39434
- /** Prompt context window. Advisory for cloud kinds (they enforce their own);
39435
- * for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
39436
- * the model with, so it is the one field that changes a PROCESS. */
39711
+ /** Prompt context window. Advisory for cloud kinds (they enforce their own). */
39437
39712
  contextLength: number().int().positive().optional(),
39438
39713
  /** Default system prompt. A caller's `system` REPLACES it (never appends —
39439
39714
  * two system prompts fighting is worse than either alone). */
@@ -39459,16 +39734,37 @@ var LlmProfileSchema = object({
39459
39734
  * library; the REGISTRY of callable tools is ours and is empty in v1, so a
39460
39735
  * `true` here buys the wiring, not behaviour, until tools are registered. */
39461
39736
  toolsEnabled: boolean().default(false),
39462
- extraHeaders: record(string(), string()).optional(),
39463
- /** kind === 'managed-local' only (spec §4). */
39464
- runtime: ManagedRuntimeConfigSchema.optional(),
39465
- /**
39466
- * kind === 'apple-foundation' only: WHERE it runs — the only thing there is
39467
- * to configure (no key, no URL, no download; `model` is `apple-system`).
39468
- * `supportsVision` on such a row is stamped by the provider from the node's
39469
- * reported `imageInput`, never taken from the operator (D62).
39470
- */
39471
- appleFoundation: object({ nodeId: string() }).optional()
39737
+ /** Everything the kind's provider owns (endpoint, key, node, runtime…). */
39738
+ providerConfig: LlmProviderConfigSchema.default({})
39739
+ });
39740
+ /**
39741
+ * The common profile fields a kind's editor offers. The editor owns how each
39742
+ * one is drawn; the provider says which of them mean something on its wire.
39743
+ */
39744
+ var LlmProfileFieldSchema = _enum([
39745
+ "temperature",
39746
+ "topP",
39747
+ "topK",
39748
+ "maxTokens",
39749
+ "contextLength",
39750
+ "systemPrompt",
39751
+ "timeoutMs",
39752
+ "connectTimeoutMs",
39753
+ "firstTokenTimeoutMs",
39754
+ "idleTimeoutMs",
39755
+ "retry",
39756
+ "toolsEnabled"
39757
+ ]);
39758
+ /**
39759
+ * A provider-drawn part of the editor, by a generic widget id the admin UI
39760
+ * registers (`ai/apple-node`). `placement: 'model'` replaces the generic model
39761
+ * picker: that widget owns the model choice.
39762
+ */
39763
+ var LlmProviderWidgetSchema = object({
39764
+ id: string(),
39765
+ placement: _enum(["connection", "model"]),
39766
+ /** `providerConfig` keys this widget must fill before the profile can be saved. */
39767
+ requires: array(string()).optional()
39472
39768
  });
39473
39769
  /** ConfigUISchema tree passed through untyped on the wire (the
39474
39770
  * notification-output `ConfigSchemaPassthrough` precedent at
@@ -39477,11 +39773,56 @@ var ConfigSchemaPassthrough$3 = unknown();
39477
39773
  var LlmProfileKindDescriptorSchema = object({
39478
39774
  kind: LlmProfileKindSchema,
39479
39775
  label: string(),
39776
+ /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
39480
39777
  icon: string(),
39481
39778
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
39482
39779
  addonId: string(),
39483
- configSchema: ConfigSchemaPassthrough$3
39780
+ /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
39781
+ connectionSchema: ConfigSchemaPassthrough$3,
39782
+ /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
39783
+ advancedSchema: ConfigSchemaPassthrough$3.optional(),
39784
+ /** The kind's defaults; a model from `listModels` may override any of them. */
39785
+ features: LlmModelFeaturesSchema,
39786
+ /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
39787
+ visionEditable: boolean(),
39788
+ /** Where the model list comes from: `listModels`, `staticModels`, or nowhere. */
39789
+ modelCatalog: _enum([
39790
+ "fetch",
39791
+ "static",
39792
+ "none"
39793
+ ]),
39794
+ staticModels: array(LlmModelInfoSchema).optional(),
39795
+ /** The common fields that mean something on this kind's wire. */
39796
+ profileFields: array(LlmProfileFieldSchema),
39797
+ providerWidgets: array(LlmProviderWidgetSchema).optional()
39798
+ });
39799
+ /**
39800
+ * `listModels` input. `connection` is an UNSAVED draft of `providerConfig`
39801
+ * (the editor's form); with `profileId` too, a secret the draft leaves
39802
+ * untouched (absent or the redaction marker) is resolved server-side from the
39803
+ * stored profile — the browser never receives it.
39804
+ */
39805
+ var LlmListModelsInputSchema = object({
39806
+ addonId: string(),
39807
+ kind: LlmProfileKindSchema,
39808
+ profileId: string().optional(),
39809
+ connection: LlmProviderConfigSchema.optional()
39484
39810
  });
39811
+ var LlmListModelsErrorCodeSchema = _enum([
39812
+ "auth",
39813
+ "network",
39814
+ "unsupported",
39815
+ "invalid"
39816
+ ]);
39817
+ /** A RESULT, never a throw: "wrong key" is an answer the editor renders inline. */
39818
+ var LlmListModelsResultSchema = discriminatedUnion("ok", [object({
39819
+ ok: literal(true),
39820
+ models: array(LlmModelInfoSchema)
39821
+ }), object({
39822
+ ok: literal(false),
39823
+ code: LlmListModelsErrorCodeSchema,
39824
+ message: string()
39825
+ })]);
39485
39826
  var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
39486
39827
  var LlmDefaultSchema = object({
39487
39828
  selector: LlmDefaultSelectorSchema,
@@ -39581,7 +39922,10 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
39581
39922
  kind: "mutation",
39582
39923
  auth: "admin",
39583
39924
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39584
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
39925
+ }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
39926
+ kind: "mutation",
39927
+ auth: "admin"
39928
+ }), method(object({}), array(LlmDefaultSchema)), method(object({
39585
39929
  selector: LlmDefaultSelectorSchema,
39586
39930
  profileId: string().nullable()
39587
39931
  }), _void(), {
@@ -43645,202 +43989,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
43645
43989
  auth: "admin"
43646
43990
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
43647
43991
  /**
43648
- * Zod schemas for persisted record types.
43649
- *
43650
- * These schemas serve as the single source of truth for types that are
43651
- * stored in the settings-store backend and retrieved via tRPC. They
43652
- * replace the manual TypeScript interfaces with schema-derived types,
43653
- * enabling runtime validation when reading from the backend.
43654
- *
43655
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
43656
- * keeps the original name for backward compatibility.
43657
- */
43658
- /**
43659
- * Auth model (v2 — 2026-05-12 caps-only):
43660
- *
43661
- * Two principals:
43662
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
43663
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
43664
- *
43665
- * No role enum. There used to be `viewer / agent / scoped` and earlier
43666
- * `super_admin` — collapsed onto the single boolean because every
43667
- * non-admin caller is governed by the same scope-check rules; the
43668
- * distinction was only ever used to route role-specific procedures
43669
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
43670
- * with `isAdmin: false` + an explicit scope list.
43671
- */
43672
- /** Per-method access flavour. Materialised on every cap method via codegen. */
43673
- var MethodAccessSchema = _enum([
43674
- "view",
43675
- "create",
43676
- "delete"
43677
- ]);
43678
- /**
43679
- * A single scope grant. Three forms — checked in matcher with OR
43680
- * semantics; the first match decides whether the call passes:
43681
- *
43682
- * - `category` — broadest. `target: 'device' | 'system'` selects every
43683
- * cap with the matching `scope` declaration. New caps inherit grants
43684
- * automatically — adding a device cap to the codebase makes it
43685
- * reachable to every user with `category:device [...]` without a
43686
- * re-grant. Use this for "family viewer" / "operator" tiers.
43687
- *
43688
- * - `addon` — every cap that ships inside a given addon id. Niche;
43689
- * useful when an integration needs to interact with one specific
43690
- * addon's surface regardless of how many caps it exports.
43691
- *
43692
- * - `capability` — the most precise form. Single cap name. Use for
43693
- * integration tokens where you want to grant `addons.installPackage`
43694
- * and nothing else.
43695
- *
43696
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
43697
- * "give me everything" escape; there is no wildcard scope.
43698
- */
43699
- var AllowedProviderSchema = union([literal("*"), array(string())]);
43700
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
43701
- var CapScopeSchema = _enum(["device", "system"]);
43702
- /**
43703
- * DeviceSelector (scope model v3 — 2026-08-12).
43704
- *
43705
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
43706
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
43707
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
43708
- * AFTER the grant was minted — no re-grant, no re-login.
43709
- *
43710
- * - `all` — every device in the deployment. The broad viewer/operator
43711
- * lever without a `category` grant (a `category` grant also covers device
43712
- * caps that carry no deviceId; `all` is specifically the device set).
43713
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
43714
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
43715
- * is NOT covered until the grant is edited.
43716
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
43717
- * DYNAMIC. A device that changes type, or a new device of the type,
43718
- * re-resolves on the next request.
43719
- * - `locations` — every device whose operator-assigned `location` label is
43720
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
43721
- * null/unset location matches NO `locations` selector.
43722
- */
43723
- var DeviceSelectorSchema = discriminatedUnion("kind", [
43724
- object({ kind: literal("all") }),
43725
- object({
43726
- kind: literal("ids"),
43727
- ids: array(number().int()).min(1)
43728
- }),
43729
- object({
43730
- kind: literal("types"),
43731
- types: array(_enum(DeviceType)).min(1)
43732
- }),
43733
- object({
43734
- kind: literal("locations"),
43735
- locations: array(string().min(1)).min(1)
43736
- })
43737
- ]);
43738
- var DeviceTokenScopeSchema = object({
43739
- type: literal("device"),
43740
- /** The device SET this grant covers — resolved against the live fleet. */
43741
- selector: DeviceSelectorSchema,
43742
- access: array(MethodAccessSchema).min(1),
43743
- /**
43744
- * Whether a grant on a PARENT device transparently covers its accessory
43745
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
43746
- * Direction is parent → children ONLY.
43747
- *
43748
- * Absent → the matcher DERIVES it from the access flavour: `view`
43749
- * inherits (a camera viewer sees the camera's accessories), `create` /
43750
- * `delete` do NOT (actuating/removing a child is an explicit act the
43751
- * operator must grant on the child, not inherit from the parent). Set it
43752
- * explicitly to override that default per grant.
43753
- */
43754
- includeLinked: boolean().optional()
43755
- });
43756
- /**
43757
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
43758
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
43759
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
43760
- * EVERY parse path — stored records AND the JWT-carried scope arrays
43761
- * normalised at the request boundary ({@link normalizeTokenScopes} in
43762
- * `device-selector.ts`). Chosen over a one-time DB migration because a
43763
- * migration cannot reach a JWT already in a client's hands; parse-time
43764
- * migration covers both without a flag day. No cast — the raw object is read
43765
- * through `Reflect.get` (its static type is `unknown`).
43766
- */
43767
- function migrateLegacyTokenScope(raw) {
43768
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
43769
- if (Reflect.get(raw, "type") !== "device") return raw;
43770
- if (Reflect.get(raw, "selector") !== void 0) return raw;
43771
- const targets = Reflect.get(raw, "targets");
43772
- if (!Array.isArray(targets)) return raw;
43773
- return {
43774
- type: "device",
43775
- selector: {
43776
- kind: "ids",
43777
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
43778
- },
43779
- access: Reflect.get(raw, "access")
43780
- };
43781
- }
43782
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
43783
- object({
43784
- type: literal("category"),
43785
- target: CapScopeSchema,
43786
- access: array(MethodAccessSchema).min(1)
43787
- }),
43788
- object({
43789
- type: literal("capability"),
43790
- target: string(),
43791
- access: array(MethodAccessSchema).min(1)
43792
- }),
43793
- object({
43794
- type: literal("addon"),
43795
- target: string(),
43796
- access: array(MethodAccessSchema).min(1)
43797
- }),
43798
- DeviceTokenScopeSchema
43799
- ]));
43800
- object({
43801
- id: string(),
43802
- username: string(),
43803
- passwordHash: string(),
43804
- /**
43805
- * Admin bypass. When true, the middleware skips the scope-access
43806
- * check entirely. There is no other axis of privilege; the legacy
43807
- * role enum collapsed onto this boolean in v2.
43808
- */
43809
- isAdmin: boolean().default(false),
43810
- allowedProviders: AllowedProviderSchema,
43811
- allowedDevices: AllowedDevicesSchema,
43812
- /**
43813
- * Scopes granted to this user. Admins bypass; their `scopes` is
43814
- * ignored. Non-admins without scopes are locked out of every
43815
- * protected call.
43816
- */
43817
- scopes: array(TokenScopeSchema).default([]),
43818
- createdAt: number(),
43819
- updatedAt: number()
43820
- });
43821
- object({
43822
- id: string(),
43823
- label: string(),
43824
- isAdmin: boolean().default(false),
43825
- allowedProviders: AllowedProviderSchema,
43826
- allowedDevices: AllowedDevicesSchema,
43827
- tokenHash: string(),
43828
- tokenPrefix: string(),
43829
- createdAt: number(),
43830
- lastUsedAt: number().optional()
43831
- });
43832
- object({
43833
- id: string(),
43834
- userId: string(),
43835
- name: string(),
43836
- tokenHash: string(),
43837
- tokenPrefix: string(),
43838
- scopes: array(TokenScopeSchema),
43839
- expiresAt: number().nullish(),
43840
- lastUsedAt: number().nullish(),
43841
- createdAt: number()
43842
- });
43843
- /**
43844
43992
  * `oauth-integration` — a collection cap by which an addon declares
43845
43993
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
43846
43994
  * Each provider returns a static descriptor; the core enumerates them
@@ -60772,26 +60920,6 @@ var ApiKeySummarySchema = object({
60772
60920
  createdAt: number(),
60773
60921
  lastUsedAt: number().optional()
60774
60922
  });
60775
- var ScopedTokenSummarySchema = object({
60776
- id: string(),
60777
- userId: string(),
60778
- name: string(),
60779
- tokenPrefix: string(),
60780
- scopes: array(TokenScopeSchema),
60781
- expiresAt: number().nullish(),
60782
- lastUsedAt: number().nullish(),
60783
- createdAt: number()
60784
- });
60785
- var CreateScopedTokenInputSchema = object({
60786
- userId: string(),
60787
- name: string(),
60788
- scopes: array(TokenScopeSchema),
60789
- expiresAt: number().optional()
60790
- });
60791
- var CreateScopedTokenResultSchema = object({
60792
- token: string(),
60793
- record: ScopedTokenSummarySchema
60794
- });
60795
60923
  var OauthSessionSummarySchema = object({
60796
60924
  id: string(),
60797
60925
  userId: string(),
@@ -60813,11 +60941,11 @@ var TotpStatusSchema = object({
60813
60941
  confirmedAt: number().nullable()
60814
60942
  });
60815
60943
  /**
60816
- * user-management — singleton capability for user accounts, API keys,
60817
- * and scoped tokens.
60944
+ * user-management — singleton capability for user accounts and the
60945
+ * legacy API-key rows.
60818
60946
  *
60819
60947
  * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
60820
- * — the subset check on `setUserScopes` / `createScopedToken` is moot
60948
+ * — the subset check on `setUserScopes` is moot
60821
60949
  * because non-admins never reach these. If/when we open non-admin
60822
60950
  * delegation, structural caller-scope subset check goes inside the
60823
60951
  * provider.
@@ -60874,15 +61002,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
60874
61002
  kind: "mutation",
60875
61003
  auth: "admin",
60876
61004
  access: "delete"
60877
- }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
60878
- kind: "mutation",
60879
- auth: "admin",
60880
- access: "create"
60881
- }), method(object({ id: string() }), object({ success: literal(true) }), {
60882
- kind: "mutation",
60883
- auth: "admin",
60884
- access: "delete"
60885
- }), method(object({ token: string() }), ScopedTokenSummarySchema.nullable(), { access: "view" }), method(object({ userId: string() }), array(ScopedTokenSummarySchema), { auth: "admin" }), method(object({ userId: string() }), TotpSetupResultSchema, {
61005
+ }), method(object({ userId: string() }), TotpSetupResultSchema, {
60886
61006
  kind: "mutation",
60887
61007
  auth: "admin",
60888
61008
  access: "create"
@@ -65038,7 +65158,7 @@ Object.freeze({
65038
65158
  capName: "llm",
65039
65159
  capScope: "system",
65040
65160
  addonId: null,
65041
- access: "view"
65161
+ access: "create"
65042
65162
  },
65043
65163
  "llm.listNodeModels": {
65044
65164
  capName: "llm",
@@ -69702,12 +69822,6 @@ Object.freeze({
69702
69822
  addonId: null,
69703
69823
  access: "create"
69704
69824
  },
69705
- "userManagement.createScopedToken": {
69706
- capName: "user-management",
69707
- capScope: "system",
69708
- addonId: null,
69709
- access: "create"
69710
- },
69711
69825
  "userManagement.createUser": {
69712
69826
  capName: "user-management",
69713
69827
  capScope: "system",
@@ -69756,12 +69870,6 @@ Object.freeze({
69756
69870
  addonId: null,
69757
69871
  access: "view"
69758
69872
  },
69759
- "userManagement.listScopedTokens": {
69760
- capName: "user-management",
69761
- capScope: "system",
69762
- addonId: null,
69763
- access: "view"
69764
- },
69765
69873
  "userManagement.listUsers": {
69766
69874
  capName: "user-management",
69767
69875
  capScope: "system",
@@ -69816,12 +69924,6 @@ Object.freeze({
69816
69924
  addonId: null,
69817
69925
  access: "delete"
69818
69926
  },
69819
- "userManagement.revokeScopedToken": {
69820
- capName: "user-management",
69821
- capScope: "system",
69822
- addonId: null,
69823
- access: "delete"
69824
- },
69825
69927
  "userManagement.setupTotp": {
69826
69928
  capName: "user-management",
69827
69929
  capScope: "system",
@@ -69852,12 +69954,6 @@ Object.freeze({
69852
69954
  addonId: null,
69853
69955
  access: "view"
69854
69956
  },
69855
- "userManagement.validateScopedToken": {
69856
- capName: "user-management",
69857
- capScope: "system",
69858
- addonId: null,
69859
- access: "view"
69860
- },
69861
69957
  "userManagement.verifyTotp": {
69862
69958
  capName: "user-management",
69863
69959
  capScope: "system",