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