@camstack/addon-training 0.1.59 → 0.1.61

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 (20) hide show
  1. package/dist/{MotionZonesSettings-D3MA168j.mjs → MotionZonesSettings-DSFRn3u7.mjs} +2 -2
  2. package/dist/{PrivacyMaskSettings-DlILfRb9.mjs → PrivacyMaskSettings-CJUs69K5.mjs} +2 -2
  3. package/dist/{SceneMonitorEditor-DgOpS2v_.mjs → SceneMonitorEditor-BjEBJhp2.mjs} +1 -1
  4. package/dist/_stub.js +14 -14
  5. package/dist/{_virtual_mf-localSharedImportMap___mfe_internal__addon_training_page-BbkzYirO.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_training_page-B9bxvWW7.mjs} +4 -4
  6. package/dist/_virtual_mf___mfe_internal__addon_training_page__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-BRYzagHC.mjs +26 -0
  7. package/dist/{dist-DM9y4CJe.mjs → dist-BrdzZGWE.mjs} +390 -294
  8. package/dist/{dist-DfNFNGnO.js → dist-Bw72X0Lw.js} +390 -294
  9. package/dist/{hostInit-SLlPYdLV.mjs → hostInit-Bi_brUZe.mjs} +3 -3
  10. package/dist/index.js +1 -1
  11. package/dist/orchestrator/training.addon.js +1 -1
  12. package/dist/orchestrator/training.addon.mjs +1 -1
  13. package/dist/{player-overlays-pM6iC4GI.mjs → player-overlays-DfEn3UiJ.mjs} +1 -1
  14. package/dist/providers/modal/training-modal.addon.js +1 -1
  15. package/dist/providers/modal/training-modal.addon.mjs +1 -1
  16. package/dist/remoteEntry.js +1 -1
  17. package/dist/{responsive-BAAHnmTT.mjs → responsive-KcnxmMOF.mjs} +1 -1
  18. package/dist/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_training_page__remoteEntry_js-D81A7IJp.mjs → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_training_page__remoteEntry_js-764ClezD.mjs} +1 -1
  19. package/package.json +1 -1
  20. package/dist/_virtual_mf___mfe_internal__addon_training_page__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-DlLXF7aF.mjs +0 -26
@@ -5580,7 +5580,7 @@ var ZodIssueCode = {
5580
5580
  var ZodFirstPartyTypeKind;
5581
5581
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5582
5582
  //#endregion
5583
- //#region ../types/dist/sleep-BxjU_fJM.mjs
5583
+ //#region ../types/dist/sleep-yKL5gfrH.mjs
5584
5584
  /**
5585
5585
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5586
5586
  * window to float samples (D455).
@@ -7962,6 +7962,12 @@ function normalizeAddonInitResult(result) {
7962
7962
  if (Array.isArray(result)) return { providers: result };
7963
7963
  return result;
7964
7964
  }
7965
+ /**
7966
+ * The share-view scope kinds a share-link token can carry. The hub mints
7967
+ * and validates them (`ShareViewGrantSchema` builds its
7968
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
7969
+ */
7970
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7965
7971
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7966
7972
  var PeerBytesTicketSchema = object({
7967
7973
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12823,6 +12829,280 @@ var ConvertResultSchema = object({
12823
12829
  files: array(string()).readonly()
12824
12830
  })).readonly()
12825
12831
  });
