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