@camstack/addon-provider-wyze 0.2.141 → 0.2.143

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
@@ -5425,7 +5425,7 @@ var ZodIssueCode = {
5425
5425
  var ZodFirstPartyTypeKind;
5426
5426
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5427
5427
  //#endregion
5428
- //#region ../types/dist/sleep-BxjU_fJM.mjs
5428
+ //#region ../types/dist/sleep-yKL5gfrH.mjs
5429
5429
  /**
5430
5430
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5431
5431
  * window to float samples (D455).
@@ -7807,6 +7807,12 @@ function normalizeAddonInitResult(result) {
7807
7807
  if (Array.isArray(result)) return { providers: result };
7808
7808
  return result;
7809
7809
  }
7810
+ /**
7811
+ * The share-view scope kinds a share-link token can carry. The hub mints
7812
+ * and validates them (`ShareViewGrantSchema` builds its
7813
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
7814
+ */
7815
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7810
7816
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7811
7817
  var PeerBytesTicketSchema = object({
7812
7818
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12506,6 +12512,280 @@ var ConvertResultSchema = object({
12506
12512
  files: array(string()).readonly()
12507
12513
  })).readonly()
12508
12514
  });
12515
+ /**
12516
+ * Zod schemas for persisted record types.
12517
+ *
12518
+ * These schemas serve as the single source of truth for types that are
12519
+ * stored in the settings-store backend and retrieved via tRPC. They
12520
+ * replace the manual TypeScript interfaces with schema-derived types,
12521
+ * enabling runtime validation when reading from the backend.
12522
+ *
12523
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12524
+ * keeps the original name for backward compatibility.
12525
+ */
12526
+ /**
12527
+ * Auth model (v2 — 2026-05-12 caps-only):
12528
+ *
12529
+ * Two principals:
12530
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12531
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12532
+ *
12533
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12534
+ * `super_admin` — collapsed onto the single boolean because every
12535
+ * non-admin caller is governed by the same scope-check rules; the
12536
+ * distinction was only ever used to route role-specific procedures
12537
+ * which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
12538
+ * with `isAdmin: false` + an explicit scope list.
12539
+ */
12540
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12541
+ var MethodAccessSchema = _enum([
12542
+ "view",
12543
+ "create",
12544
+ "delete"
12545
+ ]);
12546
+ /**
12547
+ * A single scope grant. Three forms — checked in matcher with OR
12548
+ * semantics; the first match decides whether the call passes:
12549
+ *
12550
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12551
+ * cap with the matching `scope` declaration. New caps inherit grants
12552
+ * automatically — adding a device cap to the codebase makes it
12553
+ * reachable to every user with `category:device [...]` without a
12554
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12555
+ *
12556
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12557
+ * useful when an integration needs to interact with one specific
12558
+ * addon's surface regardless of how many caps it exports.
12559
+ *
12560
+ * - `capability` — the most precise form. Single cap name. Use for
12561
+ * integration tokens where you want to grant `addons.installPackage`
12562
+ * and nothing else.
12563
+ *
12564
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12565
+ * "give me everything" escape; there is no wildcard scope.
12566
+ */
12567
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12568
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12569
+ var CapScopeSchema = _enum(["device", "system"]);
12570
+ /**
12571
+ * DeviceSelector (scope model v3 — 2026-08-12).
12572
+ *
12573
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12574
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12575
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12576
+ * AFTER the grant was minted — no re-grant, no re-login.
12577
+ *
12578
+ * - `all` — every device in the deployment. The broad viewer/operator
12579
+ * lever without a `category` grant (a `category` grant also covers device
12580
+ * caps that carry no deviceId; `all` is specifically the device set).
12581
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
12582
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
12583
+ * is NOT covered until the grant is edited.
12584
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
12585
+ * DYNAMIC. A device that changes type, or a new device of the type,
12586
+ * re-resolves on the next request.
12587
+ * - `locations` — every device whose operator-assigned `location` label is
12588
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
12589
+ * null/unset location matches NO `locations` selector.
12590
+ */
12591
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
12592
+ object({ kind: literal("all") }),
12593
+ object({
12594
+ kind: literal("ids"),
12595
+ ids: array(number().int()).min(1)
12596
+ }),
12597
+ object({
12598
+ kind: literal("types"),
12599
+ types: array(_enum(DeviceType)).min(1)
12600
+ }),
12601
+ object({
12602
+ kind: literal("locations"),
12603
+ locations: array(string().min(1)).min(1)
12604
+ })
12605
+ ]);
12606
+ var DeviceTokenScopeSchema = object({
12607
+ type: literal("device"),
12608
+ /** The device SET this grant covers — resolved against the live fleet. */
12609
+ selector: DeviceSelectorSchema,
12610
+ access: array(MethodAccessSchema).min(1),
12611
+ /**
12612
+ * Whether a grant on a PARENT device transparently covers its accessory
12613
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
12614
+ * Direction is parent → children ONLY.
12615
+ *
12616
+ * Absent → the matcher DERIVES it from the access flavour: `view`
12617
+ * inherits (a camera viewer sees the camera's accessories), `create` /
12618
+ * `delete` do NOT (actuating/removing a child is an explicit act the
12619
+ * operator must grant on the child, not inherit from the parent). Set it
12620
+ * explicitly to override that default per grant.
12621
+ */
12622
+ includeLinked: boolean().optional()
12623
+ });
12624
+ /**
12625
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
12626
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
12627
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
12628
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
12629
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
12630
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
12631
+ * migration cannot reach a JWT already in a client's hands; parse-time
12632
+ * migration covers both without a flag day. No cast — the raw object is read
12633
+ * through `Reflect.get` (its static type is `unknown`).
12634
+ */
12635
+ function migrateLegacyTokenScope(raw) {
12636
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
12637
+ if (Reflect.get(raw, "type") !== "device") return raw;
12638
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
12639
+ const targets = Reflect.get(raw, "targets");
12640
+ if (!Array.isArray(targets)) return raw;
12641
+ return {
12642
+ type: "device",
12643
+ selector: {
12644
+ kind: "ids",
12645
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
12646
+ },
12647
+ access: Reflect.get(raw, "access")
12648
+ };
12649
+ }
12650
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
12651
+ object({
12652
+ type: literal("category"),
12653
+ target: CapScopeSchema,
12654
+ access: array(MethodAccessSchema).min(1)
12655
+ }),
12656
+ object({
12657
+ type: literal("capability"),
12658
+ target: string(),
12659
+ access: array(MethodAccessSchema).min(1)
12660
+ }),
12661
+ object({
12662
+ type: literal("addon"),
12663
+ target: string(),
12664
+ access: array(MethodAccessSchema).min(1)
12665
+ }),
12666
+ DeviceTokenScopeSchema
12667
+ ]));
12668
+ object({
12669
+ id: string(),
12670
+ username: string(),
12671
+ passwordHash: string(),
12672
+ /**
12673
+ * Admin bypass. When true, the middleware skips the scope-access
12674
+ * check entirely. There is no other axis of privilege; the legacy
12675
+ * role enum collapsed onto this boolean in v2.
12676
+ */
12677
+ isAdmin: boolean().default(false),
12678
+ allowedProviders: AllowedProviderSchema,
12679
+ allowedDevices: AllowedDevicesSchema,
12680
+ /**
12681
+ * Scopes granted to this user. Admins bypass; their `scopes` is
12682
+ * ignored. Non-admins without scopes are locked out of every
12683
+ * protected call.
12684
+ */
12685
+ scopes: array(TokenScopeSchema).default([]),
12686
+ createdAt: number(),
12687
+ updatedAt: number()
12688
+ });
12689
+ object({
12690
+ id: string(),
12691
+ label: string(),
12692
+ isAdmin: boolean().default(false),
12693
+ allowedProviders: AllowedProviderSchema,
12694
+ allowedDevices: AllowedDevicesSchema,
12695
+ tokenHash: string(),
12696
+ tokenPrefix: string(),
12697
+ createdAt: number(),
12698
+ lastUsedAt: number().optional()
12699
+ });
12700
+ object({
12701
+ id: string(),
12702
+ userId: string(),
12703
+ name: string(),
12704
+ tokenHash: string(),
12705
+ tokenPrefix: string(),
12706
+ scopes: array(TokenScopeSchema),
12707
+ expiresAt: number().nullish(),
12708
+ lastUsedAt: number().nullish(),
12709
+ createdAt: number()
12710
+ });
12711
+ /** What a share-view grant lets its holder see. */
12712
+ var ShareViewGrantSchema = object({
12713
+ kind: _enum(SHARE_VIEW_KINDS),
12714
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
12715
+ /** Talk-back, opt-in at mint time; absent means off. */
12716
+ talk: boolean().optional()
12717
+ });
12718
+ var ShareViewScopeSchema = object({
12719
+ type: literal("share-view"),
12720
+ grant: ShareViewGrantSchema
12721
+ });
12722
+ var AddonRoutesScopeSchema = object({
12723
+ type: literal("addon-routes"),
12724
+ access: array(MethodAccessSchema).min(1)
12725
+ });
12726
+ var PreferencesSelfScopeSchema = object({ type: literal("preferences-self") });
12727
+ var CredentialScopeSchema = union([
12728
+ literal("*"),
12729
+ ShareViewScopeSchema,
12730
+ AddonRoutesScopeSchema,
12731
+ PreferencesSelfScopeSchema,
12732
+ TokenScopeSchema
12733
+ ]);
12734
+ object({
12735
+ kind: literal("credential"),
12736
+ sub: string().min(1),
12737
+ jti: string().min(16),
12738
+ scopes: array(CredentialScopeSchema).min(1)
12739
+ });
12740
+ var PreferenceNamespaceSchema = string().regex(/^[a-z][a-z0-9.-]{0,63}$/);
12741
+ /** A namespace's value: a JSON object, opaque to the hub. */
12742
+ var PreferenceValueSchema = record(string(), unknown());
12743
+ var PreferenceDeviceIdSchema = string().min(1).max(64);
12744
+ /** A stored row, as the owner reads it. */
12745
+ var PreferenceRowSchema = object({
12746
+ namespace: PreferenceNamespaceSchema,
12747
+ value: PreferenceValueSchema,
12748
+ /** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
12749
+ revision: number().int().positive(),
12750
+ updatedAt: number().int(),
12751
+ /** The client id the last writer sent; `null` when it sent none. */
12752
+ updatedByDevice: PreferenceDeviceIdSchema.nullable()
12753
+ });
12754
+ object({
12755
+ /** Absent: every namespace the caller holds. */
12756
+ namespaces: array(PreferenceNamespaceSchema).max(32).optional() });
12757
+ object({ rows: array(PreferenceRowSchema) });
12758
+ object({
12759
+ namespace: PreferenceNamespaceSchema,
12760
+ value: PreferenceValueSchema,
12761
+ /**
12762
+ * The revision the edit was based on. Absent: last write wins. `0`: the
12763
+ * namespace must not exist yet. Any other value that is not the current
12764
+ * revision answers `conflict` and writes nothing.
12765
+ */
12766
+ baseRevision: number().int().nonnegative().optional(),
12767
+ deviceId: PreferenceDeviceIdSchema.optional()
12768
+ });
12769
+ discriminatedUnion("status", [object({
12770
+ status: literal("saved"),
12771
+ row: PreferenceRowSchema
12772
+ }), object({
12773
+ status: literal("conflict"),
12774
+ current: PreferenceRowSchema.nullable()
12775
+ })]);
12776
+ object({ namespace: PreferenceNamespaceSchema });
12777
+ object({
12778
+ /** `false` when the namespace did not exist. */
12779
+ deleted: boolean() });
12780
+ object({
12781
+ /** The revision the client holds per namespace; a namespace it does not list is new to it. */
12782
+ revisionByNamespace: record(PreferenceNamespaceSchema, number().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
12783
+ object({
12784
+ /** Every row whose revision differs from the client's, and every row it did not list. */
12785
+ rows: array(PreferenceRowSchema),
12786
+ /** Namespaces the client listed that no longer exist. */
12787
+ deleted: array(PreferenceNamespaceSchema)
12788
+ });
12509
12789
  _enum(["new-session", "step-up"]);
12510
12790
  /** The languages the hub's app landing pages are written in (D858). */
12511
12791
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -39699,38 +39979,37 @@ method(LlmRuntimeCompleteInputSchema, LlmGenerateResultSchema, {
39699
39979
  auth: "admin",
39700
39980
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39701
39981
  });
39982
+ var LlmProfileKindSchema = string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "a kind id is lower-case letters, digits and dashes");
39983
+ /** What a model (or, by default, every model of a kind) can do. */
39984
+ var LlmModelFeaturesSchema = object({
39985
+ vision: boolean(),
39986
+ tools: boolean(),
39987
+ streaming: boolean()
39988
+ });
39989
+ /** One model a provider offers. `features` overrides the kind's defaults, per field. */
39990
+ var LlmModelInfoSchema = object({
39991
+ id: string(),
39992
+ label: string().optional(),
39993
+ contextLength: number().int().positive().optional(),
39994
+ features: LlmModelFeaturesSchema.partial().optional()
39995
+ });
39702
39996
  /**
39703
- * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
39704
- * methods concat-fan across providers; single-row methods route to ONE
39705
- * provider by the `addonId` in the call input (the notification-output
39706
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
39707
- * (hub-placed); the cap stays open for future providers.
39708
- *
39709
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
39710
- * `apiKey` is a password field — providers REDACT it on read and merge on
39711
- * write; a stored key NEVER round-trips to a client.
39997
+ * The provider-specific part of a profile, validated by the provider that owns
39998
+ * the kind (`upsertProfile` refuses what it does not accept). A field its
39999
+ * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
40000
+ * keychain, never in the row, and reads back as the redaction marker.
39712
40001
  */
39713
- var LlmProfileKindSchema = _enum([
39714
- "openai-compatible",
39715
- "openai",
39716
- "anthropic",
39717
- "google",
39718
- "managed-local",
39719
- "apple-foundation"
39720
- ]);
40002
+ var LlmProviderConfigSchema = record(string(), unknown());
39721
40003
  var LlmProfileSchema = object({
39722
40004
  id: string(),
39723
40005
  name: string(),
40006
+ /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
39724
40007
  kind: LlmProfileKindSchema,
39725
40008
  /** Stamped by the provider — keeps the fanned catalog routable. */
39726
40009
  addonId: string(),
39727
40010
  enabled: boolean(),
39728
40011
  /** Vendor model id, or the managed runtime's loaded model. */
39729
40012
  model: string(),
39730
- /** Required for openai-compatible; override for cloud kinds. */
39731
- baseUrl: string().optional(),
39732
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
39733
- apiKey: string().optional(),
39734
40013
  /** Vision on/off. A vision call against a `false` profile is REFUSED, never
39735
40014
  * degraded to text — that shipped once and produced a confident answer to a
39736
40015
  * question about a picture nobody sent. */
@@ -39738,15 +40017,11 @@ var LlmProfileSchema = object({
39738
40017
  temperature: number().min(0).max(2).optional(),
39739
40018
  /** Nucleus sampling. Every wire we speak has it. */
39740
40019
  topP: number().min(0).max(1).optional(),
39741
- /** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
39742
- * wire does, and the client drops it there (measured: the request body gets
39743
- * `top_p` and no `top_k`). The profile editor hides the field wherever it
39744
- * would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
40020
+ /** Top-k sampling. Carried only by the wires that have it — a kind offers the
40021
+ * field in its editor only when its descriptor lists it in `profileFields`. */
39745
40022
  topK: number().int().positive().optional(),
39746
40023
  maxTokens: number().int().positive().optional(),
39747
- /** Prompt context window. Advisory for cloud kinds (they enforce their own);
39748
- * for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
39749
- * the model with, so it is the one field that changes a PROCESS. */
40024
+ /** Prompt context window. Advisory for cloud kinds (they enforce their own). */
39750
40025
  contextLength: number().int().positive().optional(),
39751
40026
  /** Default system prompt. A caller's `system` REPLACES it (never appends —
39752
40027
  * two system prompts fighting is worse than either alone). */
@@ -39772,16 +40047,37 @@ var LlmProfileSchema = object({
39772
40047
  * library; the REGISTRY of callable tools is ours and is empty in v1, so a
39773
40048
  * `true` here buys the wiring, not behaviour, until tools are registered. */
39774
40049
  toolsEnabled: boolean().default(false),
39775
- extraHeaders: record(string(), string()).optional(),
39776
- /** kind === 'managed-local' only (spec §4). */
39777
- runtime: ManagedRuntimeConfigSchema.optional(),
39778
- /**
39779
- * kind === 'apple-foundation' only: WHERE it runs — the only thing there is
39780
- * to configure (no key, no URL, no download; `model` is `apple-system`).
39781
- * `supportsVision` on such a row is stamped by the provider from the node's
39782
- * reported `imageInput`, never taken from the operator (D62).
39783
- */
39784
- appleFoundation: object({ nodeId: string() }).optional()
40050
+ /** Everything the kind's provider owns (endpoint, key, node, runtime…). */
40051
+ providerConfig: LlmProviderConfigSchema.default({})
40052
+ });
40053
+ /**
40054
+ * The common profile fields a kind's editor offers. The editor owns how each
40055
+ * one is drawn; the provider says which of them mean something on its wire.
40056
+ */
40057
+ var LlmProfileFieldSchema = _enum([
40058
+ "temperature",
40059
+ "topP",
40060
+ "topK",
40061
+ "maxTokens",
40062
+ "contextLength",
40063
+ "systemPrompt",
40064
+ "timeoutMs",
40065
+ "connectTimeoutMs",
40066
+ "firstTokenTimeoutMs",
40067
+ "idleTimeoutMs",
40068
+ "retry",
40069
+ "toolsEnabled"
40070
+ ]);
40071
+ /**
40072
+ * A provider-drawn part of the editor, by a generic widget id the admin UI
40073
+ * registers (`ai/apple-node`). `placement: 'model'` replaces the generic model
40074
+ * picker: that widget owns the model choice.
40075
+ */
40076
+ var LlmProviderWidgetSchema = object({
40077
+ id: string(),
40078
+ placement: _enum(["connection", "model"]),
40079
+ /** `providerConfig` keys this widget must fill before the profile can be saved. */
40080
+ requires: array(string()).optional()
39785
40081
  });
39786
40082
  /** ConfigUISchema tree passed through untyped on the wire (the
39787
40083
  * notification-output `ConfigSchemaPassthrough` precedent at
@@ -39790,11 +40086,56 @@ var ConfigSchemaPassthrough$3 = unknown();
39790
40086
  var LlmProfileKindDescriptorSchema = object({
39791
40087
  kind: LlmProfileKindSchema,
39792
40088
  label: string(),
40089
+ /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
39793
40090
  icon: string(),
39794
40091
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
39795
40092
  addonId: string(),
39796
- configSchema: ConfigSchemaPassthrough$3
40093
+ /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
40094
+ connectionSchema: ConfigSchemaPassthrough$3,
40095
+ /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
40096
+ advancedSchema: ConfigSchemaPassthrough$3.optional(),
40097
+ /** The kind's defaults; a model from `listModels` may override any of them. */
40098
+ features: LlmModelFeaturesSchema,
40099
+ /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
40100
+ visionEditable: boolean(),
40101
+ /** Where the model list comes from: `listModels`, `staticModels`, or nowhere. */
40102
+ modelCatalog: _enum([
40103
+ "fetch",
40104
+ "static",
40105
+ "none"
40106
+ ]),
40107
+ staticModels: array(LlmModelInfoSchema).optional(),
40108
+ /** The common fields that mean something on this kind's wire. */
40109
+ profileFields: array(LlmProfileFieldSchema),
40110
+ providerWidgets: array(LlmProviderWidgetSchema).optional()
40111
+ });
40112
+ /**
40113
+ * `listModels` input. `connection` is an UNSAVED draft of `providerConfig`
40114
+ * (the editor's form); with `profileId` too, a secret the draft leaves
40115
+ * untouched (absent or the redaction marker) is resolved server-side from the
40116
+ * stored profile — the browser never receives it.
40117
+ */
40118
+ var LlmListModelsInputSchema = object({
40119
+ addonId: string(),
40120
+ kind: LlmProfileKindSchema,
40121
+ profileId: string().optional(),
40122
+ connection: LlmProviderConfigSchema.optional()
39797
40123
  });
40124
+ var LlmListModelsErrorCodeSchema = _enum([
40125
+ "auth",
40126
+ "network",
40127
+ "unsupported",
40128
+ "invalid"
40129
+ ]);
40130
+ /** A RESULT, never a throw: "wrong key" is an answer the editor renders inline. */
40131
+ var LlmListModelsResultSchema = discriminatedUnion("ok", [object({
40132
+ ok: literal(true),
40133
+ models: array(LlmModelInfoSchema)
40134
+ }), object({
40135
+ ok: literal(false),
40136
+ code: LlmListModelsErrorCodeSchema,
40137
+ message: string()
40138
+ })]);
39798
40139
  var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
39799
40140
  var LlmDefaultSchema = object({
39800
40141
  selector: LlmDefaultSelectorSchema,
@@ -39894,7 +40235,10 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
39894
40235
  kind: "mutation",
39895
40236
  auth: "admin",
39896
40237
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39897
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
40238
+ }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
40239
+ kind: "mutation",
40240
+ auth: "admin"
40241
+ }), method(object({}), array(LlmDefaultSchema)), method(object({
39898
40242
  selector: LlmDefaultSelectorSchema,
39899
40243
  profileId: string().nullable()
39900
40244
  }), _void(), {
@@ -44000,202 +44344,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
44000
44344
  auth: "admin"
44001
44345
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
44002
44346
  /**
44003
- * Zod schemas for persisted record types.
44004
- *
44005
- * These schemas serve as the single source of truth for types that are
44006
- * stored in the settings-store backend and retrieved via tRPC. They
44007
- * replace the manual TypeScript interfaces with schema-derived types,
44008
- * enabling runtime validation when reading from the backend.
44009
- *
44010
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
44011
- * keeps the original name for backward compatibility.
44012
- */
44013
- /**
44014
- * Auth model (v2 — 2026-05-12 caps-only):
44015
- *
44016
- * Two principals:
44017
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
44018
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
44019
- *
44020
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44021
- * `super_admin` — collapsed onto the single boolean because every
44022
- * non-admin caller is governed by the same scope-check rules; the
44023
- * distinction was only ever used to route role-specific procedures
44024
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44025
- * with `isAdmin: false` + an explicit scope list.
44026
- */
44027
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44028
- var MethodAccessSchema = _enum([
44029
- "view",
44030
- "create",
44031
- "delete"
44032
- ]);
44033
- /**
44034
- * A single scope grant. Three forms — checked in matcher with OR
44035
- * semantics; the first match decides whether the call passes:
44036
- *
44037
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44038
- * cap with the matching `scope` declaration. New caps inherit grants
44039
- * automatically — adding a device cap to the codebase makes it
44040
- * reachable to every user with `category:device [...]` without a
44041
- * re-grant. Use this for "family viewer" / "operator" tiers.
44042
- *
44043
- * - `addon` — every cap that ships inside a given addon id. Niche;
44044
- * useful when an integration needs to interact with one specific
44045
- * addon's surface regardless of how many caps it exports.
44046
- *
44047
- * - `capability` — the most precise form. Single cap name. Use for
44048
- * integration tokens where you want to grant `addons.installPackage`
44049
- * and nothing else.
44050
- *
44051
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44052
- * "give me everything" escape; there is no wildcard scope.
44053
- */
44054
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44055
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44056
- var CapScopeSchema = _enum(["device", "system"]);
44057
- /**
44058
- * DeviceSelector (scope model v3 — 2026-08-12).
44059
- *
44060
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44061
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44062
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44063
- * AFTER the grant was minted — no re-grant, no re-login.
44064
- *
44065
- * - `all` — every device in the deployment. The broad viewer/operator
44066
- * lever without a `category` grant (a `category` grant also covers device
44067
- * caps that carry no deviceId; `all` is specifically the device set).
44068
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44069
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44070
- * is NOT covered until the grant is edited.
44071
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44072
- * DYNAMIC. A device that changes type, or a new device of the type,
44073
- * re-resolves on the next request.
44074
- * - `locations` — every device whose operator-assigned `location` label is
44075
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44076
- * null/unset location matches NO `locations` selector.
44077
- */
44078
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44079
- object({ kind: literal("all") }),
44080
- object({
44081
- kind: literal("ids"),
44082
- ids: array(number().int()).min(1)
44083
- }),
44084
- object({
44085
- kind: literal("types"),
44086
- types: array(_enum(DeviceType)).min(1)
44087
- }),
44088
- object({
44089
- kind: literal("locations"),
44090
- locations: array(string().min(1)).min(1)
44091
- })
44092
- ]);
44093
- var DeviceTokenScopeSchema = object({
44094
- type: literal("device"),
44095
- /** The device SET this grant covers — resolved against the live fleet. */
44096
- selector: DeviceSelectorSchema,
44097
- access: array(MethodAccessSchema).min(1),
44098
- /**
44099
- * Whether a grant on a PARENT device transparently covers its accessory
44100
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44101
- * Direction is parent → children ONLY.
44102
- *
44103
- * Absent → the matcher DERIVES it from the access flavour: `view`
44104
- * inherits (a camera viewer sees the camera's accessories), `create` /
44105
- * `delete` do NOT (actuating/removing a child is an explicit act the
44106
- * operator must grant on the child, not inherit from the parent). Set it
44107
- * explicitly to override that default per grant.
44108
- */
44109
- includeLinked: boolean().optional()
44110
- });
44111
- /**
44112
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44113
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44114
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44115
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44116
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44117
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44118
- * migration cannot reach a JWT already in a client's hands; parse-time
44119
- * migration covers both without a flag day. No cast — the raw object is read
44120
- * through `Reflect.get` (its static type is `unknown`).
44121
- */
44122
- function migrateLegacyTokenScope(raw) {
44123
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44124
- if (Reflect.get(raw, "type") !== "device") return raw;
44125
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44126
- const targets = Reflect.get(raw, "targets");
44127
- if (!Array.isArray(targets)) return raw;
44128
- return {
44129
- type: "device",
44130
- selector: {
44131
- kind: "ids",
44132
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44133
- },
44134
- access: Reflect.get(raw, "access")
44135
- };
44136
- }
44137
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44138
- object({
44139
- type: literal("category"),
44140
- target: CapScopeSchema,
44141
- access: array(MethodAccessSchema).min(1)
44142
- }),
44143
- object({
44144
- type: literal("capability"),
44145
- target: string(),
44146
- access: array(MethodAccessSchema).min(1)
44147
- }),
44148
- object({
44149
- type: literal("addon"),
44150
- target: string(),
44151
- access: array(MethodAccessSchema).min(1)
44152
- }),
44153
- DeviceTokenScopeSchema
44154
- ]));
44155
- object({
44156
- id: string(),
44157
- username: string(),
44158
- passwordHash: string(),
44159
- /**
44160
- * Admin bypass. When true, the middleware skips the scope-access
44161
- * check entirely. There is no other axis of privilege; the legacy
44162
- * role enum collapsed onto this boolean in v2.
44163
- */
44164
- isAdmin: boolean().default(false),
44165
- allowedProviders: AllowedProviderSchema,
44166
- allowedDevices: AllowedDevicesSchema,
44167
- /**
44168
- * Scopes granted to this user. Admins bypass; their `scopes` is
44169
- * ignored. Non-admins without scopes are locked out of every
44170
- * protected call.
44171
- */
44172
- scopes: array(TokenScopeSchema).default([]),
44173
- createdAt: number(),
44174
- updatedAt: number()
44175
- });
44176
- object({
44177
- id: string(),
44178
- label: string(),
44179
- isAdmin: boolean().default(false),
44180
- allowedProviders: AllowedProviderSchema,
44181
- allowedDevices: AllowedDevicesSchema,
44182
- tokenHash: string(),
44183
- tokenPrefix: string(),
44184
- createdAt: number(),
44185
- lastUsedAt: number().optional()
44186
- });
44187
- object({
44188
- id: string(),
44189
- userId: string(),
44190
- name: string(),
44191
- tokenHash: string(),
44192
- tokenPrefix: string(),
44193
- scopes: array(TokenScopeSchema),
44194
- expiresAt: number().nullish(),
44195
- lastUsedAt: number().nullish(),
44196
- createdAt: number()
44197
- });
44198
- /**
44199
44347
  * `oauth-integration` — a collection cap by which an addon declares
44200
44348
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44201
44349
  * Each provider returns a static descriptor; the core enumerates them
@@ -64090,26 +64238,6 @@ var ApiKeySummarySchema = object({
64090
64238
  createdAt: number(),
64091
64239
  lastUsedAt: number().optional()
64092
64240
  });
64093
- var ScopedTokenSummarySchema = object({
64094
- id: string(),
64095
- userId: string(),
64096
- name: string(),
64097
- tokenPrefix: string(),
64098
- scopes: array(TokenScopeSchema),
64099
- expiresAt: number().nullish(),
64100
- lastUsedAt: number().nullish(),
64101
- createdAt: number()
64102
- });
64103
- var CreateScopedTokenInputSchema = object({
64104
- userId: string(),
64105
- name: string(),
64106
- scopes: array(TokenScopeSchema),
64107
- expiresAt: number().optional()
64108
- });
64109
- var CreateScopedTokenResultSchema = object({
64110
- token: string(),
64111
- record: ScopedTokenSummarySchema
64112
- });
64113
64241
  var OauthSessionSummarySchema = object({
64114
64242
  id: string(),
64115
64243
  userId: string(),
@@ -64131,11 +64259,11 @@ var TotpStatusSchema = object({
64131
64259
  confirmedAt: number().nullable()
64132
64260
  });
64133
64261
  /**
64134
- * user-management — singleton capability for user accounts, API keys,
64135
- * and scoped tokens.
64262
+ * user-management — singleton capability for user accounts and the
64263
+ * legacy API-key rows.
64136
64264
  *
64137
64265
  * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
64138
- * — the subset check on `setUserScopes` / `createScopedToken` is moot
64266
+ * — the subset check on `setUserScopes` is moot
64139
64267
  * because non-admins never reach these. If/when we open non-admin
64140
64268
  * delegation, structural caller-scope subset check goes inside the
64141
64269
  * provider.
@@ -64192,15 +64320,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
64192
64320
  kind: "mutation",
64193
64321
  auth: "admin",
64194
64322
  access: "delete"
64195
- }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
64196
- kind: "mutation",
64197
- auth: "admin",
64198
- access: "create"
64199
- }), method(object({ id: string() }), object({ success: literal(true) }), {
64200
- kind: "mutation",
64201
- auth: "admin",
64202
- access: "delete"
64203
- }), method(object({ token: string() }), ScopedTokenSummarySchema.nullable(), { access: "view" }), method(object({ userId: string() }), array(ScopedTokenSummarySchema), { auth: "admin" }), method(object({ userId: string() }), TotpSetupResultSchema, {
64323
+ }), method(object({ userId: string() }), TotpSetupResultSchema, {
64204
64324
  kind: "mutation",
64205
64325
  auth: "admin",
64206
64326
  access: "create"
@@ -70290,7 +70410,7 @@ Object.freeze({
70290
70410
  capName: "llm",
70291
70411
  capScope: "system",
70292
70412
  addonId: null,
70293
- access: "view"
70413
+ access: "create"
70294
70414
  },
70295
70415
  "llm.listNodeModels": {
70296
70416
  capName: "llm",
@@ -74954,12 +75074,6 @@ Object.freeze({
74954
75074
  addonId: null,
74955
75075
  access: "create"
74956
75076
  },
74957
- "userManagement.createScopedToken": {
74958
- capName: "user-management",
74959
- capScope: "system",
74960
- addonId: null,
74961
- access: "create"
74962
- },
74963
75077
  "userManagement.createUser": {
74964
75078
  capName: "user-management",
74965
75079
  capScope: "system",
@@ -75008,12 +75122,6 @@ Object.freeze({
75008
75122
  addonId: null,
75009
75123
  access: "view"
75010
75124
  },
75011
- "userManagement.listScopedTokens": {
75012
- capName: "user-management",
75013
- capScope: "system",
75014
- addonId: null,
75015
- access: "view"
75016
- },
75017
75125
  "userManagement.listUsers": {
75018
75126
  capName: "user-management",
75019
75127
  capScope: "system",
@@ -75068,12 +75176,6 @@ Object.freeze({
75068
75176
  addonId: null,
75069
75177
  access: "delete"
75070
75178
  },
75071
- "userManagement.revokeScopedToken": {
75072
- capName: "user-management",
75073
- capScope: "system",
75074
- addonId: null,
75075
- access: "delete"
75076
- },
75077
75179
  "userManagement.setupTotp": {
75078
75180
  capName: "user-management",
75079
75181
  capScope: "system",
@@ -75104,12 +75206,6 @@ Object.freeze({
75104
75206
  addonId: null,
75105
75207
  access: "view"
75106
75208
  },
75107
- "userManagement.validateScopedToken": {
75108
- capName: "user-management",
75109
- capScope: "system",
75110
- addonId: null,
75111
- access: "view"
75112
- },
75113
75209
  "userManagement.verifyTotp": {
75114
75210
  capName: "user-management",
75115
75211
  capScope: "system",