@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.js CHANGED
@@ -5446,7 +5446,7 @@ var ZodIssueCode = {
5446
5446
  var ZodFirstPartyTypeKind;
5447
5447
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5448
5448
  //#endregion
5449
- //#region ../types/dist/sleep-BxjU_fJM.mjs
5449
+ //#region ../types/dist/sleep-yKL5gfrH.mjs
5450
5450
  /**
5451
5451
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5452
5452
  * window to float samples (D455).
@@ -7828,6 +7828,12 @@ function normalizeAddonInitResult(result) {
7828
7828
  if (Array.isArray(result)) return { providers: result };
7829
7829
  return result;
7830
7830
  }
7831
+ /**
7832
+ * The share-view scope kinds a share-link token can carry. The hub mints
7833
+ * and validates them (`ShareViewGrantSchema` builds its
7834
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
7835
+ */
7836
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7831
7837
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7832
7838
  var PeerBytesTicketSchema = object({
7833
7839
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12527,6 +12533,280 @@ var ConvertResultSchema = object({
12527
12533
  files: array(string()).readonly()
12528
12534
  })).readonly()
12529
12535
  });
12536
+ /**
12537
+ * Zod schemas for persisted record types.
12538
+ *
12539
+ * These schemas serve as the single source of truth for types that are
12540
+ * stored in the settings-store backend and retrieved via tRPC. They
12541
+ * replace the manual TypeScript interfaces with schema-derived types,
12542
+ * enabling runtime validation when reading from the backend.
12543
+ *
12544
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12545
+ * keeps the original name for backward compatibility.
12546
+ */
12547
+ /**
12548
+ * Auth model (v2 — 2026-05-12 caps-only):
12549
+ *
12550
+ * Two principals:
12551
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12552
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12553
+ *
12554
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12555
+ * `super_admin` — collapsed onto the single boolean because every
12556
+ * non-admin caller is governed by the same scope-check rules; the
12557
+ * distinction was only ever used to route role-specific procedures
12558
+ * which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
12559
+ * with `isAdmin: false` + an explicit scope list.
12560
+ */
12561
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12562
+ var MethodAccessSchema = _enum([
12563
+ "view",
12564
+ "create",
12565
+ "delete"
12566
+ ]);
12567
+ /**
12568
+ * A single scope grant. Three forms — checked in matcher with OR
12569
+ * semantics; the first match decides whether the call passes:
12570
+ *
12571
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12572
+ * cap with the matching `scope` declaration. New caps inherit grants
12573
+ * automatically — adding a device cap to the codebase makes it
12574
+ * reachable to every user with `category:device [...]` without a
12575
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12576
+ *
12577
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12578
+ * useful when an integration needs to interact with one specific
12579
+ * addon's surface regardless of how many caps it exports.
12580
+ *
12581
+ * - `capability` — the most precise form. Single cap name. Use for
12582
+ * integration tokens where you want to grant `addons.installPackage`
12583
+ * and nothing else.
12584
+ *
12585
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12586
+ * "give me everything" escape; there is no wildcard scope.
12587
+ */
12588
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12589
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12590
+ var CapScopeSchema = _enum(["device", "system"]);
12591
+ /**
12592
+ * DeviceSelector (scope model v3 — 2026-08-12).
12593
+ *
12594
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12595
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12596
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12597
+ * AFTER the grant was minted — no re-grant, no re-login.
12598
+ *
12599
+ * - `all` — every device in the deployment. The broad viewer/operator
12600
+ * lever without a `category` grant (a `category` grant also covers device
12601
+ * caps that carry no deviceId; `all` is specifically the device set).
12602
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
12603
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
12604
+ * is NOT covered until the grant is edited.
12605
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
12606
+ * DYNAMIC. A device that changes type, or a new device of the type,
12607
+ * re-resolves on the next request.
12608
+ * - `locations` — every device whose operator-assigned `location` label is
12609
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
12610
+ * null/unset location matches NO `locations` selector.
12611
+ */
12612
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
12613
+ object({ kind: literal("all") }),
12614
+ object({
12615
+ kind: literal("ids"),
12616
+ ids: array(number().int()).min(1)
12617
+ }),
12618
+ object({
12619
+ kind: literal("types"),
12620
+ types: array(_enum(DeviceType)).min(1)
12621
+ }),
12622
+ object({
12623
+ kind: literal("locations"),
12624
+ locations: array(string().min(1)).min(1)
12625
+ })
12626
+ ]);
12627
+ var DeviceTokenScopeSchema = object({
12628
+ type: literal("device"),
12629
+ /** The device SET this grant covers — resolved against the live fleet. */
12630
+ selector: DeviceSelectorSchema,
12631
+ access: array(MethodAccessSchema).min(1),
12632
+ /**
12633
+ * Whether a grant on a PARENT device transparently covers its accessory
12634
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
12635
+ * Direction is parent → children ONLY.
12636
+ *
12637
+ * Absent → the matcher DERIVES it from the access flavour: `view`
12638
+ * inherits (a camera viewer sees the camera's accessories), `create` /
12639
+ * `delete` do NOT (actuating/removing a child is an explicit act the
12640
+ * operator must grant on the child, not inherit from the parent). Set it
12641
+ * explicitly to override that default per grant.
12642
+ */
12643
+ includeLinked: boolean().optional()
12644
+ });
12645
+ /**
12646
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
12647
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
12648
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
12649
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
12650
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
12651
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
12652
+ * migration cannot reach a JWT already in a client's hands; parse-time
12653
+ * migration covers both without a flag day. No cast — the raw object is read
12654
+ * through `Reflect.get` (its static type is `unknown`).
12655
+ */
12656
+ function migrateLegacyTokenScope(raw) {
12657
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
12658
+ if (Reflect.get(raw, "type") !== "device") return raw;
12659
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
12660
+ const targets = Reflect.get(raw, "targets");
12661
+ if (!Array.isArray(targets)) return raw;
12662
+ return {
12663
+ type: "device",
12664
+ selector: {
12665
+ kind: "ids",
12666
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
12667
+ },
12668
+ access: Reflect.get(raw, "access")
12669
+ };
12670
+ }
12671
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
12672
+ object({
12673
+ type: literal("category"),
12674
+ target: CapScopeSchema,
12675
+ access: array(MethodAccessSchema).min(1)
12676
+ }),
12677
+ object({
12678
+ type: literal("capability"),
12679
+ target: string(),
12680
+ access: array(MethodAccessSchema).min(1)
12681
+ }),
12682
+ object({
12683
+ type: literal("addon"),
12684
+ target: string(),
12685
+ access: array(MethodAccessSchema).min(1)
12686
+ }),
12687
+ DeviceTokenScopeSchema
12688
+ ]));
12689
+ object({
12690
+ id: string(),
12691
+ username: string(),
12692
+ passwordHash: string(),
12693
+ /**
12694
+ * Admin bypass. When true, the middleware skips the scope-access
12695
+ * check entirely. There is no other axis of privilege; the legacy
12696
+ * role enum collapsed onto this boolean in v2.
12697
+ */
12698
+ isAdmin: boolean().default(false),
12699
+ allowedProviders: AllowedProviderSchema,
12700
+ allowedDevices: AllowedDevicesSchema,
12701
+ /**
12702
+ * Scopes granted to this user. Admins bypass; their `scopes` is
12703
+ * ignored. Non-admins without scopes are locked out of every
12704
+ * protected call.
12705
+ */
12706
+ scopes: array(TokenScopeSchema).default([]),
12707
+ createdAt: number(),
12708
+ updatedAt: number()
12709
+ });
12710
+ object({
12711
+ id: string(),
12712
+ label: string(),
12713
+ isAdmin: boolean().default(false),
12714
+ allowedProviders: AllowedProviderSchema,
12715
+ allowedDevices: AllowedDevicesSchema,
12716
+ tokenHash: string(),
12717
+ tokenPrefix: string(),
12718
+ createdAt: number(),
12719
+ lastUsedAt: number().optional()
12720
+ });
12721
+ object({
12722
+ id: string(),
12723
+ userId: string(),
12724
+ name: string(),
12725
+ tokenHash: string(),
12726
+ tokenPrefix: string(),
12727
+ scopes: array(TokenScopeSchema),
12728
+ expiresAt: number().nullish(),
12729
+ lastUsedAt: number().nullish(),
12730
+ createdAt: number()
12731
+ });
12732
+ /** What a share-view grant lets its holder see. */
12733
+ var ShareViewGrantSchema = object({
12734
+ kind: _enum(SHARE_VIEW_KINDS),
12735
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
12736
+ /** Talk-back, opt-in at mint time; absent means off. */
12737
+ talk: boolean().optional()
12738
+ });
12739
+ var ShareViewScopeSchema = object({
12740
+ type: literal("share-view"),
12741
+ grant: ShareViewGrantSchema
12742
+ });
12743
+ var AddonRoutesScopeSchema = object({
12744
+ type: literal("addon-routes"),
12745
+ access: array(MethodAccessSchema).min(1)
12746
+ });
12747
+ var PreferencesSelfScopeSchema = object({ type: literal("preferences-self") });
12748
+ var CredentialScopeSchema = union([
12749
+ literal("*"),
12750
+ ShareViewScopeSchema,
12751
+ AddonRoutesScopeSchema,
12752
+ PreferencesSelfScopeSchema,
12753
+ TokenScopeSchema
12754
+ ]);
12755
+ object({
12756
+ kind: literal("credential"),
12757
+ sub: string().min(1),
12758
+ jti: string().min(16),
12759
+ scopes: array(CredentialScopeSchema).min(1)
12760
+ });
12761
+ var PreferenceNamespaceSchema = string().regex(/^[a-z][a-z0-9.-]{0,63}$/);
12762
+ /** A namespace's value: a JSON object, opaque to the hub. */
12763
+ var PreferenceValueSchema = record(string(), unknown());
12764
+ var PreferenceDeviceIdSchema = string().min(1).max(64);
12765
+ /** A stored row, as the owner reads it. */
12766
+ var PreferenceRowSchema = object({
12767
+ namespace: PreferenceNamespaceSchema,
12768
+ value: PreferenceValueSchema,
12769
+ /** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
12770
+ revision: number().int().positive(),
12771
+ updatedAt: number().int(),
12772
+ /** The client id the last writer sent; `null` when it sent none. */
12773
+ updatedByDevice: PreferenceDeviceIdSchema.nullable()
12774
+ });
12775
+ object({
12776
+ /** Absent: every namespace the caller holds. */
12777
+ namespaces: array(PreferenceNamespaceSchema).max(32).optional() });
12778
+ object({ rows: array(PreferenceRowSchema) });
12779
+ object({
12780
+ namespace: PreferenceNamespaceSchema,
12781
+ value: PreferenceValueSchema,
12782
+ /**
12783
+ * The revision the edit was based on. Absent: last write wins. `0`: the
12784
+ * namespace must not exist yet. Any other value that is not the current
12785
+ * revision answers `conflict` and writes nothing.
12786
+ */
12787
+ baseRevision: number().int().nonnegative().optional(),
12788
+ deviceId: PreferenceDeviceIdSchema.optional()
12789
+ });
12790
+ discriminatedUnion("status", [object({
12791
+ status: literal("saved"),
12792
+ row: PreferenceRowSchema
12793
+ }), object({
12794
+ status: literal("conflict"),
12795
+ current: PreferenceRowSchema.nullable()
12796
+ })]);
12797
+ object({ namespace: PreferenceNamespaceSchema });
12798
+ object({
12799
+ /** `false` when the namespace did not exist. */
12800
+ deleted: boolean() });
12801
+ object({
12802
+ /** The revision the client holds per namespace; a namespace it does not list is new to it. */
12803
+ revisionByNamespace: record(PreferenceNamespaceSchema, number().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
12804
+ object({
12805
+ /** Every row whose revision differs from the client's, and every row it did not list. */
12806
+ rows: array(PreferenceRowSchema),
12807
+ /** Namespaces the client listed that no longer exist. */
12808
+ deleted: array(PreferenceNamespaceSchema)
12809
+ });
12530
12810
  _enum(["new-session", "step-up"]);
12531
12811
  /** The languages the hub's app landing pages are written in (D858). */
12532
12812
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -39720,38 +40000,37 @@ method(LlmRuntimeCompleteInputSchema, LlmGenerateResultSchema, {
39720
40000
  auth: "admin",
39721
40001
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39722
40002
  });
40003
+ var LlmProfileKindSchema = string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "a kind id is lower-case letters, digits and dashes");
40004
+ /** What a model (or, by default, every model of a kind) can do. */
40005
+ var LlmModelFeaturesSchema = object({
40006
+ vision: boolean(),
40007
+ tools: boolean(),
40008
+ streaming: boolean()
40009
+ });
40010
+ /** One model a provider offers. `features` overrides the kind's defaults, per field. */
40011
+ var LlmModelInfoSchema = object({
40012
+ id: string(),
40013
+ label: string().optional(),
40014
+ contextLength: number().int().positive().optional(),
40015
+ features: LlmModelFeaturesSchema.partial().optional()
40016
+ });
39723
40017
  /**
39724
- * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
39725
- * methods concat-fan across providers; single-row methods route to ONE
39726
- * provider by the `addonId` in the call input (the notification-output
39727
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
39728
- * (hub-placed); the cap stays open for future providers.
39729
- *
39730
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
39731
- * `apiKey` is a password field — providers REDACT it on read and merge on
39732
- * write; a stored key NEVER round-trips to a client.
40018
+ * The provider-specific part of a profile, validated by the provider that owns
40019
+ * the kind (`upsertProfile` refuses what it does not accept). A field its
40020
+ * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
40021
+ * keychain, never in the row, and reads back as the redaction marker.
39733
40022
  */
39734
- var LlmProfileKindSchema = _enum([
39735
- "openai-compatible",
39736
- "openai",
39737
- "anthropic",
39738
- "google",
39739
- "managed-local",
39740
- "apple-foundation"
39741
- ]);
40023
+ var LlmProviderConfigSchema = record(string(), unknown());
39742
40024
  var LlmProfileSchema = object({
39743
40025
  id: string(),
39744
40026
  name: string(),
40027
+ /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
39745
40028
  kind: LlmProfileKindSchema,
39746
40029
  /** Stamped by the provider — keeps the fanned catalog routable. */
39747
40030
  addonId: string(),
39748
40031
  enabled: boolean(),
39749
40032
  /** Vendor model id, or the managed runtime's loaded model. */
39750
40033
  model: string(),
39751
- /** Required for openai-compatible; override for cloud kinds. */
39752
- baseUrl: string().optional(),
39753
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
39754
- apiKey: string().optional(),
39755
40034
  /** Vision on/off. A vision call against a `false` profile is REFUSED, never
39756
40035
  * degraded to text — that shipped once and produced a confident answer to a
39757
40036
  * question about a picture nobody sent. */
@@ -39759,15 +40038,11 @@ var LlmProfileSchema = object({
39759
40038
  temperature: number().min(0).max(2).optional(),
39760
40039
  /** Nucleus sampling. Every wire we speak has it. */
39761
40040
  topP: number().min(0).max(1).optional(),
39762
- /** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
39763
- * wire does, and the client drops it there (measured: the request body gets
39764
- * `top_p` and no `top_k`). The profile editor hides the field wherever it
39765
- * would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
40041
+ /** Top-k sampling. Carried only by the wires that have it — a kind offers the
40042
+ * field in its editor only when its descriptor lists it in `profileFields`. */
39766
40043
  topK: number().int().positive().optional(),
39767
40044
  maxTokens: number().int().positive().optional(),
39768
- /** Prompt context window. Advisory for cloud kinds (they enforce their own);
39769
- * for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
39770
- * the model with, so it is the one field that changes a PROCESS. */
40045
+ /** Prompt context window. Advisory for cloud kinds (they enforce their own). */
39771
40046
  contextLength: number().int().positive().optional(),
39772
40047
  /** Default system prompt. A caller's `system` REPLACES it (never appends —
39773
40048
  * two system prompts fighting is worse than either alone). */
@@ -39793,16 +40068,37 @@ var LlmProfileSchema = object({
39793
40068
  * library; the REGISTRY of callable tools is ours and is empty in v1, so a
39794
40069
  * `true` here buys the wiring, not behaviour, until tools are registered. */
39795
40070
  toolsEnabled: boolean().default(false),
39796
- extraHeaders: record(string(), string()).optional(),
39797
- /** kind === 'managed-local' only (spec §4). */
39798
- runtime: ManagedRuntimeConfigSchema.optional(),
39799
- /**
39800
- * kind === 'apple-foundation' only: WHERE it runs — the only thing there is
39801
- * to configure (no key, no URL, no download; `model` is `apple-system`).
39802
- * `supportsVision` on such a row is stamped by the provider from the node's
39803
- * reported `imageInput`, never taken from the operator (D62).
39804
- */
39805
- appleFoundation: object({ nodeId: string() }).optional()
40071
+ /** Everything the kind's provider owns (endpoint, key, node, runtime…). */
40072
+ providerConfig: LlmProviderConfigSchema.default({})
40073
+ });
40074
+ /**
40075
+ * The common profile fields a kind's editor offers. The editor owns how each
40076
+ * one is drawn; the provider says which of them mean something on its wire.
40077
+ */
40078
+ var LlmProfileFieldSchema = _enum([
40079
+ "temperature",
40080
+ "topP",
40081
+ "topK",
40082
+ "maxTokens",
40083
+ "contextLength",
40084
+ "systemPrompt",
40085
+ "timeoutMs",
40086
+ "connectTimeoutMs",
40087
+ "firstTokenTimeoutMs",
40088
+ "idleTimeoutMs",
40089
+ "retry",
40090
+ "toolsEnabled"
40091
+ ]);
40092
+ /**
40093
+ * A provider-drawn part of the editor, by a generic widget id the admin UI
40094
+ * registers (`ai/apple-node`). `placement: 'model'` replaces the generic model
40095
+ * picker: that widget owns the model choice.
40096
+ */
40097
+ var LlmProviderWidgetSchema = object({
40098
+ id: string(),
40099
+ placement: _enum(["connection", "model"]),
40100
+ /** `providerConfig` keys this widget must fill before the profile can be saved. */
40101
+ requires: array(string()).optional()
39806
40102
  });
39807
40103
  /** ConfigUISchema tree passed through untyped on the wire (the
39808
40104
  * notification-output `ConfigSchemaPassthrough` precedent at
@@ -39811,11 +40107,56 @@ var ConfigSchemaPassthrough$3 = unknown();
39811
40107
  var LlmProfileKindDescriptorSchema = object({
39812
40108
  kind: LlmProfileKindSchema,
39813
40109
  label: string(),
40110
+ /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
39814
40111
  icon: string(),
39815
40112
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
39816
40113
  addonId: string(),
39817
- configSchema: ConfigSchemaPassthrough$3
40114
+ /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
40115
+ connectionSchema: ConfigSchemaPassthrough$3,
40116
+ /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
40117
+ advancedSchema: ConfigSchemaPassthrough$3.optional(),
40118
+ /** The kind's defaults; a model from `listModels` may override any of them. */
40119
+ features: LlmModelFeaturesSchema,
40120
+ /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
40121
+ visionEditable: boolean(),
40122
+ /** Where the model list comes from: `listModels`, `staticModels`, or nowhere. */
40123
+ modelCatalog: _enum([
40124
+ "fetch",
40125
+ "static",
40126
+ "none"
40127
+ ]),
40128
+ staticModels: array(LlmModelInfoSchema).optional(),
40129
+ /** The common fields that mean something on this kind's wire. */
40130
+ profileFields: array(LlmProfileFieldSchema),
40131
+ providerWidgets: array(LlmProviderWidgetSchema).optional()
40132
+ });
40133
+ /**
40134
+ * `listModels` input. `connection` is an UNSAVED draft of `providerConfig`
40135
+ * (the editor's form); with `profileId` too, a secret the draft leaves
40136
+ * untouched (absent or the redaction marker) is resolved server-side from the
40137
+ * stored profile — the browser never receives it.
40138
+ */
40139
+ var LlmListModelsInputSchema = object({
40140
+ addonId: string(),
40141
+ kind: LlmProfileKindSchema,
40142
+ profileId: string().optional(),
40143
+ connection: LlmProviderConfigSchema.optional()
39818
40144
  });
40145
+ var LlmListModelsErrorCodeSchema = _enum([
40146
+ "auth",
40147
+ "network",
40148
+ "unsupported",
40149
+ "invalid"
40150
+ ]);
40151
+ /** A RESULT, never a throw: "wrong key" is an answer the editor renders inline. */
40152
+ var LlmListModelsResultSchema = discriminatedUnion("ok", [object({
40153
+ ok: literal(true),
40154
+ models: array(LlmModelInfoSchema)
40155
+ }), object({
40156
+ ok: literal(false),
40157
+ code: LlmListModelsErrorCodeSchema,
40158
+ message: string()
40159
+ })]);
39819
40160
  var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
39820
40161
  var LlmDefaultSchema = object({
39821
40162
  selector: LlmDefaultSelectorSchema,
@@ -39915,7 +40256,10 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
39915
40256
  kind: "mutation",
39916
40257
  auth: "admin",
39917
40258
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39918
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
40259
+ }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
40260
+ kind: "mutation",
40261
+ auth: "admin"
40262
+ }), method(object({}), array(LlmDefaultSchema)), method(object({
39919
40263
  selector: LlmDefaultSelectorSchema,
39920
40264
  profileId: string().nullable()
39921
40265
  }), _void(), {
@@ -44021,202 +44365,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
44021
44365
  auth: "admin"
44022
44366
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
44023
44367
  /**
44024
- * Zod schemas for persisted record types.
44025
- *
44026
- * These schemas serve as the single source of truth for types that are
44027
- * stored in the settings-store backend and retrieved via tRPC. They
44028
- * replace the manual TypeScript interfaces with schema-derived types,
44029
- * enabling runtime validation when reading from the backend.
44030
- *
44031
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
44032
- * keeps the original name for backward compatibility.
44033
- */
44034
- /**
44035
- * Auth model (v2 — 2026-05-12 caps-only):
44036
- *
44037
- * Two principals:
44038
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
44039
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
44040
- *
44041
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44042
- * `super_admin` — collapsed onto the single boolean because every
44043
- * non-admin caller is governed by the same scope-check rules; the
44044
- * distinction was only ever used to route role-specific procedures
44045
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44046
- * with `isAdmin: false` + an explicit scope list.
44047
- */
44048
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44049
- var MethodAccessSchema = _enum([
44050
- "view",
44051
- "create",
44052
- "delete"
44053
- ]);
44054
- /**
44055
- * A single scope grant. Three forms — checked in matcher with OR
44056
- * semantics; the first match decides whether the call passes:
44057
- *
44058
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44059
- * cap with the matching `scope` declaration. New caps inherit grants
44060
- * automatically — adding a device cap to the codebase makes it
44061
- * reachable to every user with `category:device [...]` without a
44062
- * re-grant. Use this for "family viewer" / "operator" tiers.
44063
- *
44064
- * - `addon` — every cap that ships inside a given addon id. Niche;
44065
- * useful when an integration needs to interact with one specific
44066
- * addon's surface regardless of how many caps it exports.
44067
- *
44068
- * - `capability` — the most precise form. Single cap name. Use for
44069
- * integration tokens where you want to grant `addons.installPackage`
44070
- * and nothing else.
44071
- *
44072
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44073
- * "give me everything" escape; there is no wildcard scope.
44074
- */
44075
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44076
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44077
- var CapScopeSchema = _enum(["device", "system"]);
44078
- /**
44079
- * DeviceSelector (scope model v3 — 2026-08-12).
44080
- *
44081
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44082
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44083
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44084
- * AFTER the grant was minted — no re-grant, no re-login.
44085
- *
44086
- * - `all` — every device in the deployment. The broad viewer/operator
44087
- * lever without a `category` grant (a `category` grant also covers device
44088
- * caps that carry no deviceId; `all` is specifically the device set).
44089
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44090
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44091
- * is NOT covered until the grant is edited.
44092
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44093
- * DYNAMIC. A device that changes type, or a new device of the type,
44094
- * re-resolves on the next request.
44095
- * - `locations` — every device whose operator-assigned `location` label is
44096
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44097
- * null/unset location matches NO `locations` selector.
44098
- */
44099
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44100
- object({ kind: literal("all") }),
44101
- object({
44102
- kind: literal("ids"),
44103
- ids: array(number().int()).min(1)
44104
- }),
44105
- object({
44106
- kind: literal("types"),
44107
- types: array(_enum(DeviceType)).min(1)
44108
- }),
44109
- object({
44110
- kind: literal("locations"),
44111
- locations: array(string().min(1)).min(1)
44112
- })
44113
- ]);
44114
- var DeviceTokenScopeSchema = object({
44115
- type: literal("device"),
44116
- /** The device SET this grant covers — resolved against the live fleet. */
44117
- selector: DeviceSelectorSchema,
44118
- access: array(MethodAccessSchema).min(1),
44119
- /**
44120
- * Whether a grant on a PARENT device transparently covers its accessory
44121
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44122
- * Direction is parent → children ONLY.
44123
- *
44124
- * Absent → the matcher DERIVES it from the access flavour: `view`
44125
- * inherits (a camera viewer sees the camera's accessories), `create` /
44126
- * `delete` do NOT (actuating/removing a child is an explicit act the
44127
- * operator must grant on the child, not inherit from the parent). Set it
44128
- * explicitly to override that default per grant.
44129
- */
44130
- includeLinked: boolean().optional()
44131
- });
44132
- /**
44133
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44134
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44135
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44136
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44137
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44138
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44139
- * migration cannot reach a JWT already in a client's hands; parse-time
44140
- * migration covers both without a flag day. No cast — the raw object is read
44141
- * through `Reflect.get` (its static type is `unknown`).
44142
- */
44143
- function migrateLegacyTokenScope(raw) {
44144
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44145
- if (Reflect.get(raw, "type") !== "device") return raw;
44146
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44147
- const targets = Reflect.get(raw, "targets");
44148
- if (!Array.isArray(targets)) return raw;
44149
- return {
44150
- type: "device",
44151
- selector: {
44152
- kind: "ids",
44153
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44154
- },
44155
- access: Reflect.get(raw, "access")
44156
- };
44157
- }
44158
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44159
- object({
44160
- type: literal("category"),
44161
- target: CapScopeSchema,
44162
- access: array(MethodAccessSchema).min(1)
44163
- }),
44164
- object({
44165
- type: literal("capability"),
44166
- target: string(),
44167
- access: array(MethodAccessSchema).min(1)
44168
- }),
44169
- object({
44170
- type: literal("addon"),
44171
- target: string(),
44172
- access: array(MethodAccessSchema).min(1)
44173
- }),
44174
- DeviceTokenScopeSchema
44175
- ]));
44176
- object({
44177
- id: string(),
44178
- username: string(),
44179
- passwordHash: string(),
44180
- /**
44181
- * Admin bypass. When true, the middleware skips the scope-access
44182
- * check entirely. There is no other axis of privilege; the legacy
44183
- * role enum collapsed onto this boolean in v2.
44184
- */
44185
- isAdmin: boolean().default(false),
44186
- allowedProviders: AllowedProviderSchema,
44187
- allowedDevices: AllowedDevicesSchema,
44188
- /**
44189
- * Scopes granted to this user. Admins bypass; their `scopes` is
44190
- * ignored. Non-admins without scopes are locked out of every
44191
- * protected call.
44192
- */
44193
- scopes: array(TokenScopeSchema).default([]),
44194
- createdAt: number(),
44195
- updatedAt: number()
44196
- });
44197
- object({
44198
- id: string(),
44199
- label: string(),
44200
- isAdmin: boolean().default(false),
44201
- allowedProviders: AllowedProviderSchema,
44202
- allowedDevices: AllowedDevicesSchema,
44203
- tokenHash: string(),
44204
- tokenPrefix: string(),
44205
- createdAt: number(),
44206
- lastUsedAt: number().optional()
44207
- });
44208
- object({
44209
- id: string(),
44210
- userId: string(),
44211
- name: string(),
44212
- tokenHash: string(),
44213
- tokenPrefix: string(),
44214
- scopes: array(TokenScopeSchema),
44215
- expiresAt: number().nullish(),
44216
- lastUsedAt: number().nullish(),
44217
- createdAt: number()
44218
- });
44219
- /**
44220
44368
  * `oauth-integration` — a collection cap by which an addon declares
44221
44369
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44222
44370
  * Each provider returns a static descriptor; the core enumerates them
@@ -64111,26 +64259,6 @@ var ApiKeySummarySchema = object({
64111
64259
  createdAt: number(),
64112
64260
  lastUsedAt: number().optional()
64113
64261
  });
64114
- var ScopedTokenSummarySchema = object({
64115
- id: string(),
64116
- userId: string(),
64117
- name: string(),
64118
- tokenPrefix: string(),
64119
- scopes: array(TokenScopeSchema),
64120
- expiresAt: number().nullish(),
64121
- lastUsedAt: number().nullish(),
64122
- createdAt: number()
64123
- });
64124
- var CreateScopedTokenInputSchema = object({
64125
- userId: string(),
64126
- name: string(),
64127
- scopes: array(TokenScopeSchema),
64128
- expiresAt: number().optional()
64129
- });
64130
- var CreateScopedTokenResultSchema = object({
64131
- token: string(),
64132
- record: ScopedTokenSummarySchema
64133
- });
64134
64262
  var OauthSessionSummarySchema = object({
64135
64263
  id: string(),
64136
64264
  userId: string(),
@@ -64152,11 +64280,11 @@ var TotpStatusSchema = object({
64152
64280
  confirmedAt: number().nullable()
64153
64281
  });
64154
64282
  /**
64155
- * user-management — singleton capability for user accounts, API keys,
64156
- * and scoped tokens.
64283
+ * user-management — singleton capability for user accounts and the
64284
+ * legacy API-key rows.
64157
64285
  *
64158
64286
  * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
64159
- * — the subset check on `setUserScopes` / `createScopedToken` is moot
64287
+ * — the subset check on `setUserScopes` is moot
64160
64288
  * because non-admins never reach these. If/when we open non-admin
64161
64289
  * delegation, structural caller-scope subset check goes inside the
64162
64290
  * provider.
@@ -64213,15 +64341,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
64213
64341
  kind: "mutation",
64214
64342
  auth: "admin",
64215
64343
  access: "delete"
64216
- }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
64217
- kind: "mutation",
64218
- auth: "admin",
64219
- access: "create"
64220
- }), method(object({ id: string() }), object({ success: literal(true) }), {
64221
- kind: "mutation",
64222
- auth: "admin",
64223
- access: "delete"
64224
- }), method(object({ token: string() }), ScopedTokenSummarySchema.nullable(), { access: "view" }), method(object({ userId: string() }), array(ScopedTokenSummarySchema), { auth: "admin" }), method(object({ userId: string() }), TotpSetupResultSchema, {
64344
+ }), method(object({ userId: string() }), TotpSetupResultSchema, {
64225
64345
  kind: "mutation",
64226
64346
  auth: "admin",
64227
64347
  access: "create"
@@ -70311,7 +70431,7 @@ Object.freeze({
70311
70431
  capName: "llm",
70312
70432
  capScope: "system",
70313
70433
  addonId: null,
70314
- access: "view"
70434
+ access: "create"
70315
70435
  },
70316
70436
  "llm.listNodeModels": {
70317
70437
  capName: "llm",
@@ -74975,12 +75095,6 @@ Object.freeze({
74975
75095
  addonId: null,
74976
75096
  access: "create"
74977
75097
  },
74978
- "userManagement.createScopedToken": {
74979
- capName: "user-management",
74980
- capScope: "system",
74981
- addonId: null,
74982
- access: "create"
74983
- },
74984
75098
  "userManagement.createUser": {
74985
75099
  capName: "user-management",
74986
75100
  capScope: "system",
@@ -75029,12 +75143,6 @@ Object.freeze({
75029
75143
  addonId: null,
75030
75144
  access: "view"
75031
75145
  },
75032
- "userManagement.listScopedTokens": {
75033
- capName: "user-management",
75034
- capScope: "system",
75035
- addonId: null,
75036
- access: "view"
75037
- },
75038
75146
  "userManagement.listUsers": {
75039
75147
  capName: "user-management",
75040
75148
  capScope: "system",
@@ -75089,12 +75197,6 @@ Object.freeze({
75089
75197
  addonId: null,
75090
75198
  access: "delete"
75091
75199
  },
75092
- "userManagement.revokeScopedToken": {
75093
- capName: "user-management",
75094
- capScope: "system",
75095
- addonId: null,
75096
- access: "delete"
75097
- },
75098
75200
  "userManagement.setupTotp": {
75099
75201
  capName: "user-management",
75100
75202
  capScope: "system",
@@ -75125,12 +75227,6 @@ Object.freeze({
75125
75227
  addonId: null,
75126
75228
  access: "view"
75127
75229
  },
75128
- "userManagement.validateScopedToken": {
75129
- capName: "user-management",
75130
- capScope: "system",
75131
- addonId: null,
75132
- access: "view"
75133
- },
75134
75230
  "userManagement.verifyTotp": {
75135
75231
  capName: "user-management",
75136
75232
  capScope: "system",