@camstack/addon-waste-collections 0.1.10 → 0.1.12

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.
@@ -5554,7 +5554,7 @@ var ZodIssueCode = {
5554
5554
  var ZodFirstPartyTypeKind;
5555
5555
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5556
5556
  //#endregion
5557
- //#region ../types/dist/sleep-BxjU_fJM.mjs
5557
+ //#region ../types/dist/sleep-yKL5gfrH.mjs
5558
5558
  /**
5559
5559
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5560
5560
  * window to float samples (D455).
@@ -7946,6 +7946,12 @@ function normalizeAddonInitResult(result) {
7946
7946
  if (Array.isArray(result)) return { providers: result };
7947
7947
  return result;
7948
7948
  }
7949
+ /**
7950
+ * The share-view scope kinds a share-link token can carry. The hub mints
7951
+ * and validates them (`ShareViewGrantSchema` builds its
7952
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
7953
+ */
7954
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7949
7955
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7950
7956
  var PeerBytesTicketSchema = object({
7951
7957
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12818,6 +12824,280 @@ var ConvertResultSchema = object({
12818
12824
  files: array(string()).readonly()
12819
12825
  })).readonly()
12820
12826
  });
12827
+ /**
12828
+ * Zod schemas for persisted record types.
12829
+ *
12830
+ * These schemas serve as the single source of truth for types that are
12831
+ * stored in the settings-store backend and retrieved via tRPC. They
12832
+ * replace the manual TypeScript interfaces with schema-derived types,
12833
+ * enabling runtime validation when reading from the backend.
12834
+ *
12835
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12836
+ * keeps the original name for backward compatibility.
12837
+ */
12838
+ /**
12839
+ * Auth model (v2 — 2026-05-12 caps-only):
12840
+ *
12841
+ * Two principals:
12842
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12843
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12844
+ *
12845
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12846
+ * `super_admin` — collapsed onto the single boolean because every
12847
+ * non-admin caller is governed by the same scope-check rules; the
12848
+ * distinction was only ever used to route role-specific procedures
12849
+ * which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
12850
+ * with `isAdmin: false` + an explicit scope list.
12851
+ */
12852
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12853
+ var MethodAccessSchema = _enum([
12854
+ "view",
12855
+ "create",
12856
+ "delete"
12857
+ ]);
12858
+ /**
12859
+ * A single scope grant. Three forms — checked in matcher with OR
12860
+ * semantics; the first match decides whether the call passes:
12861
+ *
12862
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12863
+ * cap with the matching `scope` declaration. New caps inherit grants
12864
+ * automatically — adding a device cap to the codebase makes it
12865
+ * reachable to every user with `category:device [...]` without a
12866
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12867
+ *
12868
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12869
+ * useful when an integration needs to interact with one specific
12870
+ * addon's surface regardless of how many caps it exports.
12871
+ *
12872
+ * - `capability` — the most precise form. Single cap name. Use for
12873
+ * integration tokens where you want to grant `addons.installPackage`
12874
+ * and nothing else.
12875
+ *
12876
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12877
+ * "give me everything" escape; there is no wildcard scope.
12878
+ */
12879
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12880
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12881
+ var CapScopeSchema = _enum(["device", "system"]);
12882
+ /**
12883
+ * DeviceSelector (scope model v3 — 2026-08-12).
12884
+ *
12885
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12886
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12887
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12888
+ * AFTER the grant was minted — no re-grant, no re-login.
12889
+ *
12890
+ * - `all` — every device in the deployment. The broad viewer/operator
12891
+ * lever without a `category` grant (a `category` grant also covers device
12892
+ * caps that carry no deviceId; `all` is specifically the device set).
12893
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
12894
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
12895
+ * is NOT covered until the grant is edited.
12896
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
12897
+ * DYNAMIC. A device that changes type, or a new device of the type,
12898
+ * re-resolves on the next request.
12899
+ * - `locations` — every device whose operator-assigned `location` label is
12900
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
12901
+ * null/unset location matches NO `locations` selector.
12902
+ */
12903
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
12904
+ object({ kind: literal("all") }),
12905
+ object({
12906
+ kind: literal("ids"),
12907
+ ids: array(number().int()).min(1)
12908
+ }),
12909
+ object({
12910
+ kind: literal("types"),
12911
+ types: array(_enum(DeviceType)).min(1)
12912
+ }),
12913
+ object({
12914
+ kind: literal("locations"),
12915
+ locations: array(string().min(1)).min(1)
12916
+ })
12917
+ ]);
12918
+ var DeviceTokenScopeSchema = object({
12919
+ type: literal("device"),
12920
+ /** The device SET this grant covers — resolved against the live fleet. */
12921
+ selector: DeviceSelectorSchema,
12922
+ access: array(MethodAccessSchema).min(1),
12923
+ /**
12924
+ * Whether a grant on a PARENT device transparently covers its accessory
12925
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
12926
+ * Direction is parent → children ONLY.
12927
+ *
12928
+ * Absent → the matcher DERIVES it from the access flavour: `view`
12929
+ * inherits (a camera viewer sees the camera's accessories), `create` /
12930
+ * `delete` do NOT (actuating/removing a child is an explicit act the
12931
+ * operator must grant on the child, not inherit from the parent). Set it
12932
+ * explicitly to override that default per grant.
12933
+ */
12934
+ includeLinked: boolean().optional()
12935
+ });
12936
+ /**
12937
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
12938
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
12939
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
12940
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
12941
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
12942
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
12943
+ * migration cannot reach a JWT already in a client's hands; parse-time
12944
+ * migration covers both without a flag day. No cast — the raw object is read
12945
+ * through `Reflect.get` (its static type is `unknown`).
12946
+ */
12947
+ function migrateLegacyTokenScope(raw) {
12948
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
12949
+ if (Reflect.get(raw, "type") !== "device") return raw;
12950
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
12951
+ const targets = Reflect.get(raw, "targets");
12952
+ if (!Array.isArray(targets)) return raw;
12953
+ return {
12954
+ type: "device",
12955
+ selector: {
12956
+ kind: "ids",
12957
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
12958
+ },
12959
+ access: Reflect.get(raw, "access")
12960
+ };
12961
+ }
12962
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
12963
+ object({
12964
+ type: literal("category"),
12965
+ target: CapScopeSchema,
12966
+ access: array(MethodAccessSchema).min(1)
12967
+ }),
12968
+ object({
12969
+ type: literal("capability"),
12970
+ target: string(),
12971
+ access: array(MethodAccessSchema).min(1)
12972
+ }),
12973
+ object({
12974
+ type: literal("addon"),
12975
+ target: string(),
12976
+ access: array(MethodAccessSchema).min(1)
12977
+ }),
12978
+ DeviceTokenScopeSchema
12979
+ ]));
12980
+ object({
12981
+ id: string(),
12982
+ username: string(),
12983
+ passwordHash: string(),
12984
+ /**
12985
+ * Admin bypass. When true, the middleware skips the scope-access
12986
+ * check entirely. There is no other axis of privilege; the legacy
12987
+ * role enum collapsed onto this boolean in v2.
12988
+ */
12989
+ isAdmin: boolean().default(false),
12990
+ allowedProviders: AllowedProviderSchema,
12991
+ allowedDevices: AllowedDevicesSchema,
12992
+ /**
12993
+ * Scopes granted to this user. Admins bypass; their `scopes` is
12994
+ * ignored. Non-admins without scopes are locked out of every
12995
+ * protected call.
12996
+ */
12997
+ scopes: array(TokenScopeSchema).default([]),
12998
+ createdAt: number(),
12999
+ updatedAt: number()
13000
+ });
13001
+ object({
13002
+ id: string(),
13003
+ label: string(),
13004
+ isAdmin: boolean().default(false),
13005
+ allowedProviders: AllowedProviderSchema,
13006
+ allowedDevices: AllowedDevicesSchema,
13007
+ tokenHash: string(),
13008
+ tokenPrefix: string(),
13009
+ createdAt: number(),
13010
+ lastUsedAt: number().optional()
13011
+ });
13012
+ object({
13013
+ id: string(),
13014
+ userId: string(),
13015
+ name: string(),
13016
+ tokenHash: string(),
13017
+ tokenPrefix: string(),
13018
+ scopes: array(TokenScopeSchema),
13019
+ expiresAt: number().nullish(),
13020
+ lastUsedAt: number().nullish(),
13021
+ createdAt: number()
13022
+ });
13023
+ /** What a share-view grant lets its holder see. */
13024
+ var ShareViewGrantSchema = object({
13025
+ kind: _enum(SHARE_VIEW_KINDS),
13026
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
13027
+ /** Talk-back, opt-in at mint time; absent means off. */
13028
+ talk: boolean().optional()
13029
+ });
13030
+ var ShareViewScopeSchema = object({
13031
+ type: literal("share-view"),
13032
+ grant: ShareViewGrantSchema
13033
+ });
13034
+ var AddonRoutesScopeSchema = object({
13035
+ type: literal("addon-routes"),
13036
+ access: array(MethodAccessSchema).min(1)
13037
+ });
13038
+ var PreferencesSelfScopeSchema = object({ type: literal("preferences-self") });
13039
+ var CredentialScopeSchema = union([
13040
+ literal("*"),
13041
+ ShareViewScopeSchema,
13042
+ AddonRoutesScopeSchema,
13043
+ PreferencesSelfScopeSchema,
13044
+ TokenScopeSchema
13045
+ ]);
13046
+ object({
13047
+ kind: literal("credential"),
13048
+ sub: string().min(1),
13049
+ jti: string().min(16),
13050
+ scopes: array(CredentialScopeSchema).min(1)
13051
+ });
13052
+ var PreferenceNamespaceSchema = string().regex(/^[a-z][a-z0-9.-]{0,63}$/);
13053
+ /** A namespace's value: a JSON object, opaque to the hub. */
13054
+ var PreferenceValueSchema = record(string(), unknown());
13055
+ var PreferenceDeviceIdSchema = string().min(1).max(64);
13056
+ /** A stored row, as the owner reads it. */
13057
+ var PreferenceRowSchema = object({
13058
+ namespace: PreferenceNamespaceSchema,
13059
+ value: PreferenceValueSchema,
13060
+ /** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
13061
+ revision: number().int().positive(),
13062
+ updatedAt: number().int(),
13063
+ /** The client id the last writer sent; `null` when it sent none. */
13064
+ updatedByDevice: PreferenceDeviceIdSchema.nullable()
13065
+ });
13066
+ object({
13067
+ /** Absent: every namespace the caller holds. */
13068
+ namespaces: array(PreferenceNamespaceSchema).max(32).optional() });
13069
+ object({ rows: array(PreferenceRowSchema) });
13070
+ object({
13071
+ namespace: PreferenceNamespaceSchema,
13072
+ value: PreferenceValueSchema,
13073
+ /**
13074
+ * The revision the edit was based on. Absent: last write wins. `0`: the
13075
+ * namespace must not exist yet. Any other value that is not the current
13076
+ * revision answers `conflict` and writes nothing.
13077
+ */
13078
+ baseRevision: number().int().nonnegative().optional(),
13079
+ deviceId: PreferenceDeviceIdSchema.optional()
13080
+ });
13081
+ discriminatedUnion("status", [object({
13082
+ status: literal("saved"),
13083
+ row: PreferenceRowSchema
13084
+ }), object({
13085
+ status: literal("conflict"),
13086
+ current: PreferenceRowSchema.nullable()
13087
+ })]);
13088
+ object({ namespace: PreferenceNamespaceSchema });
13089
+ object({
13090
+ /** `false` when the namespace did not exist. */
13091
+ deleted: boolean() });
13092
+ object({
13093
+ /** The revision the client holds per namespace; a namespace it does not list is new to it. */
13094
+ revisionByNamespace: record(PreferenceNamespaceSchema, number().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
13095
+ object({
13096
+ /** Every row whose revision differs from the client's, and every row it did not list. */
13097
+ rows: array(PreferenceRowSchema),
13098
+ /** Namespaces the client listed that no longer exist. */
13099
+ deleted: array(PreferenceNamespaceSchema)
13100
+ });
12821
13101
  _enum(["new-session", "step-up"]);
12822
13102
  /** The languages the hub's app landing pages are written in (D858). */
12823
13103
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -39696,38 +39976,37 @@ method(LlmRuntimeCompleteInputSchema, LlmGenerateResultSchema, {
39696
39976
  auth: "admin",
39697
39977
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39698
39978
  });
39979
+ var LlmProfileKindSchema = string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "a kind id is lower-case letters, digits and dashes");
39980
+ /** What a model (or, by default, every model of a kind) can do. */
39981
+ var LlmModelFeaturesSchema = object({
39982
+ vision: boolean(),
39983
+ tools: boolean(),
39984
+ streaming: boolean()
39985
+ });
39986
+ /** One model a provider offers. `features` overrides the kind's defaults, per field. */
39987
+ var LlmModelInfoSchema = object({
39988
+ id: string(),
39989
+ label: string().optional(),
39990
+ contextLength: number().int().positive().optional(),
39991
+ features: LlmModelFeaturesSchema.partial().optional()
39992
+ });
39699
39993
  /**
39700
- * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
39701
- * methods concat-fan across providers; single-row methods route to ONE
39702
- * provider by the `addonId` in the call input (the notification-output
39703
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
39704
- * (hub-placed); the cap stays open for future providers.
39705
- *
39706
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
39707
- * `apiKey` is a password field — providers REDACT it on read and merge on
39708
- * write; a stored key NEVER round-trips to a client.
39994
+ * The provider-specific part of a profile, validated by the provider that owns
39995
+ * the kind (`upsertProfile` refuses what it does not accept). A field its
39996
+ * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
39997
+ * keychain, never in the row, and reads back as the redaction marker.
39709
39998
  */
39710
- var LlmProfileKindSchema = _enum([
39711
- "openai-compatible",
39712
- "openai",
39713
- "anthropic",
39714
- "google",
39715
- "managed-local",
39716
- "apple-foundation"
39717
- ]);
39999
+ var LlmProviderConfigSchema = record(string(), unknown());
39718
40000
  var LlmProfileSchema = object({
39719
40001
  id: string(),
39720
40002
  name: string(),
40003
+ /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
39721
40004
  kind: LlmProfileKindSchema,
39722
40005
  /** Stamped by the provider — keeps the fanned catalog routable. */
39723
40006
  addonId: string(),
39724
40007
  enabled: boolean(),
39725
40008
  /** Vendor model id, or the managed runtime's loaded model. */
39726
40009
  model: string(),
39727
- /** Required for openai-compatible; override for cloud kinds. */
39728
- baseUrl: string().optional(),
39729
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
39730
- apiKey: string().optional(),
39731
40010
  /** Vision on/off. A vision call against a `false` profile is REFUSED, never
39732
40011
  * degraded to text — that shipped once and produced a confident answer to a
39733
40012
  * question about a picture nobody sent. */
@@ -39735,15 +40014,11 @@ var LlmProfileSchema = object({
39735
40014
  temperature: number().min(0).max(2).optional(),
39736
40015
  /** Nucleus sampling. Every wire we speak has it. */
39737
40016
  topP: number().min(0).max(1).optional(),
39738
- /** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
39739
- * wire does, and the client drops it there (measured: the request body gets
39740
- * `top_p` and no `top_k`). The profile editor hides the field wherever it
39741
- * would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
40017
+ /** Top-k sampling. Carried only by the wires that have it — a kind offers the
40018
+ * field in its editor only when its descriptor lists it in `profileFields`. */
39742
40019
  topK: number().int().positive().optional(),
39743
40020
  maxTokens: number().int().positive().optional(),
39744
- /** Prompt context window. Advisory for cloud kinds (they enforce their own);
39745
- * for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
39746
- * the model with, so it is the one field that changes a PROCESS. */
40021
+ /** Prompt context window. Advisory for cloud kinds (they enforce their own). */
39747
40022
  contextLength: number().int().positive().optional(),
39748
40023
  /** Default system prompt. A caller's `system` REPLACES it (never appends —
39749
40024
  * two system prompts fighting is worse than either alone). */
@@ -39769,16 +40044,37 @@ var LlmProfileSchema = object({
39769
40044
  * library; the REGISTRY of callable tools is ours and is empty in v1, so a
39770
40045
  * `true` here buys the wiring, not behaviour, until tools are registered. */
39771
40046
  toolsEnabled: boolean().default(false),
39772
- extraHeaders: record(string(), string()).optional(),
39773
- /** kind === 'managed-local' only (spec §4). */
39774
- runtime: ManagedRuntimeConfigSchema.optional(),
39775
- /**
39776
- * kind === 'apple-foundation' only: WHERE it runs — the only thing there is
39777
- * to configure (no key, no URL, no download; `model` is `apple-system`).
39778
- * `supportsVision` on such a row is stamped by the provider from the node's
39779
- * reported `imageInput`, never taken from the operator (D62).
39780
- */
39781
- appleFoundation: object({ nodeId: string() }).optional()
40047
+ /** Everything the kind's provider owns (endpoint, key, node, runtime…). */
40048
+ providerConfig: LlmProviderConfigSchema.default({})
40049
+ });
40050
+ /**
40051
+ * The common profile fields a kind's editor offers. The editor owns how each
40052
+ * one is drawn; the provider says which of them mean something on its wire.
40053
+ */
40054
+ var LlmProfileFieldSchema = _enum([
40055
+ "temperature",
40056
+ "topP",
40057
+ "topK",
40058
+ "maxTokens",
40059
+ "contextLength",
40060
+ "systemPrompt",
40061
+ "timeoutMs",
40062
+ "connectTimeoutMs",
40063
+ "firstTokenTimeoutMs",
40064
+ "idleTimeoutMs",
40065
+ "retry",
40066
+ "toolsEnabled"
40067
+ ]);
40068
+ /**
40069
+ * A provider-drawn part of the editor, by a generic widget id the admin UI
40070
+ * registers (`ai/apple-node`). `placement: 'model'` replaces the generic model
40071
+ * picker: that widget owns the model choice.
40072
+ */
40073
+ var LlmProviderWidgetSchema = object({
40074
+ id: string(),
40075
+ placement: _enum(["connection", "model"]),
40076
+ /** `providerConfig` keys this widget must fill before the profile can be saved. */
40077
+ requires: array(string()).optional()
39782
40078
  });
39783
40079
  /** ConfigUISchema tree passed through untyped on the wire (the
39784
40080
  * notification-output `ConfigSchemaPassthrough` precedent at
@@ -39787,11 +40083,56 @@ var ConfigSchemaPassthrough$3 = unknown();
39787
40083
  var LlmProfileKindDescriptorSchema = object({
39788
40084
  kind: LlmProfileKindSchema,
39789
40085
  label: string(),
40086
+ /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
39790
40087
  icon: string(),
39791
40088
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
39792
40089
  addonId: string(),
39793
- configSchema: ConfigSchemaPassthrough$3
40090
+ /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
40091
+ connectionSchema: ConfigSchemaPassthrough$3,
40092
+ /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
40093
+ advancedSchema: ConfigSchemaPassthrough$3.optional(),
40094
+ /** The kind's defaults; a model from `listModels` may override any of them. */
40095
+ features: LlmModelFeaturesSchema,
40096
+ /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
40097
+ visionEditable: boolean(),
40098
+ /** Where the model list comes from: `listModels`, `staticModels`, or nowhere. */
40099
+ modelCatalog: _enum([
40100
+ "fetch",
40101
+ "static",
40102
+ "none"
40103
+ ]),
40104
+ staticModels: array(LlmModelInfoSchema).optional(),
40105
+ /** The common fields that mean something on this kind's wire. */
40106
+ profileFields: array(LlmProfileFieldSchema),
40107
+ providerWidgets: array(LlmProviderWidgetSchema).optional()
40108
+ });
40109
+ /**
40110
+ * `listModels` input. `connection` is an UNSAVED draft of `providerConfig`
40111
+ * (the editor's form); with `profileId` too, a secret the draft leaves
40112
+ * untouched (absent or the redaction marker) is resolved server-side from the
40113
+ * stored profile — the browser never receives it.
40114
+ */
40115
+ var LlmListModelsInputSchema = object({
40116
+ addonId: string(),
40117
+ kind: LlmProfileKindSchema,
40118
+ profileId: string().optional(),
40119
+ connection: LlmProviderConfigSchema.optional()
39794
40120
  });
40121
+ var LlmListModelsErrorCodeSchema = _enum([
40122
+ "auth",
40123
+ "network",
40124
+ "unsupported",
40125
+ "invalid"
40126
+ ]);
40127
+ /** A RESULT, never a throw: "wrong key" is an answer the editor renders inline. */
40128
+ var LlmListModelsResultSchema = discriminatedUnion("ok", [object({
40129
+ ok: literal(true),
40130
+ models: array(LlmModelInfoSchema)
40131
+ }), object({
40132
+ ok: literal(false),
40133
+ code: LlmListModelsErrorCodeSchema,
40134
+ message: string()
40135
+ })]);
39795
40136
  var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
39796
40137
  var LlmDefaultSchema = object({
39797
40138
  selector: LlmDefaultSelectorSchema,
@@ -39891,7 +40232,10 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
39891
40232
  kind: "mutation",
39892
40233
  auth: "admin",
39893
40234
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39894
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
40235
+ }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
40236
+ kind: "mutation",
40237
+ auth: "admin"
40238
+ }), method(object({}), array(LlmDefaultSchema)), method(object({
39895
40239
  selector: LlmDefaultSelectorSchema,
39896
40240
  profileId: string().nullable()
39897
40241
  }), _void(), {
@@ -43955,202 +44299,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
43955
44299
  auth: "admin"
43956
44300
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
43957
44301
  /**
43958
- * Zod schemas for persisted record types.
43959
- *
43960
- * These schemas serve as the single source of truth for types that are
43961
- * stored in the settings-store backend and retrieved via tRPC. They
43962
- * replace the manual TypeScript interfaces with schema-derived types,
43963
- * enabling runtime validation when reading from the backend.
43964
- *
43965
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
43966
- * keeps the original name for backward compatibility.
43967
- */
43968
- /**
43969
- * Auth model (v2 — 2026-05-12 caps-only):
43970
- *
43971
- * Two principals:
43972
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
43973
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
43974
- *
43975
- * No role enum. There used to be `viewer / agent / scoped` and earlier
43976
- * `super_admin` — collapsed onto the single boolean because every
43977
- * non-admin caller is governed by the same scope-check rules; the
43978
- * distinction was only ever used to route role-specific procedures
43979
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
43980
- * with `isAdmin: false` + an explicit scope list.
43981
- */
43982
- /** Per-method access flavour. Materialised on every cap method via codegen. */
43983
- var MethodAccessSchema = _enum([
43984
- "view",
43985
- "create",
43986
- "delete"
43987
- ]);
43988
- /**
43989
- * A single scope grant. Three forms — checked in matcher with OR
43990
- * semantics; the first match decides whether the call passes:
43991
- *
43992
- * - `category` — broadest. `target: 'device' | 'system'` selects every
43993
- * cap with the matching `scope` declaration. New caps inherit grants
43994
- * automatically — adding a device cap to the codebase makes it
43995
- * reachable to every user with `category:device [...]` without a
43996
- * re-grant. Use this for "family viewer" / "operator" tiers.
43997
- *
43998
- * - `addon` — every cap that ships inside a given addon id. Niche;
43999
- * useful when an integration needs to interact with one specific
44000
- * addon's surface regardless of how many caps it exports.
44001
- *
44002
- * - `capability` — the most precise form. Single cap name. Use for
44003
- * integration tokens where you want to grant `addons.installPackage`
44004
- * and nothing else.
44005
- *
44006
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44007
- * "give me everything" escape; there is no wildcard scope.
44008
- */
44009
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44010
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44011
- var CapScopeSchema = _enum(["device", "system"]);
44012
- /**
44013
- * DeviceSelector (scope model v3 — 2026-08-12).
44014
- *
44015
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44016
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44017
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44018
- * AFTER the grant was minted — no re-grant, no re-login.
44019
- *
44020
- * - `all` — every device in the deployment. The broad viewer/operator
44021
- * lever without a `category` grant (a `category` grant also covers device
44022
- * caps that carry no deviceId; `all` is specifically the device set).
44023
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44024
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44025
- * is NOT covered until the grant is edited.
44026
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44027
- * DYNAMIC. A device that changes type, or a new device of the type,
44028
- * re-resolves on the next request.
44029
- * - `locations` — every device whose operator-assigned `location` label is
44030
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44031
- * null/unset location matches NO `locations` selector.
44032
- */
44033
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44034
- object({ kind: literal("all") }),
44035
- object({
44036
- kind: literal("ids"),
44037
- ids: array(number().int()).min(1)
44038
- }),
44039
- object({
44040
- kind: literal("types"),
44041
- types: array(_enum(DeviceType)).min(1)
44042
- }),
44043
- object({
44044
- kind: literal("locations"),
44045
- locations: array(string().min(1)).min(1)
44046
- })
44047
- ]);
44048
- var DeviceTokenScopeSchema = object({
44049
- type: literal("device"),
44050
- /** The device SET this grant covers — resolved against the live fleet. */
44051
- selector: DeviceSelectorSchema,
44052
- access: array(MethodAccessSchema).min(1),
44053
- /**
44054
- * Whether a grant on a PARENT device transparently covers its accessory
44055
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44056
- * Direction is parent → children ONLY.
44057
- *
44058
- * Absent → the matcher DERIVES it from the access flavour: `view`
44059
- * inherits (a camera viewer sees the camera's accessories), `create` /
44060
- * `delete` do NOT (actuating/removing a child is an explicit act the
44061
- * operator must grant on the child, not inherit from the parent). Set it
44062
- * explicitly to override that default per grant.
44063
- */
44064
- includeLinked: boolean().optional()
44065
- });
44066
- /**
44067
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44068
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44069
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44070
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44071
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44072
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44073
- * migration cannot reach a JWT already in a client's hands; parse-time
44074
- * migration covers both without a flag day. No cast — the raw object is read
44075
- * through `Reflect.get` (its static type is `unknown`).
44076
- */
44077
- function migrateLegacyTokenScope(raw) {
44078
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44079
- if (Reflect.get(raw, "type") !== "device") return raw;
44080
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44081
- const targets = Reflect.get(raw, "targets");
44082
- if (!Array.isArray(targets)) return raw;
44083
- return {
44084
- type: "device",
44085
- selector: {
44086
- kind: "ids",
44087
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44088
- },
44089
- access: Reflect.get(raw, "access")
44090
- };
44091
- }
44092
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44093
- object({
44094
- type: literal("category"),
44095
- target: CapScopeSchema,
44096
- access: array(MethodAccessSchema).min(1)
44097
- }),
44098
- object({
44099
- type: literal("capability"),
44100
- target: string(),
44101
- access: array(MethodAccessSchema).min(1)
44102
- }),
44103
- object({
44104
- type: literal("addon"),
44105
- target: string(),
44106
- access: array(MethodAccessSchema).min(1)
44107
- }),
44108
- DeviceTokenScopeSchema
44109
- ]));
44110
- object({
44111
- id: string(),
44112
- username: string(),
44113
- passwordHash: string(),
44114
- /**
44115
- * Admin bypass. When true, the middleware skips the scope-access
44116
- * check entirely. There is no other axis of privilege; the legacy
44117
- * role enum collapsed onto this boolean in v2.
44118
- */
44119
- isAdmin: boolean().default(false),
44120
- allowedProviders: AllowedProviderSchema,
44121
- allowedDevices: AllowedDevicesSchema,
44122
- /**
44123
- * Scopes granted to this user. Admins bypass; their `scopes` is
44124
- * ignored. Non-admins without scopes are locked out of every
44125
- * protected call.
44126
- */
44127
- scopes: array(TokenScopeSchema).default([]),
44128
- createdAt: number(),
44129
- updatedAt: number()
44130
- });
44131
- object({
44132
- id: string(),
44133
- label: string(),
44134
- isAdmin: boolean().default(false),
44135
- allowedProviders: AllowedProviderSchema,
44136
- allowedDevices: AllowedDevicesSchema,
44137
- tokenHash: string(),
44138
- tokenPrefix: string(),
44139
- createdAt: number(),
44140
- lastUsedAt: number().optional()
44141
- });
44142
- object({
44143
- id: string(),
44144
- userId: string(),
44145
- name: string(),
44146
- tokenHash: string(),
44147
- tokenPrefix: string(),
44148
- scopes: array(TokenScopeSchema),
44149
- expiresAt: number().nullish(),
44150
- lastUsedAt: number().nullish(),
44151
- createdAt: number()
44152
- });
44153
- /**
44154
44302
  * `oauth-integration` — a collection cap by which an addon declares
44155
44303
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44156
44304
  * Each provider returns a static descriptor; the core enumerates them
@@ -61092,26 +61240,6 @@ var ApiKeySummarySchema = object({
61092
61240
  createdAt: number(),
61093
61241
  lastUsedAt: number().optional()
61094
61242
  });
61095
- var ScopedTokenSummarySchema = object({
61096
- id: string(),
61097
- userId: string(),
61098
- name: string(),
61099
- tokenPrefix: string(),
61100
- scopes: array(TokenScopeSchema),
61101
- expiresAt: number().nullish(),
61102
- lastUsedAt: number().nullish(),
61103
- createdAt: number()
61104
- });
61105
- var CreateScopedTokenInputSchema = object({
61106
- userId: string(),
61107
- name: string(),
61108
- scopes: array(TokenScopeSchema),
61109
- expiresAt: number().optional()
61110
- });
61111
- var CreateScopedTokenResultSchema = object({
61112
- token: string(),
61113
- record: ScopedTokenSummarySchema
61114
- });
61115
61243
  var OauthSessionSummarySchema = object({
61116
61244
  id: string(),
61117
61245
  userId: string(),
@@ -61133,11 +61261,11 @@ var TotpStatusSchema = object({
61133
61261
  confirmedAt: number().nullable()
61134
61262
  });
61135
61263
  /**
61136
- * user-management — singleton capability for user accounts, API keys,
61137
- * and scoped tokens.
61264
+ * user-management — singleton capability for user accounts and the
61265
+ * legacy API-key rows.
61138
61266
  *
61139
61267
  * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
61140
- * — the subset check on `setUserScopes` / `createScopedToken` is moot
61268
+ * — the subset check on `setUserScopes` is moot
61141
61269
  * because non-admins never reach these. If/when we open non-admin
61142
61270
  * delegation, structural caller-scope subset check goes inside the
61143
61271
  * provider.
@@ -61194,15 +61322,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
61194
61322
  kind: "mutation",
61195
61323
  auth: "admin",
61196
61324
  access: "delete"
61197
- }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
61198
- kind: "mutation",
61199
- auth: "admin",
61200
- access: "create"
61201
- }), method(object({ id: string() }), object({ success: literal(true) }), {
61202
- kind: "mutation",
61203
- auth: "admin",
61204
- access: "delete"
61205
- }), method(object({ token: string() }), ScopedTokenSummarySchema.nullable(), { access: "view" }), method(object({ userId: string() }), array(ScopedTokenSummarySchema), { auth: "admin" }), method(object({ userId: string() }), TotpSetupResultSchema, {
61325
+ }), method(object({ userId: string() }), TotpSetupResultSchema, {
61206
61326
  kind: "mutation",
61207
61327
  auth: "admin",
61208
61328
  access: "create"
@@ -65358,7 +65478,7 @@ Object.freeze({
65358
65478
  capName: "llm",
65359
65479
  capScope: "system",
65360
65480
  addonId: null,
65361
- access: "view"
65481
+ access: "create"
65362
65482
  },
65363
65483
  "llm.listNodeModels": {
65364
65484
  capName: "llm",
@@ -70022,12 +70142,6 @@ Object.freeze({
70022
70142
  addonId: null,
70023
70143
  access: "create"
70024
70144
  },
70025
- "userManagement.createScopedToken": {
70026
- capName: "user-management",
70027
- capScope: "system",
70028
- addonId: null,
70029
- access: "create"
70030
- },
70031
70145
  "userManagement.createUser": {
70032
70146
  capName: "user-management",
70033
70147
  capScope: "system",
@@ -70076,12 +70190,6 @@ Object.freeze({
70076
70190
  addonId: null,
70077
70191
  access: "view"
70078
70192
  },
70079
- "userManagement.listScopedTokens": {
70080
- capName: "user-management",
70081
- capScope: "system",
70082
- addonId: null,
70083
- access: "view"
70084
- },
70085
70193
  "userManagement.listUsers": {
70086
70194
  capName: "user-management",
70087
70195
  capScope: "system",
@@ -70136,12 +70244,6 @@ Object.freeze({
70136
70244
  addonId: null,
70137
70245
  access: "delete"
70138
70246
  },
70139
- "userManagement.revokeScopedToken": {
70140
- capName: "user-management",
70141
- capScope: "system",
70142
- addonId: null,
70143
- access: "delete"
70144
- },
70145
70247
  "userManagement.setupTotp": {
70146
70248
  capName: "user-management",
70147
70249
  capScope: "system",
@@ -70172,12 +70274,6 @@ Object.freeze({
70172
70274
  addonId: null,
70173
70275
  access: "view"
70174
70276
  },
70175
- "userManagement.validateScopedToken": {
70176
- capName: "user-management",
70177
- capScope: "system",
70178
- addonId: null,
70179
- access: "view"
70180
- },
70181
70277
  "userManagement.verifyTotp": {
70182
70278
  capName: "user-management",
70183
70279
  capScope: "system",