12832
+ /**
12833
+ * Zod schemas for persisted record types.
12834
+ *
12835
+ * These schemas serve as the single source of truth for types that are
12836
+ * stored in the settings-store backend and retrieved via tRPC. They
12837
+ * replace the manual TypeScript interfaces with schema-derived types,
12838
+ * enabling runtime validation when reading from the backend.
12839
+ *
12840
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12841
+ * keeps the original name for backward compatibility.
12842
+ */
12843
+ /**
12844
+ * Auth model (v2 — 2026-05-12 caps-only):
12845
+ *
12846
+ * Two principals:
12847
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12848
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12849
+ *
12850
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12851
+ * `super_admin` — collapsed onto the single boolean because every
12852
+ * non-admin caller is governed by the same scope-check rules; the
12853
+ * distinction was only ever used to route role-specific procedures
12854
+ * which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
12855
+ * with `isAdmin: false` + an explicit scope list.
12856
+ */
12857
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12858
+ var MethodAccessSchema = _enum([
12859
+ "view",
12860
+ "create",
12861
+ "delete"
12862
+ ]);
12863
+ /**
12864
+ * A single scope grant. Three forms — checked in matcher with OR
12865
+ * semantics; the first match decides whether the call passes:
12866
+ *
12867
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12868
+ * cap with the matching `scope` declaration. New caps inherit grants
12869
+ * automatically — adding a device cap to the codebase makes it
12870
+ * reachable to every user with `category:device [...]` without a
12871
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12872
+ *
12873
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12874
+ * useful when an integration needs to interact with one specific
12875
+ * addon's surface regardless of how many caps it exports.
12876
+ *
12877
+ * - `capability` — the most precise form. Single cap name. Use for
12878
+ * integration tokens where you want to grant `addons.installPackage`
12879
+ * and nothing else.
12880
+ *
12881
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12882
+ * "give me everything" escape; there is no wildcard scope.
12883
+ */
12884
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12885
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12886
+ var CapScopeSchema = _enum(["device", "system"]);
12887
+ /**
12888
+ * DeviceSelector (scope model v3 — 2026-08-12).
12889
+ *
12890
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12891
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12892
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12893
+ * AFTER the grant was minted — no re-grant, no re-login.
12894
+ *
12895
+ * - `all` — every device in the deployment. The broad viewer/operator
12896
+ * lever without a `category` grant (a `category` grant also covers device
12897
+ * caps that carry no deviceId; `all` is specifically the device set).
12898
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
12899
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
12900
+ * is NOT covered until the grant is edited.
12901
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
12902
+ * DYNAMIC. A device that changes type, or a new device of the type,
12903
+ * re-resolves on the next request.
12904
+ * - `locations` — every device whose operator-assigned `location` label is
12905
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
12906
+ * null/unset location matches NO `locations` selector.
12907
+ */
12908
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
12909
+ object({ kind: literal("all") }),
12910
+ object({
12911
+ kind: literal("ids"),
12912
+ ids: array(number().int()).min(1)
12913
+ }),
12914
+ object({
12915
+ kind: literal("types"),
12916
+ types: array(_enum(DeviceType)).min(1)
12917
+ }),
12918
+ object({
12919
+ kind: literal("locations"),
12920
+ locations: array(string().min(1)).min(1)
12921
+ })
12922
+ ]);
12923
+ var DeviceTokenScopeSchema = object({
12924
+ type: literal("device"),
12925
+ /** The device SET this grant covers — resolved against the live fleet. */
12926
+ selector: DeviceSelectorSchema,
12927
+ access: array(MethodAccessSchema).min(1),
12928
+ /**
12929
+ * Whether a grant on a PARENT device transparently covers its accessory
12930
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
12931
+ * Direction is parent → children ONLY.
12932
+ *
12933
+ * Absent → the matcher DERIVES it from the access flavour: `view`
12934
+ * inherits (a camera viewer sees the camera's accessories), `create` /
12935
+ * `delete` do NOT (actuating/removing a child is an explicit act the
12936
+ * operator must grant on the child, not inherit from the parent). Set it
12937
+ * explicitly to override that default per grant.
12938
+ */
12939
+ includeLinked: boolean().optional()
12940
+ });
12941
+ /**
12942
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
12943
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
12944
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
12945
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
12946
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
12947
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
12948
+ * migration cannot reach a JWT already in a client's hands; parse-time
12949
+ * migration covers both without a flag day. No cast — the raw object is read
12950
+ * through `Reflect.get` (its static type is `unknown`).
12951
+ */
12952
+ function migrateLegacyTokenScope(raw) {
12953
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
12954
+ if (Reflect.get(raw, "type") !== "device") return raw;
12955
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
12956
+ const targets = Reflect.get(raw, "targets");
12957
+ if (!Array.isArray(targets)) return raw;
12958
+ return {
12959
+ type: "device",
12960
+ selector: {
12961
+ kind: "ids",
12962
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
12963
+ },
12964
+ access: Reflect.get(raw, "access")
12965
+ };
12966
+ }
12967
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
12968
+ object({
12969
+ type: literal("category"),
12970
+ target: CapScopeSchema,
12971
+ access: array(MethodAccessSchema).min(1)
12972
+ }),
12973
+ object({
12974
+ type: literal("capability"),
12975
+ target: string(),
12976
+ access: array(MethodAccessSchema).min(1)
12977
+ }),
12978
+ object({
12979
+ type: literal("addon"),
12980
+ target: string(),
12981
+ access: array(MethodAccessSchema).min(1)
12982
+ }),
12983
+ DeviceTokenScopeSchema
12984
+ ]));
12985
+ object({
12986
+ id: string(),
12987
+ username: string(),
12988
+ passwordHash: string(),
12989
+ /**
12990
+ * Admin bypass. When true, the middleware skips the scope-access
12991
+ * check entirely. There is no other axis of privilege; the legacy
12992
+ * role enum collapsed onto this boolean in v2.
12993
+ */
12994
+ isAdmin: boolean().default(false),
12995
+ allowedProviders: AllowedProviderSchema,
12996
+ allowedDevices: AllowedDevicesSchema,
12997
+ /**
12998
+ * Scopes granted to this user. Admins bypass; their `scopes` is
12999
+ * ignored. Non-admins without scopes are locked out of every
13000
+ * protected call.
13001
+ */
13002
+ scopes: array(TokenScopeSchema).default([]),
13003
+ createdAt: number(),
13004
+ updatedAt: number()
13005
+ });
13006
+ object({
13007
+ id: string(),
13008
+ label: string(),
13009
+ isAdmin: boolean().default(false),
13010
+ allowedProviders: AllowedProviderSchema,
13011
+ allowedDevices: AllowedDevicesSchema,
13012
+ tokenHash: string(),
13013
+ tokenPrefix: string(),
13014
+ createdAt: number(),
13015
+ lastUsedAt: number().optional()
13016
+ });
13017
+ object({
13018
+ id: string(),
13019
+ userId: string(),
13020
+ name: string(),
13021
+ tokenHash: string(),
13022
+ tokenPrefix: string(),
13023
+ scopes: array(TokenScopeSchema),
13024
+ expiresAt: number().nullish(),
13025
+ lastUsedAt: number().nullish(),
13026
+ createdAt: number()
13027
+ });
13028
+ /** What a share-view grant lets its holder see. */
13029
+ var ShareViewGrantSchema = object({
13030
+ kind: _enum(SHARE_VIEW_KINDS),
13031
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
13032
+ /** Talk-back, opt-in at mint time; absent means off. */
13033
+ talk: boolean().optional()
13034
+ });
13035
+ var ShareViewScopeSchema = object({
13036
+ type: literal("share-view"),
13037
+ grant: ShareViewGrantSchema
13038
+ });
13039
+ var AddonRoutesScopeSchema = object({
13040
+ type: literal("addon-routes"),
13041
+ access: array(MethodAccessSchema).min(1)
13042
+ });
13043
+ var PreferencesSelfScopeSchema = object({ type: literal("preferences-self") });
13044
+ var CredentialScopeSchema = union([
13045
+ literal("*"),
13046
+ ShareViewScopeSchema,
13047
+ AddonRoutesScopeSchema,
13048
+ PreferencesSelfScopeSchema,
13049
+ TokenScopeSchema
13050
+ ]);
13051
+ object({
13052
+ kind: literal("credential"),
13053
+ sub: string().min(1),
13054
+ jti: string().min(16),
13055
+ scopes: array(CredentialScopeSchema).min(1)
13056
+ });
13057
+ var PreferenceNamespaceSchema = string().regex(/^[a-z][a-z0-9.-]{0,63}$/);
13058
+ /** A namespace's value: a JSON object, opaque to the hub. */
13059
+ var PreferenceValueSchema = record(string(), unknown());
13060
+ var PreferenceDeviceIdSchema = string().min(1).max(64);
13061
+ /** A stored row, as the owner reads it. */
13062
+ var PreferenceRowSchema = object({
13063
+ namespace: PreferenceNamespaceSchema,
13064
+ value: PreferenceValueSchema,
13065
+ /** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
13066
+ revision: number().int().positive(),
13067
+ updatedAt: number().int(),
13068
+ /** The client id the last writer sent; `null` when it sent none. */
13069
+ updatedByDevice: PreferenceDeviceIdSchema.nullable()
13070
+ });
13071
+ object({
13072
+ /** Absent: every namespace the caller holds. */
13073
+ namespaces: array(PreferenceNamespaceSchema).max(32).optional() });
13074
+ object({ rows: array(PreferenceRowSchema) });
13075
+ object({
13076
+ namespace: PreferenceNamespaceSchema,
13077
+ value: PreferenceValueSchema,
13078
+ /**
13079
+ * The revision the edit was based on. Absent: last write wins. `0`: the
13080
+ * namespace must not exist yet. Any other value that is not the current
13081
+ * revision answers `conflict` and writes nothing.
13082
+ */
13083
+ baseRevision: number().int().nonnegative().optional(),
13084
+ deviceId: PreferenceDeviceIdSchema.optional()
13085
+ });
13086
+ discriminatedUnion("status", [object({
13087
+ status: literal("saved"),
13088
+ row: PreferenceRowSchema
13089
+ }), object({
13090
+ status: literal("conflict"),
13091
+ current: PreferenceRowSchema.nullable()
13092
+ })]);
13093
+ object({ namespace: PreferenceNamespaceSchema });
13094
+ object({
13095
+ /** `false` when the namespace did not exist. */
13096
+ deleted: boolean() });
13097
+ object({
13098
+ /** The revision the client holds per namespace; a namespace it does not list is new to it. */
13099
+ revisionByNamespace: record(PreferenceNamespaceSchema, number().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
13100
+ object({
13101
+ /** Every row whose revision differs from the client's, and every row it did not list. */
13102
+ rows: array(PreferenceRowSchema),
13103
+ /** Namespaces the client listed that no longer exist. */
13104
+ deleted: array(PreferenceNamespaceSchema)
13105
+ });
12826
13106
  _enum(["new-session", "step-up"]);
12827
13107
  /** The languages the hub's app landing pages are written in (D858). */
12828
13108
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -39718,38 +39998,37 @@ method(LlmRuntimeCompleteInputSchema, LlmGenerateResultSchema, {
39718
39998
  auth: "admin",
39719
39999
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39720
40000
  });
40001
+ var LlmProfileKindSchema = string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "a kind id is lower-case letters, digits and dashes");
40002
+ /** What a model (or, by default, every model of a kind) can do. */
40003
+ var LlmModelFeaturesSchema = object({
40004
+ vision: boolean(),
40005
+ tools: boolean(),
40006
+ streaming: boolean()
40007
+ });
40008
+ /** One model a provider offers. `features` overrides the kind's defaults, per field. */
40009
+ var LlmModelInfoSchema = object({
40010
+ id: string(),
40011
+ label: string().optional(),
40012
+ contextLength: number().int().positive().optional(),
40013
+ features: LlmModelFeaturesSchema.partial().optional()
40014
+ });
39721
40015
  /**
39722
- * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
39723
- * methods concat-fan across providers; single-row methods route to ONE
39724
- * provider by the `addonId` in the call input (the notification-output
39725
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
39726
- * (hub-placed); the cap stays open for future providers.
39727
- *
39728
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
39729
- * `apiKey` is a password field — providers REDACT it on read and merge on
39730
- * write; a stored key NEVER round-trips to a client.
40016
+ * The provider-specific part of a profile, validated by the provider that owns
40017
+ * the kind (`upsertProfile` refuses what it does not accept). A field its
40018
+ * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
40019
+ * keychain, never in the row, and reads back as the redaction marker.
39731
40020
  */
39732
- var LlmProfileKindSchema = _enum([
39733
- "openai-compatible",
39734
- "openai",
39735
- "anthropic",
39736
- "google",
39737
- "managed-local",
39738
- "apple-foundation"
39739
- ]);
40021
+ var LlmProviderConfigSchema = record(string(), unknown());
39740
40022
  var LlmProfileSchema = object({
39741
40023
  id: string(),
39742
40024
  name: string(),
40025
+ /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
39743
40026
  kind: LlmProfileKindSchema,
39744
40027
  /** Stamped by the provider — keeps the fanned catalog routable. */
39745
40028
  addonId: string(),
39746
40029
  enabled: boolean(),
39747
40030
  /** Vendor model id, or the managed runtime's loaded model. */
39748
40031
  model: string(),
39749
- /** Required for openai-compatible; override for cloud kinds. */
39750
- baseUrl: string().optional(),
39751
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
39752
- apiKey: string().optional(),
39753
40032
  /** Vision on/off. A vision call against a `false` profile is REFUSED, never
39754
40033
  * degraded to text — that shipped once and produced a confident answer to a
39755
40034
  * question about a picture nobody sent. */
@@ -39757,15 +40036,11 @@ var LlmProfileSchema = object({
39757
40036
  temperature: number().min(0).max(2).optional(),
39758
40037
  /** Nucleus sampling. Every wire we speak has it. */
39759
40038
  topP: number().min(0).max(1).optional(),
39760
- /** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
39761
- * wire does, and the client drops it there (measured: the request body gets
39762
- * `top_p` and no `top_k`). The profile editor hides the field wherever it
39763
- * would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
40039
+ /** Top-k sampling. Carried only by the wires that have it — a kind offers the
40040
+ * field in its editor only when its descriptor lists it in `profileFields`. */
39764
40041
  topK: number().int().positive().optional(),
39765
40042
  maxTokens: number().int().positive().optional(),
39766
- /** Prompt context window. Advisory for cloud kinds (they enforce their own);
39767
- * for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
39768
- * the model with, so it is the one field that changes a PROCESS. */
40043
+ /** Prompt context window. Advisory for cloud kinds (they enforce their own). */
39769
40044
  contextLength: number().int().positive().optional(),
39770
40045
  /** Default system prompt. A caller's `system` REPLACES it (never appends —
39771
40046
  * two system prompts fighting is worse than either alone). */
@@ -39791,16 +40066,37 @@ var LlmProfileSchema = object({
39791
40066
  * library; the REGISTRY of callable tools is ours and is empty in v1, so a
39792
40067
  * `true` here buys the wiring, not behaviour, until tools are registered. */
39793
40068
  toolsEnabled: boolean().default(false),
39794
- extraHeaders: record(string(), string()).optional(),
39795
- /** kind === 'managed-local' only (spec §4). */
39796
- runtime: ManagedRuntimeConfigSchema.optional(),
39797
- /**
39798
- * kind === 'apple-foundation' only: WHERE it runs — the only thing there is
39799
- * to configure (no key, no URL, no download; `model` is `apple-system`).
39800
- * `supportsVision` on such a row is stamped by the provider from the node's
39801
- * reported `imageInput`, never taken from the operator (D62).
39802
- */
39803
- appleFoundation: object({ nodeId: string() }).optional()
40069
+ /** Everything the kind's provider owns (endpoint, key, node, runtime…). */
40070
+ providerConfig: LlmProviderConfigSchema.default({})
40071
+ });
40072
+ /**
40073
+ * The common profile fields a kind's editor offers. The editor owns how each
40074
+ * one is drawn; the provider says which of them mean something on its wire.
40075
+ */
40076
+ var LlmProfileFieldSchema = _enum([
40077
+ "temperature",
40078
+ "topP",
40079
+ "topK",
40080
+ "maxTokens",
40081
+ "contextLength",
40082
+ "systemPrompt",
40083
+ "timeoutMs",
40084
+ "connectTimeoutMs",
40085
+ "firstTokenTimeoutMs",
40086
+ "idleTimeoutMs",
40087
+ "retry",
40088
+ "toolsEnabled"
40089
+ ]);
40090
+ /**
40091
+ * A provider-drawn part of the editor, by a generic widget id the admin UI
40092
+ * registers (`ai/apple-node`). `placement: 'model'` replaces the generic model
40093
+ * picker: that widget owns the model choice.
40094
+ */
40095
+ var LlmProviderWidgetSchema = object({
40096
+ id: string(),
40097
+ placement: _enum(["connection", "model"]),
40098
+ /** `providerConfig` keys this widget must fill before the profile can be saved. */
40099
+ requires: array(string()).optional()
39804
40100
  });
39805
40101
  /** ConfigUISchema tree passed through untyped on the wire (the
39806
40102
  * notification-output `ConfigSchemaPassthrough` precedent at
@@ -39809,11 +40105,56 @@ var ConfigSchemaPassthrough$3 = unknown();
39809
40105
  var LlmProfileKindDescriptorSchema = object({
39810
40106
  kind: LlmProfileKindSchema,
39811
40107
  label: string(),
40108
+ /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
39812
40109
  icon: string(),
39813
40110
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
39814
40111
  addonId: string(),
39815
- configSchema: ConfigSchemaPassthrough$3
40112
+ /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
40113
+ connectionSchema: ConfigSchemaPassthrough$3,
40114
+ /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
40115
+ advancedSchema: ConfigSchemaPassthrough$3.optional(),
40116
+ /** The kind's defaults; a model from `listModels` may override any of them. */
40117
+ features: LlmModelFeaturesSchema,
40118
+ /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
40119
+ visionEditable: boolean(),
40120
+ /** Where the model list comes from: `listModels`, `staticModels`, or nowhere. */
40121
+ modelCatalog: _enum([
40122
+ "fetch",
40123
+ "static",
40124
+ "none"
40125
+ ]),
40126
+ staticModels: array(LlmModelInfoSchema).optional(),
40127
+ /** The common fields that mean something on this kind's wire. */
40128
+ profileFields: array(LlmProfileFieldSchema),
40129
+ providerWidgets: array(LlmProviderWidgetSchema).optional()
40130
+ });
40131
+ /**
40132
+ * `listModels` input. `connection` is an UNSAVED draft of `providerConfig`
40133
+ * (the editor's form); with `profileId` too, a secret the draft leaves
40134
+ * untouched (absent or the redaction marker) is resolved server-side from the
40135
+ * stored profile — the browser never receives it.
40136
+ */
40137
+ var LlmListModelsInputSchema = object({
40138
+ addonId: string(),
40139
+ kind: LlmProfileKindSchema,
40140
+ profileId: string().optional(),
40141
+ connection: LlmProviderConfigSchema.optional()
39816
40142
  });
40143
+ var LlmListModelsErrorCodeSchema = _enum([
40144
+ "auth",
40145
+ "network",
40146
+ "unsupported",
40147
+ "invalid"
40148
+ ]);
40149
+ /** A RESULT, never a throw: "wrong key" is an answer the editor renders inline. */
40150
+ var LlmListModelsResultSchema = discriminatedUnion("ok", [object({
40151
+ ok: literal(true),
40152
+ models: array(LlmModelInfoSchema)
40153
+ }), object({
40154
+ ok: literal(false),
40155
+ code: LlmListModelsErrorCodeSchema,
40156
+ message: string()
40157
+ })]);
39817
40158
  var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
39818
40159
  var LlmDefaultSchema = object({
39819
40160
  selector: LlmDefaultSelectorSchema,
@@ -39913,7 +40254,10 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
39913
40254
  kind: "mutation",
39914
40255
  auth: "admin",
39915
40256
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39916
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
40257
+ }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
40258
+ kind: "mutation",
40259
+ auth: "admin"
40260
+ }), method(object({}), array(LlmDefaultSchema)), method(object({
39917
40261
  selector: LlmDefaultSelectorSchema,
39918
40262
  profileId: string().nullable()
39919
40263
  }), _void(), {
@@ -43977,202 +44321,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
43977
44321
  auth: "admin"
43978
44322
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
43979
44323
  /**
43980
- * Zod schemas for persisted record types.
43981
- *
43982
- * These schemas serve as the single source of truth for types that are
43983
- * stored in the settings-store backend and retrieved via tRPC. They
43984
- * replace the manual TypeScript interfaces with schema-derived types,
43985
- * enabling runtime validation when reading from the backend.
43986
- *
43987
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
43988
- * keeps the original name for backward compatibility.
43989
- */
43990
- /**
43991
- * Auth model (v2 — 2026-05-12 caps-only):
43992
- *
43993
- * Two principals:
43994
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
43995
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
43996
- *
43997
- * No role enum. There used to be `viewer / agent / scoped` and earlier
43998
- * `super_admin` — collapsed onto the single boolean because every
43999
- * non-admin caller is governed by the same scope-check rules; the
44000
- * distinction was only ever used to route role-specific procedures
44001
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44002
- * with `isAdmin: false` + an explicit scope list.
44003
- */
44004
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44005
- var MethodAccessSchema = _enum([
44006
- "view",
44007
- "create",
44008
- "delete"
44009
- ]);
44010
- /**
44011
- * A single scope grant. Three forms — checked in matcher with OR
44012
- * semantics; the first match decides whether the call passes:
44013
- *
44014
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44015
- * cap with the matching `scope` declaration. New caps inherit grants
44016
- * automatically — adding a device cap to the codebase makes it
44017
- * reachable to every user with `category:device [...]` without a
44018
- * re-grant. Use this for "family viewer" / "operator" tiers.
44019
- *
44020
- * - `addon` — every cap that ships inside a given addon id. Niche;
44021
- * useful when an integration needs to interact with one specific
44022
- * addon's surface regardless of how many caps it exports.
44023
- *
44024
- * - `capability` — the most precise form. Single cap name. Use for
44025
- * integration tokens where you want to grant `addons.installPackage`
44026
- * and nothing else.
44027
- *
44028
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44029
- * "give me everything" escape; there is no wildcard scope.
44030
- */
44031
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44032
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44033
- var CapScopeSchema = _enum(["device", "system"]);
44034
- /**
44035
- * DeviceSelector (scope model v3 — 2026-08-12).
44036
- *
44037
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44038
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44039
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44040
- * AFTER the grant was minted — no re-grant, no re-login.
44041
- *
44042
- * - `all` — every device in the deployment. The broad viewer/operator
44043
- * lever without a `category` grant (a `category` grant also covers device
44044
- * caps that carry no deviceId; `all` is specifically the device set).
44045
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44046
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44047
- * is NOT covered until the grant is edited.
44048
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44049
- * DYNAMIC. A device that changes type, or a new device of the type,
44050
- * re-resolves on the next request.
44051
- * - `locations` — every device whose operator-assigned `location` label is
44052
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44053
- * null/unset location matches NO `locations` selector.
44054
- */
44055
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44056
- object({ kind: literal("all") }),
44057
- object({
44058
- kind: literal("ids"),
44059
- ids: array(number().int()).min(1)
44060
- }),
44061
- object({
44062
- kind: literal("types"),
44063
- types: array(_enum(DeviceType)).min(1)
44064
- }),
44065
- object({
44066
- kind: literal("locations"),
44067
- locations: array(string().min(1)).min(1)
44068
- })
44069
- ]);
44070
- var DeviceTokenScopeSchema = object({
44071
- type: literal("device"),
44072
- /** The device SET this grant covers — resolved against the live fleet. */
44073
- selector: DeviceSelectorSchema,
44074
- access: array(MethodAccessSchema).min(1),
44075
- /**
44076
- * Whether a grant on a PARENT device transparently covers its accessory
44077
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44078
- * Direction is parent → children ONLY.
44079
- *
44080
- * Absent → the matcher DERIVES it from the access flavour: `view`
44081
- * inherits (a camera viewer sees the camera's accessories), `create` /
44082
- * `delete` do NOT (actuating/removing a child is an explicit act the
44083
- * operator must grant on the child, not inherit from the parent). Set it
44084
- * explicitly to override that default per grant.
44085
- */
44086
- includeLinked: boolean().optional()
44087
- });
44088
- /**
44089
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44090
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44091
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44092
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44093
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44094
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44095
- * migration cannot reach a JWT already in a client's hands; parse-time
44096
- * migration covers both without a flag day. No cast — the raw object is read
44097
- * through `Reflect.get` (its static type is `unknown`).
44098
- */
44099
- function migrateLegacyTokenScope(raw) {
44100
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44101
- if (Reflect.get(raw, "type") !== "device") return raw;
44102
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44103
- const targets = Reflect.get(raw, "targets");
44104
- if (!Array.isArray(targets)) return raw;
44105
- return {
44106
- type: "device",
44107
- selector: {
44108
- kind: "ids",
44109
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44110
- },
44111
- access: Reflect.get(raw, "access")
44112
- };
44113
- }
44114
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44115
- object({
44116
- type: literal("category"),
44117
- target: CapScopeSchema,
44118
- access: array(MethodAccessSchema).min(1)
44119
- }),
44120
- object({
44121
- type: literal("capability"),
44122
- target: string(),
44123
- access: array(MethodAccessSchema).min(1)
44124
- }),
44125
- object({
44126
- type: literal("addon"),
44127
- target: string(),
44128
- access: array(MethodAccessSchema).min(1)
44129
- }),
44130
- DeviceTokenScopeSchema
44131
- ]));
44132
- object({
44133
- id: string(),
44134
- username: string(),
44135
- passwordHash: string(),
44136
- /**
44137
- * Admin bypass. When true, the middleware skips the scope-access
44138
- * check entirely. There is no other axis of privilege; the legacy
44139
- * role enum collapsed onto this boolean in v2.
44140
- */
44141
- isAdmin: boolean().default(false),
44142
- allowedProviders: AllowedProviderSchema,
44143
- allowedDevices: AllowedDevicesSchema,
44144
- /**
44145
- * Scopes granted to this user. Admins bypass; their `scopes` is
44146
- * ignored. Non-admins without scopes are locked out of every
44147
- * protected call.
44148
- */
44149
- scopes: array(TokenScopeSchema).default([]),
44150
- createdAt: number(),
44151
- updatedAt: number()
44152
- });
44153
- object({
44154
- id: string(),
44155
- label: string(),
44156
- isAdmin: boolean().default(false),
44157
- allowedProviders: AllowedProviderSchema,
44158
- allowedDevices: AllowedDevicesSchema,
44159
- tokenHash: string(),
44160
- tokenPrefix: string(),
44161
- createdAt: number(),
44162
- lastUsedAt: number().optional()
44163
- });
44164
- object({
44165
- id: string(),
44166
- userId: string(),
44167
- name: string(),
44168
- tokenHash: string(),
44169
- tokenPrefix: string(),
44170
- scopes: array(TokenScopeSchema),
44171
- expiresAt: number().nullish(),
44172
- lastUsedAt: number().nullish(),
44173
- createdAt: number()
44174
- });
44175
- /**
44176
44324
  * `oauth-integration` — a collection cap by which an addon declares
44177
44325
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44178
44326
  * Each provider returns a static descriptor; the core enumerates them
@@ -61104,26 +61252,6 @@ var ApiKeySummarySchema = object({
61104
61252
  createdAt: number(),
61105
61253
  lastUsedAt: number().optional()
61106
61254
  });
61107
- var ScopedTokenSummarySchema = object({
61108
- id: string(),
61109
- userId: string(),
61110
- name: string(),
61111
- tokenPrefix: string(),
61112
- scopes: array(TokenScopeSchema),
61113
- expiresAt: number().nullish(),
61114
- lastUsedAt: number().nullish(),
61115
- createdAt: number()
61116
- });
61117
- var CreateScopedTokenInputSchema = object({
61118
- userId: string(),
61119
- name: string(),
61120
- scopes: array(TokenScopeSchema),
61121
- expiresAt: number().optional()
61122
- });
61123
- var CreateScopedTokenResultSchema = object({
61124
- token: string(),
61125
- record: ScopedTokenSummarySchema
61126
- });
61127
61255
  var OauthSessionSummarySchema = object({
61128
61256
  id: string(),
61129
61257
  userId: string(),
@@ -61145,11 +61273,11 @@ var TotpStatusSchema = object({
61145
61273
  confirmedAt: number().nullable()
61146
61274
  });
61147
61275
  /**
61148
- * user-management — singleton capability for user accounts, API keys,
61149
- * and scoped tokens.
61276
+ * user-management — singleton capability for user accounts and the
61277
+ * legacy API-key rows.
61150
61278
  *
61151
61279
  * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
61152
- * — the subset check on `setUserScopes` / `createScopedToken` is moot
61280
+ * — the subset check on `setUserScopes` is moot
61153
61281
  * because non-admins never reach these. If/when we open non-admin
61154
61282
  * delegation, structural caller-scope subset check goes inside the
61155
61283
  * provider.
@@ -61206,15 +61334,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
61206
61334
  kind: "mutation",
61207
61335
  auth: "admin",
61208
61336
  access: "delete"
61209
- }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
61210
- kind: "mutation",
61211
- auth: "admin",
61212
- access: "create"
61213
- }), method(object({ id: string() }), object({ success: literal(true) }), {
61214
- kind: "mutation",
61215
- auth: "admin",
61216
- access: "delete"
61217
- }), method(object({ token: string() }), ScopedTokenSummarySchema.nullable(), { access: "view" }), method(object({ userId: string() }), array(ScopedTokenSummarySchema), { auth: "admin" }), method(object({ userId: string() }), TotpSetupResultSchema, {
61337
+ }), method(object({ userId: string() }), TotpSetupResultSchema, {
61218
61338
  kind: "mutation",
61219
61339
  auth: "admin",
61220
61340
  access: "create"
@@ -65470,7 +65590,7 @@ Object.freeze({
65470
65590
  capName: "llm",
65471
65591
  capScope: "system",
65472
65592
  addonId: null,
65473
- access: "view"
65593
+ access: "create"
65474
65594
  },
65475
65595
  "llm.listNodeModels": {
65476
65596
  capName: "llm",
@@ -70134,12 +70254,6 @@ Object.freeze({
70134
70254
  addonId: null,
70135
70255
  access: "create"
70136
70256
  },
70137
- "userManagement.createScopedToken": {
70138
- capName: "user-management",
70139
- capScope: "system",
70140
- addonId: null,
70141
- access: "create"
70142
- },
70143
70257
  "userManagement.createUser": {
70144
70258
  capName: "user-management",
70145
70259
  capScope: "system",
@@ -70188,12 +70302,6 @@ Object.freeze({
70188
70302
  addonId: null,
70189
70303
  access: "view"
70190
70304
  },
70191
- "userManagement.listScopedTokens": {
70192
- capName: "user-management",
70193
- capScope: "system",
70194
- addonId: null,
70195
- access: "view"
70196
- },
70197
70305
  "userManagement.listUsers": {
70198
70306
  capName: "user-management",
70199
70307
  capScope: "system",
@@ -70248,12 +70356,6 @@ Object.freeze({
70248
70356
  addonId: null,
70249
70357
  access: "delete"
70250
70358
  },
70251
- "userManagement.revokeScopedToken": {
70252
- capName: "user-management",
70253
- capScope: "system",
70254
- addonId: null,
70255
- access: "delete"
70256
- },
70257
70359
  "userManagement.setupTotp": {
70258
70360
  capName: "user-management",
70259
70361
  capScope: "system",
@@ -70284,12 +70386,6 @@ Object.freeze({
70284
70386
  addonId: null,
70285
70387
  access: "view"
70286
70388
  },
70287
- "userManagement.validateScopedToken": {
70288
- capName: "user-management",
70289
- capScope: "system",
70290
- addonId: null,
70291
- access: "view"
70292
- },
70293
70389
  "userManagement.verifyTotp": {
70294
70390
  capName: "user-management",
70295
70391
  capScope: "system",