@camstack/addon-provider-petkit 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
@@ -6515,7 +6515,7 @@ var ZodIssueCode = {
6515
6515
  var ZodFirstPartyTypeKind;
6516
6516
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
6517
6517
  //#endregion
6518
- //#region ../types/dist/sleep-BxjU_fJM.mjs
6518
+ //#region ../types/dist/sleep-yKL5gfrH.mjs
6519
6519
  /**
6520
6520
  * The audio chunk plane's byte format, and the ONE expansion from a coded
6521
6521
  * window to float samples (D455).
@@ -8897,6 +8897,12 @@ function normalizeAddonInitResult(result) {
8897
8897
  if (Array.isArray(result)) return { providers: result };
8898
8898
  return result;
8899
8899
  }
8900
+ /**
8901
+ * The share-view scope kinds a share-link token can carry. The hub mints
8902
+ * and validates them (`ShareViewGrantSchema` builds its
8903
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
8904
+ */
8905
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
8900
8906
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
8901
8907
  var PeerBytesTicketSchema = object({
8902
8908
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -13562,6 +13568,280 @@ var ConvertResultSchema = object({
13562
13568
  files: array(string()).readonly()
13563
13569
  })).readonly()
13564
13570
  });
13571
+ /**
13572
+ * Zod schemas for persisted record types.
13573
+ *
13574
+ * These schemas serve as the single source of truth for types that are
13575
+ * stored in the settings-store backend and retrieved via tRPC. They
13576
+ * replace the manual TypeScript interfaces with schema-derived types,
13577
+ * enabling runtime validation when reading from the backend.
13578
+ *
13579
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
13580
+ * keeps the original name for backward compatibility.
13581
+ */
13582
+ /**
13583
+ * Auth model (v2 — 2026-05-12 caps-only):
13584
+ *
13585
+ * Two principals:
13586
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
13587
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
13588
+ *
13589
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
13590
+ * `super_admin` — collapsed onto the single boolean because every
13591
+ * non-admin caller is governed by the same scope-check rules; the
13592
+ * distinction was only ever used to route role-specific procedures
13593
+ * which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
13594
+ * with `isAdmin: false` + an explicit scope list.
13595
+ */
13596
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
13597
+ var MethodAccessSchema = _enum([
13598
+ "view",
13599
+ "create",
13600
+ "delete"
13601
+ ]);
13602
+ /**
13603
+ * A single scope grant. Three forms — checked in matcher with OR
13604
+ * semantics; the first match decides whether the call passes:
13605
+ *
13606
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
13607
+ * cap with the matching `scope` declaration. New caps inherit grants
13608
+ * automatically — adding a device cap to the codebase makes it
13609
+ * reachable to every user with `category:device [...]` without a
13610
+ * re-grant. Use this for "family viewer" / "operator" tiers.
13611
+ *
13612
+ * - `addon` — every cap that ships inside a given addon id. Niche;
13613
+ * useful when an integration needs to interact with one specific
13614
+ * addon's surface regardless of how many caps it exports.
13615
+ *
13616
+ * - `capability` — the most precise form. Single cap name. Use for
13617
+ * integration tokens where you want to grant `addons.installPackage`
13618
+ * and nothing else.
13619
+ *
13620
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
13621
+ * "give me everything" escape; there is no wildcard scope.
13622
+ */
13623
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
13624
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
13625
+ var CapScopeSchema = _enum(["device", "system"]);
13626
+ /**
13627
+ * DeviceSelector (scope model v3 — 2026-08-12).
13628
+ *
13629
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
13630
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
13631
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
13632
+ * AFTER the grant was minted — no re-grant, no re-login.
13633
+ *
13634
+ * - `all` — every device in the deployment. The broad viewer/operator
13635
+ * lever without a `category` grant (a `category` grant also covers device
13636
+ * caps that carry no deviceId; `all` is specifically the device set).
13637
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
13638
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
13639
+ * is NOT covered until the grant is edited.
13640
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
13641
+ * DYNAMIC. A device that changes type, or a new device of the type,
13642
+ * re-resolves on the next request.
13643
+ * - `locations` — every device whose operator-assigned `location` label is
13644
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
13645
+ * null/unset location matches NO `locations` selector.
13646
+ */
13647
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
13648
+ object({ kind: literal("all") }),
13649
+ object({
13650
+ kind: literal("ids"),
13651
+ ids: array(number().int()).min(1)
13652
+ }),
13653
+ object({
13654
+ kind: literal("types"),
13655
+ types: array(_enum(DeviceType)).min(1)
13656
+ }),
13657
+ object({
13658
+ kind: literal("locations"),
13659
+ locations: array(string().min(1)).min(1)
13660
+ })
13661
+ ]);
13662
+ var DeviceTokenScopeSchema = object({
13663
+ type: literal("device"),
13664
+ /** The device SET this grant covers — resolved against the live fleet. */
13665
+ selector: DeviceSelectorSchema,
13666
+ access: array(MethodAccessSchema).min(1),
13667
+ /**
13668
+ * Whether a grant on a PARENT device transparently covers its accessory
13669
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
13670
+ * Direction is parent → children ONLY.
13671
+ *
13672
+ * Absent → the matcher DERIVES it from the access flavour: `view`
13673
+ * inherits (a camera viewer sees the camera's accessories), `create` /
13674
+ * `delete` do NOT (actuating/removing a child is an explicit act the
13675
+ * operator must grant on the child, not inherit from the parent). Set it
13676
+ * explicitly to override that default per grant.
13677
+ */
13678
+ includeLinked: boolean().optional()
13679
+ });
13680
+ /**
13681
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
13682
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
13683
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
13684
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
13685
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
13686
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
13687
+ * migration cannot reach a JWT already in a client's hands; parse-time
13688
+ * migration covers both without a flag day. No cast — the raw object is read
13689
+ * through `Reflect.get` (its static type is `unknown`).
13690
+ */
13691
+ function migrateLegacyTokenScope(raw) {
13692
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
13693
+ if (Reflect.get(raw, "type") !== "device") return raw;
13694
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
13695
+ const targets = Reflect.get(raw, "targets");
13696
+ if (!Array.isArray(targets)) return raw;
13697
+ return {
13698
+ type: "device",
13699
+ selector: {
13700
+ kind: "ids",
13701
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
13702
+ },
13703
+ access: Reflect.get(raw, "access")
13704
+ };
13705
+ }
13706
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
13707
+ object({
13708
+ type: literal("category"),
13709
+ target: CapScopeSchema,
13710
+ access: array(MethodAccessSchema).min(1)
13711
+ }),
13712
+ object({
13713
+ type: literal("capability"),
13714
+ target: string(),
13715
+ access: array(MethodAccessSchema).min(1)
13716
+ }),
13717
+ object({
13718
+ type: literal("addon"),
13719
+ target: string(),
13720
+ access: array(MethodAccessSchema).min(1)
13721
+ }),
13722
+ DeviceTokenScopeSchema
13723
+ ]));
13724
+ object({
13725
+ id: string(),
13726
+ username: string(),
13727
+ passwordHash: string(),
13728
+ /**
13729
+ * Admin bypass. When true, the middleware skips the scope-access
13730
+ * check entirely. There is no other axis of privilege; the legacy
13731
+ * role enum collapsed onto this boolean in v2.
13732
+ */
13733
+ isAdmin: boolean().default(false),
13734
+ allowedProviders: AllowedProviderSchema,
13735
+ allowedDevices: AllowedDevicesSchema,
13736
+ /**
13737
+ * Scopes granted to this user. Admins bypass; their `scopes` is
13738
+ * ignored. Non-admins without scopes are locked out of every
13739
+ * protected call.
13740
+ */
13741
+ scopes: array(TokenScopeSchema).default([]),
13742
+ createdAt: number(),
13743
+ updatedAt: number()
13744
+ });
13745
+ object({
13746
+ id: string(),
13747
+ label: string(),
13748
+ isAdmin: boolean().default(false),
13749
+ allowedProviders: AllowedProviderSchema,
13750
+ allowedDevices: AllowedDevicesSchema,
13751
+ tokenHash: string(),
13752
+ tokenPrefix: string(),
13753
+ createdAt: number(),
13754
+ lastUsedAt: number().optional()
13755
+ });
13756
+ object({
13757
+ id: string(),
13758
+ userId: string(),
13759
+ name: string(),
13760
+ tokenHash: string(),
13761
+ tokenPrefix: string(),
13762
+ scopes: array(TokenScopeSchema),
13763
+ expiresAt: number().nullish(),
13764
+ lastUsedAt: number().nullish(),
13765
+ createdAt: number()
13766
+ });
13767
+ /** What a share-view grant lets its holder see. */
13768
+ var ShareViewGrantSchema = object({
13769
+ kind: _enum(SHARE_VIEW_KINDS),
13770
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
13771
+ /** Talk-back, opt-in at mint time; absent means off. */
13772
+ talk: boolean().optional()
13773
+ });
13774
+ var ShareViewScopeSchema = object({
13775
+ type: literal("share-view"),
13776
+ grant: ShareViewGrantSchema
13777
+ });
13778
+ var AddonRoutesScopeSchema = object({
13779
+ type: literal("addon-routes"),
13780
+ access: array(MethodAccessSchema).min(1)
13781
+ });
13782
+ var PreferencesSelfScopeSchema = object({ type: literal("preferences-self") });
13783
+ var CredentialScopeSchema = union([
13784
+ literal("*"),
13785
+ ShareViewScopeSchema,
13786
+ AddonRoutesScopeSchema,
13787
+ PreferencesSelfScopeSchema,
13788
+ TokenScopeSchema
13789
+ ]);
13790
+ object({
13791
+ kind: literal("credential"),
13792
+ sub: string().min(1),
13793
+ jti: string().min(16),
13794
+ scopes: array(CredentialScopeSchema).min(1)
13795
+ });
13796
+ var PreferenceNamespaceSchema = string().regex(/^[a-z][a-z0-9.-]{0,63}$/);
13797
+ /** A namespace's value: a JSON object, opaque to the hub. */
13798
+ var PreferenceValueSchema = record(string(), unknown());
13799
+ var PreferenceDeviceIdSchema = string().min(1).max(64);
13800
+ /** A stored row, as the owner reads it. */
13801
+ var PreferenceRowSchema = object({
13802
+ namespace: PreferenceNamespaceSchema,
13803
+ value: PreferenceValueSchema,
13804
+ /** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
13805
+ revision: number().int().positive(),
13806
+ updatedAt: number().int(),
13807
+ /** The client id the last writer sent; `null` when it sent none. */
13808
+ updatedByDevice: PreferenceDeviceIdSchema.nullable()
13809
+ });
13810
+ object({
13811
+ /** Absent: every namespace the caller holds. */
13812
+ namespaces: array(PreferenceNamespaceSchema).max(32).optional() });
13813
+ object({ rows: array(PreferenceRowSchema) });
13814
+ object({
13815
+ namespace: PreferenceNamespaceSchema,
13816
+ value: PreferenceValueSchema,
13817
+ /**
13818
+ * The revision the edit was based on. Absent: last write wins. `0`: the
13819
+ * namespace must not exist yet. Any other value that is not the current
13820
+ * revision answers `conflict` and writes nothing.
13821
+ */
13822
+ baseRevision: number().int().nonnegative().optional(),
13823
+ deviceId: PreferenceDeviceIdSchema.optional()
13824
+ });
13825
+ discriminatedUnion("status", [object({
13826
+ status: literal("saved"),
13827
+ row: PreferenceRowSchema
13828
+ }), object({
13829
+ status: literal("conflict"),
13830
+ current: PreferenceRowSchema.nullable()
13831
+ })]);
13832
+ object({ namespace: PreferenceNamespaceSchema });
13833
+ object({
13834
+ /** `false` when the namespace did not exist. */
13835
+ deleted: boolean() });
13836
+ object({
13837
+ /** The revision the client holds per namespace; a namespace it does not list is new to it. */
13838
+ revisionByNamespace: record(PreferenceNamespaceSchema, number().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
13839
+ object({
13840
+ /** Every row whose revision differs from the client's, and every row it did not list. */
13841
+ rows: array(PreferenceRowSchema),
13842
+ /** Namespaces the client listed that no longer exist. */
13843
+ deleted: array(PreferenceNamespaceSchema)
13844
+ });
13565
13845
  _enum(["new-session", "step-up"]);
13566
13846
  /** The languages the hub's app landing pages are written in (D858). */
13567
13847
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -40755,38 +41035,37 @@ method(LlmRuntimeCompleteInputSchema, LlmGenerateResultSchema, {
40755
41035
  auth: "admin",
40756
41036
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
40757
41037
  });
41038
+ var LlmProfileKindSchema = string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "a kind id is lower-case letters, digits and dashes");
41039
+ /** What a model (or, by default, every model of a kind) can do. */
41040
+ var LlmModelFeaturesSchema = object({
41041
+ vision: boolean(),
41042
+ tools: boolean(),
41043
+ streaming: boolean()
41044
+ });
41045
+ /** One model a provider offers. `features` overrides the kind's defaults, per field. */
41046
+ var LlmModelInfoSchema = object({
41047
+ id: string(),
41048
+ label: string().optional(),
41049
+ contextLength: number().int().positive().optional(),
41050
+ features: LlmModelFeaturesSchema.partial().optional()
41051
+ });
40758
41052
  /**
40759
- * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
40760
- * methods concat-fan across providers; single-row methods route to ONE
40761
- * provider by the `addonId` in the call input (the notification-output
40762
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
40763
- * (hub-placed); the cap stays open for future providers.
40764
- *
40765
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
40766
- * `apiKey` is a password field — providers REDACT it on read and merge on
40767
- * write; a stored key NEVER round-trips to a client.
41053
+ * The provider-specific part of a profile, validated by the provider that owns
41054
+ * the kind (`upsertProfile` refuses what it does not accept). A field its
41055
+ * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
41056
+ * keychain, never in the row, and reads back as the redaction marker.
40768
41057
  */
40769
- var LlmProfileKindSchema = _enum([
40770
- "openai-compatible",
40771
- "openai",
40772
- "anthropic",
40773
- "google",
40774
- "managed-local",
40775
- "apple-foundation"
40776
- ]);
41058
+ var LlmProviderConfigSchema = record(string(), unknown());
40777
41059
  var LlmProfileSchema = object({
40778
41060
  id: string(),
40779
41061
  name: string(),
41062
+ /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
40780
41063
  kind: LlmProfileKindSchema,
40781
41064
  /** Stamped by the provider — keeps the fanned catalog routable. */
40782
41065
  addonId: string(),
40783
41066
  enabled: boolean(),
40784
41067
  /** Vendor model id, or the managed runtime's loaded model. */
40785
41068
  model: string(),
40786
- /** Required for openai-compatible; override for cloud kinds. */
40787
- baseUrl: string().optional(),
40788
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
40789
- apiKey: string().optional(),
40790
41069
  /** Vision on/off. A vision call against a `false` profile is REFUSED, never
40791
41070
  * degraded to text — that shipped once and produced a confident answer to a
40792
41071
  * question about a picture nobody sent. */
@@ -40794,15 +41073,11 @@ var LlmProfileSchema = object({
40794
41073
  temperature: number().min(0).max(2).optional(),
40795
41074
  /** Nucleus sampling. Every wire we speak has it. */
40796
41075
  topP: number().min(0).max(1).optional(),
40797
- /** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
40798
- * wire does, and the client drops it there (measured: the request body gets
40799
- * `top_p` and no `top_k`). The profile editor hides the field wherever it
40800
- * would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
41076
+ /** Top-k sampling. Carried only by the wires that have it — a kind offers the
41077
+ * field in its editor only when its descriptor lists it in `profileFields`. */
40801
41078
  topK: number().int().positive().optional(),
40802
41079
  maxTokens: number().int().positive().optional(),
40803
- /** Prompt context window. Advisory for cloud kinds (they enforce their own);
40804
- * for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
40805
- * the model with, so it is the one field that changes a PROCESS. */
41080
+ /** Prompt context window. Advisory for cloud kinds (they enforce their own). */
40806
41081
  contextLength: number().int().positive().optional(),
40807
41082
  /** Default system prompt. A caller's `system` REPLACES it (never appends —
40808
41083
  * two system prompts fighting is worse than either alone). */
@@ -40828,16 +41103,37 @@ var LlmProfileSchema = object({
40828
41103
  * library; the REGISTRY of callable tools is ours and is empty in v1, so a
40829
41104
  * `true` here buys the wiring, not behaviour, until tools are registered. */
40830
41105
  toolsEnabled: boolean().default(false),
40831
- extraHeaders: record(string(), string()).optional(),
40832
- /** kind === 'managed-local' only (spec §4). */
40833
- runtime: ManagedRuntimeConfigSchema.optional(),
40834
- /**
40835
- * kind === 'apple-foundation' only: WHERE it runs — the only thing there is
40836
- * to configure (no key, no URL, no download; `model` is `apple-system`).
40837
- * `supportsVision` on such a row is stamped by the provider from the node's
40838
- * reported `imageInput`, never taken from the operator (D62).
40839
- */
40840
- appleFoundation: object({ nodeId: string() }).optional()
41106
+ /** Everything the kind's provider owns (endpoint, key, node, runtime…). */
41107
+ providerConfig: LlmProviderConfigSchema.default({})
41108
+ });
41109
+ /**
41110
+ * The common profile fields a kind's editor offers. The editor owns how each
41111
+ * one is drawn; the provider says which of them mean something on its wire.
41112
+ */
41113
+ var LlmProfileFieldSchema = _enum([
41114
+ "temperature",
41115
+ "topP",
41116
+ "topK",
41117
+ "maxTokens",
41118
+ "contextLength",
41119
+ "systemPrompt",
41120
+ "timeoutMs",
41121
+ "connectTimeoutMs",
41122
+ "firstTokenTimeoutMs",
41123
+ "idleTimeoutMs",
41124
+ "retry",
41125
+ "toolsEnabled"
41126
+ ]);
41127
+ /**
41128
+ * A provider-drawn part of the editor, by a generic widget id the admin UI
41129
+ * registers (`ai/apple-node`). `placement: 'model'` replaces the generic model
41130
+ * picker: that widget owns the model choice.
41131
+ */
41132
+ var LlmProviderWidgetSchema = object({
41133
+ id: string(),
41134
+ placement: _enum(["connection", "model"]),
41135
+ /** `providerConfig` keys this widget must fill before the profile can be saved. */
41136
+ requires: array(string()).optional()
40841
41137
  });
40842
41138
  /** ConfigUISchema tree passed through untyped on the wire (the
40843
41139
  * notification-output `ConfigSchemaPassthrough` precedent at
@@ -40846,11 +41142,56 @@ var ConfigSchemaPassthrough$3 = unknown();
40846
41142
  var LlmProfileKindDescriptorSchema = object({
40847
41143
  kind: LlmProfileKindSchema,
40848
41144
  label: string(),
41145
+ /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
40849
41146
  icon: string(),
40850
41147
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
40851
41148
  addonId: string(),
40852
- configSchema: ConfigSchemaPassthrough$3
41149
+ /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
41150
+ connectionSchema: ConfigSchemaPassthrough$3,
41151
+ /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
41152
+ advancedSchema: ConfigSchemaPassthrough$3.optional(),
41153
+ /** The kind's defaults; a model from `listModels` may override any of them. */
41154
+ features: LlmModelFeaturesSchema,
41155
+ /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
41156
+ visionEditable: boolean(),
41157
+ /** Where the model list comes from: `listModels`, `staticModels`, or nowhere. */
41158
+ modelCatalog: _enum([
41159
+ "fetch",
41160
+ "static",
41161
+ "none"
41162
+ ]),
41163
+ staticModels: array(LlmModelInfoSchema).optional(),
41164
+ /** The common fields that mean something on this kind's wire. */
41165
+ profileFields: array(LlmProfileFieldSchema),
41166
+ providerWidgets: array(LlmProviderWidgetSchema).optional()
41167
+ });
41168
+ /**
41169
+ * `listModels` input. `connection` is an UNSAVED draft of `providerConfig`
41170
+ * (the editor's form); with `profileId` too, a secret the draft leaves
41171
+ * untouched (absent or the redaction marker) is resolved server-side from the
41172
+ * stored profile — the browser never receives it.
41173
+ */
41174
+ var LlmListModelsInputSchema = object({
41175
+ addonId: string(),
41176
+ kind: LlmProfileKindSchema,
41177
+ profileId: string().optional(),
41178
+ connection: LlmProviderConfigSchema.optional()
40853
41179
  });
41180
+ var LlmListModelsErrorCodeSchema = _enum([
41181
+ "auth",
41182
+ "network",
41183
+ "unsupported",
41184
+ "invalid"
41185
+ ]);
41186
+ /** A RESULT, never a throw: "wrong key" is an answer the editor renders inline. */
41187
+ var LlmListModelsResultSchema = discriminatedUnion("ok", [object({
41188
+ ok: literal(true),
41189
+ models: array(LlmModelInfoSchema)
41190
+ }), object({
41191
+ ok: literal(false),
41192
+ code: LlmListModelsErrorCodeSchema,
41193
+ message: string()
41194
+ })]);
40854
41195
  var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
40855
41196
  var LlmDefaultSchema = object({
40856
41197
  selector: LlmDefaultSelectorSchema,
@@ -40950,7 +41291,10 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
40950
41291
  kind: "mutation",
40951
41292
  auth: "admin",
40952
41293
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
40953
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
41294
+ }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
41295
+ kind: "mutation",
41296
+ auth: "admin"
41297
+ }), method(object({}), array(LlmDefaultSchema)), method(object({
40954
41298
  selector: LlmDefaultSelectorSchema,
40955
41299
  profileId: string().nullable()
40956
41300
  }), _void(), {
@@ -45056,202 +45400,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
45056
45400
  auth: "admin"
45057
45401
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
45058
45402
  /**
45059
- * Zod schemas for persisted record types.
45060
- *
45061
- * These schemas serve as the single source of truth for types that are
45062
- * stored in the settings-store backend and retrieved via tRPC. They
45063
- * replace the manual TypeScript interfaces with schema-derived types,
45064
- * enabling runtime validation when reading from the backend.
45065
- *
45066
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
45067
- * keeps the original name for backward compatibility.
45068
- */
45069
- /**
45070
- * Auth model (v2 — 2026-05-12 caps-only):
45071
- *
45072
- * Two principals:
45073
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
45074
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
45075
- *
45076
- * No role enum. There used to be `viewer / agent / scoped` and earlier
45077
- * `super_admin` — collapsed onto the single boolean because every
45078
- * non-admin caller is governed by the same scope-check rules; the
45079
- * distinction was only ever used to route role-specific procedures
45080
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
45081
- * with `isAdmin: false` + an explicit scope list.
45082
- */
45083
- /** Per-method access flavour. Materialised on every cap method via codegen. */
45084
- var MethodAccessSchema = _enum([
45085
- "view",
45086
- "create",
45087
- "delete"
45088
- ]);
45089
- /**
45090
- * A single scope grant. Three forms — checked in matcher with OR
45091
- * semantics; the first match decides whether the call passes:
45092
- *
45093
- * - `category` — broadest. `target: 'device' | 'system'` selects every
45094
- * cap with the matching `scope` declaration. New caps inherit grants
45095
- * automatically — adding a device cap to the codebase makes it
45096
- * reachable to every user with `category:device [...]` without a
45097
- * re-grant. Use this for "family viewer" / "operator" tiers.
45098
- *
45099
- * - `addon` — every cap that ships inside a given addon id. Niche;
45100
- * useful when an integration needs to interact with one specific
45101
- * addon's surface regardless of how many caps it exports.
45102
- *
45103
- * - `capability` — the most precise form. Single cap name. Use for
45104
- * integration tokens where you want to grant `addons.installPackage`
45105
- * and nothing else.
45106
- *
45107
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
45108
- * "give me everything" escape; there is no wildcard scope.
45109
- */
45110
- var AllowedProviderSchema = union([literal("*"), array(string())]);
45111
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
45112
- var CapScopeSchema = _enum(["device", "system"]);
45113
- /**
45114
- * DeviceSelector (scope model v3 — 2026-08-12).
45115
- *
45116
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
45117
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
45118
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
45119
- * AFTER the grant was minted — no re-grant, no re-login.
45120
- *
45121
- * - `all` — every device in the deployment. The broad viewer/operator
45122
- * lever without a `category` grant (a `category` grant also covers device
45123
- * caps that carry no deviceId; `all` is specifically the device set).
45124
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
45125
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
45126
- * is NOT covered until the grant is edited.
45127
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
45128
- * DYNAMIC. A device that changes type, or a new device of the type,
45129
- * re-resolves on the next request.
45130
- * - `locations` — every device whose operator-assigned `location` label is
45131
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
45132
- * null/unset location matches NO `locations` selector.
45133
- */
45134
- var DeviceSelectorSchema = discriminatedUnion("kind", [
45135
- object({ kind: literal("all") }),
45136
- object({
45137
- kind: literal("ids"),
45138
- ids: array(number().int()).min(1)
45139
- }),
45140
- object({
45141
- kind: literal("types"),
45142
- types: array(_enum(DeviceType)).min(1)
45143
- }),
45144
- object({
45145
- kind: literal("locations"),
45146
- locations: array(string().min(1)).min(1)
45147
- })
45148
- ]);
45149
- var DeviceTokenScopeSchema = object({
45150
- type: literal("device"),
45151
- /** The device SET this grant covers — resolved against the live fleet. */
45152
- selector: DeviceSelectorSchema,
45153
- access: array(MethodAccessSchema).min(1),
45154
- /**
45155
- * Whether a grant on a PARENT device transparently covers its accessory
45156
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
45157
- * Direction is parent → children ONLY.
45158
- *
45159
- * Absent → the matcher DERIVES it from the access flavour: `view`
45160
- * inherits (a camera viewer sees the camera's accessories), `create` /
45161
- * `delete` do NOT (actuating/removing a child is an explicit act the
45162
- * operator must grant on the child, not inherit from the parent). Set it
45163
- * explicitly to override that default per grant.
45164
- */
45165
- includeLinked: boolean().optional()
45166
- });
45167
- /**
45168
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
45169
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
45170
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
45171
- * EVERY parse path — stored records AND the JWT-carried scope arrays
45172
- * normalised at the request boundary ({@link normalizeTokenScopes} in
45173
- * `device-selector.ts`). Chosen over a one-time DB migration because a
45174
- * migration cannot reach a JWT already in a client's hands; parse-time
45175
- * migration covers both without a flag day. No cast — the raw object is read
45176
- * through `Reflect.get` (its static type is `unknown`).
45177
- */
45178
- function migrateLegacyTokenScope(raw) {
45179
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
45180
- if (Reflect.get(raw, "type") !== "device") return raw;
45181
- if (Reflect.get(raw, "selector") !== void 0) return raw;
45182
- const targets = Reflect.get(raw, "targets");
45183
- if (!Array.isArray(targets)) return raw;
45184
- return {
45185
- type: "device",
45186
- selector: {
45187
- kind: "ids",
45188
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
45189
- },
45190
- access: Reflect.get(raw, "access")
45191
- };
45192
- }
45193
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
45194
- object({
45195
- type: literal("category"),
45196
- target: CapScopeSchema,
45197
- access: array(MethodAccessSchema).min(1)
45198
- }),
45199
- object({
45200
- type: literal("capability"),
45201
- target: string(),
45202
- access: array(MethodAccessSchema).min(1)
45203
- }),
45204
- object({
45205
- type: literal("addon"),
45206
- target: string(),
45207
- access: array(MethodAccessSchema).min(1)
45208
- }),
45209
- DeviceTokenScopeSchema
45210
- ]));
45211
- object({
45212
- id: string(),
45213
- username: string(),
45214
- passwordHash: string(),
45215
- /**
45216
- * Admin bypass. When true, the middleware skips the scope-access
45217
- * check entirely. There is no other axis of privilege; the legacy
45218
- * role enum collapsed onto this boolean in v2.
45219
- */
45220
- isAdmin: boolean().default(false),
45221
- allowedProviders: AllowedProviderSchema,
45222
- allowedDevices: AllowedDevicesSchema,
45223
- /**
45224
- * Scopes granted to this user. Admins bypass; their `scopes` is
45225
- * ignored. Non-admins without scopes are locked out of every
45226
- * protected call.
45227
- */
45228
- scopes: array(TokenScopeSchema).default([]),
45229
- createdAt: number(),
45230
- updatedAt: number()
45231
- });
45232
- object({
45233
- id: string(),
45234
- label: string(),
45235
- isAdmin: boolean().default(false),
45236
- allowedProviders: AllowedProviderSchema,
45237
- allowedDevices: AllowedDevicesSchema,
45238
- tokenHash: string(),
45239
- tokenPrefix: string(),
45240
- createdAt: number(),
45241
- lastUsedAt: number().optional()
45242
- });
45243
- object({
45244
- id: string(),
45245
- userId: string(),
45246
- name: string(),
45247
- tokenHash: string(),
45248
- tokenPrefix: string(),
45249
- scopes: array(TokenScopeSchema),
45250
- expiresAt: number().nullish(),
45251
- lastUsedAt: number().nullish(),
45252
- createdAt: number()
45253
- });
45254
- /**
45255
45403
  * `oauth-integration` — a collection cap by which an addon declares
45256
45404
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
45257
45405
  * Each provider returns a static descriptor; the core enumerates them
@@ -65042,26 +65190,6 @@ var ApiKeySummarySchema = object({
65042
65190
  createdAt: number(),
65043
65191
  lastUsedAt: number().optional()
65044
65192
  });
65045
- var ScopedTokenSummarySchema = object({
65046
- id: string(),
65047
- userId: string(),
65048
- name: string(),
65049
- tokenPrefix: string(),
65050
- scopes: array(TokenScopeSchema),
65051
- expiresAt: number().nullish(),
65052
- lastUsedAt: number().nullish(),
65053
- createdAt: number()
65054
- });
65055
- var CreateScopedTokenInputSchema = object({
65056
- userId: string(),
65057
- name: string(),
65058
- scopes: array(TokenScopeSchema),
65059
- expiresAt: number().optional()
65060
- });
65061
- var CreateScopedTokenResultSchema = object({
65062
- token: string(),
65063
- record: ScopedTokenSummarySchema
65064
- });
65065
65193
  var OauthSessionSummarySchema = object({
65066
65194
  id: string(),
65067
65195
  userId: string(),
@@ -65083,11 +65211,11 @@ var TotpStatusSchema = object({
65083
65211
  confirmedAt: number().nullable()
65084
65212
  });
65085
65213
  /**
65086
- * user-management — singleton capability for user accounts, API keys,
65087
- * and scoped tokens.
65214
+ * user-management — singleton capability for user accounts and the
65215
+ * legacy API-key rows.
65088
65216
  *
65089
65217
  * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
65090
- * — the subset check on `setUserScopes` / `createScopedToken` is moot
65218
+ * — the subset check on `setUserScopes` is moot
65091
65219
  * because non-admins never reach these. If/when we open non-admin
65092
65220
  * delegation, structural caller-scope subset check goes inside the
65093
65221
  * provider.
@@ -65144,15 +65272,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
65144
65272
  kind: "mutation",
65145
65273
  auth: "admin",
65146
65274
  access: "delete"
65147
- }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
65148
- kind: "mutation",
65149
- auth: "admin",
65150
- access: "create"
65151
- }), method(object({ id: string() }), object({ success: literal(true) }), {
65152
- kind: "mutation",
65153
- auth: "admin",
65154
- access: "delete"
65155
- }), method(object({ token: string() }), ScopedTokenSummarySchema.nullable(), { access: "view" }), method(object({ userId: string() }), array(ScopedTokenSummarySchema), { auth: "admin" }), method(object({ userId: string() }), TotpSetupResultSchema, {
65275
+ }), method(object({ userId: string() }), TotpSetupResultSchema, {
65156
65276
  kind: "mutation",
65157
65277
  auth: "admin",
65158
65278
  access: "create"
@@ -71242,7 +71362,7 @@ Object.freeze({
71242
71362
  capName: "llm",
71243
71363
  capScope: "system",
71244
71364
  addonId: null,
71245
- access: "view"
71365
+ access: "create"
71246
71366
  },
71247
71367
  "llm.listNodeModels": {
71248
71368
  capName: "llm",
@@ -75906,12 +76026,6 @@ Object.freeze({
75906
76026
  addonId: null,
75907
76027
  access: "create"
75908
76028
  },
75909
- "userManagement.createScopedToken": {
75910
- capName: "user-management",
75911
- capScope: "system",
75912
- addonId: null,
75913
- access: "create"
75914
- },
75915
76029
  "userManagement.createUser": {
75916
76030
  capName: "user-management",
75917
76031
  capScope: "system",
@@ -75960,12 +76074,6 @@ Object.freeze({
75960
76074
  addonId: null,
75961
76075
  access: "view"
75962
76076
  },
75963
- "userManagement.listScopedTokens": {
75964
- capName: "user-management",
75965
- capScope: "system",
75966
- addonId: null,
75967
- access: "view"
75968
- },
75969
76077
  "userManagement.listUsers": {
75970
76078
  capName: "user-management",
75971
76079
  capScope: "system",
@@ -76020,12 +76128,6 @@ Object.freeze({
76020
76128
  addonId: null,
76021
76129
  access: "delete"
76022
76130
  },
76023
- "userManagement.revokeScopedToken": {
76024
- capName: "user-management",
76025
- capScope: "system",
76026
- addonId: null,
76027
- access: "delete"
76028
- },
76029
76131
  "userManagement.setupTotp": {
76030
76132
  capName: "user-management",
76031
76133
  capScope: "system",
@@ -76056,12 +76158,6 @@ Object.freeze({
76056
76158
  addonId: null,
76057
76159
  access: "view"
76058
76160
  },
76059
- "userManagement.validateScopedToken": {
76060
- capName: "user-management",
76061
- capScope: "system",
76062
- addonId: null,
76063
- access: "view"
76064
- },
76065
76161
  "userManagement.verifyTotp": {
76066
76162
  capName: "user-management",
76067
76163
  capScope: "system",