@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.js CHANGED
@@ -5446,7 +5446,7 @@ var ZodIssueCode = {
5446
5446
  var ZodFirstPartyTypeKind;
5447
5447
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5448
5448
  //#endregion
5449
- //#region ../types/dist/sleep-BxjU_fJM.mjs
5449
+ //#region ../types/dist/sleep-yKL5gfrH.mjs
5450
5450
  /**
5451
5451
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5452
5452
  * window to float samples (D455).
@@ -7828,6 +7828,12 @@ function normalizeAddonInitResult(result) {
7828
7828
  if (Array.isArray(result)) return { providers: result };
7829
7829
  return result;
7830
7830
  }
7831
+ /**
7832
+ * The share-view scope kinds a share-link token can carry. The hub mints
7833
+ * and validates them (`ShareViewGrantSchema` builds its
7834
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
7835
+ */
7836
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7831
7837
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7832
7838
  var PeerBytesTicketSchema = object({
7833
7839
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12584,6 +12590,280 @@ var ConvertResultSchema = object({
12584
12590
  files: array(string()).readonly()
12585
12591
  })).readonly()
12586
12592
  });
12593
+ /**
12594
+ * Zod schemas for persisted record types.
12595
+ *
12596
+ * These schemas serve as the single source of truth for types that are
12597
+ * stored in the settings-store backend and retrieved via tRPC. They
12598
+ * replace the manual TypeScript interfaces with schema-derived types,
12599
+ * enabling runtime validation when reading from the backend.
12600
+ *
12601
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12602
+ * keeps the original name for backward compatibility.
12603
+ */
12604
+ /**
12605
+ * Auth model (v2 — 2026-05-12 caps-only):
12606
+ *
12607
+ * Two principals:
12608
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12609
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12610
+ *
12611
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12612
+ * `super_admin` — collapsed onto the single boolean because every
12613
+ * non-admin caller is governed by the same scope-check rules; the
12614
+ * distinction was only ever used to route role-specific procedures
12615
+ * which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
12616
+ * with `isAdmin: false` + an explicit scope list.
12617
+ */
12618
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12619
+ var MethodAccessSchema = _enum([
12620
+ "view",
12621
+ "create",
12622
+ "delete"
12623
+ ]);
12624
+ /**
12625
+ * A single scope grant. Three forms — checked in matcher with OR
12626
+ * semantics; the first match decides whether the call passes:
12627
+ *
12628
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12629
+ * cap with the matching `scope` declaration. New caps inherit grants
12630
+ * automatically — adding a device cap to the codebase makes it
12631
+ * reachable to every user with `category:device [...]` without a
12632
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12633
+ *
12634
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12635
+ * useful when an integration needs to interact with one specific
12636
+ * addon's surface regardless of how many caps it exports.
12637
+ *
12638
+ * - `capability` — the most precise form. Single cap name. Use for
12639
+ * integration tokens where you want to grant `addons.installPackage`
12640
+ * and nothing else.
12641
+ *
12642
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12643
+ * "give me everything" escape; there is no wildcard scope.
12644
+ */
12645
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12646
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12647
+ var CapScopeSchema = _enum(["device", "system"]);
12648
+ /**
12649
+ * DeviceSelector (scope model v3 — 2026-08-12).
12650
+ *
12651
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12652
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12653
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12654
+ * AFTER the grant was minted — no re-grant, no re-login.
12655
+ *
12656
+ * - `all` — every device in the deployment. The broad viewer/operator
12657
+ * lever without a `category` grant (a `category` grant also covers device
12658
+ * caps that carry no deviceId; `all` is specifically the device set).
12659
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
12660
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
12661
+ * is NOT covered until the grant is edited.
12662
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
12663
+ * DYNAMIC. A device that changes type, or a new device of the type,
12664
+ * re-resolves on the next request.
12665
+ * - `locations` — every device whose operator-assigned `location` label is
12666
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
12667
+ * null/unset location matches NO `locations` selector.
12668
+ */
12669
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
12670
+ object({ kind: literal("all") }),
12671
+ object({
12672
+ kind: literal("ids"),
12673
+ ids: array(number().int()).min(1)
12674
+ }),
12675
+ object({
12676
+ kind: literal("types"),
12677
+ types: array(_enum(DeviceType)).min(1)
12678
+ }),
12679
+ object({
12680
+ kind: literal("locations"),
12681
+ locations: array(string().min(1)).min(1)
12682
+ })
12683
+ ]);
12684
+ var DeviceTokenScopeSchema = object({
12685
+ type: literal("device"),
12686
+ /** The device SET this grant covers — resolved against the live fleet. */
12687
+ selector: DeviceSelectorSchema,
12688
+ access: array(MethodAccessSchema).min(1),
12689
+ /**
12690
+ * Whether a grant on a PARENT device transparently covers its accessory
12691
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
12692
+ * Direction is parent → children ONLY.
12693
+ *
12694
+ * Absent → the matcher DERIVES it from the access flavour: `view`
12695
+ * inherits (a camera viewer sees the camera's accessories), `create` /
12696
+ * `delete` do NOT (actuating/removing a child is an explicit act the
12697
+ * operator must grant on the child, not inherit from the parent). Set it
12698
+ * explicitly to override that default per grant.
12699
+ */
12700
+ includeLinked: boolean().optional()
12701
+ });
12702
+ /**
12703
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
12704
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
12705
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
12706
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
12707
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
12708
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
12709
+ * migration cannot reach a JWT already in a client's hands; parse-time
12710
+ * migration covers both without a flag day. No cast — the raw object is read
12711
+ * through `Reflect.get` (its static type is `unknown`).
12712
+ */
12713
+ function migrateLegacyTokenScope(raw) {
12714
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
12715
+ if (Reflect.get(raw, "type") !== "device") return raw;
12716
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
12717
+ const targets = Reflect.get(raw, "targets");
12718
+ if (!Array.isArray(targets)) return raw;
12719
+ return {
12720
+ type: "device",
12721
+ selector: {
12722
+ kind: "ids",
12723
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
12724
+ },
12725
+ access: Reflect.get(raw, "access")
12726
+ };
12727
+ }
12728
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
12729
+ object({
12730
+ type: literal("category"),
12731
+ target: CapScopeSchema,
12732
+ access: array(MethodAccessSchema).min(1)
12733
+ }),
12734
+ object({
12735
+ type: literal("capability"),
12736
+ target: string(),
12737
+ access: array(MethodAccessSchema).min(1)
12738
+ }),
12739
+ object({
12740
+ type: literal("addon"),
12741
+ target: string(),
12742
+ access: array(MethodAccessSchema).min(1)
12743
+ }),
12744
+ DeviceTokenScopeSchema
12745
+ ]));
12746
+ object({
12747
+ id: string(),
12748
+ username: string(),
12749
+ passwordHash: string(),
12750
+ /**
12751
+ * Admin bypass. When true, the middleware skips the scope-access
12752
+ * check entirely. There is no other axis of privilege; the legacy
12753
+ * role enum collapsed onto this boolean in v2.
12754
+ */
12755
+ isAdmin: boolean().default(false),
12756
+ allowedProviders: AllowedProviderSchema,
12757
+ allowedDevices: AllowedDevicesSchema,
12758
+ /**
12759
+ * Scopes granted to this user. Admins bypass; their `scopes` is
12760
+ * ignored. Non-admins without scopes are locked out of every
12761
+ * protected call.
12762
+ */
12763
+ scopes: array(TokenScopeSchema).default([]),
12764
+ createdAt: number(),
12765
+ updatedAt: number()
12766
+ });
12767
+ object({
12768
+ id: string(),
12769
+ label: string(),
12770
+ isAdmin: boolean().default(false),
12771
+ allowedProviders: AllowedProviderSchema,
12772
+ allowedDevices: AllowedDevicesSchema,
12773
+ tokenHash: string(),
12774
+ tokenPrefix: string(),
12775
+ createdAt: number(),
12776
+ lastUsedAt: number().optional()
12777
+ });
12778
+ object({
12779
+ id: string(),
12780
+ userId: string(),
12781
+ name: string(),
12782
+ tokenHash: string(),
12783
+ tokenPrefix: string(),
12784
+ scopes: array(TokenScopeSchema),
12785
+ expiresAt: number().nullish(),
12786
+ lastUsedAt: number().nullish(),
12787
+ createdAt: number()
12788
+ });
12789
+ /** What a share-view grant lets its holder see. */
12790
+ var ShareViewGrantSchema = object({
12791
+ kind: _enum(SHARE_VIEW_KINDS),
12792
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
12793
+ /** Talk-back, opt-in at mint time; absent means off. */
12794
+ talk: boolean().optional()
12795
+ });
12796
+ var ShareViewScopeSchema = object({
12797
+ type: literal("share-view"),
12798
+ grant: ShareViewGrantSchema
12799
+ });
12800
+ var AddonRoutesScopeSchema = object({
12801
+ type: literal("addon-routes"),
12802
+ access: array(MethodAccessSchema).min(1)
12803
+ });
12804
+ var PreferencesSelfScopeSchema = object({ type: literal("preferences-self") });
12805
+ var CredentialScopeSchema = union([
12806
+ literal("*"),
12807
+ ShareViewScopeSchema,
12808
+ AddonRoutesScopeSchema,
12809
+ PreferencesSelfScopeSchema,
12810
+ TokenScopeSchema
12811
+ ]);
12812
+ object({
12813
+ kind: literal("credential"),
12814
+ sub: string().min(1),
12815
+ jti: string().min(16),
12816
+ scopes: array(CredentialScopeSchema).min(1)
12817
+ });
12818
+ var PreferenceNamespaceSchema = string().regex(/^[a-z][a-z0-9.-]{0,63}$/);
12819
+ /** A namespace's value: a JSON object, opaque to the hub. */
12820
+ var PreferenceValueSchema = record(string(), unknown());
12821
+ var PreferenceDeviceIdSchema = string().min(1).max(64);
12822
+ /** A stored row, as the owner reads it. */
12823
+ var PreferenceRowSchema = object({
12824
+ namespace: PreferenceNamespaceSchema,
12825
+ value: PreferenceValueSchema,
12826
+ /** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
12827
+ revision: number().int().positive(),
12828
+ updatedAt: number().int(),
12829
+ /** The client id the last writer sent; `null` when it sent none. */
12830
+ updatedByDevice: PreferenceDeviceIdSchema.nullable()
12831
+ });
12832
+ object({
12833
+ /** Absent: every namespace the caller holds. */
12834
+ namespaces: array(PreferenceNamespaceSchema).max(32).optional() });
12835
+ object({ rows: array(PreferenceRowSchema) });
12836
+ object({
12837
+ namespace: PreferenceNamespaceSchema,
12838
+ value: PreferenceValueSchema,
12839
+ /**
12840
+ * The revision the edit was based on. Absent: last write wins. `0`: the
12841
+ * namespace must not exist yet. Any other value that is not the current
12842
+ * revision answers `conflict` and writes nothing.
12843
+ */
12844
+ baseRevision: number().int().nonnegative().optional(),
12845
+ deviceId: PreferenceDeviceIdSchema.optional()
12846
+ });
12847
+ discriminatedUnion("status", [object({
12848
+ status: literal("saved"),
12849
+ row: PreferenceRowSchema
12850
+ }), object({
12851
+ status: literal("conflict"),
12852
+ current: PreferenceRowSchema.nullable()
12853
+ })]);
12854
+ object({ namespace: PreferenceNamespaceSchema });
12855
+ object({
12856
+ /** `false` when the namespace did not exist. */
12857
+ deleted: boolean() });
12858
+ object({
12859
+ /** The revision the client holds per namespace; a namespace it does not list is new to it. */
12860
+ revisionByNamespace: record(PreferenceNamespaceSchema, number().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
12861
+ object({
12862
+ /** Every row whose revision differs from the client's, and every row it did not list. */
12863
+ rows: array(PreferenceRowSchema),
12864
+ /** Namespaces the client listed that no longer exist. */
12865
+ deleted: array(PreferenceNamespaceSchema)
12866
+ });
12587
12867
  _enum(["new-session", "step-up"]);
12588
12868
  /** The languages the hub's app landing pages are written in (D858). */
12589
12869
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -39679,38 +39959,37 @@ method(LlmRuntimeCompleteInputSchema, LlmGenerateResultSchema, {
39679
39959
  auth: "admin",
39680
39960
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39681
39961
  });
39962
+ var LlmProfileKindSchema = string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "a kind id is lower-case letters, digits and dashes");
39963
+ /** What a model (or, by default, every model of a kind) can do. */
39964
+ var LlmModelFeaturesSchema = object({
39965
+ vision: boolean(),
39966
+ tools: boolean(),
39967
+ streaming: boolean()
39968
+ });
39969
+ /** One model a provider offers. `features` overrides the kind's defaults, per field. */
39970
+ var LlmModelInfoSchema = object({
39971
+ id: string(),
39972
+ label: string().optional(),
39973
+ contextLength: number().int().positive().optional(),
39974
+ features: LlmModelFeaturesSchema.partial().optional()
39975
+ });
39682
39976
  /**
39683
- * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
39684
- * methods concat-fan across providers; single-row methods route to ONE
39685
- * provider by the `addonId` in the call input (the notification-output
39686
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
39687
- * (hub-placed); the cap stays open for future providers.
39688
- *
39689
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
39690
- * `apiKey` is a password field — providers REDACT it on read and merge on
39691
- * write; a stored key NEVER round-trips to a client.
39977
+ * The provider-specific part of a profile, validated by the provider that owns
39978
+ * the kind (`upsertProfile` refuses what it does not accept). A field its
39979
+ * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
39980
+ * keychain, never in the row, and reads back as the redaction marker.
39692
39981
  */
39693
- var LlmProfileKindSchema = _enum([
39694
- "openai-compatible",
39695
- "openai",
39696
- "anthropic",
39697
- "google",
39698
- "managed-local",
39699
- "apple-foundation"
39700
- ]);
39982
+ var LlmProviderConfigSchema = record(string(), unknown());
39701
39983
  var LlmProfileSchema = object({
39702
39984
  id: string(),
39703
39985
  name: string(),
39986
+ /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
39704
39987
  kind: LlmProfileKindSchema,
39705
39988
  /** Stamped by the provider — keeps the fanned catalog routable. */
39706
39989
  addonId: string(),
39707
39990
  enabled: boolean(),
39708
39991
  /** Vendor model id, or the managed runtime's loaded model. */
39709
39992
  model: string(),
39710
- /** Required for openai-compatible; override for cloud kinds. */
39711
- baseUrl: string().optional(),
39712
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
39713
- apiKey: string().optional(),
39714
39993
  /** Vision on/off. A vision call against a `false` profile is REFUSED, never
39715
39994
  * degraded to text — that shipped once and produced a confident answer to a
39716
39995
  * question about a picture nobody sent. */
@@ -39718,15 +39997,11 @@ var LlmProfileSchema = object({
39718
39997
  temperature: number().min(0).max(2).optional(),
39719
39998
  /** Nucleus sampling. Every wire we speak has it. */
39720
39999
  topP: number().min(0).max(1).optional(),
39721
- /** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
39722
- * wire does, and the client drops it there (measured: the request body gets
39723
- * `top_p` and no `top_k`). The profile editor hides the field wherever it
39724
- * would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
40000
+ /** Top-k sampling. Carried only by the wires that have it — a kind offers the
40001
+ * field in its editor only when its descriptor lists it in `profileFields`. */
39725
40002
  topK: number().int().positive().optional(),
39726
40003
  maxTokens: number().int().positive().optional(),
39727
- /** Prompt context window. Advisory for cloud kinds (they enforce their own);
39728
- * for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
39729
- * the model with, so it is the one field that changes a PROCESS. */
40004
+ /** Prompt context window. Advisory for cloud kinds (they enforce their own). */
39730
40005
  contextLength: number().int().positive().optional(),
39731
40006
  /** Default system prompt. A caller's `system` REPLACES it (never appends —
39732
40007
  * two system prompts fighting is worse than either alone). */
@@ -39752,16 +40027,37 @@ var LlmProfileSchema = object({
39752
40027
  * library; the REGISTRY of callable tools is ours and is empty in v1, so a
39753
40028
  * `true` here buys the wiring, not behaviour, until tools are registered. */
39754
40029
  toolsEnabled: boolean().default(false),
39755
- extraHeaders: record(string(), string()).optional(),
39756
- /** kind === 'managed-local' only (spec §4). */
39757
- runtime: ManagedRuntimeConfigSchema.optional(),
39758
- /**
39759
- * kind === 'apple-foundation' only: WHERE it runs — the only thing there is
39760
- * to configure (no key, no URL, no download; `model` is `apple-system`).
39761
- * `supportsVision` on such a row is stamped by the provider from the node's
39762
- * reported `imageInput`, never taken from the operator (D62).
39763
- */
39764
- appleFoundation: object({ nodeId: string() }).optional()
40030
+ /** Everything the kind's provider owns (endpoint, key, node, runtime…). */
40031
+ providerConfig: LlmProviderConfigSchema.default({})
40032
+ });
40033
+ /**
40034
+ * The common profile fields a kind's editor offers. The editor owns how each
40035
+ * one is drawn; the provider says which of them mean something on its wire.
40036
+ */
40037
+ var LlmProfileFieldSchema = _enum([
40038
+ "temperature",
40039
+ "topP",
40040
+ "topK",
40041
+ "maxTokens",
40042
+ "contextLength",
40043
+ "systemPrompt",
40044
+ "timeoutMs",
40045
+ "connectTimeoutMs",
40046
+ "firstTokenTimeoutMs",
40047
+ "idleTimeoutMs",
40048
+ "retry",
40049
+ "toolsEnabled"
40050
+ ]);
40051
+ /**
40052
+ * A provider-drawn part of the editor, by a generic widget id the admin UI
40053
+ * registers (`ai/apple-node`). `placement: 'model'` replaces the generic model
40054
+ * picker: that widget owns the model choice.
40055
+ */
40056
+ var LlmProviderWidgetSchema = object({
40057
+ id: string(),
40058
+ placement: _enum(["connection", "model"]),
40059
+ /** `providerConfig` keys this widget must fill before the profile can be saved. */
40060
+ requires: array(string()).optional()
39765
40061
  });
39766
40062
  /** ConfigUISchema tree passed through untyped on the wire (the
39767
40063
  * notification-output `ConfigSchemaPassthrough` precedent at
@@ -39770,11 +40066,56 @@ var ConfigSchemaPassthrough$3 = unknown();
39770
40066
  var LlmProfileKindDescriptorSchema = object({
39771
40067
  kind: LlmProfileKindSchema,
39772
40068
  label: string(),
40069
+ /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
39773
40070
  icon: string(),
39774
40071
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
39775
40072
  addonId: string(),
39776
- configSchema: ConfigSchemaPassthrough$3
40073
+ /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
40074
+ connectionSchema: ConfigSchemaPassthrough$3,
40075
+ /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
40076
+ advancedSchema: ConfigSchemaPassthrough$3.optional(),
40077
+ /** The kind's defaults; a model from `listModels` may override any of them. */
40078
+ features: LlmModelFeaturesSchema,
40079
+ /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
40080
+ visionEditable: boolean(),
40081
+ /** Where the model list comes from: `listModels`, `staticModels`, or nowhere. */
40082
+ modelCatalog: _enum([
40083
+ "fetch",
40084
+ "static",
40085
+ "none"
40086
+ ]),
40087
+ staticModels: array(LlmModelInfoSchema).optional(),
40088
+ /** The common fields that mean something on this kind's wire. */
40089
+ profileFields: array(LlmProfileFieldSchema),
40090
+ providerWidgets: array(LlmProviderWidgetSchema).optional()
40091
+ });
40092
+ /**
40093
+ * `listModels` input. `connection` is an UNSAVED draft of `providerConfig`
40094
+ * (the editor's form); with `profileId` too, a secret the draft leaves
40095
+ * untouched (absent or the redaction marker) is resolved server-side from the
40096
+ * stored profile — the browser never receives it.
40097
+ */
40098
+ var LlmListModelsInputSchema = object({
40099
+ addonId: string(),
40100
+ kind: LlmProfileKindSchema,
40101
+ profileId: string().optional(),
40102
+ connection: LlmProviderConfigSchema.optional()
39777
40103
  });
40104
+ var LlmListModelsErrorCodeSchema = _enum([
40105
+ "auth",
40106
+ "network",
40107
+ "unsupported",
40108
+ "invalid"
40109
+ ]);
40110
+ /** A RESULT, never a throw: "wrong key" is an answer the editor renders inline. */
40111
+ var LlmListModelsResultSchema = discriminatedUnion("ok", [object({
40112
+ ok: literal(true),
40113
+ models: array(LlmModelInfoSchema)
40114
+ }), object({
40115
+ ok: literal(false),
40116
+ code: LlmListModelsErrorCodeSchema,
40117
+ message: string()
40118
+ })]);
39778
40119
  var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
39779
40120
  var LlmDefaultSchema = object({
39780
40121
  selector: LlmDefaultSelectorSchema,
@@ -39874,7 +40215,10 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
39874
40215
  kind: "mutation",
39875
40216
  auth: "admin",
39876
40217
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
39877
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
40218
+ }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
40219
+ kind: "mutation",
40220
+ auth: "admin"
40221
+ }), method(object({}), array(LlmDefaultSchema)), method(object({
39878
40222
  selector: LlmDefaultSelectorSchema,
39879
40223
  profileId: string().nullable()
39880
40224
  }), _void(), {
@@ -43980,202 +44324,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
43980
44324
  auth: "admin"
43981
44325
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
43982
44326
  /**
43983
- * Zod schemas for persisted record types.
43984
- *
43985
- * These schemas serve as the single source of truth for types that are
43986
- * stored in the settings-store backend and retrieved via tRPC. They
43987
- * replace the manual TypeScript interfaces with schema-derived types,
43988
- * enabling runtime validation when reading from the backend.
43989
- *
43990
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
43991
- * keeps the original name for backward compatibility.
43992
- */
43993
- /**
43994
- * Auth model (v2 — 2026-05-12 caps-only):
43995
- *
43996
- * Two principals:
43997
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
43998
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
43999
- *
44000
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44001
- * `super_admin` — collapsed onto the single boolean because every
44002
- * non-admin caller is governed by the same scope-check rules; the
44003
- * distinction was only ever used to route role-specific procedures
44004
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44005
- * with `isAdmin: false` + an explicit scope list.
44006
- */
44007
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44008
- var MethodAccessSchema = _enum([
44009
- "view",
44010
- "create",
44011
- "delete"
44012
- ]);
44013
- /**
44014
- * A single scope grant. Three forms — checked in matcher with OR
44015
- * semantics; the first match decides whether the call passes:
44016
- *
44017
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44018
- * cap with the matching `scope` declaration. New caps inherit grants
44019
- * automatically — adding a device cap to the codebase makes it
44020
- * reachable to every user with `category:device [...]` without a
44021
- * re-grant. Use this for "family viewer" / "operator" tiers.
44022
- *
44023
- * - `addon` — every cap that ships inside a given addon id. Niche;
44024
- * useful when an integration needs to interact with one specific
44025
- * addon's surface regardless of how many caps it exports.
44026
- *
44027
- * - `capability` — the most precise form. Single cap name. Use for
44028
- * integration tokens where you want to grant `addons.installPackage`
44029
- * and nothing else.
44030
- *
44031
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44032
- * "give me everything" escape; there is no wildcard scope.
44033
- */
44034
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44035
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44036
- var CapScopeSchema = _enum(["device", "system"]);
44037
- /**
44038
- * DeviceSelector (scope model v3 — 2026-08-12).
44039
- *
44040
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44041
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44042
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44043
- * AFTER the grant was minted — no re-grant, no re-login.
44044
- *
44045
- * - `all` — every device in the deployment. The broad viewer/operator
44046
- * lever without a `category` grant (a `category` grant also covers device
44047
- * caps that carry no deviceId; `all` is specifically the device set).
44048
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44049
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44050
- * is NOT covered until the grant is edited.
44051
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44052
- * DYNAMIC. A device that changes type, or a new device of the type,
44053
- * re-resolves on the next request.
44054
- * - `locations` — every device whose operator-assigned `location` label is
44055
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44056
- * null/unset location matches NO `locations` selector.
44057
- */
44058
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44059
- object({ kind: literal("all") }),
44060
- object({
44061
- kind: literal("ids"),
44062
- ids: array(number().int()).min(1)
44063
- }),
44064
- object({
44065
- kind: literal("types"),
44066
- types: array(_enum(DeviceType)).min(1)
44067
- }),
44068
- object({
44069
- kind: literal("locations"),
44070
- locations: array(string().min(1)).min(1)
44071
- })
44072
- ]);
44073
- var DeviceTokenScopeSchema = object({
44074
- type: literal("device"),
44075
- /** The device SET this grant covers — resolved against the live fleet. */
44076
- selector: DeviceSelectorSchema,
44077
- access: array(MethodAccessSchema).min(1),
44078
- /**
44079
- * Whether a grant on a PARENT device transparently covers its accessory
44080
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44081
- * Direction is parent → children ONLY.
44082
- *
44083
- * Absent → the matcher DERIVES it from the access flavour: `view`
44084
- * inherits (a camera viewer sees the camera's accessories), `create` /
44085
- * `delete` do NOT (actuating/removing a child is an explicit act the
44086
- * operator must grant on the child, not inherit from the parent). Set it
44087
- * explicitly to override that default per grant.
44088
- */
44089
- includeLinked: boolean().optional()
44090
- });
44091
- /**
44092
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44093
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44094
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44095
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44096
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44097
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44098
- * migration cannot reach a JWT already in a client's hands; parse-time
44099
- * migration covers both without a flag day. No cast — the raw object is read
44100
- * through `Reflect.get` (its static type is `unknown`).
44101
- */
44102
- function migrateLegacyTokenScope(raw) {
44103
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44104
- if (Reflect.get(raw, "type") !== "device") return raw;
44105
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44106
- const targets = Reflect.get(raw, "targets");
44107
- if (!Array.isArray(targets)) return raw;
44108
- return {
44109
- type: "device",
44110
- selector: {
44111
- kind: "ids",
44112
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44113
- },
44114
- access: Reflect.get(raw, "access")
44115
- };
44116
- }
44117
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44118
- object({
44119
- type: literal("category"),
44120
- target: CapScopeSchema,
44121
- access: array(MethodAccessSchema).min(1)
44122
- }),
44123
- object({
44124
- type: literal("capability"),
44125
- target: string(),
44126
- access: array(MethodAccessSchema).min(1)
44127
- }),
44128
- object({
44129
- type: literal("addon"),
44130
- target: string(),
44131
- access: array(MethodAccessSchema).min(1)
44132
- }),
44133
- DeviceTokenScopeSchema
44134
- ]));
44135
- object({
44136
- id: string(),
44137
- username: string(),
44138
- passwordHash: string(),
44139
- /**
44140
- * Admin bypass. When true, the middleware skips the scope-access
44141
- * check entirely. There is no other axis of privilege; the legacy
44142
- * role enum collapsed onto this boolean in v2.
44143
- */
44144
- isAdmin: boolean().default(false),
44145
- allowedProviders: AllowedProviderSchema,
44146
- allowedDevices: AllowedDevicesSchema,
44147
- /**
44148
- * Scopes granted to this user. Admins bypass; their `scopes` is
44149
- * ignored. Non-admins without scopes are locked out of every
44150
- * protected call.
44151
- */
44152
- scopes: array(TokenScopeSchema).default([]),
44153
- createdAt: number(),
44154
- updatedAt: number()
44155
- });
44156
- object({
44157
- id: string(),
44158
- label: string(),
44159
- isAdmin: boolean().default(false),
44160
- allowedProviders: AllowedProviderSchema,
44161
- allowedDevices: AllowedDevicesSchema,
44162
- tokenHash: string(),
44163
- tokenPrefix: string(),
44164
- createdAt: number(),
44165
- lastUsedAt: number().optional()
44166
- });
44167
- object({
44168
- id: string(),
44169
- userId: string(),
44170
- name: string(),
44171
- tokenHash: string(),
44172
- tokenPrefix: string(),
44173
- scopes: array(TokenScopeSchema),
44174
- expiresAt: number().nullish(),
44175
- lastUsedAt: number().nullish(),
44176
- createdAt: number()
44177
- });
44178
- /**
44179
44327
  * `oauth-integration` — a collection cap by which an addon declares
44180
44328
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44181
44329
  * Each provider returns a static descriptor; the core enumerates them
@@ -64106,26 +64254,6 @@ var ApiKeySummarySchema = object({
64106
64254
  createdAt: number(),
64107
64255
  lastUsedAt: number().optional()
64108
64256
  });
64109
- var ScopedTokenSummarySchema = object({
64110
- id: string(),
64111
- userId: string(),
64112
- name: string(),
64113
- tokenPrefix: string(),
64114
- scopes: array(TokenScopeSchema),
64115
- expiresAt: number().nullish(),
64116
- lastUsedAt: number().nullish(),
64117
- createdAt: number()
64118
- });
64119
- var CreateScopedTokenInputSchema = object({
64120
- userId: string(),
64121
- name: string(),
64122
- scopes: array(TokenScopeSchema),
64123
- expiresAt: number().optional()
64124
- });
64125
- var CreateScopedTokenResultSchema = object({
64126
- token: string(),
64127
- record: ScopedTokenSummarySchema
64128
- });
64129
64257
  var OauthSessionSummarySchema = object({
64130
64258
  id: string(),
64131
64259
  userId: string(),
@@ -64147,11 +64275,11 @@ var TotpStatusSchema = object({
64147
64275
  confirmedAt: number().nullable()
64148
64276
  });
64149
64277
  /**
64150
- * user-management — singleton capability for user accounts, API keys,
64151
- * and scoped tokens.
64278
+ * user-management — singleton capability for user accounts and the
64279
+ * legacy API-key rows.
64152
64280
  *
64153
64281
  * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
64154
- * — the subset check on `setUserScopes` / `createScopedToken` is moot
64282
+ * — the subset check on `setUserScopes` is moot
64155
64283
  * because non-admins never reach these. If/when we open non-admin
64156
64284
  * delegation, structural caller-scope subset check goes inside the
64157
64285
  * provider.
@@ -64208,15 +64336,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
64208
64336
  kind: "mutation",
64209
64337
  auth: "admin",
64210
64338
  access: "delete"
64211
- }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
64212
- kind: "mutation",
64213
- auth: "admin",
64214
- access: "create"
64215
- }), method(object({ id: string() }), object({ success: literal(true) }), {
64216
- kind: "mutation",
64217
- auth: "admin",
64218
- access: "delete"
64219
- }), method(object({ token: string() }), ScopedTokenSummarySchema.nullable(), { access: "view" }), method(object({ userId: string() }), array(ScopedTokenSummarySchema), { auth: "admin" }), method(object({ userId: string() }), TotpSetupResultSchema, {
64339
+ }), method(object({ userId: string() }), TotpSetupResultSchema, {
64220
64340
  kind: "mutation",
64221
64341
  auth: "admin",
64222
64342
  access: "create"
@@ -69823,7 +69943,7 @@ Object.freeze({
69823
69943
  capName: "llm",
69824
69944
  capScope: "system",
69825
69945
  addonId: null,
69826
- access: "view"
69946
+ access: "create"
69827
69947
  },
69828
69948
  "llm.listNodeModels": {
69829
69949
  capName: "llm",
@@ -74487,12 +74607,6 @@ Object.freeze({
74487
74607
  addonId: null,
74488
74608
  access: "create"
74489
74609
  },
74490
- "userManagement.createScopedToken": {
74491
- capName: "user-management",
74492
- capScope: "system",
74493
- addonId: null,
74494
- access: "create"
74495
- },
74496
74610
  "userManagement.createUser": {
74497
74611
  capName: "user-management",
74498
74612
  capScope: "system",
@@ -74541,12 +74655,6 @@ Object.freeze({
74541
74655
  addonId: null,
74542
74656
  access: "view"
74543
74657
  },
74544
- "userManagement.listScopedTokens": {
74545
- capName: "user-management",
74546
- capScope: "system",
74547
- addonId: null,
74548
- access: "view"
74549
- },
74550
74658
  "userManagement.listUsers": {
74551
74659
  capName: "user-management",
74552
74660
  capScope: "system",
@@ -74601,12 +74709,6 @@ Object.freeze({
74601
74709
  addonId: null,
74602
74710
  access: "delete"
74603
74711
  },
74604
- "userManagement.revokeScopedToken": {
74605
- capName: "user-management",
74606
- capScope: "system",
74607
- addonId: null,
74608
- access: "delete"
74609
- },
74610
74712
  "userManagement.setupTotp": {
74611
74713
  capName: "user-management",
74612
74714
  capScope: "system",
@@ -74637,12 +74739,6 @@ Object.freeze({
74637
74739
  addonId: null,
74638
74740
  access: "view"
74639
74741
  },
74640
- "userManagement.validateScopedToken": {
74641
- capName: "user-management",
74642
- capScope: "system",
74643
- addonId: null,
74644
- access: "view"
74645
- },
74646
74742
  "userManagement.verifyTotp": {
74647
74743
  capName: "user-management",
74648
74744
  capScope: "system",