@camstack/addon-terminal 0.1.135 → 0.1.137

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 (3) hide show
  1. package/dist/addon.js +390 -294
  2. package/dist/addon.mjs +390 -294
  3. package/package.json +1 -1
package/dist/addon.mjs CHANGED
@@ -5423,7 +5423,7 @@ var ZodIssueCode = {
5423
5423
  var ZodFirstPartyTypeKind;
5424
5424
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5425
5425
  //#endregion
5426
- //#region ../types/dist/sleep-BxjU_fJM.mjs
5426
+ //#region ../types/dist/sleep-yKL5gfrH.mjs
5427
5427
  /**
5428
5428
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5429
5429
  * window to float samples (D455).
@@ -7805,6 +7805,12 @@ function normalizeAddonInitResult(result) {
7805
7805
  if (Array.isArray(result)) return { providers: result };
7806
7806
  return result;
7807
7807
  }
7808
+ /**
7809
+ * The share-view scope kinds a share-link token can carry. The hub mints
7810
+ * and validates them (`ShareViewGrantSchema` builds its
7811
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
7812
+ */
7813
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7808
7814
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7809
7815
  var PeerBytesTicketSchema = object({
7810
7816
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12561,6 +12567,280 @@ var ConvertResultSchema = object({
12561
12567
  files: array(string()).readonly()
12562
12568
  })).readonly()
12563
12569
  });
