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