@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
@@ -5783,7 +5783,7 @@ var ZodIssueCode = {
5783
5783
  var ZodFirstPartyTypeKind;
5784
5784
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5785
5785
  //#endregion
5786
- //#region ../types/dist/sleep-BxjU_fJM.mjs
5786
+ //#region ../types/dist/sleep-yKL5gfrH.mjs
5787
5787
  /**
5788
5788
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5789
5789
  * window to float samples (D455).
@@ -8165,6 +8165,12 @@ function normalizeAddonInitResult(result) {
8165
8165
  if (Array.isArray(result)) return { providers: result };
8166
8166
  return result;
8167
8167
  }
8168
+ /**
8169
+ * The share-view scope kinds a share-link token can carry. The hub mints
8170
+ * and validates them (`ShareViewGrantSchema` builds its
8171
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
8172
+ */
8173
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
8168
8174
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
8169
8175
  var PeerBytesTicketSchema = object({
8170
8176
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12969,6 +12975,280 @@ var ConvertResultSchema = object({
12969
12975
  entry: ModelCatalogEntrySchema,
12970
12976
  artifacts: array(ConvertArtifactSchema).readonly()
12971
12977
  });
12978
+ /**
12979
+ * Zod schemas for persisted record types.
12980
+ *
12981
+ * These schemas serve as the single source of truth for types that are
12982
+ * stored in the settings-store backend and retrieved via tRPC. They
12983
+ * replace the manual TypeScript interfaces with schema-derived types,
12984
+ * enabling runtime validation when reading from the backend.
12985
+ *
12986
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12987
+ * keeps the original name for backward compatibility.
12988
+ */
12989
+ /**
12990
+ * Auth model (v2 — 2026-05-12 caps-only):
12991
+ *
12992
+ * Two principals:
12993
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12994
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12995
+ *
12996
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12997
+ * `super_admin` — collapsed onto the single boolean because every
12998
+ * non-admin caller is governed by the same scope-check rules; the
12999
+ * distinction was only ever used to route role-specific procedures
13000
+ * which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
13001
+ * with `isAdmin: false` + an explicit scope list.
13002
+ */
13003
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
13004
+ var MethodAccessSchema = _enum([
13005
+ "view",
13006
+ "create",
13007
+ "delete"
13008
+ ]);
13009
+ /**
13010
+ * A single scope grant. Three forms — checked in matcher with OR
13011
+ * semantics; the first match decides whether the call passes:
13012
+ *
13013
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
13014
+ * cap with the matching `scope` declaration. New caps inherit grants
13015
+ * automatically — adding a device cap to the codebase makes it
13016
+ * reachable to every user with `category:device [...]` without a
13017
+ * re-grant. Use this for "family viewer" / "operator" tiers.
13018
+ *
13019
+ * - `addon` — every cap that ships inside a given addon id. Niche;
13020
+ * useful when an integration needs to interact with one specific
13021
+ * addon's surface regardless of how many caps it exports.
13022
+ *
13023
+ * - `capability` — the most precise form. Single cap name. Use for
13024
+ * integration tokens where you want to grant `addons.installPackage`
13025
+ * and nothing else.
13026
+ *
13027
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
13028
+ * "give me everything" escape; there is no wildcard scope.
13029
+ */
13030
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
13031
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
13032
+ var CapScopeSchema = _enum(["device", "system"]);
13033
+ /**
13034
+ * DeviceSelector (scope model v3 — 2026-08-12).
13035
+ *
13036
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
13037
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
13038
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
13039
+ * AFTER the grant was minted — no re-grant, no re-login.
13040
+ *
13041
+ * - `all` — every device in the deployment. The broad viewer/operator
13042
+ * lever without a `category` grant (a `category` grant also covers device
13043
+ * caps that carry no deviceId; `all` is specifically the device set).
13044
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
13045
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
13046
+ * is NOT covered until the grant is edited.
13047
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
13048
+ * DYNAMIC. A device that changes type, or a new device of the type,
13049
+ * re-resolves on the next request.
13050
+ * - `locations` — every device whose operator-assigned `location` label is
13051
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
13052
+ * null/unset location matches NO `locations` selector.
13053
+ */
13054
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
13055
+ object({ kind: literal("all") }),
13056
+ object({
13057
+ kind: literal("ids"),
13058
+ ids: array(number().int()).min(1)
13059
+ }),
13060
+ object({
13061
+ kind: literal("types"),
13062
+ types: array(_enum(DeviceType)).min(1)
13063
+ }),
13064
+ object({
13065
+ kind: literal("locations"),
13066
+ locations: array(string().min(1)).min(1)
13067
+ })
13068
+ ]);
13069
+ var DeviceTokenScopeSchema = object({
13070
+ type: literal("device"),
13071
+ /** The device SET this grant covers — resolved against the live fleet. */
13072
+ selector: DeviceSelectorSchema,
13073
+ access: array(MethodAccessSchema).min(1),
13074
+ /**
13075
+ * Whether a grant on a PARENT device transparently covers its accessory
13076
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
13077
+ * Direction is parent → children ONLY.
13078
+ *
13079
+ * Absent → the matcher DERIVES it from the access flavour: `view`
13080
+ * inherits (a camera viewer sees the camera's accessories), `create` /
13081
+ * `delete` do NOT (actuating/removing a child is an explicit act the
13082
+ * operator must grant on the child, not inherit from the parent). Set it
13083
+ * explicitly to override that default per grant.
13084
+ */
13085
+ includeLinked: boolean().optional()
13086
+ });
13087
+ /**
13088
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
13089
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
13090
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
13091
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
13092
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
13093
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
13094
+ * migration cannot reach a JWT already in a client's hands; parse-time
13095
+ * migration covers both without a flag day. No cast — the raw object is read
13096
+ * through `Reflect.get` (its static type is `unknown`).
13097
+ */
13098
+ function migrateLegacyTokenScope(raw) {
13099
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
13100
+ if (Reflect.get(raw, "type") !== "device") return raw;
13101
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
13102
+ const targets = Reflect.get(raw, "targets");
13103
+ if (!Array.isArray(targets)) return raw;
13104
+ return {
13105
+ type: "device",
13106
+ selector: {
13107
+ kind: "ids",
13108
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
13109
+ },
13110
+ access: Reflect.get(raw, "access")
13111
+ };
13112
+ }
13113
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
13114
+ object({
13115
+ type: literal("category"),
13116
+ target: CapScopeSchema,
13117
+ access: array(MethodAccessSchema).min(1)
13118
+ }),
13119
+ object({
13120
+ type: literal("capability"),
13121
+ target: string(),
13122
+ access: array(MethodAccessSchema).min(1)
13123
+ }),
13124
+ object({
13125
+ type: literal("addon"),
13126
+ target: string(),
13127
+ access: array(MethodAccessSchema).min(1)
13128
+ }),
13129
+ DeviceTokenScopeSchema
13130
+ ]));
13131
+ object({
13132
+ id: string(),
13133
+ username: string(),
13134
+ passwordHash: string(),
13135
+ /**
13136
+ * Admin bypass. When true, the middleware skips the scope-access
13137
+ * check entirely. There is no other axis of privilege; the legacy
13138
+ * role enum collapsed onto this boolean in v2.
13139
+ */
13140
+ isAdmin: boolean().default(false),
13141
+ allowedProviders: AllowedProviderSchema,
13142
+ allowedDevices: AllowedDevicesSchema,
13143
+ /**
13144
+ * Scopes granted to this user. Admins bypass; their `scopes` is
13145
+ * ignored. Non-admins without scopes are locked out of every
13146
+ * protected call.
13147
+ */
13148
+ scopes: array(TokenScopeSchema).default([]),
13149
+ createdAt: number(),
13150
+ updatedAt: number()
13151
+ });
13152
+ object({
13153
+ id: string(),
13154
+ label: string(),
13155
+ isAdmin: boolean().default(false),
13156
+ allowedProviders: AllowedProviderSchema,
13157
+ allowedDevices: AllowedDevicesSchema,
13158
+ tokenHash: string(),
13159
+ tokenPrefix: string(),
13160
+ createdAt: number(),
13161
+ lastUsedAt: number().optional()
13162
+ });
13163
+ object({
13164
+ id: string(),
13165
+ userId: string(),
13166
+ name: string(),
13167
+ tokenHash: string(),
13168
+ tokenPrefix: string(),
13169
+ scopes: array(TokenScopeSchema),
13170
+ expiresAt: number().nullish(),
13171
+ lastUsedAt: number().nullish(),
13172
+ createdAt: number()
13173
+ });
13174
+ /** What a share-view grant lets its holder see. */
13175
+ var ShareViewGrantSchema = object({
13176
+ kind: _enum(SHARE_VIEW_KINDS),
13177
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
13178
+ /** Talk-back, opt-in at mint time; absent means off. */
13179
+ talk: boolean().optional()
13180
+ });
13181
+ var ShareViewScopeSchema = object({
13182
+ type: literal("share-view"),
13183
+ grant: ShareViewGrantSchema
13184
+ });
13185
+ var AddonRoutesScopeSchema = object({
13186
+ type: literal("addon-routes"),
13187
+ access: array(MethodAccessSchema).min(1)
13188
+ });
13189
+ var PreferencesSelfScopeSchema = object({ type: literal("preferences-self") });
13190
+ var CredentialScopeSchema = union([
13191
+ literal("*"),
13192
+ ShareViewScopeSchema,
13193
+ AddonRoutesScopeSchema,
13194
+ PreferencesSelfScopeSchema,
13195
+ TokenScopeSchema
13196
+ ]);
13197
+ object({
13198
+ kind: literal("credential"),
13199
+ sub: string().min(1),
13200
+ jti: string().min(16),
13201
+ scopes: array(CredentialScopeSchema).min(1)
13202
+ });
13203
+ var PreferenceNamespaceSchema = string().regex(/^[a-z][a-z0-9.-]{0,63}$/);
13204
+ /** A namespace's value: a JSON object, opaque to the hub. */
13205
+ var PreferenceValueSchema = record(string(), unknown());
13206
+ var PreferenceDeviceIdSchema = string().min(1).max(64);
13207
+ /** A stored row, as the owner reads it. */
13208
+ var PreferenceRowSchema = object({
13209
+ namespace: PreferenceNamespaceSchema,
13210
+ value: PreferenceValueSchema,
13211
+ /** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
13212
+ revision: number().int().positive(),
13213
+ updatedAt: number().int(),
13214
+ /** The client id the last writer sent; `null` when it sent none. */
13215
+ updatedByDevice: PreferenceDeviceIdSchema.nullable()
13216
+ });
13217
+ object({
13218
+ /** Absent: every namespace the caller holds. */
13219
+ namespaces: array(PreferenceNamespaceSchema).max(32).optional() });
13220
+ object({ rows: array(PreferenceRowSchema) });
13221
+ object({
13222
+ namespace: PreferenceNamespaceSchema,
13223
+ value: PreferenceValueSchema,
13224
+ /**
13225
+ * The revision the edit was based on. Absent: last write wins. `0`: the
13226
+ * namespace must not exist yet. Any other value that is not the current
13227
+ * revision answers `conflict` and writes nothing.
13228
+ */
13229
+ baseRevision: number().int().nonnegative().optional(),
13230
+ deviceId: PreferenceDeviceIdSchema.optional()
13231
+ });
13232
+ discriminatedUnion("status", [object({
13233
+ status: literal("saved"),
13234
+ row: PreferenceRowSchema
13235
+ }), object({
13236
+ status: literal("conflict"),
13237
+ current: PreferenceRowSchema.nullable()
13238
+ })]);
13239
+ object({ namespace: PreferenceNamespaceSchema });
13240
+ object({
13241
+ /** `false` when the namespace did not exist. */
13242
+ deleted: boolean() });
13243
+ object({
13244
+ /** The revision the client holds per namespace; a namespace it does not list is new to it. */
13245
+ revisionByNamespace: record(PreferenceNamespaceSchema, number().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
13246
+ object({
13247
+ /** Every row whose revision differs from the client's, and every row it did not list. */
13248
+ rows: array(PreferenceRowSchema),
13249
+ /** Namespaces the client listed that no longer exist. */
13250
+ deleted: array(PreferenceNamespaceSchema)
13251
+ });
12972
13252
  _enum(["new-session", "step-up"]);
12973
13253
  /** The languages the hub's app landing pages are written in (D858). */
12974
13254
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -39892,38 +40172,37 @@ method(LlmRuntimeCompleteInputSchema, LlmGenerateResultSchema, {
39892
40172
  auth: "admin",
39893
40173
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39894
40174
  });
40175
+ var LlmProfileKindSchema = string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "a kind id is lower-case letters, digits and dashes");
40176
+ /** What a model (or, by default, every model of a kind) can do. */
40177
+ var LlmModelFeaturesSchema = object({
40178
+ vision: boolean(),
40179
+ tools: boolean(),
40180
+ streaming: boolean()
40181
+ });
40182
+ /** One model a provider offers. `features` overrides the kind's defaults, per field. */
40183
+ var LlmModelInfoSchema = object({
40184
+ id: string(),
40185
+ label: string().optional(),
40186
+ contextLength: number().int().positive().optional(),
40187
+ features: LlmModelFeaturesSchema.partial().optional()
40188
+ });
39895
40189
  /**
39896
- * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
39897
- * methods concat-fan across providers; single-row methods route to ONE
39898
- * provider by the `addonId` in the call input (the notification-output
39899
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
39900
- * (hub-placed); the cap stays open for future providers.
39901
- *
39902
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
39903
- * `apiKey` is a password field — providers REDACT it on read and merge on
39904
- * write; a stored key NEVER round-trips to a client.
40190
+ * The provider-specific part of a profile, validated by the provider that owns
40191
+ * the kind (`upsertProfile` refuses what it does not accept). A field its
40192
+ * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
40193
+ * keychain, never in the row, and reads back as the redaction marker.
39905
40194
  */
39906
- var LlmProfileKindSchema = _enum([
39907
- "openai-compatible",
39908
- "openai",
39909
- "anthropic",
39910
- "google",
39911
- "managed-local",
39912
- "apple-foundation"
39913
- ]);
40195
+ var LlmProviderConfigSchema = record(string(), unknown());
39914
40196
  var LlmProfileSchema = object({
39915
40197
  id: string(),
39916
40198
  name: string(),
40199
+ /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
39917
40200
  kind: LlmProfileKindSchema,
39918
40201
  /** Stamped by the provider — keeps the fanned catalog routable. */
39919
40202
  addonId: string(),
39920
40203
  enabled: boolean(),
39921
40204
  /** Vendor model id, or the managed runtime's loaded model. */
39922
40205
  model: string(),
39923
- /** Required for openai-compatible; override for cloud kinds. */
39924
- baseUrl: string().optional(),
39925
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
39926
- apiKey: string().optional(),
39927
40206
  /** Vision on/off. A vision call against a `false` profile is REFUSED, never
39928
40207
  * degraded to text — that shipped once and produced a confident answer to a
39929
40208
  * question about a picture nobody sent. */
@@ -39931,15 +40210,11 @@ var LlmProfileSchema = object({
39931
40210
  temperature: number().min(0).max(2).optional(),
39932
40211
  /** Nucleus sampling. Every wire we speak has it. */
39933
40212
  topP: number().min(0).max(1).optional(),
39934
- /** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
39935
- * wire does, and the client drops it there (measured: the request body gets
39936
- * `top_p` and no `top_k`). The profile editor hides the field wherever it
39937
- * would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
40213
+ /** Top-k sampling. Carried only by the wires that have it — a kind offers the
40214
+ * field in its editor only when its descriptor lists it in `profileFields`. */
39938
40215
  topK: number().int().positive().optional(),
39939
40216
  maxTokens: number().int().positive().optional(),
39940
- /** Prompt context window. Advisory for cloud kinds (they enforce their own);
39941
- * for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
39942
- * the model with, so it is the one field that changes a PROCESS. */
40217
+ /** Prompt context window. Advisory for cloud kinds (they enforce their own). */
39943
40218
  contextLength: number().int().positive().optional(),
39944
40219
  /** Default system prompt. A caller's `system` REPLACES it (never appends —
39945
40220
  * two system prompts fighting is worse than either alone). */
@@ -39965,16 +40240,37 @@ var LlmProfileSchema = object({
39965
40240
  * library; the REGISTRY of callable tools is ours and is empty in v1, so a
39966
40241
  * `true` here buys the wiring, not behaviour, until tools are registered. */
39967
40242
  toolsEnabled: boolean().default(false),
39968
- extraHeaders: record(string(), string()).optional(),
39969
- /** kind === 'managed-local' only (spec §4). */
39970
- runtime: ManagedRuntimeConfigSchema.optional(),
39971
- /**
39972
- * kind === 'apple-foundation' only: WHERE it runs — the only thing there is
39973
- * to configure (no key, no URL, no download; `model` is `apple-system`).
39974
- * `supportsVision` on such a row is stamped by the provider from the node's
39975
- * reported `imageInput`, never taken from the operator (D62).
39976
- */
39977
- appleFoundation: object({ nodeId: string() }).optional()
40243
+ /** Everything the kind's provider owns (endpoint, key, node, runtime…). */
40244
+ providerConfig: LlmProviderConfigSchema.default({})
40245
+ });
40246
+ /**
40247
+ * The common profile fields a kind's editor offers. The editor owns how each
40248
+ * one is drawn; the provider says which of them mean something on its wire.
40249
+ */
40250
+ var LlmProfileFieldSchema = _enum([
40251
+ "temperature",
40252
+ "topP",
40253
+ "topK",
40254
+ "maxTokens",
40255
+ "contextLength",
40256
+ "systemPrompt",
40257
+ "timeoutMs",
40258
+ "connectTimeoutMs",
40259
+ "firstTokenTimeoutMs",
40260
+ "idleTimeoutMs",
40261
+ "retry",
40262
+ "toolsEnabled"
40263
+ ]);
40264
+ /**
40265
+ * A provider-drawn part of the editor, by a generic widget id the admin UI
40266
+ * registers (`ai/apple-node`). `placement: 'model'` replaces the generic model
40267
+ * picker: that widget owns the model choice.
40268
+ */
40269
+ var LlmProviderWidgetSchema = object({
40270
+ id: string(),
40271
+ placement: _enum(["connection", "model"]),
40272
+ /** `providerConfig` keys this widget must fill before the profile can be saved. */
40273
+ requires: array(string()).optional()
39978
40274
  });
39979
40275
  /** ConfigUISchema tree passed through untyped on the wire (the
39980
40276
  * notification-output `ConfigSchemaPassthrough` precedent at
@@ -39983,11 +40279,56 @@ var ConfigSchemaPassthrough$3 = unknown();
39983
40279
  var LlmProfileKindDescriptorSchema = object({
39984
40280
  kind: LlmProfileKindSchema,
39985
40281
  label: string(),
40282
+ /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
39986
40283
  icon: string(),
39987
40284
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
39988
40285
  addonId: string(),
39989
- configSchema: ConfigSchemaPassthrough$3
40286
+ /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
40287
+ connectionSchema: ConfigSchemaPassthrough$3,
40288
+ /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
40289
+ advancedSchema: ConfigSchemaPassthrough$3.optional(),
40290
+ /** The kind's defaults; a model from `listModels` may override any of them. */
40291
+ features: LlmModelFeaturesSchema,
40292
+ /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
40293
+ visionEditable: boolean(),
40294
+ /** Where the model list comes from: `listModels`, `staticModels`, or nowhere. */
40295
+ modelCatalog: _enum([
40296
+ "fetch",
40297
+ "static",
40298
+ "none"
40299
+ ]),
40300
+ staticModels: array(LlmModelInfoSchema).optional(),
40301
+ /** The common fields that mean something on this kind's wire. */
40302
+ profileFields: array(LlmProfileFieldSchema),
40303
+ providerWidgets: array(LlmProviderWidgetSchema).optional()
40304
+ });
40305
+ /**
40306
+ * `listModels` input. `connection` is an UNSAVED draft of `providerConfig`
40307
+ * (the editor's form); with `profileId` too, a secret the draft leaves
40308
+ * untouched (absent or the redaction marker) is resolved server-side from the
40309
+ * stored profile — the browser never receives it.
40310
+ */
40311
+ var LlmListModelsInputSchema = object({
40312
+ addonId: string(),
40313
+ kind: LlmProfileKindSchema,
40314
+ profileId: string().optional(),
40315
+ connection: LlmProviderConfigSchema.optional()
39990
40316
  });
40317
+ var LlmListModelsErrorCodeSchema = _enum([
40318
+ "auth",
40319
+ "network",
40320
+ "unsupported",
40321
+ "invalid"
40322
+ ]);
40323
+ /** A RESULT, never a throw: "wrong key" is an answer the editor renders inline. */
40324
+ var LlmListModelsResultSchema = discriminatedUnion("ok", [object({
40325
+ ok: literal(true),
40326
+ models: array(LlmModelInfoSchema)
40327
+ }), object({
40328
+ ok: literal(false),
40329
+ code: LlmListModelsErrorCodeSchema,
40330
+ message: string()
40331
+ })]);
39991
40332
  var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
39992
40333
  var LlmDefaultSchema = object({
39993
40334
  selector: LlmDefaultSelectorSchema,
@@ -40087,7 +40428,10 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
40087
40428
  kind: "mutation",
40088
40429
  auth: "admin",
40089
40430
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
40090
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
40431
+ }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
40432
+ kind: "mutation",
40433
+ auth: "admin"
40434
+ }), method(object({}), array(LlmDefaultSchema)), method(object({
40091
40435
  selector: LlmDefaultSelectorSchema,
40092
40436
  profileId: string().nullable()
40093
40437
  }), _void(), {
@@ -44157,202 +44501,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
44157
44501
  auth: "admin"
44158
44502
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
44159
44503
  /**
44160
- * Zod schemas for persisted record types.
44161
- *
44162
- * These schemas serve as the single source of truth for types that are
44163
- * stored in the settings-store backend and retrieved via tRPC. They
44164
- * replace the manual TypeScript interfaces with schema-derived types,
44165
- * enabling runtime validation when reading from the backend.
44166
- *
44167
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
44168
- * keeps the original name for backward compatibility.
44169
- */
44170
- /**
44171
- * Auth model (v2 — 2026-05-12 caps-only):
44172
- *
44173
- * Two principals:
44174
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
44175
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
44176
- *
44177
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44178
- * `super_admin` — collapsed onto the single boolean because every
44179
- * non-admin caller is governed by the same scope-check rules; the
44180
- * distinction was only ever used to route role-specific procedures
44181
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44182
- * with `isAdmin: false` + an explicit scope list.
44183
- */
44184
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44185
- var MethodAccessSchema = _enum([
44186
- "view",
44187
- "create",
44188
- "delete"
44189
- ]);
44190
- /**
44191
- * A single scope grant. Three forms — checked in matcher with OR
44192
- * semantics; the first match decides whether the call passes:
44193
- *
44194
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44195
- * cap with the matching `scope` declaration. New caps inherit grants
44196
- * automatically — adding a device cap to the codebase makes it
44197
- * reachable to every user with `category:device [...]` without a
44198
- * re-grant. Use this for "family viewer" / "operator" tiers.
44199
- *
44200
- * - `addon` — every cap that ships inside a given addon id. Niche;
44201
- * useful when an integration needs to interact with one specific
44202
- * addon's surface regardless of how many caps it exports.
44203
- *
44204
- * - `capability` — the most precise form. Single cap name. Use for
44205
- * integration tokens where you want to grant `addons.installPackage`
44206
- * and nothing else.
44207
- *
44208
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44209
- * "give me everything" escape; there is no wildcard scope.
44210
- */
44211
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44212
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44213
- var CapScopeSchema = _enum(["device", "system"]);
44214
- /**
44215
- * DeviceSelector (scope model v3 — 2026-08-12).
44216
- *
44217
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44218
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44219
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44220
- * AFTER the grant was minted — no re-grant, no re-login.
44221
- *
44222
- * - `all` — every device in the deployment. The broad viewer/operator
44223
- * lever without a `category` grant (a `category` grant also covers device
44224
- * caps that carry no deviceId; `all` is specifically the device set).
44225
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44226
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44227
- * is NOT covered until the grant is edited.
44228
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44229
- * DYNAMIC. A device that changes type, or a new device of the type,
44230
- * re-resolves on the next request.
44231
- * - `locations` — every device whose operator-assigned `location` label is
44232
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44233
- * null/unset location matches NO `locations` selector.
44234
- */
44235
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44236
- object({ kind: literal("all") }),
44237
- object({
44238
- kind: literal("ids"),
44239
- ids: array(number().int()).min(1)
44240
- }),
44241
- object({
44242
- kind: literal("types"),
44243
- types: array(_enum(DeviceType)).min(1)
44244
- }),
44245
- object({
44246
- kind: literal("locations"),
44247
- locations: array(string().min(1)).min(1)
44248
- })
44249
- ]);
44250
- var DeviceTokenScopeSchema = object({
44251
- type: literal("device"),
44252
- /** The device SET this grant covers — resolved against the live fleet. */
44253
- selector: DeviceSelectorSchema,
44254
- access: array(MethodAccessSchema).min(1),
44255
- /**
44256
- * Whether a grant on a PARENT device transparently covers its accessory
44257
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44258
- * Direction is parent → children ONLY.
44259
- *
44260
- * Absent → the matcher DERIVES it from the access flavour: `view`
44261
- * inherits (a camera viewer sees the camera's accessories), `create` /
44262
- * `delete` do NOT (actuating/removing a child is an explicit act the
44263
- * operator must grant on the child, not inherit from the parent). Set it
44264
- * explicitly to override that default per grant.
44265
- */
44266
- includeLinked: boolean().optional()
44267
- });
44268
- /**
44269
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44270
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44271
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44272
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44273
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44274
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44275
- * migration cannot reach a JWT already in a client's hands; parse-time
44276
- * migration covers both without a flag day. No cast — the raw object is read
44277
- * through `Reflect.get` (its static type is `unknown`).
44278
- */
44279
- function migrateLegacyTokenScope(raw) {
44280
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44281
- if (Reflect.get(raw, "type") !== "device") return raw;
44282
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44283
- const targets = Reflect.get(raw, "targets");
44284
- if (!Array.isArray(targets)) return raw;
44285
- return {
44286
- type: "device",
44287
- selector: {
44288
- kind: "ids",
44289
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44290
- },
44291
- access: Reflect.get(raw, "access")
44292
- };
44293
- }
44294
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44295
- object({
44296
- type: literal("category"),
44297
- target: CapScopeSchema,
44298
- access: array(MethodAccessSchema).min(1)
44299
- }),
44300
- object({
44301
- type: literal("capability"),
44302
- target: string(),
44303
- access: array(MethodAccessSchema).min(1)
44304
- }),
44305
- object({
44306
- type: literal("addon"),
44307
- target: string(),
44308
- access: array(MethodAccessSchema).min(1)
44309
- }),
44310
- DeviceTokenScopeSchema
44311
- ]));
44312
- object({
44313
- id: string(),
44314
- username: string(),
44315
- passwordHash: string(),
44316
- /**
44317
- * Admin bypass. When true, the middleware skips the scope-access
44318
- * check entirely. There is no other axis of privilege; the legacy
44319
- * role enum collapsed onto this boolean in v2.
44320
- */
44321
- isAdmin: boolean().default(false),
44322
- allowedProviders: AllowedProviderSchema,
44323
- allowedDevices: AllowedDevicesSchema,
44324
- /**
44325
- * Scopes granted to this user. Admins bypass; their `scopes` is
44326
- * ignored. Non-admins without scopes are locked out of every
44327
- * protected call.
44328
- */
44329
- scopes: array(TokenScopeSchema).default([]),
44330
- createdAt: number(),
44331
- updatedAt: number()
44332
- });
44333
- object({
44334
- id: string(),
44335
- label: string(),
44336
- isAdmin: boolean().default(false),
44337
- allowedProviders: AllowedProviderSchema,
44338
- allowedDevices: AllowedDevicesSchema,
44339
- tokenHash: string(),
44340
- tokenPrefix: string(),
44341
- createdAt: number(),
44342
- lastUsedAt: number().optional()
44343
- });
44344
- object({
44345
- id: string(),
44346
- userId: string(),
44347
- name: string(),
44348
- tokenHash: string(),
44349
- tokenPrefix: string(),
44350
- scopes: array(TokenScopeSchema),
44351
- expiresAt: number().nullish(),
44352
- lastUsedAt: number().nullish(),
44353
- createdAt: number()
44354
- });
44355
- /**
44356
44504
  * `oauth-integration` — a collection cap by which an addon declares
44357
44505
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44358
44506
  * Each provider returns a static descriptor; the core enumerates them
@@ -61284,26 +61432,6 @@ var ApiKeySummarySchema = object({
61284
61432
  createdAt: number(),
61285
61433
  lastUsedAt: number().optional()
61286
61434
  });
61287
- var ScopedTokenSummarySchema = object({
61288
- id: string(),
61289
- userId: string(),
61290
- name: string(),
61291
- tokenPrefix: string(),
61292
- scopes: array(TokenScopeSchema),
61293
- expiresAt: number().nullish(),
61294
- lastUsedAt: number().nullish(),
61295
- createdAt: number()
61296
- });
61297
- var CreateScopedTokenInputSchema = object({
61298
- userId: string(),
61299
- name: string(),
61300
- scopes: array(TokenScopeSchema),
61301
- expiresAt: number().optional()
61302
- });
61303
- var CreateScopedTokenResultSchema = object({
61304
- token: string(),
61305
- record: ScopedTokenSummarySchema
61306
- });
61307
61435
  var OauthSessionSummarySchema = object({
61308
61436
  id: string(),
61309
61437
  userId: string(),
@@ -61325,11 +61453,11 @@ var TotpStatusSchema = object({
61325
61453
  confirmedAt: number().nullable()
61326
61454
  });
61327
61455
  /**
61328
- * user-management — singleton capability for user accounts, API keys,
61329
- * and scoped tokens.
61456
+ * user-management — singleton capability for user accounts and the
61457
+ * legacy API-key rows.
61330
61458
  *
61331
61459
  * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
61332
- * — the subset check on `setUserScopes` / `createScopedToken` is moot
61460
+ * — the subset check on `setUserScopes` is moot
61333
61461
  * because non-admins never reach these. If/when we open non-admin
61334
61462
  * delegation, structural caller-scope subset check goes inside the
61335
61463
  * provider.
@@ -61386,15 +61514,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
61386
61514
  kind: "mutation",
61387
61515
  auth: "admin",
61388
61516
  access: "delete"
61389
- }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
61390
- kind: "mutation",
61391
- auth: "admin",
61392
- access: "create"
61393
- }), method(object({ id: string() }), object({ success: literal(true) }), {
61394
- kind: "mutation",
61395
- auth: "admin",
61396
- access: "delete"
61397
- }), method(object({ token: string() }), ScopedTokenSummarySchema.nullable(), { access: "view" }), method(object({ userId: string() }), array(ScopedTokenSummarySchema), { auth: "admin" }), method(object({ userId: string() }), TotpSetupResultSchema, {
61517
+ }), method(object({ userId: string() }), TotpSetupResultSchema, {
61398
61518
  kind: "mutation",
61399
61519
  auth: "admin",
61400
61520
  access: "create"
@@ -65648,7 +65768,7 @@ Object.freeze({
65648
65768
  capName: "llm",
65649
65769
  capScope: "system",
65650
65770
  addonId: null,
65651
- access: "view"
65771
+ access: "create"
65652
65772
  },
65653
65773
  "llm.listNodeModels": {
65654
65774
  capName: "llm",
@@ -70312,12 +70432,6 @@ Object.freeze({
70312
70432
  addonId: null,
70313
70433
  access: "create"
70314
70434
  },
70315
- "userManagement.createScopedToken": {
70316
- capName: "user-management",
70317
- capScope: "system",
70318
- addonId: null,
70319
- access: "create"
70320
- },
70321
70435
  "userManagement.createUser": {
70322
70436
  capName: "user-management",
70323
70437
  capScope: "system",
@@ -70366,12 +70480,6 @@ Object.freeze({
70366
70480
  addonId: null,
70367
70481
  access: "view"
70368
70482
  },
70369
- "userManagement.listScopedTokens": {
70370
- capName: "user-management",
70371
- capScope: "system",
70372
- addonId: null,
70373
- access: "view"
70374
- },
70375
70483
  "userManagement.listUsers": {
70376
70484
  capName: "user-management",
70377
70485
  capScope: "system",
@@ -70426,12 +70534,6 @@ Object.freeze({
70426
70534
  addonId: null,
70427
70535
  access: "delete"
70428
70536
  },
70429
- "userManagement.revokeScopedToken": {
70430
- capName: "user-management",
70431
- capScope: "system",
70432
- addonId: null,
70433
- access: "delete"
70434
- },
70435
70537
  "userManagement.setupTotp": {
70436
70538
  capName: "user-management",
70437
70539
  capScope: "system",
@@ -70462,12 +70564,6 @@ Object.freeze({
70462
70564
  addonId: null,
70463
70565
  access: "view"
70464
70566
  },
70465
- "userManagement.validateScopedToken": {
70466
- capName: "user-management",
70467
- capScope: "system",
70468
- addonId: null,
70469
- access: "view"
70470
- },
70471
70567
  "userManagement.verifyTotp": {
70472
70568
  capName: "user-management",
70473
70569
  capScope: "system",