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