@camstack/addon-import-alexa 0.2.130 → 0.2.132

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.
Files changed (3) hide show
  1. package/dist/addon.js +390 -294
  2. package/dist/addon.mjs +390 -294
  3. package/package.json +1 -1
package/dist/addon.mjs CHANGED
@@ -5586,7 +5586,7 @@ var ZodIssueCode = {
5586
5586
  var ZodFirstPartyTypeKind;
5587
5587
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5588
5588
  //#endregion
5589
- //#region ../types/dist/sleep-BxjU_fJM.mjs
5589
+ //#region ../types/dist/sleep-yKL5gfrH.mjs
5590
5590
  /**
5591
5591
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5592
5592
  * window to float samples (D455).
@@ -7968,6 +7968,12 @@ function normalizeAddonInitResult(result) {
7968
7968
  if (Array.isArray(result)) return { providers: result };
7969
7969
  return result;
7970
7970
  }
7971
+ /**
7972
+ * The share-view scope kinds a share-link token can carry. The hub mints
7973
+ * and validates them (`ShareViewGrantSchema` builds its
7974
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
7975
+ */
7976
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7971
7977
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7972
7978
  var PeerBytesTicketSchema = object({
7973
7979
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12950,6 +12956,280 @@ var ConvertResultSchema = object({
12950
12956
  files: array(string()).readonly()
12951
12957
  })).readonly()
12952
12958
  });
