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