@camstack/addon-model-studio 1.1.272 → 1.1.274

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 (18) hide show
  1. package/dist/{MotionZonesSettings-uJM4ZUGp.mjs → MotionZonesSettings-D5MWmul3.mjs} +2 -2
  2. package/dist/{PrivacyMaskSettings-xm3OPawb.mjs → PrivacyMaskSettings-C3Wr7iyO.mjs} +4 -4
  3. package/dist/{SceneMonitorEditor-CU_dpHhd.mjs → SceneMonitorEditor-C1_f1Q-S.mjs} +3 -3
  4. package/dist/_stub.js +53 -53
  5. package/dist/{_virtual_mf-localSharedImportMap___mfe_internal__addon_model_studio_page-CDB41sJz.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_model_studio_page-BmHFCtbY.mjs} +4 -4
  6. package/dist/_virtual_mf___mfe_internal__addon_model_studio_page__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-CNZj-X83.mjs +26 -0
  7. package/dist/{hostInit-Bb-UT7C0.mjs → hostInit-DXmGI4M9.mjs} +3 -3
  8. package/dist/model-studio.addon.js +390 -294
  9. package/dist/model-studio.addon.mjs +390 -294
  10. package/dist/{player-overlays-BbEJx8gV.mjs → player-overlays-CBnRP2P1.mjs} +1 -1
  11. package/dist/remoteEntry.js +1 -1
  12. package/dist/{responsive-CYhlrBgb.mjs → responsive-E8SO15pe.mjs} +1 -1
  13. package/dist/{scene-monitor-copy-Bwlftx4l.mjs → scene-monitor-copy-CwqpqS1B.mjs} +1 -1
  14. package/dist/{square-BVO9tL_2.mjs → square-CLaS5lbJ.mjs} +1 -1
  15. package/dist/{trash-2-oXufXh2k.mjs → trash-2-BRMfSpae.mjs} +1 -1
  16. package/dist/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_model_studio_page__remoteEntry_js-9kZRVZbG.mjs → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_model_studio_page__remoteEntry_js-DQeUkSxv.mjs} +1 -1
  17. package/package.json +1 -1
  18. package/dist/_virtual_mf___mfe_internal__addon_model_studio_page__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-i7uk041N.mjs +0 -26