12959
+ /**
12960
+ * Zod schemas for persisted record types.
12961
+ *
12962
+ * These schemas serve as the single source of truth for types that are
12963
+ * stored in the settings-store backend and retrieved via tRPC. They
12964
+ * replace the manual TypeScript interfaces with schema-derived types,
12965
+ * enabling runtime validation when reading from the backend.
12966
+ *
12967
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12968
+ * keeps the original name for backward compatibility.
12969
+ */
12970
+ /**
12971
+ * Auth model (v2 — 2026-05-12 caps-only):
12972
+ *
12973
+ * Two principals:
12974
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12975
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12976
+ *
12977
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12978
+ * `super_admin` — collapsed onto the single boolean because every
12979
+ * non-admin caller is governed by the same scope-check rules; the
12980
+ * distinction was only ever used to route role-specific procedures
12981
+ * which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
12982
+ * with `isAdmin: false` + an explicit scope list.
12983
+ */
12984
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12985
+ var MethodAccessSchema = _enum([
12986
+ "view",
12987
+ "create",
12988
+ "delete"
12989
+ ]);
12990
+ /**
12991
+ * A single scope grant. Three forms — checked in matcher with OR
12992
+ * semantics; the first match decides whether the call passes:
12993
+ *
12994
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12995
+ * cap with the matching `scope` declaration. New caps inherit grants
12996
+ * automatically — adding a device cap to the codebase makes it
12997
+ * reachable to every user with `category:device [...]` without a
12998
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12999
+ *
13000
+ * - `addon` — every cap that ships inside a given addon id. Niche;
13001
+ * useful when an integration needs to interact with one specific
13002
+ * addon's surface regardless of how many caps it exports.
13003
+ *
13004
+ * - `capability` — the most precise form. Single cap name. Use for
13005
+ * integration tokens where you want to grant `addons.installPackage`
13006
+ * and nothing else.
13007
+ *
13008
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
13009
+ * "give me everything" escape; there is no wildcard scope.
13010
+ */
13011
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
13012
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
13013
+ var CapScopeSchema = _enum(["device", "system"]);
13014
+ /**
13015
+ * DeviceSelector (scope model v3 — 2026-08-12).
13016
+ *
13017
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
13018
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
13019
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
13020
+ * AFTER the grant was minted — no re-grant, no re-login.
13021
+ *
13022
+ * - `all` — every device in the deployment. The broad viewer/operator
13023
+ * lever without a `category` grant (a `category` grant also covers device
13024
+ * caps that carry no deviceId; `all` is specifically the device set).
13025
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
13026
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
13027
+ * is NOT covered until the grant is edited.
13028
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
13029
+ * DYNAMIC. A device that changes type, or a new device of the type,
13030
+ * re-resolves on the next request.
13031
+ * - `locations` — every device whose operator-assigned `location` label is
13032
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
13033
+ * null/unset location matches NO `locations` selector.
13034
+ */
13035
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
13036
+ object({ kind: literal("all") }),
13037
+ object({
13038
+ kind: literal("ids"),
13039
+ ids: array(number().int()).min(1)
13040
+ }),
13041
+ object({
13042
+ kind: literal("types"),
13043
+ types: array(_enum(DeviceType)).min(1)
13044
+ }),
13045
+ object({
13046
+ kind: literal("locations"),
13047
+ locations: array(string().min(1)).min(1)
13048
+ })
13049
+ ]);
13050
+ var DeviceTokenScopeSchema = object({
13051
+ type: literal("device"),
13052
+ /** The device SET this grant covers — resolved against the live fleet. */
13053
+ selector: DeviceSelectorSchema,
13054
+ access: array(MethodAccessSchema).min(1),
13055
+ /**
13056
+ * Whether a grant on a PARENT device transparently covers its accessory
13057
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
13058
+ * Direction is parent → children ONLY.
13059
+ *
13060
+ * Absent → the matcher DERIVES it from the access flavour: `view`
13061
+ * inherits (a camera viewer sees the camera's accessories), `create` /
13062
+ * `delete` do NOT (actuating/removing a child is an explicit act the
13063
+ * operator must grant on the child, not inherit from the parent). Set it
13064
+ * explicitly to override that default per grant.
13065
+ */
13066
+ includeLinked: boolean().optional()
13067
+ });
13068
+ /**
13069
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
13070
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
13071
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
13072
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
13073
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
13074
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
13075
+ * migration cannot reach a JWT already in a client's hands; parse-time
13076
+ * migration covers both without a flag day. No cast — the raw object is read
13077
+ * through `Reflect.get` (its static type is `unknown`).
13078
+ */
13079
+ function migrateLegacyTokenScope(raw) {
13080
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
13081
+ if (Reflect.get(raw, "type") !== "device") return raw;
13082
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
13083
+ const targets = Reflect.get(raw, "targets");
13084
+ if (!Array.isArray(targets)) return raw;
13085
+ return {
13086
+ type: "device",
13087
+ selector: {
13088
+ kind: "ids",
13089
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
13090
+ },
13091
+ access: Reflect.get(raw, "access")
13092
+ };
13093
+ }
13094
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
13095
+ object({
13096
+ type: literal("category"),
13097
+ target: CapScopeSchema,
13098
+ access: array(MethodAccessSchema).min(1)
13099
+ }),
13100
+ object({
13101
+ type: literal("capability"),
13102
+ target: string(),
13103
+ access: array(MethodAccessSchema).min(1)
13104
+ }),
13105
+ object({
13106
+ type: literal("addon"),
13107
+ target: string(),
13108
+ access: array(MethodAccessSchema).min(1)
13109
+ }),
13110
+ DeviceTokenScopeSchema
13111
+ ]));
13112
+ object({
13113
+ id: string(),
13114
+ username: string(),
13115
+ passwordHash: string(),
13116
+ /**
13117
+ * Admin bypass. When true, the middleware skips the scope-access
13118
+ * check entirely. There is no other axis of privilege; the legacy
13119
+ * role enum collapsed onto this boolean in v2.
13120
+ */
13121
+ isAdmin: boolean().default(false),
13122
+ allowedProviders: AllowedProviderSchema,
13123
+ allowedDevices: AllowedDevicesSchema,
13124
+ /**
13125
+ * Scopes granted to this user. Admins bypass; their `scopes` is
13126
+ * ignored. Non-admins without scopes are locked out of every
13127
+ * protected call.
13128
+ */
13129
+ scopes: array(TokenScopeSchema).default([]),
13130
+ createdAt: number(),
13131
+ updatedAt: number()
13132
+ });
13133
+ object({
13134
+ id: string(),
13135
+ label: string(),
13136
+ isAdmin: boolean().default(false),
13137
+ allowedProviders: AllowedProviderSchema,
13138
+ allowedDevices: AllowedDevicesSchema,
13139
+ tokenHash: string(),
13140
+ tokenPrefix: string(),
13141
+ createdAt: number(),
13142
+ lastUsedAt: number().optional()
13143
+ });
13144
+ object({
13145
+ id: string(),
13146
+ userId: string(),
13147
+ name: string(),
13148
+ tokenHash: string(),
13149
+ tokenPrefix: string(),
13150
+ scopes: array(TokenScopeSchema),
13151
+ expiresAt: number().nullish(),
13152
+ lastUsedAt: number().nullish(),
13153
+ createdAt: number()
13154
+ });
13155
+ /** What a share-view grant lets its holder see. */
13156
+ var ShareViewGrantSchema = object({
13157
+ kind: _enum(SHARE_VIEW_KINDS),
13158
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
13159
+ /** Talk-back, opt-in at mint time; absent means off. */
13160
+ talk: boolean().optional()
13161
+ });
13162
+ var ShareViewScopeSchema = object({
13163
+ type: literal("share-view"),
13164
+ grant: ShareViewGrantSchema
13165
+ });
13166
+ var AddonRoutesScopeSchema = object({
13167
+ type: literal("addon-routes"),
13168
+ access: array(MethodAccessSchema).min(1)
13169
+ });
13170
+ var PreferencesSelfScopeSchema = object({ type: literal("preferences-self") });
13171
+ var CredentialScopeSchema = union([
13172
+ literal("*"),
13173
+ ShareViewScopeSchema,
13174
+ AddonRoutesScopeSchema,
13175
+ PreferencesSelfScopeSchema,
13176
+ TokenScopeSchema
13177
+ ]);
13178
+ object({
13179
+ kind: literal("credential"),
13180
+ sub: string().min(1),
13181
+ jti: string().min(16),
13182
+ scopes: array(CredentialScopeSchema).min(1)
13183
+ });
13184
+ var PreferenceNamespaceSchema = string().regex(/^[a-z][a-z0-9.-]{0,63}$/);
13185
+ /** A namespace's value: a JSON object, opaque to the hub. */
13186
+ var PreferenceValueSchema = record(string(), unknown());
13187
+ var PreferenceDeviceIdSchema = string().min(1).max(64);
13188
+ /** A stored row, as the owner reads it. */
13189
+ var PreferenceRowSchema = object({
13190
+ namespace: PreferenceNamespaceSchema,
13191
+ value: PreferenceValueSchema,
13192
+ /** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
13193
+ revision: number().int().positive(),
13194
+ updatedAt: number().int(),
13195
+ /** The client id the last writer sent; `null` when it sent none. */
13196
+ updatedByDevice: PreferenceDeviceIdSchema.nullable()
13197
+ });
13198
+ object({
13199
+ /** Absent: every namespace the caller holds. */
13200
+ namespaces: array(PreferenceNamespaceSchema).max(32).optional() });
13201
+ object({ rows: array(PreferenceRowSchema) });
13202
+ object({
13203
+ namespace: PreferenceNamespaceSchema,
13204
+ value: PreferenceValueSchema,
13205
+ /**
13206
+ * The revision the edit was based on. Absent: last write wins. `0`: the
13207
+ * namespace must not exist yet. Any other value that is not the current
13208
+ * revision answers `conflict` and writes nothing.
13209
+ */
13210
+ baseRevision: number().int().nonnegative().optional(),
13211
+ deviceId: PreferenceDeviceIdSchema.optional()
13212
+ });
13213
+ discriminatedUnion("status", [object({
13214
+ status: literal("saved"),
13215
+ row: PreferenceRowSchema
13216
+ }), object({
13217
+ status: literal("conflict"),
13218
+ current: PreferenceRowSchema.nullable()
13219
+ })]);
13220
+ object({ namespace: PreferenceNamespaceSchema });
13221
+ object({
13222
+ /** `false` when the namespace did not exist. */
13223
+ deleted: boolean() });
13224
+ object({
13225
+ /** The revision the client holds per namespace; a namespace it does not list is new to it. */
13226
+ revisionByNamespace: record(PreferenceNamespaceSchema, number().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
13227
+ object({
13228
+ /** Every row whose revision differs from the client's, and every row it did not list. */
13229
+ rows: array(PreferenceRowSchema),
13230
+ /** Namespaces the client listed that no longer exist. */
13231
+ deleted: array(PreferenceNamespaceSchema)
13232
+ });
12953
13233
  _enum(["new-session", "step-up"]);
12954
13234
  /** The languages the hub's app landing pages are written in (D858). */
12955
13235
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -40211,38 +40491,37 @@ method(LlmRuntimeCompleteInputSchema, LlmGenerateResultSchema, {
40211
40491
  auth: "admin",
40212
40492
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
40213
40493
  });
40494
+ var LlmProfileKindSchema = string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "a kind id is lower-case letters, digits and dashes");
40495
+ /** What a model (or, by default, every model of a kind) can do. */
40496
+ var LlmModelFeaturesSchema = object({
40497
+ vision: boolean(),
40498
+ tools: boolean(),
40499
+ streaming: boolean()
40500
+ });
40501
+ /** One model a provider offers. `features` overrides the kind's defaults, per field. */
40502
+ var LlmModelInfoSchema = object({
40503
+ id: string(),
40504
+ label: string().optional(),
40505
+ contextLength: number().int().positive().optional(),
40506
+ features: LlmModelFeaturesSchema.partial().optional()
40507
+ });
40214
40508
  /**
40215
- * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
40216
- * methods concat-fan across providers; single-row methods route to ONE
40217
- * provider by the `addonId` in the call input (the notification-output
40218
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
40219
- * (hub-placed); the cap stays open for future providers.
40220
- *
40221
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
40222
- * `apiKey` is a password field — providers REDACT it on read and merge on
40223
- * write; a stored key NEVER round-trips to a client.
40509
+ * The provider-specific part of a profile, validated by the provider that owns
40510
+ * the kind (`upsertProfile` refuses what it does not accept). A field its
40511
+ * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
40512
+ * keychain, never in the row, and reads back as the redaction marker.
40224
40513
  */
40225
- var LlmProfileKindSchema = _enum([
40226
- "openai-compatible",
40227
- "openai",
40228
- "anthropic",
40229
- "google",
40230
- "managed-local",
40231
- "apple-foundation"
40232
- ]);
40514
+ var LlmProviderConfigSchema = record(string(), unknown());
40233
40515
  var LlmProfileSchema = object({
40234
40516
  id: string(),
40235
40517
  name: string(),
40518
+ /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
40236
40519
  kind: LlmProfileKindSchema,
40237
40520
  /** Stamped by the provider — keeps the fanned catalog routable. */
40238
40521
  addonId: string(),
40239
40522
  enabled: boolean(),
40240
40523
  /** Vendor model id, or the managed runtime's loaded model. */
40241
40524
  model: string(),
40242
- /** Required for openai-compatible; override for cloud kinds. */
40243
- baseUrl: string().optional(),
40244
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
40245
- apiKey: string().optional(),
40246
40525
  /** Vision on/off. A vision call against a `false` profile is REFUSED, never
40247
40526
  * degraded to text — that shipped once and produced a confident answer to a
40248
40527
  * question about a picture nobody sent. */
@@ -40250,15 +40529,11 @@ var LlmProfileSchema = object({
40250
40529
  temperature: number().min(0).max(2).optional(),
40251
40530
  /** Nucleus sampling. Every wire we speak has it. */
40252
40531
  topP: number().min(0).max(1).optional(),
40253
- /** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
40254
- * wire does, and the client drops it there (measured: the request body gets
40255
- * `top_p` and no `top_k`). The profile editor hides the field wherever it
40256
- * would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
40532
+ /** Top-k sampling. Carried only by the wires that have it — a kind offers the
40533
+ * field in its editor only when its descriptor lists it in `profileFields`. */
40257
40534
  topK: number().int().positive().optional(),
40258
40535
  maxTokens: number().int().positive().optional(),
40259
- /** Prompt context window. Advisory for cloud kinds (they enforce their own);
40260
- * for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
40261
- * the model with, so it is the one field that changes a PROCESS. */
40536
+ /** Prompt context window. Advisory for cloud kinds (they enforce their own). */
40262
40537
  contextLength: number().int().positive().optional(),
40263
40538
  /** Default system prompt. A caller's `system` REPLACES it (never appends —
40264
40539
  * two system prompts fighting is worse than either alone). */
@@ -40284,16 +40559,37 @@ var LlmProfileSchema = object({
40284
40559
  * library; the REGISTRY of callable tools is ours and is empty in v1, so a
40285
40560
  * `true` here buys the wiring, not behaviour, until tools are registered. */
40286
40561
  toolsEnabled: boolean().default(false),
40287
- extraHeaders: record(string(), string()).optional(),
40288
- /** kind === 'managed-local' only (spec §4). */
40289
- runtime: ManagedRuntimeConfigSchema.optional(),
40290
- /**
40291
- * kind === 'apple-foundation' only: WHERE it runs — the only thing there is
40292
- * to configure (no key, no URL, no download; `model` is `apple-system`).
40293
- * `supportsVision` on such a row is stamped by the provider from the node's
40294
- * reported `imageInput`, never taken from the operator (D62).
40295
- */
40296
- appleFoundation: object({ nodeId: string() }).optional()
40562
+ /** Everything the kind's provider owns (endpoint, key, node, runtime…). */
40563
+ providerConfig: LlmProviderConfigSchema.default({})
40564
+ });
40565
+ /**
40566
+ * The common profile fields a kind's editor offers. The editor owns how each
40567
+ * one is drawn; the provider says which of them mean something on its wire.
40568
+ */
40569
+ var LlmProfileFieldSchema = _enum([
40570
+ "temperature",
40571
+ "topP",
40572
+ "topK",
40573
+ "maxTokens",
40574
+ "contextLength",
40575
+ "systemPrompt",
40576
+ "timeoutMs",
40577
+ "connectTimeoutMs",
40578
+ "firstTokenTimeoutMs",
40579
+ "idleTimeoutMs",
40580
+ "retry",
40581
+ "toolsEnabled"
40582
+ ]);
40583
+ /**
40584
+ * A provider-drawn part of the editor, by a generic widget id the admin UI
40585
+ * registers (`ai/apple-node`). `placement: 'model'` replaces the generic model
40586
+ * picker: that widget owns the model choice.
40587
+ */
40588
+ var LlmProviderWidgetSchema = object({
40589
+ id: string(),
40590
+ placement: _enum(["connection", "model"]),
40591
+ /** `providerConfig` keys this widget must fill before the profile can be saved. */
40592
+ requires: array(string()).optional()
40297
40593
  });
40298
40594
  /** ConfigUISchema tree passed through untyped on the wire (the
40299
40595
  * notification-output `ConfigSchemaPassthrough` precedent at
@@ -40302,11 +40598,56 @@ var ConfigSchemaPassthrough$3 = unknown();
40302
40598
  var LlmProfileKindDescriptorSchema = object({
40303
40599
  kind: LlmProfileKindSchema,
40304
40600
  label: string(),
40601
+ /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
40305
40602
  icon: string(),
40306
40603
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
40307
40604
  addonId: string(),
40308
- configSchema: ConfigSchemaPassthrough$3
40605
+ /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
40606
+ connectionSchema: ConfigSchemaPassthrough$3,
40607
+ /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
40608
+ advancedSchema: ConfigSchemaPassthrough$3.optional(),
40609
+ /** The kind's defaults; a model from `listModels` may override any of them. */
40610
+ features: LlmModelFeaturesSchema,
40611
+ /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
40612
+ visionEditable: boolean(),
40613
+ /** Where the model list comes from: `listModels`, `staticModels`, or nowhere. */
40614
+ modelCatalog: _enum([
40615
+ "fetch",
40616
+ "static",
40617
+ "none"
40618
+ ]),
40619
+ staticModels: array(LlmModelInfoSchema).optional(),
40620
+ /** The common fields that mean something on this kind's wire. */
40621
+ profileFields: array(LlmProfileFieldSchema),
40622
+ providerWidgets: array(LlmProviderWidgetSchema).optional()
40623
+ });
40624
+ /**
40625
+ * `listModels` input. `connection` is an UNSAVED draft of `providerConfig`
40626
+ * (the editor's form); with `profileId` too, a secret the draft leaves
40627
+ * untouched (absent or the redaction marker) is resolved server-side from the
40628
+ * stored profile — the browser never receives it.
40629
+ */
40630
+ var LlmListModelsInputSchema = object({
40631
+ addonId: string(),
40632
+ kind: LlmProfileKindSchema,
40633
+ profileId: string().optional(),
40634
+ connection: LlmProviderConfigSchema.optional()
40309
40635
  });
40636
+ var LlmListModelsErrorCodeSchema = _enum([
40637
+ "auth",
40638
+ "network",
40639
+ "unsupported",
40640
+ "invalid"
40641
+ ]);
40642
+ /** A RESULT, never a throw: "wrong key" is an answer the editor renders inline. */
40643
+ var LlmListModelsResultSchema = discriminatedUnion("ok", [object({
40644
+ ok: literal(true),
40645
+ models: array(LlmModelInfoSchema)
40646
+ }), object({
40647
+ ok: literal(false),
40648
+ code: LlmListModelsErrorCodeSchema,
40649
+ message: string()
40650
+ })]);
40310
40651
  var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
40311
40652
  var LlmDefaultSchema = object({
40312
40653
  selector: LlmDefaultSelectorSchema,
@@ -40406,7 +40747,10 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
40406
40747
  kind: "mutation",
40407
40748
  auth: "admin",
40408
40749
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
40409
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
40750
+ }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
40751
+ kind: "mutation",
40752
+ auth: "admin"
40753
+ }), method(object({}), array(LlmDefaultSchema)), method(object({
40410
40754
  selector: LlmDefaultSelectorSchema,
40411
40755
  profileId: string().nullable()
40412
40756
  }), _void(), {
@@ -44512,202 +44856,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
44512
44856
  auth: "admin"
44513
44857
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
44514
44858
  /**
44515
- * Zod schemas for persisted record types.
44516
- *
44517
- * These schemas serve as the single source of truth for types that are
44518
- * stored in the settings-store backend and retrieved via tRPC. They
44519
- * replace the manual TypeScript interfaces with schema-derived types,
44520
- * enabling runtime validation when reading from the backend.
44521
- *
44522
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
44523
- * keeps the original name for backward compatibility.
44524
- */
44525
- /**
44526
- * Auth model (v2 — 2026-05-12 caps-only):
44527
- *
44528
- * Two principals:
44529
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
44530
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
44531
- *
44532
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44533
- * `super_admin` — collapsed onto the single boolean because every
44534
- * non-admin caller is governed by the same scope-check rules; the
44535
- * distinction was only ever used to route role-specific procedures
44536
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44537
- * with `isAdmin: false` + an explicit scope list.
44538
- */
44539
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44540
- var MethodAccessSchema = _enum([
44541
- "view",
44542
- "create",
44543
- "delete"
44544
- ]);
44545
- /**
44546
- * A single scope grant. Three forms — checked in matcher with OR
44547
- * semantics; the first match decides whether the call passes:
44548
- *
44549
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44550
- * cap with the matching `scope` declaration. New caps inherit grants
44551
- * automatically — adding a device cap to the codebase makes it
44552
- * reachable to every user with `category:device [...]` without a
44553
- * re-grant. Use this for "family viewer" / "operator" tiers.
44554
- *
44555
- * - `addon` — every cap that ships inside a given addon id. Niche;
44556
- * useful when an integration needs to interact with one specific
44557
- * addon's surface regardless of how many caps it exports.
44558
- *
44559
- * - `capability` — the most precise form. Single cap name. Use for
44560
- * integration tokens where you want to grant `addons.installPackage`
44561
- * and nothing else.
44562
- *
44563
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44564
- * "give me everything" escape; there is no wildcard scope.
44565
- */
44566
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44567
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44568
- var CapScopeSchema = _enum(["device", "system"]);
44569
- /**
44570
- * DeviceSelector (scope model v3 — 2026-08-12).
44571
- *
44572
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44573
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44574
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44575
- * AFTER the grant was minted — no re-grant, no re-login.
44576
- *
44577
- * - `all` — every device in the deployment. The broad viewer/operator
44578
- * lever without a `category` grant (a `category` grant also covers device
44579
- * caps that carry no deviceId; `all` is specifically the device set).
44580
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44581
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44582
- * is NOT covered until the grant is edited.
44583
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44584
- * DYNAMIC. A device that changes type, or a new device of the type,
44585
- * re-resolves on the next request.
44586
- * - `locations` — every device whose operator-assigned `location` label is
44587
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44588
- * null/unset location matches NO `locations` selector.
44589
- */
44590
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44591
- object({ kind: literal("all") }),
44592
- object({
44593
- kind: literal("ids"),
44594
- ids: array(number().int()).min(1)
44595
- }),
44596
- object({
44597
- kind: literal("types"),
44598
- types: array(_enum(DeviceType)).min(1)
44599
- }),
44600
- object({
44601
- kind: literal("locations"),
44602
- locations: array(string().min(1)).min(1)
44603
- })
44604
- ]);
44605
- var DeviceTokenScopeSchema = object({
44606
- type: literal("device"),
44607
- /** The device SET this grant covers — resolved against the live fleet. */
44608
- selector: DeviceSelectorSchema,
44609
- access: array(MethodAccessSchema).min(1),
44610
- /**
44611
- * Whether a grant on a PARENT device transparently covers its accessory
44612
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44613
- * Direction is parent → children ONLY.
44614
- *
44615
- * Absent → the matcher DERIVES it from the access flavour: `view`
44616
- * inherits (a camera viewer sees the camera's accessories), `create` /
44617
- * `delete` do NOT (actuating/removing a child is an explicit act the
44618
- * operator must grant on the child, not inherit from the parent). Set it
44619
- * explicitly to override that default per grant.
44620
- */
44621
- includeLinked: boolean().optional()
44622
- });
44623
- /**
44624
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44625
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44626
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44627
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44628
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44629
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44630
- * migration cannot reach a JWT already in a client's hands; parse-time
44631
- * migration covers both without a flag day. No cast — the raw object is read
44632
- * through `Reflect.get` (its static type is `unknown`).
44633
- */
44634
- function migrateLegacyTokenScope(raw) {
44635
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44636
- if (Reflect.get(raw, "type") !== "device") return raw;
44637
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44638
- const targets = Reflect.get(raw, "targets");
44639
- if (!Array.isArray(targets)) return raw;
44640
- return {
44641
- type: "device",
44642
- selector: {
44643
- kind: "ids",
44644
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44645
- },
44646
- access: Reflect.get(raw, "access")
44647
- };
44648
- }
44649
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44650
- object({
44651
- type: literal("category"),
44652
- target: CapScopeSchema,
44653
- access: array(MethodAccessSchema).min(1)
44654
- }),
44655
- object({
44656
- type: literal("capability"),
44657
- target: string(),
44658
- access: array(MethodAccessSchema).min(1)
44659
- }),
44660
- object({
44661
- type: literal("addon"),
44662
- target: string(),
44663
- access: array(MethodAccessSchema).min(1)
44664
- }),
44665
- DeviceTokenScopeSchema
44666
- ]));
44667
- object({
44668
- id: string(),
44669
- username: string(),
44670
- passwordHash: string(),
44671
- /**
44672
- * Admin bypass. When true, the middleware skips the scope-access
44673
- * check entirely. There is no other axis of privilege; the legacy
44674
- * role enum collapsed onto this boolean in v2.
44675
- */
44676
- isAdmin: boolean().default(false),
44677
- allowedProviders: AllowedProviderSchema,
44678
- allowedDevices: AllowedDevicesSchema,
44679
- /**
44680
- * Scopes granted to this user. Admins bypass; their `scopes` is
44681
- * ignored. Non-admins without scopes are locked out of every
44682
- * protected call.
44683
- */
44684
- scopes: array(TokenScopeSchema).default([]),
44685
- createdAt: number(),
44686
- updatedAt: number()
44687
- });
44688
- object({
44689
- id: string(),
44690
- label: string(),
44691
- isAdmin: boolean().default(false),
44692
- allowedProviders: AllowedProviderSchema,
44693
- allowedDevices: AllowedDevicesSchema,
44694
- tokenHash: string(),
44695
- tokenPrefix: string(),
44696
- createdAt: number(),
44697
- lastUsedAt: number().optional()
44698
- });
44699
- object({
44700
- id: string(),
44701
- userId: string(),
44702
- name: string(),
44703
- tokenHash: string(),
44704
- tokenPrefix: string(),
44705
- scopes: array(TokenScopeSchema),
44706
- expiresAt: number().nullish(),
44707
- lastUsedAt: number().nullish(),
44708
- createdAt: number()
44709
- });
44710
- /**
44711
44859
  * `oauth-integration` — a collection cap by which an addon declares
44712
44860
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44713
44861
  * Each provider returns a static descriptor; the core enumerates them
@@ -64507,26 +64655,6 @@ var ApiKeySummarySchema = object({
64507
64655
  createdAt: number(),
64508
64656
  lastUsedAt: number().optional()
64509
64657
  });
64510
- var ScopedTokenSummarySchema = object({
64511
- id: string(),
64512
- userId: string(),
64513
- name: string(),
64514
- tokenPrefix: string(),
64515
- scopes: array(TokenScopeSchema),
64516
- expiresAt: number().nullish(),
64517
- lastUsedAt: number().nullish(),
64518
- createdAt: number()
64519
- });
64520
- var CreateScopedTokenInputSchema = object({
64521
- userId: string(),
64522
- name: string(),
64523
- scopes: array(TokenScopeSchema),
64524
- expiresAt: number().optional()
64525
- });
64526
- var CreateScopedTokenResultSchema = object({
64527
- token: string(),
64528
- record: ScopedTokenSummarySchema
64529
- });
64530
64658
  var OauthSessionSummarySchema = object({
64531
64659
  id: string(),
64532
64660
  userId: string(),
@@ -64548,11 +64676,11 @@ var TotpStatusSchema = object({
64548
64676
  confirmedAt: number().nullable()
64549
64677
  });
64550
64678
  /**
64551
- * user-management — singleton capability for user accounts, API keys,
64552
- * and scoped tokens.
64679
+ * user-management — singleton capability for user accounts and the
64680
+ * legacy API-key rows.
64553
64681
  *
64554
64682
  * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
64555
- * — the subset check on `setUserScopes` / `createScopedToken` is moot
64683
+ * — the subset check on `setUserScopes` is moot
64556
64684
  * because non-admins never reach these. If/when we open non-admin
64557
64685
  * delegation, structural caller-scope subset check goes inside the
64558
64686
  * provider.
@@ -64609,15 +64737,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
64609
64737
  kind: "mutation",
64610
64738
  auth: "admin",
64611
64739
  access: "delete"
64612
- }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
64613
- kind: "mutation",
64614
- auth: "admin",
64615
- access: "create"
64616
- }), method(object({ id: string() }), object({ success: literal(true) }), {
64617
- kind: "mutation",
64618
- auth: "admin",
64619
- access: "delete"
64620
- }), method(object({ token: string() }), ScopedTokenSummarySchema.nullable(), { access: "view" }), method(object({ userId: string() }), array(ScopedTokenSummarySchema), { auth: "admin" }), method(object({ userId: string() }), TotpSetupResultSchema, {
64740
+ }), method(object({ userId: string() }), TotpSetupResultSchema, {
64621
64741
  kind: "mutation",
64622
64742
  auth: "admin",
64623
64743
  access: "create"
@@ -70707,7 +70827,7 @@ Object.freeze({
70707
70827
  capName: "llm",
70708
70828
  capScope: "system",
70709
70829
  addonId: null,
70710
- access: "view"
70830
+ access: "create"
70711
70831
  },
70712
70832
  "llm.listNodeModels": {
70713
70833
  capName: "llm",
@@ -75371,12 +75491,6 @@ Object.freeze({
75371
75491
  addonId: null,
75372
75492
  access: "create"
75373
75493
  },
75374
- "userManagement.createScopedToken": {
75375
- capName: "user-management",
75376
- capScope: "system",
75377
- addonId: null,
75378
- access: "create"
75379
- },
75380
75494
  "userManagement.createUser": {
75381
75495
  capName: "user-management",
75382
75496
  capScope: "system",
@@ -75425,12 +75539,6 @@ Object.freeze({
75425
75539
  addonId: null,
75426
75540
  access: "view"
75427
75541
  },
75428
- "userManagement.listScopedTokens": {
75429
- capName: "user-management",
75430
- capScope: "system",
75431
- addonId: null,
75432
- access: "view"
75433
- },
75434
75542
  "userManagement.listUsers": {
75435
75543
  capName: "user-management",
75436
75544
  capScope: "system",
@@ -75485,12 +75593,6 @@ Object.freeze({
75485
75593
  addonId: null,
75486
75594
  access: "delete"
75487
75595
  },
75488
- "userManagement.revokeScopedToken": {
75489
- capName: "user-management",
75490
- capScope: "system",
75491
- addonId: null,
75492
- access: "delete"
75493
- },
75494
75596
  "userManagement.setupTotp": {
75495
75597
  capName: "user-management",
75496
75598
  capScope: "system",
@@ -75521,12 +75623,6 @@ Object.freeze({
75521
75623
  addonId: null,
75522
75624
  access: "view"
75523
75625
  },
75524
- "userManagement.validateScopedToken": {
75525
- capName: "user-management",
75526
- capScope: "system",
75527
- addonId: null,
75528
- access: "view"
75529
- },
75530
75626
  "userManagement.verifyTotp": {
75531
75627
  capName: "user-management",
75532
75628
  capScope: "system",