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