@camstack/addon-export-alexa 1.2.148 → 1.2.150

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.
@@ -5420,7 +5420,7 @@ var ZodIssueCode = {
5420
5420
  var ZodFirstPartyTypeKind;
5421
5421
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5422
5422
  //#endregion
5423
- //#region ../types/dist/sleep-BxjU_fJM.mjs
5423
+ //#region ../types/dist/sleep-yKL5gfrH.mjs
5424
5424
  /**
5425
5425
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5426
5426
  * window to float samples (D455).
@@ -7802,6 +7802,12 @@ function normalizeAddonInitResult(result) {
7802
7802
  if (Array.isArray(result)) return { providers: result };
7803
7803
  return result;
7804
7804
  }
7805
+ /**
7806
+ * The share-view scope kinds a share-link token can carry. The hub mints
7807
+ * and validates them (`ShareViewGrantSchema` builds its
7808
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
7809
+ */
7810
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7805
7811
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7806
7812
  var PeerBytesTicketSchema = object({
7807
7813
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12682,6 +12688,280 @@ var ConvertResultSchema = object({
12682
12688
  function scopesAllowDeviceCap(scopes, access) {
12683
12689
  return scopes.some((s) => s.type === "category" && s.target === "device" && s.access.includes(access));
12684
12690
  }
12691
+ /**
12692
+ * Zod schemas for persisted record types.
12693
+ *
12694
+ * These schemas serve as the single source of truth for types that are
12695
+ * stored in the settings-store backend and retrieved via tRPC. They
12696
+ * replace the manual TypeScript interfaces with schema-derived types,
12697
+ * enabling runtime validation when reading from the backend.
12698
+ *
12699
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12700
+ * keeps the original name for backward compatibility.
12701
+ */
12702
+ /**
12703
+ * Auth model (v2 — 2026-05-12 caps-only):
12704
+ *
12705
+ * Two principals:
12706
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12707
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12708
+ *
12709
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12710
+ * `super_admin` — collapsed onto the single boolean because every
12711
+ * non-admin caller is governed by the same scope-check rules; the
12712
+ * distinction was only ever used to route role-specific procedures
12713
+ * which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
12714
+ * with `isAdmin: false` + an explicit scope list.
12715
+ */
12716
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12717
+ var MethodAccessSchema = _enum([
12718
+ "view",
12719
+ "create",
12720
+ "delete"
12721
+ ]);
12722
+ /**
12723
+ * A single scope grant. Three forms — checked in matcher with OR
12724
+ * semantics; the first match decides whether the call passes:
12725
+ *
12726
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12727
+ * cap with the matching `scope` declaration. New caps inherit grants
12728
+ * automatically — adding a device cap to the codebase makes it
12729
+ * reachable to every user with `category:device [...]` without a
12730
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12731
+ *
12732
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12733
+ * useful when an integration needs to interact with one specific
12734
+ * addon's surface regardless of how many caps it exports.
12735
+ *
12736
+ * - `capability` — the most precise form. Single cap name. Use for
12737
+ * integration tokens where you want to grant `addons.installPackage`
12738
+ * and nothing else.
12739
+ *
12740
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12741
+ * "give me everything" escape; there is no wildcard scope.
12742
+ */
12743
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12744
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12745
+ var CapScopeSchema = _enum(["device", "system"]);
12746
+ /**
12747
+ * DeviceSelector (scope model v3 — 2026-08-12).
12748
+ *
12749
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12750
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12751
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12752
+ * AFTER the grant was minted — no re-grant, no re-login.
12753
+ *
12754
+ * - `all` — every device in the deployment. The broad viewer/operator
12755
+ * lever without a `category` grant (a `category` grant also covers device
12756
+ * caps that carry no deviceId; `all` is specifically the device set).
12757
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
12758
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
12759
+ * is NOT covered until the grant is edited.
12760
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
12761
+ * DYNAMIC. A device that changes type, or a new device of the type,
12762
+ * re-resolves on the next request.
12763
+ * - `locations` — every device whose operator-assigned `location` label is
12764
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
12765
+ * null/unset location matches NO `locations` selector.
12766
+ */
12767
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
12768
+ object({ kind: literal("all") }),
12769
+ object({
12770
+ kind: literal("ids"),
12771
+ ids: array(number().int()).min(1)
12772
+ }),
12773
+ object({
12774
+ kind: literal("types"),
12775
+ types: array(_enum(DeviceType)).min(1)
12776
+ }),
12777
+ object({
12778
+ kind: literal("locations"),
12779
+ locations: array(string().min(1)).min(1)
12780
+ })
12781
+ ]);
12782
+ var DeviceTokenScopeSchema = object({
12783
+ type: literal("device"),
12784
+ /** The device SET this grant covers — resolved against the live fleet. */
12785
+ selector: DeviceSelectorSchema,
12786
+ access: array(MethodAccessSchema).min(1),
12787
+ /**
12788
+ * Whether a grant on a PARENT device transparently covers its accessory
12789
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
12790
+ * Direction is parent → children ONLY.
12791
+ *
12792
+ * Absent → the matcher DERIVES it from the access flavour: `view`
12793
+ * inherits (a camera viewer sees the camera's accessories), `create` /
12794
+ * `delete` do NOT (actuating/removing a child is an explicit act the
12795
+ * operator must grant on the child, not inherit from the parent). Set it
12796
+ * explicitly to override that default per grant.
12797
+ */
12798
+ includeLinked: boolean().optional()
12799
+ });
12800
+ /**
12801
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
12802
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
12803
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
12804
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
12805
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
12806
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
12807
+ * migration cannot reach a JWT already in a client's hands; parse-time
12808
+ * migration covers both without a flag day. No cast — the raw object is read
12809
+ * through `Reflect.get` (its static type is `unknown`).
12810
+ */
12811
+ function migrateLegacyTokenScope(raw) {
12812
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
12813
+ if (Reflect.get(raw, "type") !== "device") return raw;
12814
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
12815
+ const targets = Reflect.get(raw, "targets");
12816
+ if (!Array.isArray(targets)) return raw;
12817
+ return {
12818
+ type: "device",
12819
+ selector: {
12820
+ kind: "ids",
12821
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
12822
+ },
12823
+ access: Reflect.get(raw, "access")
12824
+ };
12825
+ }
12826
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
12827
+ object({
12828
+ type: literal("category"),
12829
+ target: CapScopeSchema,
12830
+ access: array(MethodAccessSchema).min(1)
12831
+ }),
12832
+ object({
12833
+ type: literal("capability"),
12834
+ target: string(),
12835
+ access: array(MethodAccessSchema).min(1)
12836
+ }),
12837
+ object({
12838
+ type: literal("addon"),
12839
+ target: string(),
12840
+ access: array(MethodAccessSchema).min(1)
12841
+ }),
12842
+ DeviceTokenScopeSchema
12843
+ ]));
12844
+ object({
12845
+ id: string(),
12846
+ username: string(),
12847
+ passwordHash: string(),
12848
+ /**
12849
+ * Admin bypass. When true, the middleware skips the scope-access
12850
+ * check entirely. There is no other axis of privilege; the legacy
12851
+ * role enum collapsed onto this boolean in v2.
12852
+ */
12853
+ isAdmin: boolean().default(false),
12854
+ allowedProviders: AllowedProviderSchema,
12855
+ allowedDevices: AllowedDevicesSchema,
12856
+ /**
12857
+ * Scopes granted to this user. Admins bypass; their `scopes` is
12858
+ * ignored. Non-admins without scopes are locked out of every
12859
+ * protected call.
12860
+ */
12861
+ scopes: array(TokenScopeSchema).default([]),
12862
+ createdAt: number(),
12863
+ updatedAt: number()
12864
+ });
12865
+ object({
12866
+ id: string(),
12867
+ label: string(),
12868
+ isAdmin: boolean().default(false),
12869
+ allowedProviders: AllowedProviderSchema,
12870
+ allowedDevices: AllowedDevicesSchema,
12871
+ tokenHash: string(),
12872
+ tokenPrefix: string(),
12873
+ createdAt: number(),
12874
+ lastUsedAt: number().optional()
12875
+ });
12876
+ object({
12877
+ id: string(),
12878
+ userId: string(),
12879
+ name: string(),
12880
+ tokenHash: string(),
12881
+ tokenPrefix: string(),
12882
+ scopes: array(TokenScopeSchema),
12883
+ expiresAt: number().nullish(),
12884
+ lastUsedAt: number().nullish(),
12885
+ createdAt: number()
12886
+ });
12887
+ /** What a share-view grant lets its holder see. */
12888
+ var ShareViewGrantSchema = object({
12889
+ kind: _enum(SHARE_VIEW_KINDS),
12890
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
12891
+ /** Talk-back, opt-in at mint time; absent means off. */
12892
+ talk: boolean().optional()
12893
+ });
12894
+ var ShareViewScopeSchema = object({
12895
+ type: literal("share-view"),
12896
+ grant: ShareViewGrantSchema
12897
+ });
12898
+ var AddonRoutesScopeSchema = object({
12899
+ type: literal("addon-routes"),
12900
+ access: array(MethodAccessSchema).min(1)
12901
+ });
12902
+ var PreferencesSelfScopeSchema = object({ type: literal("preferences-self") });
12903
+ var CredentialScopeSchema = union([
12904
+ literal("*"),
12905
+ ShareViewScopeSchema,
12906
+ AddonRoutesScopeSchema,
12907
+ PreferencesSelfScopeSchema,
12908
+ TokenScopeSchema
12909
+ ]);
12910
+ object({
12911
+ kind: literal("credential"),
12912
+ sub: string().min(1),
12913
+ jti: string().min(16),
12914
+ scopes: array(CredentialScopeSchema).min(1)
12915
+ });
12916
+ var PreferenceNamespaceSchema = string().regex(/^[a-z][a-z0-9.-]{0,63}$/);
12917
+ /** A namespace's value: a JSON object, opaque to the hub. */
12918
+ var PreferenceValueSchema = record(string(), unknown());
12919
+ var PreferenceDeviceIdSchema = string().min(1).max(64);
12920
+ /** A stored row, as the owner reads it. */
12921
+ var PreferenceRowSchema = object({
12922
+ namespace: PreferenceNamespaceSchema,
12923
+ value: PreferenceValueSchema,
12924
+ /** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
12925
+ revision: number().int().positive(),
12926
+ updatedAt: number().int(),
12927
+ /** The client id the last writer sent; `null` when it sent none. */
12928
+ updatedByDevice: PreferenceDeviceIdSchema.nullable()
12929
+ });
12930
+ object({
12931
+ /** Absent: every namespace the caller holds. */
12932
+ namespaces: array(PreferenceNamespaceSchema).max(32).optional() });
12933
+ object({ rows: array(PreferenceRowSchema) });
12934
+ object({
12935
+ namespace: PreferenceNamespaceSchema,
12936
+ value: PreferenceValueSchema,
12937
+ /**
12938
+ * The revision the edit was based on. Absent: last write wins. `0`: the
12939
+ * namespace must not exist yet. Any other value that is not the current
12940
+ * revision answers `conflict` and writes nothing.
12941
+ */
12942
+ baseRevision: number().int().nonnegative().optional(),
12943
+ deviceId: PreferenceDeviceIdSchema.optional()
12944
+ });
12945
+ discriminatedUnion("status", [object({
12946
+ status: literal("saved"),
12947
+ row: PreferenceRowSchema
12948
+ }), object({
12949
+ status: literal("conflict"),
12950
+ current: PreferenceRowSchema.nullable()
12951
+ })]);
12952
+ object({ namespace: PreferenceNamespaceSchema });
12953
+ object({
12954
+ /** `false` when the namespace did not exist. */
12955
+ deleted: boolean() });
12956
+ object({
12957
+ /** The revision the client holds per namespace; a namespace it does not list is new to it. */
12958
+ revisionByNamespace: record(PreferenceNamespaceSchema, number().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
12959
+ object({
12960
+ /** Every row whose revision differs from the client's, and every row it did not list. */
12961
+ rows: array(PreferenceRowSchema),
12962
+ /** Namespaces the client listed that no longer exist. */
12963
+ deleted: array(PreferenceNamespaceSchema)
12964
+ });
12685
12965
  _enum(["new-session", "step-up"]);
12686
12966
  /** The languages the hub's app landing pages are written in (D858). */
12687
12967
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -39604,38 +39884,37 @@ method(LlmRuntimeCompleteInputSchema, LlmGenerateResultSchema, {
39604
39884
  auth: "admin",
39605
39885
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39606
39886
  });
39887
+ var LlmProfileKindSchema = string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "a kind id is lower-case letters, digits and dashes");
39888
+ /** What a model (or, by default, every model of a kind) can do. */
39889
+ var LlmModelFeaturesSchema = object({
39890
+ vision: boolean(),
39891
+ tools: boolean(),
39892
+ streaming: boolean()
39893
+ });
39894
+ /** One model a provider offers. `features` overrides the kind's defaults, per field. */
39895
+ var LlmModelInfoSchema = object({
39896
+ id: string(),
39897
+ label: string().optional(),
39898
+ contextLength: number().int().positive().optional(),
39899
+ features: LlmModelFeaturesSchema.partial().optional()
39900
+ });
39607
39901
  /**
39608
- * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
39609
- * methods concat-fan across providers; single-row methods route to ONE
39610
- * provider by the `addonId` in the call input (the notification-output
39611
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
39612
- * (hub-placed); the cap stays open for future providers.
39613
- *
39614
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
39615
- * `apiKey` is a password field — providers REDACT it on read and merge on
39616
- * write; a stored key NEVER round-trips to a client.
39902
+ * The provider-specific part of a profile, validated by the provider that owns
39903
+ * the kind (`upsertProfile` refuses what it does not accept). A field its
39904
+ * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
39905
+ * keychain, never in the row, and reads back as the redaction marker.
39617
39906
  */
39618
- var LlmProfileKindSchema = _enum([
39619
- "openai-compatible",
39620
- "openai",
39621
- "anthropic",
39622
- "google",
39623
- "managed-local",
39624
- "apple-foundation"
39625
- ]);
39907
+ var LlmProviderConfigSchema = record(string(), unknown());
39626
39908
  var LlmProfileSchema = object({
39627
39909
  id: string(),
39628
39910
  name: string(),
39911
+ /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
39629
39912
  kind: LlmProfileKindSchema,
39630
39913
  /** Stamped by the provider — keeps the fanned catalog routable. */
39631
39914
  addonId: string(),
39632
39915
  enabled: boolean(),
39633
39916
  /** Vendor model id, or the managed runtime's loaded model. */
39634
39917
  model: string(),
39635
- /** Required for openai-compatible; override for cloud kinds. */
39636
- baseUrl: string().optional(),
39637
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
39638
- apiKey: string().optional(),
39639
39918
  /** Vision on/off. A vision call against a `false` profile is REFUSED, never
39640
39919
  * degraded to text — that shipped once and produced a confident answer to a
39641
39920
  * question about a picture nobody sent. */
@@ -39643,15 +39922,11 @@ var LlmProfileSchema = object({
39643
39922
  temperature: number().min(0).max(2).optional(),
39644
39923
  /** Nucleus sampling. Every wire we speak has it. */
39645
39924
  topP: number().min(0).max(1).optional(),
39646
- /** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
39647
- * wire does, and the client drops it there (measured: the request body gets
39648
- * `top_p` and no `top_k`). The profile editor hides the field wherever it
39649
- * would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
39925
+ /** Top-k sampling. Carried only by the wires that have it — a kind offers the
39926
+ * field in its editor only when its descriptor lists it in `profileFields`. */
39650
39927
  topK: number().int().positive().optional(),
39651
39928
  maxTokens: number().int().positive().optional(),
39652
- /** Prompt context window. Advisory for cloud kinds (they enforce their own);
39653
- * for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
39654
- * the model with, so it is the one field that changes a PROCESS. */
39929
+ /** Prompt context window. Advisory for cloud kinds (they enforce their own). */
39655
39930
  contextLength: number().int().positive().optional(),
39656
39931
  /** Default system prompt. A caller's `system` REPLACES it (never appends —
39657
39932
  * two system prompts fighting is worse than either alone). */
@@ -39677,16 +39952,37 @@ var LlmProfileSchema = object({
39677
39952
  * library; the REGISTRY of callable tools is ours and is empty in v1, so a
39678
39953
  * `true` here buys the wiring, not behaviour, until tools are registered. */
39679
39954
  toolsEnabled: boolean().default(false),
39680
- extraHeaders: record(string(), string()).optional(),
39681
- /** kind === 'managed-local' only (spec §4). */
39682
- runtime: ManagedRuntimeConfigSchema.optional(),
39683
- /**
39684
- * kind === 'apple-foundation' only: WHERE it runs — the only thing there is
39685
- * to configure (no key, no URL, no download; `model` is `apple-system`).
39686
- * `supportsVision` on such a row is stamped by the provider from the node's
39687
- * reported `imageInput`, never taken from the operator (D62).
39688
- */
39689
- appleFoundation: object({ nodeId: string() }).optional()
39955
+ /** Everything the kind's provider owns (endpoint, key, node, runtime…). */
39956
+ providerConfig: LlmProviderConfigSchema.default({})
39957
+ });
39958
+ /**
39959
+ * The common profile fields a kind's editor offers. The editor owns how each
39960
+ * one is drawn; the provider says which of them mean something on its wire.
39961
+ */
39962
+ var LlmProfileFieldSchema = _enum([
39963
+ "temperature",
39964
+ "topP",
39965
+ "topK",
39966
+ "maxTokens",
39967
+ "contextLength",
39968
+ "systemPrompt",
39969
+ "timeoutMs",
39970
+ "connectTimeoutMs",
39971
+ "firstTokenTimeoutMs",
39972
+ "idleTimeoutMs",
39973
+ "retry",
39974
+ "toolsEnabled"
39975
+ ]);
39976
+ /**
39977
+ * A provider-drawn part of the editor, by a generic widget id the admin UI
39978
+ * registers (`ai/apple-node`). `placement: 'model'` replaces the generic model
39979
+ * picker: that widget owns the model choice.
39980
+ */
39981
+ var LlmProviderWidgetSchema = object({
39982
+ id: string(),
39983
+ placement: _enum(["connection", "model"]),
39984
+ /** `providerConfig` keys this widget must fill before the profile can be saved. */
39985
+ requires: array(string()).optional()
39690
39986
  });
39691
39987
  /** ConfigUISchema tree passed through untyped on the wire (the
39692
39988
  * notification-output `ConfigSchemaPassthrough` precedent at
@@ -39695,11 +39991,56 @@ var ConfigSchemaPassthrough$3 = unknown();
39695
39991
  var LlmProfileKindDescriptorSchema = object({
39696
39992
  kind: LlmProfileKindSchema,
39697
39993
  label: string(),
39994
+ /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
39698
39995
  icon: string(),
39699
39996
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
39700
39997
  addonId: string(),
39701
- configSchema: ConfigSchemaPassthrough$3
39998
+ /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
39999
+ connectionSchema: ConfigSchemaPassthrough$3,
40000
+ /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
40001
+ advancedSchema: ConfigSchemaPassthrough$3.optional(),
40002
+ /** The kind's defaults; a model from `listModels` may override any of them. */
40003
+ features: LlmModelFeaturesSchema,
40004
+ /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
40005
+ visionEditable: boolean(),
40006
+ /** Where the model list comes from: `listModels`, `staticModels`, or nowhere. */
40007
+ modelCatalog: _enum([
40008
+ "fetch",
40009
+ "static",
40010
+ "none"
40011
+ ]),
40012
+ staticModels: array(LlmModelInfoSchema).optional(),
40013
+ /** The common fields that mean something on this kind's wire. */
40014
+ profileFields: array(LlmProfileFieldSchema),
40015
+ providerWidgets: array(LlmProviderWidgetSchema).optional()
40016
+ });
40017
+ /**
40018
+ * `listModels` input. `connection` is an UNSAVED draft of `providerConfig`
40019
+ * (the editor's form); with `profileId` too, a secret the draft leaves
40020
+ * untouched (absent or the redaction marker) is resolved server-side from the
40021
+ * stored profile — the browser never receives it.
40022
+ */
40023
+ var LlmListModelsInputSchema = object({
40024
+ addonId: string(),
40025
+ kind: LlmProfileKindSchema,
40026
+ profileId: string().optional(),
40027
+ connection: LlmProviderConfigSchema.optional()
39702
40028
  });
40029
+ var LlmListModelsErrorCodeSchema = _enum([
40030
+ "auth",
40031
+ "network",
40032
+ "unsupported",
40033
+ "invalid"
40034
+ ]);
40035
+ /** A RESULT, never a throw: "wrong key" is an answer the editor renders inline. */
40036
+ var LlmListModelsResultSchema = discriminatedUnion("ok", [object({
40037
+ ok: literal(true),
40038
+ models: array(LlmModelInfoSchema)
40039
+ }), object({
40040
+ ok: literal(false),
40041
+ code: LlmListModelsErrorCodeSchema,
40042
+ message: string()
40043
+ })]);
39703
40044
  var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
39704
40045
  var LlmDefaultSchema = object({
39705
40046
  selector: LlmDefaultSelectorSchema,
@@ -39799,7 +40140,10 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
39799
40140
  kind: "mutation",
39800
40141
  auth: "admin",
39801
40142
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39802
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
40143
+ }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
40144
+ kind: "mutation",
40145
+ auth: "admin"
40146
+ }), method(object({}), array(LlmDefaultSchema)), method(object({
39803
40147
  selector: LlmDefaultSelectorSchema,
39804
40148
  profileId: string().nullable()
39805
40149
  }), _void(), {
@@ -43863,202 +44207,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
43863
44207
  auth: "admin"
43864
44208
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
43865
44209
  /**
43866
- * Zod schemas for persisted record types.
43867
- *
43868
- * These schemas serve as the single source of truth for types that are
43869
- * stored in the settings-store backend and retrieved via tRPC. They
43870
- * replace the manual TypeScript interfaces with schema-derived types,
43871
- * enabling runtime validation when reading from the backend.
43872
- *
43873
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
43874
- * keeps the original name for backward compatibility.
43875
- */
43876
- /**
43877
- * Auth model (v2 — 2026-05-12 caps-only):
43878
- *
43879
- * Two principals:
43880
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
43881
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
43882
- *
43883
- * No role enum. There used to be `viewer / agent / scoped` and earlier
43884
- * `super_admin` — collapsed onto the single boolean because every
43885
- * non-admin caller is governed by the same scope-check rules; the
43886
- * distinction was only ever used to route role-specific procedures
43887
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
43888
- * with `isAdmin: false` + an explicit scope list.
43889
- */
43890
- /** Per-method access flavour. Materialised on every cap method via codegen. */
43891
- var MethodAccessSchema = _enum([
43892
- "view",
43893
- "create",
43894
- "delete"
43895
- ]);
43896
- /**
43897
- * A single scope grant. Three forms — checked in matcher with OR
43898
- * semantics; the first match decides whether the call passes:
43899
- *
43900
- * - `category` — broadest. `target: 'device' | 'system'` selects every
43901
- * cap with the matching `scope` declaration. New caps inherit grants
43902
- * automatically — adding a device cap to the codebase makes it
43903
- * reachable to every user with `category:device [...]` without a
43904
- * re-grant. Use this for "family viewer" / "operator" tiers.
43905
- *
43906
- * - `addon` — every cap that ships inside a given addon id. Niche;
43907
- * useful when an integration needs to interact with one specific
43908
- * addon's surface regardless of how many caps it exports.
43909
- *
43910
- * - `capability` — the most precise form. Single cap name. Use for
43911
- * integration tokens where you want to grant `addons.installPackage`
43912
- * and nothing else.
43913
- *
43914
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
43915
- * "give me everything" escape; there is no wildcard scope.
43916
- */
43917
- var AllowedProviderSchema = union([literal("*"), array(string())]);
43918
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
43919
- var CapScopeSchema = _enum(["device", "system"]);
43920
- /**
43921
- * DeviceSelector (scope model v3 — 2026-08-12).
43922
- *
43923
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
43924
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
43925
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
43926
- * AFTER the grant was minted — no re-grant, no re-login.
43927
- *
43928
- * - `all` — every device in the deployment. The broad viewer/operator
43929
- * lever without a `category` grant (a `category` grant also covers device
43930
- * caps that carry no deviceId; `all` is specifically the device set).
43931
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
43932
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
43933
- * is NOT covered until the grant is edited.
43934
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
43935
- * DYNAMIC. A device that changes type, or a new device of the type,
43936
- * re-resolves on the next request.
43937
- * - `locations` — every device whose operator-assigned `location` label is
43938
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
43939
- * null/unset location matches NO `locations` selector.
43940
- */
43941
- var DeviceSelectorSchema = discriminatedUnion("kind", [
43942
- object({ kind: literal("all") }),
43943
- object({
43944
- kind: literal("ids"),
43945
- ids: array(number().int()).min(1)
43946
- }),
43947
- object({
43948
- kind: literal("types"),
43949
- types: array(_enum(DeviceType)).min(1)
43950
- }),
43951
- object({
43952
- kind: literal("locations"),
43953
- locations: array(string().min(1)).min(1)
43954
- })
43955
- ]);
43956
- var DeviceTokenScopeSchema = object({
43957
- type: literal("device"),
43958
- /** The device SET this grant covers — resolved against the live fleet. */
43959
- selector: DeviceSelectorSchema,
43960
- access: array(MethodAccessSchema).min(1),
43961
- /**
43962
- * Whether a grant on a PARENT device transparently covers its accessory
43963
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
43964
- * Direction is parent → children ONLY.
43965
- *
43966
- * Absent → the matcher DERIVES it from the access flavour: `view`
43967
- * inherits (a camera viewer sees the camera's accessories), `create` /
43968
- * `delete` do NOT (actuating/removing a child is an explicit act the
43969
- * operator must grant on the child, not inherit from the parent). Set it
43970
- * explicitly to override that default per grant.
43971
- */
43972
- includeLinked: boolean().optional()
43973
- });
43974
- /**
43975
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
43976
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
43977
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
43978
- * EVERY parse path — stored records AND the JWT-carried scope arrays
43979
- * normalised at the request boundary ({@link normalizeTokenScopes} in
43980
- * `device-selector.ts`). Chosen over a one-time DB migration because a
43981
- * migration cannot reach a JWT already in a client's hands; parse-time
43982
- * migration covers both without a flag day. No cast — the raw object is read
43983
- * through `Reflect.get` (its static type is `unknown`).
43984
- */
43985
- function migrateLegacyTokenScope(raw) {
43986
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
43987
- if (Reflect.get(raw, "type") !== "device") return raw;
43988
- if (Reflect.get(raw, "selector") !== void 0) return raw;
43989
- const targets = Reflect.get(raw, "targets");
43990
- if (!Array.isArray(targets)) return raw;
43991
- return {
43992
- type: "device",
43993
- selector: {
43994
- kind: "ids",
43995
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
43996
- },
43997
- access: Reflect.get(raw, "access")
43998
- };
43999
- }
44000
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44001
- object({
44002
- type: literal("category"),
44003
- target: CapScopeSchema,
44004
- access: array(MethodAccessSchema).min(1)
44005
- }),
44006
- object({
44007
- type: literal("capability"),
44008
- target: string(),
44009
- access: array(MethodAccessSchema).min(1)
44010
- }),
44011
- object({
44012
- type: literal("addon"),
44013
- target: string(),
44014
- access: array(MethodAccessSchema).min(1)
44015
- }),
44016
- DeviceTokenScopeSchema
44017
- ]));
44018
- object({
44019
- id: string(),
44020
- username: string(),
44021
- passwordHash: string(),
44022
- /**
44023
- * Admin bypass. When true, the middleware skips the scope-access
44024
- * check entirely. There is no other axis of privilege; the legacy
44025
- * role enum collapsed onto this boolean in v2.
44026
- */
44027
- isAdmin: boolean().default(false),
44028
- allowedProviders: AllowedProviderSchema,
44029
- allowedDevices: AllowedDevicesSchema,
44030
- /**
44031
- * Scopes granted to this user. Admins bypass; their `scopes` is
44032
- * ignored. Non-admins without scopes are locked out of every
44033
- * protected call.
44034
- */
44035
- scopes: array(TokenScopeSchema).default([]),
44036
- createdAt: number(),
44037
- updatedAt: number()
44038
- });
44039
- object({
44040
- id: string(),
44041
- label: string(),
44042
- isAdmin: boolean().default(false),
44043
- allowedProviders: AllowedProviderSchema,
44044
- allowedDevices: AllowedDevicesSchema,
44045
- tokenHash: string(),
44046
- tokenPrefix: string(),
44047
- createdAt: number(),
44048
- lastUsedAt: number().optional()
44049
- });
44050
- object({
44051
- id: string(),
44052
- userId: string(),
44053
- name: string(),
44054
- tokenHash: string(),
44055
- tokenPrefix: string(),
44056
- scopes: array(TokenScopeSchema),
44057
- expiresAt: number().nullish(),
44058
- lastUsedAt: number().nullish(),
44059
- createdAt: number()
44060
- });
44061
- /**
44062
44210
  * `oauth-integration` — a collection cap by which an addon declares
44063
44211
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44064
44212
  * Each provider returns a static descriptor; the core enumerates them
@@ -61061,26 +61209,6 @@ var ApiKeySummarySchema = object({
61061
61209
  createdAt: number(),
61062
61210
  lastUsedAt: number().optional()
61063
61211
  });
61064
- var ScopedTokenSummarySchema = object({
61065
- id: string(),
61066
- userId: string(),
61067
- name: string(),
61068
- tokenPrefix: string(),
61069
- scopes: array(TokenScopeSchema),
61070
- expiresAt: number().nullish(),
61071
- lastUsedAt: number().nullish(),
61072
- createdAt: number()
61073
- });
61074
- var CreateScopedTokenInputSchema = object({
61075
- userId: string(),
61076
- name: string(),
61077
- scopes: array(TokenScopeSchema),
61078
- expiresAt: number().optional()
61079
- });
61080
- var CreateScopedTokenResultSchema = object({
61081
- token: string(),
61082
- record: ScopedTokenSummarySchema
61083
- });
61084
61212
  var OauthSessionSummarySchema = object({
61085
61213
  id: string(),
61086
61214
  userId: string(),
@@ -61102,11 +61230,11 @@ var TotpStatusSchema = object({
61102
61230
  confirmedAt: number().nullable()
61103
61231
  });
61104
61232
  /**
61105
- * user-management — singleton capability for user accounts, API keys,
61106
- * and scoped tokens.
61233
+ * user-management — singleton capability for user accounts and the
61234
+ * legacy API-key rows.
61107
61235
  *
61108
61236
  * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
61109
- * — the subset check on `setUserScopes` / `createScopedToken` is moot
61237
+ * — the subset check on `setUserScopes` is moot
61110
61238
  * because non-admins never reach these. If/when we open non-admin
61111
61239
  * delegation, structural caller-scope subset check goes inside the
61112
61240
  * provider.
@@ -61163,15 +61291,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
61163
61291
  kind: "mutation",
61164
61292
  auth: "admin",
61165
61293
  access: "delete"
61166
- }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
61167
- kind: "mutation",
61168
- auth: "admin",
61169
- access: "create"
61170
- }), method(object({ id: string() }), object({ success: literal(true) }), {
61171
- kind: "mutation",
61172
- auth: "admin",
61173
- access: "delete"
61174
- }), method(object({ token: string() }), ScopedTokenSummarySchema.nullable(), { access: "view" }), method(object({ userId: string() }), array(ScopedTokenSummarySchema), { auth: "admin" }), method(object({ userId: string() }), TotpSetupResultSchema, {
61294
+ }), method(object({ userId: string() }), TotpSetupResultSchema, {
61175
61295
  kind: "mutation",
61176
61296
  auth: "admin",
61177
61297
  access: "create"
@@ -65327,7 +65447,7 @@ Object.freeze({
65327
65447
  capName: "llm",
65328
65448
  capScope: "system",
65329
65449
  addonId: null,
65330
- access: "view"
65450
+ access: "create"
65331
65451
  },
65332
65452
  "llm.listNodeModels": {
65333
65453
  capName: "llm",
@@ -69991,12 +70111,6 @@ Object.freeze({
69991
70111
  addonId: null,
69992
70112
  access: "create"
69993
70113
  },
69994
- "userManagement.createScopedToken": {
69995
- capName: "user-management",
69996
- capScope: "system",
69997
- addonId: null,
69998
- access: "create"
69999
- },
70000
70114
  "userManagement.createUser": {
70001
70115
  capName: "user-management",
70002
70116
  capScope: "system",
@@ -70045,12 +70159,6 @@ Object.freeze({
70045
70159
  addonId: null,
70046
70160
  access: "view"
70047
70161
  },
70048
- "userManagement.listScopedTokens": {
70049
- capName: "user-management",
70050
- capScope: "system",
70051
- addonId: null,
70052
- access: "view"
70053
- },
70054
70162
  "userManagement.listUsers": {
70055
70163
  capName: "user-management",
70056
70164
  capScope: "system",
@@ -70105,12 +70213,6 @@ Object.freeze({
70105
70213
  addonId: null,
70106
70214
  access: "delete"
70107
70215
  },
70108
- "userManagement.revokeScopedToken": {
70109
- capName: "user-management",
70110
- capScope: "system",
70111
- addonId: null,
70112
- access: "delete"
70113
- },
70114
70216
  "userManagement.setupTotp": {
70115
70217
  capName: "user-management",
70116
70218
  capScope: "system",
@@ -70141,12 +70243,6 @@ Object.freeze({
70141
70243
  addonId: null,
70142
70244
  access: "view"
70143
70245
  },
70144
- "userManagement.validateScopedToken": {
70145
- capName: "user-management",
70146
- capScope: "system",
70147
- addonId: null,
70148
- access: "view"
70149
- },
70150
70246
  "userManagement.verifyTotp": {
70151
70247
  capName: "user-management",
70152
70248
  capScope: "system",