@@ -5809,7 +5809,7 @@ var ZodIssueCode = {
5809
5809
  var ZodFirstPartyTypeKind;
5810
5810
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5811
5811
  //#endregion
5812
- //#region ../types/dist/sleep-BxjU_fJM.mjs
5812
+ //#region ../types/dist/sleep-yKL5gfrH.mjs
5813
5813
  /**
5814
5814
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5815
5815
  * window to float samples (D455).
@@ -8191,6 +8191,12 @@ function normalizeAddonInitResult(result) {
8191
8191
  if (Array.isArray(result)) return { providers: result };
8192
8192
  return result;
8193
8193
  }
8194
+ /**
8195
+ * The share-view scope kinds a share-link token can carry. The hub mints
8196
+ * and validates them (`ShareViewGrantSchema` builds its
8197
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
8198
+ */
8199
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
8194
8200
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
8195
8201
  var PeerBytesTicketSchema = object({
8196
8202
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12995,6 +13001,280 @@ var ConvertResultSchema = object({
12995
13001
  entry: ModelCatalogEntrySchema,
12996
13002
  artifacts: array(ConvertArtifactSchema).readonly()
12997
13003
  });
13004
+ /**
13005
+ * Zod schemas for persisted record types.
13006
+ *
13007
+ * These schemas serve as the single source of truth for types that are
13008
+ * stored in the settings-store backend and retrieved via tRPC. They
13009
+ * replace the manual TypeScript interfaces with schema-derived types,
13010
+ * enabling runtime validation when reading from the backend.
13011
+ *
13012
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
13013
+ * keeps the original name for backward compatibility.
13014
+ */
13015
+ /**
13016
+ * Auth model (v2 — 2026-05-12 caps-only):
13017
+ *
13018
+ * Two principals:
13019
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
13020
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
13021
+ *
13022
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
13023
+ * `super_admin` — collapsed onto the single boolean because every
13024
+ * non-admin caller is governed by the same scope-check rules; the
13025
+ * distinction was only ever used to route role-specific procedures
13026
+ * which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
13027
+ * with `isAdmin: false` + an explicit scope list.
13028
+ */
13029
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
13030
+ var MethodAccessSchema = _enum([
13031
+ "view",
13032
+ "create",
13033
+ "delete"
13034
+ ]);
13035
+ /**
13036
+ * A single scope grant. Three forms — checked in matcher with OR
13037
+ * semantics; the first match decides whether the call passes:
13038
+ *
13039
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
13040
+ * cap with the matching `scope` declaration. New caps inherit grants
13041
+ * automatically — adding a device cap to the codebase makes it
13042
+ * reachable to every user with `category:device [...]` without a
13043
+ * re-grant. Use this for "family viewer" / "operator" tiers.
13044
+ *
13045
+ * - `addon` — every cap that ships inside a given addon id. Niche;
13046
+ * useful when an integration needs to interact with one specific
13047
+ * addon's surface regardless of how many caps it exports.
13048
+ *
13049
+ * - `capability` — the most precise form. Single cap name. Use for
13050
+ * integration tokens where you want to grant `addons.installPackage`
13051
+ * and nothing else.
13052
+ *
13053
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
13054
+ * "give me everything" escape; there is no wildcard scope.
13055
+ */
13056
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
13057
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
13058
+ var CapScopeSchema = _enum(["device", "system"]);
13059
+ /**
13060
+ * DeviceSelector (scope model v3 — 2026-08-12).
13061
+ *
13062
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
13063
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
13064
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
13065
+ * AFTER the grant was minted — no re-grant, no re-login.
13066
+ *
13067
+ * - `all` — every device in the deployment. The broad viewer/operator
13068
+ * lever without a `category` grant (a `category` grant also covers device
13069
+ * caps that carry no deviceId; `all` is specifically the device set).
13070
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
13071
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
13072
+ * is NOT covered until the grant is edited.
13073
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
13074
+ * DYNAMIC. A device that changes type, or a new device of the type,
13075
+ * re-resolves on the next request.
13076
+ * - `locations` — every device whose operator-assigned `location` label is
13077
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
13078
+ * null/unset location matches NO `locations` selector.
13079
+ */
13080
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
13081
+ object({ kind: literal("all") }),
13082
+ object({
13083
+ kind: literal("ids"),
13084
+ ids: array(number().int()).min(1)
13085
+ }),
13086
+ object({
13087
+ kind: literal("types"),
13088
+ types: array(_enum(DeviceType)).min(1)
13089
+ }),
13090
+ object({
13091
+ kind: literal("locations"),
13092
+ locations: array(string().min(1)).min(1)
13093
+ })
13094
+ ]);
13095
+ var DeviceTokenScopeSchema = object({
13096
+ type: literal("device"),
13097
+ /** The device SET this grant covers — resolved against the live fleet. */
13098
+ selector: DeviceSelectorSchema,
13099
+ access: array(MethodAccessSchema).min(1),
13100
+ /**
13101
+ * Whether a grant on a PARENT device transparently covers its accessory
13102
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
13103
+ * Direction is parent → children ONLY.
13104
+ *
13105
+ * Absent → the matcher DERIVES it from the access flavour: `view`
13106
+ * inherits (a camera viewer sees the camera's accessories), `create` /
13107
+ * `delete` do NOT (actuating/removing a child is an explicit act the
13108
+ * operator must grant on the child, not inherit from the parent). Set it
13109
+ * explicitly to override that default per grant.
13110
+ */
13111
+ includeLinked: boolean().optional()
13112
+ });
13113
+ /**
13114
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
13115
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
13116
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
13117
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
13118
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
13119
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
13120
+ * migration cannot reach a JWT already in a client's hands; parse-time
13121
+ * migration covers both without a flag day. No cast — the raw object is read
13122
+ * through `Reflect.get` (its static type is `unknown`).
13123
+ */
13124
+ function migrateLegacyTokenScope(raw) {
13125
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
13126
+ if (Reflect.get(raw, "type") !== "device") return raw;
13127
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
13128
+ const targets = Reflect.get(raw, "targets");
13129
+ if (!Array.isArray(targets)) return raw;
13130
+ return {
13131
+ type: "device",
13132
+ selector: {
13133
+ kind: "ids",
13134
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
13135
+ },
13136
+ access: Reflect.get(raw, "access")
13137
+ };
13138
+ }
13139
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
13140
+ object({
13141
+ type: literal("category"),
13142
+ target: CapScopeSchema,
13143
+ access: array(MethodAccessSchema).min(1)
13144
+ }),
13145
+ object({
13146
+ type: literal("capability"),
13147
+ target: string(),
13148
+ access: array(MethodAccessSchema).min(1)
13149
+ }),
13150
+ object({
13151
+ type: literal("addon"),
13152
+ target: string(),
13153
+ access: array(MethodAccessSchema).min(1)
13154
+ }),
13155
+ DeviceTokenScopeSchema
13156
+ ]));
13157
+ object({
13158
+ id: string(),
13159
+ username: string(),
13160
+ passwordHash: string(),
13161
+ /**
13162
+ * Admin bypass. When true, the middleware skips the scope-access
13163
+ * check entirely. There is no other axis of privilege; the legacy
13164
+ * role enum collapsed onto this boolean in v2.
13165
+ */
13166
+ isAdmin: boolean().default(false),
13167
+ allowedProviders: AllowedProviderSchema,
13168
+ allowedDevices: AllowedDevicesSchema,
13169
+ /**
13170
+ * Scopes granted to this user. Admins bypass; their `scopes` is
13171
+ * ignored. Non-admins without scopes are locked out of every
13172
+ * protected call.
13173
+ */
13174
+ scopes: array(TokenScopeSchema).default([]),
13175
+ createdAt: number(),
13176
+ updatedAt: number()
13177
+ });
13178
+ object({
13179
+ id: string(),
13180
+ label: string(),
13181
+ isAdmin: boolean().default(false),
13182
+ allowedProviders: AllowedProviderSchema,
13183
+ allowedDevices: AllowedDevicesSchema,
13184
+ tokenHash: string(),
13185
+ tokenPrefix: string(),
13186
+ createdAt: number(),
13187
+ lastUsedAt: number().optional()
13188
+ });
13189
+ object({
13190
+ id: string(),
13191
+ userId: string(),
13192
+ name: string(),
13193
+ tokenHash: string(),
13194
+ tokenPrefix: string(),
13195
+ scopes: array(TokenScopeSchema),
13196
+ expiresAt: number().nullish(),
13197
+ lastUsedAt: number().nullish(),
13198
+ createdAt: number()
13199
+ });
13200
+ /** What a share-view grant lets its holder see. */
13201
+ var ShareViewGrantSchema = object({
13202
+ kind: _enum(SHARE_VIEW_KINDS),
13203
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
13204
+ /** Talk-back, opt-in at mint time; absent means off. */
13205
+ talk: boolean().optional()
13206
+ });
13207
+ var ShareViewScopeSchema = object({
13208
+ type: literal("share-view"),
13209
+ grant: ShareViewGrantSchema
13210
+ });
13211
+ var AddonRoutesScopeSchema = object({
13212
+ type: literal("addon-routes"),
13213
+ access: array(MethodAccessSchema).min(1)
13214
+ });
13215
+ var PreferencesSelfScopeSchema = object({ type: literal("preferences-self") });
13216
+ var CredentialScopeSchema = union([
13217
+ literal("*"),
13218
+ ShareViewScopeSchema,
13219
+ AddonRoutesScopeSchema,
13220
+ PreferencesSelfScopeSchema,
13221
+ TokenScopeSchema
13222
+ ]);
13223
+ object({
13224
+ kind: literal("credential"),
13225
+ sub: string().min(1),
13226
+ jti: string().min(16),
13227
+ scopes: array(CredentialScopeSchema).min(1)
13228
+ });
13229
+ var PreferenceNamespaceSchema = string().regex(/^[a-z][a-z0-9.-]{0,63}$/);
13230
+ /** A namespace's value: a JSON object, opaque to the hub. */
13231
+ var PreferenceValueSchema = record(string(), unknown());
13232
+ var PreferenceDeviceIdSchema = string().min(1).max(64);
13233
+ /** A stored row, as the owner reads it. */
13234
+ var PreferenceRowSchema = object({
13235
+ namespace: PreferenceNamespaceSchema,
13236
+ value: PreferenceValueSchema,
13237
+ /** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
13238
+ revision: number().int().positive(),
13239
+ updatedAt: number().int(),
13240
+ /** The client id the last writer sent; `null` when it sent none. */
13241
+ updatedByDevice: PreferenceDeviceIdSchema.nullable()
13242
+ });
13243
+ object({
13244
+ /** Absent: every namespace the caller holds. */
13245
+ namespaces: array(PreferenceNamespaceSchema).max(32).optional() });
13246
+ object({ rows: array(PreferenceRowSchema) });
13247
+ object({
13248
+ namespace: PreferenceNamespaceSchema,
13249
+ value: PreferenceValueSchema,
13250
+ /**
13251
+ * The revision the edit was based on. Absent: last write wins. `0`: the
13252
+ * namespace must not exist yet. Any other value that is not the current
13253
+ * revision answers `conflict` and writes nothing.
13254
+ */
13255
+ baseRevision: number().int().nonnegative().optional(),
13256
+ deviceId: PreferenceDeviceIdSchema.optional()
13257
+ });
13258
+ discriminatedUnion("status", [object({
13259
+ status: literal("saved"),
13260
+ row: PreferenceRowSchema
13261
+ }), object({
13262
+ status: literal("conflict"),
13263
+ current: PreferenceRowSchema.nullable()
13264
+ })]);
13265
+ object({ namespace: PreferenceNamespaceSchema });
13266
+ object({
13267
+ /** `false` when the namespace did not exist. */
13268
+ deleted: boolean() });
13269
+ object({
13270
+ /** The revision the client holds per namespace; a namespace it does not list is new to it. */
13271
+ revisionByNamespace: record(PreferenceNamespaceSchema, number().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
13272
+ object({
13273
+ /** Every row whose revision differs from the client's, and every row it did not list. */
13274
+ rows: array(PreferenceRowSchema),
13275
+ /** Namespaces the client listed that no longer exist. */
13276
+ deleted: array(PreferenceNamespaceSchema)
13277
+ });
12998
13278
  _enum(["new-session", "step-up"]);
12999
13279
  /** The languages the hub's app landing pages are written in (D858). */
13000
13280
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -39918,38 +40198,37 @@ method(LlmRuntimeCompleteInputSchema, LlmGenerateResultSchema, {
39918
40198
  auth: "admin",
39919
40199
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39920
40200
  });
40201
+ var LlmProfileKindSchema = string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "a kind id is lower-case letters, digits and dashes");
40202
+ /** What a model (or, by default, every model of a kind) can do. */
40203
+ var LlmModelFeaturesSchema = object({
40204
+ vision: boolean(),
40205
+ tools: boolean(),
40206
+ streaming: boolean()
40207
+ });
40208
+ /** One model a provider offers. `features` overrides the kind's defaults, per field. */
40209
+ var LlmModelInfoSchema = object({
40210
+ id: string(),
40211
+ label: string().optional(),
40212
+ contextLength: number().int().positive().optional(),
40213
+ features: LlmModelFeaturesSchema.partial().optional()
40214
+ });
39921
40215
  /**
39922
- * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
39923
- * methods concat-fan across providers; single-row methods route to ONE
39924
- * provider by the `addonId` in the call input (the notification-output
39925
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
39926
- * (hub-placed); the cap stays open for future providers.
39927
- *
39928
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
39929
- * `apiKey` is a password field — providers REDACT it on read and merge on
39930
- * write; a stored key NEVER round-trips to a client.
40216
+ * The provider-specific part of a profile, validated by the provider that owns
40217
+ * the kind (`upsertProfile` refuses what it does not accept). A field its
40218
+ * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
40219
+ * keychain, never in the row, and reads back as the redaction marker.
39931
40220
  */
39932
- var LlmProfileKindSchema = _enum([
39933
- "openai-compatible",
39934
- "openai",
39935
- "anthropic",
39936
- "google",
39937
- "managed-local",
39938
- "apple-foundation"
39939
- ]);
40221
+ var LlmProviderConfigSchema = record(string(), unknown());
39940
40222
  var LlmProfileSchema = object({
39941
40223
  id: string(),
39942
40224
  name: string(),
40225
+ /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
39943
40226
  kind: LlmProfileKindSchema,
39944
40227
  /** Stamped by the provider — keeps the fanned catalog routable. */
39945
40228
  addonId: string(),
39946
40229
  enabled: boolean(),
39947
40230
  /** Vendor model id, or the managed runtime's loaded model. */
39948
40231
  model: string(),
39949
- /** Required for openai-compatible; override for cloud kinds. */
39950
- baseUrl: string().optional(),
39951
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
39952
- apiKey: string().optional(),
39953
40232
  /** Vision on/off. A vision call against a `false` profile is REFUSED, never
39954
40233
  * degraded to text — that shipped once and produced a confident answer to a
39955
40234
  * question about a picture nobody sent. */
@@ -39957,15 +40236,11 @@ var LlmProfileSchema = object({
39957
40236
  temperature: number().min(0).max(2).optional(),
39958
40237
  /** Nucleus sampling. Every wire we speak has it. */
39959
40238
  topP: number().min(0).max(1).optional(),
39960
- /** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
39961
- * wire does, and the client drops it there (measured: the request body gets
39962
- * `top_p` and no `top_k`). The profile editor hides the field wherever it
39963
- * would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
40239
+ /** Top-k sampling. Carried only by the wires that have it — a kind offers the
40240
+ * field in its editor only when its descriptor lists it in `profileFields`. */
39964
40241
  topK: number().int().positive().optional(),
39965
40242
  maxTokens: number().int().positive().optional(),
39966
- /** Prompt context window. Advisory for cloud kinds (they enforce their own);
39967
- * for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
39968
- * the model with, so it is the one field that changes a PROCESS. */
40243
+ /** Prompt context window. Advisory for cloud kinds (they enforce their own). */
39969
40244
  contextLength: number().int().positive().optional(),
39970
40245
  /** Default system prompt. A caller's `system` REPLACES it (never appends —
39971
40246
  * two system prompts fighting is worse than either alone). */
@@ -39991,16 +40266,37 @@ var LlmProfileSchema = object({
39991
40266
  * library; the REGISTRY of callable tools is ours and is empty in v1, so a
39992
40267
  * `true` here buys the wiring, not behaviour, until tools are registered. */
39993
40268
  toolsEnabled: boolean().default(false),
39994
- extraHeaders: record(string(), string()).optional(),
39995
- /** kind === 'managed-local' only (spec §4). */
39996
- runtime: ManagedRuntimeConfigSchema.optional(),
39997
- /**
39998
- * kind === 'apple-foundation' only: WHERE it runs — the only thing there is
39999
- * to configure (no key, no URL, no download; `model` is `apple-system`).
40000
- * `supportsVision` on such a row is stamped by the provider from the node's
40001
- * reported `imageInput`, never taken from the operator (D62).
40002
- */
40003
- appleFoundation: object({ nodeId: string() }).optional()
40269
+ /** Everything the kind's provider owns (endpoint, key, node, runtime…). */
40270
+ providerConfig: LlmProviderConfigSchema.default({})
40271
+ });
40272
+ /**
40273
+ * The common profile fields a kind's editor offers. The editor owns how each
40274
+ * one is drawn; the provider says which of them mean something on its wire.
40275
+ */
40276
+ var LlmProfileFieldSchema = _enum([
40277
+ "temperature",
40278
+ "topP",
40279
+ "topK",
40280
+ "maxTokens",
40281
+ "contextLength",
40282
+ "systemPrompt",
40283
+ "timeoutMs",
40284
+ "connectTimeoutMs",
40285
+ "firstTokenTimeoutMs",
40286
+ "idleTimeoutMs",
40287
+ "retry",
40288
+ "toolsEnabled"
40289
+ ]);
40290
+ /**
40291
+ * A provider-drawn part of the editor, by a generic widget id the admin UI
40292
+ * registers (`ai/apple-node`). `placement: 'model'` replaces the generic model
40293
+ * picker: that widget owns the model choice.
40294
+ */
40295
+ var LlmProviderWidgetSchema = object({
40296
+ id: string(),
40297
+ placement: _enum(["connection", "model"]),
40298
+ /** `providerConfig` keys this widget must fill before the profile can be saved. */
40299
+ requires: array(string()).optional()
40004
40300
  });
40005
40301
  /** ConfigUISchema tree passed through untyped on the wire (the
40006
40302
  * notification-output `ConfigSchemaPassthrough` precedent at
@@ -40009,11 +40305,56 @@ var ConfigSchemaPassthrough$3 = unknown();
40009
40305
  var LlmProfileKindDescriptorSchema = object({
40010
40306
  kind: LlmProfileKindSchema,
40011
40307
  label: string(),
40308
+ /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
40012
40309
  icon: string(),
40013
40310
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
40014
40311
  addonId: string(),
40015
- configSchema: ConfigSchemaPassthrough$3
40312
+ /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
40313
+ connectionSchema: ConfigSchemaPassthrough$3,
40314
+ /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
40315
+ advancedSchema: ConfigSchemaPassthrough$3.optional(),
40316
+ /** The kind's defaults; a model from `listModels` may override any of them. */
40317
+ features: LlmModelFeaturesSchema,
40318
+ /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
40319
+ visionEditable: boolean(),
40320
+ /** Where the model list comes from: `listModels`, `staticModels`, or nowhere. */
40321
+ modelCatalog: _enum([
40322
+ "fetch",
40323
+ "static",
40324
+ "none"
40325
+ ]),
40326
+ staticModels: array(LlmModelInfoSchema).optional(),
40327
+ /** The common fields that mean something on this kind's wire. */
40328
+ profileFields: array(LlmProfileFieldSchema),
40329
+ providerWidgets: array(LlmProviderWidgetSchema).optional()
40330
+ });
40331
+ /**
40332
+ * `listModels` input. `connection` is an UNSAVED draft of `providerConfig`
40333
+ * (the editor's form); with `profileId` too, a secret the draft leaves
40334
+ * untouched (absent or the redaction marker) is resolved server-side from the
40335
+ * stored profile — the browser never receives it.
40336
+ */
40337
+ var LlmListModelsInputSchema = object({
40338
+ addonId: string(),
40339
+ kind: LlmProfileKindSchema,
40340
+ profileId: string().optional(),
40341
+ connection: LlmProviderConfigSchema.optional()
40016
40342
  });
40343
+ var LlmListModelsErrorCodeSchema = _enum([
40344
+ "auth",
40345
+ "network",
40346
+ "unsupported",
40347
+ "invalid"
40348
+ ]);
40349
+ /** A RESULT, never a throw: "wrong key" is an answer the editor renders inline. */
40350
+ var LlmListModelsResultSchema = discriminatedUnion("ok", [object({
40351
+ ok: literal(true),
40352
+ models: array(LlmModelInfoSchema)
40353
+ }), object({
40354
+ ok: literal(false),
40355
+ code: LlmListModelsErrorCodeSchema,
40356
+ message: string()
40357
+ })]);
40017
40358
  var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
40018
40359
  var LlmDefaultSchema = object({
40019
40360
  selector: LlmDefaultSelectorSchema,
@@ -40113,7 +40454,10 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
40113
40454
  kind: "mutation",
40114
40455
  auth: "admin",
40115
40456
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
40116
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
40457
+ }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
40458
+ kind: "mutation",
40459
+ auth: "admin"
40460
+ }), method(object({}), array(LlmDefaultSchema)), method(object({
40117
40461
  selector: LlmDefaultSelectorSchema,
40118
40462
  profileId: string().nullable()
40119
40463
  }), _void(), {
@@ -44183,202 +44527,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
44183
44527
  auth: "admin"
44184
44528
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
44185
44529
  /**
44186
- * Zod schemas for persisted record types.
44187
- *
44188
- * These schemas serve as the single source of truth for types that are
44189
- * stored in the settings-store backend and retrieved via tRPC. They
44190
- * replace the manual TypeScript interfaces with schema-derived types,
44191
- * enabling runtime validation when reading from the backend.
44192
- *
44193
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
44194
- * keeps the original name for backward compatibility.
44195
- */
44196
- /**
44197
- * Auth model (v2 — 2026-05-12 caps-only):
44198
- *
44199
- * Two principals:
44200
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
44201
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
44202
- *
44203
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44204
- * `super_admin` — collapsed onto the single boolean because every
44205
- * non-admin caller is governed by the same scope-check rules; the
44206
- * distinction was only ever used to route role-specific procedures
44207
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44208
- * with `isAdmin: false` + an explicit scope list.
44209
- */
44210
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44211
- var MethodAccessSchema = _enum([
44212
- "view",
44213
- "create",
44214
- "delete"
44215
- ]);
44216
- /**
44217
- * A single scope grant. Three forms — checked in matcher with OR
44218
- * semantics; the first match decides whether the call passes:
44219
- *
44220
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44221
- * cap with the matching `scope` declaration. New caps inherit grants
44222
- * automatically — adding a device cap to the codebase makes it
44223
- * reachable to every user with `category:device [...]` without a
44224
- * re-grant. Use this for "family viewer" / "operator" tiers.
44225
- *
44226
- * - `addon` — every cap that ships inside a given addon id. Niche;
44227
- * useful when an integration needs to interact with one specific
44228
- * addon's surface regardless of how many caps it exports.
44229
- *
44230
- * - `capability` — the most precise form. Single cap name. Use for
44231
- * integration tokens where you want to grant `addons.installPackage`
44232
- * and nothing else.
44233
- *
44234
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44235
- * "give me everything" escape; there is no wildcard scope.
44236
- */
44237
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44238
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44239
- var CapScopeSchema = _enum(["device", "system"]);
44240
- /**
44241
- * DeviceSelector (scope model v3 — 2026-08-12).
44242
- *
44243
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44244
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44245
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44246
- * AFTER the grant was minted — no re-grant, no re-login.
44247
- *
44248
- * - `all` — every device in the deployment. The broad viewer/operator
44249
- * lever without a `category` grant (a `category` grant also covers device
44250
- * caps that carry no deviceId; `all` is specifically the device set).
44251
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44252
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44253
- * is NOT covered until the grant is edited.
44254
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44255
- * DYNAMIC. A device that changes type, or a new device of the type,
44256
- * re-resolves on the next request.
44257
- * - `locations` — every device whose operator-assigned `location` label is
44258
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44259
- * null/unset location matches NO `locations` selector.
44260
- */
44261
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44262
- object({ kind: literal("all") }),
44263
- object({
44264
- kind: literal("ids"),
44265
- ids: array(number().int()).min(1)
44266
- }),
44267
- object({
44268
- kind: literal("types"),
44269
- types: array(_enum(DeviceType)).min(1)
44270
- }),
44271
- object({
44272
- kind: literal("locations"),
44273
- locations: array(string().min(1)).min(1)
44274
- })
44275
- ]);
44276
- var DeviceTokenScopeSchema = object({
44277
- type: literal("device"),
44278
- /** The device SET this grant covers — resolved against the live fleet. */
44279
- selector: DeviceSelectorSchema,
44280
- access: array(MethodAccessSchema).min(1),
44281
- /**
44282
- * Whether a grant on a PARENT device transparently covers its accessory
44283
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44284
- * Direction is parent → children ONLY.
44285
- *
44286
- * Absent → the matcher DERIVES it from the access flavour: `view`
44287
- * inherits (a camera viewer sees the camera's accessories), `create` /
44288
- * `delete` do NOT (actuating/removing a child is an explicit act the
44289
- * operator must grant on the child, not inherit from the parent). Set it
44290
- * explicitly to override that default per grant.
44291
- */
44292
- includeLinked: boolean().optional()
44293
- });
44294
- /**
44295
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44296
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44297
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44298
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44299
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44300
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44301
- * migration cannot reach a JWT already in a client's hands; parse-time
44302
- * migration covers both without a flag day. No cast — the raw object is read
44303
- * through `Reflect.get` (its static type is `unknown`).
44304
- */
44305
- function migrateLegacyTokenScope(raw) {
44306
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44307
- if (Reflect.get(raw, "type") !== "device") return raw;
44308
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44309
- const targets = Reflect.get(raw, "targets");
44310
- if (!Array.isArray(targets)) return raw;
44311
- return {
44312
- type: "device",
44313
- selector: {
44314
- kind: "ids",
44315
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44316
- },
44317
- access: Reflect.get(raw, "access")
44318
- };
44319
- }
44320
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44321
- object({
44322
- type: literal("category"),
44323
- target: CapScopeSchema,
44324
- access: array(MethodAccessSchema).min(1)
44325
- }),
44326
- object({
44327
- type: literal("capability"),
44328
- target: string(),
44329
- access: array(MethodAccessSchema).min(1)
44330
- }),
44331
- object({
44332
- type: literal("addon"),
44333
- target: string(),
44334
- access: array(MethodAccessSchema).min(1)
44335
- }),
44336
- DeviceTokenScopeSchema
44337
- ]));
44338
- object({
44339
- id: string(),
44340
- username: string(),
44341
- passwordHash: string(),
44342
- /**
44343
- * Admin bypass. When true, the middleware skips the scope-access
44344
- * check entirely. There is no other axis of privilege; the legacy
44345
- * role enum collapsed onto this boolean in v2.
44346
- */
44347
- isAdmin: boolean().default(false),
44348
- allowedProviders: AllowedProviderSchema,
44349
- allowedDevices: AllowedDevicesSchema,
44350
- /**
44351
- * Scopes granted to this user. Admins bypass; their `scopes` is
44352
- * ignored. Non-admins without scopes are locked out of every
44353
- * protected call.
44354
- */
44355
- scopes: array(TokenScopeSchema).default([]),
44356
- createdAt: number(),
44357
- updatedAt: number()
44358
- });
44359
- object({
44360
- id: string(),
44361
- label: string(),
44362
- isAdmin: boolean().default(false),
44363
- allowedProviders: AllowedProviderSchema,
44364
- allowedDevices: AllowedDevicesSchema,
44365
- tokenHash: string(),
44366
- tokenPrefix: string(),
44367
- createdAt: number(),
44368
- lastUsedAt: number().optional()
44369
- });
44370
- object({
44371
- id: string(),
44372
- userId: string(),
44373
- name: string(),
44374
- tokenHash: string(),
44375
- tokenPrefix: string(),
44376
- scopes: array(TokenScopeSchema),
44377
- expiresAt: number().nullish(),
44378
- lastUsedAt: number().nullish(),
44379
- createdAt: number()
44380
- });
44381
- /**
44382
44530
  * `oauth-integration` — a collection cap by which an addon declares
44383
44531
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44384
44532
  * Each provider returns a static descriptor; the core enumerates them
@@ -61310,26 +61458,6 @@ var ApiKeySummarySchema = object({
61310
61458
  createdAt: number(),
61311
61459
  lastUsedAt: number().optional()
61312
61460
  });
61313
- var ScopedTokenSummarySchema = object({
61314
- id: string(),
61315
- userId: string(),
61316
- name: string(),
61317
- tokenPrefix: string(),
61318
- scopes: array(TokenScopeSchema),
61319
- expiresAt: number().nullish(),
61320
- lastUsedAt: number().nullish(),
61321
- createdAt: number()
61322
- });
61323
- var CreateScopedTokenInputSchema = object({
61324
- userId: string(),
61325
- name: string(),
61326
- scopes: array(TokenScopeSchema),
61327
- expiresAt: number().optional()
61328
- });
61329
- var CreateScopedTokenResultSchema = object({
61330
- token: string(),
61331
- record: ScopedTokenSummarySchema
61332
- });
61333
61461
  var OauthSessionSummarySchema = object({
61334
61462
  id: string(),
61335
61463
  userId: string(),
@@ -61351,11 +61479,11 @@ var TotpStatusSchema = object({
61351
61479
  confirmedAt: number().nullable()
61352
61480
  });
61353
61481
  /**
61354
- * user-management — singleton capability for user accounts, API keys,
61355
- * and scoped tokens.
61482
+ * user-management — singleton capability for user accounts and the
61483
+ * legacy API-key rows.
61356
61484
  *
61357
61485
  * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
61358
- * — the subset check on `setUserScopes` / `createScopedToken` is moot
61486
+ * — the subset check on `setUserScopes` is moot
61359
61487
  * because non-admins never reach these. If/when we open non-admin
61360
61488
  * delegation, structural caller-scope subset check goes inside the
61361
61489
  * provider.
@@ -61412,15 +61540,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
61412
61540
  kind: "mutation",
61413
61541
  auth: "admin",
61414
61542
  access: "delete"
61415
- }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
61416
- kind: "mutation",
61417
- auth: "admin",
61418
- access: "create"
61419
- }), method(object({ id: string() }), object({ success: literal(true) }), {
61420
- kind: "mutation",
61421
- auth: "admin",
61422
- access: "delete"
61423
- }), method(object({ token: string() }), ScopedTokenSummarySchema.nullable(), { access: "view" }), method(object({ userId: string() }), array(ScopedTokenSummarySchema), { auth: "admin" }), method(object({ userId: string() }), TotpSetupResultSchema, {
61543
+ }), method(object({ userId: string() }), TotpSetupResultSchema, {
61424
61544
  kind: "mutation",
61425
61545
  auth: "admin",
61426
61546
  access: "create"
@@ -65674,7 +65794,7 @@ Object.freeze({
65674
65794
  capName: "llm",
65675
65795
  capScope: "system",
65676
65796
  addonId: null,
65677
- access: "view"
65797
+ access: "create"
65678
65798
  },
65679
65799
  "llm.listNodeModels": {
65680
65800
  capName: "llm",
@@ -70338,12 +70458,6 @@ Object.freeze({
70338
70458
  addonId: null,
70339
70459
  access: "create"
70340
70460
  },
70341
- "userManagement.createScopedToken": {
70342
- capName: "user-management",
70343
- capScope: "system",
70344
- addonId: null,
70345
- access: "create"
70346
- },
70347
70461
  "userManagement.createUser": {
70348
70462
  capName: "user-management",
70349
70463
  capScope: "system",
@@ -70392,12 +70506,6 @@ Object.freeze({
70392
70506
  addonId: null,
70393
70507
  access: "view"
70394
70508
  },
70395
- "userManagement.listScopedTokens": {
70396
- capName: "user-management",
70397
- capScope: "system",
70398
- addonId: null,
70399
- access: "view"
70400
- },
70401
70509
  "userManagement.listUsers": {
70402
70510
  capName: "user-management",
70403
70511
  capScope: "system",
@@ -70452,12 +70560,6 @@ Object.freeze({
70452
70560
  addonId: null,
70453
70561
  access: "delete"
70454
70562
  },
70455
- "userManagement.revokeScopedToken": {
70456
- capName: "user-management",
70457
- capScope: "system",
70458
- addonId: null,
70459
- access: "delete"
70460
- },
70461
70563
  "userManagement.setupTotp": {
70462
70564
  capName: "user-management",
70463
70565
  capScope: "system",
@@ -70488,12 +70590,6 @@ Object.freeze({
70488
70590
  addonId: null,
70489
70591
  access: "view"
70490
70592
  },
70491
- "userManagement.validateScopedToken": {
70492
- capName: "user-management",
70493
- capScope: "system",
70494
- addonId: null,
70495
- access: "view"
70496
- },
70497
70593
  "userManagement.verifyTotp": {
70498
70594
  capName: "user-management",
70499
70595
  capScope: "system",