@camstack/addon-export-google 0.1.95 → 0.1.97

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.
@@ -5492,7 +5492,7 @@ var ZodIssueCode = {
5492
5492
  var ZodFirstPartyTypeKind;
5493
5493
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5494
5494
  //#endregion
5495
- //#region ../types/dist/sleep-BxjU_fJM.mjs
5495
+ //#region ../types/dist/sleep-yKL5gfrH.mjs
5496
5496
  /**
5497
5497
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5498
5498
  * window to float samples (D455).
@@ -7874,6 +7874,12 @@ function normalizeAddonInitResult(result) {
7874
7874
  if (Array.isArray(result)) return { providers: result };
7875
7875
  return result;
7876
7876
  }
7877
+ /**
7878
+ * The share-view scope kinds a share-link token can carry. The hub mints
7879
+ * and validates them (`ShareViewGrantSchema` builds its
7880
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
7881
+ */
7882
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7877
7883
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7878
7884
  var PeerBytesTicketSchema = object({
7879
7885
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12614,6 +12620,280 @@ var ConvertResultSchema = object({
12614
12620
  function scopesAllowDeviceCap(scopes, access) {
12615
12621
  return scopes.some((s) => s.type === "category" && s.target === "device" && s.access.includes(access));
12616
12622
  }
12623
+ /**
12624
+ * Zod schemas for persisted record types.
12625
+ *
12626
+ * These schemas serve as the single source of truth for types that are
12627
+ * stored in the settings-store backend and retrieved via tRPC. They
12628
+ * replace the manual TypeScript interfaces with schema-derived types,
12629
+ * enabling runtime validation when reading from the backend.
12630
+ *
12631
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12632
+ * keeps the original name for backward compatibility.
12633
+ */
12634
+ /**
12635
+ * Auth model (v2 — 2026-05-12 caps-only):
12636
+ *
12637
+ * Two principals:
12638
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12639
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12640
+ *
12641
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12642
+ * `super_admin` — collapsed onto the single boolean because every
12643
+ * non-admin caller is governed by the same scope-check rules; the
12644
+ * distinction was only ever used to route role-specific procedures
12645
+ * which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
12646
+ * with `isAdmin: false` + an explicit scope list.
12647
+ */
12648
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12649
+ var MethodAccessSchema = _enum([
12650
+ "view",
12651
+ "create",
12652
+ "delete"
12653
+ ]);
12654
+ /**
12655
+ * A single scope grant. Three forms — checked in matcher with OR
12656
+ * semantics; the first match decides whether the call passes:
12657
+ *
12658
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12659
+ * cap with the matching `scope` declaration. New caps inherit grants
12660
+ * automatically — adding a device cap to the codebase makes it
12661
+ * reachable to every user with `category:device [...]` without a
12662
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12663
+ *
12664
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12665
+ * useful when an integration needs to interact with one specific
12666
+ * addon's surface regardless of how many caps it exports.
12667
+ *
12668
+ * - `capability` — the most precise form. Single cap name. Use for
12669
+ * integration tokens where you want to grant `addons.installPackage`
12670
+ * and nothing else.
12671
+ *
12672
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12673
+ * "give me everything" escape; there is no wildcard scope.
12674
+ */
12675
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12676
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12677
+ var CapScopeSchema = _enum(["device", "system"]);
12678
+ /**
12679
+ * DeviceSelector (scope model v3 — 2026-08-12).
12680
+ *
12681
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12682
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12683
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12684
+ * AFTER the grant was minted — no re-grant, no re-login.
12685
+ *
12686
+ * - `all` — every device in the deployment. The broad viewer/operator
12687
+ * lever without a `category` grant (a `category` grant also covers device
12688
+ * caps that carry no deviceId; `all` is specifically the device set).
12689
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
12690
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
12691
+ * is NOT covered until the grant is edited.
12692
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
12693
+ * DYNAMIC. A device that changes type, or a new device of the type,
12694
+ * re-resolves on the next request.
12695
+ * - `locations` — every device whose operator-assigned `location` label is
12696
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
12697
+ * null/unset location matches NO `locations` selector.
12698
+ */
12699
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
12700
+ object({ kind: literal("all") }),
12701
+ object({
12702
+ kind: literal("ids"),
12703
+ ids: array(number().int()).min(1)
12704
+ }),
12705
+ object({
12706
+ kind: literal("types"),
12707
+ types: array(_enum(DeviceType)).min(1)
12708
+ }),
12709
+ object({
12710
+ kind: literal("locations"),
12711
+ locations: array(string().min(1)).min(1)
12712
+ })
12713
+ ]);
12714
+ var DeviceTokenScopeSchema = object({
12715
+ type: literal("device"),
12716
+ /** The device SET this grant covers — resolved against the live fleet. */
12717
+ selector: DeviceSelectorSchema,
12718
+ access: array(MethodAccessSchema).min(1),
12719
+ /**
12720
+ * Whether a grant on a PARENT device transparently covers its accessory
12721
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
12722
+ * Direction is parent → children ONLY.
12723
+ *
12724
+ * Absent → the matcher DERIVES it from the access flavour: `view`
12725
+ * inherits (a camera viewer sees the camera's accessories), `create` /
12726
+ * `delete` do NOT (actuating/removing a child is an explicit act the
12727
+ * operator must grant on the child, not inherit from the parent). Set it
12728
+ * explicitly to override that default per grant.
12729
+ */
12730
+ includeLinked: boolean().optional()
12731
+ });
12732
+ /**
12733
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
12734
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
12735
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
12736
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
12737
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
12738
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
12739
+ * migration cannot reach a JWT already in a client's hands; parse-time
12740
+ * migration covers both without a flag day. No cast — the raw object is read
12741
+ * through `Reflect.get` (its static type is `unknown`).
12742
+ */
12743
+ function migrateLegacyTokenScope(raw) {
12744
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
12745
+ if (Reflect.get(raw, "type") !== "device") return raw;
12746
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
12747
+ const targets = Reflect.get(raw, "targets");
12748
+ if (!Array.isArray(targets)) return raw;
12749
+ return {
12750
+ type: "device",
12751
+ selector: {
12752
+ kind: "ids",
12753
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
12754
+ },
12755
+ access: Reflect.get(raw, "access")
12756
+ };
12757
+ }
12758
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
12759
+ object({
12760
+ type: literal("category"),
12761
+ target: CapScopeSchema,
12762
+ access: array(MethodAccessSchema).min(1)
12763
+ }),
12764
+ object({
12765
+ type: literal("capability"),
12766
+ target: string(),
12767
+ access: array(MethodAccessSchema).min(1)
12768
+ }),
12769
+ object({
12770
+ type: literal("addon"),
12771
+ target: string(),
12772
+ access: array(MethodAccessSchema).min(1)
12773
+ }),
12774
+ DeviceTokenScopeSchema
12775
+ ]));
12776
+ object({
12777
+ id: string(),
12778
+ username: string(),
12779
+ passwordHash: string(),
12780
+ /**
12781
+ * Admin bypass. When true, the middleware skips the scope-access
12782
+ * check entirely. There is no other axis of privilege; the legacy
12783
+ * role enum collapsed onto this boolean in v2.
12784
+ */
12785
+ isAdmin: boolean().default(false),
12786
+ allowedProviders: AllowedProviderSchema,
12787
+ allowedDevices: AllowedDevicesSchema,
12788
+ /**
12789
+ * Scopes granted to this user. Admins bypass; their `scopes` is
12790
+ * ignored. Non-admins without scopes are locked out of every
12791
+ * protected call.
12792
+ */
12793
+ scopes: array(TokenScopeSchema).default([]),
12794
+ createdAt: number(),
12795
+ updatedAt: number()
12796
+ });
12797
+ object({
12798
+ id: string(),
12799
+ label: string(),
12800
+ isAdmin: boolean().default(false),
12801
+ allowedProviders: AllowedProviderSchema,
12802
+ allowedDevices: AllowedDevicesSchema,
12803
+ tokenHash: string(),
12804
+ tokenPrefix: string(),
12805
+ createdAt: number(),
12806
+ lastUsedAt: number().optional()
12807
+ });
12808
+ object({
12809
+ id: string(),
12810
+ userId: string(),
12811
+ name: string(),
12812
+ tokenHash: string(),
12813
+ tokenPrefix: string(),
12814
+ scopes: array(TokenScopeSchema),
12815
+ expiresAt: number().nullish(),
12816
+ lastUsedAt: number().nullish(),
12817
+ createdAt: number()
12818
+ });
12819
+ /** What a share-view grant lets its holder see. */
12820
+ var ShareViewGrantSchema = object({
12821
+ kind: _enum(SHARE_VIEW_KINDS),
12822
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
12823
+ /** Talk-back, opt-in at mint time; absent means off. */
12824
+ talk: boolean().optional()
12825
+ });
12826
+ var ShareViewScopeSchema = object({
12827
+ type: literal("share-view"),
12828
+ grant: ShareViewGrantSchema
12829
+ });
12830
+ var AddonRoutesScopeSchema = object({
12831
+ type: literal("addon-routes"),
12832
+ access: array(MethodAccessSchema).min(1)
12833
+ });
12834
+ var PreferencesSelfScopeSchema = object({ type: literal("preferences-self") });
12835
+ var CredentialScopeSchema = union([
12836
+ literal("*"),
12837
+ ShareViewScopeSchema,
12838
+ AddonRoutesScopeSchema,
12839
+ PreferencesSelfScopeSchema,
12840
+ TokenScopeSchema
12841
+ ]);
12842
+ object({
12843
+ kind: literal("credential"),
12844
+ sub: string().min(1),
12845
+ jti: string().min(16),
12846
+ scopes: array(CredentialScopeSchema).min(1)
12847
+ });
12848
+ var PreferenceNamespaceSchema = string().regex(/^[a-z][a-z0-9.-]{0,63}$/);
12849
+ /** A namespace's value: a JSON object, opaque to the hub. */
12850
+ var PreferenceValueSchema = record(string(), unknown());
12851
+ var PreferenceDeviceIdSchema = string().min(1).max(64);
12852
+ /** A stored row, as the owner reads it. */
12853
+ var PreferenceRowSchema = object({
12854
+ namespace: PreferenceNamespaceSchema,
12855
+ value: PreferenceValueSchema,
12856
+ /** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
12857
+ revision: number().int().positive(),
12858
+ updatedAt: number().int(),
12859
+ /** The client id the last writer sent; `null` when it sent none. */
12860
+ updatedByDevice: PreferenceDeviceIdSchema.nullable()
12861
+ });
12862
+ object({
12863
+ /** Absent: every namespace the caller holds. */
12864
+ namespaces: array(PreferenceNamespaceSchema).max(32).optional() });
12865
+ object({ rows: array(PreferenceRowSchema) });
12866
+ object({
12867
+ namespace: PreferenceNamespaceSchema,
12868
+ value: PreferenceValueSchema,
12869
+ /**
12870
+ * The revision the edit was based on. Absent: last write wins. `0`: the
12871
+ * namespace must not exist yet. Any other value that is not the current
12872
+ * revision answers `conflict` and writes nothing.
12873
+ */
12874
+ baseRevision: number().int().nonnegative().optional(),
12875
+ deviceId: PreferenceDeviceIdSchema.optional()
12876
+ });
12877
+ discriminatedUnion("status", [object({
12878
+ status: literal("saved"),
12879
+ row: PreferenceRowSchema
12880
+ }), object({
12881
+ status: literal("conflict"),
12882
+ current: PreferenceRowSchema.nullable()
12883
+ })]);
12884
+ object({ namespace: PreferenceNamespaceSchema });
12885
+ object({
12886
+ /** `false` when the namespace did not exist. */
12887
+ deleted: boolean() });
12888
+ object({
12889
+ /** The revision the client holds per namespace; a namespace it does not list is new to it. */
12890
+ revisionByNamespace: record(PreferenceNamespaceSchema, number().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
12891
+ object({
12892
+ /** Every row whose revision differs from the client's, and every row it did not list. */
12893
+ rows: array(PreferenceRowSchema),
12894
+ /** Namespaces the client listed that no longer exist. */
12895
+ deleted: array(PreferenceNamespaceSchema)
12896
+ });
12617
12897
  _enum(["new-session", "step-up"]);
12618
12898
  /** The languages the hub's app landing pages are written in (D858). */
12619
12899
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -39536,38 +39816,37 @@ method(LlmRuntimeCompleteInputSchema, LlmGenerateResultSchema, {
39536
39816
  auth: "admin",
39537
39817
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39538
39818
  });
39819
+ var LlmProfileKindSchema = string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "a kind id is lower-case letters, digits and dashes");
39820
+ /** What a model (or, by default, every model of a kind) can do. */
39821
+ var LlmModelFeaturesSchema = object({
39822
+ vision: boolean(),
39823
+ tools: boolean(),
39824
+ streaming: boolean()
39825
+ });
39826
+ /** One model a provider offers. `features` overrides the kind's defaults, per field. */
39827
+ var LlmModelInfoSchema = object({
39828
+ id: string(),
39829
+ label: string().optional(),
39830
+ contextLength: number().int().positive().optional(),
39831
+ features: LlmModelFeaturesSchema.partial().optional()
39832
+ });
39539
39833
  /**
39540
- * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
39541
- * methods concat-fan across providers; single-row methods route to ONE
39542
- * provider by the `addonId` in the call input (the notification-output
39543
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
39544
- * (hub-placed); the cap stays open for future providers.
39545
- *
39546
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
39547
- * `apiKey` is a password field — providers REDACT it on read and merge on
39548
- * write; a stored key NEVER round-trips to a client.
39834
+ * The provider-specific part of a profile, validated by the provider that owns
39835
+ * the kind (`upsertProfile` refuses what it does not accept). A field its
39836
+ * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
39837
+ * keychain, never in the row, and reads back as the redaction marker.
39549
39838
  */
39550
- var LlmProfileKindSchema = _enum([
39551
- "openai-compatible",
39552
- "openai",
39553
- "anthropic",
39554
- "google",
39555
- "managed-local",
39556
- "apple-foundation"
39557
- ]);
39839
+ var LlmProviderConfigSchema = record(string(), unknown());
39558
39840
  var LlmProfileSchema = object({
39559
39841
  id: string(),
39560
39842
  name: string(),
39843
+ /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
39561
39844
  kind: LlmProfileKindSchema,
39562
39845
  /** Stamped by the provider — keeps the fanned catalog routable. */
39563
39846
  addonId: string(),
39564
39847
  enabled: boolean(),
39565
39848
  /** Vendor model id, or the managed runtime's loaded model. */
39566
39849
  model: string(),
39567
- /** Required for openai-compatible; override for cloud kinds. */
39568
- baseUrl: string().optional(),
39569
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
39570
- apiKey: string().optional(),
39571
39850
  /** Vision on/off. A vision call against a `false` profile is REFUSED, never
39572
39851
  * degraded to text — that shipped once and produced a confident answer to a
39573
39852
  * question about a picture nobody sent. */
@@ -39575,15 +39854,11 @@ var LlmProfileSchema = object({
39575
39854
  temperature: number().min(0).max(2).optional(),
39576
39855
  /** Nucleus sampling. Every wire we speak has it. */
39577
39856
  topP: number().min(0).max(1).optional(),
39578
- /** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
39579
- * wire does, and the client drops it there (measured: the request body gets
39580
- * `top_p` and no `top_k`). The profile editor hides the field wherever it
39581
- * would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
39857
+ /** Top-k sampling. Carried only by the wires that have it — a kind offers the
39858
+ * field in its editor only when its descriptor lists it in `profileFields`. */
39582
39859
  topK: number().int().positive().optional(),
39583
39860
  maxTokens: number().int().positive().optional(),
39584
- /** Prompt context window. Advisory for cloud kinds (they enforce their own);
39585
- * for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
39586
- * the model with, so it is the one field that changes a PROCESS. */
39861
+ /** Prompt context window. Advisory for cloud kinds (they enforce their own). */
39587
39862
  contextLength: number().int().positive().optional(),
39588
39863
  /** Default system prompt. A caller's `system` REPLACES it (never appends —
39589
39864
  * two system prompts fighting is worse than either alone). */
@@ -39609,16 +39884,37 @@ var LlmProfileSchema = object({
39609
39884
  * library; the REGISTRY of callable tools is ours and is empty in v1, so a
39610
39885
  * `true` here buys the wiring, not behaviour, until tools are registered. */
39611
39886
  toolsEnabled: boolean().default(false),
39612
- extraHeaders: record(string(), string()).optional(),
39613
- /** kind === 'managed-local' only (spec §4). */
39614
- runtime: ManagedRuntimeConfigSchema.optional(),
39615
- /**
39616
- * kind === 'apple-foundation' only: WHERE it runs — the only thing there is
39617
- * to configure (no key, no URL, no download; `model` is `apple-system`).
39618
- * `supportsVision` on such a row is stamped by the provider from the node's
39619
- * reported `imageInput`, never taken from the operator (D62).
39620
- */
39621
- appleFoundation: object({ nodeId: string() }).optional()
39887
+ /** Everything the kind's provider owns (endpoint, key, node, runtime…). */
39888
+ providerConfig: LlmProviderConfigSchema.default({})
39889
+ });
39890
+ /**
39891
+ * The common profile fields a kind's editor offers. The editor owns how each
39892
+ * one is drawn; the provider says which of them mean something on its wire.
39893
+ */
39894
+ var LlmProfileFieldSchema = _enum([
39895
+ "temperature",
39896
+ "topP",
39897
+ "topK",
39898
+ "maxTokens",
39899
+ "contextLength",
39900
+ "systemPrompt",
39901
+ "timeoutMs",
39902
+ "connectTimeoutMs",
39903
+ "firstTokenTimeoutMs",
39904
+ "idleTimeoutMs",
39905
+ "retry",
39906
+ "toolsEnabled"
39907
+ ]);
39908
+ /**
39909
+ * A provider-drawn part of the editor, by a generic widget id the admin UI
39910
+ * registers (`ai/apple-node`). `placement: 'model'` replaces the generic model
39911
+ * picker: that widget owns the model choice.
39912
+ */
39913
+ var LlmProviderWidgetSchema = object({
39914
+ id: string(),
39915
+ placement: _enum(["connection", "model"]),
39916
+ /** `providerConfig` keys this widget must fill before the profile can be saved. */
39917
+ requires: array(string()).optional()
39622
39918
  });
39623
39919
  /** ConfigUISchema tree passed through untyped on the wire (the
39624
39920
  * notification-output `ConfigSchemaPassthrough` precedent at
@@ -39627,11 +39923,56 @@ var ConfigSchemaPassthrough$3 = unknown();
39627
39923
  var LlmProfileKindDescriptorSchema = object({
39628
39924
  kind: LlmProfileKindSchema,
39629
39925
  label: string(),
39926
+ /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
39630
39927
  icon: string(),
39631
39928
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
39632
39929
  addonId: string(),
39633
- configSchema: ConfigSchemaPassthrough$3
39930
+ /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
39931
+ connectionSchema: ConfigSchemaPassthrough$3,
39932
+ /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
39933
+ advancedSchema: ConfigSchemaPassthrough$3.optional(),
39934
+ /** The kind's defaults; a model from `listModels` may override any of them. */
39935
+ features: LlmModelFeaturesSchema,
39936
+ /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
39937
+ visionEditable: boolean(),
39938
+ /** Where the model list comes from: `listModels`, `staticModels`, or nowhere. */
39939
+ modelCatalog: _enum([
39940
+ "fetch",
39941
+ "static",
39942
+ "none"
39943
+ ]),
39944
+ staticModels: array(LlmModelInfoSchema).optional(),
39945
+ /** The common fields that mean something on this kind's wire. */
39946
+ profileFields: array(LlmProfileFieldSchema),
39947
+ providerWidgets: array(LlmProviderWidgetSchema).optional()
39948
+ });
39949
+ /**
39950
+ * `listModels` input. `connection` is an UNSAVED draft of `providerConfig`
39951
+ * (the editor's form); with `profileId` too, a secret the draft leaves
39952
+ * untouched (absent or the redaction marker) is resolved server-side from the
39953
+ * stored profile — the browser never receives it.
39954
+ */
39955
+ var LlmListModelsInputSchema = object({
39956
+ addonId: string(),
39957
+ kind: LlmProfileKindSchema,
39958
+ profileId: string().optional(),
39959
+ connection: LlmProviderConfigSchema.optional()
39634
39960
  });
39961
+ var LlmListModelsErrorCodeSchema = _enum([
39962
+ "auth",
39963
+ "network",
39964
+ "unsupported",
39965
+ "invalid"
39966
+ ]);
39967
+ /** A RESULT, never a throw: "wrong key" is an answer the editor renders inline. */
39968
+ var LlmListModelsResultSchema = discriminatedUnion("ok", [object({
39969
+ ok: literal(true),
39970
+ models: array(LlmModelInfoSchema)
39971
+ }), object({
39972
+ ok: literal(false),
39973
+ code: LlmListModelsErrorCodeSchema,
39974
+ message: string()
39975
+ })]);
39635
39976
  var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
39636
39977
  var LlmDefaultSchema = object({
39637
39978
  selector: LlmDefaultSelectorSchema,
@@ -39731,7 +40072,10 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
39731
40072
  kind: "mutation",
39732
40073
  auth: "admin",
39733
40074
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39734
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
40075
+ }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
40076
+ kind: "mutation",
40077
+ auth: "admin"
40078
+ }), method(object({}), array(LlmDefaultSchema)), method(object({
39735
40079
  selector: LlmDefaultSelectorSchema,
39736
40080
  profileId: string().nullable()
39737
40081
  }), _void(), {
@@ -43795,202 +44139,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
43795
44139
  auth: "admin"
43796
44140
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
43797
44141
  /**
43798
- * Zod schemas for persisted record types.
43799
- *
43800
- * These schemas serve as the single source of truth for types that are
43801
- * stored in the settings-store backend and retrieved via tRPC. They
43802
- * replace the manual TypeScript interfaces with schema-derived types,
43803
- * enabling runtime validation when reading from the backend.
43804
- *
43805
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
43806
- * keeps the original name for backward compatibility.
43807
- */
43808
- /**
43809
- * Auth model (v2 — 2026-05-12 caps-only):
43810
- *
43811
- * Two principals:
43812
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
43813
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
43814
- *
43815
- * No role enum. There used to be `viewer / agent / scoped` and earlier
43816
- * `super_admin` — collapsed onto the single boolean because every
43817
- * non-admin caller is governed by the same scope-check rules; the
43818
- * distinction was only ever used to route role-specific procedures
43819
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
43820
- * with `isAdmin: false` + an explicit scope list.
43821
- */
43822
- /** Per-method access flavour. Materialised on every cap method via codegen. */
43823
- var MethodAccessSchema = _enum([
43824
- "view",
43825
- "create",
43826
- "delete"
43827
- ]);
43828
- /**
43829
- * A single scope grant. Three forms — checked in matcher with OR
43830
- * semantics; the first match decides whether the call passes:
43831
- *
43832
- * - `category` — broadest. `target: 'device' | 'system'` selects every
43833
- * cap with the matching `scope` declaration. New caps inherit grants
43834
- * automatically — adding a device cap to the codebase makes it
43835
- * reachable to every user with `category:device [...]` without a
43836
- * re-grant. Use this for "family viewer" / "operator" tiers.
43837
- *
43838
- * - `addon` — every cap that ships inside a given addon id. Niche;
43839
- * useful when an integration needs to interact with one specific
43840
- * addon's surface regardless of how many caps it exports.
43841
- *
43842
- * - `capability` — the most precise form. Single cap name. Use for
43843
- * integration tokens where you want to grant `addons.installPackage`
43844
- * and nothing else.
43845
- *
43846
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
43847
- * "give me everything" escape; there is no wildcard scope.
43848
- */
43849
- var AllowedProviderSchema = union([literal("*"), array(string())]);
43850
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
43851
- var CapScopeSchema = _enum(["device", "system"]);
43852
- /**
43853
- * DeviceSelector (scope model v3 — 2026-08-12).
43854
- *
43855
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
43856
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
43857
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
43858
- * AFTER the grant was minted — no re-grant, no re-login.
43859
- *
43860
- * - `all` — every device in the deployment. The broad viewer/operator
43861
- * lever without a `category` grant (a `category` grant also covers device
43862
- * caps that carry no deviceId; `all` is specifically the device set).
43863
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
43864
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
43865
- * is NOT covered until the grant is edited.
43866
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
43867
- * DYNAMIC. A device that changes type, or a new device of the type,
43868
- * re-resolves on the next request.
43869
- * - `locations` — every device whose operator-assigned `location` label is
43870
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
43871
- * null/unset location matches NO `locations` selector.
43872
- */
43873
- var DeviceSelectorSchema = discriminatedUnion("kind", [
43874
- object({ kind: literal("all") }),
43875
- object({
43876
- kind: literal("ids"),
43877
- ids: array(number().int()).min(1)
43878
- }),
43879
- object({
43880
- kind: literal("types"),
43881
- types: array(_enum(DeviceType)).min(1)
43882
- }),
43883
- object({
43884
- kind: literal("locations"),
43885
- locations: array(string().min(1)).min(1)
43886
- })
43887
- ]);
43888
- var DeviceTokenScopeSchema = object({
43889
- type: literal("device"),
43890
- /** The device SET this grant covers — resolved against the live fleet. */
43891
- selector: DeviceSelectorSchema,
43892
- access: array(MethodAccessSchema).min(1),
43893
- /**
43894
- * Whether a grant on a PARENT device transparently covers its accessory
43895
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
43896
- * Direction is parent → children ONLY.
43897
- *
43898
- * Absent → the matcher DERIVES it from the access flavour: `view`
43899
- * inherits (a camera viewer sees the camera's accessories), `create` /
43900
- * `delete` do NOT (actuating/removing a child is an explicit act the
43901
- * operator must grant on the child, not inherit from the parent). Set it
43902
- * explicitly to override that default per grant.
43903
- */
43904
- includeLinked: boolean().optional()
43905
- });
43906
- /**
43907
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
43908
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
43909
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
43910
- * EVERY parse path — stored records AND the JWT-carried scope arrays
43911
- * normalised at the request boundary ({@link normalizeTokenScopes} in
43912
- * `device-selector.ts`). Chosen over a one-time DB migration because a
43913
- * migration cannot reach a JWT already in a client's hands; parse-time
43914
- * migration covers both without a flag day. No cast — the raw object is read
43915
- * through `Reflect.get` (its static type is `unknown`).
43916
- */
43917
- function migrateLegacyTokenScope(raw) {
43918
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
43919
- if (Reflect.get(raw, "type") !== "device") return raw;
43920
- if (Reflect.get(raw, "selector") !== void 0) return raw;
43921
- const targets = Reflect.get(raw, "targets");
43922
- if (!Array.isArray(targets)) return raw;
43923
- return {
43924
- type: "device",
43925
- selector: {
43926
- kind: "ids",
43927
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
43928
- },
43929
- access: Reflect.get(raw, "access")
43930
- };
43931
- }
43932
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
43933
- object({
43934
- type: literal("category"),
43935
- target: CapScopeSchema,
43936
- access: array(MethodAccessSchema).min(1)
43937
- }),
43938
- object({
43939
- type: literal("capability"),
43940
- target: string(),
43941
- access: array(MethodAccessSchema).min(1)
43942
- }),
43943
- object({
43944
- type: literal("addon"),
43945
- target: string(),
43946
- access: array(MethodAccessSchema).min(1)
43947
- }),
43948
- DeviceTokenScopeSchema
43949
- ]));
43950
- object({
43951
- id: string(),
43952
- username: string(),
43953
- passwordHash: string(),
43954
- /**
43955
- * Admin bypass. When true, the middleware skips the scope-access
43956
- * check entirely. There is no other axis of privilege; the legacy
43957
- * role enum collapsed onto this boolean in v2.
43958
- */
43959
- isAdmin: boolean().default(false),
43960
- allowedProviders: AllowedProviderSchema,
43961
- allowedDevices: AllowedDevicesSchema,
43962
- /**
43963
- * Scopes granted to this user. Admins bypass; their `scopes` is
43964
- * ignored. Non-admins without scopes are locked out of every
43965
- * protected call.
43966
- */
43967
- scopes: array(TokenScopeSchema).default([]),
43968
- createdAt: number(),
43969
- updatedAt: number()
43970
- });
43971
- object({
43972
- id: string(),
43973
- label: string(),
43974
- isAdmin: boolean().default(false),
43975
- allowedProviders: AllowedProviderSchema,
43976
- allowedDevices: AllowedDevicesSchema,
43977
- tokenHash: string(),
43978
- tokenPrefix: string(),
43979
- createdAt: number(),
43980
- lastUsedAt: number().optional()
43981
- });
43982
- object({
43983
- id: string(),
43984
- userId: string(),
43985
- name: string(),
43986
- tokenHash: string(),
43987
- tokenPrefix: string(),
43988
- scopes: array(TokenScopeSchema),
43989
- expiresAt: number().nullish(),
43990
- lastUsedAt: number().nullish(),
43991
- createdAt: number()
43992
- });
43993
- /**
43994
44142
  * `oauth-integration` — a collection cap by which an addon declares
43995
44143
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
43996
44144
  * Each provider returns a static descriptor; the core enumerates them
@@ -60957,26 +61105,6 @@ var ApiKeySummarySchema = object({
60957
61105
  createdAt: number(),
60958
61106
  lastUsedAt: number().optional()
60959
61107
  });
60960
- var ScopedTokenSummarySchema = object({
60961
- id: string(),
60962
- userId: string(),
60963
- name: string(),
60964
- tokenPrefix: string(),
60965
- scopes: array(TokenScopeSchema),
60966
- expiresAt: number().nullish(),
60967
- lastUsedAt: number().nullish(),
60968
- createdAt: number()
60969
- });
60970
- var CreateScopedTokenInputSchema = object({
60971
- userId: string(),
60972
- name: string(),
60973
- scopes: array(TokenScopeSchema),
60974
- expiresAt: number().optional()
60975
- });
60976
- var CreateScopedTokenResultSchema = object({
60977
- token: string(),
60978
- record: ScopedTokenSummarySchema
60979
- });
60980
61108
  var OauthSessionSummarySchema = object({
60981
61109
  id: string(),
60982
61110
  userId: string(),
@@ -60998,11 +61126,11 @@ var TotpStatusSchema = object({
60998
61126
  confirmedAt: number().nullable()
60999
61127
  });
61000
61128
  /**
61001
- * user-management — singleton capability for user accounts, API keys,
61002
- * and scoped tokens.
61129
+ * user-management — singleton capability for user accounts and the
61130
+ * legacy API-key rows.
61003
61131
  *
61004
61132
  * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
61005
- * — the subset check on `setUserScopes` / `createScopedToken` is moot
61133
+ * — the subset check on `setUserScopes` is moot
61006
61134
  * because non-admins never reach these. If/when we open non-admin
61007
61135
  * delegation, structural caller-scope subset check goes inside the
61008
61136
  * provider.
@@ -61059,15 +61187,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
61059
61187
  kind: "mutation",
61060
61188
  auth: "admin",
61061
61189
  access: "delete"
61062
- }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
61063
- kind: "mutation",
61064
- auth: "admin",
61065
- access: "create"
61066
- }), method(object({ id: string() }), object({ success: literal(true) }), {
61067
- kind: "mutation",
61068
- auth: "admin",
61069
- access: "delete"
61070
- }), method(object({ token: string() }), ScopedTokenSummarySchema.nullable(), { access: "view" }), method(object({ userId: string() }), array(ScopedTokenSummarySchema), { auth: "admin" }), method(object({ userId: string() }), TotpSetupResultSchema, {
61190
+ }), method(object({ userId: string() }), TotpSetupResultSchema, {
61071
61191
  kind: "mutation",
61072
61192
  auth: "admin",
61073
61193
  access: "create"
@@ -65223,7 +65343,7 @@ Object.freeze({
65223
65343
  capName: "llm",
65224
65344
  capScope: "system",
65225
65345
  addonId: null,
65226
- access: "view"
65346
+ access: "create"
65227
65347
  },
65228
65348
  "llm.listNodeModels": {
65229
65349
  capName: "llm",
@@ -69887,12 +70007,6 @@ Object.freeze({
69887
70007
  addonId: null,
69888
70008
  access: "create"
69889
70009
  },
69890
- "userManagement.createScopedToken": {
69891
- capName: "user-management",
69892
- capScope: "system",
69893
- addonId: null,
69894
- access: "create"
69895
- },
69896
70010
  "userManagement.createUser": {
69897
70011
  capName: "user-management",
69898
70012
  capScope: "system",
@@ -69941,12 +70055,6 @@ Object.freeze({
69941
70055
  addonId: null,
69942
70056
  access: "view"
69943
70057
  },
69944
- "userManagement.listScopedTokens": {
69945
- capName: "user-management",
69946
- capScope: "system",
69947
- addonId: null,
69948
- access: "view"
69949
- },
69950
70058
  "userManagement.listUsers": {
69951
70059
  capName: "user-management",
69952
70060
  capScope: "system",
@@ -70001,12 +70109,6 @@ Object.freeze({
70001
70109
  addonId: null,
70002
70110
  access: "delete"
70003
70111
  },
70004
- "userManagement.revokeScopedToken": {
70005
- capName: "user-management",
70006
- capScope: "system",
70007
- addonId: null,
70008
- access: "delete"
70009
- },
70010
70112
  "userManagement.setupTotp": {
70011
70113
  capName: "user-management",
70012
70114
  capScope: "system",
@@ -70037,12 +70139,6 @@ Object.freeze({
70037
70139
  addonId: null,
70038
70140
  access: "view"
70039
70141
  },
70040
- "userManagement.validateScopedToken": {
70041
- capName: "user-management",
70042
- capScope: "system",
70043
- addonId: null,
70044
- access: "view"
70045
- },
70046
70142
  "userManagement.verifyTotp": {
70047
70143
  capName: "user-management",
70048
70144
  capScope: "system",