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