@camstack/addon-provider-amcrest 0.2.140 → 0.2.142

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
@@ -5429,7 +5429,7 @@ var ZodIssueCode = {
5429
5429
  var ZodFirstPartyTypeKind;
5430
5430
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5431
5431
  //#endregion
5432
- //#region ../types/dist/sleep-BxjU_fJM.mjs
5432
+ //#region ../types/dist/sleep-yKL5gfrH.mjs
5433
5433
  /**
5434
5434
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5435
5435
  * window to float samples (D455).
@@ -7811,6 +7811,12 @@ function normalizeAddonInitResult(result) {
7811
7811
  if (Array.isArray(result)) return { providers: result };
7812
7812
  return result;
7813
7813
  }
7814
+ /**
7815
+ * The share-view scope kinds a share-link token can carry. The hub mints
7816
+ * and validates them (`ShareViewGrantSchema` builds its
7817
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
7818
+ */
7819
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7814
7820
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7815
7821
  var PeerBytesTicketSchema = object({
7816
7822
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12500,6 +12506,280 @@ var ConvertResultSchema = object({
12500
12506
  files: array(string()).readonly()
12501
12507
  })).readonly()
12502
12508
  });
12509
+ /**
12510
+ * Zod schemas for persisted record types.
12511
+ *
12512
+ * These schemas serve as the single source of truth for types that are
12513
+ * stored in the settings-store backend and retrieved via tRPC. They
12514
+ * replace the manual TypeScript interfaces with schema-derived types,
12515
+ * enabling runtime validation when reading from the backend.
12516
+ *
12517
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12518
+ * keeps the original name for backward compatibility.
12519
+ */
12520
+ /**
12521
+ * Auth model (v2 — 2026-05-12 caps-only):
12522
+ *
12523
+ * Two principals:
12524
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12525
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12526
+ *
12527
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12528
+ * `super_admin` — collapsed onto the single boolean because every
12529
+ * non-admin caller is governed by the same scope-check rules; the
12530
+ * distinction was only ever used to route role-specific procedures
12531
+ * which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
12532
+ * with `isAdmin: false` + an explicit scope list.
12533
+ */
12534
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12535
+ var MethodAccessSchema = _enum([
12536
+ "view",
12537
+ "create",
12538
+ "delete"
12539
+ ]);
12540
+ /**
12541
+ * A single scope grant. Three forms — checked in matcher with OR
12542
+ * semantics; the first match decides whether the call passes:
12543
+ *
12544
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12545
+ * cap with the matching `scope` declaration. New caps inherit grants
12546
+ * automatically — adding a device cap to the codebase makes it
12547
+ * reachable to every user with `category:device [...]` without a
12548
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12549
+ *
12550
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12551
+ * useful when an integration needs to interact with one specific
12552
+ * addon's surface regardless of how many caps it exports.
12553
+ *
12554
+ * - `capability` — the most precise form. Single cap name. Use for
12555
+ * integration tokens where you want to grant `addons.installPackage`
12556
+ * and nothing else.
12557
+ *
12558
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12559
+ * "give me everything" escape; there is no wildcard scope.
12560
+ */
12561
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12562
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12563
+ var CapScopeSchema = _enum(["device", "system"]);
12564
+ /**
12565
+ * DeviceSelector (scope model v3 — 2026-08-12).
12566
+ *
12567
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12568
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12569
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12570
+ * AFTER the grant was minted — no re-grant, no re-login.
12571
+ *
12572
+ * - `all` — every device in the deployment. The broad viewer/operator
12573
+ * lever without a `category` grant (a `category` grant also covers device
12574
+ * caps that carry no deviceId; `all` is specifically the device set).
12575
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
12576
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
12577
+ * is NOT covered until the grant is edited.
12578
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
12579
+ * DYNAMIC. A device that changes type, or a new device of the type,
12580
+ * re-resolves on the next request.
12581
+ * - `locations` — every device whose operator-assigned `location` label is
12582
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
12583
+ * null/unset location matches NO `locations` selector.
12584
+ */
12585
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
12586
+ object({ kind: literal("all") }),
12587
+ object({
12588
+ kind: literal("ids"),
12589
+ ids: array(number().int()).min(1)
12590
+ }),
12591
+ object({
12592
+ kind: literal("types"),
12593
+ types: array(_enum(DeviceType)).min(1)
12594
+ }),
12595
+ object({
12596
+ kind: literal("locations"),
12597
+ locations: array(string().min(1)).min(1)
12598
+ })
12599
+ ]);
12600
+ var DeviceTokenScopeSchema = object({
12601
+ type: literal("device"),
12602
+ /** The device SET this grant covers — resolved against the live fleet. */
12603
+ selector: DeviceSelectorSchema,
12604
+ access: array(MethodAccessSchema).min(1),
12605
+ /**
12606
+ * Whether a grant on a PARENT device transparently covers its accessory
12607
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
12608
+ * Direction is parent → children ONLY.
12609
+ *
12610
+ * Absent → the matcher DERIVES it from the access flavour: `view`
12611
+ * inherits (a camera viewer sees the camera's accessories), `create` /
12612
+ * `delete` do NOT (actuating/removing a child is an explicit act the
12613
+ * operator must grant on the child, not inherit from the parent). Set it
12614
+ * explicitly to override that default per grant.
12615
+ */
12616
+ includeLinked: boolean().optional()
12617
+ });
12618
+ /**
12619
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
12620
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
12621
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
12622
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
12623
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
12624
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
12625
+ * migration cannot reach a JWT already in a client's hands; parse-time
12626
+ * migration covers both without a flag day. No cast — the raw object is read
12627
+ * through `Reflect.get` (its static type is `unknown`).
12628
+ */
12629
+ function migrateLegacyTokenScope(raw) {
12630
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
12631
+ if (Reflect.get(raw, "type") !== "device") return raw;
12632
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
12633
+ const targets = Reflect.get(raw, "targets");
12634
+ if (!Array.isArray(targets)) return raw;
12635
+ return {
12636
+ type: "device",
12637
+ selector: {
12638
+ kind: "ids",
12639
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
12640
+ },
12641
+ access: Reflect.get(raw, "access")
12642
+ };
12643
+ }
12644
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
12645
+ object({
12646
+ type: literal("category"),
12647
+ target: CapScopeSchema,
12648
+ access: array(MethodAccessSchema).min(1)
12649
+ }),
12650
+ object({
12651
+ type: literal("capability"),
12652
+ target: string(),
12653
+ access: array(MethodAccessSchema).min(1)
12654
+ }),
12655
+ object({
12656
+ type: literal("addon"),
12657
+ target: string(),
12658
+ access: array(MethodAccessSchema).min(1)
12659
+ }),
12660
+ DeviceTokenScopeSchema
12661
+ ]));
12662
+ object({
12663
+ id: string(),
12664
+ username: string(),
12665
+ passwordHash: string(),
12666
+ /**
12667
+ * Admin bypass. When true, the middleware skips the scope-access
12668
+ * check entirely. There is no other axis of privilege; the legacy
12669
+ * role enum collapsed onto this boolean in v2.
12670
+ */
12671
+ isAdmin: boolean().default(false),
12672
+ allowedProviders: AllowedProviderSchema,
12673
+ allowedDevices: AllowedDevicesSchema,
12674
+ /**
12675
+ * Scopes granted to this user. Admins bypass; their `scopes` is
12676
+ * ignored. Non-admins without scopes are locked out of every
12677
+ * protected call.
12678
+ */
12679
+ scopes: array(TokenScopeSchema).default([]),
12680
+ createdAt: number(),
12681
+ updatedAt: number()
12682
+ });
12683
+ object({
12684
+ id: string(),
12685
+ label: string(),
12686
+ isAdmin: boolean().default(false),
12687
+ allowedProviders: AllowedProviderSchema,
12688
+ allowedDevices: AllowedDevicesSchema,
12689
+ tokenHash: string(),
12690
+ tokenPrefix: string(),
12691
+ createdAt: number(),
12692
+ lastUsedAt: number().optional()
12693
+ });
12694
+ object({
12695
+ id: string(),
12696
+ userId: string(),
12697
+ name: string(),
12698
+ tokenHash: string(),
12699
+ tokenPrefix: string(),
12700
+ scopes: array(TokenScopeSchema),
12701
+ expiresAt: number().nullish(),
12702
+ lastUsedAt: number().nullish(),
12703
+ createdAt: number()
12704
+ });
12705
+ /** What a share-view grant lets its holder see. */
12706
+ var ShareViewGrantSchema = object({
12707
+ kind: _enum(SHARE_VIEW_KINDS),
12708
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
12709
+ /** Talk-back, opt-in at mint time; absent means off. */
12710
+ talk: boolean().optional()
12711
+ });
12712
+ var ShareViewScopeSchema = object({
12713
+ type: literal("share-view"),
12714
+ grant: ShareViewGrantSchema
12715
+ });
12716
+ var AddonRoutesScopeSchema = object({
12717
+ type: literal("addon-routes"),
12718
+ access: array(MethodAccessSchema).min(1)
12719
+ });
12720
+ var PreferencesSelfScopeSchema = object({ type: literal("preferences-self") });
12721
+ var CredentialScopeSchema = union([
12722
+ literal("*"),
12723
+ ShareViewScopeSchema,
12724
+ AddonRoutesScopeSchema,
12725
+ PreferencesSelfScopeSchema,
12726
+ TokenScopeSchema
12727
+ ]);
12728
+ object({
12729
+ kind: literal("credential"),
12730
+ sub: string().min(1),
12731
+ jti: string().min(16),
12732
+ scopes: array(CredentialScopeSchema).min(1)
12733
+ });
12734
+ var PreferenceNamespaceSchema = string().regex(/^[a-z][a-z0-9.-]{0,63}$/);
12735
+ /** A namespace's value: a JSON object, opaque to the hub. */
12736
+ var PreferenceValueSchema = record(string(), unknown());
12737
+ var PreferenceDeviceIdSchema = string().min(1).max(64);
12738
+ /** A stored row, as the owner reads it. */
12739
+ var PreferenceRowSchema = object({
12740
+ namespace: PreferenceNamespaceSchema,
12741
+ value: PreferenceValueSchema,
12742
+ /** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
12743
+ revision: number().int().positive(),
12744
+ updatedAt: number().int(),
12745
+ /** The client id the last writer sent; `null` when it sent none. */
12746
+ updatedByDevice: PreferenceDeviceIdSchema.nullable()
12747
+ });
12748
+ object({
12749
+ /** Absent: every namespace the caller holds. */
12750
+ namespaces: array(PreferenceNamespaceSchema).max(32).optional() });
12751
+ object({ rows: array(PreferenceRowSchema) });
12752
+ object({
12753
+ namespace: PreferenceNamespaceSchema,
12754
+ value: PreferenceValueSchema,
12755
+ /**
12756
+ * The revision the edit was based on. Absent: last write wins. `0`: the
12757
+ * namespace must not exist yet. Any other value that is not the current
12758
+ * revision answers `conflict` and writes nothing.
12759
+ */
12760
+ baseRevision: number().int().nonnegative().optional(),
12761
+ deviceId: PreferenceDeviceIdSchema.optional()
12762
+ });
12763
+ discriminatedUnion("status", [object({
12764
+ status: literal("saved"),
12765
+ row: PreferenceRowSchema
12766
+ }), object({
12767
+ status: literal("conflict"),
12768
+ current: PreferenceRowSchema.nullable()
12769
+ })]);
12770
+ object({ namespace: PreferenceNamespaceSchema });
12771
+ object({
12772
+ /** `false` when the namespace did not exist. */
12773
+ deleted: boolean() });
12774
+ object({
12775
+ /** The revision the client holds per namespace; a namespace it does not list is new to it. */
12776
+ revisionByNamespace: record(PreferenceNamespaceSchema, number().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
12777
+ object({
12778
+ /** Every row whose revision differs from the client's, and every row it did not list. */
12779
+ rows: array(PreferenceRowSchema),
12780
+ /** Namespaces the client listed that no longer exist. */
12781
+ deleted: array(PreferenceNamespaceSchema)
12782
+ });
12503
12783
  _enum(["new-session", "step-up"]);
12504
12784
  /** The languages the hub's app landing pages are written in (D858). */
12505
12785
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -39789,38 +40069,37 @@ method(LlmRuntimeCompleteInputSchema, LlmGenerateResultSchema, {
39789
40069
  auth: "admin",
39790
40070
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39791
40071
  });
40072
+ var LlmProfileKindSchema = string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "a kind id is lower-case letters, digits and dashes");
40073
+ /** What a model (or, by default, every model of a kind) can do. */
40074
+ var LlmModelFeaturesSchema = object({
40075
+ vision: boolean(),
40076
+ tools: boolean(),
40077
+ streaming: boolean()
40078
+ });
40079
+ /** One model a provider offers. `features` overrides the kind's defaults, per field. */
40080
+ var LlmModelInfoSchema = object({
40081
+ id: string(),
40082
+ label: string().optional(),
40083
+ contextLength: number().int().positive().optional(),
40084
+ features: LlmModelFeaturesSchema.partial().optional()
40085
+ });
39792
40086
  /**
39793
- * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
39794
- * methods concat-fan across providers; single-row methods route to ONE
39795
- * provider by the `addonId` in the call input (the notification-output
39796
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
39797
- * (hub-placed); the cap stays open for future providers.
39798
- *
39799
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
39800
- * `apiKey` is a password field — providers REDACT it on read and merge on
39801
- * write; a stored key NEVER round-trips to a client.
40087
+ * The provider-specific part of a profile, validated by the provider that owns
40088
+ * the kind (`upsertProfile` refuses what it does not accept). A field its
40089
+ * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
40090
+ * keychain, never in the row, and reads back as the redaction marker.
39802
40091
  */
39803
- var LlmProfileKindSchema = _enum([
39804
- "openai-compatible",
39805
- "openai",
39806
- "anthropic",
39807
- "google",
39808
- "managed-local",
39809
- "apple-foundation"
39810
- ]);
40092
+ var LlmProviderConfigSchema = record(string(), unknown());
39811
40093
  var LlmProfileSchema = object({
39812
40094
  id: string(),
39813
40095
  name: string(),
40096
+ /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
39814
40097
  kind: LlmProfileKindSchema,
39815
40098
  /** Stamped by the provider — keeps the fanned catalog routable. */
39816
40099
  addonId: string(),
39817
40100
  enabled: boolean(),
39818
40101
  /** Vendor model id, or the managed runtime's loaded model. */
39819
40102
  model: string(),
39820
- /** Required for openai-compatible; override for cloud kinds. */
39821
- baseUrl: string().optional(),
39822
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
39823
- apiKey: string().optional(),
39824
40103
  /** Vision on/off. A vision call against a `false` profile is REFUSED, never
39825
40104
  * degraded to text — that shipped once and produced a confident answer to a
39826
40105
  * question about a picture nobody sent. */
@@ -39828,15 +40107,11 @@ var LlmProfileSchema = object({
39828
40107
  temperature: number().min(0).max(2).optional(),
39829
40108
  /** Nucleus sampling. Every wire we speak has it. */
39830
40109
  topP: number().min(0).max(1).optional(),
39831
- /** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
39832
- * wire does, and the client drops it there (measured: the request body gets
39833
- * `top_p` and no `top_k`). The profile editor hides the field wherever it
39834
- * would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
40110
+ /** Top-k sampling. Carried only by the wires that have it — a kind offers the
40111
+ * field in its editor only when its descriptor lists it in `profileFields`. */
39835
40112
  topK: number().int().positive().optional(),
39836
40113
  maxTokens: number().int().positive().optional(),
39837
- /** Prompt context window. Advisory for cloud kinds (they enforce their own);
39838
- * for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
39839
- * the model with, so it is the one field that changes a PROCESS. */
40114
+ /** Prompt context window. Advisory for cloud kinds (they enforce their own). */
39840
40115
  contextLength: number().int().positive().optional(),
39841
40116
  /** Default system prompt. A caller's `system` REPLACES it (never appends —
39842
40117
  * two system prompts fighting is worse than either alone). */
@@ -39862,16 +40137,37 @@ var LlmProfileSchema = object({
39862
40137
  * library; the REGISTRY of callable tools is ours and is empty in v1, so a
39863
40138
  * `true` here buys the wiring, not behaviour, until tools are registered. */
39864
40139
  toolsEnabled: boolean().default(false),
39865
- extraHeaders: record(string(), string()).optional(),
39866
- /** kind === 'managed-local' only (spec §4). */
39867
- runtime: ManagedRuntimeConfigSchema.optional(),
39868
- /**
39869
- * kind === 'apple-foundation' only: WHERE it runs — the only thing there is
39870
- * to configure (no key, no URL, no download; `model` is `apple-system`).
39871
- * `supportsVision` on such a row is stamped by the provider from the node's
39872
- * reported `imageInput`, never taken from the operator (D62).
39873
- */
39874
- appleFoundation: object({ nodeId: string() }).optional()
40140
+ /** Everything the kind's provider owns (endpoint, key, node, runtime…). */
40141
+ providerConfig: LlmProviderConfigSchema.default({})
40142
+ });
40143
+ /**
40144
+ * The common profile fields a kind's editor offers. The editor owns how each
40145
+ * one is drawn; the provider says which of them mean something on its wire.
40146
+ */
40147
+ var LlmProfileFieldSchema = _enum([
40148
+ "temperature",
40149
+ "topP",
40150
+ "topK",
40151
+ "maxTokens",
40152
+ "contextLength",
40153
+ "systemPrompt",
40154
+ "timeoutMs",
40155
+ "connectTimeoutMs",
40156
+ "firstTokenTimeoutMs",
40157
+ "idleTimeoutMs",
40158
+ "retry",
40159
+ "toolsEnabled"
40160
+ ]);
40161
+ /**
40162
+ * A provider-drawn part of the editor, by a generic widget id the admin UI
40163
+ * registers (`ai/apple-node`). `placement: 'model'` replaces the generic model
40164
+ * picker: that widget owns the model choice.
40165
+ */
40166
+ var LlmProviderWidgetSchema = object({
40167
+ id: string(),
40168
+ placement: _enum(["connection", "model"]),
40169
+ /** `providerConfig` keys this widget must fill before the profile can be saved. */
40170
+ requires: array(string()).optional()
39875
40171
  });
39876
40172
  /** ConfigUISchema tree passed through untyped on the wire (the
39877
40173
  * notification-output `ConfigSchemaPassthrough` precedent at
@@ -39880,11 +40176,56 @@ var ConfigSchemaPassthrough$3 = unknown();
39880
40176
  var LlmProfileKindDescriptorSchema = object({
39881
40177
  kind: LlmProfileKindSchema,
39882
40178
  label: string(),
40179
+ /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
39883
40180
  icon: string(),
39884
40181
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
39885
40182
  addonId: string(),
39886
- configSchema: ConfigSchemaPassthrough$3
40183
+ /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
40184
+ connectionSchema: ConfigSchemaPassthrough$3,
40185
+ /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
40186
+ advancedSchema: ConfigSchemaPassthrough$3.optional(),
40187
+ /** The kind's defaults; a model from `listModels` may override any of them. */
40188
+ features: LlmModelFeaturesSchema,
40189
+ /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
40190
+ visionEditable: boolean(),
40191
+ /** Where the model list comes from: `listModels`, `staticModels`, or nowhere. */
40192
+ modelCatalog: _enum([
40193
+ "fetch",
40194
+ "static",
40195
+ "none"
40196
+ ]),
40197
+ staticModels: array(LlmModelInfoSchema).optional(),
40198
+ /** The common fields that mean something on this kind's wire. */
40199
+ profileFields: array(LlmProfileFieldSchema),
40200
+ providerWidgets: array(LlmProviderWidgetSchema).optional()
40201
+ });
40202
+ /**
40203
+ * `listModels` input. `connection` is an UNSAVED draft of `providerConfig`
40204
+ * (the editor's form); with `profileId` too, a secret the draft leaves
40205
+ * untouched (absent or the redaction marker) is resolved server-side from the
40206
+ * stored profile — the browser never receives it.
40207
+ */
40208
+ var LlmListModelsInputSchema = object({
40209
+ addonId: string(),
40210
+ kind: LlmProfileKindSchema,
40211
+ profileId: string().optional(),
40212
+ connection: LlmProviderConfigSchema.optional()
39887
40213
  });
40214
+ var LlmListModelsErrorCodeSchema = _enum([
40215
+ "auth",
40216
+ "network",
40217
+ "unsupported",
40218
+ "invalid"
40219
+ ]);
40220
+ /** A RESULT, never a throw: "wrong key" is an answer the editor renders inline. */
40221
+ var LlmListModelsResultSchema = discriminatedUnion("ok", [object({
40222
+ ok: literal(true),
40223
+ models: array(LlmModelInfoSchema)
40224
+ }), object({
40225
+ ok: literal(false),
40226
+ code: LlmListModelsErrorCodeSchema,
40227
+ message: string()
40228
+ })]);
39888
40229
  var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
39889
40230
  var LlmDefaultSchema = object({
39890
40231
  selector: LlmDefaultSelectorSchema,
@@ -39984,7 +40325,10 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
39984
40325
  kind: "mutation",
39985
40326
  auth: "admin",
39986
40327
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39987
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
40328
+ }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
40329
+ kind: "mutation",
40330
+ auth: "admin"
40331
+ }), method(object({}), array(LlmDefaultSchema)), method(object({
39988
40332
  selector: LlmDefaultSelectorSchema,
39989
40333
  profileId: string().nullable()
39990
40334
  }), _void(), {
@@ -44090,202 +44434,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
44090
44434
  auth: "admin"
44091
44435
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
44092
44436
  /**
44093
- * Zod schemas for persisted record types.
44094
- *
44095
- * These schemas serve as the single source of truth for types that are
44096
- * stored in the settings-store backend and retrieved via tRPC. They
44097
- * replace the manual TypeScript interfaces with schema-derived types,
44098
- * enabling runtime validation when reading from the backend.
44099
- *
44100
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
44101
- * keeps the original name for backward compatibility.
44102
- */
44103
- /**
44104
- * Auth model (v2 — 2026-05-12 caps-only):
44105
- *
44106
- * Two principals:
44107
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
44108
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
44109
- *
44110
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44111
- * `super_admin` — collapsed onto the single boolean because every
44112
- * non-admin caller is governed by the same scope-check rules; the
44113
- * distinction was only ever used to route role-specific procedures
44114
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44115
- * with `isAdmin: false` + an explicit scope list.
44116
- */
44117
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44118
- var MethodAccessSchema = _enum([
44119
- "view",
44120
- "create",
44121
- "delete"
44122
- ]);
44123
- /**
44124
- * A single scope grant. Three forms — checked in matcher with OR
44125
- * semantics; the first match decides whether the call passes:
44126
- *
44127
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44128
- * cap with the matching `scope` declaration. New caps inherit grants
44129
- * automatically — adding a device cap to the codebase makes it
44130
- * reachable to every user with `category:device [...]` without a
44131
- * re-grant. Use this for "family viewer" / "operator" tiers.
44132
- *
44133
- * - `addon` — every cap that ships inside a given addon id. Niche;
44134
- * useful when an integration needs to interact with one specific
44135
- * addon's surface regardless of how many caps it exports.
44136
- *
44137
- * - `capability` — the most precise form. Single cap name. Use for
44138
- * integration tokens where you want to grant `addons.installPackage`
44139
- * and nothing else.
44140
- *
44141
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44142
- * "give me everything" escape; there is no wildcard scope.
44143
- */
44144
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44145
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44146
- var CapScopeSchema = _enum(["device", "system"]);
44147
- /**
44148
- * DeviceSelector (scope model v3 — 2026-08-12).
44149
- *
44150
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44151
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44152
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44153
- * AFTER the grant was minted — no re-grant, no re-login.
44154
- *
44155
- * - `all` — every device in the deployment. The broad viewer/operator
44156
- * lever without a `category` grant (a `category` grant also covers device
44157
- * caps that carry no deviceId; `all` is specifically the device set).
44158
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44159
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44160
- * is NOT covered until the grant is edited.
44161
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44162
- * DYNAMIC. A device that changes type, or a new device of the type,
44163
- * re-resolves on the next request.
44164
- * - `locations` — every device whose operator-assigned `location` label is
44165
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44166
- * null/unset location matches NO `locations` selector.
44167
- */
44168
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44169
- object({ kind: literal("all") }),
44170
- object({
44171
- kind: literal("ids"),
44172
- ids: array(number().int()).min(1)
44173
- }),
44174
- object({
44175
- kind: literal("types"),
44176
- types: array(_enum(DeviceType)).min(1)
44177
- }),
44178
- object({
44179
- kind: literal("locations"),
44180
- locations: array(string().min(1)).min(1)
44181
- })
44182
- ]);
44183
- var DeviceTokenScopeSchema = object({
44184
- type: literal("device"),
44185
- /** The device SET this grant covers — resolved against the live fleet. */
44186
- selector: DeviceSelectorSchema,
44187
- access: array(MethodAccessSchema).min(1),
44188
- /**
44189
- * Whether a grant on a PARENT device transparently covers its accessory
44190
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44191
- * Direction is parent → children ONLY.
44192
- *
44193
- * Absent → the matcher DERIVES it from the access flavour: `view`
44194
- * inherits (a camera viewer sees the camera's accessories), `create` /
44195
- * `delete` do NOT (actuating/removing a child is an explicit act the
44196
- * operator must grant on the child, not inherit from the parent). Set it
44197
- * explicitly to override that default per grant.
44198
- */
44199
- includeLinked: boolean().optional()
44200
- });
44201
- /**
44202
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44203
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44204
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44205
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44206
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44207
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44208
- * migration cannot reach a JWT already in a client's hands; parse-time
44209
- * migration covers both without a flag day. No cast — the raw object is read
44210
- * through `Reflect.get` (its static type is `unknown`).
44211
- */
44212
- function migrateLegacyTokenScope(raw) {
44213
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44214
- if (Reflect.get(raw, "type") !== "device") return raw;
44215
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44216
- const targets = Reflect.get(raw, "targets");
44217
- if (!Array.isArray(targets)) return raw;
44218
- return {
44219
- type: "device",
44220
- selector: {
44221
- kind: "ids",
44222
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44223
- },
44224
- access: Reflect.get(raw, "access")
44225
- };
44226
- }
44227
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44228
- object({
44229
- type: literal("category"),
44230
- target: CapScopeSchema,
44231
- access: array(MethodAccessSchema).min(1)
44232
- }),
44233
- object({
44234
- type: literal("capability"),
44235
- target: string(),
44236
- access: array(MethodAccessSchema).min(1)
44237
- }),
44238
- object({
44239
- type: literal("addon"),
44240
- target: string(),
44241
- access: array(MethodAccessSchema).min(1)
44242
- }),
44243
- DeviceTokenScopeSchema
44244
- ]));
44245
- object({
44246
- id: string(),
44247
- username: string(),
44248
- passwordHash: string(),
44249
- /**
44250
- * Admin bypass. When true, the middleware skips the scope-access
44251
- * check entirely. There is no other axis of privilege; the legacy
44252
- * role enum collapsed onto this boolean in v2.
44253
- */
44254
- isAdmin: boolean().default(false),
44255
- allowedProviders: AllowedProviderSchema,
44256
- allowedDevices: AllowedDevicesSchema,
44257
- /**
44258
- * Scopes granted to this user. Admins bypass; their `scopes` is
44259
- * ignored. Non-admins without scopes are locked out of every
44260
- * protected call.
44261
- */
44262
- scopes: array(TokenScopeSchema).default([]),
44263
- createdAt: number(),
44264
- updatedAt: number()
44265
- });
44266
- object({
44267
- id: string(),
44268
- label: string(),
44269
- isAdmin: boolean().default(false),
44270
- allowedProviders: AllowedProviderSchema,
44271
- allowedDevices: AllowedDevicesSchema,
44272
- tokenHash: string(),
44273
- tokenPrefix: string(),
44274
- createdAt: number(),
44275
- lastUsedAt: number().optional()
44276
- });
44277
- object({
44278
- id: string(),
44279
- userId: string(),
44280
- name: string(),
44281
- tokenHash: string(),
44282
- tokenPrefix: string(),
44283
- scopes: array(TokenScopeSchema),
44284
- expiresAt: number().nullish(),
44285
- lastUsedAt: number().nullish(),
44286
- createdAt: number()
44287
- });
44288
- /**
44289
44437
  * `oauth-integration` — a collection cap by which an addon declares
44290
44438
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44291
44439
  * Each provider returns a static descriptor; the core enumerates them
@@ -65043,26 +65191,6 @@ var ApiKeySummarySchema = object({
65043
65191
  createdAt: number(),
65044
65192
  lastUsedAt: number().optional()
65045
65193
  });
65046
- var ScopedTokenSummarySchema = object({
65047
- id: string(),
65048
- userId: string(),
65049
- name: string(),
65050
- tokenPrefix: string(),
65051
- scopes: array(TokenScopeSchema),
65052
- expiresAt: number().nullish(),
65053
- lastUsedAt: number().nullish(),
65054
- createdAt: number()
65055
- });
65056
- var CreateScopedTokenInputSchema = object({
65057
- userId: string(),
65058
- name: string(),
65059
- scopes: array(TokenScopeSchema),
65060
- expiresAt: number().optional()
65061
- });
65062
- var CreateScopedTokenResultSchema = object({
65063
- token: string(),
65064
- record: ScopedTokenSummarySchema
65065
- });
65066
65194
  var OauthSessionSummarySchema = object({
65067
65195
  id: string(),
65068
65196
  userId: string(),
@@ -65084,11 +65212,11 @@ var TotpStatusSchema = object({
65084
65212
  confirmedAt: number().nullable()
65085
65213
  });
65086
65214
  /**
65087
- * user-management — singleton capability for user accounts, API keys,
65088
- * and scoped tokens.
65215
+ * user-management — singleton capability for user accounts and the
65216
+ * legacy API-key rows.
65089
65217
  *
65090
65218
  * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
65091
- * — the subset check on `setUserScopes` / `createScopedToken` is moot
65219
+ * — the subset check on `setUserScopes` is moot
65092
65220
  * because non-admins never reach these. If/when we open non-admin
65093
65221
  * delegation, structural caller-scope subset check goes inside the
65094
65222
  * provider.
@@ -65145,15 +65273,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
65145
65273
  kind: "mutation",
65146
65274
  auth: "admin",
65147
65275
  access: "delete"
65148
- }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
65149
- kind: "mutation",
65150
- auth: "admin",
65151
- access: "create"
65152
- }), method(object({ id: string() }), object({ success: literal(true) }), {
65153
- kind: "mutation",
65154
- auth: "admin",
65155
- access: "delete"
65156
- }), method(object({ token: string() }), ScopedTokenSummarySchema.nullable(), { access: "view" }), method(object({ userId: string() }), array(ScopedTokenSummarySchema), { auth: "admin" }), method(object({ userId: string() }), TotpSetupResultSchema, {
65276
+ }), method(object({ userId: string() }), TotpSetupResultSchema, {
65157
65277
  kind: "mutation",
65158
65278
  auth: "admin",
65159
65279
  access: "create"
@@ -71247,7 +71367,7 @@ Object.freeze({
71247
71367
  capName: "llm",
71248
71368
  capScope: "system",
71249
71369
  addonId: null,
71250
- access: "view"
71370
+ access: "create"
71251
71371
  },
71252
71372
  "llm.listNodeModels": {
71253
71373
  capName: "llm",
@@ -75911,12 +76031,6 @@ Object.freeze({
75911
76031
  addonId: null,
75912
76032
  access: "create"
75913
76033
  },
75914
- "userManagement.createScopedToken": {
75915
- capName: "user-management",
75916
- capScope: "system",
75917
- addonId: null,
75918
- access: "create"
75919
- },
75920
76034
  "userManagement.createUser": {
75921
76035
  capName: "user-management",
75922
76036
  capScope: "system",
@@ -75965,12 +76079,6 @@ Object.freeze({
75965
76079
  addonId: null,
75966
76080
  access: "view"
75967
76081
  },
75968
- "userManagement.listScopedTokens": {
75969
- capName: "user-management",
75970
- capScope: "system",
75971
- addonId: null,
75972
- access: "view"
75973
- },
75974
76082
  "userManagement.listUsers": {
75975
76083
  capName: "user-management",
75976
76084
  capScope: "system",
@@ -76025,12 +76133,6 @@ Object.freeze({
76025
76133
  addonId: null,
76026
76134
  access: "delete"
76027
76135
  },
76028
- "userManagement.revokeScopedToken": {
76029
- capName: "user-management",
76030
- capScope: "system",
76031
- addonId: null,
76032
- access: "delete"
76033
- },
76034
76136
  "userManagement.setupTotp": {
76035
76137
  capName: "user-management",
76036
76138
  capScope: "system",
@@ -76061,12 +76163,6 @@ Object.freeze({
76061
76163
  addonId: null,
76062
76164
  access: "view"
76063
76165
  },
76064
- "userManagement.validateScopedToken": {
76065
- capName: "user-management",
76066
- capScope: "system",
76067
- addonId: null,
76068
- access: "view"
76069
- },
76070
76166
  "userManagement.verifyTotp": {
76071
76167
  capName: "user-management",
76072
76168
  capScope: "system",