@camstack/addon-google-services 0.2.12 → 0.2.14

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.
@@ -5551,7 +5551,7 @@ var ZodIssueCode = {
5551
5551
  var ZodFirstPartyTypeKind;
5552
5552
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5553
5553
  //#endregion
5554
- //#region ../types/dist/sleep-BxjU_fJM.mjs
5554
+ //#region ../types/dist/sleep-yKL5gfrH.mjs
5555
5555
  /**
5556
5556
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5557
5557
  * window to float samples (D455).
@@ -7933,6 +7933,12 @@ function normalizeAddonInitResult(result) {
7933
7933
  if (Array.isArray(result)) return { providers: result };
7934
7934
  return result;
7935
7935
  }
7936
+ /**
7937
+ * The share-view scope kinds a share-link token can carry. The hub mints
7938
+ * and validates them (`ShareViewGrantSchema` builds its
7939
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
7940
+ */
7941
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7936
7942
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7937
7943
  var PeerBytesTicketSchema = object({
7938
7944
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12915,6 +12921,280 @@ var ConvertResultSchema = object({
12915
12921
  files: array(string()).readonly()
12916
12922
  })).readonly()
12917
12923
  });
12924
+ /**
12925
+ * Zod schemas for persisted record types.
12926
+ *
12927
+ * These schemas serve as the single source of truth for types that are
12928
+ * stored in the settings-store backend and retrieved via tRPC. They
12929
+ * replace the manual TypeScript interfaces with schema-derived types,
12930
+ * enabling runtime validation when reading from the backend.
12931
+ *
12932
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12933
+ * keeps the original name for backward compatibility.
12934
+ */
12935
+ /**
12936
+ * Auth model (v2 — 2026-05-12 caps-only):
12937
+ *
12938
+ * Two principals:
12939
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12940
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12941
+ *
12942
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12943
+ * `super_admin` — collapsed onto the single boolean because every
12944
+ * non-admin caller is governed by the same scope-check rules; the
12945
+ * distinction was only ever used to route role-specific procedures
12946
+ * which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
12947
+ * with `isAdmin: false` + an explicit scope list.
12948
+ */
12949
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12950
+ var MethodAccessSchema = _enum([
12951
+ "view",
12952
+ "create",
12953
+ "delete"
12954
+ ]);
12955
+ /**
12956
+ * A single scope grant. Three forms — checked in matcher with OR
12957
+ * semantics; the first match decides whether the call passes:
12958
+ *
12959
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12960
+ * cap with the matching `scope` declaration. New caps inherit grants
12961
+ * automatically — adding a device cap to the codebase makes it
12962
+ * reachable to every user with `category:device [...]` without a
12963
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12964
+ *
12965
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12966
+ * useful when an integration needs to interact with one specific
12967
+ * addon's surface regardless of how many caps it exports.
12968
+ *
12969
+ * - `capability` — the most precise form. Single cap name. Use for
12970
+ * integration tokens where you want to grant `addons.installPackage`
12971
+ * and nothing else.
12972
+ *
12973
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12974
+ * "give me everything" escape; there is no wildcard scope.
12975
+ */
12976
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12977
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12978
+ var CapScopeSchema = _enum(["device", "system"]);
12979
+ /**
12980
+ * DeviceSelector (scope model v3 — 2026-08-12).
12981
+ *
12982
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12983
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12984
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12985
+ * AFTER the grant was minted — no re-grant, no re-login.
12986
+ *
12987
+ * - `all` — every device in the deployment. The broad viewer/operator
12988
+ * lever without a `category` grant (a `category` grant also covers device
12989
+ * caps that carry no deviceId; `all` is specifically the device set).
12990
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
12991
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
12992
+ * is NOT covered until the grant is edited.
12993
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
12994
+ * DYNAMIC. A device that changes type, or a new device of the type,
12995
+ * re-resolves on the next request.
12996
+ * - `locations` — every device whose operator-assigned `location` label is
12997
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
12998
+ * null/unset location matches NO `locations` selector.
12999
+ */
13000
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
13001
+ object({ kind: literal("all") }),
13002
+ object({
13003
+ kind: literal("ids"),
13004
+ ids: array(number().int()).min(1)
13005
+ }),
13006
+ object({
13007
+ kind: literal("types"),
13008
+ types: array(_enum(DeviceType)).min(1)
13009
+ }),
13010
+ object({
13011
+ kind: literal("locations"),
13012
+ locations: array(string().min(1)).min(1)
13013
+ })
13014
+ ]);
13015
+ var DeviceTokenScopeSchema = object({
13016
+ type: literal("device"),
13017
+ /** The device SET this grant covers — resolved against the live fleet. */
13018
+ selector: DeviceSelectorSchema,
13019
+ access: array(MethodAccessSchema).min(1),
13020
+ /**
13021
+ * Whether a grant on a PARENT device transparently covers its accessory
13022
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
13023
+ * Direction is parent → children ONLY.
13024
+ *
13025
+ * Absent → the matcher DERIVES it from the access flavour: `view`
13026
+ * inherits (a camera viewer sees the camera's accessories), `create` /
13027
+ * `delete` do NOT (actuating/removing a child is an explicit act the
13028
+ * operator must grant on the child, not inherit from the parent). Set it
13029
+ * explicitly to override that default per grant.
13030
+ */
13031
+ includeLinked: boolean().optional()
13032
+ });
13033
+ /**
13034
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
13035
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
13036
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
13037
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
13038
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
13039
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
13040
+ * migration cannot reach a JWT already in a client's hands; parse-time
13041
+ * migration covers both without a flag day. No cast — the raw object is read
13042
+ * through `Reflect.get` (its static type is `unknown`).
13043
+ */
13044
+ function migrateLegacyTokenScope(raw) {
13045
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
13046
+ if (Reflect.get(raw, "type") !== "device") return raw;
13047
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
13048
+ const targets = Reflect.get(raw, "targets");
13049
+ if (!Array.isArray(targets)) return raw;
13050
+ return {
13051
+ type: "device",
13052
+ selector: {
13053
+ kind: "ids",
13054
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
13055
+ },
13056
+ access: Reflect.get(raw, "access")
13057
+ };
13058
+ }
13059
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
13060
+ object({
13061
+ type: literal("category"),
13062
+ target: CapScopeSchema,
13063
+ access: array(MethodAccessSchema).min(1)
13064
+ }),
13065
+ object({
13066
+ type: literal("capability"),
13067
+ target: string(),
13068
+ access: array(MethodAccessSchema).min(1)
13069
+ }),
13070
+ object({
13071
+ type: literal("addon"),
13072
+ target: string(),
13073
+ access: array(MethodAccessSchema).min(1)
13074
+ }),
13075
+ DeviceTokenScopeSchema
13076
+ ]));
13077
+ object({
13078
+ id: string(),
13079
+ username: string(),
13080
+ passwordHash: string(),
13081
+ /**
13082
+ * Admin bypass. When true, the middleware skips the scope-access
13083
+ * check entirely. There is no other axis of privilege; the legacy
13084
+ * role enum collapsed onto this boolean in v2.
13085
+ */
13086
+ isAdmin: boolean().default(false),
13087
+ allowedProviders: AllowedProviderSchema,
13088
+ allowedDevices: AllowedDevicesSchema,
13089
+ /**
13090
+ * Scopes granted to this user. Admins bypass; their `scopes` is
13091
+ * ignored. Non-admins without scopes are locked out of every
13092
+ * protected call.
13093
+ */
13094
+ scopes: array(TokenScopeSchema).default([]),
13095
+ createdAt: number(),
13096
+ updatedAt: number()
13097
+ });
13098
+ object({
13099
+ id: string(),
13100
+ label: string(),
13101
+ isAdmin: boolean().default(false),
13102
+ allowedProviders: AllowedProviderSchema,
13103
+ allowedDevices: AllowedDevicesSchema,
13104
+ tokenHash: string(),
13105
+ tokenPrefix: string(),
13106
+ createdAt: number(),
13107
+ lastUsedAt: number().optional()
13108
+ });
13109
+ object({
13110
+ id: string(),
13111
+ userId: string(),
13112
+ name: string(),
13113
+ tokenHash: string(),
13114
+ tokenPrefix: string(),
13115
+ scopes: array(TokenScopeSchema),
13116
+ expiresAt: number().nullish(),
13117
+ lastUsedAt: number().nullish(),
13118
+ createdAt: number()
13119
+ });
13120
+ /** What a share-view grant lets its holder see. */
13121
+ var ShareViewGrantSchema = object({
13122
+ kind: _enum(SHARE_VIEW_KINDS),
13123
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
13124
+ /** Talk-back, opt-in at mint time; absent means off. */
13125
+ talk: boolean().optional()
13126
+ });
13127
+ var ShareViewScopeSchema = object({
13128
+ type: literal("share-view"),
13129
+ grant: ShareViewGrantSchema
13130
+ });
13131
+ var AddonRoutesScopeSchema = object({
13132
+ type: literal("addon-routes"),
13133
+ access: array(MethodAccessSchema).min(1)
13134
+ });
13135
+ var PreferencesSelfScopeSchema = object({ type: literal("preferences-self") });
13136
+ var CredentialScopeSchema = union([
13137
+ literal("*"),
13138
+ ShareViewScopeSchema,
13139
+ AddonRoutesScopeSchema,
13140
+ PreferencesSelfScopeSchema,
13141
+ TokenScopeSchema
13142
+ ]);
13143
+ object({
13144
+ kind: literal("credential"),
13145
+ sub: string().min(1),
13146
+ jti: string().min(16),
13147
+ scopes: array(CredentialScopeSchema).min(1)
13148
+ });
13149
+ var PreferenceNamespaceSchema = string().regex(/^[a-z][a-z0-9.-]{0,63}$/);
13150
+ /** A namespace's value: a JSON object, opaque to the hub. */
13151
+ var PreferenceValueSchema = record(string(), unknown());
13152
+ var PreferenceDeviceIdSchema = string().min(1).max(64);
13153
+ /** A stored row, as the owner reads it. */
13154
+ var PreferenceRowSchema = object({
13155
+ namespace: PreferenceNamespaceSchema,
13156
+ value: PreferenceValueSchema,
13157
+ /** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
13158
+ revision: number().int().positive(),
13159
+ updatedAt: number().int(),
13160
+ /** The client id the last writer sent; `null` when it sent none. */
13161
+ updatedByDevice: PreferenceDeviceIdSchema.nullable()
13162
+ });
13163
+ object({
13164
+ /** Absent: every namespace the caller holds. */
13165
+ namespaces: array(PreferenceNamespaceSchema).max(32).optional() });
13166
+ object({ rows: array(PreferenceRowSchema) });
13167
+ object({
13168
+ namespace: PreferenceNamespaceSchema,
13169
+ value: PreferenceValueSchema,
13170
+ /**
13171
+ * The revision the edit was based on. Absent: last write wins. `0`: the
13172
+ * namespace must not exist yet. Any other value that is not the current
13173
+ * revision answers `conflict` and writes nothing.
13174
+ */
13175
+ baseRevision: number().int().nonnegative().optional(),
13176
+ deviceId: PreferenceDeviceIdSchema.optional()
13177
+ });
13178
+ discriminatedUnion("status", [object({
13179
+ status: literal("saved"),
13180
+ row: PreferenceRowSchema
13181
+ }), object({
13182
+ status: literal("conflict"),
13183
+ current: PreferenceRowSchema.nullable()
13184
+ })]);
13185
+ object({ namespace: PreferenceNamespaceSchema });
13186
+ object({
13187
+ /** `false` when the namespace did not exist. */
13188
+ deleted: boolean() });
13189
+ object({
13190
+ /** The revision the client holds per namespace; a namespace it does not list is new to it. */
13191
+ revisionByNamespace: record(PreferenceNamespaceSchema, number().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
13192
+ object({
13193
+ /** Every row whose revision differs from the client's, and every row it did not list. */
13194
+ rows: array(PreferenceRowSchema),
13195
+ /** Namespaces the client listed that no longer exist. */
13196
+ deleted: array(PreferenceNamespaceSchema)
13197
+ });
12918
13198
  _enum(["new-session", "step-up"]);
12919
13199
  /** The languages the hub's app landing pages are written in (D858). */
12920
13200
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -39861,38 +40141,37 @@ method(LlmRuntimeCompleteInputSchema, LlmGenerateResultSchema, {
39861
40141
  auth: "admin",
39862
40142
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39863
40143
  });
40144
+ var LlmProfileKindSchema = string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "a kind id is lower-case letters, digits and dashes");
40145
+ /** What a model (or, by default, every model of a kind) can do. */
40146
+ var LlmModelFeaturesSchema = object({
40147
+ vision: boolean(),
40148
+ tools: boolean(),
40149
+ streaming: boolean()
40150
+ });
40151
+ /** One model a provider offers. `features` overrides the kind's defaults, per field. */
40152
+ var LlmModelInfoSchema = object({
40153
+ id: string(),
40154
+ label: string().optional(),
40155
+ contextLength: number().int().positive().optional(),
40156
+ features: LlmModelFeaturesSchema.partial().optional()
40157
+ });
39864
40158
  /**
39865
- * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
39866
- * methods concat-fan across providers; single-row methods route to ONE
39867
- * provider by the `addonId` in the call input (the notification-output
39868
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
39869
- * (hub-placed); the cap stays open for future providers.
39870
- *
39871
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
39872
- * `apiKey` is a password field — providers REDACT it on read and merge on
39873
- * write; a stored key NEVER round-trips to a client.
40159
+ * The provider-specific part of a profile, validated by the provider that owns
40160
+ * the kind (`upsertProfile` refuses what it does not accept). A field its
40161
+ * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
40162
+ * keychain, never in the row, and reads back as the redaction marker.
39874
40163
  */
39875
- var LlmProfileKindSchema = _enum([
39876
- "openai-compatible",
39877
- "openai",
39878
- "anthropic",
39879
- "google",
39880
- "managed-local",
39881
- "apple-foundation"
39882
- ]);
40164
+ var LlmProviderConfigSchema = record(string(), unknown());
39883
40165
  var LlmProfileSchema = object({
39884
40166
  id: string(),
39885
40167
  name: string(),
40168
+ /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
39886
40169
  kind: LlmProfileKindSchema,
39887
40170
  /** Stamped by the provider — keeps the fanned catalog routable. */
39888
40171
  addonId: string(),
39889
40172
  enabled: boolean(),
39890
40173
  /** Vendor model id, or the managed runtime's loaded model. */
39891
40174
  model: string(),
39892
- /** Required for openai-compatible; override for cloud kinds. */
39893
- baseUrl: string().optional(),
39894
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
39895
- apiKey: string().optional(),
39896
40175
  /** Vision on/off. A vision call against a `false` profile is REFUSED, never
39897
40176
  * degraded to text — that shipped once and produced a confident answer to a
39898
40177
  * question about a picture nobody sent. */
@@ -39900,15 +40179,11 @@ var LlmProfileSchema = object({
39900
40179
  temperature: number().min(0).max(2).optional(),
39901
40180
  /** Nucleus sampling. Every wire we speak has it. */
39902
40181
  topP: number().min(0).max(1).optional(),
39903
- /** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
39904
- * wire does, and the client drops it there (measured: the request body gets
39905
- * `top_p` and no `top_k`). The profile editor hides the field wherever it
39906
- * would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
40182
+ /** Top-k sampling. Carried only by the wires that have it — a kind offers the
40183
+ * field in its editor only when its descriptor lists it in `profileFields`. */
39907
40184
  topK: number().int().positive().optional(),
39908
40185
  maxTokens: number().int().positive().optional(),
39909
- /** Prompt context window. Advisory for cloud kinds (they enforce their own);
39910
- * for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
39911
- * the model with, so it is the one field that changes a PROCESS. */
40186
+ /** Prompt context window. Advisory for cloud kinds (they enforce their own). */
39912
40187
  contextLength: number().int().positive().optional(),
39913
40188
  /** Default system prompt. A caller's `system` REPLACES it (never appends —
39914
40189
  * two system prompts fighting is worse than either alone). */
@@ -39934,16 +40209,37 @@ var LlmProfileSchema = object({
39934
40209
  * library; the REGISTRY of callable tools is ours and is empty in v1, so a
39935
40210
  * `true` here buys the wiring, not behaviour, until tools are registered. */
39936
40211
  toolsEnabled: boolean().default(false),
39937
- extraHeaders: record(string(), string()).optional(),
39938
- /** kind === 'managed-local' only (spec §4). */
39939
- runtime: ManagedRuntimeConfigSchema.optional(),
39940
- /**
39941
- * kind === 'apple-foundation' only: WHERE it runs — the only thing there is
39942
- * to configure (no key, no URL, no download; `model` is `apple-system`).
39943
- * `supportsVision` on such a row is stamped by the provider from the node's
39944
- * reported `imageInput`, never taken from the operator (D62).
39945
- */
39946
- appleFoundation: object({ nodeId: string() }).optional()
40212
+ /** Everything the kind's provider owns (endpoint, key, node, runtime…). */
40213
+ providerConfig: LlmProviderConfigSchema.default({})
40214
+ });
40215
+ /**
40216
+ * The common profile fields a kind's editor offers. The editor owns how each
40217
+ * one is drawn; the provider says which of them mean something on its wire.
40218
+ */
40219
+ var LlmProfileFieldSchema = _enum([
40220
+ "temperature",
40221
+ "topP",
40222
+ "topK",
40223
+ "maxTokens",
40224
+ "contextLength",
40225
+ "systemPrompt",
40226
+ "timeoutMs",
40227
+ "connectTimeoutMs",
40228
+ "firstTokenTimeoutMs",
40229
+ "idleTimeoutMs",
40230
+ "retry",
40231
+ "toolsEnabled"
40232
+ ]);
40233
+ /**
40234
+ * A provider-drawn part of the editor, by a generic widget id the admin UI
40235
+ * registers (`ai/apple-node`). `placement: 'model'` replaces the generic model
40236
+ * picker: that widget owns the model choice.
40237
+ */
40238
+ var LlmProviderWidgetSchema = object({
40239
+ id: string(),
40240
+ placement: _enum(["connection", "model"]),
40241
+ /** `providerConfig` keys this widget must fill before the profile can be saved. */
40242
+ requires: array(string()).optional()
39947
40243
  });
39948
40244
  /** ConfigUISchema tree passed through untyped on the wire (the
39949
40245
  * notification-output `ConfigSchemaPassthrough` precedent at
@@ -39952,11 +40248,56 @@ var ConfigSchemaPassthrough$3 = unknown();
39952
40248
  var LlmProfileKindDescriptorSchema = object({
39953
40249
  kind: LlmProfileKindSchema,
39954
40250
  label: string(),
40251
+ /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
39955
40252
  icon: string(),
39956
40253
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
39957
40254
  addonId: string(),
39958
- configSchema: ConfigSchemaPassthrough$3
40255
+ /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
40256
+ connectionSchema: ConfigSchemaPassthrough$3,
40257
+ /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
40258
+ advancedSchema: ConfigSchemaPassthrough$3.optional(),
40259
+ /** The kind's defaults; a model from `listModels` may override any of them. */
40260
+ features: LlmModelFeaturesSchema,
40261
+ /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
40262
+ visionEditable: boolean(),
40263
+ /** Where the model list comes from: `listModels`, `staticModels`, or nowhere. */
40264
+ modelCatalog: _enum([
40265
+ "fetch",
40266
+ "static",
40267
+ "none"
40268
+ ]),
40269
+ staticModels: array(LlmModelInfoSchema).optional(),
40270
+ /** The common fields that mean something on this kind's wire. */
40271
+ profileFields: array(LlmProfileFieldSchema),
40272
+ providerWidgets: array(LlmProviderWidgetSchema).optional()
40273
+ });
40274
+ /**
40275
+ * `listModels` input. `connection` is an UNSAVED draft of `providerConfig`
40276
+ * (the editor's form); with `profileId` too, a secret the draft leaves
40277
+ * untouched (absent or the redaction marker) is resolved server-side from the
40278
+ * stored profile — the browser never receives it.
40279
+ */
40280
+ var LlmListModelsInputSchema = object({
40281
+ addonId: string(),
40282
+ kind: LlmProfileKindSchema,
40283
+ profileId: string().optional(),
40284
+ connection: LlmProviderConfigSchema.optional()
39959
40285
  });
40286
+ var LlmListModelsErrorCodeSchema = _enum([
40287
+ "auth",
40288
+ "network",
40289
+ "unsupported",
40290
+ "invalid"
40291
+ ]);
40292
+ /** A RESULT, never a throw: "wrong key" is an answer the editor renders inline. */
40293
+ var LlmListModelsResultSchema = discriminatedUnion("ok", [object({
40294
+ ok: literal(true),
40295
+ models: array(LlmModelInfoSchema)
40296
+ }), object({
40297
+ ok: literal(false),
40298
+ code: LlmListModelsErrorCodeSchema,
40299
+ message: string()
40300
+ })]);
39960
40301
  var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
39961
40302
  var LlmDefaultSchema = object({
39962
40303
  selector: LlmDefaultSelectorSchema,
@@ -40056,7 +40397,10 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
40056
40397
  kind: "mutation",
40057
40398
  auth: "admin",
40058
40399
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
40059
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
40400
+ }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
40401
+ kind: "mutation",
40402
+ auth: "admin"
40403
+ }), method(object({}), array(LlmDefaultSchema)), method(object({
40060
40404
  selector: LlmDefaultSelectorSchema,
40061
40405
  profileId: string().nullable()
40062
40406
  }), _void(), {
@@ -44120,202 +44464,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
44120
44464
  auth: "admin"
44121
44465
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
44122
44466
  /**
44123
- * Zod schemas for persisted record types.
44124
- *
44125
- * These schemas serve as the single source of truth for types that are
44126
- * stored in the settings-store backend and retrieved via tRPC. They
44127
- * replace the manual TypeScript interfaces with schema-derived types,
44128
- * enabling runtime validation when reading from the backend.
44129
- *
44130
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
44131
- * keeps the original name for backward compatibility.
44132
- */
44133
- /**
44134
- * Auth model (v2 — 2026-05-12 caps-only):
44135
- *
44136
- * Two principals:
44137
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
44138
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
44139
- *
44140
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44141
- * `super_admin` — collapsed onto the single boolean because every
44142
- * non-admin caller is governed by the same scope-check rules; the
44143
- * distinction was only ever used to route role-specific procedures
44144
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44145
- * with `isAdmin: false` + an explicit scope list.
44146
- */
44147
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44148
- var MethodAccessSchema = _enum([
44149
- "view",
44150
- "create",
44151
- "delete"
44152
- ]);
44153
- /**
44154
- * A single scope grant. Three forms — checked in matcher with OR
44155
- * semantics; the first match decides whether the call passes:
44156
- *
44157
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44158
- * cap with the matching `scope` declaration. New caps inherit grants
44159
- * automatically — adding a device cap to the codebase makes it
44160
- * reachable to every user with `category:device [...]` without a
44161
- * re-grant. Use this for "family viewer" / "operator" tiers.
44162
- *
44163
- * - `addon` — every cap that ships inside a given addon id. Niche;
44164
- * useful when an integration needs to interact with one specific
44165
- * addon's surface regardless of how many caps it exports.
44166
- *
44167
- * - `capability` — the most precise form. Single cap name. Use for
44168
- * integration tokens where you want to grant `addons.installPackage`
44169
- * and nothing else.
44170
- *
44171
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44172
- * "give me everything" escape; there is no wildcard scope.
44173
- */
44174
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44175
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44176
- var CapScopeSchema = _enum(["device", "system"]);
44177
- /**
44178
- * DeviceSelector (scope model v3 — 2026-08-12).
44179
- *
44180
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44181
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44182
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44183
- * AFTER the grant was minted — no re-grant, no re-login.
44184
- *
44185
- * - `all` — every device in the deployment. The broad viewer/operator
44186
- * lever without a `category` grant (a `category` grant also covers device
44187
- * caps that carry no deviceId; `all` is specifically the device set).
44188
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44189
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44190
- * is NOT covered until the grant is edited.
44191
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44192
- * DYNAMIC. A device that changes type, or a new device of the type,
44193
- * re-resolves on the next request.
44194
- * - `locations` — every device whose operator-assigned `location` label is
44195
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44196
- * null/unset location matches NO `locations` selector.
44197
- */
44198
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44199
- object({ kind: literal("all") }),
44200
- object({
44201
- kind: literal("ids"),
44202
- ids: array(number().int()).min(1)
44203
- }),
44204
- object({
44205
- kind: literal("types"),
44206
- types: array(_enum(DeviceType)).min(1)
44207
- }),
44208
- object({
44209
- kind: literal("locations"),
44210
- locations: array(string().min(1)).min(1)
44211
- })
44212
- ]);
44213
- var DeviceTokenScopeSchema = object({
44214
- type: literal("device"),
44215
- /** The device SET this grant covers — resolved against the live fleet. */
44216
- selector: DeviceSelectorSchema,
44217
- access: array(MethodAccessSchema).min(1),
44218
- /**
44219
- * Whether a grant on a PARENT device transparently covers its accessory
44220
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44221
- * Direction is parent → children ONLY.
44222
- *
44223
- * Absent → the matcher DERIVES it from the access flavour: `view`
44224
- * inherits (a camera viewer sees the camera's accessories), `create` /
44225
- * `delete` do NOT (actuating/removing a child is an explicit act the
44226
- * operator must grant on the child, not inherit from the parent). Set it
44227
- * explicitly to override that default per grant.
44228
- */
44229
- includeLinked: boolean().optional()
44230
- });
44231
- /**
44232
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44233
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44234
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44235
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44236
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44237
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44238
- * migration cannot reach a JWT already in a client's hands; parse-time
44239
- * migration covers both without a flag day. No cast — the raw object is read
44240
- * through `Reflect.get` (its static type is `unknown`).
44241
- */
44242
- function migrateLegacyTokenScope(raw) {
44243
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44244
- if (Reflect.get(raw, "type") !== "device") return raw;
44245
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44246
- const targets = Reflect.get(raw, "targets");
44247
- if (!Array.isArray(targets)) return raw;
44248
- return {
44249
- type: "device",
44250
- selector: {
44251
- kind: "ids",
44252
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44253
- },
44254
- access: Reflect.get(raw, "access")
44255
- };
44256
- }
44257
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44258
- object({
44259
- type: literal("category"),
44260
- target: CapScopeSchema,
44261
- access: array(MethodAccessSchema).min(1)
44262
- }),
44263
- object({
44264
- type: literal("capability"),
44265
- target: string(),
44266
- access: array(MethodAccessSchema).min(1)
44267
- }),
44268
- object({
44269
- type: literal("addon"),
44270
- target: string(),
44271
- access: array(MethodAccessSchema).min(1)
44272
- }),
44273
- DeviceTokenScopeSchema
44274
- ]));
44275
- object({
44276
- id: string(),
44277
- username: string(),
44278
- passwordHash: string(),
44279
- /**
44280
- * Admin bypass. When true, the middleware skips the scope-access
44281
- * check entirely. There is no other axis of privilege; the legacy
44282
- * role enum collapsed onto this boolean in v2.
44283
- */
44284
- isAdmin: boolean().default(false),
44285
- allowedProviders: AllowedProviderSchema,
44286
- allowedDevices: AllowedDevicesSchema,
44287
- /**
44288
- * Scopes granted to this user. Admins bypass; their `scopes` is
44289
- * ignored. Non-admins without scopes are locked out of every
44290
- * protected call.
44291
- */
44292
- scopes: array(TokenScopeSchema).default([]),
44293
- createdAt: number(),
44294
- updatedAt: number()
44295
- });
44296
- object({
44297
- id: string(),
44298
- label: string(),
44299
- isAdmin: boolean().default(false),
44300
- allowedProviders: AllowedProviderSchema,
44301
- allowedDevices: AllowedDevicesSchema,
44302
- tokenHash: string(),
44303
- tokenPrefix: string(),
44304
- createdAt: number(),
44305
- lastUsedAt: number().optional()
44306
- });
44307
- object({
44308
- id: string(),
44309
- userId: string(),
44310
- name: string(),
44311
- tokenHash: string(),
44312
- tokenPrefix: string(),
44313
- scopes: array(TokenScopeSchema),
44314
- expiresAt: number().nullish(),
44315
- lastUsedAt: number().nullish(),
44316
- createdAt: number()
44317
- });
44318
- /**
44319
44467
  * `oauth-integration` — a collection cap by which an addon declares
44320
44468
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44321
44469
  * Each provider returns a static descriptor; the core enumerates them
@@ -61270,26 +61418,6 @@ var ApiKeySummarySchema = object({
61270
61418
  createdAt: number(),
61271
61419
  lastUsedAt: number().optional()
61272
61420
  });
61273
- var ScopedTokenSummarySchema = object({
61274
- id: string(),
61275
- userId: string(),
61276
- name: string(),
61277
- tokenPrefix: string(),
61278
- scopes: array(TokenScopeSchema),
61279
- expiresAt: number().nullish(),
61280
- lastUsedAt: number().nullish(),
61281
- createdAt: number()
61282
- });
61283
- var CreateScopedTokenInputSchema = object({
61284
- userId: string(),
61285
- name: string(),
61286
- scopes: array(TokenScopeSchema),
61287
- expiresAt: number().optional()
61288
- });
61289
- var CreateScopedTokenResultSchema = object({
61290
- token: string(),
61291
- record: ScopedTokenSummarySchema
61292
- });
61293
61421
  var OauthSessionSummarySchema = object({
61294
61422
  id: string(),
61295
61423
  userId: string(),
@@ -61311,11 +61439,11 @@ var TotpStatusSchema = object({
61311
61439
  confirmedAt: number().nullable()
61312
61440
  });
61313
61441
  /**
61314
- * user-management — singleton capability for user accounts, API keys,
61315
- * and scoped tokens.
61442
+ * user-management — singleton capability for user accounts and the
61443
+ * legacy API-key rows.
61316
61444
  *
61317
61445
  * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
61318
- * — the subset check on `setUserScopes` / `createScopedToken` is moot
61446
+ * — the subset check on `setUserScopes` is moot
61319
61447
  * because non-admins never reach these. If/when we open non-admin
61320
61448
  * delegation, structural caller-scope subset check goes inside the
61321
61449
  * provider.
@@ -61372,15 +61500,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
61372
61500
  kind: "mutation",
61373
61501
  auth: "admin",
61374
61502
  access: "delete"
61375
- }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
61376
- kind: "mutation",
61377
- auth: "admin",
61378
- access: "create"
61379
- }), method(object({ id: string() }), object({ success: literal(true) }), {
61380
- kind: "mutation",
61381
- auth: "admin",
61382
- access: "delete"
61383
- }), method(object({ token: string() }), ScopedTokenSummarySchema.nullable(), { access: "view" }), method(object({ userId: string() }), array(ScopedTokenSummarySchema), { auth: "admin" }), method(object({ userId: string() }), TotpSetupResultSchema, {
61503
+ }), method(object({ userId: string() }), TotpSetupResultSchema, {
61384
61504
  kind: "mutation",
61385
61505
  auth: "admin",
61386
61506
  access: "create"
@@ -65536,7 +65656,7 @@ Object.freeze({
65536
65656
  capName: "llm",
65537
65657
  capScope: "system",
65538
65658
  addonId: null,
65539
- access: "view"
65659
+ access: "create"
65540
65660
  },
65541
65661
  "llm.listNodeModels": {
65542
65662
  capName: "llm",
@@ -70200,12 +70320,6 @@ Object.freeze({
70200
70320
  addonId: null,
70201
70321
  access: "create"
70202
70322
  },
70203
- "userManagement.createScopedToken": {
70204
- capName: "user-management",
70205
- capScope: "system",
70206
- addonId: null,
70207
- access: "create"
70208
- },
70209
70323
  "userManagement.createUser": {
70210
70324
  capName: "user-management",
70211
70325
  capScope: "system",
@@ -70254,12 +70368,6 @@ Object.freeze({
70254
70368
  addonId: null,
70255
70369
  access: "view"
70256
70370
  },
70257
- "userManagement.listScopedTokens": {
70258
- capName: "user-management",
70259
- capScope: "system",
70260
- addonId: null,
70261
- access: "view"
70262
- },
70263
70371
  "userManagement.listUsers": {
70264
70372
  capName: "user-management",
70265
70373
  capScope: "system",
@@ -70314,12 +70422,6 @@ Object.freeze({
70314
70422
  addonId: null,
70315
70423
  access: "delete"
70316
70424
  },
70317
- "userManagement.revokeScopedToken": {
70318
- capName: "user-management",
70319
- capScope: "system",
70320
- addonId: null,
70321
- access: "delete"
70322
- },
70323
70425
  "userManagement.setupTotp": {
70324
70426
  capName: "user-management",
70325
70427
  capScope: "system",
@@ -70350,12 +70452,6 @@ Object.freeze({
70350
70452
  addonId: null,
70351
70453
  access: "view"
70352
70454
  },
70353
- "userManagement.validateScopedToken": {
70354
- capName: "user-management",
70355
- capScope: "system",
70356
- addonId: null,
70357
- access: "view"
70358
- },
70359
70455
  "userManagement.verifyTotp": {
70360
70456
  capName: "user-management",
70361
70457
  capScope: "system",