@camstack/addon-notifiers 1.2.603 → 1.2.605

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
@@ -5550,7 +5550,7 @@ var ZodIssueCode = {
5550
5550
  var ZodFirstPartyTypeKind;
5551
5551
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5552
5552
  //#endregion
5553
- //#region ../types/dist/sleep-BxjU_fJM.mjs
5553
+ //#region ../types/dist/sleep-yKL5gfrH.mjs
5554
5554
  /**
5555
5555
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5556
5556
  * window to float samples (D455).
@@ -7932,6 +7932,12 @@ function normalizeAddonInitResult(result) {
7932
7932
  if (Array.isArray(result)) return { providers: result };
7933
7933
  return result;
7934
7934
  }
7935
+ /**
7936
+ * The share-view scope kinds a share-link token can carry. The hub mints
7937
+ * and validates them (`ShareViewGrantSchema` builds its
7938
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
7939
+ */
7940
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7935
7941
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7936
7942
  var PeerBytesTicketSchema = object({
7937
7943
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12883,6 +12889,280 @@ var ConvertResultSchema = object({
12883
12889
  files: array(string()).readonly()
12884
12890
  })).readonly()
12885
12891
  });
12892
+ /**
12893
+ * Zod schemas for persisted record types.
12894
+ *
12895
+ * These schemas serve as the single source of truth for types that are
12896
+ * stored in the settings-store backend and retrieved via tRPC. They
12897
+ * replace the manual TypeScript interfaces with schema-derived types,
12898
+ * enabling runtime validation when reading from the backend.
12899
+ *
12900
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12901
+ * keeps the original name for backward compatibility.
12902
+ */
12903
+ /**
12904
+ * Auth model (v2 — 2026-05-12 caps-only):
12905
+ *
12906
+ * Two principals:
12907
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12908
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12909
+ *
12910
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12911
+ * `super_admin` — collapsed onto the single boolean because every
12912
+ * non-admin caller is governed by the same scope-check rules; the
12913
+ * distinction was only ever used to route role-specific procedures
12914
+ * which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
12915
+ * with `isAdmin: false` + an explicit scope list.
12916
+ */
12917
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12918
+ var MethodAccessSchema = _enum([
12919
+ "view",
12920
+ "create",
12921
+ "delete"
12922
+ ]);
12923
+ /**
12924
+ * A single scope grant. Three forms — checked in matcher with OR
12925
+ * semantics; the first match decides whether the call passes:
12926
+ *
12927
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12928
+ * cap with the matching `scope` declaration. New caps inherit grants
12929
+ * automatically — adding a device cap to the codebase makes it
12930
+ * reachable to every user with `category:device [...]` without a
12931
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12932
+ *
12933
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12934
+ * useful when an integration needs to interact with one specific
12935
+ * addon's surface regardless of how many caps it exports.
12936
+ *
12937
+ * - `capability` — the most precise form. Single cap name. Use for
12938
+ * integration tokens where you want to grant `addons.installPackage`
12939
+ * and nothing else.
12940
+ *
12941
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12942
+ * "give me everything" escape; there is no wildcard scope.
12943
+ */
12944
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12945
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12946
+ var CapScopeSchema = _enum(["device", "system"]);
12947
+ /**
12948
+ * DeviceSelector (scope model v3 — 2026-08-12).
12949
+ *
12950
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12951
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12952
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12953
+ * AFTER the grant was minted — no re-grant, no re-login.
12954
+ *
12955
+ * - `all` — every device in the deployment. The broad viewer/operator
12956
+ * lever without a `category` grant (a `category` grant also covers device
12957
+ * caps that carry no deviceId; `all` is specifically the device set).
12958
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
12959
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
12960
+ * is NOT covered until the grant is edited.
12961
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
12962
+ * DYNAMIC. A device that changes type, or a new device of the type,
12963
+ * re-resolves on the next request.
12964
+ * - `locations` — every device whose operator-assigned `location` label is
12965
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
12966
+ * null/unset location matches NO `locations` selector.
12967
+ */
12968
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
12969
+ object({ kind: literal("all") }),
12970
+ object({
12971
+ kind: literal("ids"),
12972
+ ids: array(number().int()).min(1)
12973
+ }),
12974
+ object({
12975
+ kind: literal("types"),
12976
+ types: array(_enum(DeviceType)).min(1)
12977
+ }),
12978
+ object({
12979
+ kind: literal("locations"),
12980
+ locations: array(string().min(1)).min(1)
12981
+ })
12982
+ ]);
12983
+ var DeviceTokenScopeSchema = object({
12984
+ type: literal("device"),
12985
+ /** The device SET this grant covers — resolved against the live fleet. */
12986
+ selector: DeviceSelectorSchema,
12987
+ access: array(MethodAccessSchema).min(1),
12988
+ /**
12989
+ * Whether a grant on a PARENT device transparently covers its accessory
12990
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
12991
+ * Direction is parent → children ONLY.
12992
+ *
12993
+ * Absent → the matcher DERIVES it from the access flavour: `view`
12994
+ * inherits (a camera viewer sees the camera's accessories), `create` /
12995
+ * `delete` do NOT (actuating/removing a child is an explicit act the
12996
+ * operator must grant on the child, not inherit from the parent). Set it
12997
+ * explicitly to override that default per grant.
12998
+ */
12999
+ includeLinked: boolean().optional()
13000
+ });
13001
+ /**
13002
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
13003
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
13004
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
13005
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
13006
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
13007
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
13008
+ * migration cannot reach a JWT already in a client's hands; parse-time
13009
+ * migration covers both without a flag day. No cast — the raw object is read
13010
+ * through `Reflect.get` (its static type is `unknown`).
13011
+ */
13012
+ function migrateLegacyTokenScope(raw) {
13013
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
13014
+ if (Reflect.get(raw, "type") !== "device") return raw;
13015
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
13016
+ const targets = Reflect.get(raw, "targets");
13017
+ if (!Array.isArray(targets)) return raw;
13018
+ return {
13019
+ type: "device",
13020
+ selector: {
13021
+ kind: "ids",
13022
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
13023
+ },
13024
+ access: Reflect.get(raw, "access")
13025
+ };
13026
+ }
13027
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
13028
+ object({
13029
+ type: literal("category"),
13030
+ target: CapScopeSchema,
13031
+ access: array(MethodAccessSchema).min(1)
13032
+ }),
13033
+ object({
13034
+ type: literal("capability"),
13035
+ target: string(),
13036
+ access: array(MethodAccessSchema).min(1)
13037
+ }),
13038
+ object({
13039
+ type: literal("addon"),
13040
+ target: string(),
13041
+ access: array(MethodAccessSchema).min(1)
13042
+ }),
13043
+ DeviceTokenScopeSchema
13044
+ ]));
13045
+ object({
13046
+ id: string(),
13047
+ username: string(),
13048
+ passwordHash: string(),
13049
+ /**
13050
+ * Admin bypass. When true, the middleware skips the scope-access
13051
+ * check entirely. There is no other axis of privilege; the legacy
13052
+ * role enum collapsed onto this boolean in v2.
13053
+ */
13054
+ isAdmin: boolean().default(false),
13055
+ allowedProviders: AllowedProviderSchema,
13056
+ allowedDevices: AllowedDevicesSchema,
13057
+ /**
13058
+ * Scopes granted to this user. Admins bypass; their `scopes` is
13059
+ * ignored. Non-admins without scopes are locked out of every
13060
+ * protected call.
13061
+ */
13062
+ scopes: array(TokenScopeSchema).default([]),
13063
+ createdAt: number(),
13064
+ updatedAt: number()
13065
+ });
13066
+ object({
13067
+ id: string(),
13068
+ label: string(),
13069
+ isAdmin: boolean().default(false),
13070
+ allowedProviders: AllowedProviderSchema,
13071
+ allowedDevices: AllowedDevicesSchema,
13072
+ tokenHash: string(),
13073
+ tokenPrefix: string(),
13074
+ createdAt: number(),
13075
+ lastUsedAt: number().optional()
13076
+ });
13077
+ object({
13078
+ id: string(),
13079
+ userId: string(),
13080
+ name: string(),
13081
+ tokenHash: string(),
13082
+ tokenPrefix: string(),
13083
+ scopes: array(TokenScopeSchema),
13084
+ expiresAt: number().nullish(),
13085
+ lastUsedAt: number().nullish(),
13086
+ createdAt: number()
13087
+ });
13088
+ /** What a share-view grant lets its holder see. */
13089
+ var ShareViewGrantSchema = object({
13090
+ kind: _enum(SHARE_VIEW_KINDS),
13091
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
13092
+ /** Talk-back, opt-in at mint time; absent means off. */
13093
+ talk: boolean().optional()
13094
+ });
13095
+ var ShareViewScopeSchema = object({
13096
+ type: literal("share-view"),
13097
+ grant: ShareViewGrantSchema
13098
+ });
13099
+ var AddonRoutesScopeSchema = object({
13100
+ type: literal("addon-routes"),
13101
+ access: array(MethodAccessSchema).min(1)
13102
+ });
13103
+ var PreferencesSelfScopeSchema = object({ type: literal("preferences-self") });
13104
+ var CredentialScopeSchema = union([
13105
+ literal("*"),
13106
+ ShareViewScopeSchema,
13107
+ AddonRoutesScopeSchema,
13108
+ PreferencesSelfScopeSchema,
13109
+ TokenScopeSchema
13110
+ ]);
13111
+ object({
13112
+ kind: literal("credential"),
13113
+ sub: string().min(1),
13114
+ jti: string().min(16),
13115
+ scopes: array(CredentialScopeSchema).min(1)
13116
+ });
13117
+ var PreferenceNamespaceSchema = string().regex(/^[a-z][a-z0-9.-]{0,63}$/);
13118
+ /** A namespace's value: a JSON object, opaque to the hub. */
13119
+ var PreferenceValueSchema = record(string(), unknown());
13120
+ var PreferenceDeviceIdSchema = string().min(1).max(64);
13121
+ /** A stored row, as the owner reads it. */
13122
+ var PreferenceRowSchema = object({
13123
+ namespace: PreferenceNamespaceSchema,
13124
+ value: PreferenceValueSchema,
13125
+ /** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
13126
+ revision: number().int().positive(),
13127
+ updatedAt: number().int(),
13128
+ /** The client id the last writer sent; `null` when it sent none. */
13129
+ updatedByDevice: PreferenceDeviceIdSchema.nullable()
13130
+ });
13131
+ object({
13132
+ /** Absent: every namespace the caller holds. */
13133
+ namespaces: array(PreferenceNamespaceSchema).max(32).optional() });
13134
+ object({ rows: array(PreferenceRowSchema) });
13135
+ object({
13136
+ namespace: PreferenceNamespaceSchema,
13137
+ value: PreferenceValueSchema,
13138
+ /**
13139
+ * The revision the edit was based on. Absent: last write wins. `0`: the
13140
+ * namespace must not exist yet. Any other value that is not the current
13141
+ * revision answers `conflict` and writes nothing.
13142
+ */
13143
+ baseRevision: number().int().nonnegative().optional(),
13144
+ deviceId: PreferenceDeviceIdSchema.optional()
13145
+ });
13146
+ discriminatedUnion("status", [object({
13147
+ status: literal("saved"),
13148
+ row: PreferenceRowSchema
13149
+ }), object({
13150
+ status: literal("conflict"),
13151
+ current: PreferenceRowSchema.nullable()
13152
+ })]);
13153
+ object({ namespace: PreferenceNamespaceSchema });
13154
+ object({
13155
+ /** `false` when the namespace did not exist. */
13156
+ deleted: boolean() });
13157
+ object({
13158
+ /** The revision the client holds per namespace; a namespace it does not list is new to it. */
13159
+ revisionByNamespace: record(PreferenceNamespaceSchema, number().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
13160
+ object({
13161
+ /** Every row whose revision differs from the client's, and every row it did not list. */
13162
+ rows: array(PreferenceRowSchema),
13163
+ /** Namespaces the client listed that no longer exist. */
13164
+ deleted: array(PreferenceNamespaceSchema)
13165
+ });
12886
13166
  _enum(["new-session", "step-up"]);
12887
13167
  /** The languages the hub's app landing pages are written in (D858). */
12888
13168
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -39780,38 +40060,37 @@ method(LlmRuntimeCompleteInputSchema, LlmGenerateResultSchema, {
39780
40060
  auth: "admin",
39781
40061
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39782
40062
  });
40063
+ var LlmProfileKindSchema = string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "a kind id is lower-case letters, digits and dashes");
40064
+ /** What a model (or, by default, every model of a kind) can do. */
40065
+ var LlmModelFeaturesSchema = object({
40066
+ vision: boolean(),
40067
+ tools: boolean(),
40068
+ streaming: boolean()
40069
+ });
40070
+ /** One model a provider offers. `features` overrides the kind's defaults, per field. */
40071
+ var LlmModelInfoSchema = object({
40072
+ id: string(),
40073
+ label: string().optional(),
40074
+ contextLength: number().int().positive().optional(),
40075
+ features: LlmModelFeaturesSchema.partial().optional()
40076
+ });
39783
40077
  /**
39784
- * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
39785
- * methods concat-fan across providers; single-row methods route to ONE
39786
- * provider by the `addonId` in the call input (the notification-output
39787
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
39788
- * (hub-placed); the cap stays open for future providers.
39789
- *
39790
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
39791
- * `apiKey` is a password field — providers REDACT it on read and merge on
39792
- * write; a stored key NEVER round-trips to a client.
40078
+ * The provider-specific part of a profile, validated by the provider that owns
40079
+ * the kind (`upsertProfile` refuses what it does not accept). A field its
40080
+ * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
40081
+ * keychain, never in the row, and reads back as the redaction marker.
39793
40082
  */
39794
- var LlmProfileKindSchema = _enum([
39795
- "openai-compatible",
39796
- "openai",
39797
- "anthropic",
39798
- "google",
39799
- "managed-local",
39800
- "apple-foundation"
39801
- ]);
40083
+ var LlmProviderConfigSchema = record(string(), unknown());
39802
40084
  var LlmProfileSchema = object({
39803
40085
  id: string(),
39804
40086
  name: string(),
40087
+ /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
39805
40088
  kind: LlmProfileKindSchema,
39806
40089
  /** Stamped by the provider — keeps the fanned catalog routable. */
39807
40090
  addonId: string(),
39808
40091
  enabled: boolean(),
39809
40092
  /** Vendor model id, or the managed runtime's loaded model. */
39810
40093
  model: string(),
39811
- /** Required for openai-compatible; override for cloud kinds. */
39812
- baseUrl: string().optional(),
39813
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
39814
- apiKey: string().optional(),
39815
40094
  /** Vision on/off. A vision call against a `false` profile is REFUSED, never
39816
40095
  * degraded to text — that shipped once and produced a confident answer to a
39817
40096
  * question about a picture nobody sent. */
@@ -39819,15 +40098,11 @@ var LlmProfileSchema = object({
39819
40098
  temperature: number().min(0).max(2).optional(),
39820
40099
  /** Nucleus sampling. Every wire we speak has it. */
39821
40100
  topP: number().min(0).max(1).optional(),
39822
- /** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
39823
- * wire does, and the client drops it there (measured: the request body gets
39824
- * `top_p` and no `top_k`). The profile editor hides the field wherever it
39825
- * would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
40101
+ /** Top-k sampling. Carried only by the wires that have it — a kind offers the
40102
+ * field in its editor only when its descriptor lists it in `profileFields`. */
39826
40103
  topK: number().int().positive().optional(),
39827
40104
  maxTokens: number().int().positive().optional(),
39828
- /** Prompt context window. Advisory for cloud kinds (they enforce their own);
39829
- * for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
39830
- * the model with, so it is the one field that changes a PROCESS. */
40105
+ /** Prompt context window. Advisory for cloud kinds (they enforce their own). */
39831
40106
  contextLength: number().int().positive().optional(),
39832
40107
  /** Default system prompt. A caller's `system` REPLACES it (never appends —
39833
40108
  * two system prompts fighting is worse than either alone). */
@@ -39853,16 +40128,37 @@ var LlmProfileSchema = object({
39853
40128
  * library; the REGISTRY of callable tools is ours and is empty in v1, so a
39854
40129
  * `true` here buys the wiring, not behaviour, until tools are registered. */
39855
40130
  toolsEnabled: boolean().default(false),
39856
- extraHeaders: record(string(), string()).optional(),
39857
- /** kind === 'managed-local' only (spec §4). */
39858
- runtime: ManagedRuntimeConfigSchema.optional(),
39859
- /**
39860
- * kind === 'apple-foundation' only: WHERE it runs — the only thing there is
39861
- * to configure (no key, no URL, no download; `model` is `apple-system`).
39862
- * `supportsVision` on such a row is stamped by the provider from the node's
39863
- * reported `imageInput`, never taken from the operator (D62).
39864
- */
39865
- appleFoundation: object({ nodeId: string() }).optional()
40131
+ /** Everything the kind's provider owns (endpoint, key, node, runtime…). */
40132
+ providerConfig: LlmProviderConfigSchema.default({})
40133
+ });
40134
+ /**
40135
+ * The common profile fields a kind's editor offers. The editor owns how each
40136
+ * one is drawn; the provider says which of them mean something on its wire.
40137
+ */
40138
+ var LlmProfileFieldSchema = _enum([
40139
+ "temperature",
40140
+ "topP",
40141
+ "topK",
40142
+ "maxTokens",
40143
+ "contextLength",
40144
+ "systemPrompt",
40145
+ "timeoutMs",
40146
+ "connectTimeoutMs",
40147
+ "firstTokenTimeoutMs",
40148
+ "idleTimeoutMs",
40149
+ "retry",
40150
+ "toolsEnabled"
40151
+ ]);
40152
+ /**
40153
+ * A provider-drawn part of the editor, by a generic widget id the admin UI
40154
+ * registers (`ai/apple-node`). `placement: 'model'` replaces the generic model
40155
+ * picker: that widget owns the model choice.
40156
+ */
40157
+ var LlmProviderWidgetSchema = object({
40158
+ id: string(),
40159
+ placement: _enum(["connection", "model"]),
40160
+ /** `providerConfig` keys this widget must fill before the profile can be saved. */
40161
+ requires: array(string()).optional()
39866
40162
  });
39867
40163
  /** ConfigUISchema tree passed through untyped on the wire (the
39868
40164
  * notification-output `ConfigSchemaPassthrough` precedent at
@@ -39871,11 +40167,56 @@ var ConfigSchemaPassthrough$3 = unknown();
39871
40167
  var LlmProfileKindDescriptorSchema = object({
39872
40168
  kind: LlmProfileKindSchema,
39873
40169
  label: string(),
40170
+ /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
39874
40171
  icon: string(),
39875
40172
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
39876
40173
  addonId: string(),
39877
- configSchema: ConfigSchemaPassthrough$3
40174
+ /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
40175
+ connectionSchema: ConfigSchemaPassthrough$3,
40176
+ /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
40177
+ advancedSchema: ConfigSchemaPassthrough$3.optional(),
40178
+ /** The kind's defaults; a model from `listModels` may override any of them. */
40179
+ features: LlmModelFeaturesSchema,
40180
+ /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
40181
+ visionEditable: boolean(),
40182
+ /** Where the model list comes from: `listModels`, `staticModels`, or nowhere. */
40183
+ modelCatalog: _enum([
40184
+ "fetch",
40185
+ "static",
40186
+ "none"
40187
+ ]),
40188
+ staticModels: array(LlmModelInfoSchema).optional(),
40189
+ /** The common fields that mean something on this kind's wire. */
40190
+ profileFields: array(LlmProfileFieldSchema),
40191
+ providerWidgets: array(LlmProviderWidgetSchema).optional()
40192
+ });
40193
+ /**
40194
+ * `listModels` input. `connection` is an UNSAVED draft of `providerConfig`
40195
+ * (the editor's form); with `profileId` too, a secret the draft leaves
40196
+ * untouched (absent or the redaction marker) is resolved server-side from the
40197
+ * stored profile — the browser never receives it.
40198
+ */
40199
+ var LlmListModelsInputSchema = object({
40200
+ addonId: string(),
40201
+ kind: LlmProfileKindSchema,
40202
+ profileId: string().optional(),
40203
+ connection: LlmProviderConfigSchema.optional()
39878
40204
  });
40205
+ var LlmListModelsErrorCodeSchema = _enum([
40206
+ "auth",
40207
+ "network",
40208
+ "unsupported",
40209
+ "invalid"
40210
+ ]);
40211
+ /** A RESULT, never a throw: "wrong key" is an answer the editor renders inline. */
40212
+ var LlmListModelsResultSchema = discriminatedUnion("ok", [object({
40213
+ ok: literal(true),
40214
+ models: array(LlmModelInfoSchema)
40215
+ }), object({
40216
+ ok: literal(false),
40217
+ code: LlmListModelsErrorCodeSchema,
40218
+ message: string()
40219
+ })]);
39879
40220
  var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
39880
40221
  var LlmDefaultSchema = object({
39881
40222
  selector: LlmDefaultSelectorSchema,
@@ -39975,7 +40316,10 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
39975
40316
  kind: "mutation",
39976
40317
  auth: "admin",
39977
40318
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39978
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
40319
+ }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
40320
+ kind: "mutation",
40321
+ auth: "admin"
40322
+ }), method(object({}), array(LlmDefaultSchema)), method(object({
39979
40323
  selector: LlmDefaultSelectorSchema,
39980
40324
  profileId: string().nullable()
39981
40325
  }), _void(), {
@@ -44061,202 +44405,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
44061
44405
  auth: "admin"
44062
44406
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
44063
44407
  /**
44064
- * Zod schemas for persisted record types.
44065
- *
44066
- * These schemas serve as the single source of truth for types that are
44067
- * stored in the settings-store backend and retrieved via tRPC. They
44068
- * replace the manual TypeScript interfaces with schema-derived types,
44069
- * enabling runtime validation when reading from the backend.
44070
- *
44071
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
44072
- * keeps the original name for backward compatibility.
44073
- */
44074
- /**
44075
- * Auth model (v2 — 2026-05-12 caps-only):
44076
- *
44077
- * Two principals:
44078
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
44079
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
44080
- *
44081
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44082
- * `super_admin` — collapsed onto the single boolean because every
44083
- * non-admin caller is governed by the same scope-check rules; the
44084
- * distinction was only ever used to route role-specific procedures
44085
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44086
- * with `isAdmin: false` + an explicit scope list.
44087
- */
44088
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44089
- var MethodAccessSchema = _enum([
44090
- "view",
44091
- "create",
44092
- "delete"
44093
- ]);
44094
- /**
44095
- * A single scope grant. Three forms — checked in matcher with OR
44096
- * semantics; the first match decides whether the call passes:
44097
- *
44098
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44099
- * cap with the matching `scope` declaration. New caps inherit grants
44100
- * automatically — adding a device cap to the codebase makes it
44101
- * reachable to every user with `category:device [...]` without a
44102
- * re-grant. Use this for "family viewer" / "operator" tiers.
44103
- *
44104
- * - `addon` — every cap that ships inside a given addon id. Niche;
44105
- * useful when an integration needs to interact with one specific
44106
- * addon's surface regardless of how many caps it exports.
44107
- *
44108
- * - `capability` — the most precise form. Single cap name. Use for
44109
- * integration tokens where you want to grant `addons.installPackage`
44110
- * and nothing else.
44111
- *
44112
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44113
- * "give me everything" escape; there is no wildcard scope.
44114
- */
44115
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44116
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44117
- var CapScopeSchema = _enum(["device", "system"]);
44118
- /**
44119
- * DeviceSelector (scope model v3 — 2026-08-12).
44120
- *
44121
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44122
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44123
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44124
- * AFTER the grant was minted — no re-grant, no re-login.
44125
- *
44126
- * - `all` — every device in the deployment. The broad viewer/operator
44127
- * lever without a `category` grant (a `category` grant also covers device
44128
- * caps that carry no deviceId; `all` is specifically the device set).
44129
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44130
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44131
- * is NOT covered until the grant is edited.
44132
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44133
- * DYNAMIC. A device that changes type, or a new device of the type,
44134
- * re-resolves on the next request.
44135
- * - `locations` — every device whose operator-assigned `location` label is
44136
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44137
- * null/unset location matches NO `locations` selector.
44138
- */
44139
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44140
- object({ kind: literal("all") }),
44141
- object({
44142
- kind: literal("ids"),
44143
- ids: array(number().int()).min(1)
44144
- }),
44145
- object({
44146
- kind: literal("types"),
44147
- types: array(_enum(DeviceType)).min(1)
44148
- }),
44149
- object({
44150
- kind: literal("locations"),
44151
- locations: array(string().min(1)).min(1)
44152
- })
44153
- ]);
44154
- var DeviceTokenScopeSchema = object({
44155
- type: literal("device"),
44156
- /** The device SET this grant covers — resolved against the live fleet. */
44157
- selector: DeviceSelectorSchema,
44158
- access: array(MethodAccessSchema).min(1),
44159
- /**
44160
- * Whether a grant on a PARENT device transparently covers its accessory
44161
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44162
- * Direction is parent → children ONLY.
44163
- *
44164
- * Absent → the matcher DERIVES it from the access flavour: `view`
44165
- * inherits (a camera viewer sees the camera's accessories), `create` /
44166
- * `delete` do NOT (actuating/removing a child is an explicit act the
44167
- * operator must grant on the child, not inherit from the parent). Set it
44168
- * explicitly to override that default per grant.
44169
- */
44170
- includeLinked: boolean().optional()
44171
- });
44172
- /**
44173
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44174
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44175
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44176
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44177
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44178
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44179
- * migration cannot reach a JWT already in a client's hands; parse-time
44180
- * migration covers both without a flag day. No cast — the raw object is read
44181
- * through `Reflect.get` (its static type is `unknown`).
44182
- */
44183
- function migrateLegacyTokenScope(raw) {
44184
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44185
- if (Reflect.get(raw, "type") !== "device") return raw;
44186
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44187
- const targets = Reflect.get(raw, "targets");
44188
- if (!Array.isArray(targets)) return raw;
44189
- return {
44190
- type: "device",
44191
- selector: {
44192
- kind: "ids",
44193
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44194
- },
44195
- access: Reflect.get(raw, "access")
44196
- };
44197
- }
44198
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44199
- object({
44200
- type: literal("category"),
44201
- target: CapScopeSchema,
44202
- access: array(MethodAccessSchema).min(1)
44203
- }),
44204
- object({
44205
- type: literal("capability"),
44206
- target: string(),
44207
- access: array(MethodAccessSchema).min(1)
44208
- }),
44209
- object({
44210
- type: literal("addon"),
44211
- target: string(),
44212
- access: array(MethodAccessSchema).min(1)
44213
- }),
44214
- DeviceTokenScopeSchema
44215
- ]));
44216
- object({
44217
- id: string(),
44218
- username: string(),
44219
- passwordHash: string(),
44220
- /**
44221
- * Admin bypass. When true, the middleware skips the scope-access
44222
- * check entirely. There is no other axis of privilege; the legacy
44223
- * role enum collapsed onto this boolean in v2.
44224
- */
44225
- isAdmin: boolean().default(false),
44226
- allowedProviders: AllowedProviderSchema,
44227
- allowedDevices: AllowedDevicesSchema,
44228
- /**
44229
- * Scopes granted to this user. Admins bypass; their `scopes` is
44230
- * ignored. Non-admins without scopes are locked out of every
44231
- * protected call.
44232
- */
44233
- scopes: array(TokenScopeSchema).default([]),
44234
- createdAt: number(),
44235
- updatedAt: number()
44236
- });
44237
- object({
44238
- id: string(),
44239
- label: string(),
44240
- isAdmin: boolean().default(false),
44241
- allowedProviders: AllowedProviderSchema,
44242
- allowedDevices: AllowedDevicesSchema,
44243
- tokenHash: string(),
44244
- tokenPrefix: string(),
44245
- createdAt: number(),
44246
- lastUsedAt: number().optional()
44247
- });
44248
- object({
44249
- id: string(),
44250
- userId: string(),
44251
- name: string(),
44252
- tokenHash: string(),
44253
- tokenPrefix: string(),
44254
- scopes: array(TokenScopeSchema),
44255
- expiresAt: number().nullish(),
44256
- lastUsedAt: number().nullish(),
44257
- createdAt: number()
44258
- });
44259
- /**
44260
44408
  * `oauth-integration` — a collection cap by which an addon declares
44261
44409
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44262
44410
  * Each provider returns a static descriptor; the core enumerates them
@@ -61188,26 +61336,6 @@ var ApiKeySummarySchema = object({
61188
61336
  createdAt: number(),
61189
61337
  lastUsedAt: number().optional()
61190
61338
  });
61191
- var ScopedTokenSummarySchema = object({
61192
- id: string(),
61193
- userId: string(),
61194
- name: string(),
61195
- tokenPrefix: string(),
61196
- scopes: array(TokenScopeSchema),
61197
- expiresAt: number().nullish(),
61198
- lastUsedAt: number().nullish(),
61199
- createdAt: number()
61200
- });
61201
- var CreateScopedTokenInputSchema = object({
61202
- userId: string(),
61203
- name: string(),
61204
- scopes: array(TokenScopeSchema),
61205
- expiresAt: number().optional()
61206
- });
61207
- var CreateScopedTokenResultSchema = object({
61208
- token: string(),
61209
- record: ScopedTokenSummarySchema
61210
- });
61211
61339
  var OauthSessionSummarySchema = object({
61212
61340
  id: string(),
61213
61341
  userId: string(),
@@ -61229,11 +61357,11 @@ var TotpStatusSchema = object({
61229
61357
  confirmedAt: number().nullable()
61230
61358
  });
61231
61359
  /**
61232
- * user-management — singleton capability for user accounts, API keys,
61233
- * and scoped tokens.
61360
+ * user-management — singleton capability for user accounts and the
61361
+ * legacy API-key rows.
61234
61362
  *
61235
61363
  * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
61236
- * — the subset check on `setUserScopes` / `createScopedToken` is moot
61364
+ * — the subset check on `setUserScopes` is moot
61237
61365
  * because non-admins never reach these. If/when we open non-admin
61238
61366
  * delegation, structural caller-scope subset check goes inside the
61239
61367
  * provider.
@@ -61290,15 +61418,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
61290
61418
  kind: "mutation",
61291
61419
  auth: "admin",
61292
61420
  access: "delete"
61293
- }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
61294
- kind: "mutation",
61295
- auth: "admin",
61296
- access: "create"
61297
- }), method(object({ id: string() }), object({ success: literal(true) }), {
61298
- kind: "mutation",
61299
- auth: "admin",
61300
- access: "delete"
61301
- }), method(object({ token: string() }), ScopedTokenSummarySchema.nullable(), { access: "view" }), method(object({ userId: string() }), array(ScopedTokenSummarySchema), { auth: "admin" }), method(object({ userId: string() }), TotpSetupResultSchema, {
61421
+ }), method(object({ userId: string() }), TotpSetupResultSchema, {
61302
61422
  kind: "mutation",
61303
61423
  auth: "admin",
61304
61424
  access: "create"
@@ -65454,7 +65574,7 @@ Object.freeze({
65454
65574
  capName: "llm",
65455
65575
  capScope: "system",
65456
65576
  addonId: null,
65457
- access: "view"
65577
+ access: "create"
65458
65578
  },
65459
65579
  "llm.listNodeModels": {
65460
65580
  capName: "llm",
@@ -70118,12 +70238,6 @@ Object.freeze({
70118
70238
  addonId: null,
70119
70239
  access: "create"
70120
70240
  },
70121
- "userManagement.createScopedToken": {
70122
- capName: "user-management",
70123
- capScope: "system",
70124
- addonId: null,
70125
- access: "create"
70126
- },
70127
70241
  "userManagement.createUser": {
70128
70242
  capName: "user-management",
70129
70243
  capScope: "system",
@@ -70172,12 +70286,6 @@ Object.freeze({
70172
70286
  addonId: null,
70173
70287
  access: "view"
70174
70288
  },
70175
- "userManagement.listScopedTokens": {
70176
- capName: "user-management",
70177
- capScope: "system",
70178
- addonId: null,
70179
- access: "view"
70180
- },
70181
70289
  "userManagement.listUsers": {
70182
70290
  capName: "user-management",
70183
70291
  capScope: "system",
@@ -70232,12 +70340,6 @@ Object.freeze({
70232
70340
  addonId: null,
70233
70341
  access: "delete"
70234
70342
  },
70235
- "userManagement.revokeScopedToken": {
70236
- capName: "user-management",
70237
- capScope: "system",
70238
- addonId: null,
70239
- access: "delete"
70240
- },
70241
70343
  "userManagement.setupTotp": {
70242
70344
  capName: "user-management",
70243
70345
  capScope: "system",
@@ -70268,12 +70370,6 @@ Object.freeze({
70268
70370
  addonId: null,
70269
70371
  access: "view"
70270
70372
  },
70271
- "userManagement.validateScopedToken": {
70272
- capName: "user-management",
70273
- capScope: "system",
70274
- addonId: null,
70275
- access: "view"
70276
- },
70277
70373
  "userManagement.verifyTotp": {
70278
70374
  capName: "user-management",
70279
70375
  capScope: "system",