@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.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. */
@@ -12521,6 +12527,280 @@ var ConvertResultSchema = object({
12521
12527
  files: array(string()).readonly()
12522
12528
  })).readonly()
12523
12529
  });
12530
+ /**
12531
+ * Zod schemas for persisted record types.
12532
+ *
12533
+ * These schemas serve as the single source of truth for types that are
12534
+ * stored in the settings-store backend and retrieved via tRPC. They
12535
+ * replace the manual TypeScript interfaces with schema-derived types,
12536
+ * enabling runtime validation when reading from the backend.
12537
+ *
12538
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12539
+ * keeps the original name for backward compatibility.
12540
+ */
12541
+ /**
12542
+ * Auth model (v2 — 2026-05-12 caps-only):
12543
+ *
12544
+ * Two principals:
12545
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12546
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12547
+ *
12548
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12549
+ * `super_admin` — collapsed onto the single boolean because every
12550
+ * non-admin caller is governed by the same scope-check rules; the
12551
+ * distinction was only ever used to route role-specific procedures
12552
+ * which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
12553
+ * with `isAdmin: false` + an explicit scope list.
12554
+ */
12555
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12556
+ var MethodAccessSchema = _enum([
12557
+ "view",
12558
+ "create",
12559
+ "delete"
12560
+ ]);
12561
+ /**
12562
+ * A single scope grant. Three forms — checked in matcher with OR
12563
+ * semantics; the first match decides whether the call passes:
12564
+ *
12565
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12566
+ * cap with the matching `scope` declaration. New caps inherit grants
12567
+ * automatically — adding a device cap to the codebase makes it
12568
+ * reachable to every user with `category:device [...]` without a
12569
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12570
+ *
12571
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12572
+ * useful when an integration needs to interact with one specific
12573
+ * addon's surface regardless of how many caps it exports.
12574
+ *
12575
+ * - `capability` — the most precise form. Single cap name. Use for
12576
+ * integration tokens where you want to grant `addons.installPackage`
12577
+ * and nothing else.
12578
+ *
12579
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12580
+ * "give me everything" escape; there is no wildcard scope.
12581
+ */
12582
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12583
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12584
+ var CapScopeSchema = _enum(["device", "system"]);
12585
+ /**
12586
+ * DeviceSelector (scope model v3 — 2026-08-12).
12587
+ *
12588
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12589
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12590
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12591
+ * AFTER the grant was minted — no re-grant, no re-login.
12592
+ *
12593
+ * - `all` — every device in the deployment. The broad viewer/operator
12594
+ * lever without a `category` grant (a `category` grant also covers device
12595
+ * caps that carry no deviceId; `all` is specifically the device set).
12596
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
12597
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
12598
+ * is NOT covered until the grant is edited.
12599
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
12600
+ * DYNAMIC. A device that changes type, or a new device of the type,
12601
+ * re-resolves on the next request.
12602
+ * - `locations` — every device whose operator-assigned `location` label is
12603
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
12604
+ * null/unset location matches NO `locations` selector.
12605
+ */
12606
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
12607
+ object({ kind: literal("all") }),
12608
+ object({
12609
+ kind: literal("ids"),
12610
+ ids: array(number().int()).min(1)
12611
+ }),
12612
+ object({
12613
+ kind: literal("types"),
12614
+ types: array(_enum(DeviceType)).min(1)
12615
+ }),
12616
+ object({
12617
+ kind: literal("locations"),
12618
+ locations: array(string().min(1)).min(1)
12619
+ })
12620
+ ]);
12621
+ var DeviceTokenScopeSchema = object({
12622
+ type: literal("device"),
12623
+ /** The device SET this grant covers — resolved against the live fleet. */
12624
+ selector: DeviceSelectorSchema,
12625
+ access: array(MethodAccessSchema).min(1),
12626
+ /**
12627
+ * Whether a grant on a PARENT device transparently covers its accessory
12628
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
12629
+ * Direction is parent → children ONLY.
12630
+ *
12631
+ * Absent → the matcher DERIVES it from the access flavour: `view`
12632
+ * inherits (a camera viewer sees the camera's accessories), `create` /
12633
+ * `delete` do NOT (actuating/removing a child is an explicit act the
12634
+ * operator must grant on the child, not inherit from the parent). Set it
12635
+ * explicitly to override that default per grant.
12636
+ */
12637
+ includeLinked: boolean().optional()
12638
+ });
12639
+ /**
12640
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
12641
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
12642
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
12643
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
12644
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
12645
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
12646
+ * migration cannot reach a JWT already in a client's hands; parse-time
12647
+ * migration covers both without a flag day. No cast — the raw object is read
12648
+ * through `Reflect.get` (its static type is `unknown`).
12649
+ */
12650
+ function migrateLegacyTokenScope(raw) {
12651
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
12652
+ if (Reflect.get(raw, "type") !== "device") return raw;
12653
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
12654
+ const targets = Reflect.get(raw, "targets");
12655
+ if (!Array.isArray(targets)) return raw;
12656
+ return {
12657
+ type: "device",
12658
+ selector: {
12659
+ kind: "ids",
12660
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
12661
+ },
12662
+ access: Reflect.get(raw, "access")
12663
+ };
12664
+ }
12665
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
12666
+ object({
12667
+ type: literal("category"),
12668
+ target: CapScopeSchema,
12669
+ access: array(MethodAccessSchema).min(1)
12670
+ }),
12671
+ object({
12672
+ type: literal("capability"),
12673
+ target: string(),
12674
+ access: array(MethodAccessSchema).min(1)
12675
+ }),
12676
+ object({
12677
+ type: literal("addon"),
12678
+ target: string(),
12679
+ access: array(MethodAccessSchema).min(1)
12680
+ }),
12681
+ DeviceTokenScopeSchema
12682
+ ]));
12683
+ object({
12684
+ id: string(),
12685
+ username: string(),
12686
+ passwordHash: string(),
12687
+ /**
12688
+ * Admin bypass. When true, the middleware skips the scope-access
12689
+ * check entirely. There is no other axis of privilege; the legacy
12690
+ * role enum collapsed onto this boolean in v2.
12691
+ */
12692
+ isAdmin: boolean().default(false),
12693
+ allowedProviders: AllowedProviderSchema,
12694
+ allowedDevices: AllowedDevicesSchema,
12695
+ /**
12696
+ * Scopes granted to this user. Admins bypass; their `scopes` is
12697
+ * ignored. Non-admins without scopes are locked out of every
12698
+ * protected call.
12699
+ */
12700
+ scopes: array(TokenScopeSchema).default([]),
12701
+ createdAt: number(),
12702
+ updatedAt: number()
12703
+ });
12704
+ object({
12705
+ id: string(),
12706
+ label: string(),
12707
+ isAdmin: boolean().default(false),
12708
+ allowedProviders: AllowedProviderSchema,
12709
+ allowedDevices: AllowedDevicesSchema,
12710
+ tokenHash: string(),
12711
+ tokenPrefix: string(),
12712
+ createdAt: number(),
12713
+ lastUsedAt: number().optional()
12714
+ });
12715
+ object({
12716
+ id: string(),
12717
+ userId: string(),
12718
+ name: string(),
12719
+ tokenHash: string(),
12720
+ tokenPrefix: string(),
12721
+ scopes: array(TokenScopeSchema),
12722
+ expiresAt: number().nullish(),
12723
+ lastUsedAt: number().nullish(),
12724
+ createdAt: number()
12725
+ });
12726
+ /** What a share-view grant lets its holder see. */
12727
+ var ShareViewGrantSchema = object({
12728
+ kind: _enum(SHARE_VIEW_KINDS),
12729
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
12730
+ /** Talk-back, opt-in at mint time; absent means off. */
12731
+ talk: boolean().optional()
12732
+ });
12733
+ var ShareViewScopeSchema = object({
12734
+ type: literal("share-view"),
12735
+ grant: ShareViewGrantSchema
12736
+ });
12737
+ var AddonRoutesScopeSchema = object({
12738
+ type: literal("addon-routes"),
12739
+ access: array(MethodAccessSchema).min(1)
12740
+ });
12741
+ var PreferencesSelfScopeSchema = object({ type: literal("preferences-self") });
12742
+ var CredentialScopeSchema = union([
12743
+ literal("*"),
12744
+ ShareViewScopeSchema,
12745
+ AddonRoutesScopeSchema,
12746
+ PreferencesSelfScopeSchema,
12747
+ TokenScopeSchema
12748
+ ]);
12749
+ object({
12750
+ kind: literal("credential"),
12751
+ sub: string().min(1),
12752
+ jti: string().min(16),
12753
+ scopes: array(CredentialScopeSchema).min(1)
12754
+ });
12755
+ var PreferenceNamespaceSchema = string().regex(/^[a-z][a-z0-9.-]{0,63}$/);
12756
+ /** A namespace's value: a JSON object, opaque to the hub. */
12757
+ var PreferenceValueSchema = record(string(), unknown());
12758
+ var PreferenceDeviceIdSchema = string().min(1).max(64);
12759
+ /** A stored row, as the owner reads it. */
12760
+ var PreferenceRowSchema = object({
12761
+ namespace: PreferenceNamespaceSchema,
12762
+ value: PreferenceValueSchema,
12763
+ /** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
12764
+ revision: number().int().positive(),
12765
+ updatedAt: number().int(),
12766
+ /** The client id the last writer sent; `null` when it sent none. */
12767
+ updatedByDevice: PreferenceDeviceIdSchema.nullable()
12768
+ });
12769
+ object({
12770
+ /** Absent: every namespace the caller holds. */
12771
+ namespaces: array(PreferenceNamespaceSchema).max(32).optional() });
12772
+ object({ rows: array(PreferenceRowSchema) });
12773
+ object({
12774
+ namespace: PreferenceNamespaceSchema,
12775
+ value: PreferenceValueSchema,
12776
+ /**
12777
+ * The revision the edit was based on. Absent: last write wins. `0`: the
12778
+ * namespace must not exist yet. Any other value that is not the current
12779
+ * revision answers `conflict` and writes nothing.
12780
+ */
12781
+ baseRevision: number().int().nonnegative().optional(),
12782
+ deviceId: PreferenceDeviceIdSchema.optional()
12783
+ });
12784
+ discriminatedUnion("status", [object({
12785
+ status: literal("saved"),
12786
+ row: PreferenceRowSchema
12787
+ }), object({
12788
+ status: literal("conflict"),
12789
+ current: PreferenceRowSchema.nullable()
12790
+ })]);
12791
+ object({ namespace: PreferenceNamespaceSchema });
12792
+ object({
12793
+ /** `false` when the namespace did not exist. */
12794
+ deleted: boolean() });
12795
+ object({
12796
+ /** The revision the client holds per namespace; a namespace it does not list is new to it. */
12797
+ revisionByNamespace: record(PreferenceNamespaceSchema, number().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
12798
+ object({
12799
+ /** Every row whose revision differs from the client's, and every row it did not list. */
12800
+ rows: array(PreferenceRowSchema),
12801
+ /** Namespaces the client listed that no longer exist. */
12802
+ deleted: array(PreferenceNamespaceSchema)
12803
+ });
12524
12804
  _enum(["new-session", "step-up"]);
12525
12805
  /** The languages the hub's app landing pages are written in (D858). */
12526
12806
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -39810,38 +40090,37 @@ method(LlmRuntimeCompleteInputSchema, LlmGenerateResultSchema, {
39810
40090
  auth: "admin",
39811
40091
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39812
40092
  });
40093
+ var LlmProfileKindSchema = string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "a kind id is lower-case letters, digits and dashes");
40094
+ /** What a model (or, by default, every model of a kind) can do. */
40095
+ var LlmModelFeaturesSchema = object({
40096
+ vision: boolean(),
40097
+ tools: boolean(),
40098
+ streaming: boolean()
40099
+ });
40100
+ /** One model a provider offers. `features` overrides the kind's defaults, per field. */
40101
+ var LlmModelInfoSchema = object({
40102
+ id: string(),
40103
+ label: string().optional(),
40104
+ contextLength: number().int().positive().optional(),
40105
+ features: LlmModelFeaturesSchema.partial().optional()
40106
+ });
39813
40107
  /**
39814
- * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
39815
- * methods concat-fan across providers; single-row methods route to ONE
39816
- * provider by the `addonId` in the call input (the notification-output
39817
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
39818
- * (hub-placed); the cap stays open for future providers.
39819
- *
39820
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
39821
- * `apiKey` is a password field — providers REDACT it on read and merge on
39822
- * write; a stored key NEVER round-trips to a client.
40108
+ * The provider-specific part of a profile, validated by the provider that owns
40109
+ * the kind (`upsertProfile` refuses what it does not accept). A field its
40110
+ * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
40111
+ * keychain, never in the row, and reads back as the redaction marker.
39823
40112
  */
39824
- var LlmProfileKindSchema = _enum([
39825
- "openai-compatible",
39826
- "openai",
39827
- "anthropic",
39828
- "google",
39829
- "managed-local",
39830
- "apple-foundation"
39831
- ]);
40113
+ var LlmProviderConfigSchema = record(string(), unknown());
39832
40114
  var LlmProfileSchema = object({
39833
40115
  id: string(),
39834
40116
  name: string(),
40117
+ /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
39835
40118
  kind: LlmProfileKindSchema,
39836
40119
  /** Stamped by the provider — keeps the fanned catalog routable. */
39837
40120
  addonId: string(),
39838
40121
  enabled: boolean(),
39839
40122
  /** Vendor model id, or the managed runtime's loaded model. */
39840
40123
  model: string(),
39841
- /** Required for openai-compatible; override for cloud kinds. */
39842
- baseUrl: string().optional(),
39843
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
39844
- apiKey: string().optional(),
39845
40124
  /** Vision on/off. A vision call against a `false` profile is REFUSED, never
39846
40125
  * degraded to text — that shipped once and produced a confident answer to a
39847
40126
  * question about a picture nobody sent. */
@@ -39849,15 +40128,11 @@ var LlmProfileSchema = object({
39849
40128
  temperature: number().min(0).max(2).optional(),
39850
40129
  /** Nucleus sampling. Every wire we speak has it. */
39851
40130
  topP: number().min(0).max(1).optional(),
39852
- /** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
39853
- * wire does, and the client drops it there (measured: the request body gets
39854
- * `top_p` and no `top_k`). The profile editor hides the field wherever it
39855
- * would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
40131
+ /** Top-k sampling. Carried only by the wires that have it — a kind offers the
40132
+ * field in its editor only when its descriptor lists it in `profileFields`. */
39856
40133
  topK: number().int().positive().optional(),
39857
40134
  maxTokens: number().int().positive().optional(),
39858
- /** Prompt context window. Advisory for cloud kinds (they enforce their own);
39859
- * for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
39860
- * the model with, so it is the one field that changes a PROCESS. */
40135
+ /** Prompt context window. Advisory for cloud kinds (they enforce their own). */
39861
40136
  contextLength: number().int().positive().optional(),
39862
40137
  /** Default system prompt. A caller's `system` REPLACES it (never appends —
39863
40138
  * two system prompts fighting is worse than either alone). */
@@ -39883,16 +40158,37 @@ var LlmProfileSchema = object({
39883
40158
  * library; the REGISTRY of callable tools is ours and is empty in v1, so a
39884
40159
  * `true` here buys the wiring, not behaviour, until tools are registered. */
39885
40160
  toolsEnabled: boolean().default(false),
39886
- extraHeaders: record(string(), string()).optional(),
39887
- /** kind === 'managed-local' only (spec §4). */
39888
- runtime: ManagedRuntimeConfigSchema.optional(),
39889
- /**
39890
- * kind === 'apple-foundation' only: WHERE it runs — the only thing there is
39891
- * to configure (no key, no URL, no download; `model` is `apple-system`).
39892
- * `supportsVision` on such a row is stamped by the provider from the node's
39893
- * reported `imageInput`, never taken from the operator (D62).
39894
- */
39895
- appleFoundation: object({ nodeId: string() }).optional()
40161
+ /** Everything the kind's provider owns (endpoint, key, node, runtime…). */
40162
+ providerConfig: LlmProviderConfigSchema.default({})
40163
+ });
40164
+ /**
40165
+ * The common profile fields a kind's editor offers. The editor owns how each
40166
+ * one is drawn; the provider says which of them mean something on its wire.
40167
+ */
40168
+ var LlmProfileFieldSchema = _enum([
40169
+ "temperature",
40170
+ "topP",
40171
+ "topK",
40172
+ "maxTokens",
40173
+ "contextLength",
40174
+ "systemPrompt",
40175
+ "timeoutMs",
40176
+ "connectTimeoutMs",
40177
+ "firstTokenTimeoutMs",
40178
+ "idleTimeoutMs",
40179
+ "retry",
40180
+ "toolsEnabled"
40181
+ ]);
40182
+ /**
40183
+ * A provider-drawn part of the editor, by a generic widget id the admin UI
40184
+ * registers (`ai/apple-node`). `placement: 'model'` replaces the generic model
40185
+ * picker: that widget owns the model choice.
40186
+ */
40187
+ var LlmProviderWidgetSchema = object({
40188
+ id: string(),
40189
+ placement: _enum(["connection", "model"]),
40190
+ /** `providerConfig` keys this widget must fill before the profile can be saved. */
40191
+ requires: array(string()).optional()
39896
40192
  });
39897
40193
  /** ConfigUISchema tree passed through untyped on the wire (the
39898
40194
  * notification-output `ConfigSchemaPassthrough` precedent at
@@ -39901,11 +40197,56 @@ var ConfigSchemaPassthrough$3 = unknown();
39901
40197
  var LlmProfileKindDescriptorSchema = object({
39902
40198
  kind: LlmProfileKindSchema,
39903
40199
  label: string(),
40200
+ /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
39904
40201
  icon: string(),
39905
40202
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
39906
40203
  addonId: string(),
39907
- configSchema: ConfigSchemaPassthrough$3
40204
+ /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
40205
+ connectionSchema: ConfigSchemaPassthrough$3,
40206
+ /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
40207
+ advancedSchema: ConfigSchemaPassthrough$3.optional(),
40208
+ /** The kind's defaults; a model from `listModels` may override any of them. */
40209
+ features: LlmModelFeaturesSchema,
40210
+ /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
40211
+ visionEditable: boolean(),
40212
+ /** Where the model list comes from: `listModels`, `staticModels`, or nowhere. */
40213
+ modelCatalog: _enum([
40214
+ "fetch",
40215
+ "static",
40216
+ "none"
40217
+ ]),
40218
+ staticModels: array(LlmModelInfoSchema).optional(),
40219
+ /** The common fields that mean something on this kind's wire. */
40220
+ profileFields: array(LlmProfileFieldSchema),
40221
+ providerWidgets: array(LlmProviderWidgetSchema).optional()
40222
+ });
40223
+ /**
40224
+ * `listModels` input. `connection` is an UNSAVED draft of `providerConfig`
40225
+ * (the editor's form); with `profileId` too, a secret the draft leaves
40226
+ * untouched (absent or the redaction marker) is resolved server-side from the
40227
+ * stored profile — the browser never receives it.
40228
+ */
40229
+ var LlmListModelsInputSchema = object({
40230
+ addonId: string(),
40231
+ kind: LlmProfileKindSchema,
40232
+ profileId: string().optional(),
40233
+ connection: LlmProviderConfigSchema.optional()
39908
40234
  });
40235
+ var LlmListModelsErrorCodeSchema = _enum([
40236
+ "auth",
40237
+ "network",
40238
+ "unsupported",
40239
+ "invalid"
40240
+ ]);
40241
+ /** A RESULT, never a throw: "wrong key" is an answer the editor renders inline. */
40242
+ var LlmListModelsResultSchema = discriminatedUnion("ok", [object({
40243
+ ok: literal(true),
40244
+ models: array(LlmModelInfoSchema)
40245
+ }), object({
40246
+ ok: literal(false),
40247
+ code: LlmListModelsErrorCodeSchema,
40248
+ message: string()
40249
+ })]);
39909
40250
  var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
39910
40251
  var LlmDefaultSchema = object({
39911
40252
  selector: LlmDefaultSelectorSchema,
@@ -40005,7 +40346,10 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
40005
40346
  kind: "mutation",
40006
40347
  auth: "admin",
40007
40348
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
40008
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
40349
+ }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
40350
+ kind: "mutation",
40351
+ auth: "admin"
40352
+ }), method(object({}), array(LlmDefaultSchema)), method(object({
40009
40353
  selector: LlmDefaultSelectorSchema,
40010
40354
  profileId: string().nullable()
40011
40355
  }), _void(), {
@@ -44111,202 +44455,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
44111
44455
  auth: "admin"
44112
44456
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
44113
44457
  /**
44114
- * Zod schemas for persisted record types.
44115
- *
44116
- * These schemas serve as the single source of truth for types that are
44117
- * stored in the settings-store backend and retrieved via tRPC. They
44118
- * replace the manual TypeScript interfaces with schema-derived types,
44119
- * enabling runtime validation when reading from the backend.
44120
- *
44121
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
44122
- * keeps the original name for backward compatibility.
44123
- */
44124
- /**
44125
- * Auth model (v2 — 2026-05-12 caps-only):
44126
- *
44127
- * Two principals:
44128
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
44129
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
44130
- *
44131
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44132
- * `super_admin` — collapsed onto the single boolean because every
44133
- * non-admin caller is governed by the same scope-check rules; the
44134
- * distinction was only ever used to route role-specific procedures
44135
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44136
- * with `isAdmin: false` + an explicit scope list.
44137
- */
44138
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44139
- var MethodAccessSchema = _enum([
44140
- "view",
44141
- "create",
44142
- "delete"
44143
- ]);
44144
- /**
44145
- * A single scope grant. Three forms — checked in matcher with OR
44146
- * semantics; the first match decides whether the call passes:
44147
- *
44148
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44149
- * cap with the matching `scope` declaration. New caps inherit grants
44150
- * automatically — adding a device cap to the codebase makes it
44151
- * reachable to every user with `category:device [...]` without a
44152
- * re-grant. Use this for "family viewer" / "operator" tiers.
44153
- *
44154
- * - `addon` — every cap that ships inside a given addon id. Niche;
44155
- * useful when an integration needs to interact with one specific
44156
- * addon's surface regardless of how many caps it exports.
44157
- *
44158
- * - `capability` — the most precise form. Single cap name. Use for
44159
- * integration tokens where you want to grant `addons.installPackage`
44160
- * and nothing else.
44161
- *
44162
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44163
- * "give me everything" escape; there is no wildcard scope.
44164
- */
44165
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44166
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44167
- var CapScopeSchema = _enum(["device", "system"]);
44168
- /**
44169
- * DeviceSelector (scope model v3 — 2026-08-12).
44170
- *
44171
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44172
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44173
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44174
- * AFTER the grant was minted — no re-grant, no re-login.
44175
- *
44176
- * - `all` — every device in the deployment. The broad viewer/operator
44177
- * lever without a `category` grant (a `category` grant also covers device
44178
- * caps that carry no deviceId; `all` is specifically the device set).
44179
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44180
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44181
- * is NOT covered until the grant is edited.
44182
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44183
- * DYNAMIC. A device that changes type, or a new device of the type,
44184
- * re-resolves on the next request.
44185
- * - `locations` — every device whose operator-assigned `location` label is
44186
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44187
- * null/unset location matches NO `locations` selector.
44188
- */
44189
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44190
- object({ kind: literal("all") }),
44191
- object({
44192
- kind: literal("ids"),
44193
- ids: array(number().int()).min(1)
44194
- }),
44195
- object({
44196
- kind: literal("types"),
44197
- types: array(_enum(DeviceType)).min(1)
44198
- }),
44199
- object({
44200
- kind: literal("locations"),
44201
- locations: array(string().min(1)).min(1)
44202
- })
44203
- ]);
44204
- var DeviceTokenScopeSchema = object({
44205
- type: literal("device"),
44206
- /** The device SET this grant covers — resolved against the live fleet. */
44207
- selector: DeviceSelectorSchema,
44208
- access: array(MethodAccessSchema).min(1),
44209
- /**
44210
- * Whether a grant on a PARENT device transparently covers its accessory
44211
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44212
- * Direction is parent → children ONLY.
44213
- *
44214
- * Absent → the matcher DERIVES it from the access flavour: `view`
44215
- * inherits (a camera viewer sees the camera's accessories), `create` /
44216
- * `delete` do NOT (actuating/removing a child is an explicit act the
44217
- * operator must grant on the child, not inherit from the parent). Set it
44218
- * explicitly to override that default per grant.
44219
- */
44220
- includeLinked: boolean().optional()
44221
- });
44222
- /**
44223
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44224
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44225
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44226
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44227
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44228
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44229
- * migration cannot reach a JWT already in a client's hands; parse-time
44230
- * migration covers both without a flag day. No cast — the raw object is read
44231
- * through `Reflect.get` (its static type is `unknown`).
44232
- */
44233
- function migrateLegacyTokenScope(raw) {
44234
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44235
- if (Reflect.get(raw, "type") !== "device") return raw;
44236
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44237
- const targets = Reflect.get(raw, "targets");
44238
- if (!Array.isArray(targets)) return raw;
44239
- return {
44240
- type: "device",
44241
- selector: {
44242
- kind: "ids",
44243
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44244
- },
44245
- access: Reflect.get(raw, "access")
44246
- };
44247
- }
44248
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44249
- object({
44250
- type: literal("category"),
44251
- target: CapScopeSchema,
44252
- access: array(MethodAccessSchema).min(1)
44253
- }),
44254
- object({
44255
- type: literal("capability"),
44256
- target: string(),
44257
- access: array(MethodAccessSchema).min(1)
44258
- }),
44259
- object({
44260
- type: literal("addon"),
44261
- target: string(),
44262
- access: array(MethodAccessSchema).min(1)
44263
- }),
44264
- DeviceTokenScopeSchema
44265
- ]));
44266
- object({
44267
- id: string(),
44268
- username: string(),
44269
- passwordHash: string(),
44270
- /**
44271
- * Admin bypass. When true, the middleware skips the scope-access
44272
- * check entirely. There is no other axis of privilege; the legacy
44273
- * role enum collapsed onto this boolean in v2.
44274
- */
44275
- isAdmin: boolean().default(false),
44276
- allowedProviders: AllowedProviderSchema,
44277
- allowedDevices: AllowedDevicesSchema,
44278
- /**
44279
- * Scopes granted to this user. Admins bypass; their `scopes` is
44280
- * ignored. Non-admins without scopes are locked out of every
44281
- * protected call.
44282
- */
44283
- scopes: array(TokenScopeSchema).default([]),
44284
- createdAt: number(),
44285
- updatedAt: number()
44286
- });
44287
- object({
44288
- id: string(),
44289
- label: string(),
44290
- isAdmin: boolean().default(false),
44291
- allowedProviders: AllowedProviderSchema,
44292
- allowedDevices: AllowedDevicesSchema,
44293
- tokenHash: string(),
44294
- tokenPrefix: string(),
44295
- createdAt: number(),
44296
- lastUsedAt: number().optional()
44297
- });
44298
- object({
44299
- id: string(),
44300
- userId: string(),
44301
- name: string(),
44302
- tokenHash: string(),
44303
- tokenPrefix: string(),
44304
- scopes: array(TokenScopeSchema),
44305
- expiresAt: number().nullish(),
44306
- lastUsedAt: number().nullish(),
44307
- createdAt: number()
44308
- });
44309
- /**
44310
44458
  * `oauth-integration` — a collection cap by which an addon declares
44311
44459
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44312
44460
  * Each provider returns a static descriptor; the core enumerates them
@@ -65064,26 +65212,6 @@ var ApiKeySummarySchema = object({
65064
65212
  createdAt: number(),
65065
65213
  lastUsedAt: number().optional()
65066
65214
  });
65067
- var ScopedTokenSummarySchema = object({
65068
- id: string(),
65069
- userId: string(),
65070
- name: string(),
65071
- tokenPrefix: string(),
65072
- scopes: array(TokenScopeSchema),
65073
- expiresAt: number().nullish(),
65074
- lastUsedAt: number().nullish(),
65075
- createdAt: number()
65076
- });
65077
- var CreateScopedTokenInputSchema = object({
65078
- userId: string(),
65079
- name: string(),
65080
- scopes: array(TokenScopeSchema),
65081
- expiresAt: number().optional()
65082
- });
65083
- var CreateScopedTokenResultSchema = object({
65084
- token: string(),
65085
- record: ScopedTokenSummarySchema
65086
- });
65087
65215
  var OauthSessionSummarySchema = object({
65088
65216
  id: string(),
65089
65217
  userId: string(),
@@ -65105,11 +65233,11 @@ var TotpStatusSchema = object({
65105
65233
  confirmedAt: number().nullable()
65106
65234
  });
65107
65235
  /**
65108
- * user-management — singleton capability for user accounts, API keys,
65109
- * and scoped tokens.
65236
+ * user-management — singleton capability for user accounts and the
65237
+ * legacy API-key rows.
65110
65238
  *
65111
65239
  * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
65112
- * — the subset check on `setUserScopes` / `createScopedToken` is moot
65240
+ * — the subset check on `setUserScopes` is moot
65113
65241
  * because non-admins never reach these. If/when we open non-admin
65114
65242
  * delegation, structural caller-scope subset check goes inside the
65115
65243
  * provider.
@@ -65166,15 +65294,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
65166
65294
  kind: "mutation",
65167
65295
  auth: "admin",
65168
65296
  access: "delete"
65169
- }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
65170
- kind: "mutation",
65171
- auth: "admin",
65172
- access: "create"
65173
- }), method(object({ id: string() }), object({ success: literal(true) }), {
65174
- kind: "mutation",
65175
- auth: "admin",
65176
- access: "delete"
65177
- }), method(object({ token: string() }), ScopedTokenSummarySchema.nullable(), { access: "view" }), method(object({ userId: string() }), array(ScopedTokenSummarySchema), { auth: "admin" }), method(object({ userId: string() }), TotpSetupResultSchema, {
65297
+ }), method(object({ userId: string() }), TotpSetupResultSchema, {
65178
65298
  kind: "mutation",
65179
65299
  auth: "admin",
65180
65300
  access: "create"
@@ -71268,7 +71388,7 @@ Object.freeze({
71268
71388
  capName: "llm",
71269
71389
  capScope: "system",
71270
71390
  addonId: null,
71271
- access: "view"
71391
+ access: "create"
71272
71392
  },
71273
71393
  "llm.listNodeModels": {
71274
71394
  capName: "llm",
@@ -75932,12 +76052,6 @@ Object.freeze({
75932
76052
  addonId: null,
75933
76053
  access: "create"
75934
76054
  },
75935
- "userManagement.createScopedToken": {
75936
- capName: "user-management",
75937
- capScope: "system",
75938
- addonId: null,
75939
- access: "create"
75940
- },
75941
76055
  "userManagement.createUser": {
75942
76056
  capName: "user-management",
75943
76057
  capScope: "system",
@@ -75986,12 +76100,6 @@ Object.freeze({
75986
76100
  addonId: null,
75987
76101
  access: "view"
75988
76102
  },
75989
- "userManagement.listScopedTokens": {
75990
- capName: "user-management",
75991
- capScope: "system",
75992
- addonId: null,
75993
- access: "view"
75994
- },
75995
76103
  "userManagement.listUsers": {
75996
76104
  capName: "user-management",
75997
76105
  capScope: "system",
@@ -76046,12 +76154,6 @@ Object.freeze({
76046
76154
  addonId: null,
76047
76155
  access: "delete"
76048
76156
  },
76049
- "userManagement.revokeScopedToken": {
76050
- capName: "user-management",
76051
- capScope: "system",
76052
- addonId: null,
76053
- access: "delete"
76054
- },
76055
76157
  "userManagement.setupTotp": {
76056
76158
  capName: "user-management",
76057
76159
  capScope: "system",
@@ -76082,12 +76184,6 @@ Object.freeze({
76082
76184
  addonId: null,
76083
76185
  access: "view"
76084
76186
  },
76085
- "userManagement.validateScopedToken": {
76086
- capName: "user-management",
76087
- capScope: "system",
76088
- addonId: null,
76089
- access: "view"
76090
- },
76091
76187
  "userManagement.verifyTotp": {
76092
76188
  capName: "user-management",
76093
76189
  capScope: "system",