@camstack/addon-provider-rademacher 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.mjs CHANGED
@@ -6398,7 +6398,7 @@ var ZodIssueCode = {
6398
6398
  var ZodFirstPartyTypeKind;
6399
6399
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
6400
6400
  //#endregion
6401
- //#region ../types/dist/sleep-BxjU_fJM.mjs
6401
+ //#region ../types/dist/sleep-yKL5gfrH.mjs
6402
6402
  /**
6403
6403
  * The audio chunk plane's byte format, and the ONE expansion from a coded
6404
6404
  * window to float samples (D455).
@@ -8780,6 +8780,12 @@ function normalizeAddonInitResult(result) {
8780
8780
  if (Array.isArray(result)) return { providers: result };
8781
8781
  return result;
8782
8782
  }
8783
+ /**
8784
+ * The share-view scope kinds a share-link token can carry. The hub mints
8785
+ * and validates them (`ShareViewGrantSchema` builds its
8786
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
8787
+ */
8788
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
8783
8789
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
8784
8790
  var PeerBytesTicketSchema = object({
8785
8791
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -13445,6 +13451,280 @@ var ConvertResultSchema = object({
13445
13451
  files: array(string()).readonly()
13446
13452
  })).readonly()
13447
13453
  });
13454
+ /**
13455
+ * Zod schemas for persisted record types.
13456
+ *
13457
+ * These schemas serve as the single source of truth for types that are
13458
+ * stored in the settings-store backend and retrieved via tRPC. They
13459
+ * replace the manual TypeScript interfaces with schema-derived types,
13460
+ * enabling runtime validation when reading from the backend.
13461
+ *
13462
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
13463
+ * keeps the original name for backward compatibility.
13464
+ */
13465
+ /**
13466
+ * Auth model (v2 — 2026-05-12 caps-only):
13467
+ *
13468
+ * Two principals:
13469
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
13470
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
13471
+ *
13472
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
13473
+ * `super_admin` — collapsed onto the single boolean because every
13474
+ * non-admin caller is governed by the same scope-check rules; the
13475
+ * distinction was only ever used to route role-specific procedures
13476
+ * which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
13477
+ * with `isAdmin: false` + an explicit scope list.
13478
+ */
13479
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
13480
+ var MethodAccessSchema = _enum([
13481
+ "view",
13482
+ "create",
13483
+ "delete"
13484
+ ]);
13485
+ /**
13486
+ * A single scope grant. Three forms — checked in matcher with OR
13487
+ * semantics; the first match decides whether the call passes:
13488
+ *
13489
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
13490
+ * cap with the matching `scope` declaration. New caps inherit grants
13491
+ * automatically — adding a device cap to the codebase makes it
13492
+ * reachable to every user with `category:device [...]` without a
13493
+ * re-grant. Use this for "family viewer" / "operator" tiers.
13494
+ *
13495
+ * - `addon` — every cap that ships inside a given addon id. Niche;
13496
+ * useful when an integration needs to interact with one specific
13497
+ * addon's surface regardless of how many caps it exports.
13498
+ *
13499
+ * - `capability` — the most precise form. Single cap name. Use for
13500
+ * integration tokens where you want to grant `addons.installPackage`
13501
+ * and nothing else.
13502
+ *
13503
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
13504
+ * "give me everything" escape; there is no wildcard scope.
13505
+ */
13506
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
13507
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
13508
+ var CapScopeSchema = _enum(["device", "system"]);
13509
+ /**
13510
+ * DeviceSelector (scope model v3 — 2026-08-12).
13511
+ *
13512
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
13513
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
13514
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
13515
+ * AFTER the grant was minted — no re-grant, no re-login.
13516
+ *
13517
+ * - `all` — every device in the deployment. The broad viewer/operator
13518
+ * lever without a `category` grant (a `category` grant also covers device
13519
+ * caps that carry no deviceId; `all` is specifically the device set).
13520
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
13521
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
13522
+ * is NOT covered until the grant is edited.
13523
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
13524
+ * DYNAMIC. A device that changes type, or a new device of the type,
13525
+ * re-resolves on the next request.
13526
+ * - `locations` — every device whose operator-assigned `location` label is
13527
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
13528
+ * null/unset location matches NO `locations` selector.
13529
+ */
13530
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
13531
+ object({ kind: literal("all") }),
13532
+ object({
13533
+ kind: literal("ids"),
13534
+ ids: array(number().int()).min(1)
13535
+ }),
13536
+ object({
13537
+ kind: literal("types"),
13538
+ types: array(_enum(DeviceType)).min(1)
13539
+ }),
13540
+ object({
13541
+ kind: literal("locations"),
13542
+ locations: array(string().min(1)).min(1)
13543
+ })
13544
+ ]);
13545
+ var DeviceTokenScopeSchema = object({
13546
+ type: literal("device"),
13547
+ /** The device SET this grant covers — resolved against the live fleet. */
13548
+ selector: DeviceSelectorSchema,
13549
+ access: array(MethodAccessSchema).min(1),
13550
+ /**
13551
+ * Whether a grant on a PARENT device transparently covers its accessory
13552
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
13553
+ * Direction is parent → children ONLY.
13554
+ *
13555
+ * Absent → the matcher DERIVES it from the access flavour: `view`
13556
+ * inherits (a camera viewer sees the camera's accessories), `create` /
13557
+ * `delete` do NOT (actuating/removing a child is an explicit act the
13558
+ * operator must grant on the child, not inherit from the parent). Set it
13559
+ * explicitly to override that default per grant.
13560
+ */
13561
+ includeLinked: boolean().optional()
13562
+ });
13563
+ /**
13564
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
13565
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
13566
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
13567
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
13568
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
13569
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
13570
+ * migration cannot reach a JWT already in a client's hands; parse-time
13571
+ * migration covers both without a flag day. No cast — the raw object is read
13572
+ * through `Reflect.get` (its static type is `unknown`).
13573
+ */
13574
+ function migrateLegacyTokenScope(raw) {
13575
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
13576
+ if (Reflect.get(raw, "type") !== "device") return raw;
13577
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
13578
+ const targets = Reflect.get(raw, "targets");
13579
+ if (!Array.isArray(targets)) return raw;
13580
+ return {
13581
+ type: "device",
13582
+ selector: {
13583
+ kind: "ids",
13584
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
13585
+ },
13586
+ access: Reflect.get(raw, "access")
13587
+ };
13588
+ }
13589
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
13590
+ object({
13591
+ type: literal("category"),
13592
+ target: CapScopeSchema,
13593
+ access: array(MethodAccessSchema).min(1)
13594
+ }),
13595
+ object({
13596
+ type: literal("capability"),
13597
+ target: string(),
13598
+ access: array(MethodAccessSchema).min(1)
13599
+ }),
13600
+ object({
13601
+ type: literal("addon"),
13602
+ target: string(),
13603
+ access: array(MethodAccessSchema).min(1)
13604
+ }),
13605
+ DeviceTokenScopeSchema
13606
+ ]));
13607
+ object({
13608
+ id: string(),
13609
+ username: string(),
13610
+ passwordHash: string(),
13611
+ /**
13612
+ * Admin bypass. When true, the middleware skips the scope-access
13613
+ * check entirely. There is no other axis of privilege; the legacy
13614
+ * role enum collapsed onto this boolean in v2.
13615
+ */
13616
+ isAdmin: boolean().default(false),
13617
+ allowedProviders: AllowedProviderSchema,
13618
+ allowedDevices: AllowedDevicesSchema,
13619
+ /**
13620
+ * Scopes granted to this user. Admins bypass; their `scopes` is
13621
+ * ignored. Non-admins without scopes are locked out of every
13622
+ * protected call.
13623
+ */
13624
+ scopes: array(TokenScopeSchema).default([]),
13625
+ createdAt: number(),
13626
+ updatedAt: number()
13627
+ });
13628
+ object({
13629
+ id: string(),
13630
+ label: string(),
13631
+ isAdmin: boolean().default(false),
13632
+ allowedProviders: AllowedProviderSchema,
13633
+ allowedDevices: AllowedDevicesSchema,
13634
+ tokenHash: string(),
13635
+ tokenPrefix: string(),
13636
+ createdAt: number(),
13637
+ lastUsedAt: number().optional()
13638
+ });
13639
+ object({
13640
+ id: string(),
13641
+ userId: string(),
13642
+ name: string(),
13643
+ tokenHash: string(),
13644
+ tokenPrefix: string(),
13645
+ scopes: array(TokenScopeSchema),
13646
+ expiresAt: number().nullish(),
13647
+ lastUsedAt: number().nullish(),
13648
+ createdAt: number()
13649
+ });
13650
+ /** What a share-view grant lets its holder see. */
13651
+ var ShareViewGrantSchema = object({
13652
+ kind: _enum(SHARE_VIEW_KINDS),
13653
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
13654
+ /** Talk-back, opt-in at mint time; absent means off. */
13655
+ talk: boolean().optional()
13656
+ });
13657
+ var ShareViewScopeSchema = object({
13658
+ type: literal("share-view"),
13659
+ grant: ShareViewGrantSchema
13660
+ });
13661
+ var AddonRoutesScopeSchema = object({
13662
+ type: literal("addon-routes"),
13663
+ access: array(MethodAccessSchema).min(1)
13664
+ });
13665
+ var PreferencesSelfScopeSchema = object({ type: literal("preferences-self") });
13666
+ var CredentialScopeSchema = union([
13667
+ literal("*"),
13668
+ ShareViewScopeSchema,
13669
+ AddonRoutesScopeSchema,
13670
+ PreferencesSelfScopeSchema,
13671
+ TokenScopeSchema
13672
+ ]);
13673
+ object({
13674
+ kind: literal("credential"),
13675
+ sub: string().min(1),
13676
+ jti: string().min(16),
13677
+ scopes: array(CredentialScopeSchema).min(1)
13678
+ });
13679
+ var PreferenceNamespaceSchema = string().regex(/^[a-z][a-z0-9.-]{0,63}$/);
13680
+ /** A namespace's value: a JSON object, opaque to the hub. */
13681
+ var PreferenceValueSchema = record(string(), unknown());
13682
+ var PreferenceDeviceIdSchema = string().min(1).max(64);
13683
+ /** A stored row, as the owner reads it. */
13684
+ var PreferenceRowSchema = object({
13685
+ namespace: PreferenceNamespaceSchema,
13686
+ value: PreferenceValueSchema,
13687
+ /** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
13688
+ revision: number().int().positive(),
13689
+ updatedAt: number().int(),
13690
+ /** The client id the last writer sent; `null` when it sent none. */
13691
+ updatedByDevice: PreferenceDeviceIdSchema.nullable()
13692
+ });
13693
+ object({
13694
+ /** Absent: every namespace the caller holds. */
13695
+ namespaces: array(PreferenceNamespaceSchema).max(32).optional() });
13696
+ object({ rows: array(PreferenceRowSchema) });
13697
+ object({
13698
+ namespace: PreferenceNamespaceSchema,
13699
+ value: PreferenceValueSchema,
13700
+ /**
13701
+ * The revision the edit was based on. Absent: last write wins. `0`: the
13702
+ * namespace must not exist yet. Any other value that is not the current
13703
+ * revision answers `conflict` and writes nothing.
13704
+ */
13705
+ baseRevision: number().int().nonnegative().optional(),
13706
+ deviceId: PreferenceDeviceIdSchema.optional()
13707
+ });
13708
+ discriminatedUnion("status", [object({
13709
+ status: literal("saved"),
13710
+ row: PreferenceRowSchema
13711
+ }), object({
13712
+ status: literal("conflict"),
13713
+ current: PreferenceRowSchema.nullable()
13714
+ })]);
13715
+ object({ namespace: PreferenceNamespaceSchema });
13716
+ object({
13717
+ /** `false` when the namespace did not exist. */
13718
+ deleted: boolean() });
13719
+ object({
13720
+ /** The revision the client holds per namespace; a namespace it does not list is new to it. */
13721
+ revisionByNamespace: record(PreferenceNamespaceSchema, number().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
13722
+ object({
13723
+ /** Every row whose revision differs from the client's, and every row it did not list. */
13724
+ rows: array(PreferenceRowSchema),
13725
+ /** Namespaces the client listed that no longer exist. */
13726
+ deleted: array(PreferenceNamespaceSchema)
13727
+ });
13448
13728
  _enum(["new-session", "step-up"]);
13449
13729
  /** The languages the hub's app landing pages are written in (D858). */
13450
13730
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -40734,38 +41014,37 @@ method(LlmRuntimeCompleteInputSchema, LlmGenerateResultSchema, {
40734
41014
  auth: "admin",
40735
41015
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
40736
41016
  });
41017
+ var LlmProfileKindSchema = string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "a kind id is lower-case letters, digits and dashes");
41018
+ /** What a model (or, by default, every model of a kind) can do. */
41019
+ var LlmModelFeaturesSchema = object({
41020
+ vision: boolean(),
41021
+ tools: boolean(),
41022
+ streaming: boolean()
41023
+ });
41024
+ /** One model a provider offers. `features` overrides the kind's defaults, per field. */
41025
+ var LlmModelInfoSchema = object({
41026
+ id: string(),
41027
+ label: string().optional(),
41028
+ contextLength: number().int().positive().optional(),
41029
+ features: LlmModelFeaturesSchema.partial().optional()
41030
+ });
40737
41031
  /**
40738
- * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
40739
- * methods concat-fan across providers; single-row methods route to ONE
40740
- * provider by the `addonId` in the call input (the notification-output
40741
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
40742
- * (hub-placed); the cap stays open for future providers.
40743
- *
40744
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
40745
- * `apiKey` is a password field — providers REDACT it on read and merge on
40746
- * write; a stored key NEVER round-trips to a client.
41032
+ * The provider-specific part of a profile, validated by the provider that owns
41033
+ * the kind (`upsertProfile` refuses what it does not accept). A field its
41034
+ * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
41035
+ * keychain, never in the row, and reads back as the redaction marker.
40747
41036
  */
40748
- var LlmProfileKindSchema = _enum([
40749
- "openai-compatible",
40750
- "openai",
40751
- "anthropic",
40752
- "google",
40753
- "managed-local",
40754
- "apple-foundation"
40755
- ]);
41037
+ var LlmProviderConfigSchema = record(string(), unknown());
40756
41038
  var LlmProfileSchema = object({
40757
41039
  id: string(),
40758
41040
  name: string(),
41041
+ /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
40759
41042
  kind: LlmProfileKindSchema,
40760
41043
  /** Stamped by the provider — keeps the fanned catalog routable. */
40761
41044
  addonId: string(),
40762
41045
  enabled: boolean(),
40763
41046
  /** Vendor model id, or the managed runtime's loaded model. */
40764
41047
  model: string(),
40765
- /** Required for openai-compatible; override for cloud kinds. */
40766
- baseUrl: string().optional(),
40767
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
40768
- apiKey: string().optional(),
40769
41048
  /** Vision on/off. A vision call against a `false` profile is REFUSED, never
40770
41049
  * degraded to text — that shipped once and produced a confident answer to a
40771
41050
  * question about a picture nobody sent. */
@@ -40773,15 +41052,11 @@ var LlmProfileSchema = object({
40773
41052
  temperature: number().min(0).max(2).optional(),
40774
41053
  /** Nucleus sampling. Every wire we speak has it. */
40775
41054
  topP: number().min(0).max(1).optional(),
40776
- /** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
40777
- * wire does, and the client drops it there (measured: the request body gets
40778
- * `top_p` and no `top_k`). The profile editor hides the field wherever it
40779
- * would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
41055
+ /** Top-k sampling. Carried only by the wires that have it — a kind offers the
41056
+ * field in its editor only when its descriptor lists it in `profileFields`. */
40780
41057
  topK: number().int().positive().optional(),
40781
41058
  maxTokens: number().int().positive().optional(),
40782
- /** Prompt context window. Advisory for cloud kinds (they enforce their own);
40783
- * for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
40784
- * the model with, so it is the one field that changes a PROCESS. */
41059
+ /** Prompt context window. Advisory for cloud kinds (they enforce their own). */
40785
41060
  contextLength: number().int().positive().optional(),
40786
41061
  /** Default system prompt. A caller's `system` REPLACES it (never appends —
40787
41062
  * two system prompts fighting is worse than either alone). */
@@ -40807,16 +41082,37 @@ var LlmProfileSchema = object({
40807
41082
  * library; the REGISTRY of callable tools is ours and is empty in v1, so a
40808
41083
  * `true` here buys the wiring, not behaviour, until tools are registered. */
40809
41084
  toolsEnabled: boolean().default(false),
40810
- extraHeaders: record(string(), string()).optional(),
40811
- /** kind === 'managed-local' only (spec §4). */
40812
- runtime: ManagedRuntimeConfigSchema.optional(),
40813
- /**
40814
- * kind === 'apple-foundation' only: WHERE it runs — the only thing there is
40815
- * to configure (no key, no URL, no download; `model` is `apple-system`).
40816
- * `supportsVision` on such a row is stamped by the provider from the node's
40817
- * reported `imageInput`, never taken from the operator (D62).
40818
- */
40819
- appleFoundation: object({ nodeId: string() }).optional()
41085
+ /** Everything the kind's provider owns (endpoint, key, node, runtime…). */
41086
+ providerConfig: LlmProviderConfigSchema.default({})
41087
+ });
41088
+ /**
41089
+ * The common profile fields a kind's editor offers. The editor owns how each
41090
+ * one is drawn; the provider says which of them mean something on its wire.
41091
+ */
41092
+ var LlmProfileFieldSchema = _enum([
41093
+ "temperature",
41094
+ "topP",
41095
+ "topK",
41096
+ "maxTokens",
41097
+ "contextLength",
41098
+ "systemPrompt",
41099
+ "timeoutMs",
41100
+ "connectTimeoutMs",
41101
+ "firstTokenTimeoutMs",
41102
+ "idleTimeoutMs",
41103
+ "retry",
41104
+ "toolsEnabled"
41105
+ ]);
41106
+ /**
41107
+ * A provider-drawn part of the editor, by a generic widget id the admin UI
41108
+ * registers (`ai/apple-node`). `placement: 'model'` replaces the generic model
41109
+ * picker: that widget owns the model choice.
41110
+ */
41111
+ var LlmProviderWidgetSchema = object({
41112
+ id: string(),
41113
+ placement: _enum(["connection", "model"]),
41114
+ /** `providerConfig` keys this widget must fill before the profile can be saved. */
41115
+ requires: array(string()).optional()
40820
41116
  });
40821
41117
  /** ConfigUISchema tree passed through untyped on the wire (the
40822
41118
  * notification-output `ConfigSchemaPassthrough` precedent at
@@ -40825,11 +41121,56 @@ var ConfigSchemaPassthrough$3 = unknown();
40825
41121
  var LlmProfileKindDescriptorSchema = object({
40826
41122
  kind: LlmProfileKindSchema,
40827
41123
  label: string(),
41124
+ /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
40828
41125
  icon: string(),
40829
41126
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
40830
41127
  addonId: string(),
40831
- configSchema: ConfigSchemaPassthrough$3
41128
+ /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
41129
+ connectionSchema: ConfigSchemaPassthrough$3,
41130
+ /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
41131
+ advancedSchema: ConfigSchemaPassthrough$3.optional(),
41132
+ /** The kind's defaults; a model from `listModels` may override any of them. */
41133
+ features: LlmModelFeaturesSchema,
41134
+ /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
41135
+ visionEditable: boolean(),
41136
+ /** Where the model list comes from: `listModels`, `staticModels`, or nowhere. */
41137
+ modelCatalog: _enum([
41138
+ "fetch",
41139
+ "static",
41140
+ "none"
41141
+ ]),
41142
+ staticModels: array(LlmModelInfoSchema).optional(),
41143
+ /** The common fields that mean something on this kind's wire. */
41144
+ profileFields: array(LlmProfileFieldSchema),
41145
+ providerWidgets: array(LlmProviderWidgetSchema).optional()
41146
+ });
41147
+ /**
41148
+ * `listModels` input. `connection` is an UNSAVED draft of `providerConfig`
41149
+ * (the editor's form); with `profileId` too, a secret the draft leaves
41150
+ * untouched (absent or the redaction marker) is resolved server-side from the
41151
+ * stored profile — the browser never receives it.
41152
+ */
41153
+ var LlmListModelsInputSchema = object({
41154
+ addonId: string(),
41155
+ kind: LlmProfileKindSchema,
41156
+ profileId: string().optional(),
41157
+ connection: LlmProviderConfigSchema.optional()
40832
41158
  });
41159
+ var LlmListModelsErrorCodeSchema = _enum([
41160
+ "auth",
41161
+ "network",
41162
+ "unsupported",
41163
+ "invalid"
41164
+ ]);
41165
+ /** A RESULT, never a throw: "wrong key" is an answer the editor renders inline. */
41166
+ var LlmListModelsResultSchema = discriminatedUnion("ok", [object({
41167
+ ok: literal(true),
41168
+ models: array(LlmModelInfoSchema)
41169
+ }), object({
41170
+ ok: literal(false),
41171
+ code: LlmListModelsErrorCodeSchema,
41172
+ message: string()
41173
+ })]);
40833
41174
  var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
40834
41175
  var LlmDefaultSchema = object({
40835
41176
  selector: LlmDefaultSelectorSchema,
@@ -40929,7 +41270,10 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
40929
41270
  kind: "mutation",
40930
41271
  auth: "admin",
40931
41272
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
40932
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
41273
+ }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
41274
+ kind: "mutation",
41275
+ auth: "admin"
41276
+ }), method(object({}), array(LlmDefaultSchema)), method(object({
40933
41277
  selector: LlmDefaultSelectorSchema,
40934
41278
  profileId: string().nullable()
40935
41279
  }), _void(), {
@@ -45035,202 +45379,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
45035
45379
  auth: "admin"
45036
45380
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
45037
45381
  /**
45038
- * Zod schemas for persisted record types.
45039
- *
45040
- * These schemas serve as the single source of truth for types that are
45041
- * stored in the settings-store backend and retrieved via tRPC. They
45042
- * replace the manual TypeScript interfaces with schema-derived types,
45043
- * enabling runtime validation when reading from the backend.
45044
- *
45045
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
45046
- * keeps the original name for backward compatibility.
45047
- */
45048
- /**
45049
- * Auth model (v2 — 2026-05-12 caps-only):
45050
- *
45051
- * Two principals:
45052
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
45053
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
45054
- *
45055
- * No role enum. There used to be `viewer / agent / scoped` and earlier
45056
- * `super_admin` — collapsed onto the single boolean because every
45057
- * non-admin caller is governed by the same scope-check rules; the
45058
- * distinction was only ever used to route role-specific procedures
45059
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
45060
- * with `isAdmin: false` + an explicit scope list.
45061
- */
45062
- /** Per-method access flavour. Materialised on every cap method via codegen. */
45063
- var MethodAccessSchema = _enum([
45064
- "view",
45065
- "create",
45066
- "delete"
45067
- ]);
45068
- /**
45069
- * A single scope grant. Three forms — checked in matcher with OR
45070
- * semantics; the first match decides whether the call passes:
45071
- *
45072
- * - `category` — broadest. `target: 'device' | 'system'` selects every
45073
- * cap with the matching `scope` declaration. New caps inherit grants
45074
- * automatically — adding a device cap to the codebase makes it
45075
- * reachable to every user with `category:device [...]` without a
45076
- * re-grant. Use this for "family viewer" / "operator" tiers.
45077
- *
45078
- * - `addon` — every cap that ships inside a given addon id. Niche;
45079
- * useful when an integration needs to interact with one specific
45080
- * addon's surface regardless of how many caps it exports.
45081
- *
45082
- * - `capability` — the most precise form. Single cap name. Use for
45083
- * integration tokens where you want to grant `addons.installPackage`
45084
- * and nothing else.
45085
- *
45086
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
45087
- * "give me everything" escape; there is no wildcard scope.
45088
- */
45089
- var AllowedProviderSchema = union([literal("*"), array(string())]);
45090
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
45091
- var CapScopeSchema = _enum(["device", "system"]);
45092
- /**
45093
- * DeviceSelector (scope model v3 — 2026-08-12).
45094
- *
45095
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
45096
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
45097
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
45098
- * AFTER the grant was minted — no re-grant, no re-login.
45099
- *
45100
- * - `all` — every device in the deployment. The broad viewer/operator
45101
- * lever without a `category` grant (a `category` grant also covers device
45102
- * caps that carry no deviceId; `all` is specifically the device set).
45103
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
45104
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
45105
- * is NOT covered until the grant is edited.
45106
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
45107
- * DYNAMIC. A device that changes type, or a new device of the type,
45108
- * re-resolves on the next request.
45109
- * - `locations` — every device whose operator-assigned `location` label is
45110
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
45111
- * null/unset location matches NO `locations` selector.
45112
- */
45113
- var DeviceSelectorSchema = discriminatedUnion("kind", [
45114
- object({ kind: literal("all") }),
45115
- object({
45116
- kind: literal("ids"),
45117
- ids: array(number().int()).min(1)
45118
- }),
45119
- object({
45120
- kind: literal("types"),
45121
- types: array(_enum(DeviceType)).min(1)
45122
- }),
45123
- object({
45124
- kind: literal("locations"),
45125
- locations: array(string().min(1)).min(1)
45126
- })
45127
- ]);
45128
- var DeviceTokenScopeSchema = object({
45129
- type: literal("device"),
45130
- /** The device SET this grant covers — resolved against the live fleet. */
45131
- selector: DeviceSelectorSchema,
45132
- access: array(MethodAccessSchema).min(1),
45133
- /**
45134
- * Whether a grant on a PARENT device transparently covers its accessory
45135
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
45136
- * Direction is parent → children ONLY.
45137
- *
45138
- * Absent → the matcher DERIVES it from the access flavour: `view`
45139
- * inherits (a camera viewer sees the camera's accessories), `create` /
45140
- * `delete` do NOT (actuating/removing a child is an explicit act the
45141
- * operator must grant on the child, not inherit from the parent). Set it
45142
- * explicitly to override that default per grant.
45143
- */
45144
- includeLinked: boolean().optional()
45145
- });
45146
- /**
45147
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
45148
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
45149
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
45150
- * EVERY parse path — stored records AND the JWT-carried scope arrays
45151
- * normalised at the request boundary ({@link normalizeTokenScopes} in
45152
- * `device-selector.ts`). Chosen over a one-time DB migration because a
45153
- * migration cannot reach a JWT already in a client's hands; parse-time
45154
- * migration covers both without a flag day. No cast — the raw object is read
45155
- * through `Reflect.get` (its static type is `unknown`).
45156
- */
45157
- function migrateLegacyTokenScope(raw) {
45158
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
45159
- if (Reflect.get(raw, "type") !== "device") return raw;
45160
- if (Reflect.get(raw, "selector") !== void 0) return raw;
45161
- const targets = Reflect.get(raw, "targets");
45162
- if (!Array.isArray(targets)) return raw;
45163
- return {
45164
- type: "device",
45165
- selector: {
45166
- kind: "ids",
45167
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
45168
- },
45169
- access: Reflect.get(raw, "access")
45170
- };
45171
- }
45172
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
45173
- object({
45174
- type: literal("category"),
45175
- target: CapScopeSchema,
45176
- access: array(MethodAccessSchema).min(1)
45177
- }),
45178
- object({
45179
- type: literal("capability"),
45180
- target: string(),
45181
- access: array(MethodAccessSchema).min(1)
45182
- }),
45183
- object({
45184
- type: literal("addon"),
45185
- target: string(),
45186
- access: array(MethodAccessSchema).min(1)
45187
- }),
45188
- DeviceTokenScopeSchema
45189
- ]));
45190
- object({
45191
- id: string(),
45192
- username: string(),
45193
- passwordHash: string(),
45194
- /**
45195
- * Admin bypass. When true, the middleware skips the scope-access
45196
- * check entirely. There is no other axis of privilege; the legacy
45197
- * role enum collapsed onto this boolean in v2.
45198
- */
45199
- isAdmin: boolean().default(false),
45200
- allowedProviders: AllowedProviderSchema,
45201
- allowedDevices: AllowedDevicesSchema,
45202
- /**
45203
- * Scopes granted to this user. Admins bypass; their `scopes` is
45204
- * ignored. Non-admins without scopes are locked out of every
45205
- * protected call.
45206
- */
45207
- scopes: array(TokenScopeSchema).default([]),
45208
- createdAt: number(),
45209
- updatedAt: number()
45210
- });
45211
- object({
45212
- id: string(),
45213
- label: string(),
45214
- isAdmin: boolean().default(false),
45215
- allowedProviders: AllowedProviderSchema,
45216
- allowedDevices: AllowedDevicesSchema,
45217
- tokenHash: string(),
45218
- tokenPrefix: string(),
45219
- createdAt: number(),
45220
- lastUsedAt: number().optional()
45221
- });
45222
- object({
45223
- id: string(),
45224
- userId: string(),
45225
- name: string(),
45226
- tokenHash: string(),
45227
- tokenPrefix: string(),
45228
- scopes: array(TokenScopeSchema),
45229
- expiresAt: number().nullish(),
45230
- lastUsedAt: number().nullish(),
45231
- createdAt: number()
45232
- });
45233
- /**
45234
45382
  * `oauth-integration` — a collection cap by which an addon declares
45235
45383
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
45236
45384
  * Each provider returns a static descriptor; the core enumerates them
@@ -65013,26 +65161,6 @@ var ApiKeySummarySchema = object({
65013
65161
  createdAt: number(),
65014
65162
  lastUsedAt: number().optional()
65015
65163
  });
65016
- var ScopedTokenSummarySchema = object({
65017
- id: string(),
65018
- userId: string(),
65019
- name: string(),
65020
- tokenPrefix: string(),
65021
- scopes: array(TokenScopeSchema),
65022
- expiresAt: number().nullish(),
65023
- lastUsedAt: number().nullish(),
65024
- createdAt: number()
65025
- });
65026
- var CreateScopedTokenInputSchema = object({
65027
- userId: string(),
65028
- name: string(),
65029
- scopes: array(TokenScopeSchema),
65030
- expiresAt: number().optional()
65031
- });
65032
- var CreateScopedTokenResultSchema = object({
65033
- token: string(),
65034
- record: ScopedTokenSummarySchema
65035
- });
65036
65164
  var OauthSessionSummarySchema = object({
65037
65165
  id: string(),
65038
65166
  userId: string(),
@@ -65054,11 +65182,11 @@ var TotpStatusSchema = object({
65054
65182
  confirmedAt: number().nullable()
65055
65183
  });
65056
65184
  /**
65057
- * user-management — singleton capability for user accounts, API keys,
65058
- * and scoped tokens.
65185
+ * user-management — singleton capability for user accounts and the
65186
+ * legacy API-key rows.
65059
65187
  *
65060
65188
  * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
65061
- * — the subset check on `setUserScopes` / `createScopedToken` is moot
65189
+ * — the subset check on `setUserScopes` is moot
65062
65190
  * because non-admins never reach these. If/when we open non-admin
65063
65191
  * delegation, structural caller-scope subset check goes inside the
65064
65192
  * provider.
@@ -65115,15 +65243,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
65115
65243
  kind: "mutation",
65116
65244
  auth: "admin",
65117
65245
  access: "delete"
65118
- }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
65119
- kind: "mutation",
65120
- auth: "admin",
65121
- access: "create"
65122
- }), method(object({ id: string() }), object({ success: literal(true) }), {
65123
- kind: "mutation",
65124
- auth: "admin",
65125
- access: "delete"
65126
- }), method(object({ token: string() }), ScopedTokenSummarySchema.nullable(), { access: "view" }), method(object({ userId: string() }), array(ScopedTokenSummarySchema), { auth: "admin" }), method(object({ userId: string() }), TotpSetupResultSchema, {
65246
+ }), method(object({ userId: string() }), TotpSetupResultSchema, {
65127
65247
  kind: "mutation",
65128
65248
  auth: "admin",
65129
65249
  access: "create"
@@ -71213,7 +71333,7 @@ Object.freeze({
71213
71333
  capName: "llm",
71214
71334
  capScope: "system",
71215
71335
  addonId: null,
71216
- access: "view"
71336
+ access: "create"
71217
71337
  },
71218
71338
  "llm.listNodeModels": {
71219
71339
  capName: "llm",
@@ -75877,12 +75997,6 @@ Object.freeze({
75877
75997
  addonId: null,
75878
75998
  access: "create"
75879
75999
  },
75880
- "userManagement.createScopedToken": {
75881
- capName: "user-management",
75882
- capScope: "system",
75883
- addonId: null,
75884
- access: "create"
75885
- },
75886
76000
  "userManagement.createUser": {
75887
76001
  capName: "user-management",
75888
76002
  capScope: "system",
@@ -75931,12 +76045,6 @@ Object.freeze({
75931
76045
  addonId: null,
75932
76046
  access: "view"
75933
76047
  },
75934
- "userManagement.listScopedTokens": {
75935
- capName: "user-management",
75936
- capScope: "system",
75937
- addonId: null,
75938
- access: "view"
75939
- },
75940
76048
  "userManagement.listUsers": {
75941
76049
  capName: "user-management",
75942
76050
  capScope: "system",
@@ -75991,12 +76099,6 @@ Object.freeze({
75991
76099
  addonId: null,
75992
76100
  access: "delete"
75993
76101
  },
75994
- "userManagement.revokeScopedToken": {
75995
- capName: "user-management",
75996
- capScope: "system",
75997
- addonId: null,
75998
- access: "delete"
75999
- },
76000
76102
  "userManagement.setupTotp": {
76001
76103
  capName: "user-management",
76002
76104
  capScope: "system",
@@ -76027,12 +76129,6 @@ Object.freeze({
76027
76129
  addonId: null,
76028
76130
  access: "view"
76029
76131
  },
76030
- "userManagement.validateScopedToken": {
76031
- capName: "user-management",
76032
- capScope: "system",
76033
- addonId: null,
76034
- access: "view"
76035
- },
76036
76132
  "userManagement.verifyTotp": {
76037
76133
  capName: "user-management",
76038
76134
  capScope: "system",