@camstack/addon-provider-unraid 0.2.129 → 0.2.131

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
@@ -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. */
@@ -12475,6 +12481,280 @@ var ConvertResultSchema = object({
12475
12481
  files: array(string()).readonly()
12476
12482
  })).readonly()
12477
12483
  });
12484
+ /**
12485
+ * Zod schemas for persisted record types.
12486
+ *
12487
+ * These schemas serve as the single source of truth for types that are
12488
+ * stored in the settings-store backend and retrieved via tRPC. They
12489
+ * replace the manual TypeScript interfaces with schema-derived types,
12490
+ * enabling runtime validation when reading from the backend.
12491
+ *
12492
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12493
+ * keeps the original name for backward compatibility.
12494
+ */
12495
+ /**
12496
+ * Auth model (v2 — 2026-05-12 caps-only):
12497
+ *
12498
+ * Two principals:
12499
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12500
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12501
+ *
12502
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12503
+ * `super_admin` — collapsed onto the single boolean because every
12504
+ * non-admin caller is governed by the same scope-check rules; the
12505
+ * distinction was only ever used to route role-specific procedures
12506
+ * which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
12507
+ * with `isAdmin: false` + an explicit scope list.
12508
+ */
12509
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12510
+ var MethodAccessSchema = _enum([
12511
+ "view",
12512
+ "create",
12513
+ "delete"
12514
+ ]);
12515
+ /**
12516
+ * A single scope grant. Three forms — checked in matcher with OR
12517
+ * semantics; the first match decides whether the call passes:
12518
+ *
12519
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12520
+ * cap with the matching `scope` declaration. New caps inherit grants
12521
+ * automatically — adding a device cap to the codebase makes it
12522
+ * reachable to every user with `category:device [...]` without a
12523
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12524
+ *
12525
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12526
+ * useful when an integration needs to interact with one specific
12527
+ * addon's surface regardless of how many caps it exports.
12528
+ *
12529
+ * - `capability` — the most precise form. Single cap name. Use for
12530
+ * integration tokens where you want to grant `addons.installPackage`
12531
+ * and nothing else.
12532
+ *
12533
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12534
+ * "give me everything" escape; there is no wildcard scope.
12535
+ */
12536
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12537
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12538
+ var CapScopeSchema = _enum(["device", "system"]);
12539
+ /**
12540
+ * DeviceSelector (scope model v3 — 2026-08-12).
12541
+ *
12542
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12543
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12544
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12545
+ * AFTER the grant was minted — no re-grant, no re-login.
12546
+ *
12547
+ * - `all` — every device in the deployment. The broad viewer/operator
12548
+ * lever without a `category` grant (a `category` grant also covers device
12549
+ * caps that carry no deviceId; `all` is specifically the device set).
12550
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
12551
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
12552
+ * is NOT covered until the grant is edited.
12553
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
12554
+ * DYNAMIC. A device that changes type, or a new device of the type,
12555
+ * re-resolves on the next request.
12556
+ * - `locations` — every device whose operator-assigned `location` label is
12557
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
12558
+ * null/unset location matches NO `locations` selector.
12559
+ */
12560
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
12561
+ object({ kind: literal("all") }),
12562
+ object({
12563
+ kind: literal("ids"),
12564
+ ids: array(number().int()).min(1)
12565
+ }),
12566
+ object({
12567
+ kind: literal("types"),
12568
+ types: array(_enum(DeviceType)).min(1)
12569
+ }),
12570
+ object({
12571
+ kind: literal("locations"),
12572
+ locations: array(string().min(1)).min(1)
12573
+ })
12574
+ ]);
12575
+ var DeviceTokenScopeSchema = object({
12576
+ type: literal("device"),
12577
+ /** The device SET this grant covers — resolved against the live fleet. */
12578
+ selector: DeviceSelectorSchema,
12579
+ access: array(MethodAccessSchema).min(1),
12580
+ /**
12581
+ * Whether a grant on a PARENT device transparently covers its accessory
12582
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
12583
+ * Direction is parent → children ONLY.
12584
+ *
12585
+ * Absent → the matcher DERIVES it from the access flavour: `view`
12586
+ * inherits (a camera viewer sees the camera's accessories), `create` /
12587
+ * `delete` do NOT (actuating/removing a child is an explicit act the
12588
+ * operator must grant on the child, not inherit from the parent). Set it
12589
+ * explicitly to override that default per grant.
12590
+ */
12591
+ includeLinked: boolean().optional()
12592
+ });
12593
+ /**
12594
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
12595
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
12596
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
12597
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
12598
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
12599
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
12600
+ * migration cannot reach a JWT already in a client's hands; parse-time
12601
+ * migration covers both without a flag day. No cast — the raw object is read
12602
+ * through `Reflect.get` (its static type is `unknown`).
12603
+ */
12604
+ function migrateLegacyTokenScope(raw) {
12605
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
12606
+ if (Reflect.get(raw, "type") !== "device") return raw;
12607
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
12608
+ const targets = Reflect.get(raw, "targets");
12609
+ if (!Array.isArray(targets)) return raw;
12610
+ return {
12611
+ type: "device",
12612
+ selector: {
12613
+ kind: "ids",
12614
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
12615
+ },
12616
+ access: Reflect.get(raw, "access")
12617
+ };
12618
+ }
12619
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
12620
+ object({
12621
+ type: literal("category"),
12622
+ target: CapScopeSchema,
12623
+ access: array(MethodAccessSchema).min(1)
12624
+ }),
12625
+ object({
12626
+ type: literal("capability"),
12627
+ target: string(),
12628
+ access: array(MethodAccessSchema).min(1)
12629
+ }),
12630
+ object({
12631
+ type: literal("addon"),
12632
+ target: string(),
12633
+ access: array(MethodAccessSchema).min(1)
12634
+ }),
12635
+ DeviceTokenScopeSchema
12636
+ ]));
12637
+ object({
12638
+ id: string(),
12639
+ username: string(),
12640
+ passwordHash: string(),
12641
+ /**
12642
+ * Admin bypass. When true, the middleware skips the scope-access
12643
+ * check entirely. There is no other axis of privilege; the legacy
12644
+ * role enum collapsed onto this boolean in v2.
12645
+ */
12646
+ isAdmin: boolean().default(false),
12647
+ allowedProviders: AllowedProviderSchema,
12648
+ allowedDevices: AllowedDevicesSchema,
12649
+ /**
12650
+ * Scopes granted to this user. Admins bypass; their `scopes` is
12651
+ * ignored. Non-admins without scopes are locked out of every
12652
+ * protected call.
12653
+ */
12654
+ scopes: array(TokenScopeSchema).default([]),
12655
+ createdAt: number(),
12656
+ updatedAt: number()
12657
+ });
12658
+ object({
12659
+ id: string(),
12660
+ label: string(),
12661
+ isAdmin: boolean().default(false),
12662
+ allowedProviders: AllowedProviderSchema,
12663
+ allowedDevices: AllowedDevicesSchema,
12664
+ tokenHash: string(),
12665
+ tokenPrefix: string(),
12666
+ createdAt: number(),
12667
+ lastUsedAt: number().optional()
12668
+ });
12669
+ object({
12670
+ id: string(),
12671
+ userId: string(),
12672
+ name: string(),
12673
+ tokenHash: string(),
12674
+ tokenPrefix: string(),
12675
+ scopes: array(TokenScopeSchema),
12676
+ expiresAt: number().nullish(),
12677
+ lastUsedAt: number().nullish(),
12678
+ createdAt: number()
12679
+ });
12680
+ /** What a share-view grant lets its holder see. */
12681
+ var ShareViewGrantSchema = object({
12682
+ kind: _enum(SHARE_VIEW_KINDS),
12683
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
12684
+ /** Talk-back, opt-in at mint time; absent means off. */
12685
+ talk: boolean().optional()
12686
+ });
12687
+ var ShareViewScopeSchema = object({
12688
+ type: literal("share-view"),
12689
+ grant: ShareViewGrantSchema
12690
+ });
12691
+ var AddonRoutesScopeSchema = object({
12692
+ type: literal("addon-routes"),
12693
+ access: array(MethodAccessSchema).min(1)
12694
+ });
12695
+ var PreferencesSelfScopeSchema = object({ type: literal("preferences-self") });
12696
+ var CredentialScopeSchema = union([
12697
+ literal("*"),
12698
+ ShareViewScopeSchema,
12699
+ AddonRoutesScopeSchema,
12700
+ PreferencesSelfScopeSchema,
12701
+ TokenScopeSchema
12702
+ ]);
12703
+ object({
12704
+ kind: literal("credential"),
12705
+ sub: string().min(1),
12706
+ jti: string().min(16),
12707
+ scopes: array(CredentialScopeSchema).min(1)
12708
+ });
12709
+ var PreferenceNamespaceSchema = string().regex(/^[a-z][a-z0-9.-]{0,63}$/);
12710
+ /** A namespace's value: a JSON object, opaque to the hub. */
12711
+ var PreferenceValueSchema = record(string(), unknown());
12712
+ var PreferenceDeviceIdSchema = string().min(1).max(64);
12713
+ /** A stored row, as the owner reads it. */
12714
+ var PreferenceRowSchema = object({
12715
+ namespace: PreferenceNamespaceSchema,
12716
+ value: PreferenceValueSchema,
12717
+ /** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
12718
+ revision: number().int().positive(),
12719
+ updatedAt: number().int(),
12720
+ /** The client id the last writer sent; `null` when it sent none. */
12721
+ updatedByDevice: PreferenceDeviceIdSchema.nullable()
12722
+ });
12723
+ object({
12724
+ /** Absent: every namespace the caller holds. */
12725
+ namespaces: array(PreferenceNamespaceSchema).max(32).optional() });
12726
+ object({ rows: array(PreferenceRowSchema) });
12727
+ object({
12728
+ namespace: PreferenceNamespaceSchema,
12729
+ value: PreferenceValueSchema,
12730
+ /**
12731
+ * The revision the edit was based on. Absent: last write wins. `0`: the
12732
+ * namespace must not exist yet. Any other value that is not the current
12733
+ * revision answers `conflict` and writes nothing.
12734
+ */
12735
+ baseRevision: number().int().nonnegative().optional(),
12736
+ deviceId: PreferenceDeviceIdSchema.optional()
12737
+ });
12738
+ discriminatedUnion("status", [object({
12739
+ status: literal("saved"),
12740
+ row: PreferenceRowSchema
12741
+ }), object({
12742
+ status: literal("conflict"),
12743
+ current: PreferenceRowSchema.nullable()
12744
+ })]);
12745
+ object({ namespace: PreferenceNamespaceSchema });
12746
+ object({
12747
+ /** `false` when the namespace did not exist. */
12748
+ deleted: boolean() });
12749
+ object({
12750
+ /** The revision the client holds per namespace; a namespace it does not list is new to it. */
12751
+ revisionByNamespace: record(PreferenceNamespaceSchema, number().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
12752
+ object({
12753
+ /** Every row whose revision differs from the client's, and every row it did not list. */
12754
+ rows: array(PreferenceRowSchema),
12755
+ /** Namespaces the client listed that no longer exist. */
12756
+ deleted: array(PreferenceNamespaceSchema)
12757
+ });
12478
12758
  _enum(["new-session", "step-up"]);
12479
12759
  /** The languages the hub's app landing pages are written in (D858). */
12480
12760
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -39764,38 +40044,37 @@ method(LlmRuntimeCompleteInputSchema, LlmGenerateResultSchema, {
39764
40044
  auth: "admin",
39765
40045
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39766
40046
  });
40047
+ var LlmProfileKindSchema = string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "a kind id is lower-case letters, digits and dashes");
40048
+ /** What a model (or, by default, every model of a kind) can do. */
40049
+ var LlmModelFeaturesSchema = object({
40050
+ vision: boolean(),
40051
+ tools: boolean(),
40052
+ streaming: boolean()
40053
+ });
40054
+ /** One model a provider offers. `features` overrides the kind's defaults, per field. */
40055
+ var LlmModelInfoSchema = object({
40056
+ id: string(),
40057
+ label: string().optional(),
40058
+ contextLength: number().int().positive().optional(),
40059
+ features: LlmModelFeaturesSchema.partial().optional()
40060
+ });
39767
40061
  /**
39768
- * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
39769
- * methods concat-fan across providers; single-row methods route to ONE
39770
- * provider by the `addonId` in the call input (the notification-output
39771
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
39772
- * (hub-placed); the cap stays open for future providers.
39773
- *
39774
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
39775
- * `apiKey` is a password field — providers REDACT it on read and merge on
39776
- * write; a stored key NEVER round-trips to a client.
40062
+ * The provider-specific part of a profile, validated by the provider that owns
40063
+ * the kind (`upsertProfile` refuses what it does not accept). A field its
40064
+ * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
40065
+ * keychain, never in the row, and reads back as the redaction marker.
39777
40066
  */
39778
- var LlmProfileKindSchema = _enum([
39779
- "openai-compatible",
39780
- "openai",
39781
- "anthropic",
39782
- "google",
39783
- "managed-local",
39784
- "apple-foundation"
39785
- ]);
40067
+ var LlmProviderConfigSchema = record(string(), unknown());
39786
40068
  var LlmProfileSchema = object({
39787
40069
  id: string(),
39788
40070
  name: string(),
40071
+ /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
39789
40072
  kind: LlmProfileKindSchema,
39790
40073
  /** Stamped by the provider — keeps the fanned catalog routable. */
39791
40074
  addonId: string(),
39792
40075
  enabled: boolean(),
39793
40076
  /** Vendor model id, or the managed runtime's loaded model. */
39794
40077
  model: string(),
39795
- /** Required for openai-compatible; override for cloud kinds. */
39796
- baseUrl: string().optional(),
39797
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
39798
- apiKey: string().optional(),
39799
40078
  /** Vision on/off. A vision call against a `false` profile is REFUSED, never
39800
40079
  * degraded to text — that shipped once and produced a confident answer to a
39801
40080
  * question about a picture nobody sent. */
@@ -39803,15 +40082,11 @@ var LlmProfileSchema = object({
39803
40082
  temperature: number().min(0).max(2).optional(),
39804
40083
  /** Nucleus sampling. Every wire we speak has it. */
39805
40084
  topP: number().min(0).max(1).optional(),
39806
- /** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
39807
- * wire does, and the client drops it there (measured: the request body gets
39808
- * `top_p` and no `top_k`). The profile editor hides the field wherever it
39809
- * would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
40085
+ /** Top-k sampling. Carried only by the wires that have it — a kind offers the
40086
+ * field in its editor only when its descriptor lists it in `profileFields`. */
39810
40087
  topK: number().int().positive().optional(),
39811
40088
  maxTokens: number().int().positive().optional(),
39812
- /** Prompt context window. Advisory for cloud kinds (they enforce their own);
39813
- * for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
39814
- * the model with, so it is the one field that changes a PROCESS. */
40089
+ /** Prompt context window. Advisory for cloud kinds (they enforce their own). */
39815
40090
  contextLength: number().int().positive().optional(),
39816
40091
  /** Default system prompt. A caller's `system` REPLACES it (never appends —
39817
40092
  * two system prompts fighting is worse than either alone). */
@@ -39837,16 +40112,37 @@ var LlmProfileSchema = object({
39837
40112
  * library; the REGISTRY of callable tools is ours and is empty in v1, so a
39838
40113
  * `true` here buys the wiring, not behaviour, until tools are registered. */
39839
40114
  toolsEnabled: boolean().default(false),
39840
- extraHeaders: record(string(), string()).optional(),
39841
- /** kind === 'managed-local' only (spec §4). */
39842
- runtime: ManagedRuntimeConfigSchema.optional(),
39843
- /**
39844
- * kind === 'apple-foundation' only: WHERE it runs — the only thing there is
39845
- * to configure (no key, no URL, no download; `model` is `apple-system`).
39846
- * `supportsVision` on such a row is stamped by the provider from the node's
39847
- * reported `imageInput`, never taken from the operator (D62).
39848
- */
39849
- appleFoundation: object({ nodeId: string() }).optional()
40115
+ /** Everything the kind's provider owns (endpoint, key, node, runtime…). */
40116
+ providerConfig: LlmProviderConfigSchema.default({})
40117
+ });
40118
+ /**
40119
+ * The common profile fields a kind's editor offers. The editor owns how each
40120
+ * one is drawn; the provider says which of them mean something on its wire.
40121
+ */
40122
+ var LlmProfileFieldSchema = _enum([
40123
+ "temperature",
40124
+ "topP",
40125
+ "topK",
40126
+ "maxTokens",
40127
+ "contextLength",
40128
+ "systemPrompt",
40129
+ "timeoutMs",
40130
+ "connectTimeoutMs",
40131
+ "firstTokenTimeoutMs",
40132
+ "idleTimeoutMs",
40133
+ "retry",
40134
+ "toolsEnabled"
40135
+ ]);
40136
+ /**
40137
+ * A provider-drawn part of the editor, by a generic widget id the admin UI
40138
+ * registers (`ai/apple-node`). `placement: 'model'` replaces the generic model
40139
+ * picker: that widget owns the model choice.
40140
+ */
40141
+ var LlmProviderWidgetSchema = object({
40142
+ id: string(),
40143
+ placement: _enum(["connection", "model"]),
40144
+ /** `providerConfig` keys this widget must fill before the profile can be saved. */
40145
+ requires: array(string()).optional()
39850
40146
  });
39851
40147
  /** ConfigUISchema tree passed through untyped on the wire (the
39852
40148
  * notification-output `ConfigSchemaPassthrough` precedent at
@@ -39855,11 +40151,56 @@ var ConfigSchemaPassthrough$3 = unknown();
39855
40151
  var LlmProfileKindDescriptorSchema = object({
39856
40152
  kind: LlmProfileKindSchema,
39857
40153
  label: string(),
40154
+ /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
39858
40155
  icon: string(),
39859
40156
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
39860
40157
  addonId: string(),
39861
- configSchema: ConfigSchemaPassthrough$3
40158
+ /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
40159
+ connectionSchema: ConfigSchemaPassthrough$3,
40160
+ /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
40161
+ advancedSchema: ConfigSchemaPassthrough$3.optional(),
40162
+ /** The kind's defaults; a model from `listModels` may override any of them. */
40163
+ features: LlmModelFeaturesSchema,
40164
+ /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
40165
+ visionEditable: boolean(),
40166
+ /** Where the model list comes from: `listModels`, `staticModels`, or nowhere. */
40167
+ modelCatalog: _enum([
40168
+ "fetch",
40169
+ "static",
40170
+ "none"
40171
+ ]),
40172
+ staticModels: array(LlmModelInfoSchema).optional(),
40173
+ /** The common fields that mean something on this kind's wire. */
40174
+ profileFields: array(LlmProfileFieldSchema),
40175
+ providerWidgets: array(LlmProviderWidgetSchema).optional()
40176
+ });
40177
+ /**
40178
+ * `listModels` input. `connection` is an UNSAVED draft of `providerConfig`
40179
+ * (the editor's form); with `profileId` too, a secret the draft leaves
40180
+ * untouched (absent or the redaction marker) is resolved server-side from the
40181
+ * stored profile — the browser never receives it.
40182
+ */
40183
+ var LlmListModelsInputSchema = object({
40184
+ addonId: string(),
40185
+ kind: LlmProfileKindSchema,
40186
+ profileId: string().optional(),
40187
+ connection: LlmProviderConfigSchema.optional()
39862
40188
  });
40189
+ var LlmListModelsErrorCodeSchema = _enum([
40190
+ "auth",
40191
+ "network",
40192
+ "unsupported",
40193
+ "invalid"
40194
+ ]);
40195
+ /** A RESULT, never a throw: "wrong key" is an answer the editor renders inline. */
40196
+ var LlmListModelsResultSchema = discriminatedUnion("ok", [object({
40197
+ ok: literal(true),
40198
+ models: array(LlmModelInfoSchema)
40199
+ }), object({
40200
+ ok: literal(false),
40201
+ code: LlmListModelsErrorCodeSchema,
40202
+ message: string()
40203
+ })]);
39863
40204
  var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
39864
40205
  var LlmDefaultSchema = object({
39865
40206
  selector: LlmDefaultSelectorSchema,
@@ -39959,7 +40300,10 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
39959
40300
  kind: "mutation",
39960
40301
  auth: "admin",
39961
40302
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39962
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
40303
+ }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
40304
+ kind: "mutation",
40305
+ auth: "admin"
40306
+ }), method(object({}), array(LlmDefaultSchema)), method(object({
39963
40307
  selector: LlmDefaultSelectorSchema,
39964
40308
  profileId: string().nullable()
39965
40309
  }), _void(), {
@@ -44065,202 +44409,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
44065
44409
  auth: "admin"
44066
44410
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
44067
44411
  /**
44068
- * Zod schemas for persisted record types.
44069
- *
44070
- * These schemas serve as the single source of truth for types that are
44071
- * stored in the settings-store backend and retrieved via tRPC. They
44072
- * replace the manual TypeScript interfaces with schema-derived types,
44073
- * enabling runtime validation when reading from the backend.
44074
- *
44075
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
44076
- * keeps the original name for backward compatibility.
44077
- */
44078
- /**
44079
- * Auth model (v2 — 2026-05-12 caps-only):
44080
- *
44081
- * Two principals:
44082
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
44083
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
44084
- *
44085
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44086
- * `super_admin` — collapsed onto the single boolean because every
44087
- * non-admin caller is governed by the same scope-check rules; the
44088
- * distinction was only ever used to route role-specific procedures
44089
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44090
- * with `isAdmin: false` + an explicit scope list.
44091
- */
44092
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44093
- var MethodAccessSchema = _enum([
44094
- "view",
44095
- "create",
44096
- "delete"
44097
- ]);
44098
- /**
44099
- * A single scope grant. Three forms — checked in matcher with OR
44100
- * semantics; the first match decides whether the call passes:
44101
- *
44102
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44103
- * cap with the matching `scope` declaration. New caps inherit grants
44104
- * automatically — adding a device cap to the codebase makes it
44105
- * reachable to every user with `category:device [...]` without a
44106
- * re-grant. Use this for "family viewer" / "operator" tiers.
44107
- *
44108
- * - `addon` — every cap that ships inside a given addon id. Niche;
44109
- * useful when an integration needs to interact with one specific
44110
- * addon's surface regardless of how many caps it exports.
44111
- *
44112
- * - `capability` — the most precise form. Single cap name. Use for
44113
- * integration tokens where you want to grant `addons.installPackage`
44114
- * and nothing else.
44115
- *
44116
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44117
- * "give me everything" escape; there is no wildcard scope.
44118
- */
44119
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44120
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44121
- var CapScopeSchema = _enum(["device", "system"]);
44122
- /**
44123
- * DeviceSelector (scope model v3 — 2026-08-12).
44124
- *
44125
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44126
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44127
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44128
- * AFTER the grant was minted — no re-grant, no re-login.
44129
- *
44130
- * - `all` — every device in the deployment. The broad viewer/operator
44131
- * lever without a `category` grant (a `category` grant also covers device
44132
- * caps that carry no deviceId; `all` is specifically the device set).
44133
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44134
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44135
- * is NOT covered until the grant is edited.
44136
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44137
- * DYNAMIC. A device that changes type, or a new device of the type,
44138
- * re-resolves on the next request.
44139
- * - `locations` — every device whose operator-assigned `location` label is
44140
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44141
- * null/unset location matches NO `locations` selector.
44142
- */
44143
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44144
- object({ kind: literal("all") }),
44145
- object({
44146
- kind: literal("ids"),
44147
- ids: array(number().int()).min(1)
44148
- }),
44149
- object({
44150
- kind: literal("types"),
44151
- types: array(_enum(DeviceType)).min(1)
44152
- }),
44153
- object({
44154
- kind: literal("locations"),
44155
- locations: array(string().min(1)).min(1)
44156
- })
44157
- ]);
44158
- var DeviceTokenScopeSchema = object({
44159
- type: literal("device"),
44160
- /** The device SET this grant covers — resolved against the live fleet. */
44161
- selector: DeviceSelectorSchema,
44162
- access: array(MethodAccessSchema).min(1),
44163
- /**
44164
- * Whether a grant on a PARENT device transparently covers its accessory
44165
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44166
- * Direction is parent → children ONLY.
44167
- *
44168
- * Absent → the matcher DERIVES it from the access flavour: `view`
44169
- * inherits (a camera viewer sees the camera's accessories), `create` /
44170
- * `delete` do NOT (actuating/removing a child is an explicit act the
44171
- * operator must grant on the child, not inherit from the parent). Set it
44172
- * explicitly to override that default per grant.
44173
- */
44174
- includeLinked: boolean().optional()
44175
- });
44176
- /**
44177
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44178
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44179
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44180
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44181
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44182
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44183
- * migration cannot reach a JWT already in a client's hands; parse-time
44184
- * migration covers both without a flag day. No cast — the raw object is read
44185
- * through `Reflect.get` (its static type is `unknown`).
44186
- */
44187
- function migrateLegacyTokenScope(raw) {
44188
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44189
- if (Reflect.get(raw, "type") !== "device") return raw;
44190
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44191
- const targets = Reflect.get(raw, "targets");
44192
- if (!Array.isArray(targets)) return raw;
44193
- return {
44194
- type: "device",
44195
- selector: {
44196
- kind: "ids",
44197
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44198
- },
44199
- access: Reflect.get(raw, "access")
44200
- };
44201
- }
44202
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44203
- object({
44204
- type: literal("category"),
44205
- target: CapScopeSchema,
44206
- access: array(MethodAccessSchema).min(1)
44207
- }),
44208
- object({
44209
- type: literal("capability"),
44210
- target: string(),
44211
- access: array(MethodAccessSchema).min(1)
44212
- }),
44213
- object({
44214
- type: literal("addon"),
44215
- target: string(),
44216
- access: array(MethodAccessSchema).min(1)
44217
- }),
44218
- DeviceTokenScopeSchema
44219
- ]));
44220
- object({
44221
- id: string(),
44222
- username: string(),
44223
- passwordHash: string(),
44224
- /**
44225
- * Admin bypass. When true, the middleware skips the scope-access
44226
- * check entirely. There is no other axis of privilege; the legacy
44227
- * role enum collapsed onto this boolean in v2.
44228
- */
44229
- isAdmin: boolean().default(false),
44230
- allowedProviders: AllowedProviderSchema,
44231
- allowedDevices: AllowedDevicesSchema,
44232
- /**
44233
- * Scopes granted to this user. Admins bypass; their `scopes` is
44234
- * ignored. Non-admins without scopes are locked out of every
44235
- * protected call.
44236
- */
44237
- scopes: array(TokenScopeSchema).default([]),
44238
- createdAt: number(),
44239
- updatedAt: number()
44240
- });
44241
- object({
44242
- id: string(),
44243
- label: string(),
44244
- isAdmin: boolean().default(false),
44245
- allowedProviders: AllowedProviderSchema,
44246
- allowedDevices: AllowedDevicesSchema,
44247
- tokenHash: string(),
44248
- tokenPrefix: string(),
44249
- createdAt: number(),
44250
- lastUsedAt: number().optional()
44251
- });
44252
- object({
44253
- id: string(),
44254
- userId: string(),
44255
- name: string(),
44256
- tokenHash: string(),
44257
- tokenPrefix: string(),
44258
- scopes: array(TokenScopeSchema),
44259
- expiresAt: number().nullish(),
44260
- lastUsedAt: number().nullish(),
44261
- createdAt: number()
44262
- });
44263
- /**
44264
44412
  * `oauth-integration` — a collection cap by which an addon declares
44265
44413
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44266
44414
  * Each provider returns a static descriptor; the core enumerates them
@@ -64060,26 +64208,6 @@ var ApiKeySummarySchema = object({
64060
64208
  createdAt: number(),
64061
64209
  lastUsedAt: number().optional()
64062
64210
  });
64063
- var ScopedTokenSummarySchema = object({
64064
- id: string(),
64065
- userId: string(),
64066
- name: string(),
64067
- tokenPrefix: string(),
64068
- scopes: array(TokenScopeSchema),
64069
- expiresAt: number().nullish(),
64070
- lastUsedAt: number().nullish(),
64071
- createdAt: number()
64072
- });
64073
- var CreateScopedTokenInputSchema = object({
64074
- userId: string(),
64075
- name: string(),
64076
- scopes: array(TokenScopeSchema),
64077
- expiresAt: number().optional()
64078
- });
64079
- var CreateScopedTokenResultSchema = object({
64080
- token: string(),
64081
- record: ScopedTokenSummarySchema
64082
- });
64083
64211
  var OauthSessionSummarySchema = object({
64084
64212
  id: string(),
64085
64213
  userId: string(),
@@ -64101,11 +64229,11 @@ var TotpStatusSchema = object({
64101
64229
  confirmedAt: number().nullable()
64102
64230
  });
64103
64231
  /**
64104
- * user-management — singleton capability for user accounts, API keys,
64105
- * and scoped tokens.
64232
+ * user-management — singleton capability for user accounts and the
64233
+ * legacy API-key rows.
64106
64234
  *
64107
64235
  * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
64108
- * — the subset check on `setUserScopes` / `createScopedToken` is moot
64236
+ * — the subset check on `setUserScopes` is moot
64109
64237
  * because non-admins never reach these. If/when we open non-admin
64110
64238
  * delegation, structural caller-scope subset check goes inside the
64111
64239
  * provider.
@@ -64162,15 +64290,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
64162
64290
  kind: "mutation",
64163
64291
  auth: "admin",
64164
64292
  access: "delete"
64165
- }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
64166
- kind: "mutation",
64167
- auth: "admin",
64168
- access: "create"
64169
- }), method(object({ id: string() }), object({ success: literal(true) }), {
64170
- kind: "mutation",
64171
- auth: "admin",
64172
- access: "delete"
64173
- }), method(object({ token: string() }), ScopedTokenSummarySchema.nullable(), { access: "view" }), method(object({ userId: string() }), array(ScopedTokenSummarySchema), { auth: "admin" }), method(object({ userId: string() }), TotpSetupResultSchema, {
64293
+ }), method(object({ userId: string() }), TotpSetupResultSchema, {
64174
64294
  kind: "mutation",
64175
64295
  auth: "admin",
64176
64296
  access: "create"
@@ -70260,7 +70380,7 @@ Object.freeze({
70260
70380
  capName: "llm",
70261
70381
  capScope: "system",
70262
70382
  addonId: null,
70263
- access: "view"
70383
+ access: "create"
70264
70384
  },
70265
70385
  "llm.listNodeModels": {
70266
70386
  capName: "llm",
@@ -74924,12 +75044,6 @@ Object.freeze({
74924
75044
  addonId: null,
74925
75045
  access: "create"
74926
75046
  },
74927
- "userManagement.createScopedToken": {
74928
- capName: "user-management",
74929
- capScope: "system",
74930
- addonId: null,
74931
- access: "create"
74932
- },
74933
75047
  "userManagement.createUser": {
74934
75048
  capName: "user-management",
74935
75049
  capScope: "system",
@@ -74978,12 +75092,6 @@ Object.freeze({
74978
75092
  addonId: null,
74979
75093
  access: "view"
74980
75094
  },
74981
- "userManagement.listScopedTokens": {
74982
- capName: "user-management",
74983
- capScope: "system",
74984
- addonId: null,
74985
- access: "view"
74986
- },
74987
75095
  "userManagement.listUsers": {
74988
75096
  capName: "user-management",
74989
75097
  capScope: "system",
@@ -75038,12 +75146,6 @@ Object.freeze({
75038
75146
  addonId: null,
75039
75147
  access: "delete"
75040
75148
  },
75041
- "userManagement.revokeScopedToken": {
75042
- capName: "user-management",
75043
- capScope: "system",
75044
- addonId: null,
75045
- access: "delete"
75046
- },
75047
75149
  "userManagement.setupTotp": {
75048
75150
  capName: "user-management",
75049
75151
  capScope: "system",
@@ -75074,12 +75176,6 @@ Object.freeze({
75074
75176
  addonId: null,
75075
75177
  access: "view"
75076
75178
  },
75077
- "userManagement.validateScopedToken": {
75078
- capName: "user-management",
75079
- capScope: "system",
75080
- addonId: null,
75081
- access: "view"
75082
- },
75083
75179
  "userManagement.verifyTotp": {
75084
75180
  capName: "user-management",
75085
75181
  capScope: "system",