@camstack/addon-export-hap 1.2.161 → 1.2.163

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.
@@ -5464,7 +5464,7 @@ var ZodIssueCode = {
5464
5464
  var ZodFirstPartyTypeKind;
5465
5465
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5466
5466
  //#endregion
5467
- //#region ../types/dist/sleep-BxjU_fJM.mjs
5467
+ //#region ../types/dist/sleep-yKL5gfrH.mjs
5468
5468
  /**
5469
5469
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5470
5470
  * window to float samples (D455).
@@ -7846,6 +7846,12 @@ function normalizeAddonInitResult(result) {
7846
7846
  if (Array.isArray(result)) return { providers: result };
7847
7847
  return result;
7848
7848
  }
7849
+ /**
7850
+ * The share-view scope kinds a share-link token can carry. The hub mints
7851
+ * and validates them (`ShareViewGrantSchema` builds its
7852
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
7853
+ */
7854
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7849
7855
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7850
7856
  var PeerBytesTicketSchema = object({
7851
7857
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -13318,6 +13324,280 @@ var ConvertResultSchema = object({
13318
13324
  files: array(string()).readonly()
13319
13325
  })).readonly()
13320
13326
  });
13327
+ /**
13328
+ * Zod schemas for persisted record types.
13329
+ *
13330
+ * These schemas serve as the single source of truth for types that are
13331
+ * stored in the settings-store backend and retrieved via tRPC. They
13332
+ * replace the manual TypeScript interfaces with schema-derived types,
13333
+ * enabling runtime validation when reading from the backend.
13334
+ *
13335
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
13336
+ * keeps the original name for backward compatibility.
13337
+ */
13338
+ /**
13339
+ * Auth model (v2 — 2026-05-12 caps-only):
13340
+ *
13341
+ * Two principals:
13342
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
13343
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
13344
+ *
13345
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
13346
+ * `super_admin` — collapsed onto the single boolean because every
13347
+ * non-admin caller is governed by the same scope-check rules; the
13348
+ * distinction was only ever used to route role-specific procedures
13349
+ * which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
13350
+ * with `isAdmin: false` + an explicit scope list.
13351
+ */
13352
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
13353
+ var MethodAccessSchema = _enum([
13354
+ "view",
13355
+ "create",
13356
+ "delete"
13357
+ ]);
13358
+ /**
13359
+ * A single scope grant. Three forms — checked in matcher with OR
13360
+ * semantics; the first match decides whether the call passes:
13361
+ *
13362
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
13363
+ * cap with the matching `scope` declaration. New caps inherit grants
13364
+ * automatically — adding a device cap to the codebase makes it
13365
+ * reachable to every user with `category:device [...]` without a
13366
+ * re-grant. Use this for "family viewer" / "operator" tiers.
13367
+ *
13368
+ * - `addon` — every cap that ships inside a given addon id. Niche;
13369
+ * useful when an integration needs to interact with one specific
13370
+ * addon's surface regardless of how many caps it exports.
13371
+ *
13372
+ * - `capability` — the most precise form. Single cap name. Use for
13373
+ * integration tokens where you want to grant `addons.installPackage`
13374
+ * and nothing else.
13375
+ *
13376
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
13377
+ * "give me everything" escape; there is no wildcard scope.
13378
+ */
13379
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
13380
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
13381
+ var CapScopeSchema = _enum(["device", "system"]);
13382
+ /**
13383
+ * DeviceSelector (scope model v3 — 2026-08-12).
13384
+ *
13385
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
13386
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
13387
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
13388
+ * AFTER the grant was minted — no re-grant, no re-login.
13389
+ *
13390
+ * - `all` — every device in the deployment. The broad viewer/operator
13391
+ * lever without a `category` grant (a `category` grant also covers device
13392
+ * caps that carry no deviceId; `all` is specifically the device set).
13393
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
13394
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
13395
+ * is NOT covered until the grant is edited.
13396
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
13397
+ * DYNAMIC. A device that changes type, or a new device of the type,
13398
+ * re-resolves on the next request.
13399
+ * - `locations` — every device whose operator-assigned `location` label is
13400
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
13401
+ * null/unset location matches NO `locations` selector.
13402
+ */
13403
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
13404
+ object({ kind: literal("all") }),
13405
+ object({
13406
+ kind: literal("ids"),
13407
+ ids: array(number().int()).min(1)
13408
+ }),
13409
+ object({
13410
+ kind: literal("types"),
13411
+ types: array(_enum(DeviceType)).min(1)
13412
+ }),
13413
+ object({
13414
+ kind: literal("locations"),
13415
+ locations: array(string().min(1)).min(1)
13416
+ })
13417
+ ]);
13418
+ var DeviceTokenScopeSchema = object({
13419
+ type: literal("device"),
13420
+ /** The device SET this grant covers — resolved against the live fleet. */
13421
+ selector: DeviceSelectorSchema,
13422
+ access: array(MethodAccessSchema).min(1),
13423
+ /**
13424
+ * Whether a grant on a PARENT device transparently covers its accessory
13425
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
13426
+ * Direction is parent → children ONLY.
13427
+ *
13428
+ * Absent → the matcher DERIVES it from the access flavour: `view`
13429
+ * inherits (a camera viewer sees the camera's accessories), `create` /
13430
+ * `delete` do NOT (actuating/removing a child is an explicit act the
13431
+ * operator must grant on the child, not inherit from the parent). Set it
13432
+ * explicitly to override that default per grant.
13433
+ */
13434
+ includeLinked: boolean().optional()
13435
+ });
13436
+ /**
13437
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
13438
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
13439
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
13440
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
13441
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
13442
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
13443
+ * migration cannot reach a JWT already in a client's hands; parse-time
13444
+ * migration covers both without a flag day. No cast — the raw object is read
13445
+ * through `Reflect.get` (its static type is `unknown`).
13446
+ */
13447
+ function migrateLegacyTokenScope(raw) {
13448
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
13449
+ if (Reflect.get(raw, "type") !== "device") return raw;
13450
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
13451
+ const targets = Reflect.get(raw, "targets");
13452
+ if (!Array.isArray(targets)) return raw;
13453
+ return {
13454
+ type: "device",
13455
+ selector: {
13456
+ kind: "ids",
13457
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
13458
+ },
13459
+ access: Reflect.get(raw, "access")
13460
+ };
13461
+ }
13462
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
13463
+ object({
13464
+ type: literal("category"),
13465
+ target: CapScopeSchema,
13466
+ access: array(MethodAccessSchema).min(1)
13467
+ }),
13468
+ object({
13469
+ type: literal("capability"),
13470
+ target: string(),
13471
+ access: array(MethodAccessSchema).min(1)
13472
+ }),
13473
+ object({
13474
+ type: literal("addon"),
13475
+ target: string(),
13476
+ access: array(MethodAccessSchema).min(1)
13477
+ }),
13478
+ DeviceTokenScopeSchema
13479
+ ]));
13480
+ object({
13481
+ id: string(),
13482
+ username: string(),
13483
+ passwordHash: string(),
13484
+ /**
13485
+ * Admin bypass. When true, the middleware skips the scope-access
13486
+ * check entirely. There is no other axis of privilege; the legacy
13487
+ * role enum collapsed onto this boolean in v2.
13488
+ */
13489
+ isAdmin: boolean().default(false),
13490
+ allowedProviders: AllowedProviderSchema,
13491
+ allowedDevices: AllowedDevicesSchema,
13492
+ /**
13493
+ * Scopes granted to this user. Admins bypass; their `scopes` is
13494
+ * ignored. Non-admins without scopes are locked out of every
13495
+ * protected call.
13496
+ */
13497
+ scopes: array(TokenScopeSchema).default([]),
13498
+ createdAt: number(),
13499
+ updatedAt: number()
13500
+ });
13501
+ object({
13502
+ id: string(),
13503
+ label: string(),
13504
+ isAdmin: boolean().default(false),
13505
+ allowedProviders: AllowedProviderSchema,
13506
+ allowedDevices: AllowedDevicesSchema,
13507
+ tokenHash: string(),
13508
+ tokenPrefix: string(),
13509
+ createdAt: number(),
13510
+ lastUsedAt: number().optional()
13511
+ });
13512
+ object({
13513
+ id: string(),
13514
+ userId: string(),
13515
+ name: string(),
13516
+ tokenHash: string(),
13517
+ tokenPrefix: string(),
13518
+ scopes: array(TokenScopeSchema),
13519
+ expiresAt: number().nullish(),
13520
+ lastUsedAt: number().nullish(),
13521
+ createdAt: number()
13522
+ });
13523
+ /** What a share-view grant lets its holder see. */
13524
+ var ShareViewGrantSchema = object({
13525
+ kind: _enum(SHARE_VIEW_KINDS),
13526
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
13527
+ /** Talk-back, opt-in at mint time; absent means off. */
13528
+ talk: boolean().optional()
13529
+ });
13530
+ var ShareViewScopeSchema = object({
13531
+ type: literal("share-view"),
13532
+ grant: ShareViewGrantSchema
13533
+ });
13534
+ var AddonRoutesScopeSchema = object({
13535
+ type: literal("addon-routes"),
13536
+ access: array(MethodAccessSchema).min(1)
13537
+ });
13538
+ var PreferencesSelfScopeSchema = object({ type: literal("preferences-self") });
13539
+ var CredentialScopeSchema = union([
13540
+ literal("*"),
13541
+ ShareViewScopeSchema,
13542
+ AddonRoutesScopeSchema,
13543
+ PreferencesSelfScopeSchema,
13544
+ TokenScopeSchema
13545
+ ]);
13546
+ object({
13547
+ kind: literal("credential"),
13548
+ sub: string().min(1),
13549
+ jti: string().min(16),
13550
+ scopes: array(CredentialScopeSchema).min(1)
13551
+ });
13552
+ var PreferenceNamespaceSchema = string().regex(/^[a-z][a-z0-9.-]{0,63}$/);
13553
+ /** A namespace's value: a JSON object, opaque to the hub. */
13554
+ var PreferenceValueSchema = record(string(), unknown());
13555
+ var PreferenceDeviceIdSchema = string().min(1).max(64);
13556
+ /** A stored row, as the owner reads it. */
13557
+ var PreferenceRowSchema = object({
13558
+ namespace: PreferenceNamespaceSchema,
13559
+ value: PreferenceValueSchema,
13560
+ /** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
13561
+ revision: number().int().positive(),
13562
+ updatedAt: number().int(),
13563
+ /** The client id the last writer sent; `null` when it sent none. */
13564
+ updatedByDevice: PreferenceDeviceIdSchema.nullable()
13565
+ });
13566
+ object({
13567
+ /** Absent: every namespace the caller holds. */
13568
+ namespaces: array(PreferenceNamespaceSchema).max(32).optional() });
13569
+ object({ rows: array(PreferenceRowSchema) });
13570
+ object({
13571
+ namespace: PreferenceNamespaceSchema,
13572
+ value: PreferenceValueSchema,
13573
+ /**
13574
+ * The revision the edit was based on. Absent: last write wins. `0`: the
13575
+ * namespace must not exist yet. Any other value that is not the current
13576
+ * revision answers `conflict` and writes nothing.
13577
+ */
13578
+ baseRevision: number().int().nonnegative().optional(),
13579
+ deviceId: PreferenceDeviceIdSchema.optional()
13580
+ });
13581
+ discriminatedUnion("status", [object({
13582
+ status: literal("saved"),
13583
+ row: PreferenceRowSchema
13584
+ }), object({
13585
+ status: literal("conflict"),
13586
+ current: PreferenceRowSchema.nullable()
13587
+ })]);
13588
+ object({ namespace: PreferenceNamespaceSchema });
13589
+ object({
13590
+ /** `false` when the namespace did not exist. */
13591
+ deleted: boolean() });
13592
+ object({
13593
+ /** The revision the client holds per namespace; a namespace it does not list is new to it. */
13594
+ revisionByNamespace: record(PreferenceNamespaceSchema, number().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
13595
+ object({
13596
+ /** Every row whose revision differs from the client's, and every row it did not list. */
13597
+ rows: array(PreferenceRowSchema),
13598
+ /** Namespaces the client listed that no longer exist. */
13599
+ deleted: array(PreferenceNamespaceSchema)
13600
+ });
13321
13601
  _enum(["new-session", "step-up"]);
13322
13602
  /** The languages the hub's app landing pages are written in (D858). */
13323
13603
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -40277,38 +40557,37 @@ method(LlmRuntimeCompleteInputSchema, LlmGenerateResultSchema, {
40277
40557
  auth: "admin",
40278
40558
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
40279
40559
  });
40560
+ var LlmProfileKindSchema = string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "a kind id is lower-case letters, digits and dashes");
40561
+ /** What a model (or, by default, every model of a kind) can do. */
40562
+ var LlmModelFeaturesSchema = object({
40563
+ vision: boolean(),
40564
+ tools: boolean(),
40565
+ streaming: boolean()
40566
+ });
40567
+ /** One model a provider offers. `features` overrides the kind's defaults, per field. */
40568
+ var LlmModelInfoSchema = object({
40569
+ id: string(),
40570
+ label: string().optional(),
40571
+ contextLength: number().int().positive().optional(),
40572
+ features: LlmModelFeaturesSchema.partial().optional()
40573
+ });
40280
40574
  /**
40281
- * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
40282
- * methods concat-fan across providers; single-row methods route to ONE
40283
- * provider by the `addonId` in the call input (the notification-output
40284
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
40285
- * (hub-placed); the cap stays open for future providers.
40286
- *
40287
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
40288
- * `apiKey` is a password field — providers REDACT it on read and merge on
40289
- * write; a stored key NEVER round-trips to a client.
40575
+ * The provider-specific part of a profile, validated by the provider that owns
40576
+ * the kind (`upsertProfile` refuses what it does not accept). A field its
40577
+ * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
40578
+ * keychain, never in the row, and reads back as the redaction marker.
40290
40579
  */
40291
- var LlmProfileKindSchema = _enum([
40292
- "openai-compatible",
40293
- "openai",
40294
- "anthropic",
40295
- "google",
40296
- "managed-local",
40297
- "apple-foundation"
40298
- ]);
40580
+ var LlmProviderConfigSchema = record(string(), unknown());
40299
40581
  var LlmProfileSchema = object({
40300
40582
  id: string(),
40301
40583
  name: string(),
40584
+ /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
40302
40585
  kind: LlmProfileKindSchema,
40303
40586
  /** Stamped by the provider — keeps the fanned catalog routable. */
40304
40587
  addonId: string(),
40305
40588
  enabled: boolean(),
40306
40589
  /** Vendor model id, or the managed runtime's loaded model. */
40307
40590
  model: string(),
40308
- /** Required for openai-compatible; override for cloud kinds. */
40309
- baseUrl: string().optional(),
40310
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
40311
- apiKey: string().optional(),
40312
40591
  /** Vision on/off. A vision call against a `false` profile is REFUSED, never
40313
40592
  * degraded to text — that shipped once and produced a confident answer to a
40314
40593
  * question about a picture nobody sent. */
@@ -40316,15 +40595,11 @@ var LlmProfileSchema = object({
40316
40595
  temperature: number().min(0).max(2).optional(),
40317
40596
  /** Nucleus sampling. Every wire we speak has it. */
40318
40597
  topP: number().min(0).max(1).optional(),
40319
- /** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
40320
- * wire does, and the client drops it there (measured: the request body gets
40321
- * `top_p` and no `top_k`). The profile editor hides the field wherever it
40322
- * would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
40598
+ /** Top-k sampling. Carried only by the wires that have it — a kind offers the
40599
+ * field in its editor only when its descriptor lists it in `profileFields`. */
40323
40600
  topK: number().int().positive().optional(),
40324
40601
  maxTokens: number().int().positive().optional(),
40325
- /** Prompt context window. Advisory for cloud kinds (they enforce their own);
40326
- * for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
40327
- * the model with, so it is the one field that changes a PROCESS. */
40602
+ /** Prompt context window. Advisory for cloud kinds (they enforce their own). */
40328
40603
  contextLength: number().int().positive().optional(),
40329
40604
  /** Default system prompt. A caller's `system` REPLACES it (never appends —
40330
40605
  * two system prompts fighting is worse than either alone). */
@@ -40350,16 +40625,37 @@ var LlmProfileSchema = object({
40350
40625
  * library; the REGISTRY of callable tools is ours and is empty in v1, so a
40351
40626
  * `true` here buys the wiring, not behaviour, until tools are registered. */
40352
40627
  toolsEnabled: boolean().default(false),
40353
- extraHeaders: record(string(), string()).optional(),
40354
- /** kind === 'managed-local' only (spec §4). */
40355
- runtime: ManagedRuntimeConfigSchema.optional(),
40356
- /**
40357
- * kind === 'apple-foundation' only: WHERE it runs — the only thing there is
40358
- * to configure (no key, no URL, no download; `model` is `apple-system`).
40359
- * `supportsVision` on such a row is stamped by the provider from the node's
40360
- * reported `imageInput`, never taken from the operator (D62).
40361
- */
40362
- appleFoundation: object({ nodeId: string() }).optional()
40628
+ /** Everything the kind's provider owns (endpoint, key, node, runtime…). */
40629
+ providerConfig: LlmProviderConfigSchema.default({})
40630
+ });
40631
+ /**
40632
+ * The common profile fields a kind's editor offers. The editor owns how each
40633
+ * one is drawn; the provider says which of them mean something on its wire.
40634
+ */
40635
+ var LlmProfileFieldSchema = _enum([
40636
+ "temperature",
40637
+ "topP",
40638
+ "topK",
40639
+ "maxTokens",
40640
+ "contextLength",
40641
+ "systemPrompt",
40642
+ "timeoutMs",
40643
+ "connectTimeoutMs",
40644
+ "firstTokenTimeoutMs",
40645
+ "idleTimeoutMs",
40646
+ "retry",
40647
+ "toolsEnabled"
40648
+ ]);
40649
+ /**
40650
+ * A provider-drawn part of the editor, by a generic widget id the admin UI
40651
+ * registers (`ai/apple-node`). `placement: 'model'` replaces the generic model
40652
+ * picker: that widget owns the model choice.
40653
+ */
40654
+ var LlmProviderWidgetSchema = object({
40655
+ id: string(),
40656
+ placement: _enum(["connection", "model"]),
40657
+ /** `providerConfig` keys this widget must fill before the profile can be saved. */
40658
+ requires: array(string()).optional()
40363
40659
  });
40364
40660
  /** ConfigUISchema tree passed through untyped on the wire (the
40365
40661
  * notification-output `ConfigSchemaPassthrough` precedent at
@@ -40368,11 +40664,56 @@ var ConfigSchemaPassthrough$3 = unknown();
40368
40664
  var LlmProfileKindDescriptorSchema = object({
40369
40665
  kind: LlmProfileKindSchema,
40370
40666
  label: string(),
40667
+ /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
40371
40668
  icon: string(),
40372
40669
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
40373
40670
  addonId: string(),
40374
- configSchema: ConfigSchemaPassthrough$3
40671
+ /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
40672
+ connectionSchema: ConfigSchemaPassthrough$3,
40673
+ /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
40674
+ advancedSchema: ConfigSchemaPassthrough$3.optional(),
40675
+ /** The kind's defaults; a model from `listModels` may override any of them. */
40676
+ features: LlmModelFeaturesSchema,
40677
+ /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
40678
+ visionEditable: boolean(),
40679
+ /** Where the model list comes from: `listModels`, `staticModels`, or nowhere. */
40680
+ modelCatalog: _enum([
40681
+ "fetch",
40682
+ "static",
40683
+ "none"
40684
+ ]),
40685
+ staticModels: array(LlmModelInfoSchema).optional(),
40686
+ /** The common fields that mean something on this kind's wire. */
40687
+ profileFields: array(LlmProfileFieldSchema),
40688
+ providerWidgets: array(LlmProviderWidgetSchema).optional()
40689
+ });
40690
+ /**
40691
+ * `listModels` input. `connection` is an UNSAVED draft of `providerConfig`
40692
+ * (the editor's form); with `profileId` too, a secret the draft leaves
40693
+ * untouched (absent or the redaction marker) is resolved server-side from the
40694
+ * stored profile — the browser never receives it.
40695
+ */
40696
+ var LlmListModelsInputSchema = object({
40697
+ addonId: string(),
40698
+ kind: LlmProfileKindSchema,
40699
+ profileId: string().optional(),
40700
+ connection: LlmProviderConfigSchema.optional()
40375
40701
  });
40702
+ var LlmListModelsErrorCodeSchema = _enum([
40703
+ "auth",
40704
+ "network",
40705
+ "unsupported",
40706
+ "invalid"
40707
+ ]);
40708
+ /** A RESULT, never a throw: "wrong key" is an answer the editor renders inline. */
40709
+ var LlmListModelsResultSchema = discriminatedUnion("ok", [object({
40710
+ ok: literal(true),
40711
+ models: array(LlmModelInfoSchema)
40712
+ }), object({
40713
+ ok: literal(false),
40714
+ code: LlmListModelsErrorCodeSchema,
40715
+ message: string()
40716
+ })]);
40376
40717
  var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
40377
40718
  var LlmDefaultSchema = object({
40378
40719
  selector: LlmDefaultSelectorSchema,
@@ -40472,7 +40813,10 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
40472
40813
  kind: "mutation",
40473
40814
  auth: "admin",
40474
40815
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
40475
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
40816
+ }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
40817
+ kind: "mutation",
40818
+ auth: "admin"
40819
+ }), method(object({}), array(LlmDefaultSchema)), method(object({
40476
40820
  selector: LlmDefaultSelectorSchema,
40477
40821
  profileId: string().nullable()
40478
40822
  }), _void(), {
@@ -44536,202 +44880,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
44536
44880
  auth: "admin"
44537
44881
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
44538
44882
  /**
44539
- * Zod schemas for persisted record types.
44540
- *
44541
- * These schemas serve as the single source of truth for types that are
44542
- * stored in the settings-store backend and retrieved via tRPC. They
44543
- * replace the manual TypeScript interfaces with schema-derived types,
44544
- * enabling runtime validation when reading from the backend.
44545
- *
44546
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
44547
- * keeps the original name for backward compatibility.
44548
- */
44549
- /**
44550
- * Auth model (v2 — 2026-05-12 caps-only):
44551
- *
44552
- * Two principals:
44553
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
44554
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
44555
- *
44556
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44557
- * `super_admin` — collapsed onto the single boolean because every
44558
- * non-admin caller is governed by the same scope-check rules; the
44559
- * distinction was only ever used to route role-specific procedures
44560
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44561
- * with `isAdmin: false` + an explicit scope list.
44562
- */
44563
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44564
- var MethodAccessSchema = _enum([
44565
- "view",
44566
- "create",
44567
- "delete"
44568
- ]);
44569
- /**
44570
- * A single scope grant. Three forms — checked in matcher with OR
44571
- * semantics; the first match decides whether the call passes:
44572
- *
44573
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44574
- * cap with the matching `scope` declaration. New caps inherit grants
44575
- * automatically — adding a device cap to the codebase makes it
44576
- * reachable to every user with `category:device [...]` without a
44577
- * re-grant. Use this for "family viewer" / "operator" tiers.
44578
- *
44579
- * - `addon` — every cap that ships inside a given addon id. Niche;
44580
- * useful when an integration needs to interact with one specific
44581
- * addon's surface regardless of how many caps it exports.
44582
- *
44583
- * - `capability` — the most precise form. Single cap name. Use for
44584
- * integration tokens where you want to grant `addons.installPackage`
44585
- * and nothing else.
44586
- *
44587
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44588
- * "give me everything" escape; there is no wildcard scope.
44589
- */
44590
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44591
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44592
- var CapScopeSchema = _enum(["device", "system"]);
44593
- /**
44594
- * DeviceSelector (scope model v3 — 2026-08-12).
44595
- *
44596
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44597
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44598
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44599
- * AFTER the grant was minted — no re-grant, no re-login.
44600
- *
44601
- * - `all` — every device in the deployment. The broad viewer/operator
44602
- * lever without a `category` grant (a `category` grant also covers device
44603
- * caps that carry no deviceId; `all` is specifically the device set).
44604
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44605
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44606
- * is NOT covered until the grant is edited.
44607
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44608
- * DYNAMIC. A device that changes type, or a new device of the type,
44609
- * re-resolves on the next request.
44610
- * - `locations` — every device whose operator-assigned `location` label is
44611
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44612
- * null/unset location matches NO `locations` selector.
44613
- */
44614
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44615
- object({ kind: literal("all") }),
44616
- object({
44617
- kind: literal("ids"),
44618
- ids: array(number().int()).min(1)
44619
- }),
44620
- object({
44621
- kind: literal("types"),
44622
- types: array(_enum(DeviceType)).min(1)
44623
- }),
44624
- object({
44625
- kind: literal("locations"),
44626
- locations: array(string().min(1)).min(1)
44627
- })
44628
- ]);
44629
- var DeviceTokenScopeSchema = object({
44630
- type: literal("device"),
44631
- /** The device SET this grant covers — resolved against the live fleet. */
44632
- selector: DeviceSelectorSchema,
44633
- access: array(MethodAccessSchema).min(1),
44634
- /**
44635
- * Whether a grant on a PARENT device transparently covers its accessory
44636
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44637
- * Direction is parent → children ONLY.
44638
- *
44639
- * Absent → the matcher DERIVES it from the access flavour: `view`
44640
- * inherits (a camera viewer sees the camera's accessories), `create` /
44641
- * `delete` do NOT (actuating/removing a child is an explicit act the
44642
- * operator must grant on the child, not inherit from the parent). Set it
44643
- * explicitly to override that default per grant.
44644
- */
44645
- includeLinked: boolean().optional()
44646
- });
44647
- /**
44648
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44649
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44650
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44651
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44652
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44653
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44654
- * migration cannot reach a JWT already in a client's hands; parse-time
44655
- * migration covers both without a flag day. No cast — the raw object is read
44656
- * through `Reflect.get` (its static type is `unknown`).
44657
- */
44658
- function migrateLegacyTokenScope(raw) {
44659
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44660
- if (Reflect.get(raw, "type") !== "device") return raw;
44661
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44662
- const targets = Reflect.get(raw, "targets");
44663
- if (!Array.isArray(targets)) return raw;
44664
- return {
44665
- type: "device",
44666
- selector: {
44667
- kind: "ids",
44668
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44669
- },
44670
- access: Reflect.get(raw, "access")
44671
- };
44672
- }
44673
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44674
- object({
44675
- type: literal("category"),
44676
- target: CapScopeSchema,
44677
- access: array(MethodAccessSchema).min(1)
44678
- }),
44679
- object({
44680
- type: literal("capability"),
44681
- target: string(),
44682
- access: array(MethodAccessSchema).min(1)
44683
- }),
44684
- object({
44685
- type: literal("addon"),
44686
- target: string(),
44687
- access: array(MethodAccessSchema).min(1)
44688
- }),
44689
- DeviceTokenScopeSchema
44690
- ]));
44691
- object({
44692
- id: string(),
44693
- username: string(),
44694
- passwordHash: string(),
44695
- /**
44696
- * Admin bypass. When true, the middleware skips the scope-access
44697
- * check entirely. There is no other axis of privilege; the legacy
44698
- * role enum collapsed onto this boolean in v2.
44699
- */
44700
- isAdmin: boolean().default(false),
44701
- allowedProviders: AllowedProviderSchema,
44702
- allowedDevices: AllowedDevicesSchema,
44703
- /**
44704
- * Scopes granted to this user. Admins bypass; their `scopes` is
44705
- * ignored. Non-admins without scopes are locked out of every
44706
- * protected call.
44707
- */
44708
- scopes: array(TokenScopeSchema).default([]),
44709
- createdAt: number(),
44710
- updatedAt: number()
44711
- });
44712
- object({
44713
- id: string(),
44714
- label: string(),
44715
- isAdmin: boolean().default(false),
44716
- allowedProviders: AllowedProviderSchema,
44717
- allowedDevices: AllowedDevicesSchema,
44718
- tokenHash: string(),
44719
- tokenPrefix: string(),
44720
- createdAt: number(),
44721
- lastUsedAt: number().optional()
44722
- });
44723
- object({
44724
- id: string(),
44725
- userId: string(),
44726
- name: string(),
44727
- tokenHash: string(),
44728
- tokenPrefix: string(),
44729
- scopes: array(TokenScopeSchema),
44730
- expiresAt: number().nullish(),
44731
- lastUsedAt: number().nullish(),
44732
- createdAt: number()
44733
- });
44734
- /**
44735
44883
  * `oauth-integration` — a collection cap by which an addon declares
44736
44884
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44737
44885
  * Each provider returns a static descriptor; the core enumerates them
@@ -61917,26 +62065,6 @@ var ApiKeySummarySchema = object({
61917
62065
  createdAt: number(),
61918
62066
  lastUsedAt: number().optional()
61919
62067
  });
61920
- var ScopedTokenSummarySchema = object({
61921
- id: string(),
61922
- userId: string(),
61923
- name: string(),
61924
- tokenPrefix: string(),
61925
- scopes: array(TokenScopeSchema),
61926
- expiresAt: number().nullish(),
61927
- lastUsedAt: number().nullish(),
61928
- createdAt: number()
61929
- });
61930
- var CreateScopedTokenInputSchema = object({
61931
- userId: string(),
61932
- name: string(),
61933
- scopes: array(TokenScopeSchema),
61934
- expiresAt: number().optional()
61935
- });
61936
- var CreateScopedTokenResultSchema = object({
61937
- token: string(),
61938
- record: ScopedTokenSummarySchema
61939
- });
61940
62068
  var OauthSessionSummarySchema = object({
61941
62069
  id: string(),
61942
62070
  userId: string(),
@@ -61958,11 +62086,11 @@ var TotpStatusSchema = object({
61958
62086
  confirmedAt: number().nullable()
61959
62087
  });
61960
62088
  /**
61961
- * user-management — singleton capability for user accounts, API keys,
61962
- * and scoped tokens.
62089
+ * user-management — singleton capability for user accounts and the
62090
+ * legacy API-key rows.
61963
62091
  *
61964
62092
  * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
61965
- * — the subset check on `setUserScopes` / `createScopedToken` is moot
62093
+ * — the subset check on `setUserScopes` is moot
61966
62094
  * because non-admins never reach these. If/when we open non-admin
61967
62095
  * delegation, structural caller-scope subset check goes inside the
61968
62096
  * provider.
@@ -62019,15 +62147,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
62019
62147
  kind: "mutation",
62020
62148
  auth: "admin",
62021
62149
  access: "delete"
62022
- }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
62023
- kind: "mutation",
62024
- auth: "admin",
62025
- access: "create"
62026
- }), method(object({ id: string() }), object({ success: literal(true) }), {
62027
- kind: "mutation",
62028
- auth: "admin",
62029
- access: "delete"
62030
- }), method(object({ token: string() }), ScopedTokenSummarySchema.nullable(), { access: "view" }), method(object({ userId: string() }), array(ScopedTokenSummarySchema), { auth: "admin" }), method(object({ userId: string() }), TotpSetupResultSchema, {
62150
+ }), method(object({ userId: string() }), TotpSetupResultSchema, {
62031
62151
  kind: "mutation",
62032
62152
  auth: "admin",
62033
62153
  access: "create"
@@ -66183,7 +66303,7 @@ Object.freeze({
66183
66303
  capName: "llm",
66184
66304
  capScope: "system",
66185
66305
  addonId: null,
66186
- access: "view"
66306
+ access: "create"
66187
66307
  },
66188
66308
  "llm.listNodeModels": {
66189
66309
  capName: "llm",
@@ -70847,12 +70967,6 @@ Object.freeze({
70847
70967
  addonId: null,
70848
70968
  access: "create"
70849
70969
  },
70850
- "userManagement.createScopedToken": {
70851
- capName: "user-management",
70852
- capScope: "system",
70853
- addonId: null,
70854
- access: "create"
70855
- },
70856
70970
  "userManagement.createUser": {
70857
70971
  capName: "user-management",
70858
70972
  capScope: "system",
@@ -70901,12 +71015,6 @@ Object.freeze({
70901
71015
  addonId: null,
70902
71016
  access: "view"
70903
71017
  },
70904
- "userManagement.listScopedTokens": {
70905
- capName: "user-management",
70906
- capScope: "system",
70907
- addonId: null,
70908
- access: "view"
70909
- },
70910
71018
  "userManagement.listUsers": {
70911
71019
  capName: "user-management",
70912
71020
  capScope: "system",
@@ -70961,12 +71069,6 @@ Object.freeze({
70961
71069
  addonId: null,
70962
71070
  access: "delete"
70963
71071
  },
70964
- "userManagement.revokeScopedToken": {
70965
- capName: "user-management",
70966
- capScope: "system",
70967
- addonId: null,
70968
- access: "delete"
70969
- },
70970
71072
  "userManagement.setupTotp": {
70971
71073
  capName: "user-management",
70972
71074
  capScope: "system",
@@ -70997,12 +71099,6 @@ Object.freeze({
70997
71099
  addonId: null,
70998
71100
  access: "view"
70999
71101
  },
71000
- "userManagement.validateScopedToken": {
71001
- capName: "user-management",
71002
- capScope: "system",
71003
- addonId: null,
71004
- access: "view"
71005
- },
71006
71102
  "userManagement.verifyTotp": {
71007
71103
  capName: "user-management",
71008
71104
  capScope: "system",