@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.js CHANGED
@@ -5577,7 +5577,7 @@ var ZodIssueCode = {
5577
5577
  var ZodFirstPartyTypeKind;
5578
5578
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5579
5579
  //#endregion
5580
- //#region ../types/dist/sleep-BxjU_fJM.mjs
5580
+ //#region ../types/dist/sleep-yKL5gfrH.mjs
5581
5581
  /**
5582
5582
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5583
5583
  * window to float samples (D455).
@@ -7959,6 +7959,12 @@ function normalizeAddonInitResult(result) {
7959
7959
  if (Array.isArray(result)) return { providers: result };
7960
7960
  return result;
7961
7961
  }
7962
+ /**
7963
+ * The share-view scope kinds a share-link token can carry. The hub mints
7964
+ * and validates them (`ShareViewGrantSchema` builds its
7965
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
7966
+ */
7967
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7962
7968
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7963
7969
  var PeerBytesTicketSchema = object({
7964
7970
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12910,6 +12916,280 @@ var ConvertResultSchema = object({
12910
12916
  files: array(string()).readonly()
12911
12917
  })).readonly()
12912
12918
  });
12919
+ /**
12920
+ * Zod schemas for persisted record types.
12921
+ *
12922
+ * These schemas serve as the single source of truth for types that are
12923
+ * stored in the settings-store backend and retrieved via tRPC. They
12924
+ * replace the manual TypeScript interfaces with schema-derived types,
12925
+ * enabling runtime validation when reading from the backend.
12926
+ *
12927
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12928
+ * keeps the original name for backward compatibility.
12929
+ */
12930
+ /**
12931
+ * Auth model (v2 — 2026-05-12 caps-only):
12932
+ *
12933
+ * Two principals:
12934
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12935
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12936
+ *
12937
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12938
+ * `super_admin` — collapsed onto the single boolean because every
12939
+ * non-admin caller is governed by the same scope-check rules; the
12940
+ * distinction was only ever used to route role-specific procedures
12941
+ * which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
12942
+ * with `isAdmin: false` + an explicit scope list.
12943
+ */
12944
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12945
+ var MethodAccessSchema = _enum([
12946
+ "view",
12947
+ "create",
12948
+ "delete"
12949
+ ]);
12950
+ /**
12951
+ * A single scope grant. Three forms — checked in matcher with OR
12952
+ * semantics; the first match decides whether the call passes:
12953
+ *
12954
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12955
+ * cap with the matching `scope` declaration. New caps inherit grants
12956
+ * automatically — adding a device cap to the codebase makes it
12957
+ * reachable to every user with `category:device [...]` without a
12958
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12959
+ *
12960
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12961
+ * useful when an integration needs to interact with one specific
12962
+ * addon's surface regardless of how many caps it exports.
12963
+ *
12964
+ * - `capability` — the most precise form. Single cap name. Use for
12965
+ * integration tokens where you want to grant `addons.installPackage`
12966
+ * and nothing else.
12967
+ *
12968
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12969
+ * "give me everything" escape; there is no wildcard scope.
12970
+ */
12971
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12972
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12973
+ var CapScopeSchema = _enum(["device", "system"]);
12974
+ /**
12975
+ * DeviceSelector (scope model v3 — 2026-08-12).
12976
+ *
12977
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12978
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12979
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12980
+ * AFTER the grant was minted — no re-grant, no re-login.
12981
+ *
12982
+ * - `all` — every device in the deployment. The broad viewer/operator
12983
+ * lever without a `category` grant (a `category` grant also covers device
12984
+ * caps that carry no deviceId; `all` is specifically the device set).
12985
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
12986
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
12987
+ * is NOT covered until the grant is edited.
12988
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
12989
+ * DYNAMIC. A device that changes type, or a new device of the type,
12990
+ * re-resolves on the next request.
12991
+ * - `locations` — every device whose operator-assigned `location` label is
12992
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
12993
+ * null/unset location matches NO `locations` selector.
12994
+ */
12995
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
12996
+ object({ kind: literal("all") }),
12997
+ object({
12998
+ kind: literal("ids"),
12999
+ ids: array(number().int()).min(1)
13000
+ }),
13001
+ object({
13002
+ kind: literal("types"),
13003
+ types: array(_enum(DeviceType)).min(1)
13004
+ }),
13005
+ object({
13006
+ kind: literal("locations"),
13007
+ locations: array(string().min(1)).min(1)
13008
+ })
13009
+ ]);
13010
+ var DeviceTokenScopeSchema = object({
13011
+ type: literal("device"),
13012
+ /** The device SET this grant covers — resolved against the live fleet. */
13013
+ selector: DeviceSelectorSchema,
13014
+ access: array(MethodAccessSchema).min(1),
13015
+ /**
13016
+ * Whether a grant on a PARENT device transparently covers its accessory
13017
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
13018
+ * Direction is parent → children ONLY.
13019
+ *
13020
+ * Absent → the matcher DERIVES it from the access flavour: `view`
13021
+ * inherits (a camera viewer sees the camera's accessories), `create` /
13022
+ * `delete` do NOT (actuating/removing a child is an explicit act the
13023
+ * operator must grant on the child, not inherit from the parent). Set it
13024
+ * explicitly to override that default per grant.
13025
+ */
13026
+ includeLinked: boolean().optional()
13027
+ });
13028
+ /**
13029
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
13030
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
13031
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
13032
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
13033
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
13034
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
13035
+ * migration cannot reach a JWT already in a client's hands; parse-time
13036
+ * migration covers both without a flag day. No cast — the raw object is read
13037
+ * through `Reflect.get` (its static type is `unknown`).
13038
+ */
13039
+ function migrateLegacyTokenScope(raw) {
13040
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
13041
+ if (Reflect.get(raw, "type") !== "device") return raw;
13042
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
13043
+ const targets = Reflect.get(raw, "targets");
13044
+ if (!Array.isArray(targets)) return raw;
13045
+ return {
13046
+ type: "device",
13047
+ selector: {
13048
+ kind: "ids",
13049
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
13050
+ },
13051
+ access: Reflect.get(raw, "access")
13052
+ };
13053
+ }
13054
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
13055
+ object({
13056
+ type: literal("category"),
13057
+ target: CapScopeSchema,
13058
+ access: array(MethodAccessSchema).min(1)
13059
+ }),
13060
+ object({
13061
+ type: literal("capability"),
13062
+ target: string(),
13063
+ access: array(MethodAccessSchema).min(1)
13064
+ }),
13065
+ object({
13066
+ type: literal("addon"),
13067
+ target: string(),
13068
+ access: array(MethodAccessSchema).min(1)
13069
+ }),
13070
+ DeviceTokenScopeSchema
13071
+ ]));
13072
+ object({
13073
+ id: string(),
13074
+ username: string(),
13075
+ passwordHash: string(),
13076
+ /**
13077
+ * Admin bypass. When true, the middleware skips the scope-access
13078
+ * check entirely. There is no other axis of privilege; the legacy
13079
+ * role enum collapsed onto this boolean in v2.
13080
+ */
13081
+ isAdmin: boolean().default(false),
13082
+ allowedProviders: AllowedProviderSchema,
13083
+ allowedDevices: AllowedDevicesSchema,
13084
+ /**
13085
+ * Scopes granted to this user. Admins bypass; their `scopes` is
13086
+ * ignored. Non-admins without scopes are locked out of every
13087
+ * protected call.
13088
+ */
13089
+ scopes: array(TokenScopeSchema).default([]),
13090
+ createdAt: number(),
13091
+ updatedAt: number()
13092
+ });
13093
+ object({
13094
+ id: string(),
13095
+ label: string(),
13096
+ isAdmin: boolean().default(false),
13097
+ allowedProviders: AllowedProviderSchema,
13098
+ allowedDevices: AllowedDevicesSchema,
13099
+ tokenHash: string(),
13100
+ tokenPrefix: string(),
13101
+ createdAt: number(),
13102
+ lastUsedAt: number().optional()
13103
+ });
13104
+ object({
13105
+ id: string(),
13106
+ userId: string(),
13107
+ name: string(),
13108
+ tokenHash: string(),
13109
+ tokenPrefix: string(),
13110
+ scopes: array(TokenScopeSchema),
13111
+ expiresAt: number().nullish(),
13112
+ lastUsedAt: number().nullish(),
13113
+ createdAt: number()
13114
+ });
13115
+ /** What a share-view grant lets its holder see. */
13116
+ var ShareViewGrantSchema = object({
13117
+ kind: _enum(SHARE_VIEW_KINDS),
13118
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
13119
+ /** Talk-back, opt-in at mint time; absent means off. */
13120
+ talk: boolean().optional()
13121
+ });
13122
+ var ShareViewScopeSchema = object({
13123
+ type: literal("share-view"),
13124
+ grant: ShareViewGrantSchema
13125
+ });
13126
+ var AddonRoutesScopeSchema = object({
13127
+ type: literal("addon-routes"),
13128
+ access: array(MethodAccessSchema).min(1)
13129
+ });
13130
+ var PreferencesSelfScopeSchema = object({ type: literal("preferences-self") });
13131
+ var CredentialScopeSchema = union([
13132
+ literal("*"),
13133
+ ShareViewScopeSchema,
13134
+ AddonRoutesScopeSchema,
13135
+ PreferencesSelfScopeSchema,
13136
+ TokenScopeSchema
13137
+ ]);
13138
+ object({
13139
+ kind: literal("credential"),
13140
+ sub: string().min(1),
13141
+ jti: string().min(16),
13142
+ scopes: array(CredentialScopeSchema).min(1)
13143
+ });
13144
+ var PreferenceNamespaceSchema = string().regex(/^[a-z][a-z0-9.-]{0,63}$/);
13145
+ /** A namespace's value: a JSON object, opaque to the hub. */
13146
+ var PreferenceValueSchema = record(string(), unknown());
13147
+ var PreferenceDeviceIdSchema = string().min(1).max(64);
13148
+ /** A stored row, as the owner reads it. */
13149
+ var PreferenceRowSchema = object({
13150
+ namespace: PreferenceNamespaceSchema,
13151
+ value: PreferenceValueSchema,
13152
+ /** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
13153
+ revision: number().int().positive(),
13154
+ updatedAt: number().int(),
13155
+ /** The client id the last writer sent; `null` when it sent none. */
13156
+ updatedByDevice: PreferenceDeviceIdSchema.nullable()
13157
+ });
13158
+ object({
13159
+ /** Absent: every namespace the caller holds. */
13160
+ namespaces: array(PreferenceNamespaceSchema).max(32).optional() });
13161
+ object({ rows: array(PreferenceRowSchema) });
13162
+ object({
13163
+ namespace: PreferenceNamespaceSchema,
13164
+ value: PreferenceValueSchema,
13165
+ /**
13166
+ * The revision the edit was based on. Absent: last write wins. `0`: the
13167
+ * namespace must not exist yet. Any other value that is not the current
13168
+ * revision answers `conflict` and writes nothing.
13169
+ */
13170
+ baseRevision: number().int().nonnegative().optional(),
13171
+ deviceId: PreferenceDeviceIdSchema.optional()
13172
+ });
13173
+ discriminatedUnion("status", [object({
13174
+ status: literal("saved"),
13175
+ row: PreferenceRowSchema
13176
+ }), object({
13177
+ status: literal("conflict"),
13178
+ current: PreferenceRowSchema.nullable()
13179
+ })]);
13180
+ object({ namespace: PreferenceNamespaceSchema });
13181
+ object({
13182
+ /** `false` when the namespace did not exist. */
13183
+ deleted: boolean() });
13184
+ object({
13185
+ /** The revision the client holds per namespace; a namespace it does not list is new to it. */
13186
+ revisionByNamespace: record(PreferenceNamespaceSchema, number().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
13187
+ object({
13188
+ /** Every row whose revision differs from the client's, and every row it did not list. */
13189
+ rows: array(PreferenceRowSchema),
13190
+ /** Namespaces the client listed that no longer exist. */
13191
+ deleted: array(PreferenceNamespaceSchema)
13192
+ });
12913
13193
  _enum(["new-session", "step-up"]);
12914
13194
  /** The languages the hub's app landing pages are written in (D858). */
12915
13195
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -39807,38 +40087,37 @@ method(LlmRuntimeCompleteInputSchema, LlmGenerateResultSchema, {
39807
40087
  auth: "admin",
39808
40088
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39809
40089
  });
40090
+ var LlmProfileKindSchema = string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "a kind id is lower-case letters, digits and dashes");
40091
+ /** What a model (or, by default, every model of a kind) can do. */
40092
+ var LlmModelFeaturesSchema = object({
40093
+ vision: boolean(),
40094
+ tools: boolean(),
40095
+ streaming: boolean()
40096
+ });
40097
+ /** One model a provider offers. `features` overrides the kind's defaults, per field. */
40098
+ var LlmModelInfoSchema = object({
40099
+ id: string(),
40100
+ label: string().optional(),
40101
+ contextLength: number().int().positive().optional(),
40102
+ features: LlmModelFeaturesSchema.partial().optional()
40103
+ });
39810
40104
  /**
39811
- * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
39812
- * methods concat-fan across providers; single-row methods route to ONE
39813
- * provider by the `addonId` in the call input (the notification-output
39814
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
39815
- * (hub-placed); the cap stays open for future providers.
39816
- *
39817
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
39818
- * `apiKey` is a password field — providers REDACT it on read and merge on
39819
- * write; a stored key NEVER round-trips to a client.
40105
+ * The provider-specific part of a profile, validated by the provider that owns
40106
+ * the kind (`upsertProfile` refuses what it does not accept). A field its
40107
+ * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
40108
+ * keychain, never in the row, and reads back as the redaction marker.
39820
40109
  */
39821
- var LlmProfileKindSchema = _enum([
39822
- "openai-compatible",
39823
- "openai",
39824
- "anthropic",
39825
- "google",
39826
- "managed-local",
39827
- "apple-foundation"
39828
- ]);
40110
+ var LlmProviderConfigSchema = record(string(), unknown());
39829
40111
  var LlmProfileSchema = object({
39830
40112
  id: string(),
39831
40113
  name: string(),
40114
+ /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
39832
40115
  kind: LlmProfileKindSchema,
39833
40116
  /** Stamped by the provider — keeps the fanned catalog routable. */
39834
40117
  addonId: string(),
39835
40118
  enabled: boolean(),
39836
40119
  /** Vendor model id, or the managed runtime's loaded model. */
39837
40120
  model: string(),
39838
- /** Required for openai-compatible; override for cloud kinds. */
39839
- baseUrl: string().optional(),
39840
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
39841
- apiKey: string().optional(),
39842
40121
  /** Vision on/off. A vision call against a `false` profile is REFUSED, never
39843
40122
  * degraded to text — that shipped once and produced a confident answer to a
39844
40123
  * question about a picture nobody sent. */
@@ -39846,15 +40125,11 @@ var LlmProfileSchema = object({
39846
40125
  temperature: number().min(0).max(2).optional(),
39847
40126
  /** Nucleus sampling. Every wire we speak has it. */
39848
40127
  topP: number().min(0).max(1).optional(),
39849
- /** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
39850
- * wire does, and the client drops it there (measured: the request body gets
39851
- * `top_p` and no `top_k`). The profile editor hides the field wherever it
39852
- * would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
40128
+ /** Top-k sampling. Carried only by the wires that have it — a kind offers the
40129
+ * field in its editor only when its descriptor lists it in `profileFields`. */
39853
40130
  topK: number().int().positive().optional(),
39854
40131
  maxTokens: number().int().positive().optional(),
39855
- /** Prompt context window. Advisory for cloud kinds (they enforce their own);
39856
- * for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
39857
- * the model with, so it is the one field that changes a PROCESS. */
40132
+ /** Prompt context window. Advisory for cloud kinds (they enforce their own). */
39858
40133
  contextLength: number().int().positive().optional(),
39859
40134
  /** Default system prompt. A caller's `system` REPLACES it (never appends —
39860
40135
  * two system prompts fighting is worse than either alone). */
@@ -39880,16 +40155,37 @@ var LlmProfileSchema = object({
39880
40155
  * library; the REGISTRY of callable tools is ours and is empty in v1, so a
39881
40156
  * `true` here buys the wiring, not behaviour, until tools are registered. */
39882
40157
  toolsEnabled: boolean().default(false),
39883
- extraHeaders: record(string(), string()).optional(),
39884
- /** kind === 'managed-local' only (spec §4). */
39885
- runtime: ManagedRuntimeConfigSchema.optional(),
39886
- /**
39887
- * kind === 'apple-foundation' only: WHERE it runs — the only thing there is
39888
- * to configure (no key, no URL, no download; `model` is `apple-system`).
39889
- * `supportsVision` on such a row is stamped by the provider from the node's
39890
- * reported `imageInput`, never taken from the operator (D62).
39891
- */
39892
- appleFoundation: object({ nodeId: string() }).optional()
40158
+ /** Everything the kind's provider owns (endpoint, key, node, runtime…). */
40159
+ providerConfig: LlmProviderConfigSchema.default({})
40160
+ });
40161
+ /**
40162
+ * The common profile fields a kind's editor offers. The editor owns how each
40163
+ * one is drawn; the provider says which of them mean something on its wire.
40164
+ */
40165
+ var LlmProfileFieldSchema = _enum([
40166
+ "temperature",
40167
+ "topP",
40168
+ "topK",
40169
+ "maxTokens",
40170
+ "contextLength",
40171
+ "systemPrompt",
40172
+ "timeoutMs",
40173
+ "connectTimeoutMs",
40174
+ "firstTokenTimeoutMs",
40175
+ "idleTimeoutMs",
40176
+ "retry",
40177
+ "toolsEnabled"
40178
+ ]);
40179
+ /**
40180
+ * A provider-drawn part of the editor, by a generic widget id the admin UI
40181
+ * registers (`ai/apple-node`). `placement: 'model'` replaces the generic model
40182
+ * picker: that widget owns the model choice.
40183
+ */
40184
+ var LlmProviderWidgetSchema = object({
40185
+ id: string(),
40186
+ placement: _enum(["connection", "model"]),
40187
+ /** `providerConfig` keys this widget must fill before the profile can be saved. */
40188
+ requires: array(string()).optional()
39893
40189
  });
39894
40190
  /** ConfigUISchema tree passed through untyped on the wire (the
39895
40191
  * notification-output `ConfigSchemaPassthrough` precedent at
@@ -39898,11 +40194,56 @@ var ConfigSchemaPassthrough$3 = unknown();
39898
40194
  var LlmProfileKindDescriptorSchema = object({
39899
40195
  kind: LlmProfileKindSchema,
39900
40196
  label: string(),
40197
+ /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
39901
40198
  icon: string(),
39902
40199
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
39903
40200
  addonId: string(),
39904
- configSchema: ConfigSchemaPassthrough$3
40201
+ /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
40202
+ connectionSchema: ConfigSchemaPassthrough$3,
40203
+ /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
40204
+ advancedSchema: ConfigSchemaPassthrough$3.optional(),
40205
+ /** The kind's defaults; a model from `listModels` may override any of them. */
40206
+ features: LlmModelFeaturesSchema,
40207
+ /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
40208
+ visionEditable: boolean(),
40209
+ /** Where the model list comes from: `listModels`, `staticModels`, or nowhere. */
40210
+ modelCatalog: _enum([
40211
+ "fetch",
40212
+ "static",
40213
+ "none"
40214
+ ]),
40215
+ staticModels: array(LlmModelInfoSchema).optional(),
40216
+ /** The common fields that mean something on this kind's wire. */
40217
+ profileFields: array(LlmProfileFieldSchema),
40218
+ providerWidgets: array(LlmProviderWidgetSchema).optional()
40219
+ });
40220
+ /**
40221
+ * `listModels` input. `connection` is an UNSAVED draft of `providerConfig`
40222
+ * (the editor's form); with `profileId` too, a secret the draft leaves
40223
+ * untouched (absent or the redaction marker) is resolved server-side from the
40224
+ * stored profile — the browser never receives it.
40225
+ */
40226
+ var LlmListModelsInputSchema = object({
40227
+ addonId: string(),
40228
+ kind: LlmProfileKindSchema,
40229
+ profileId: string().optional(),
40230
+ connection: LlmProviderConfigSchema.optional()
39905
40231
  });
40232
+ var LlmListModelsErrorCodeSchema = _enum([
40233
+ "auth",
40234
+ "network",
40235
+ "unsupported",
40236
+ "invalid"
40237
+ ]);
40238
+ /** A RESULT, never a throw: "wrong key" is an answer the editor renders inline. */
40239
+ var LlmListModelsResultSchema = discriminatedUnion("ok", [object({
40240
+ ok: literal(true),
40241
+ models: array(LlmModelInfoSchema)
40242
+ }), object({
40243
+ ok: literal(false),
40244
+ code: LlmListModelsErrorCodeSchema,
40245
+ message: string()
40246
+ })]);
39906
40247
  var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
39907
40248
  var LlmDefaultSchema = object({
39908
40249
  selector: LlmDefaultSelectorSchema,
@@ -40002,7 +40343,10 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
40002
40343
  kind: "mutation",
40003
40344
  auth: "admin",
40004
40345
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
40005
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
40346
+ }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
40347
+ kind: "mutation",
40348
+ auth: "admin"
40349
+ }), method(object({}), array(LlmDefaultSchema)), method(object({
40006
40350
  selector: LlmDefaultSelectorSchema,
40007
40351
  profileId: string().nullable()
40008
40352
  }), _void(), {
@@ -44088,202 +44432,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
44088
44432
  auth: "admin"
44089
44433
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
44090
44434
  /**
44091
- * Zod schemas for persisted record types.
44092
- *
44093
- * These schemas serve as the single source of truth for types that are
44094
- * stored in the settings-store backend and retrieved via tRPC. They
44095
- * replace the manual TypeScript interfaces with schema-derived types,
44096
- * enabling runtime validation when reading from the backend.
44097
- *
44098
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
44099
- * keeps the original name for backward compatibility.
44100
- */
44101
- /**
44102
- * Auth model (v2 — 2026-05-12 caps-only):
44103
- *
44104
- * Two principals:
44105
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
44106
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
44107
- *
44108
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44109
- * `super_admin` — collapsed onto the single boolean because every
44110
- * non-admin caller is governed by the same scope-check rules; the
44111
- * distinction was only ever used to route role-specific procedures
44112
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44113
- * with `isAdmin: false` + an explicit scope list.
44114
- */
44115
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44116
- var MethodAccessSchema = _enum([
44117
- "view",
44118
- "create",
44119
- "delete"
44120
- ]);
44121
- /**
44122
- * A single scope grant. Three forms — checked in matcher with OR
44123
- * semantics; the first match decides whether the call passes:
44124
- *
44125
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44126
- * cap with the matching `scope` declaration. New caps inherit grants
44127
- * automatically — adding a device cap to the codebase makes it
44128
- * reachable to every user with `category:device [...]` without a
44129
- * re-grant. Use this for "family viewer" / "operator" tiers.
44130
- *
44131
- * - `addon` — every cap that ships inside a given addon id. Niche;
44132
- * useful when an integration needs to interact with one specific
44133
- * addon's surface regardless of how many caps it exports.
44134
- *
44135
- * - `capability` — the most precise form. Single cap name. Use for
44136
- * integration tokens where you want to grant `addons.installPackage`
44137
- * and nothing else.
44138
- *
44139
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44140
- * "give me everything" escape; there is no wildcard scope.
44141
- */
44142
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44143
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44144
- var CapScopeSchema = _enum(["device", "system"]);
44145
- /**
44146
- * DeviceSelector (scope model v3 — 2026-08-12).
44147
- *
44148
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44149
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44150
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44151
- * AFTER the grant was minted — no re-grant, no re-login.
44152
- *
44153
- * - `all` — every device in the deployment. The broad viewer/operator
44154
- * lever without a `category` grant (a `category` grant also covers device
44155
- * caps that carry no deviceId; `all` is specifically the device set).
44156
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44157
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44158
- * is NOT covered until the grant is edited.
44159
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44160
- * DYNAMIC. A device that changes type, or a new device of the type,
44161
- * re-resolves on the next request.
44162
- * - `locations` — every device whose operator-assigned `location` label is
44163
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44164
- * null/unset location matches NO `locations` selector.
44165
- */
44166
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44167
- object({ kind: literal("all") }),
44168
- object({
44169
- kind: literal("ids"),
44170
- ids: array(number().int()).min(1)
44171
- }),
44172
- object({
44173
- kind: literal("types"),
44174
- types: array(_enum(DeviceType)).min(1)
44175
- }),
44176
- object({
44177
- kind: literal("locations"),
44178
- locations: array(string().min(1)).min(1)
44179
- })
44180
- ]);
44181
- var DeviceTokenScopeSchema = object({
44182
- type: literal("device"),
44183
- /** The device SET this grant covers — resolved against the live fleet. */
44184
- selector: DeviceSelectorSchema,
44185
- access: array(MethodAccessSchema).min(1),
44186
- /**
44187
- * Whether a grant on a PARENT device transparently covers its accessory
44188
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44189
- * Direction is parent → children ONLY.
44190
- *
44191
- * Absent → the matcher DERIVES it from the access flavour: `view`
44192
- * inherits (a camera viewer sees the camera's accessories), `create` /
44193
- * `delete` do NOT (actuating/removing a child is an explicit act the
44194
- * operator must grant on the child, not inherit from the parent). Set it
44195
- * explicitly to override that default per grant.
44196
- */
44197
- includeLinked: boolean().optional()
44198
- });
44199
- /**
44200
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44201
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44202
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44203
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44204
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44205
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44206
- * migration cannot reach a JWT already in a client's hands; parse-time
44207
- * migration covers both without a flag day. No cast — the raw object is read
44208
- * through `Reflect.get` (its static type is `unknown`).
44209
- */
44210
- function migrateLegacyTokenScope(raw) {
44211
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44212
- if (Reflect.get(raw, "type") !== "device") return raw;
44213
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44214
- const targets = Reflect.get(raw, "targets");
44215
- if (!Array.isArray(targets)) return raw;
44216
- return {
44217
- type: "device",
44218
- selector: {
44219
- kind: "ids",
44220
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44221
- },
44222
- access: Reflect.get(raw, "access")
44223
- };
44224
- }
44225
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44226
- object({
44227
- type: literal("category"),
44228
- target: CapScopeSchema,
44229
- access: array(MethodAccessSchema).min(1)
44230
- }),
44231
- object({
44232
- type: literal("capability"),
44233
- target: string(),
44234
- access: array(MethodAccessSchema).min(1)
44235
- }),
44236
- object({
44237
- type: literal("addon"),
44238
- target: string(),
44239
- access: array(MethodAccessSchema).min(1)
44240
- }),
44241
- DeviceTokenScopeSchema
44242
- ]));
44243
- object({
44244
- id: string(),
44245
- username: string(),
44246
- passwordHash: string(),
44247
- /**
44248
- * Admin bypass. When true, the middleware skips the scope-access
44249
- * check entirely. There is no other axis of privilege; the legacy
44250
- * role enum collapsed onto this boolean in v2.
44251
- */
44252
- isAdmin: boolean().default(false),
44253
- allowedProviders: AllowedProviderSchema,
44254
- allowedDevices: AllowedDevicesSchema,
44255
- /**
44256
- * Scopes granted to this user. Admins bypass; their `scopes` is
44257
- * ignored. Non-admins without scopes are locked out of every
44258
- * protected call.
44259
- */
44260
- scopes: array(TokenScopeSchema).default([]),
44261
- createdAt: number(),
44262
- updatedAt: number()
44263
- });
44264
- object({
44265
- id: string(),
44266
- label: string(),
44267
- isAdmin: boolean().default(false),
44268
- allowedProviders: AllowedProviderSchema,
44269
- allowedDevices: AllowedDevicesSchema,
44270
- tokenHash: string(),
44271
- tokenPrefix: string(),
44272
- createdAt: number(),
44273
- lastUsedAt: number().optional()
44274
- });
44275
- object({
44276
- id: string(),
44277
- userId: string(),
44278
- name: string(),
44279
- tokenHash: string(),
44280
- tokenPrefix: string(),
44281
- scopes: array(TokenScopeSchema),
44282
- expiresAt: number().nullish(),
44283
- lastUsedAt: number().nullish(),
44284
- createdAt: number()
44285
- });
44286
- /**
44287
44435
  * `oauth-integration` — a collection cap by which an addon declares
44288
44436
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44289
44437
  * Each provider returns a static descriptor; the core enumerates them
@@ -61215,26 +61363,6 @@ var ApiKeySummarySchema = object({
61215
61363
  createdAt: number(),
61216
61364
  lastUsedAt: number().optional()
61217
61365
  });
61218
- var ScopedTokenSummarySchema = object({
61219
- id: string(),
61220
- userId: string(),
61221
- name: string(),
61222
- tokenPrefix: string(),
61223
- scopes: array(TokenScopeSchema),
61224
- expiresAt: number().nullish(),
61225
- lastUsedAt: number().nullish(),
61226
- createdAt: number()
61227
- });
61228
- var CreateScopedTokenInputSchema = object({
61229
- userId: string(),
61230
- name: string(),
61231
- scopes: array(TokenScopeSchema),
61232
- expiresAt: number().optional()
61233
- });
61234
- var CreateScopedTokenResultSchema = object({
61235
- token: string(),
61236
- record: ScopedTokenSummarySchema
61237
- });
61238
61366
  var OauthSessionSummarySchema = object({
61239
61367
  id: string(),
61240
61368
  userId: string(),
@@ -61256,11 +61384,11 @@ var TotpStatusSchema = object({
61256
61384
  confirmedAt: number().nullable()
61257
61385
  });
61258
61386
  /**
61259
- * user-management — singleton capability for user accounts, API keys,
61260
- * and scoped tokens.
61387
+ * user-management — singleton capability for user accounts and the
61388
+ * legacy API-key rows.
61261
61389
  *
61262
61390
  * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
61263
- * — the subset check on `setUserScopes` / `createScopedToken` is moot
61391
+ * — the subset check on `setUserScopes` is moot
61264
61392
  * because non-admins never reach these. If/when we open non-admin
61265
61393
  * delegation, structural caller-scope subset check goes inside the
61266
61394
  * provider.
@@ -61317,15 +61445,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
61317
61445
  kind: "mutation",
61318
61446
  auth: "admin",
61319
61447
  access: "delete"
61320
- }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
61321
- kind: "mutation",
61322
- auth: "admin",
61323
- access: "create"
61324
- }), method(object({ id: string() }), object({ success: literal(true) }), {
61325
- kind: "mutation",
61326
- auth: "admin",
61327
- access: "delete"
61328
- }), method(object({ token: string() }), ScopedTokenSummarySchema.nullable(), { access: "view" }), method(object({ userId: string() }), array(ScopedTokenSummarySchema), { auth: "admin" }), method(object({ userId: string() }), TotpSetupResultSchema, {
61448
+ }), method(object({ userId: string() }), TotpSetupResultSchema, {
61329
61449
  kind: "mutation",
61330
61450
  auth: "admin",
61331
61451
  access: "create"
@@ -65481,7 +65601,7 @@ Object.freeze({
65481
65601
  capName: "llm",
65482
65602
  capScope: "system",
65483
65603
  addonId: null,
65484
- access: "view"
65604
+ access: "create"
65485
65605
  },
65486
65606
  "llm.listNodeModels": {
65487
65607
  capName: "llm",
@@ -70145,12 +70265,6 @@ Object.freeze({
70145
70265
  addonId: null,
70146
70266
  access: "create"
70147
70267
  },
70148
- "userManagement.createScopedToken": {
70149
- capName: "user-management",
70150
- capScope: "system",
70151
- addonId: null,
70152
- access: "create"
70153
- },
70154
70268
  "userManagement.createUser": {
70155
70269
  capName: "user-management",
70156
70270
  capScope: "system",
@@ -70199,12 +70313,6 @@ Object.freeze({
70199
70313
  addonId: null,
70200
70314
  access: "view"
70201
70315
  },
70202
- "userManagement.listScopedTokens": {
70203
- capName: "user-management",
70204
- capScope: "system",
70205
- addonId: null,
70206
- access: "view"
70207
- },
70208
70316
  "userManagement.listUsers": {
70209
70317
  capName: "user-management",
70210
70318
  capScope: "system",
@@ -70259,12 +70367,6 @@ Object.freeze({
70259
70367
  addonId: null,
70260
70368
  access: "delete"
70261
70369
  },
70262
- "userManagement.revokeScopedToken": {
70263
- capName: "user-management",
70264
- capScope: "system",
70265
- addonId: null,
70266
- access: "delete"
70267
- },
70268
70370
  "userManagement.setupTotp": {
70269
70371
  capName: "user-management",
70270
70372
  capScope: "system",
@@ -70295,12 +70397,6 @@ Object.freeze({
70295
70397
  addonId: null,
70296
70398
  access: "view"
70297
70399
  },
70298
- "userManagement.validateScopedToken": {
70299
- capName: "user-management",
70300
- capScope: "system",
70301
- addonId: null,
70302
- access: "view"
70303
- },
70304
70400
  "userManagement.verifyTotp": {
70305
70401
  capName: "user-management",
70306
70402
  capScope: "system",