@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.
@@ -5449,7 +5449,7 @@ var ZodIssueCode = {
5449
5449
  var ZodFirstPartyTypeKind;
5450
5450
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5451
5451
  //#endregion
5452
- //#region ../types/dist/sleep-BxjU_fJM.mjs
5452
+ //#region ../types/dist/sleep-yKL5gfrH.mjs
5453
5453
  /**
5454
5454
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5455
5455
  * window to float samples (D455).
@@ -7831,6 +7831,12 @@ function normalizeAddonInitResult(result) {
7831
7831
  if (Array.isArray(result)) return { providers: result };
7832
7832
  return result;
7833
7833
  }
7834
+ /**
7835
+ * The share-view scope kinds a share-link token can carry. The hub mints
7836
+ * and validates them (`ShareViewGrantSchema` builds its
7837
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
7838
+ */
7839
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7834
7840
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7835
7841
  var PeerBytesTicketSchema = object({
7836
7842
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12711,6 +12717,280 @@ var ConvertResultSchema = object({
12711
12717
  function scopesAllowDeviceCap(scopes, access) {
12712
12718
  return scopes.some((s) => s.type === "category" && s.target === "device" && s.access.includes(access));
12713
12719
  }
12720
+ /**
12721
+ * Zod schemas for persisted record types.
12722
+ *
12723
+ * These schemas serve as the single source of truth for types that are
12724
+ * stored in the settings-store backend and retrieved via tRPC. They
12725
+ * replace the manual TypeScript interfaces with schema-derived types,
12726
+ * enabling runtime validation when reading from the backend.
12727
+ *
12728
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12729
+ * keeps the original name for backward compatibility.
12730
+ */
12731
+ /**
12732
+ * Auth model (v2 — 2026-05-12 caps-only):
12733
+ *
12734
+ * Two principals:
12735
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12736
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12737
+ *
12738
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12739
+ * `super_admin` — collapsed onto the single boolean because every
12740
+ * non-admin caller is governed by the same scope-check rules; the
12741
+ * distinction was only ever used to route role-specific procedures
12742
+ * which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
12743
+ * with `isAdmin: false` + an explicit scope list.
12744
+ */
12745
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12746
+ var MethodAccessSchema = _enum([
12747
+ "view",
12748
+ "create",
12749
+ "delete"
12750
+ ]);
12751
+ /**
12752
+ * A single scope grant. Three forms — checked in matcher with OR
12753
+ * semantics; the first match decides whether the call passes:
12754
+ *
12755
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12756
+ * cap with the matching `scope` declaration. New caps inherit grants
12757
+ * automatically — adding a device cap to the codebase makes it
12758
+ * reachable to every user with `category:device [...]` without a
12759
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12760
+ *
12761
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12762
+ * useful when an integration needs to interact with one specific
12763
+ * addon's surface regardless of how many caps it exports.
12764
+ *
12765
+ * - `capability` — the most precise form. Single cap name. Use for
12766
+ * integration tokens where you want to grant `addons.installPackage`
12767
+ * and nothing else.
12768
+ *
12769
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12770
+ * "give me everything" escape; there is no wildcard scope.
12771
+ */
12772
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12773
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12774
+ var CapScopeSchema = _enum(["device", "system"]);
12775
+ /**
12776
+ * DeviceSelector (scope model v3 — 2026-08-12).
12777
+ *
12778
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12779
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12780
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12781
+ * AFTER the grant was minted — no re-grant, no re-login.
12782
+ *
12783
+ * - `all` — every device in the deployment. The broad viewer/operator
12784
+ * lever without a `category` grant (a `category` grant also covers device
12785
+ * caps that carry no deviceId; `all` is specifically the device set).
12786
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
12787
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
12788
+ * is NOT covered until the grant is edited.
12789
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
12790
+ * DYNAMIC. A device that changes type, or a new device of the type,
12791
+ * re-resolves on the next request.
12792
+ * - `locations` — every device whose operator-assigned `location` label is
12793
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
12794
+ * null/unset location matches NO `locations` selector.
12795
+ */
12796
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
12797
+ object({ kind: literal("all") }),
12798
+ object({
12799
+ kind: literal("ids"),
12800
+ ids: array(number().int()).min(1)
12801
+ }),
12802
+ object({
12803
+ kind: literal("types"),
12804
+ types: array(_enum(DeviceType)).min(1)
12805
+ }),
12806
+ object({
12807
+ kind: literal("locations"),
12808
+ locations: array(string().min(1)).min(1)
12809
+ })
12810
+ ]);
12811
+ var DeviceTokenScopeSchema = object({
12812
+ type: literal("device"),
12813
+ /** The device SET this grant covers — resolved against the live fleet. */
12814
+ selector: DeviceSelectorSchema,
12815
+ access: array(MethodAccessSchema).min(1),
12816
+ /**
12817
+ * Whether a grant on a PARENT device transparently covers its accessory
12818
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
12819
+ * Direction is parent → children ONLY.
12820
+ *
12821
+ * Absent → the matcher DERIVES it from the access flavour: `view`
12822
+ * inherits (a camera viewer sees the camera's accessories), `create` /
12823
+ * `delete` do NOT (actuating/removing a child is an explicit act the
12824
+ * operator must grant on the child, not inherit from the parent). Set it
12825
+ * explicitly to override that default per grant.
12826
+ */
12827
+ includeLinked: boolean().optional()
12828
+ });
12829
+ /**
12830
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
12831
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
12832
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
12833
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
12834
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
12835
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
12836
+ * migration cannot reach a JWT already in a client's hands; parse-time
12837
+ * migration covers both without a flag day. No cast — the raw object is read
12838
+ * through `Reflect.get` (its static type is `unknown`).
12839
+ */
12840
+ function migrateLegacyTokenScope(raw) {
12841
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
12842
+ if (Reflect.get(raw, "type") !== "device") return raw;
12843
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
12844
+ const targets = Reflect.get(raw, "targets");
12845
+ if (!Array.isArray(targets)) return raw;
12846
+ return {
12847
+ type: "device",
12848
+ selector: {
12849
+ kind: "ids",
12850
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
12851
+ },
12852
+ access: Reflect.get(raw, "access")
12853
+ };
12854
+ }
12855
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
12856
+ object({
12857
+ type: literal("category"),
12858
+ target: CapScopeSchema,
12859
+ access: array(MethodAccessSchema).min(1)
12860
+ }),
12861
+ object({
12862
+ type: literal("capability"),
12863
+ target: string(),
12864
+ access: array(MethodAccessSchema).min(1)
12865
+ }),
12866
+ object({
12867
+ type: literal("addon"),
12868
+ target: string(),
12869
+ access: array(MethodAccessSchema).min(1)
12870
+ }),
12871
+ DeviceTokenScopeSchema
12872
+ ]));
12873
+ object({
12874
+ id: string(),
12875
+ username: string(),
12876
+ passwordHash: string(),
12877
+ /**
12878
+ * Admin bypass. When true, the middleware skips the scope-access
12879
+ * check entirely. There is no other axis of privilege; the legacy
12880
+ * role enum collapsed onto this boolean in v2.
12881
+ */
12882
+ isAdmin: boolean().default(false),
12883
+ allowedProviders: AllowedProviderSchema,
12884
+ allowedDevices: AllowedDevicesSchema,
12885
+ /**
12886
+ * Scopes granted to this user. Admins bypass; their `scopes` is
12887
+ * ignored. Non-admins without scopes are locked out of every
12888
+ * protected call.
12889
+ */
12890
+ scopes: array(TokenScopeSchema).default([]),
12891
+ createdAt: number(),
12892
+ updatedAt: number()
12893
+ });
12894
+ object({
12895
+ id: string(),
12896
+ label: string(),
12897
+ isAdmin: boolean().default(false),
12898
+ allowedProviders: AllowedProviderSchema,
12899
+ allowedDevices: AllowedDevicesSchema,
12900
+ tokenHash: string(),
12901
+ tokenPrefix: string(),
12902
+ createdAt: number(),
12903
+ lastUsedAt: number().optional()
12904
+ });
12905
+ object({
12906
+ id: string(),
12907
+ userId: string(),
12908
+ name: string(),
12909
+ tokenHash: string(),
12910
+ tokenPrefix: string(),
12911
+ scopes: array(TokenScopeSchema),
12912
+ expiresAt: number().nullish(),
12913
+ lastUsedAt: number().nullish(),
12914
+ createdAt: number()
12915
+ });
12916
+ /** What a share-view grant lets its holder see. */
12917
+ var ShareViewGrantSchema = object({
12918
+ kind: _enum(SHARE_VIEW_KINDS),
12919
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
12920
+ /** Talk-back, opt-in at mint time; absent means off. */
12921
+ talk: boolean().optional()
12922
+ });
12923
+ var ShareViewScopeSchema = object({
12924
+ type: literal("share-view"),
12925
+ grant: ShareViewGrantSchema
12926
+ });
12927
+ var AddonRoutesScopeSchema = object({
12928
+ type: literal("addon-routes"),
12929
+ access: array(MethodAccessSchema).min(1)
12930
+ });
12931
+ var PreferencesSelfScopeSchema = object({ type: literal("preferences-self") });
12932
+ var CredentialScopeSchema = union([
12933
+ literal("*"),
12934
+ ShareViewScopeSchema,
12935
+ AddonRoutesScopeSchema,
12936
+ PreferencesSelfScopeSchema,
12937
+ TokenScopeSchema
12938
+ ]);
12939
+ object({
12940
+ kind: literal("credential"),
12941
+ sub: string().min(1),
12942
+ jti: string().min(16),
12943
+ scopes: array(CredentialScopeSchema).min(1)
12944
+ });
12945
+ var PreferenceNamespaceSchema = string().regex(/^[a-z][a-z0-9.-]{0,63}$/);
12946
+ /** A namespace's value: a JSON object, opaque to the hub. */
12947
+ var PreferenceValueSchema = record(string(), unknown());
12948
+ var PreferenceDeviceIdSchema = string().min(1).max(64);
12949
+ /** A stored row, as the owner reads it. */
12950
+ var PreferenceRowSchema = object({
12951
+ namespace: PreferenceNamespaceSchema,
12952
+ value: PreferenceValueSchema,
12953
+ /** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
12954
+ revision: number().int().positive(),
12955
+ updatedAt: number().int(),
12956
+ /** The client id the last writer sent; `null` when it sent none. */
12957
+ updatedByDevice: PreferenceDeviceIdSchema.nullable()
12958
+ });
12959
+ object({
12960
+ /** Absent: every namespace the caller holds. */
12961
+ namespaces: array(PreferenceNamespaceSchema).max(32).optional() });
12962
+ object({ rows: array(PreferenceRowSchema) });
12963
+ object({
12964
+ namespace: PreferenceNamespaceSchema,
12965
+ value: PreferenceValueSchema,
12966
+ /**
12967
+ * The revision the edit was based on. Absent: last write wins. `0`: the
12968
+ * namespace must not exist yet. Any other value that is not the current
12969
+ * revision answers `conflict` and writes nothing.
12970
+ */
12971
+ baseRevision: number().int().nonnegative().optional(),
12972
+ deviceId: PreferenceDeviceIdSchema.optional()
12973
+ });
12974
+ discriminatedUnion("status", [object({
12975
+ status: literal("saved"),
12976
+ row: PreferenceRowSchema
12977
+ }), object({
12978
+ status: literal("conflict"),
12979
+ current: PreferenceRowSchema.nullable()
12980
+ })]);
12981
+ object({ namespace: PreferenceNamespaceSchema });
12982
+ object({
12983
+ /** `false` when the namespace did not exist. */
12984
+ deleted: boolean() });
12985
+ object({
12986
+ /** The revision the client holds per namespace; a namespace it does not list is new to it. */
12987
+ revisionByNamespace: record(PreferenceNamespaceSchema, number().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
12988
+ object({
12989
+ /** Every row whose revision differs from the client's, and every row it did not list. */
12990
+ rows: array(PreferenceRowSchema),
12991
+ /** Namespaces the client listed that no longer exist. */
12992
+ deleted: array(PreferenceNamespaceSchema)
12993
+ });
12714
12994
  _enum(["new-session", "step-up"]);
12715
12995
  /** The languages the hub's app landing pages are written in (D858). */
12716
12996
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -39633,38 +39913,37 @@ method(LlmRuntimeCompleteInputSchema, LlmGenerateResultSchema, {
39633
39913
  auth: "admin",
39634
39914
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39635
39915
  });
39916
+ var LlmProfileKindSchema = string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "a kind id is lower-case letters, digits and dashes");
39917
+ /** What a model (or, by default, every model of a kind) can do. */
39918
+ var LlmModelFeaturesSchema = object({
39919
+ vision: boolean(),
39920
+ tools: boolean(),
39921
+ streaming: boolean()
39922
+ });
39923
+ /** One model a provider offers. `features` overrides the kind's defaults, per field. */
39924
+ var LlmModelInfoSchema = object({
39925
+ id: string(),
39926
+ label: string().optional(),
39927
+ contextLength: number().int().positive().optional(),
39928
+ features: LlmModelFeaturesSchema.partial().optional()
39929
+ });
39636
39930
  /**
39637
- * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
39638
- * methods concat-fan across providers; single-row methods route to ONE
39639
- * provider by the `addonId` in the call input (the notification-output
39640
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
39641
- * (hub-placed); the cap stays open for future providers.
39642
- *
39643
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
39644
- * `apiKey` is a password field — providers REDACT it on read and merge on
39645
- * write; a stored key NEVER round-trips to a client.
39931
+ * The provider-specific part of a profile, validated by the provider that owns
39932
+ * the kind (`upsertProfile` refuses what it does not accept). A field its
39933
+ * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
39934
+ * keychain, never in the row, and reads back as the redaction marker.
39646
39935
  */
39647
- var LlmProfileKindSchema = _enum([
39648
- "openai-compatible",
39649
- "openai",
39650
- "anthropic",
39651
- "google",
39652
- "managed-local",
39653
- "apple-foundation"
39654
- ]);
39936
+ var LlmProviderConfigSchema = record(string(), unknown());
39655
39937
  var LlmProfileSchema = object({
39656
39938
  id: string(),
39657
39939
  name: string(),
39940
+ /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
39658
39941
  kind: LlmProfileKindSchema,
39659
39942
  /** Stamped by the provider — keeps the fanned catalog routable. */
39660
39943
  addonId: string(),
39661
39944
  enabled: boolean(),
39662
39945
  /** Vendor model id, or the managed runtime's loaded model. */
39663
39946
  model: string(),
39664
- /** Required for openai-compatible; override for cloud kinds. */
39665
- baseUrl: string().optional(),
39666
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
39667
- apiKey: string().optional(),
39668
39947
  /** Vision on/off. A vision call against a `false` profile is REFUSED, never
39669
39948
  * degraded to text — that shipped once and produced a confident answer to a
39670
39949
  * question about a picture nobody sent. */
@@ -39672,15 +39951,11 @@ var LlmProfileSchema = object({
39672
39951
  temperature: number().min(0).max(2).optional(),
39673
39952
  /** Nucleus sampling. Every wire we speak has it. */
39674
39953
  topP: number().min(0).max(1).optional(),
39675
- /** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
39676
- * wire does, and the client drops it there (measured: the request body gets
39677
- * `top_p` and no `top_k`). The profile editor hides the field wherever it
39678
- * would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
39954
+ /** Top-k sampling. Carried only by the wires that have it — a kind offers the
39955
+ * field in its editor only when its descriptor lists it in `profileFields`. */
39679
39956
  topK: number().int().positive().optional(),
39680
39957
  maxTokens: number().int().positive().optional(),
39681
- /** Prompt context window. Advisory for cloud kinds (they enforce their own);
39682
- * for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
39683
- * the model with, so it is the one field that changes a PROCESS. */
39958
+ /** Prompt context window. Advisory for cloud kinds (they enforce their own). */
39684
39959
  contextLength: number().int().positive().optional(),
39685
39960
  /** Default system prompt. A caller's `system` REPLACES it (never appends —
39686
39961
  * two system prompts fighting is worse than either alone). */
@@ -39706,16 +39981,37 @@ var LlmProfileSchema = object({
39706
39981
  * library; the REGISTRY of callable tools is ours and is empty in v1, so a
39707
39982
  * `true` here buys the wiring, not behaviour, until tools are registered. */
39708
39983
  toolsEnabled: boolean().default(false),
39709
- extraHeaders: record(string(), string()).optional(),
39710
- /** kind === 'managed-local' only (spec §4). */
39711
- runtime: ManagedRuntimeConfigSchema.optional(),
39712
- /**
39713
- * kind === 'apple-foundation' only: WHERE it runs — the only thing there is
39714
- * to configure (no key, no URL, no download; `model` is `apple-system`).
39715
- * `supportsVision` on such a row is stamped by the provider from the node's
39716
- * reported `imageInput`, never taken from the operator (D62).
39717
- */
39718
- appleFoundation: object({ nodeId: string() }).optional()
39984
+ /** Everything the kind's provider owns (endpoint, key, node, runtime…). */
39985
+ providerConfig: LlmProviderConfigSchema.default({})
39986
+ });
39987
+ /**
39988
+ * The common profile fields a kind's editor offers. The editor owns how each
39989
+ * one is drawn; the provider says which of them mean something on its wire.
39990
+ */
39991
+ var LlmProfileFieldSchema = _enum([
39992
+ "temperature",
39993
+ "topP",
39994
+ "topK",
39995
+ "maxTokens",
39996
+ "contextLength",
39997
+ "systemPrompt",
39998
+ "timeoutMs",
39999
+ "connectTimeoutMs",
40000
+ "firstTokenTimeoutMs",
40001
+ "idleTimeoutMs",
40002
+ "retry",
40003
+ "toolsEnabled"
40004
+ ]);
40005
+ /**
40006
+ * A provider-drawn part of the editor, by a generic widget id the admin UI
40007
+ * registers (`ai/apple-node`). `placement: 'model'` replaces the generic model
40008
+ * picker: that widget owns the model choice.
40009
+ */
40010
+ var LlmProviderWidgetSchema = object({
40011
+ id: string(),
40012
+ placement: _enum(["connection", "model"]),
40013
+ /** `providerConfig` keys this widget must fill before the profile can be saved. */
40014
+ requires: array(string()).optional()
39719
40015
  });
39720
40016
  /** ConfigUISchema tree passed through untyped on the wire (the
39721
40017
  * notification-output `ConfigSchemaPassthrough` precedent at
@@ -39724,11 +40020,56 @@ var ConfigSchemaPassthrough$3 = unknown();
39724
40020
  var LlmProfileKindDescriptorSchema = object({
39725
40021
  kind: LlmProfileKindSchema,
39726
40022
  label: string(),
40023
+ /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
39727
40024
  icon: string(),
39728
40025
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
39729
40026
  addonId: string(),
39730
- configSchema: ConfigSchemaPassthrough$3
40027
+ /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
40028
+ connectionSchema: ConfigSchemaPassthrough$3,
40029
+ /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
40030
+ advancedSchema: ConfigSchemaPassthrough$3.optional(),
40031
+ /** The kind's defaults; a model from `listModels` may override any of them. */
40032
+ features: LlmModelFeaturesSchema,
40033
+ /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
40034
+ visionEditable: boolean(),
40035
+ /** Where the model list comes from: `listModels`, `staticModels`, or nowhere. */
40036
+ modelCatalog: _enum([
40037
+ "fetch",
40038
+ "static",
40039
+ "none"
40040
+ ]),
40041
+ staticModels: array(LlmModelInfoSchema).optional(),
40042
+ /** The common fields that mean something on this kind's wire. */
40043
+ profileFields: array(LlmProfileFieldSchema),
40044
+ providerWidgets: array(LlmProviderWidgetSchema).optional()
40045
+ });
40046
+ /**
40047
+ * `listModels` input. `connection` is an UNSAVED draft of `providerConfig`
40048
+ * (the editor's form); with `profileId` too, a secret the draft leaves
40049
+ * untouched (absent or the redaction marker) is resolved server-side from the
40050
+ * stored profile — the browser never receives it.
40051
+ */
40052
+ var LlmListModelsInputSchema = object({
40053
+ addonId: string(),
40054
+ kind: LlmProfileKindSchema,
40055
+ profileId: string().optional(),
40056
+ connection: LlmProviderConfigSchema.optional()
39731
40057
  });
40058
+ var LlmListModelsErrorCodeSchema = _enum([
40059
+ "auth",
40060
+ "network",
40061
+ "unsupported",
40062
+ "invalid"
40063
+ ]);
40064
+ /** A RESULT, never a throw: "wrong key" is an answer the editor renders inline. */
40065
+ var LlmListModelsResultSchema = discriminatedUnion("ok", [object({
40066
+ ok: literal(true),
40067
+ models: array(LlmModelInfoSchema)
40068
+ }), object({
40069
+ ok: literal(false),
40070
+ code: LlmListModelsErrorCodeSchema,
40071
+ message: string()
40072
+ })]);
39732
40073
  var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
39733
40074
  var LlmDefaultSchema = object({
39734
40075
  selector: LlmDefaultSelectorSchema,
@@ -39828,7 +40169,10 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
39828
40169
  kind: "mutation",
39829
40170
  auth: "admin",
39830
40171
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39831
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
40172
+ }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
40173
+ kind: "mutation",
40174
+ auth: "admin"
40175
+ }), method(object({}), array(LlmDefaultSchema)), method(object({
39832
40176
  selector: LlmDefaultSelectorSchema,
39833
40177
  profileId: string().nullable()
39834
40178
  }), _void(), {
@@ -43892,202 +44236,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
43892
44236
  auth: "admin"
43893
44237
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
43894
44238
  /**
43895
- * Zod schemas for persisted record types.
43896
- *
43897
- * These schemas serve as the single source of truth for types that are
43898
- * stored in the settings-store backend and retrieved via tRPC. They
43899
- * replace the manual TypeScript interfaces with schema-derived types,
43900
- * enabling runtime validation when reading from the backend.
43901
- *
43902
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
43903
- * keeps the original name for backward compatibility.
43904
- */
43905
- /**
43906
- * Auth model (v2 — 2026-05-12 caps-only):
43907
- *
43908
- * Two principals:
43909
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
43910
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
43911
- *
43912
- * No role enum. There used to be `viewer / agent / scoped` and earlier
43913
- * `super_admin` — collapsed onto the single boolean because every
43914
- * non-admin caller is governed by the same scope-check rules; the
43915
- * distinction was only ever used to route role-specific procedures
43916
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
43917
- * with `isAdmin: false` + an explicit scope list.
43918
- */
43919
- /** Per-method access flavour. Materialised on every cap method via codegen. */
43920
- var MethodAccessSchema = _enum([
43921
- "view",
43922
- "create",
43923
- "delete"
43924
- ]);
43925
- /**
43926
- * A single scope grant. Three forms — checked in matcher with OR
43927
- * semantics; the first match decides whether the call passes:
43928
- *
43929
- * - `category` — broadest. `target: 'device' | 'system'` selects every
43930
- * cap with the matching `scope` declaration. New caps inherit grants
43931
- * automatically — adding a device cap to the codebase makes it
43932
- * reachable to every user with `category:device [...]` without a
43933
- * re-grant. Use this for "family viewer" / "operator" tiers.
43934
- *
43935
- * - `addon` — every cap that ships inside a given addon id. Niche;
43936
- * useful when an integration needs to interact with one specific
43937
- * addon's surface regardless of how many caps it exports.
43938
- *
43939
- * - `capability` — the most precise form. Single cap name. Use for
43940
- * integration tokens where you want to grant `addons.installPackage`
43941
- * and nothing else.
43942
- *
43943
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
43944
- * "give me everything" escape; there is no wildcard scope.
43945
- */
43946
- var AllowedProviderSchema = union([literal("*"), array(string())]);
43947
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
43948
- var CapScopeSchema = _enum(["device", "system"]);
43949
- /**
43950
- * DeviceSelector (scope model v3 — 2026-08-12).
43951
- *
43952
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
43953
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
43954
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
43955
- * AFTER the grant was minted — no re-grant, no re-login.
43956
- *
43957
- * - `all` — every device in the deployment. The broad viewer/operator
43958
- * lever without a `category` grant (a `category` grant also covers device
43959
- * caps that carry no deviceId; `all` is specifically the device set).
43960
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
43961
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
43962
- * is NOT covered until the grant is edited.
43963
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
43964
- * DYNAMIC. A device that changes type, or a new device of the type,
43965
- * re-resolves on the next request.
43966
- * - `locations` — every device whose operator-assigned `location` label is
43967
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
43968
- * null/unset location matches NO `locations` selector.
43969
- */
43970
- var DeviceSelectorSchema = discriminatedUnion("kind", [
43971
- object({ kind: literal("all") }),
43972
- object({
43973
- kind: literal("ids"),
43974
- ids: array(number().int()).min(1)
43975
- }),
43976
- object({
43977
- kind: literal("types"),
43978
- types: array(_enum(DeviceType)).min(1)
43979
- }),
43980
- object({
43981
- kind: literal("locations"),
43982
- locations: array(string().min(1)).min(1)
43983
- })
43984
- ]);
43985
- var DeviceTokenScopeSchema = object({
43986
- type: literal("device"),
43987
- /** The device SET this grant covers — resolved against the live fleet. */
43988
- selector: DeviceSelectorSchema,
43989
- access: array(MethodAccessSchema).min(1),
43990
- /**
43991
- * Whether a grant on a PARENT device transparently covers its accessory
43992
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
43993
- * Direction is parent → children ONLY.
43994
- *
43995
- * Absent → the matcher DERIVES it from the access flavour: `view`
43996
- * inherits (a camera viewer sees the camera's accessories), `create` /
43997
- * `delete` do NOT (actuating/removing a child is an explicit act the
43998
- * operator must grant on the child, not inherit from the parent). Set it
43999
- * explicitly to override that default per grant.
44000
- */
44001
- includeLinked: boolean().optional()
44002
- });
44003
- /**
44004
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44005
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44006
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44007
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44008
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44009
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44010
- * migration cannot reach a JWT already in a client's hands; parse-time
44011
- * migration covers both without a flag day. No cast — the raw object is read
44012
- * through `Reflect.get` (its static type is `unknown`).
44013
- */
44014
- function migrateLegacyTokenScope(raw) {
44015
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44016
- if (Reflect.get(raw, "type") !== "device") return raw;
44017
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44018
- const targets = Reflect.get(raw, "targets");
44019
- if (!Array.isArray(targets)) return raw;
44020
- return {
44021
- type: "device",
44022
- selector: {
44023
- kind: "ids",
44024
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44025
- },
44026
- access: Reflect.get(raw, "access")
44027
- };
44028
- }
44029
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44030
- object({
44031
- type: literal("category"),
44032
- target: CapScopeSchema,
44033
- access: array(MethodAccessSchema).min(1)
44034
- }),
44035
- object({
44036
- type: literal("capability"),
44037
- target: string(),
44038
- access: array(MethodAccessSchema).min(1)
44039
- }),
44040
- object({
44041
- type: literal("addon"),
44042
- target: string(),
44043
- access: array(MethodAccessSchema).min(1)
44044
- }),
44045
- DeviceTokenScopeSchema
44046
- ]));
44047
- object({
44048
- id: string(),
44049
- username: string(),
44050
- passwordHash: string(),
44051
- /**
44052
- * Admin bypass. When true, the middleware skips the scope-access
44053
- * check entirely. There is no other axis of privilege; the legacy
44054
- * role enum collapsed onto this boolean in v2.
44055
- */
44056
- isAdmin: boolean().default(false),
44057
- allowedProviders: AllowedProviderSchema,
44058
- allowedDevices: AllowedDevicesSchema,
44059
- /**
44060
- * Scopes granted to this user. Admins bypass; their `scopes` is
44061
- * ignored. Non-admins without scopes are locked out of every
44062
- * protected call.
44063
- */
44064
- scopes: array(TokenScopeSchema).default([]),
44065
- createdAt: number(),
44066
- updatedAt: number()
44067
- });
44068
- object({
44069
- id: string(),
44070
- label: string(),
44071
- isAdmin: boolean().default(false),
44072
- allowedProviders: AllowedProviderSchema,
44073
- allowedDevices: AllowedDevicesSchema,
44074
- tokenHash: string(),
44075
- tokenPrefix: string(),
44076
- createdAt: number(),
44077
- lastUsedAt: number().optional()
44078
- });
44079
- object({
44080
- id: string(),
44081
- userId: string(),
44082
- name: string(),
44083
- tokenHash: string(),
44084
- tokenPrefix: string(),
44085
- scopes: array(TokenScopeSchema),
44086
- expiresAt: number().nullish(),
44087
- lastUsedAt: number().nullish(),
44088
- createdAt: number()
44089
- });
44090
- /**
44091
44239
  * `oauth-integration` — a collection cap by which an addon declares
44092
44240
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44093
44241
  * Each provider returns a static descriptor; the core enumerates them
@@ -61090,26 +61238,6 @@ var ApiKeySummarySchema = object({
61090
61238
  createdAt: number(),
61091
61239
  lastUsedAt: number().optional()
61092
61240
  });
61093
- var ScopedTokenSummarySchema = object({
61094
- id: string(),
61095
- userId: string(),
61096
- name: string(),
61097
- tokenPrefix: string(),
61098
- scopes: array(TokenScopeSchema),
61099
- expiresAt: number().nullish(),
61100
- lastUsedAt: number().nullish(),
61101
- createdAt: number()
61102
- });
61103
- var CreateScopedTokenInputSchema = object({
61104
- userId: string(),
61105
- name: string(),
61106
- scopes: array(TokenScopeSchema),
61107
- expiresAt: number().optional()
61108
- });
61109
- var CreateScopedTokenResultSchema = object({
61110
- token: string(),
61111
- record: ScopedTokenSummarySchema
61112
- });
61113
61241
  var OauthSessionSummarySchema = object({
61114
61242
  id: string(),
61115
61243
  userId: string(),
@@ -61131,11 +61259,11 @@ var TotpStatusSchema = object({
61131
61259
  confirmedAt: number().nullable()
61132
61260
  });
61133
61261
  /**
61134
- * user-management — singleton capability for user accounts, API keys,
61135
- * and scoped tokens.
61262
+ * user-management — singleton capability for user accounts and the
61263
+ * legacy API-key rows.
61136
61264
  *
61137
61265
  * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
61138
- * — the subset check on `setUserScopes` / `createScopedToken` is moot
61266
+ * — the subset check on `setUserScopes` is moot
61139
61267
  * because non-admins never reach these. If/when we open non-admin
61140
61268
  * delegation, structural caller-scope subset check goes inside the
61141
61269
  * provider.
@@ -61192,15 +61320,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
61192
61320
  kind: "mutation",
61193
61321
  auth: "admin",
61194
61322
  access: "delete"
61195
- }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
61196
- kind: "mutation",
61197
- auth: "admin",
61198
- access: "create"
61199
- }), method(object({ id: string() }), object({ success: literal(true) }), {
61200
- kind: "mutation",
61201
- auth: "admin",
61202
- access: "delete"
61203
- }), method(object({ token: string() }), ScopedTokenSummarySchema.nullable(), { access: "view" }), method(object({ userId: string() }), array(ScopedTokenSummarySchema), { auth: "admin" }), method(object({ userId: string() }), TotpSetupResultSchema, {
61323
+ }), method(object({ userId: string() }), TotpSetupResultSchema, {
61204
61324
  kind: "mutation",
61205
61325
  auth: "admin",
61206
61326
  access: "create"
@@ -65356,7 +65476,7 @@ Object.freeze({
65356
65476
  capName: "llm",
65357
65477
  capScope: "system",
65358
65478
  addonId: null,
65359
- access: "view"
65479
+ access: "create"
65360
65480
  },
65361
65481
  "llm.listNodeModels": {
65362
65482
  capName: "llm",
@@ -70020,12 +70140,6 @@ Object.freeze({
70020
70140
  addonId: null,
70021
70141
  access: "create"
70022
70142
  },
70023
- "userManagement.createScopedToken": {
70024
- capName: "user-management",
70025
- capScope: "system",
70026
- addonId: null,
70027
- access: "create"
70028
- },
70029
70143
  "userManagement.createUser": {
70030
70144
  capName: "user-management",
70031
70145
  capScope: "system",
@@ -70074,12 +70188,6 @@ Object.freeze({
70074
70188
  addonId: null,
70075
70189
  access: "view"
70076
70190
  },
70077
- "userManagement.listScopedTokens": {
70078
- capName: "user-management",
70079
- capScope: "system",
70080
- addonId: null,
70081
- access: "view"
70082
- },
70083
70191
  "userManagement.listUsers": {
70084
70192
  capName: "user-management",
70085
70193
  capScope: "system",
@@ -70134,12 +70242,6 @@ Object.freeze({
70134
70242
  addonId: null,
70135
70243
  access: "delete"
70136
70244
  },
70137
- "userManagement.revokeScopedToken": {
70138
- capName: "user-management",
70139
- capScope: "system",
70140
- addonId: null,
70141
- access: "delete"
70142
- },
70143
70245
  "userManagement.setupTotp": {
70144
70246
  capName: "user-management",
70145
70247
  capScope: "system",
@@ -70170,12 +70272,6 @@ Object.freeze({
70170
70272
  addonId: null,
70171
70273
  access: "view"
70172
70274
  },
70173
- "userManagement.validateScopedToken": {
70174
- capName: "user-management",
70175
- capScope: "system",
70176
- addonId: null,
70177
- access: "view"
70178
- },
70179
70275
  "userManagement.verifyTotp": {
70180
70276
  capName: "user-management",
70181
70277
  capScope: "system",