12570
+ /**
12571
+ * Zod schemas for persisted record types.
12572
+ *
12573
+ * These schemas serve as the single source of truth for types that are
12574
+ * stored in the settings-store backend and retrieved via tRPC. They
12575
+ * replace the manual TypeScript interfaces with schema-derived types,
12576
+ * enabling runtime validation when reading from the backend.
12577
+ *
12578
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12579
+ * keeps the original name for backward compatibility.
12580
+ */
12581
+ /**
12582
+ * Auth model (v2 — 2026-05-12 caps-only):
12583
+ *
12584
+ * Two principals:
12585
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12586
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12587
+ *
12588
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12589
+ * `super_admin` — collapsed onto the single boolean because every
12590
+ * non-admin caller is governed by the same scope-check rules; the
12591
+ * distinction was only ever used to route role-specific procedures
12592
+ * which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
12593
+ * with `isAdmin: false` + an explicit scope list.
12594
+ */
12595
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12596
+ var MethodAccessSchema = _enum([
12597
+ "view",
12598
+ "create",
12599
+ "delete"
12600
+ ]);
12601
+ /**
12602
+ * A single scope grant. Three forms — checked in matcher with OR
12603
+ * semantics; the first match decides whether the call passes:
12604
+ *
12605
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12606
+ * cap with the matching `scope` declaration. New caps inherit grants
12607
+ * automatically — adding a device cap to the codebase makes it
12608
+ * reachable to every user with `category:device [...]` without a
12609
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12610
+ *
12611
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12612
+ * useful when an integration needs to interact with one specific
12613
+ * addon's surface regardless of how many caps it exports.
12614
+ *
12615
+ * - `capability` — the most precise form. Single cap name. Use for
12616
+ * integration tokens where you want to grant `addons.installPackage`
12617
+ * and nothing else.
12618
+ *
12619
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12620
+ * "give me everything" escape; there is no wildcard scope.
12621
+ */
12622
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12623
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12624
+ var CapScopeSchema = _enum(["device", "system"]);
12625
+ /**
12626
+ * DeviceSelector (scope model v3 — 2026-08-12).
12627
+ *
12628
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12629
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12630
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12631
+ * AFTER the grant was minted — no re-grant, no re-login.
12632
+ *
12633
+ * - `all` — every device in the deployment. The broad viewer/operator
12634
+ * lever without a `category` grant (a `category` grant also covers device
12635
+ * caps that carry no deviceId; `all` is specifically the device set).
12636
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
12637
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
12638
+ * is NOT covered until the grant is edited.
12639
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
12640
+ * DYNAMIC. A device that changes type, or a new device of the type,
12641
+ * re-resolves on the next request.
12642
+ * - `locations` — every device whose operator-assigned `location` label is
12643
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
12644
+ * null/unset location matches NO `locations` selector.
12645
+ */
12646
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
12647
+ object({ kind: literal("all") }),
12648
+ object({
12649
+ kind: literal("ids"),
12650
+ ids: array(number().int()).min(1)
12651
+ }),
12652
+ object({
12653
+ kind: literal("types"),
12654
+ types: array(_enum(DeviceType)).min(1)
12655
+ }),
12656
+ object({
12657
+ kind: literal("locations"),
12658
+ locations: array(string().min(1)).min(1)
12659
+ })
12660
+ ]);
12661
+ var DeviceTokenScopeSchema = object({
12662
+ type: literal("device"),
12663
+ /** The device SET this grant covers — resolved against the live fleet. */
12664
+ selector: DeviceSelectorSchema,
12665
+ access: array(MethodAccessSchema).min(1),
12666
+ /**
12667
+ * Whether a grant on a PARENT device transparently covers its accessory
12668
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
12669
+ * Direction is parent → children ONLY.
12670
+ *
12671
+ * Absent → the matcher DERIVES it from the access flavour: `view`
12672
+ * inherits (a camera viewer sees the camera's accessories), `create` /
12673
+ * `delete` do NOT (actuating/removing a child is an explicit act the
12674
+ * operator must grant on the child, not inherit from the parent). Set it
12675
+ * explicitly to override that default per grant.
12676
+ */
12677
+ includeLinked: boolean().optional()
12678
+ });
12679
+ /**
12680
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
12681
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
12682
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
12683
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
12684
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
12685
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
12686
+ * migration cannot reach a JWT already in a client's hands; parse-time
12687
+ * migration covers both without a flag day. No cast — the raw object is read
12688
+ * through `Reflect.get` (its static type is `unknown`).
12689
+ */
12690
+ function migrateLegacyTokenScope(raw) {
12691
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
12692
+ if (Reflect.get(raw, "type") !== "device") return raw;
12693
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
12694
+ const targets = Reflect.get(raw, "targets");
12695
+ if (!Array.isArray(targets)) return raw;
12696
+ return {
12697
+ type: "device",
12698
+ selector: {
12699
+ kind: "ids",
12700
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
12701
+ },
12702
+ access: Reflect.get(raw, "access")
12703
+ };
12704
+ }
12705
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
12706
+ object({
12707
+ type: literal("category"),
12708
+ target: CapScopeSchema,
12709
+ access: array(MethodAccessSchema).min(1)
12710
+ }),
12711
+ object({
12712
+ type: literal("capability"),
12713
+ target: string(),
12714
+ access: array(MethodAccessSchema).min(1)
12715
+ }),
12716
+ object({
12717
+ type: literal("addon"),
12718
+ target: string(),
12719
+ access: array(MethodAccessSchema).min(1)
12720
+ }),
12721
+ DeviceTokenScopeSchema
12722
+ ]));
12723
+ object({
12724
+ id: string(),
12725
+ username: string(),
12726
+ passwordHash: string(),
12727
+ /**
12728
+ * Admin bypass. When true, the middleware skips the scope-access
12729
+ * check entirely. There is no other axis of privilege; the legacy
12730
+ * role enum collapsed onto this boolean in v2.
12731
+ */
12732
+ isAdmin: boolean().default(false),
12733
+ allowedProviders: AllowedProviderSchema,
12734
+ allowedDevices: AllowedDevicesSchema,
12735
+ /**
12736
+ * Scopes granted to this user. Admins bypass; their `scopes` is
12737
+ * ignored. Non-admins without scopes are locked out of every
12738
+ * protected call.
12739
+ */
12740
+ scopes: array(TokenScopeSchema).default([]),
12741
+ createdAt: number(),
12742
+ updatedAt: number()
12743
+ });
12744
+ object({
12745
+ id: string(),
12746
+ label: string(),
12747
+ isAdmin: boolean().default(false),
12748
+ allowedProviders: AllowedProviderSchema,
12749
+ allowedDevices: AllowedDevicesSchema,
12750
+ tokenHash: string(),
12751
+ tokenPrefix: string(),
12752
+ createdAt: number(),
12753
+ lastUsedAt: number().optional()
12754
+ });
12755
+ object({
12756
+ id: string(),
12757
+ userId: string(),
12758
+ name: string(),
12759
+ tokenHash: string(),
12760
+ tokenPrefix: string(),
12761
+ scopes: array(TokenScopeSchema),
12762
+ expiresAt: number().nullish(),
12763
+ lastUsedAt: number().nullish(),
12764
+ createdAt: number()
12765
+ });
12766
+ /** What a share-view grant lets its holder see. */
12767
+ var ShareViewGrantSchema = object({
12768
+ kind: _enum(SHARE_VIEW_KINDS),
12769
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
12770
+ /** Talk-back, opt-in at mint time; absent means off. */
12771
+ talk: boolean().optional()
12772
+ });
12773
+ var ShareViewScopeSchema = object({
12774
+ type: literal("share-view"),
12775
+ grant: ShareViewGrantSchema
12776
+ });
12777
+ var AddonRoutesScopeSchema = object({
12778
+ type: literal("addon-routes"),
12779
+ access: array(MethodAccessSchema).min(1)
12780
+ });
12781
+ var PreferencesSelfScopeSchema = object({ type: literal("preferences-self") });
12782
+ var CredentialScopeSchema = union([
12783
+ literal("*"),
12784
+ ShareViewScopeSchema,
12785
+ AddonRoutesScopeSchema,
12786
+ PreferencesSelfScopeSchema,
12787
+ TokenScopeSchema
12788
+ ]);
12789
+ object({
12790
+ kind: literal("credential"),
12791
+ sub: string().min(1),
12792
+ jti: string().min(16),
12793
+ scopes: array(CredentialScopeSchema).min(1)
12794
+ });
12795
+ var PreferenceNamespaceSchema = string().regex(/^[a-z][a-z0-9.-]{0,63}$/);
12796
+ /** A namespace's value: a JSON object, opaque to the hub. */
12797
+ var PreferenceValueSchema = record(string(), unknown());
12798
+ var PreferenceDeviceIdSchema = string().min(1).max(64);
12799
+ /** A stored row, as the owner reads it. */
12800
+ var PreferenceRowSchema = object({
12801
+ namespace: PreferenceNamespaceSchema,
12802
+ value: PreferenceValueSchema,
12803
+ /** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
12804
+ revision: number().int().positive(),
12805
+ updatedAt: number().int(),
12806
+ /** The client id the last writer sent; `null` when it sent none. */
12807
+ updatedByDevice: PreferenceDeviceIdSchema.nullable()
12808
+ });
12809
+ object({
12810
+ /** Absent: every namespace the caller holds. */
12811
+ namespaces: array(PreferenceNamespaceSchema).max(32).optional() });
12812
+ object({ rows: array(PreferenceRowSchema) });
12813
+ object({
12814
+ namespace: PreferenceNamespaceSchema,
12815
+ value: PreferenceValueSchema,
12816
+ /**
12817
+ * The revision the edit was based on. Absent: last write wins. `0`: the
12818
+ * namespace must not exist yet. Any other value that is not the current
12819
+ * revision answers `conflict` and writes nothing.
12820
+ */
12821
+ baseRevision: number().int().nonnegative().optional(),
12822
+ deviceId: PreferenceDeviceIdSchema.optional()
12823
+ });
12824
+ discriminatedUnion("status", [object({
12825
+ status: literal("saved"),
12826
+ row: PreferenceRowSchema
12827
+ }), object({
12828
+ status: literal("conflict"),
12829
+ current: PreferenceRowSchema.nullable()
12830
+ })]);
12831
+ object({ namespace: PreferenceNamespaceSchema });
12832
+ object({
12833
+ /** `false` when the namespace did not exist. */
12834
+ deleted: boolean() });
12835
+ object({
12836
+ /** The revision the client holds per namespace; a namespace it does not list is new to it. */
12837
+ revisionByNamespace: record(PreferenceNamespaceSchema, number().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
12838
+ object({
12839
+ /** Every row whose revision differs from the client's, and every row it did not list. */
12840
+ rows: array(PreferenceRowSchema),
12841
+ /** Namespaces the client listed that no longer exist. */
12842
+ deleted: array(PreferenceNamespaceSchema)
12843
+ });
12564
12844
  _enum(["new-session", "step-up"]);
12565
12845
  /** The languages the hub's app landing pages are written in (D858). */
12566
12846
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -39656,38 +39936,37 @@ method(LlmRuntimeCompleteInputSchema, LlmGenerateResultSchema, {
39656
39936
  auth: "admin",
39657
39937
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39658
39938
  });
39939
+ var LlmProfileKindSchema = string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "a kind id is lower-case letters, digits and dashes");
39940
+ /** What a model (or, by default, every model of a kind) can do. */
39941
+ var LlmModelFeaturesSchema = object({
39942
+ vision: boolean(),
39943
+ tools: boolean(),
39944
+ streaming: boolean()
39945
+ });
39946
+ /** One model a provider offers. `features` overrides the kind's defaults, per field. */
39947
+ var LlmModelInfoSchema = object({
39948
+ id: string(),
39949
+ label: string().optional(),
39950
+ contextLength: number().int().positive().optional(),
39951
+ features: LlmModelFeaturesSchema.partial().optional()
39952
+ });
39659
39953
  /**
39660
- * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
39661
- * methods concat-fan across providers; single-row methods route to ONE
39662
- * provider by the `addonId` in the call input (the notification-output
39663
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
39664
- * (hub-placed); the cap stays open for future providers.
39665
- *
39666
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
39667
- * `apiKey` is a password field — providers REDACT it on read and merge on
39668
- * write; a stored key NEVER round-trips to a client.
39954
+ * The provider-specific part of a profile, validated by the provider that owns
39955
+ * the kind (`upsertProfile` refuses what it does not accept). A field its
39956
+ * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
39957
+ * keychain, never in the row, and reads back as the redaction marker.
39669
39958
  */
39670
- var LlmProfileKindSchema = _enum([
39671
- "openai-compatible",
39672
- "openai",
39673
- "anthropic",
39674
- "google",
39675
- "managed-local",
39676
- "apple-foundation"
39677
- ]);
39959
+ var LlmProviderConfigSchema = record(string(), unknown());
39678
39960
  var LlmProfileSchema = object({
39679
39961
  id: string(),
39680
39962
  name: string(),
39963
+ /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
39681
39964
  kind: LlmProfileKindSchema,
39682
39965
  /** Stamped by the provider — keeps the fanned catalog routable. */
39683
39966
  addonId: string(),
39684
39967
  enabled: boolean(),
39685
39968
  /** Vendor model id, or the managed runtime's loaded model. */
39686
39969
  model: string(),
39687
- /** Required for openai-compatible; override for cloud kinds. */
39688
- baseUrl: string().optional(),
39689
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
39690
- apiKey: string().optional(),
39691
39970
  /** Vision on/off. A vision call against a `false` profile is REFUSED, never
39692
39971
  * degraded to text — that shipped once and produced a confident answer to a
39693
39972
  * question about a picture nobody sent. */
@@ -39695,15 +39974,11 @@ var LlmProfileSchema = object({
39695
39974
  temperature: number().min(0).max(2).optional(),
39696
39975
  /** Nucleus sampling. Every wire we speak has it. */
39697
39976
  topP: number().min(0).max(1).optional(),
39698
- /** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
39699
- * wire does, and the client drops it there (measured: the request body gets
39700
- * `top_p` and no `top_k`). The profile editor hides the field wherever it
39701
- * would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
39977
+ /** Top-k sampling. Carried only by the wires that have it — a kind offers the
39978
+ * field in its editor only when its descriptor lists it in `profileFields`. */
39702
39979
  topK: number().int().positive().optional(),
39703
39980
  maxTokens: number().int().positive().optional(),
39704
- /** Prompt context window. Advisory for cloud kinds (they enforce their own);
39705
- * for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
39706
- * the model with, so it is the one field that changes a PROCESS. */
39981
+ /** Prompt context window. Advisory for cloud kinds (they enforce their own). */
39707
39982
  contextLength: number().int().positive().optional(),
39708
39983
  /** Default system prompt. A caller's `system` REPLACES it (never appends —
39709
39984
  * two system prompts fighting is worse than either alone). */
@@ -39729,16 +40004,37 @@ var LlmProfileSchema = object({
39729
40004
  * library; the REGISTRY of callable tools is ours and is empty in v1, so a
39730
40005
  * `true` here buys the wiring, not behaviour, until tools are registered. */
39731
40006
  toolsEnabled: boolean().default(false),
39732
- extraHeaders: record(string(), string()).optional(),
39733
- /** kind === 'managed-local' only (spec §4). */
39734
- runtime: ManagedRuntimeConfigSchema.optional(),
39735
- /**
39736
- * kind === 'apple-foundation' only: WHERE it runs — the only thing there is
39737
- * to configure (no key, no URL, no download; `model` is `apple-system`).
39738
- * `supportsVision` on such a row is stamped by the provider from the node's
39739
- * reported `imageInput`, never taken from the operator (D62).
39740
- */
39741
- appleFoundation: object({ nodeId: string() }).optional()
40007
+ /** Everything the kind's provider owns (endpoint, key, node, runtime…). */
40008
+ providerConfig: LlmProviderConfigSchema.default({})
40009
+ });
40010
+ /**
40011
+ * The common profile fields a kind's editor offers. The editor owns how each
40012
+ * one is drawn; the provider says which of them mean something on its wire.
40013
+ */
40014
+ var LlmProfileFieldSchema = _enum([
40015
+ "temperature",
40016
+ "topP",
40017
+ "topK",
40018
+ "maxTokens",
40019
+ "contextLength",
40020
+ "systemPrompt",
40021
+ "timeoutMs",
40022
+ "connectTimeoutMs",
40023
+ "firstTokenTimeoutMs",
40024
+ "idleTimeoutMs",
40025
+ "retry",
40026
+ "toolsEnabled"
40027
+ ]);
40028
+ /**
40029
+ * A provider-drawn part of the editor, by a generic widget id the admin UI
40030
+ * registers (`ai/apple-node`). `placement: 'model'` replaces the generic model
40031
+ * picker: that widget owns the model choice.
40032
+ */
40033
+ var LlmProviderWidgetSchema = object({
40034
+ id: string(),
40035
+ placement: _enum(["connection", "model"]),
40036
+ /** `providerConfig` keys this widget must fill before the profile can be saved. */
40037
+ requires: array(string()).optional()
39742
40038
  });
39743
40039
  /** ConfigUISchema tree passed through untyped on the wire (the
39744
40040
  * notification-output `ConfigSchemaPassthrough` precedent at
@@ -39747,11 +40043,56 @@ var ConfigSchemaPassthrough$3 = unknown();
39747
40043
  var LlmProfileKindDescriptorSchema = object({
39748
40044
  kind: LlmProfileKindSchema,
39749
40045
  label: string(),
40046
+ /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
39750
40047
  icon: string(),
39751
40048
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
39752
40049
  addonId: string(),
39753
- configSchema: ConfigSchemaPassthrough$3
40050
+ /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
40051
+ connectionSchema: ConfigSchemaPassthrough$3,
40052
+ /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
40053
+ advancedSchema: ConfigSchemaPassthrough$3.optional(),
40054
+ /** The kind's defaults; a model from `listModels` may override any of them. */
40055
+ features: LlmModelFeaturesSchema,
40056
+ /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
40057
+ visionEditable: boolean(),
40058
+ /** Where the model list comes from: `listModels`, `staticModels`, or nowhere. */
40059
+ modelCatalog: _enum([
40060
+ "fetch",
40061
+ "static",
40062
+ "none"
40063
+ ]),
40064
+ staticModels: array(LlmModelInfoSchema).optional(),
40065
+ /** The common fields that mean something on this kind's wire. */
40066
+ profileFields: array(LlmProfileFieldSchema),
40067
+ providerWidgets: array(LlmProviderWidgetSchema).optional()
40068
+ });
40069
+ /**
40070
+ * `listModels` input. `connection` is an UNSAVED draft of `providerConfig`
40071
+ * (the editor's form); with `profileId` too, a secret the draft leaves
40072
+ * untouched (absent or the redaction marker) is resolved server-side from the
40073
+ * stored profile — the browser never receives it.
40074
+ */
40075
+ var LlmListModelsInputSchema = object({
40076
+ addonId: string(),
40077
+ kind: LlmProfileKindSchema,
40078
+ profileId: string().optional(),
40079
+ connection: LlmProviderConfigSchema.optional()
39754
40080
  });
40081
+ var LlmListModelsErrorCodeSchema = _enum([
40082
+ "auth",
40083
+ "network",
40084
+ "unsupported",
40085
+ "invalid"
40086
+ ]);
40087
+ /** A RESULT, never a throw: "wrong key" is an answer the editor renders inline. */
40088
+ var LlmListModelsResultSchema = discriminatedUnion("ok", [object({
40089
+ ok: literal(true),
40090
+ models: array(LlmModelInfoSchema)
40091
+ }), object({
40092
+ ok: literal(false),
40093
+ code: LlmListModelsErrorCodeSchema,
40094
+ message: string()
40095
+ })]);
39755
40096
  var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
39756
40097
  var LlmDefaultSchema = object({
39757
40098
  selector: LlmDefaultSelectorSchema,
@@ -39851,7 +40192,10 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
39851
40192
  kind: "mutation",
39852
40193
  auth: "admin",
39853
40194
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39854
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
40195
+ }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
40196
+ kind: "mutation",
40197
+ auth: "admin"
40198
+ }), method(object({}), array(LlmDefaultSchema)), method(object({
39855
40199
  selector: LlmDefaultSelectorSchema,
39856
40200
  profileId: string().nullable()
39857
40201
  }), _void(), {
@@ -43957,202 +44301,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
43957
44301
  auth: "admin"
43958
44302
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
43959
44303
  /**
43960
- * Zod schemas for persisted record types.
43961
- *
43962
- * These schemas serve as the single source of truth for types that are
43963
- * stored in the settings-store backend and retrieved via tRPC. They
43964
- * replace the manual TypeScript interfaces with schema-derived types,
43965
- * enabling runtime validation when reading from the backend.
43966
- *
43967
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
43968
- * keeps the original name for backward compatibility.
43969
- */
43970
- /**
43971
- * Auth model (v2 — 2026-05-12 caps-only):
43972
- *
43973
- * Two principals:
43974
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
43975
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
43976
- *
43977
- * No role enum. There used to be `viewer / agent / scoped` and earlier
43978
- * `super_admin` — collapsed onto the single boolean because every
43979
- * non-admin caller is governed by the same scope-check rules; the
43980
- * distinction was only ever used to route role-specific procedures
43981
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
43982
- * with `isAdmin: false` + an explicit scope list.
43983
- */
43984
- /** Per-method access flavour. Materialised on every cap method via codegen. */
43985
- var MethodAccessSchema = _enum([
43986
- "view",
43987
- "create",
43988
- "delete"
43989
- ]);
43990
- /**
43991
- * A single scope grant. Three forms — checked in matcher with OR
43992
- * semantics; the first match decides whether the call passes:
43993
- *
43994
- * - `category` — broadest. `target: 'device' | 'system'` selects every
43995
- * cap with the matching `scope` declaration. New caps inherit grants
43996
- * automatically — adding a device cap to the codebase makes it
43997
- * reachable to every user with `category:device [...]` without a
43998
- * re-grant. Use this for "family viewer" / "operator" tiers.
43999
- *
44000
- * - `addon` — every cap that ships inside a given addon id. Niche;
44001
- * useful when an integration needs to interact with one specific
44002
- * addon's surface regardless of how many caps it exports.
44003
- *
44004
- * - `capability` — the most precise form. Single cap name. Use for
44005
- * integration tokens where you want to grant `addons.installPackage`
44006
- * and nothing else.
44007
- *
44008
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44009
- * "give me everything" escape; there is no wildcard scope.
44010
- */
44011
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44012
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44013
- var CapScopeSchema = _enum(["device", "system"]);
44014
- /**
44015
- * DeviceSelector (scope model v3 — 2026-08-12).
44016
- *
44017
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44018
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44019
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44020
- * AFTER the grant was minted — no re-grant, no re-login.
44021
- *
44022
- * - `all` — every device in the deployment. The broad viewer/operator
44023
- * lever without a `category` grant (a `category` grant also covers device
44024
- * caps that carry no deviceId; `all` is specifically the device set).
44025
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44026
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44027
- * is NOT covered until the grant is edited.
44028
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44029
- * DYNAMIC. A device that changes type, or a new device of the type,
44030
- * re-resolves on the next request.
44031
- * - `locations` — every device whose operator-assigned `location` label is
44032
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44033
- * null/unset location matches NO `locations` selector.
44034
- */
44035
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44036
- object({ kind: literal("all") }),
44037
- object({
44038
- kind: literal("ids"),
44039
- ids: array(number().int()).min(1)
44040
- }),
44041
- object({
44042
- kind: literal("types"),
44043
- types: array(_enum(DeviceType)).min(1)
44044
- }),
44045
- object({
44046
- kind: literal("locations"),
44047
- locations: array(string().min(1)).min(1)
44048
- })
44049
- ]);
44050
- var DeviceTokenScopeSchema = object({
44051
- type: literal("device"),
44052
- /** The device SET this grant covers — resolved against the live fleet. */
44053
- selector: DeviceSelectorSchema,
44054
- access: array(MethodAccessSchema).min(1),
44055
- /**
44056
- * Whether a grant on a PARENT device transparently covers its accessory
44057
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44058
- * Direction is parent → children ONLY.
44059
- *
44060
- * Absent → the matcher DERIVES it from the access flavour: `view`
44061
- * inherits (a camera viewer sees the camera's accessories), `create` /
44062
- * `delete` do NOT (actuating/removing a child is an explicit act the
44063
- * operator must grant on the child, not inherit from the parent). Set it
44064
- * explicitly to override that default per grant.
44065
- */
44066
- includeLinked: boolean().optional()
44067
- });
44068
- /**
44069
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44070
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44071
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44072
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44073
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44074
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44075
- * migration cannot reach a JWT already in a client's hands; parse-time
44076
- * migration covers both without a flag day. No cast — the raw object is read
44077
- * through `Reflect.get` (its static type is `unknown`).
44078
- */
44079
- function migrateLegacyTokenScope(raw) {
44080
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44081
- if (Reflect.get(raw, "type") !== "device") return raw;
44082
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44083
- const targets = Reflect.get(raw, "targets");
44084
- if (!Array.isArray(targets)) return raw;
44085
- return {
44086
- type: "device",
44087
- selector: {
44088
- kind: "ids",
44089
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44090
- },
44091
- access: Reflect.get(raw, "access")
44092
- };
44093
- }
44094
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44095
- object({
44096
- type: literal("category"),
44097
- target: CapScopeSchema,
44098
- access: array(MethodAccessSchema).min(1)
44099
- }),
44100
- object({
44101
- type: literal("capability"),
44102
- target: string(),
44103
- access: array(MethodAccessSchema).min(1)
44104
- }),
44105
- object({
44106
- type: literal("addon"),
44107
- target: string(),
44108
- access: array(MethodAccessSchema).min(1)
44109
- }),
44110
- DeviceTokenScopeSchema
44111
- ]));
44112
- object({
44113
- id: string(),
44114
- username: string(),
44115
- passwordHash: string(),
44116
- /**
44117
- * Admin bypass. When true, the middleware skips the scope-access
44118
- * check entirely. There is no other axis of privilege; the legacy
44119
- * role enum collapsed onto this boolean in v2.
44120
- */
44121
- isAdmin: boolean().default(false),
44122
- allowedProviders: AllowedProviderSchema,
44123
- allowedDevices: AllowedDevicesSchema,
44124
- /**
44125
- * Scopes granted to this user. Admins bypass; their `scopes` is
44126
- * ignored. Non-admins without scopes are locked out of every
44127
- * protected call.
44128
- */
44129
- scopes: array(TokenScopeSchema).default([]),
44130
- createdAt: number(),
44131
- updatedAt: number()
44132
- });
44133
- object({
44134
- id: string(),
44135
- label: string(),
44136
- isAdmin: boolean().default(false),
44137
- allowedProviders: AllowedProviderSchema,
44138
- allowedDevices: AllowedDevicesSchema,
44139
- tokenHash: string(),
44140
- tokenPrefix: string(),
44141
- createdAt: number(),
44142
- lastUsedAt: number().optional()
44143
- });
44144
- object({
44145
- id: string(),
44146
- userId: string(),
44147
- name: string(),
44148
- tokenHash: string(),
44149
- tokenPrefix: string(),
44150
- scopes: array(TokenScopeSchema),
44151
- expiresAt: number().nullish(),
44152
- lastUsedAt: number().nullish(),
44153
- createdAt: number()
44154
- });
44155
- /**
44156
44304
  * `oauth-integration` — a collection cap by which an addon declares
44157
44305
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44158
44306
  * Each provider returns a static descriptor; the core enumerates them
@@ -64083,26 +64231,6 @@ var ApiKeySummarySchema = object({
64083
64231
  createdAt: number(),
64084
64232
  lastUsedAt: number().optional()
64085
64233
  });
64086
- var ScopedTokenSummarySchema = object({
64087
- id: string(),
64088
- userId: string(),
64089
- name: string(),
64090
- tokenPrefix: string(),
64091
- scopes: array(TokenScopeSchema),
64092
- expiresAt: number().nullish(),
64093
- lastUsedAt: number().nullish(),
64094
- createdAt: number()
64095
- });
64096
- var CreateScopedTokenInputSchema = object({
64097
- userId: string(),
64098
- name: string(),
64099
- scopes: array(TokenScopeSchema),
64100
- expiresAt: number().optional()
64101
- });
64102
- var CreateScopedTokenResultSchema = object({
64103
- token: string(),
64104
- record: ScopedTokenSummarySchema
64105
- });
64106
64234
  var OauthSessionSummarySchema = object({
64107
64235
  id: string(),
64108
64236
  userId: string(),
@@ -64124,11 +64252,11 @@ var TotpStatusSchema = object({
64124
64252
  confirmedAt: number().nullable()
64125
64253
  });
64126
64254
  /**
64127
- * user-management — singleton capability for user accounts, API keys,
64128
- * and scoped tokens.
64255
+ * user-management — singleton capability for user accounts and the
64256
+ * legacy API-key rows.
64129
64257
  *
64130
64258
  * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
64131
- * — the subset check on `setUserScopes` / `createScopedToken` is moot
64259
+ * — the subset check on `setUserScopes` is moot
64132
64260
  * because non-admins never reach these. If/when we open non-admin
64133
64261
  * delegation, structural caller-scope subset check goes inside the
64134
64262
  * provider.
@@ -64185,15 +64313,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
64185
64313
  kind: "mutation",
64186
64314
  auth: "admin",
64187
64315
  access: "delete"
64188
- }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
64189
- kind: "mutation",
64190
- auth: "admin",
64191
- access: "create"
64192
- }), method(object({ id: string() }), object({ success: literal(true) }), {
64193
- kind: "mutation",
64194
- auth: "admin",
64195
- access: "delete"
64196
- }), method(object({ token: string() }), ScopedTokenSummarySchema.nullable(), { access: "view" }), method(object({ userId: string() }), array(ScopedTokenSummarySchema), { auth: "admin" }), method(object({ userId: string() }), TotpSetupResultSchema, {
64316
+ }), method(object({ userId: string() }), TotpSetupResultSchema, {
64197
64317
  kind: "mutation",
64198
64318
  auth: "admin",
64199
64319
  access: "create"
@@ -69800,7 +69920,7 @@ Object.freeze({
69800
69920
  capName: "llm",
69801
69921
  capScope: "system",
69802
69922
  addonId: null,
69803
- access: "view"
69923
+ access: "create"
69804
69924
  },
69805
69925
  "llm.listNodeModels": {
69806
69926
  capName: "llm",
@@ -74464,12 +74584,6 @@ Object.freeze({
74464
74584
  addonId: null,
74465
74585
  access: "create"
74466
74586
  },
74467
- "userManagement.createScopedToken": {
74468
- capName: "user-management",
74469
- capScope: "system",
74470
- addonId: null,
74471
- access: "create"
74472
- },
74473
74587
  "userManagement.createUser": {
74474
74588
  capName: "user-management",
74475
74589
  capScope: "system",
@@ -74518,12 +74632,6 @@ Object.freeze({
74518
74632
  addonId: null,
74519
74633
  access: "view"
74520
74634
  },
74521
- "userManagement.listScopedTokens": {
74522
- capName: "user-management",
74523
- capScope: "system",
74524
- addonId: null,
74525
- access: "view"
74526
- },
74527
74635
  "userManagement.listUsers": {
74528
74636
  capName: "user-management",
74529
74637
  capScope: "system",
@@ -74578,12 +74686,6 @@ Object.freeze({
74578
74686
  addonId: null,
74579
74687
  access: "delete"
74580
74688
  },
74581
- "userManagement.revokeScopedToken": {
74582
- capName: "user-management",
74583
- capScope: "system",
74584
- addonId: null,
74585
- access: "delete"
74586
- },
74587
74689
  "userManagement.setupTotp": {
74588
74690
  capName: "user-management",
74589
74691
  capScope: "system",
@@ -74614,12 +74716,6 @@ Object.freeze({
74614
74716
  addonId: null,
74615
74717
  access: "view"
74616
74718
  },
74617
- "userManagement.validateScopedToken": {
74618
- capName: "user-management",
74619
- capScope: "system",
74620
- addonId: null,
74621
- access: "view"
74622
- },
74623
74719
  "userManagement.verifyTotp": {
74624
74720
  capName: "user-management",
74625
74721
  capScope: "system",