@camstack/addon-provider-dreo 0.2.129 → 0.2.131

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
@@ -5451,7 +5451,7 @@ var ZodIssueCode = {
5451
5451
  var ZodFirstPartyTypeKind;
5452
5452
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5453
5453
  //#endregion
5454
- //#region ../types/dist/sleep-BxjU_fJM.mjs
5454
+ //#region ../types/dist/sleep-yKL5gfrH.mjs
5455
5455
  /**
5456
5456
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5457
5457
  * window to float samples (D455).
@@ -7833,6 +7833,12 @@ function normalizeAddonInitResult(result) {
7833
7833
  if (Array.isArray(result)) return { providers: result };
7834
7834
  return result;
7835
7835
  }
7836
+ /**
7837
+ * The share-view scope kinds a share-link token can carry. The hub mints
7838
+ * and validates them (`ShareViewGrantSchema` builds its
7839
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
7840
+ */
7841
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7836
7842
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7837
7843
  var PeerBytesTicketSchema = object({
7838
7844
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12498,6 +12504,280 @@ var ConvertResultSchema = object({
12498
12504
  files: array(string()).readonly()
12499
12505
  })).readonly()
12500
12506
  });
12507
+ /**
12508
+ * Zod schemas for persisted record types.
12509
+ *
12510
+ * These schemas serve as the single source of truth for types that are
12511
+ * stored in the settings-store backend and retrieved via tRPC. They
12512
+ * replace the manual TypeScript interfaces with schema-derived types,
12513
+ * enabling runtime validation when reading from the backend.
12514
+ *
12515
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12516
+ * keeps the original name for backward compatibility.
12517
+ */
12518
+ /**
12519
+ * Auth model (v2 — 2026-05-12 caps-only):
12520
+ *
12521
+ * Two principals:
12522
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12523
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12524
+ *
12525
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12526
+ * `super_admin` — collapsed onto the single boolean because every
12527
+ * non-admin caller is governed by the same scope-check rules; the
12528
+ * distinction was only ever used to route role-specific procedures
12529
+ * which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
12530
+ * with `isAdmin: false` + an explicit scope list.
12531
+ */
12532
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12533
+ var MethodAccessSchema = _enum([
12534
+ "view",
12535
+ "create",
12536
+ "delete"
12537
+ ]);
12538
+ /**
12539
+ * A single scope grant. Three forms — checked in matcher with OR
12540
+ * semantics; the first match decides whether the call passes:
12541
+ *
12542
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12543
+ * cap with the matching `scope` declaration. New caps inherit grants
12544
+ * automatically — adding a device cap to the codebase makes it
12545
+ * reachable to every user with `category:device [...]` without a
12546
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12547
+ *
12548
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12549
+ * useful when an integration needs to interact with one specific
12550
+ * addon's surface regardless of how many caps it exports.
12551
+ *
12552
+ * - `capability` — the most precise form. Single cap name. Use for
12553
+ * integration tokens where you want to grant `addons.installPackage`
12554
+ * and nothing else.
12555
+ *
12556
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12557
+ * "give me everything" escape; there is no wildcard scope.
12558
+ */
12559
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12560
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12561
+ var CapScopeSchema = _enum(["device", "system"]);
12562
+ /**
12563
+ * DeviceSelector (scope model v3 — 2026-08-12).
12564
+ *
12565
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12566
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12567
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12568
+ * AFTER the grant was minted — no re-grant, no re-login.
12569
+ *
12570
+ * - `all` — every device in the deployment. The broad viewer/operator
12571
+ * lever without a `category` grant (a `category` grant also covers device
12572
+ * caps that carry no deviceId; `all` is specifically the device set).
12573
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
12574
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
12575
+ * is NOT covered until the grant is edited.
12576
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
12577
+ * DYNAMIC. A device that changes type, or a new device of the type,
12578
+ * re-resolves on the next request.
12579
+ * - `locations` — every device whose operator-assigned `location` label is
12580
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
12581
+ * null/unset location matches NO `locations` selector.
12582
+ */
12583
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
12584
+ object({ kind: literal("all") }),
12585
+ object({
12586
+ kind: literal("ids"),
12587
+ ids: array(number().int()).min(1)
12588
+ }),
12589
+ object({
12590
+ kind: literal("types"),
12591
+ types: array(_enum(DeviceType)).min(1)
12592
+ }),
12593
+ object({
12594
+ kind: literal("locations"),
12595
+ locations: array(string().min(1)).min(1)
12596
+ })
12597
+ ]);
12598
+ var DeviceTokenScopeSchema = object({
12599
+ type: literal("device"),
12600
+ /** The device SET this grant covers — resolved against the live fleet. */
12601
+ selector: DeviceSelectorSchema,
12602
+ access: array(MethodAccessSchema).min(1),
12603
+ /**
12604
+ * Whether a grant on a PARENT device transparently covers its accessory
12605
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
12606
+ * Direction is parent → children ONLY.
12607
+ *
12608
+ * Absent → the matcher DERIVES it from the access flavour: `view`
12609
+ * inherits (a camera viewer sees the camera's accessories), `create` /
12610
+ * `delete` do NOT (actuating/removing a child is an explicit act the
12611
+ * operator must grant on the child, not inherit from the parent). Set it
12612
+ * explicitly to override that default per grant.
12613
+ */
12614
+ includeLinked: boolean().optional()
12615
+ });
12616
+ /**
12617
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
12618
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
12619
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
12620
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
12621
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
12622
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
12623
+ * migration cannot reach a JWT already in a client's hands; parse-time
12624
+ * migration covers both without a flag day. No cast — the raw object is read
12625
+ * through `Reflect.get` (its static type is `unknown`).
12626
+ */
12627
+ function migrateLegacyTokenScope(raw) {
12628
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
12629
+ if (Reflect.get(raw, "type") !== "device") return raw;
12630
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
12631
+ const targets = Reflect.get(raw, "targets");
12632
+ if (!Array.isArray(targets)) return raw;
12633
+ return {
12634
+ type: "device",
12635
+ selector: {
12636
+ kind: "ids",
12637
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
12638
+ },
12639
+ access: Reflect.get(raw, "access")
12640
+ };
12641
+ }
12642
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
12643
+ object({
12644
+ type: literal("category"),
12645
+ target: CapScopeSchema,
12646
+ access: array(MethodAccessSchema).min(1)
12647
+ }),
12648
+ object({
12649
+ type: literal("capability"),
12650
+ target: string(),
12651
+ access: array(MethodAccessSchema).min(1)
12652
+ }),
12653
+ object({
12654
+ type: literal("addon"),
12655
+ target: string(),
12656
+ access: array(MethodAccessSchema).min(1)
12657
+ }),
12658
+ DeviceTokenScopeSchema
12659
+ ]));
12660
+ object({
12661
+ id: string(),
12662
+ username: string(),
12663
+ passwordHash: string(),
12664
+ /**
12665
+ * Admin bypass. When true, the middleware skips the scope-access
12666
+ * check entirely. There is no other axis of privilege; the legacy
12667
+ * role enum collapsed onto this boolean in v2.
12668
+ */
12669
+ isAdmin: boolean().default(false),
12670
+ allowedProviders: AllowedProviderSchema,
12671
+ allowedDevices: AllowedDevicesSchema,
12672
+ /**
12673
+ * Scopes granted to this user. Admins bypass; their `scopes` is
12674
+ * ignored. Non-admins without scopes are locked out of every
12675
+ * protected call.
12676
+ */
12677
+ scopes: array(TokenScopeSchema).default([]),
12678
+ createdAt: number(),
12679
+ updatedAt: number()
12680
+ });
12681
+ object({
12682
+ id: string(),
12683
+ label: string(),
12684
+ isAdmin: boolean().default(false),
12685
+ allowedProviders: AllowedProviderSchema,
12686
+ allowedDevices: AllowedDevicesSchema,
12687
+ tokenHash: string(),
12688
+ tokenPrefix: string(),
12689
+ createdAt: number(),
12690
+ lastUsedAt: number().optional()
12691
+ });
12692
+ object({
12693
+ id: string(),
12694
+ userId: string(),
12695
+ name: string(),
12696
+ tokenHash: string(),
12697
+ tokenPrefix: string(),
12698
+ scopes: array(TokenScopeSchema),
12699
+ expiresAt: number().nullish(),
12700
+ lastUsedAt: number().nullish(),
12701
+ createdAt: number()
12702
+ });
12703
+ /** What a share-view grant lets its holder see. */
12704
+ var ShareViewGrantSchema = object({
12705
+ kind: _enum(SHARE_VIEW_KINDS),
12706
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
12707
+ /** Talk-back, opt-in at mint time; absent means off. */
12708
+ talk: boolean().optional()
12709
+ });
12710
+ var ShareViewScopeSchema = object({
12711
+ type: literal("share-view"),
12712
+ grant: ShareViewGrantSchema
12713
+ });
12714
+ var AddonRoutesScopeSchema = object({
12715
+ type: literal("addon-routes"),
12716
+ access: array(MethodAccessSchema).min(1)
12717
+ });
12718
+ var PreferencesSelfScopeSchema = object({ type: literal("preferences-self") });
12719
+ var CredentialScopeSchema = union([
12720
+ literal("*"),
12721
+ ShareViewScopeSchema,
12722
+ AddonRoutesScopeSchema,
12723
+ PreferencesSelfScopeSchema,
12724
+ TokenScopeSchema
12725
+ ]);
12726
+ object({
12727
+ kind: literal("credential"),
12728
+ sub: string().min(1),
12729
+ jti: string().min(16),
12730
+ scopes: array(CredentialScopeSchema).min(1)
12731
+ });
12732
+ var PreferenceNamespaceSchema = string().regex(/^[a-z][a-z0-9.-]{0,63}$/);
12733
+ /** A namespace's value: a JSON object, opaque to the hub. */
12734
+ var PreferenceValueSchema = record(string(), unknown());
12735
+ var PreferenceDeviceIdSchema = string().min(1).max(64);
12736
+ /** A stored row, as the owner reads it. */
12737
+ var PreferenceRowSchema = object({
12738
+ namespace: PreferenceNamespaceSchema,
12739
+ value: PreferenceValueSchema,
12740
+ /** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
12741
+ revision: number().int().positive(),
12742
+ updatedAt: number().int(),
12743
+ /** The client id the last writer sent; `null` when it sent none. */
12744
+ updatedByDevice: PreferenceDeviceIdSchema.nullable()
12745
+ });
12746
+ object({
12747
+ /** Absent: every namespace the caller holds. */
12748
+ namespaces: array(PreferenceNamespaceSchema).max(32).optional() });
12749
+ object({ rows: array(PreferenceRowSchema) });
12750
+ object({
12751
+ namespace: PreferenceNamespaceSchema,
12752
+ value: PreferenceValueSchema,
12753
+ /**
12754
+ * The revision the edit was based on. Absent: last write wins. `0`: the
12755
+ * namespace must not exist yet. Any other value that is not the current
12756
+ * revision answers `conflict` and writes nothing.
12757
+ */
12758
+ baseRevision: number().int().nonnegative().optional(),
12759
+ deviceId: PreferenceDeviceIdSchema.optional()
12760
+ });
12761
+ discriminatedUnion("status", [object({
12762
+ status: literal("saved"),
12763
+ row: PreferenceRowSchema
12764
+ }), object({
12765
+ status: literal("conflict"),
12766
+ current: PreferenceRowSchema.nullable()
12767
+ })]);
12768
+ object({ namespace: PreferenceNamespaceSchema });
12769
+ object({
12770
+ /** `false` when the namespace did not exist. */
12771
+ deleted: boolean() });
12772
+ object({
12773
+ /** The revision the client holds per namespace; a namespace it does not list is new to it. */
12774
+ revisionByNamespace: record(PreferenceNamespaceSchema, number().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
12775
+ object({
12776
+ /** Every row whose revision differs from the client's, and every row it did not list. */
12777
+ rows: array(PreferenceRowSchema),
12778
+ /** Namespaces the client listed that no longer exist. */
12779
+ deleted: array(PreferenceNamespaceSchema)
12780
+ });
12501
12781
  _enum(["new-session", "step-up"]);
12502
12782
  /** The languages the hub's app landing pages are written in (D858). */
12503
12783
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -39691,38 +39971,37 @@ method(LlmRuntimeCompleteInputSchema, LlmGenerateResultSchema, {
39691
39971
  auth: "admin",
39692
39972
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39693
39973
  });
39974
+ var LlmProfileKindSchema = string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "a kind id is lower-case letters, digits and dashes");
39975
+ /** What a model (or, by default, every model of a kind) can do. */
39976
+ var LlmModelFeaturesSchema = object({
39977
+ vision: boolean(),
39978
+ tools: boolean(),
39979
+ streaming: boolean()
39980
+ });
39981
+ /** One model a provider offers. `features` overrides the kind's defaults, per field. */
39982
+ var LlmModelInfoSchema = object({
39983
+ id: string(),
39984
+ label: string().optional(),
39985
+ contextLength: number().int().positive().optional(),
39986
+ features: LlmModelFeaturesSchema.partial().optional()
39987
+ });
39694
39988
  /**
39695
- * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
39696
- * methods concat-fan across providers; single-row methods route to ONE
39697
- * provider by the `addonId` in the call input (the notification-output
39698
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
39699
- * (hub-placed); the cap stays open for future providers.
39700
- *
39701
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
39702
- * `apiKey` is a password field — providers REDACT it on read and merge on
39703
- * write; a stored key NEVER round-trips to a client.
39989
+ * The provider-specific part of a profile, validated by the provider that owns
39990
+ * the kind (`upsertProfile` refuses what it does not accept). A field its
39991
+ * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
39992
+ * keychain, never in the row, and reads back as the redaction marker.
39704
39993
  */
39705
- var LlmProfileKindSchema = _enum([
39706
- "openai-compatible",
39707
- "openai",
39708
- "anthropic",
39709
- "google",
39710
- "managed-local",
39711
- "apple-foundation"
39712
- ]);
39994
+ var LlmProviderConfigSchema = record(string(), unknown());
39713
39995
  var LlmProfileSchema = object({
39714
39996
  id: string(),
39715
39997
  name: string(),
39998
+ /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
39716
39999
  kind: LlmProfileKindSchema,
39717
40000
  /** Stamped by the provider — keeps the fanned catalog routable. */
39718
40001
  addonId: string(),
39719
40002
  enabled: boolean(),
39720
40003
  /** Vendor model id, or the managed runtime's loaded model. */
39721
40004
  model: string(),
39722
- /** Required for openai-compatible; override for cloud kinds. */
39723
- baseUrl: string().optional(),
39724
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
39725
- apiKey: string().optional(),
39726
40005
  /** Vision on/off. A vision call against a `false` profile is REFUSED, never
39727
40006
  * degraded to text — that shipped once and produced a confident answer to a
39728
40007
  * question about a picture nobody sent. */
@@ -39730,15 +40009,11 @@ var LlmProfileSchema = object({
39730
40009
  temperature: number().min(0).max(2).optional(),
39731
40010
  /** Nucleus sampling. Every wire we speak has it. */
39732
40011
  topP: number().min(0).max(1).optional(),
39733
- /** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
39734
- * wire does, and the client drops it there (measured: the request body gets
39735
- * `top_p` and no `top_k`). The profile editor hides the field wherever it
39736
- * would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
40012
+ /** Top-k sampling. Carried only by the wires that have it — a kind offers the
40013
+ * field in its editor only when its descriptor lists it in `profileFields`. */
39737
40014
  topK: number().int().positive().optional(),
39738
40015
  maxTokens: number().int().positive().optional(),
39739
- /** Prompt context window. Advisory for cloud kinds (they enforce their own);
39740
- * for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
39741
- * the model with, so it is the one field that changes a PROCESS. */
40016
+ /** Prompt context window. Advisory for cloud kinds (they enforce their own). */
39742
40017
  contextLength: number().int().positive().optional(),
39743
40018
  /** Default system prompt. A caller's `system` REPLACES it (never appends —
39744
40019
  * two system prompts fighting is worse than either alone). */
@@ -39764,16 +40039,37 @@ var LlmProfileSchema = object({
39764
40039
  * library; the REGISTRY of callable tools is ours and is empty in v1, so a
39765
40040
  * `true` here buys the wiring, not behaviour, until tools are registered. */
39766
40041
  toolsEnabled: boolean().default(false),
39767
- extraHeaders: record(string(), string()).optional(),
39768
- /** kind === 'managed-local' only (spec §4). */
39769
- runtime: ManagedRuntimeConfigSchema.optional(),
39770
- /**
39771
- * kind === 'apple-foundation' only: WHERE it runs — the only thing there is
39772
- * to configure (no key, no URL, no download; `model` is `apple-system`).
39773
- * `supportsVision` on such a row is stamped by the provider from the node's
39774
- * reported `imageInput`, never taken from the operator (D62).
39775
- */
39776
- appleFoundation: object({ nodeId: string() }).optional()
40042
+ /** Everything the kind's provider owns (endpoint, key, node, runtime…). */
40043
+ providerConfig: LlmProviderConfigSchema.default({})
40044
+ });
40045
+ /**
40046
+ * The common profile fields a kind's editor offers. The editor owns how each
40047
+ * one is drawn; the provider says which of them mean something on its wire.
40048
+ */
40049
+ var LlmProfileFieldSchema = _enum([
40050
+ "temperature",
40051
+ "topP",
40052
+ "topK",
40053
+ "maxTokens",
40054
+ "contextLength",
40055
+ "systemPrompt",
40056
+ "timeoutMs",
40057
+ "connectTimeoutMs",
40058
+ "firstTokenTimeoutMs",
40059
+ "idleTimeoutMs",
40060
+ "retry",
40061
+ "toolsEnabled"
40062
+ ]);
40063
+ /**
40064
+ * A provider-drawn part of the editor, by a generic widget id the admin UI
40065
+ * registers (`ai/apple-node`). `placement: 'model'` replaces the generic model
40066
+ * picker: that widget owns the model choice.
40067
+ */
40068
+ var LlmProviderWidgetSchema = object({
40069
+ id: string(),
40070
+ placement: _enum(["connection", "model"]),
40071
+ /** `providerConfig` keys this widget must fill before the profile can be saved. */
40072
+ requires: array(string()).optional()
39777
40073
  });
39778
40074
  /** ConfigUISchema tree passed through untyped on the wire (the
39779
40075
  * notification-output `ConfigSchemaPassthrough` precedent at
@@ -39782,11 +40078,56 @@ var ConfigSchemaPassthrough$3 = unknown();
39782
40078
  var LlmProfileKindDescriptorSchema = object({
39783
40079
  kind: LlmProfileKindSchema,
39784
40080
  label: string(),
40081
+ /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
39785
40082
  icon: string(),
39786
40083
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
39787
40084
  addonId: string(),
39788
- configSchema: ConfigSchemaPassthrough$3
40085
+ /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
40086
+ connectionSchema: ConfigSchemaPassthrough$3,
40087
+ /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
40088
+ advancedSchema: ConfigSchemaPassthrough$3.optional(),
40089
+ /** The kind's defaults; a model from `listModels` may override any of them. */
40090
+ features: LlmModelFeaturesSchema,
40091
+ /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
40092
+ visionEditable: boolean(),
40093
+ /** Where the model list comes from: `listModels`, `staticModels`, or nowhere. */
40094
+ modelCatalog: _enum([
40095
+ "fetch",
40096
+ "static",
40097
+ "none"
40098
+ ]),
40099
+ staticModels: array(LlmModelInfoSchema).optional(),
40100
+ /** The common fields that mean something on this kind's wire. */
40101
+ profileFields: array(LlmProfileFieldSchema),
40102
+ providerWidgets: array(LlmProviderWidgetSchema).optional()
40103
+ });
40104
+ /**
40105
+ * `listModels` input. `connection` is an UNSAVED draft of `providerConfig`
40106
+ * (the editor's form); with `profileId` too, a secret the draft leaves
40107
+ * untouched (absent or the redaction marker) is resolved server-side from the
40108
+ * stored profile — the browser never receives it.
40109
+ */
40110
+ var LlmListModelsInputSchema = object({
40111
+ addonId: string(),
40112
+ kind: LlmProfileKindSchema,
40113
+ profileId: string().optional(),
40114
+ connection: LlmProviderConfigSchema.optional()
39789
40115
  });
40116
+ var LlmListModelsErrorCodeSchema = _enum([
40117
+ "auth",
40118
+ "network",
40119
+ "unsupported",
40120
+ "invalid"
40121
+ ]);
40122
+ /** A RESULT, never a throw: "wrong key" is an answer the editor renders inline. */
40123
+ var LlmListModelsResultSchema = discriminatedUnion("ok", [object({
40124
+ ok: literal(true),
40125
+ models: array(LlmModelInfoSchema)
40126
+ }), object({
40127
+ ok: literal(false),
40128
+ code: LlmListModelsErrorCodeSchema,
40129
+ message: string()
40130
+ })]);
39790
40131
  var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
39791
40132
  var LlmDefaultSchema = object({
39792
40133
  selector: LlmDefaultSelectorSchema,
@@ -39886,7 +40227,10 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
39886
40227
  kind: "mutation",
39887
40228
  auth: "admin",
39888
40229
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39889
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
40230
+ }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
40231
+ kind: "mutation",
40232
+ auth: "admin"
40233
+ }), method(object({}), array(LlmDefaultSchema)), method(object({
39890
40234
  selector: LlmDefaultSelectorSchema,
39891
40235
  profileId: string().nullable()
39892
40236
  }), _void(), {
@@ -43992,202 +44336,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
43992
44336
  auth: "admin"
43993
44337
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
43994
44338
  /**
43995
- * Zod schemas for persisted record types.
43996
- *
43997
- * These schemas serve as the single source of truth for types that are
43998
- * stored in the settings-store backend and retrieved via tRPC. They
43999
- * replace the manual TypeScript interfaces with schema-derived types,
44000
- * enabling runtime validation when reading from the backend.
44001
- *
44002
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
44003
- * keeps the original name for backward compatibility.
44004
- */
44005
- /**
44006
- * Auth model (v2 — 2026-05-12 caps-only):
44007
- *
44008
- * Two principals:
44009
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
44010
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
44011
- *
44012
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44013
- * `super_admin` — collapsed onto the single boolean because every
44014
- * non-admin caller is governed by the same scope-check rules; the
44015
- * distinction was only ever used to route role-specific procedures
44016
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44017
- * with `isAdmin: false` + an explicit scope list.
44018
- */
44019
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44020
- var MethodAccessSchema = _enum([
44021
- "view",
44022
- "create",
44023
- "delete"
44024
- ]);
44025
- /**
44026
- * A single scope grant. Three forms — checked in matcher with OR
44027
- * semantics; the first match decides whether the call passes:
44028
- *
44029
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44030
- * cap with the matching `scope` declaration. New caps inherit grants
44031
- * automatically — adding a device cap to the codebase makes it
44032
- * reachable to every user with `category:device [...]` without a
44033
- * re-grant. Use this for "family viewer" / "operator" tiers.
44034
- *
44035
- * - `addon` — every cap that ships inside a given addon id. Niche;
44036
- * useful when an integration needs to interact with one specific
44037
- * addon's surface regardless of how many caps it exports.
44038
- *
44039
- * - `capability` — the most precise form. Single cap name. Use for
44040
- * integration tokens where you want to grant `addons.installPackage`
44041
- * and nothing else.
44042
- *
44043
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44044
- * "give me everything" escape; there is no wildcard scope.
44045
- */
44046
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44047
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44048
- var CapScopeSchema = _enum(["device", "system"]);
44049
- /**
44050
- * DeviceSelector (scope model v3 — 2026-08-12).
44051
- *
44052
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44053
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44054
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44055
- * AFTER the grant was minted — no re-grant, no re-login.
44056
- *
44057
- * - `all` — every device in the deployment. The broad viewer/operator
44058
- * lever without a `category` grant (a `category` grant also covers device
44059
- * caps that carry no deviceId; `all` is specifically the device set).
44060
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44061
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44062
- * is NOT covered until the grant is edited.
44063
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44064
- * DYNAMIC. A device that changes type, or a new device of the type,
44065
- * re-resolves on the next request.
44066
- * - `locations` — every device whose operator-assigned `location` label is
44067
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44068
- * null/unset location matches NO `locations` selector.
44069
- */
44070
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44071
- object({ kind: literal("all") }),
44072
- object({
44073
- kind: literal("ids"),
44074
- ids: array(number().int()).min(1)
44075
- }),
44076
- object({
44077
- kind: literal("types"),
44078
- types: array(_enum(DeviceType)).min(1)
44079
- }),
44080
- object({
44081
- kind: literal("locations"),
44082
- locations: array(string().min(1)).min(1)
44083
- })
44084
- ]);
44085
- var DeviceTokenScopeSchema = object({
44086
- type: literal("device"),
44087
- /** The device SET this grant covers — resolved against the live fleet. */
44088
- selector: DeviceSelectorSchema,
44089
- access: array(MethodAccessSchema).min(1),
44090
- /**
44091
- * Whether a grant on a PARENT device transparently covers its accessory
44092
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44093
- * Direction is parent → children ONLY.
44094
- *
44095
- * Absent → the matcher DERIVES it from the access flavour: `view`
44096
- * inherits (a camera viewer sees the camera's accessories), `create` /
44097
- * `delete` do NOT (actuating/removing a child is an explicit act the
44098
- * operator must grant on the child, not inherit from the parent). Set it
44099
- * explicitly to override that default per grant.
44100
- */
44101
- includeLinked: boolean().optional()
44102
- });
44103
- /**
44104
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44105
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44106
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44107
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44108
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44109
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44110
- * migration cannot reach a JWT already in a client's hands; parse-time
44111
- * migration covers both without a flag day. No cast — the raw object is read
44112
- * through `Reflect.get` (its static type is `unknown`).
44113
- */
44114
- function migrateLegacyTokenScope(raw) {
44115
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44116
- if (Reflect.get(raw, "type") !== "device") return raw;
44117
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44118
- const targets = Reflect.get(raw, "targets");
44119
- if (!Array.isArray(targets)) return raw;
44120
- return {
44121
- type: "device",
44122
- selector: {
44123
- kind: "ids",
44124
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44125
- },
44126
- access: Reflect.get(raw, "access")
44127
- };
44128
- }
44129
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44130
- object({
44131
- type: literal("category"),
44132
- target: CapScopeSchema,
44133
- access: array(MethodAccessSchema).min(1)
44134
- }),
44135
- object({
44136
- type: literal("capability"),
44137
- target: string(),
44138
- access: array(MethodAccessSchema).min(1)
44139
- }),
44140
- object({
44141
- type: literal("addon"),
44142
- target: string(),
44143
- access: array(MethodAccessSchema).min(1)
44144
- }),
44145
- DeviceTokenScopeSchema
44146
- ]));
44147
- object({
44148
- id: string(),
44149
- username: string(),
44150
- passwordHash: string(),
44151
- /**
44152
- * Admin bypass. When true, the middleware skips the scope-access
44153
- * check entirely. There is no other axis of privilege; the legacy
44154
- * role enum collapsed onto this boolean in v2.
44155
- */
44156
- isAdmin: boolean().default(false),
44157
- allowedProviders: AllowedProviderSchema,
44158
- allowedDevices: AllowedDevicesSchema,
44159
- /**
44160
- * Scopes granted to this user. Admins bypass; their `scopes` is
44161
- * ignored. Non-admins without scopes are locked out of every
44162
- * protected call.
44163
- */
44164
- scopes: array(TokenScopeSchema).default([]),
44165
- createdAt: number(),
44166
- updatedAt: number()
44167
- });
44168
- object({
44169
- id: string(),
44170
- label: string(),
44171
- isAdmin: boolean().default(false),
44172
- allowedProviders: AllowedProviderSchema,
44173
- allowedDevices: AllowedDevicesSchema,
44174
- tokenHash: string(),
44175
- tokenPrefix: string(),
44176
- createdAt: number(),
44177
- lastUsedAt: number().optional()
44178
- });
44179
- object({
44180
- id: string(),
44181
- userId: string(),
44182
- name: string(),
44183
- tokenHash: string(),
44184
- tokenPrefix: string(),
44185
- scopes: array(TokenScopeSchema),
44186
- expiresAt: number().nullish(),
44187
- lastUsedAt: number().nullish(),
44188
- createdAt: number()
44189
- });
44190
- /**
44191
44339
  * `oauth-integration` — a collection cap by which an addon declares
44192
44340
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44193
44341
  * Each provider returns a static descriptor; the core enumerates them
@@ -63978,26 +64126,6 @@ var ApiKeySummarySchema = object({
63978
64126
  createdAt: number(),
63979
64127
  lastUsedAt: number().optional()
63980
64128
  });
63981
- var ScopedTokenSummarySchema = object({
63982
- id: string(),
63983
- userId: string(),
63984
- name: string(),
63985
- tokenPrefix: string(),
63986
- scopes: array(TokenScopeSchema),
63987
- expiresAt: number().nullish(),
63988
- lastUsedAt: number().nullish(),
63989
- createdAt: number()
63990
- });
63991
- var CreateScopedTokenInputSchema = object({
63992
- userId: string(),
63993
- name: string(),
63994
- scopes: array(TokenScopeSchema),
63995
- expiresAt: number().optional()
63996
- });
63997
- var CreateScopedTokenResultSchema = object({
63998
- token: string(),
63999
- record: ScopedTokenSummarySchema
64000
- });
64001
64129
  var OauthSessionSummarySchema = object({
64002
64130
  id: string(),
64003
64131
  userId: string(),
@@ -64019,11 +64147,11 @@ var TotpStatusSchema = object({
64019
64147
  confirmedAt: number().nullable()
64020
64148
  });
64021
64149
  /**
64022
- * user-management — singleton capability for user accounts, API keys,
64023
- * and scoped tokens.
64150
+ * user-management — singleton capability for user accounts and the
64151
+ * legacy API-key rows.
64024
64152
  *
64025
64153
  * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
64026
- * — the subset check on `setUserScopes` / `createScopedToken` is moot
64154
+ * — the subset check on `setUserScopes` is moot
64027
64155
  * because non-admins never reach these. If/when we open non-admin
64028
64156
  * delegation, structural caller-scope subset check goes inside the
64029
64157
  * provider.
@@ -64080,15 +64208,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
64080
64208
  kind: "mutation",
64081
64209
  auth: "admin",
64082
64210
  access: "delete"
64083
- }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
64084
- kind: "mutation",
64085
- auth: "admin",
64086
- access: "create"
64087
- }), method(object({ id: string() }), object({ success: literal(true) }), {
64088
- kind: "mutation",
64089
- auth: "admin",
64090
- access: "delete"
64091
- }), method(object({ token: string() }), ScopedTokenSummarySchema.nullable(), { access: "view" }), method(object({ userId: string() }), array(ScopedTokenSummarySchema), { auth: "admin" }), method(object({ userId: string() }), TotpSetupResultSchema, {
64211
+ }), method(object({ userId: string() }), TotpSetupResultSchema, {
64092
64212
  kind: "mutation",
64093
64213
  auth: "admin",
64094
64214
  access: "create"
@@ -70178,7 +70298,7 @@ Object.freeze({
70178
70298
  capName: "llm",
70179
70299
  capScope: "system",
70180
70300
  addonId: null,
70181
- access: "view"
70301
+ access: "create"
70182
70302
  },
70183
70303
  "llm.listNodeModels": {
70184
70304
  capName: "llm",
@@ -74842,12 +74962,6 @@ Object.freeze({
74842
74962
  addonId: null,
74843
74963
  access: "create"
74844
74964
  },
74845
- "userManagement.createScopedToken": {
74846
- capName: "user-management",
74847
- capScope: "system",
74848
- addonId: null,
74849
- access: "create"
74850
- },
74851
74965
  "userManagement.createUser": {
74852
74966
  capName: "user-management",
74853
74967
  capScope: "system",
@@ -74896,12 +75010,6 @@ Object.freeze({
74896
75010
  addonId: null,
74897
75011
  access: "view"
74898
75012
  },
74899
- "userManagement.listScopedTokens": {
74900
- capName: "user-management",
74901
- capScope: "system",
74902
- addonId: null,
74903
- access: "view"
74904
- },
74905
75013
  "userManagement.listUsers": {
74906
75014
  capName: "user-management",
74907
75015
  capScope: "system",
@@ -74956,12 +75064,6 @@ Object.freeze({
74956
75064
  addonId: null,
74957
75065
  access: "delete"
74958
75066
  },
74959
- "userManagement.revokeScopedToken": {
74960
- capName: "user-management",
74961
- capScope: "system",
74962
- addonId: null,
74963
- access: "delete"
74964
- },
74965
75067
  "userManagement.setupTotp": {
74966
75068
  capName: "user-management",
74967
75069
  capScope: "system",
@@ -74992,12 +75094,6 @@ Object.freeze({
74992
75094
  addonId: null,
74993
75095
  access: "view"
74994
75096
  },
74995
- "userManagement.validateScopedToken": {
74996
- capName: "user-management",
74997
- capScope: "system",
74998
- addonId: null,
74999
- access: "view"
75000
- },
75001
75097
  "userManagement.verifyTotp": {
75002
75098
  capName: "user-management",
75003
75099
  capScope: "system",