@camstack/types 1.2.385 → 1.2.387

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.
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_sleep = require("./sleep-BE7_6UnC.js");
2
+ const require_sleep = require("./sleep-6sOPE0EV.js");
3
3
  const require_event_category = require("./event-category-eSqkye-K.js");
4
4
  const require_composition = require("./composition-eoYYVfOp.js");
5
5
  const require_node_color = require("./node-color.js");
@@ -6616,7 +6616,7 @@ function classifyBearerPrincipal(payload) {
6616
6616
  * would lock every non-admin viewer out of recorder playback, snapshot media
6617
6617
  * and the stream-broker embed, which is a worse outcome than the hole.
6618
6618
  * - **integration** — must hold `addon:<addonId>` at the verb's access. This is
6619
- * the same rule the `cst_` scoped-token branch has always applied; the JWT
6619
+ * the same rule the scoped-token branch has always applied; the JWT
6620
6620
  * branch simply never applied it, and closing that divergence IS the fix.
6621
6621
  * `isAdmin` is ignored: an integration token is minted `isAdmin: false` and a
6622
6622
  * token claiming otherwise must not talk its way past the grant.
@@ -6637,6 +6637,420 @@ function principalMayReachAddon(input) {
6637
6637
  };
6638
6638
  }
6639
6639
  //#endregion
6640
+ //#region src/schemas/auth-records.ts
6641
+ /**
6642
+ * Zod schemas for persisted record types.
6643
+ *
6644
+ * These schemas serve as the single source of truth for types that are
6645
+ * stored in the settings-store backend and retrieved via tRPC. They
6646
+ * replace the manual TypeScript interfaces with schema-derived types,
6647
+ * enabling runtime validation when reading from the backend.
6648
+ *
6649
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
6650
+ * keeps the original name for backward compatibility.
6651
+ */
6652
+ /**
6653
+ * Auth model (v2 — 2026-05-12 caps-only):
6654
+ *
6655
+ * Two principals:
6656
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
6657
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
6658
+ *
6659
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
6660
+ * `super_admin` — collapsed onto the single boolean because every
6661
+ * non-admin caller is governed by the same scope-check rules; the
6662
+ * distinction was only ever used to route role-specific procedures
6663
+ * which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
6664
+ * with `isAdmin: false` + an explicit scope list.
6665
+ */
6666
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
6667
+ var MethodAccessSchema = zod.z.enum([
6668
+ "view",
6669
+ "create",
6670
+ "delete"
6671
+ ]);
6672
+ /**
6673
+ * A single scope grant. Three forms — checked in matcher with OR
6674
+ * semantics; the first match decides whether the call passes:
6675
+ *
6676
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
6677
+ * cap with the matching `scope` declaration. New caps inherit grants
6678
+ * automatically — adding a device cap to the codebase makes it
6679
+ * reachable to every user with `category:device [...]` without a
6680
+ * re-grant. Use this for "family viewer" / "operator" tiers.
6681
+ *
6682
+ * - `addon` — every cap that ships inside a given addon id. Niche;
6683
+ * useful when an integration needs to interact with one specific
6684
+ * addon's surface regardless of how many caps it exports.
6685
+ *
6686
+ * - `capability` — the most precise form. Single cap name. Use for
6687
+ * integration tokens where you want to grant `addons.installPackage`
6688
+ * and nothing else.
6689
+ *
6690
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
6691
+ * "give me everything" escape; there is no wildcard scope.
6692
+ */
6693
+ var AllowedProviderSchema = zod.z.union([zod.z.literal("*"), zod.z.array(zod.z.string())]);
6694
+ var AllowedDevicesSchema = zod.z.record(zod.z.string(), zod.z.union([zod.z.literal("*"), zod.z.array(zod.z.string())]));
6695
+ var CapScopeSchema = zod.z.enum(["device", "system"]);
6696
+ /**
6697
+ * DeviceSelector (scope model v3 — 2026-08-12).
6698
+ *
6699
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
6700
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
6701
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
6702
+ * AFTER the grant was minted — no re-grant, no re-login.
6703
+ *
6704
+ * - `all` — every device in the deployment. The broad viewer/operator
6705
+ * lever without a `category` grant (a `category` grant also covers device
6706
+ * caps that carry no deviceId; `all` is specifically the device set).
6707
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
6708
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
6709
+ * is NOT covered until the grant is edited.
6710
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
6711
+ * DYNAMIC. A device that changes type, or a new device of the type,
6712
+ * re-resolves on the next request.
6713
+ * - `locations` — every device whose operator-assigned `location` label is
6714
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
6715
+ * null/unset location matches NO `locations` selector.
6716
+ */
6717
+ var DeviceSelectorSchema = zod.z.discriminatedUnion("kind", [
6718
+ zod.z.object({ kind: zod.z.literal("all") }),
6719
+ zod.z.object({
6720
+ kind: zod.z.literal("ids"),
6721
+ ids: zod.z.array(zod.z.number().int()).min(1)
6722
+ }),
6723
+ zod.z.object({
6724
+ kind: zod.z.literal("types"),
6725
+ types: zod.z.array(zod.z.enum(require_err_msg.DeviceType)).min(1)
6726
+ }),
6727
+ zod.z.object({
6728
+ kind: zod.z.literal("locations"),
6729
+ locations: zod.z.array(zod.z.string().min(1)).min(1)
6730
+ })
6731
+ ]);
6732
+ var DeviceTokenScopeSchema = zod.z.object({
6733
+ type: zod.z.literal("device"),
6734
+ /** The device SET this grant covers — resolved against the live fleet. */
6735
+ selector: DeviceSelectorSchema,
6736
+ access: zod.z.array(MethodAccessSchema).min(1),
6737
+ /**
6738
+ * Whether a grant on a PARENT device transparently covers its accessory
6739
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
6740
+ * Direction is parent → children ONLY.
6741
+ *
6742
+ * Absent → the matcher DERIVES it from the access flavour: `view`
6743
+ * inherits (a camera viewer sees the camera's accessories), `create` /
6744
+ * `delete` do NOT (actuating/removing a child is an explicit act the
6745
+ * operator must grant on the child, not inherit from the parent). Set it
6746
+ * explicitly to override that default per grant.
6747
+ */
6748
+ includeLinked: zod.z.boolean().optional()
6749
+ });
6750
+ /**
6751
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
6752
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
6753
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
6754
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
6755
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
6756
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
6757
+ * migration cannot reach a JWT already in a client's hands; parse-time
6758
+ * migration covers both without a flag day. No cast — the raw object is read
6759
+ * through `Reflect.get` (its static type is `unknown`).
6760
+ */
6761
+ function migrateLegacyTokenScope(raw) {
6762
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
6763
+ if (Reflect.get(raw, "type") !== "device") return raw;
6764
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
6765
+ const targets = Reflect.get(raw, "targets");
6766
+ if (!Array.isArray(targets)) return raw;
6767
+ return {
6768
+ type: "device",
6769
+ selector: {
6770
+ kind: "ids",
6771
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
6772
+ },
6773
+ access: Reflect.get(raw, "access")
6774
+ };
6775
+ }
6776
+ var TokenScopeSchema = zod.z.preprocess(migrateLegacyTokenScope, zod.z.discriminatedUnion("type", [
6777
+ zod.z.object({
6778
+ type: zod.z.literal("category"),
6779
+ target: CapScopeSchema,
6780
+ access: zod.z.array(MethodAccessSchema).min(1)
6781
+ }),
6782
+ zod.z.object({
6783
+ type: zod.z.literal("capability"),
6784
+ target: zod.z.string(),
6785
+ access: zod.z.array(MethodAccessSchema).min(1)
6786
+ }),
6787
+ zod.z.object({
6788
+ type: zod.z.literal("addon"),
6789
+ target: zod.z.string(),
6790
+ access: zod.z.array(MethodAccessSchema).min(1)
6791
+ }),
6792
+ DeviceTokenScopeSchema
6793
+ ]));
6794
+ var UserRecordSchema = zod.z.object({
6795
+ id: zod.z.string(),
6796
+ username: zod.z.string(),
6797
+ passwordHash: zod.z.string(),
6798
+ /**
6799
+ * Admin bypass. When true, the middleware skips the scope-access
6800
+ * check entirely. There is no other axis of privilege; the legacy
6801
+ * role enum collapsed onto this boolean in v2.
6802
+ */
6803
+ isAdmin: zod.z.boolean().default(false),
6804
+ allowedProviders: AllowedProviderSchema,
6805
+ allowedDevices: AllowedDevicesSchema,
6806
+ /**
6807
+ * Scopes granted to this user. Admins bypass; their `scopes` is
6808
+ * ignored. Non-admins without scopes are locked out of every
6809
+ * protected call.
6810
+ */
6811
+ scopes: zod.z.array(TokenScopeSchema).default([]),
6812
+ createdAt: zod.z.number(),
6813
+ updatedAt: zod.z.number()
6814
+ });
6815
+ var ApiKeyRecordSchema = zod.z.object({
6816
+ id: zod.z.string(),
6817
+ label: zod.z.string(),
6818
+ isAdmin: zod.z.boolean().default(false),
6819
+ allowedProviders: AllowedProviderSchema,
6820
+ allowedDevices: AllowedDevicesSchema,
6821
+ tokenHash: zod.z.string(),
6822
+ tokenPrefix: zod.z.string(),
6823
+ createdAt: zod.z.number(),
6824
+ lastUsedAt: zod.z.number().optional()
6825
+ });
6826
+ var ScopedTokenSchema = zod.z.object({
6827
+ id: zod.z.string(),
6828
+ userId: zod.z.string(),
6829
+ name: zod.z.string(),
6830
+ tokenHash: zod.z.string(),
6831
+ tokenPrefix: zod.z.string(),
6832
+ scopes: zod.z.array(TokenScopeSchema),
6833
+ expiresAt: zod.z.number().nullish(),
6834
+ lastUsedAt: zod.z.number().nullish(),
6835
+ createdAt: zod.z.number()
6836
+ });
6837
+ //#endregion
6838
+ //#region src/auth/credential-scope.ts
6839
+ /**
6840
+ * The ONE permission vocabulary every credential is reduced to (D892).
6841
+ *
6842
+ * A credential — a login session, an account-link token, or a token
6843
+ * `auth.mintToken` issues (there is no other format, D895) — is
6844
+ * verified into a principal whose permissions are a `CredentialScope[]`, and
6845
+ * nothing else. What KIND of credential it was never decides what it may do:
6846
+ *
6847
+ * - `'*'` — everything (the admin bypass). Held by an admin's session and
6848
+ * a token minted with it.
6849
+ * - a {@link TokenScope} — the v3 capability grants (`category`,
6850
+ * `capability`, `addon`, `device`) the tRPC matcher has always applied.
6851
+ * - `share-view` — one fail-closed embed perimeter (`grid-view` /
6852
+ * `events-view`) over a few devices. A principal that holds one is
6853
+ * RESTRICTED to it: the matcher honours nothing else it holds.
6854
+ * - `addon-routes` — may reach any addon's own `authenticated` HTTP routes
6855
+ * and data planes (never an `admin` one). A person's session has always
6856
+ * had this; an integration token never had it and must hold
6857
+ * `addon:<id>` instead. Only an admin may mint it into a token.
6858
+ * - `preferences-self` — may read and write the SUBJECT's own account
6859
+ * preferences (D894), never another user's. Every person's session holds
6860
+ * it; a unified token holds it only when minted with it. `'*'` does NOT
6861
+ * imply it: the hub's own mesh principal holds `'*'` and is nobody's
6862
+ * account.
6863
+ *
6864
+ * Pure: no I/O. It lives in `@camstack/types` so the hub, the kernel and any
6865
+ * addon read the same vocabulary.
6866
+ */
6867
+ /** The admin scope: every permission. */
6868
+ var ADMIN_SCOPE = "*";
6869
+ /** At most this many devices in one share-view grant (the share-link bound). */
6870
+ var SHARE_VIEW_MAX_DEVICES = 64;
6871
+ /** What a share-view grant lets its holder see. */
6872
+ var ShareViewGrantSchema = zod.z.object({
6873
+ kind: zod.z.enum(require_sleep.SHARE_VIEW_KINDS),
6874
+ deviceIds: zod.z.array(zod.z.number().int().nonnegative()).min(1).max(64),
6875
+ /** Talk-back, opt-in at mint time; absent means off. */
6876
+ talk: zod.z.boolean().optional()
6877
+ });
6878
+ var ShareViewScopeSchema = zod.z.object({
6879
+ type: zod.z.literal("share-view"),
6880
+ grant: ShareViewGrantSchema
6881
+ });
6882
+ var AddonRoutesScopeSchema = zod.z.object({
6883
+ type: zod.z.literal("addon-routes"),
6884
+ access: zod.z.array(MethodAccessSchema).min(1)
6885
+ });
6886
+ var PreferencesSelfScopeSchema = zod.z.object({ type: zod.z.literal("preferences-self") });
6887
+ /** The grant every person's session carries for its own account preferences. */
6888
+ var PREFERENCES_SELF_SCOPE = { type: "preferences-self" };
6889
+ var CredentialScopeSchema = zod.z.union([
6890
+ zod.z.literal("*"),
6891
+ ShareViewScopeSchema,
6892
+ AddonRoutesScopeSchema,
6893
+ PreferencesSelfScopeSchema,
6894
+ TokenScopeSchema
6895
+ ]);
6896
+ /** Every access flavour — what a person's session holds on addon routes. */
6897
+ var ALL_METHOD_ACCESS = [
6898
+ "view",
6899
+ "create",
6900
+ "delete"
6901
+ ];
6902
+ function isTokenScope(scope) {
6903
+ return scope !== "*" && scope.type !== "share-view" && scope.type !== "addon-routes" && scope.type !== "preferences-self";
6904
+ }
6905
+ /** True iff the scope set holds `'*'`. */
6906
+ function scopesGrantAdmin(scopes) {
6907
+ return scopes.includes("*");
6908
+ }
6909
+ /**
6910
+ * The share-view grant that RESTRICTS this principal, or `null` when it holds
6911
+ * none. Fail closed: a set that mixes a share-view grant with anything else
6912
+ * is still restricted to its FIRST share-view grant, never widened by the rest.
6913
+ */
6914
+ function shareViewGrantOf(scopes) {
6915
+ for (const scope of scopes) if (scope !== "*" && scope.type === "share-view") return scope.grant;
6916
+ return null;
6917
+ }
6918
+ /** The capability grants the tRPC scope matcher reads. */
6919
+ function capabilityScopesOf(scopes) {
6920
+ return scopes.filter(isTokenScope);
6921
+ }
6922
+ /** True iff the set reaches every addon's own routes at `access`. */
6923
+ function scopesAllowAddonRoutes(scopes, access) {
6924
+ return scopes.some((s) => s !== "*" && s.type === "addon-routes" && s.access.includes(access));
6925
+ }
6926
+ /**
6927
+ * True iff the set may touch its subject's own account preferences: it holds
6928
+ * `preferences-self` and no share-view grant restricts it. `'*'` alone is not
6929
+ * enough (see the vocabulary above).
6930
+ */
6931
+ function scopesAllowOwnPreferences(scopes) {
6932
+ if (shareViewGrantOf(scopes) !== null) return false;
6933
+ return scopes.some((s) => s !== "*" && s.type === "preferences-self");
6934
+ }
6935
+ /**
6936
+ * Parse a scope array from an untrusted source (a JWT claim, a stored row).
6937
+ * Any element that does not parse makes the WHOLE set unusable — `null` — so
6938
+ * a corrupt grant can never degrade into a partial one.
6939
+ */
6940
+ function parseCredentialScopes(raw) {
6941
+ const parsed = zod.z.array(CredentialScopeSchema).safeParse(raw);
6942
+ return parsed.success ? parsed.data : null;
6943
+ }
6944
+ /**
6945
+ * The `kind` claim of a unified token. It names the TOKEN FAMILY (so every
6946
+ * older gate that classifies a hub JWT refuses it — `classifyBearerPrincipal`
6947
+ * treats any `kind` it does not know as not-a-credential), never what the
6948
+ * token may do: that is its `scopes`, and only its `scopes`.
6949
+ */
6950
+ var CREDENTIAL_TOKEN_KIND = "credential";
6951
+ /**
6952
+ * The `aud` claim every minted token is signed with (D895). The hub's raw JWT
6953
+ * verify (`AuthManager.verifyToken`, used by every surface that wants a LOGIN
6954
+ * session — the OAuth consent page, the session cookie, health, backups)
6955
+ * refuses a token carrying it, so a minted token — a share link above all —
6956
+ * can never be replayed as a person's session. Only the credential verifier's
6957
+ * own door (`verifyCredentialToken`) accepts it.
6958
+ */
6959
+ var CREDENTIAL_TOKEN_AUDIENCE = "camstack:credential";
6960
+ /** Does a verified JWT payload belong to the minted-token family? */
6961
+ function isCredentialTokenPayload(payload) {
6962
+ if (payload === null || typeof payload !== "object") return false;
6963
+ const kind = Reflect.get(payload, "kind");
6964
+ const aud = Reflect.get(payload, "aud");
6965
+ return kind === "credential" || aud === "camstack:credential" || Array.isArray(aud) && aud.includes("camstack:credential");
6966
+ }
6967
+ /**
6968
+ * The claims of a unified token (`auth.mintToken`). It carries no `exp`: its
6969
+ * row (looked up by `jti` on every verify, for revocation) holds the ONE
6970
+ * expiry, so a share link can be extended and a JWT clock can never disagree
6971
+ * with the row.
6972
+ */
6973
+ var CredentialTokenClaimsSchema = zod.z.object({
6974
+ kind: zod.z.literal(CREDENTIAL_TOKEN_KIND),
6975
+ sub: zod.z.string().min(1),
6976
+ jti: zod.z.string().min(16),
6977
+ scopes: zod.z.array(CredentialScopeSchema).min(1)
6978
+ });
6979
+ //#endregion
6980
+ //#region src/schemas/user-preferences.ts
6981
+ /**
6982
+ * Per-user ACCOUNT preferences (D894): the hub-side half of the viewer's two
6983
+ * settings levels.
6984
+ *
6985
+ * - DEVICE settings never leave the phone.
6986
+ * - ACCOUNT settings live here: one row per `(user, namespace)`, private to
6987
+ * that user, synced across every device signed in as them, last write wins
6988
+ * unless the writer sends the revision it based its edit on.
6989
+ *
6990
+ * A setting lives in exactly ONE level; there are no overrides. The caller
6991
+ * never names a user: the hub stamps the principal's own id, admin included.
6992
+ *
6993
+ * The contract the client codes against is the `preferences.*` tRPC router
6994
+ * (`server/backend/src/api/core/preferences.router.ts`).
6995
+ */
6996
+ /** `viewer.app`, `viewer.cameras`, `viewer.grids` … — lowercase, dot/dash separated. */
6997
+ var PREFERENCES_NAMESPACE_PATTERN = /^[a-z][a-z0-9.-]{0,63}$/;
6998
+ /** One row's value, measured as UTF-8 JSON. */
6999
+ var PREFERENCES_MAX_VALUE_BYTES = 256 * 1024;
7000
+ /** Namespaces one user may hold. */
7001
+ var PREFERENCES_MAX_NAMESPACES = 32;
7002
+ /** The opaque client id a writer stamps (`updatedByDevice`). */
7003
+ var PREFERENCES_MAX_DEVICE_ID_LENGTH = 64;
7004
+ var PreferenceNamespaceSchema = zod.z.string().regex(PREFERENCES_NAMESPACE_PATTERN);
7005
+ /** A namespace's value: a JSON object, opaque to the hub. */
7006
+ var PreferenceValueSchema = zod.z.record(zod.z.string(), zod.z.unknown());
7007
+ var PreferenceDeviceIdSchema = zod.z.string().min(1).max(64);
7008
+ /** A stored row, as the owner reads it. */
7009
+ var PreferenceRowSchema = zod.z.object({
7010
+ namespace: PreferenceNamespaceSchema,
7011
+ value: PreferenceValueSchema,
7012
+ /** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
7013
+ revision: zod.z.number().int().positive(),
7014
+ updatedAt: zod.z.number().int(),
7015
+ /** The client id the last writer sent; `null` when it sent none. */
7016
+ updatedByDevice: PreferenceDeviceIdSchema.nullable()
7017
+ });
7018
+ var PreferencesGetInputSchema = zod.z.object({
7019
+ /** Absent: every namespace the caller holds. */
7020
+ namespaces: zod.z.array(PreferenceNamespaceSchema).max(32).optional() });
7021
+ var PreferencesGetOutputSchema = zod.z.object({ rows: zod.z.array(PreferenceRowSchema) });
7022
+ var PreferencesPutInputSchema = zod.z.object({
7023
+ namespace: PreferenceNamespaceSchema,
7024
+ value: PreferenceValueSchema,
7025
+ /**
7026
+ * The revision the edit was based on. Absent: last write wins. `0`: the
7027
+ * namespace must not exist yet. Any other value that is not the current
7028
+ * revision answers `conflict` and writes nothing.
7029
+ */
7030
+ baseRevision: zod.z.number().int().nonnegative().optional(),
7031
+ deviceId: PreferenceDeviceIdSchema.optional()
7032
+ });
7033
+ var PreferencesPutOutputSchema = zod.z.discriminatedUnion("status", [zod.z.object({
7034
+ status: zod.z.literal("saved"),
7035
+ row: PreferenceRowSchema
7036
+ }), zod.z.object({
7037
+ status: zod.z.literal("conflict"),
7038
+ current: PreferenceRowSchema.nullable()
7039
+ })]);
7040
+ var PreferencesDeleteInputSchema = zod.z.object({ namespace: PreferenceNamespaceSchema });
7041
+ var PreferencesDeleteOutputSchema = zod.z.object({
7042
+ /** `false` when the namespace did not exist. */
7043
+ deleted: zod.z.boolean() });
7044
+ var PreferencesChangedSinceInputSchema = zod.z.object({
7045
+ /** The revision the client holds per namespace; a namespace it does not list is new to it. */
7046
+ revisionByNamespace: zod.z.record(PreferenceNamespaceSchema, zod.z.number().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
7047
+ var PreferencesChangedSinceOutputSchema = zod.z.object({
7048
+ /** Every row whose revision differs from the client's, and every row it did not list. */
7049
+ rows: zod.z.array(PreferenceRowSchema),
7050
+ /** Namespaces the client listed that no longer exist. */
7051
+ deleted: zod.z.array(PreferenceNamespaceSchema)
7052
+ });
7053
+ //#endregion
6640
7054
  //#region src/auth/app-callback.ts
6641
7055
  /**
6642
7056
  * The viewer app's custom-scheme callback — the ONE list of URLs a hub flow
@@ -39812,30 +40226,50 @@ var llmRuntimeCapability = {
39812
40226
  * (hub-placed); the cap stays open for future providers.
39813
40227
  *
39814
40228
  * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
39815
- * `apiKey` is a password field — providers REDACT it on read and merge on
39816
- * write; a stored key NEVER round-trips to a client.
39817
- */
39818
- var LlmProfileKindSchema = zod.z.enum([
39819
- "openai-compatible",
39820
- "openai",
39821
- "anthropic",
39822
- "google",
39823
- "managed-local",
39824
- "apple-foundation"
39825
- ]);
40229
+ * A row is common fields plus `providerConfig`, which the provider owning the
40230
+ * row's kind declares (`connectionSchema`) and validates. The kind is an open
40231
+ * id declared by that provider (D893). A `password` field of the provider's
40232
+ * schema is a secret — providers REDACT it on read and merge on write; a
40233
+ * stored key NEVER round-trips to a client.
40234
+ */
40235
+ /**
40236
+ * A profile kind is an OPEN id, declared by the provider that serves it
40237
+ * (`listProfileKinds`). The cap names no kind: a new provider ships a new kind
40238
+ * without a framework change. Lower-case, digits and dashes, so it stays safe
40239
+ * as a URL segment, a record field and a CSS hook.
40240
+ */
40241
+ var LLM_PROFILE_KIND_PATTERN = /^[a-z0-9][a-z0-9-]{0,63}$/;
40242
+ var LlmProfileKindSchema = zod.z.string().regex(LLM_PROFILE_KIND_PATTERN, "a kind id is lower-case letters, digits and dashes");
40243
+ /** What a model (or, by default, every model of a kind) can do. */
40244
+ var LlmModelFeaturesSchema = zod.z.object({
40245
+ vision: zod.z.boolean(),
40246
+ tools: zod.z.boolean(),
40247
+ streaming: zod.z.boolean()
40248
+ });
40249
+ /** One model a provider offers. `features` overrides the kind's defaults, per field. */
40250
+ var LlmModelInfoSchema = zod.z.object({
40251
+ id: zod.z.string(),
40252
+ label: zod.z.string().optional(),
40253
+ contextLength: zod.z.number().int().positive().optional(),
40254
+ features: LlmModelFeaturesSchema.partial().optional()
40255
+ });
40256
+ /**
40257
+ * The provider-specific part of a profile, validated by the provider that owns
40258
+ * the kind (`upsertProfile` refuses what it does not accept). A field its
40259
+ * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
40260
+ * keychain, never in the row, and reads back as the redaction marker.
40261
+ */
40262
+ var LlmProviderConfigSchema = zod.z.record(zod.z.string(), zod.z.unknown());
39826
40263
  var LlmProfileSchema = zod.z.object({
39827
40264
  id: zod.z.string(),
39828
40265
  name: zod.z.string(),
40266
+ /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
39829
40267
  kind: LlmProfileKindSchema,
39830
40268
  /** Stamped by the provider — keeps the fanned catalog routable. */
39831
40269
  addonId: zod.z.string(),
39832
40270
  enabled: zod.z.boolean(),
39833
40271
  /** Vendor model id, or the managed runtime's loaded model. */
39834
40272
  model: zod.z.string(),
39835
- /** Required for openai-compatible; override for cloud kinds. */
39836
- baseUrl: zod.z.string().optional(),
39837
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
39838
- apiKey: zod.z.string().optional(),
39839
40273
  /** Vision on/off. A vision call against a `false` profile is REFUSED, never
39840
40274
  * degraded to text — that shipped once and produced a confident answer to a
39841
40275
  * question about a picture nobody sent. */
@@ -39843,15 +40277,11 @@ var LlmProfileSchema = zod.z.object({
39843
40277
  temperature: zod.z.number().min(0).max(2).optional(),
39844
40278
  /** Nucleus sampling. Every wire we speak has it. */
39845
40279
  topP: zod.z.number().min(0).max(1).optional(),
39846
- /** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
39847
- * wire does, and the client drops it there (measured: the request body gets
39848
- * `top_p` and no `top_k`). The profile editor hides the field wherever it
39849
- * would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
40280
+ /** Top-k sampling. Carried only by the wires that have it — a kind offers the
40281
+ * field in its editor only when its descriptor lists it in `profileFields`. */
39850
40282
  topK: zod.z.number().int().positive().optional(),
39851
40283
  maxTokens: zod.z.number().int().positive().optional(),
39852
- /** Prompt context window. Advisory for cloud kinds (they enforce their own);
39853
- * for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
39854
- * the model with, so it is the one field that changes a PROCESS. */
40284
+ /** Prompt context window. Advisory for cloud kinds (they enforce their own). */
39855
40285
  contextLength: zod.z.number().int().positive().optional(),
39856
40286
  /** Default system prompt. A caller's `system` REPLACES it (never appends —
39857
40287
  * two system prompts fighting is worse than either alone). */
@@ -39877,16 +40307,37 @@ var LlmProfileSchema = zod.z.object({
39877
40307
  * library; the REGISTRY of callable tools is ours and is empty in v1, so a
39878
40308
  * `true` here buys the wiring, not behaviour, until tools are registered. */
39879
40309
  toolsEnabled: zod.z.boolean().default(false),
39880
- extraHeaders: zod.z.record(zod.z.string(), zod.z.string()).optional(),
39881
- /** kind === 'managed-local' only (spec §4). */
39882
- runtime: ManagedRuntimeConfigSchema.optional(),
39883
- /**
39884
- * kind === 'apple-foundation' only: WHERE it runs — the only thing there is
39885
- * to configure (no key, no URL, no download; `model` is `apple-system`).
39886
- * `supportsVision` on such a row is stamped by the provider from the node's
39887
- * reported `imageInput`, never taken from the operator (D62).
39888
- */
39889
- appleFoundation: zod.z.object({ nodeId: zod.z.string() }).optional()
40310
+ /** Everything the kind's provider owns (endpoint, key, node, runtime…). */
40311
+ providerConfig: LlmProviderConfigSchema.default({})
40312
+ });
40313
+ /**
40314
+ * The common profile fields a kind's editor offers. The editor owns how each
40315
+ * one is drawn; the provider says which of them mean something on its wire.
40316
+ */
40317
+ var LlmProfileFieldSchema = zod.z.enum([
40318
+ "temperature",
40319
+ "topP",
40320
+ "topK",
40321
+ "maxTokens",
40322
+ "contextLength",
40323
+ "systemPrompt",
40324
+ "timeoutMs",
40325
+ "connectTimeoutMs",
40326
+ "firstTokenTimeoutMs",
40327
+ "idleTimeoutMs",
40328
+ "retry",
40329
+ "toolsEnabled"
40330
+ ]);
40331
+ /**
40332
+ * A provider-drawn part of the editor, by a generic widget id the admin UI
40333
+ * registers (`ai/apple-node`). `placement: 'model'` replaces the generic model
40334
+ * picker: that widget owns the model choice.
40335
+ */
40336
+ var LlmProviderWidgetSchema = zod.z.object({
40337
+ id: zod.z.string(),
40338
+ placement: zod.z.enum(["connection", "model"]),
40339
+ /** `providerConfig` keys this widget must fill before the profile can be saved. */
40340
+ requires: zod.z.array(zod.z.string()).optional()
39890
40341
  });
39891
40342
  /** ConfigUISchema tree passed through untyped on the wire (the
39892
40343
  * notification-output `ConfigSchemaPassthrough` precedent at
@@ -39895,11 +40346,56 @@ var ConfigSchemaPassthrough$3 = zod.z.unknown();
39895
40346
  var LlmProfileKindDescriptorSchema = zod.z.object({
39896
40347
  kind: LlmProfileKindSchema,
39897
40348
  label: zod.z.string(),
40349
+ /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
39898
40350
  icon: zod.z.string(),
39899
40351
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
39900
40352
  addonId: zod.z.string(),
39901
- configSchema: ConfigSchemaPassthrough$3
40353
+ /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
40354
+ connectionSchema: ConfigSchemaPassthrough$3,
40355
+ /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
40356
+ advancedSchema: ConfigSchemaPassthrough$3.optional(),
40357
+ /** The kind's defaults; a model from `listModels` may override any of them. */
40358
+ features: LlmModelFeaturesSchema,
40359
+ /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
40360
+ visionEditable: zod.z.boolean(),
40361
+ /** Where the model list comes from: `listModels`, `staticModels`, or nowhere. */
40362
+ modelCatalog: zod.z.enum([
40363
+ "fetch",
40364
+ "static",
40365
+ "none"
40366
+ ]),
40367
+ staticModels: zod.z.array(LlmModelInfoSchema).optional(),
40368
+ /** The common fields that mean something on this kind's wire. */
40369
+ profileFields: zod.z.array(LlmProfileFieldSchema),
40370
+ providerWidgets: zod.z.array(LlmProviderWidgetSchema).optional()
39902
40371
  });
40372
+ /**
40373
+ * `listModels` input. `connection` is an UNSAVED draft of `providerConfig`
40374
+ * (the editor's form); with `profileId` too, a secret the draft leaves
40375
+ * untouched (absent or the redaction marker) is resolved server-side from the
40376
+ * stored profile — the browser never receives it.
40377
+ */
40378
+ var LlmListModelsInputSchema = zod.z.object({
40379
+ addonId: zod.z.string(),
40380
+ kind: LlmProfileKindSchema,
40381
+ profileId: zod.z.string().optional(),
40382
+ connection: LlmProviderConfigSchema.optional()
40383
+ });
40384
+ var LlmListModelsErrorCodeSchema = zod.z.enum([
40385
+ "auth",
40386
+ "network",
40387
+ "unsupported",
40388
+ "invalid"
40389
+ ]);
40390
+ /** A RESULT, never a throw: "wrong key" is an answer the editor renders inline. */
40391
+ var LlmListModelsResultSchema = zod.z.discriminatedUnion("ok", [zod.z.object({
40392
+ ok: zod.z.literal(true),
40393
+ models: zod.z.array(LlmModelInfoSchema)
40394
+ }), zod.z.object({
40395
+ ok: zod.z.literal(false),
40396
+ code: LlmListModelsErrorCodeSchema,
40397
+ message: zod.z.string()
40398
+ })]);
39903
40399
  var LlmDefaultSelectorSchema = zod.z.union([zod.z.object({ consumer: zod.z.string() }), zod.z.object({ purpose: zod.z.enum(["text", "vision"]) })]);
39904
40400
  var LlmDefaultSchema = zod.z.object({
39905
40401
  selector: LlmDefaultSelectorSchema,
@@ -40030,8 +40526,17 @@ var llmCapability = {
40030
40526
  auth: "admin",
40031
40527
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
40032
40528
  }),
40033
- /** Live vendor enumeration (GET /models etc.). */
40034
- listModels: require_sleep.method(ProfileRefInputSchema, zod.z.array(zod.z.string())),
40529
+ /**
40530
+ * The models a kind offers, for a SAVED profile or an unsaved draft
40531
+ * (`connection`). A mutation, not a query: a draft may carry a key, and a
40532
+ * query's input travels in the URL. Admin: it dials whatever endpoint the
40533
+ * draft names and may resolve a stored key to do it. The answer never
40534
+ * carries a secret — failures are a typed result, never a throw.
40535
+ */
40536
+ listModels: require_sleep.method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
40537
+ kind: "mutation",
40538
+ auth: "admin"
40539
+ }),
40035
40540
  getDefaults: require_sleep.method(zod.z.object({}), zod.z.array(LlmDefaultSchema)),
40036
40541
  setDefault: require_sleep.method(zod.z.object({
40037
40542
  selector: LlmDefaultSelectorSchema,
@@ -45899,204 +46404,6 @@ var notificationRulesCapability = {
45899
46404
  }
45900
46405
  };
45901
46406
  //#endregion
45902
- //#region src/schemas/auth-records.ts
45903
- /**
45904
- * Zod schemas for persisted record types.
45905
- *
45906
- * These schemas serve as the single source of truth for types that are
45907
- * stored in the settings-store backend and retrieved via tRPC. They
45908
- * replace the manual TypeScript interfaces with schema-derived types,
45909
- * enabling runtime validation when reading from the backend.
45910
- *
45911
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
45912
- * keeps the original name for backward compatibility.
45913
- */
45914
- /**
45915
- * Auth model (v2 — 2026-05-12 caps-only):
45916
- *
45917
- * Two principals:
45918
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
45919
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
45920
- *
45921
- * No role enum. There used to be `viewer / agent / scoped` and earlier
45922
- * `super_admin` — collapsed onto the single boolean because every
45923
- * non-admin caller is governed by the same scope-check rules; the
45924
- * distinction was only ever used to route role-specific procedures
45925
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
45926
- * with `isAdmin: false` + an explicit scope list.
45927
- */
45928
- /** Per-method access flavour. Materialised on every cap method via codegen. */
45929
- var MethodAccessSchema = zod.z.enum([
45930
- "view",
45931
- "create",
45932
- "delete"
45933
- ]);
45934
- /**
45935
- * A single scope grant. Three forms — checked in matcher with OR
45936
- * semantics; the first match decides whether the call passes:
45937
- *
45938
- * - `category` — broadest. `target: 'device' | 'system'` selects every
45939
- * cap with the matching `scope` declaration. New caps inherit grants
45940
- * automatically — adding a device cap to the codebase makes it
45941
- * reachable to every user with `category:device [...]` without a
45942
- * re-grant. Use this for "family viewer" / "operator" tiers.
45943
- *
45944
- * - `addon` — every cap that ships inside a given addon id. Niche;
45945
- * useful when an integration needs to interact with one specific
45946
- * addon's surface regardless of how many caps it exports.
45947
- *
45948
- * - `capability` — the most precise form. Single cap name. Use for
45949
- * integration tokens where you want to grant `addons.installPackage`
45950
- * and nothing else.
45951
- *
45952
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
45953
- * "give me everything" escape; there is no wildcard scope.
45954
- */
45955
- var AllowedProviderSchema = zod.z.union([zod.z.literal("*"), zod.z.array(zod.z.string())]);
45956
- var AllowedDevicesSchema = zod.z.record(zod.z.string(), zod.z.union([zod.z.literal("*"), zod.z.array(zod.z.string())]));
45957
- var CapScopeSchema = zod.z.enum(["device", "system"]);
45958
- /**
45959
- * DeviceSelector (scope model v3 — 2026-08-12).
45960
- *
45961
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
45962
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
45963
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
45964
- * AFTER the grant was minted — no re-grant, no re-login.
45965
- *
45966
- * - `all` — every device in the deployment. The broad viewer/operator
45967
- * lever without a `category` grant (a `category` grant also covers device
45968
- * caps that carry no deviceId; `all` is specifically the device set).
45969
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
45970
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
45971
- * is NOT covered until the grant is edited.
45972
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
45973
- * DYNAMIC. A device that changes type, or a new device of the type,
45974
- * re-resolves on the next request.
45975
- * - `locations` — every device whose operator-assigned `location` label is
45976
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
45977
- * null/unset location matches NO `locations` selector.
45978
- */
45979
- var DeviceSelectorSchema = zod.z.discriminatedUnion("kind", [
45980
- zod.z.object({ kind: zod.z.literal("all") }),
45981
- zod.z.object({
45982
- kind: zod.z.literal("ids"),
45983
- ids: zod.z.array(zod.z.number().int()).min(1)
45984
- }),
45985
- zod.z.object({
45986
- kind: zod.z.literal("types"),
45987
- types: zod.z.array(zod.z.enum(require_err_msg.DeviceType)).min(1)
45988
- }),
45989
- zod.z.object({
45990
- kind: zod.z.literal("locations"),
45991
- locations: zod.z.array(zod.z.string().min(1)).min(1)
45992
- })
45993
- ]);
45994
- var DeviceTokenScopeSchema = zod.z.object({
45995
- type: zod.z.literal("device"),
45996
- /** The device SET this grant covers — resolved against the live fleet. */
45997
- selector: DeviceSelectorSchema,
45998
- access: zod.z.array(MethodAccessSchema).min(1),
45999
- /**
46000
- * Whether a grant on a PARENT device transparently covers its accessory
46001
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
46002
- * Direction is parent → children ONLY.
46003
- *
46004
- * Absent → the matcher DERIVES it from the access flavour: `view`
46005
- * inherits (a camera viewer sees the camera's accessories), `create` /
46006
- * `delete` do NOT (actuating/removing a child is an explicit act the
46007
- * operator must grant on the child, not inherit from the parent). Set it
46008
- * explicitly to override that default per grant.
46009
- */
46010
- includeLinked: zod.z.boolean().optional()
46011
- });
46012
- /**
46013
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
46014
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
46015
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
46016
- * EVERY parse path — stored records AND the JWT-carried scope arrays
46017
- * normalised at the request boundary ({@link normalizeTokenScopes} in
46018
- * `device-selector.ts`). Chosen over a one-time DB migration because a
46019
- * migration cannot reach a JWT already in a client's hands; parse-time
46020
- * migration covers both without a flag day. No cast — the raw object is read
46021
- * through `Reflect.get` (its static type is `unknown`).
46022
- */
46023
- function migrateLegacyTokenScope(raw) {
46024
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
46025
- if (Reflect.get(raw, "type") !== "device") return raw;
46026
- if (Reflect.get(raw, "selector") !== void 0) return raw;
46027
- const targets = Reflect.get(raw, "targets");
46028
- if (!Array.isArray(targets)) return raw;
46029
- return {
46030
- type: "device",
46031
- selector: {
46032
- kind: "ids",
46033
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
46034
- },
46035
- access: Reflect.get(raw, "access")
46036
- };
46037
- }
46038
- var TokenScopeSchema = zod.z.preprocess(migrateLegacyTokenScope, zod.z.discriminatedUnion("type", [
46039
- zod.z.object({
46040
- type: zod.z.literal("category"),
46041
- target: CapScopeSchema,
46042
- access: zod.z.array(MethodAccessSchema).min(1)
46043
- }),
46044
- zod.z.object({
46045
- type: zod.z.literal("capability"),
46046
- target: zod.z.string(),
46047
- access: zod.z.array(MethodAccessSchema).min(1)
46048
- }),
46049
- zod.z.object({
46050
- type: zod.z.literal("addon"),
46051
- target: zod.z.string(),
46052
- access: zod.z.array(MethodAccessSchema).min(1)
46053
- }),
46054
- DeviceTokenScopeSchema
46055
- ]));
46056
- var UserRecordSchema = zod.z.object({
46057
- id: zod.z.string(),
46058
- username: zod.z.string(),
46059
- passwordHash: zod.z.string(),
46060
- /**
46061
- * Admin bypass. When true, the middleware skips the scope-access
46062
- * check entirely. There is no other axis of privilege; the legacy
46063
- * role enum collapsed onto this boolean in v2.
46064
- */
46065
- isAdmin: zod.z.boolean().default(false),
46066
- allowedProviders: AllowedProviderSchema,
46067
- allowedDevices: AllowedDevicesSchema,
46068
- /**
46069
- * Scopes granted to this user. Admins bypass; their `scopes` is
46070
- * ignored. Non-admins without scopes are locked out of every
46071
- * protected call.
46072
- */
46073
- scopes: zod.z.array(TokenScopeSchema).default([]),
46074
- createdAt: zod.z.number(),
46075
- updatedAt: zod.z.number()
46076
- });
46077
- var ApiKeyRecordSchema = zod.z.object({
46078
- id: zod.z.string(),
46079
- label: zod.z.string(),
46080
- isAdmin: zod.z.boolean().default(false),
46081
- allowedProviders: AllowedProviderSchema,
46082
- allowedDevices: AllowedDevicesSchema,
46083
- tokenHash: zod.z.string(),
46084
- tokenPrefix: zod.z.string(),
46085
- createdAt: zod.z.number(),
46086
- lastUsedAt: zod.z.number().optional()
46087
- });
46088
- var ScopedTokenSchema = zod.z.object({
46089
- id: zod.z.string(),
46090
- userId: zod.z.string(),
46091
- name: zod.z.string(),
46092
- tokenHash: zod.z.string(),
46093
- tokenPrefix: zod.z.string(),
46094
- scopes: zod.z.array(TokenScopeSchema),
46095
- expiresAt: zod.z.number().nullish(),
46096
- lastUsedAt: zod.z.number().nullish(),
46097
- createdAt: zod.z.number()
46098
- });
46099
- //#endregion
46100
46407
  //#region src/capabilities/oauth-integration.cap.ts
46101
46408
  /**
46102
46409
  * `oauth-integration` — a collection cap by which an addon declares
@@ -72353,26 +72660,6 @@ var ApiKeySummarySchema = zod.z.object({
72353
72660
  createdAt: zod.z.number(),
72354
72661
  lastUsedAt: zod.z.number().optional()
72355
72662
  });
72356
- var ScopedTokenSummarySchema = zod.z.object({
72357
- id: zod.z.string(),
72358
- userId: zod.z.string(),
72359
- name: zod.z.string(),
72360
- tokenPrefix: zod.z.string(),
72361
- scopes: zod.z.array(TokenScopeSchema),
72362
- expiresAt: zod.z.number().nullish(),
72363
- lastUsedAt: zod.z.number().nullish(),
72364
- createdAt: zod.z.number()
72365
- });
72366
- var CreateScopedTokenInputSchema = zod.z.object({
72367
- userId: zod.z.string(),
72368
- name: zod.z.string(),
72369
- scopes: zod.z.array(TokenScopeSchema),
72370
- expiresAt: zod.z.number().optional()
72371
- });
72372
- var CreateScopedTokenResultSchema = zod.z.object({
72373
- token: zod.z.string(),
72374
- record: ScopedTokenSummarySchema
72375
- });
72376
72663
  var OauthSessionSummarySchema = zod.z.object({
72377
72664
  id: zod.z.string(),
72378
72665
  userId: zod.z.string(),
@@ -72394,11 +72681,11 @@ var TotpStatusSchema = zod.z.object({
72394
72681
  confirmedAt: zod.z.number().nullable()
72395
72682
  });
72396
72683
  /**
72397
- * user-management — singleton capability for user accounts, API keys,
72398
- * and scoped tokens.
72684
+ * user-management — singleton capability for user accounts and the
72685
+ * legacy API-key rows.
72399
72686
  *
72400
72687
  * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
72401
- * — the subset check on `setUserScopes` / `createScopedToken` is moot
72688
+ * — the subset check on `setUserScopes` is moot
72402
72689
  * because non-admins never reach these. If/when we open non-admin
72403
72690
  * delegation, structural caller-scope subset check goes inside the
72404
72691
  * provider.
@@ -72469,18 +72756,6 @@ var userManagementCapability = {
72469
72756
  auth: "admin",
72470
72757
  access: "delete"
72471
72758
  }),
72472
- createScopedToken: require_sleep.method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
72473
- kind: "mutation",
72474
- auth: "admin",
72475
- access: "create"
72476
- }),
72477
- revokeScopedToken: require_sleep.method(zod.z.object({ id: zod.z.string() }), zod.z.object({ success: zod.z.literal(true) }), {
72478
- kind: "mutation",
72479
- auth: "admin",
72480
- access: "delete"
72481
- }),
72482
- validateScopedToken: require_sleep.method(zod.z.object({ token: zod.z.string() }), ScopedTokenSummarySchema.nullable(), { access: "view" }),
72483
- listScopedTokens: require_sleep.method(zod.z.object({ userId: zod.z.string() }), zod.z.array(ScopedTokenSummarySchema), { auth: "admin" }),
72484
72759
  setupTotp: require_sleep.method(zod.z.object({ userId: zod.z.string() }), TotpSetupResultSchema, {
72485
72760
  kind: "mutation",
72486
72761
  auth: "admin",
@@ -80704,7 +80979,7 @@ var METHOD_ACCESS_MAP = Object.freeze({
80704
80979
  capName: "llm",
80705
80980
  capScope: "system",
80706
80981
  addonId: null,
80707
- access: "view"
80982
+ access: "create"
80708
80983
  },
80709
80984
  "llm.listNodeModels": {
80710
80985
  capName: "llm",
@@ -85368,12 +85643,6 @@ var METHOD_ACCESS_MAP = Object.freeze({
85368
85643
  addonId: null,
85369
85644
  access: "create"
85370
85645
  },
85371
- "userManagement.createScopedToken": {
85372
- capName: "user-management",
85373
- capScope: "system",
85374
- addonId: null,
85375
- access: "create"
85376
- },
85377
85646
  "userManagement.createUser": {
85378
85647
  capName: "user-management",
85379
85648
  capScope: "system",
@@ -85422,12 +85691,6 @@ var METHOD_ACCESS_MAP = Object.freeze({
85422
85691
  addonId: null,
85423
85692
  access: "view"
85424
85693
  },
85425
- "userManagement.listScopedTokens": {
85426
- capName: "user-management",
85427
- capScope: "system",
85428
- addonId: null,
85429
- access: "view"
85430
- },
85431
85694
  "userManagement.listUsers": {
85432
85695
  capName: "user-management",
85433
85696
  capScope: "system",
@@ -85482,12 +85745,6 @@ var METHOD_ACCESS_MAP = Object.freeze({
85482
85745
  addonId: null,
85483
85746
  access: "delete"
85484
85747
  },
85485
- "userManagement.revokeScopedToken": {
85486
- capName: "user-management",
85487
- capScope: "system",
85488
- addonId: null,
85489
- access: "delete"
85490
- },
85491
85748
  "userManagement.setupTotp": {
85492
85749
  capName: "user-management",
85493
85750
  capScope: "system",
@@ -85518,12 +85775,6 @@ var METHOD_ACCESS_MAP = Object.freeze({
85518
85775
  addonId: null,
85519
85776
  access: "view"
85520
85777
  },
85521
- "userManagement.validateScopedToken": {
85522
- capName: "user-management",
85523
- capScope: "system",
85524
- addonId: null,
85525
- access: "view"
85526
- },
85527
85778
  "userManagement.verifyTotp": {
85528
85779
  capName: "user-management",
85529
85780
  capScope: "system",
@@ -93531,7 +93782,7 @@ function createSystemProxy(api) {
93531
93782
  migrateRawSecrets: (input) => dispatch("llm", "migrateRawSecrets", "mutation", input),
93532
93783
  deleteProfile: (input) => dispatch("llm", "deleteProfile", "mutation", input),
93533
93784
  testProfile: (input) => dispatch("llm", "testProfile", "mutation", input),
93534
- listModels: (input) => dispatch("llm", "listModels", "query", input),
93785
+ listModels: (input) => dispatch("llm", "listModels", "mutation", input),
93535
93786
  getDefaults: (input) => dispatch("llm", "getDefaults", "query", input),
93536
93787
  setDefault: (input) => dispatch("llm", "setDefault", "mutation", input),
93537
93788
  getUsage: (input) => dispatch("llm", "getUsage", "query", input),
@@ -93975,10 +94226,6 @@ function createSystemProxy(api) {
93975
94226
  validateCredentials: (input) => dispatch("userManagement", "validateCredentials", "mutation", input),
93976
94227
  listApiKeys: (input) => dispatch("userManagement", "listApiKeys", "query", input),
93977
94228
  revokeApiKey: (input) => dispatch("userManagement", "revokeApiKey", "mutation", input),
93978
- createScopedToken: (input) => dispatch("userManagement", "createScopedToken", "mutation", input),
93979
- revokeScopedToken: (input) => dispatch("userManagement", "revokeScopedToken", "mutation", input),
93980
- validateScopedToken: (input) => dispatch("userManagement", "validateScopedToken", "query", input),
93981
- listScopedTokens: (input) => dispatch("userManagement", "listScopedTokens", "query", input),
93982
94229
  setupTotp: (input) => dispatch("userManagement", "setupTotp", "mutation", input),
93983
94230
  confirmTotp: (input) => dispatch("userManagement", "confirmTotp", "mutation", input),
93984
94231
  disableTotp: (input) => dispatch("userManagement", "disableTotp", "mutation", input),
@@ -102878,11 +103125,13 @@ function armRemovalReconcile(opts) {
102878
103125
  //#endregion
102879
103126
  exports.ACCESSORY_LABEL = ACCESSORY_LABEL;
102880
103127
  exports.ACCESS_ROLES = ACCESS_ROLES;
103128
+ exports.ADMIN_SCOPE = ADMIN_SCOPE;
102881
103129
  exports.AGENT_MDNS_QUERY_NAME = AGENT_MDNS_QUERY_NAME;
102882
103130
  exports.AGENT_MDNS_SERVICE_TYPE = AGENT_MDNS_SERVICE_TYPE;
102883
103131
  exports.AGENT_MDNS_TXT_KEYS = AGENT_MDNS_TXT_KEYS;
102884
103132
  exports.ALEXA_EGRESS_PROFILE = ALEXA_EGRESS_PROFILE;
102885
103133
  exports.ALL_CAPABILITY_DEFINITIONS = ALL_CAPABILITY_DEFINITIONS;
103134
+ exports.ALL_METHOD_ACCESS = ALL_METHOD_ACCESS;
102886
103135
  exports.APPEARANCE_BIN_COUNT = APPEARANCE_BIN_COUNT;
102887
103136
  exports.APPEARANCE_BLOCKS = APPEARANCE_BLOCKS;
102888
103137
  exports.APPEARANCE_DESCRIPTOR_VERSION = APPEARANCE_DESCRIPTOR_VERSION;
@@ -102916,6 +103165,7 @@ exports.AddonAutoUpdateSchema = AddonAutoUpdateSchema;
102916
103165
  exports.AddonListItemSchema = AddonListItemSchema;
102917
103166
  exports.AddonPageDeclarationSchema = AddonPageDeclarationSchema;
102918
103167
  exports.AddonPageInfoSchema = AddonPageInfoSchema;
103168
+ exports.AddonRoutesScopeSchema = AddonRoutesScopeSchema;
102919
103169
  exports.AdminLinkTargetEnum = AdminLinkTargetEnum;
102920
103170
  exports.AdoptionAdoptInputSchema = AdoptInputSchema;
102921
103171
  exports.AdoptionAdoptResultSchema = AdoptResultSchema;
@@ -103090,6 +103340,8 @@ exports.CONNECTION_TEST_TIMEOUT_MS = CONNECTION_TEST_TIMEOUT_MS;
103090
103340
  exports.CONTAINER_CHILD_PRIORITY = CONTAINER_CHILD_PRIORITY;
103091
103341
  exports.CORE_BLOCKS_ADDON_ID = CORE_BLOCKS_ADDON_ID;
103092
103342
  exports.CORE_BLOCK_ADDON_PREFIX = CORE_BLOCK_ADDON_PREFIX;
103343
+ exports.CREDENTIAL_TOKEN_AUDIENCE = CREDENTIAL_TOKEN_AUDIENCE;
103344
+ exports.CREDENTIAL_TOKEN_KIND = CREDENTIAL_TOKEN_KIND;
103093
103345
  exports.CROP_SUPPLY_SOURCES = CROP_SUPPLY_SOURCES;
103094
103346
  exports.CROP_SUPPLY_STEP_IDS = CROP_SUPPLY_STEP_IDS;
103095
103347
  exports.CUSTOMIZATION_BLOCK_NAME_PREFIX = require_composition.CUSTOMIZATION_BLOCK_NAME_PREFIX;
@@ -103267,9 +103519,9 @@ exports.CoreBlockStatusSchema = CoreBlockStatusSchema;
103267
103519
  exports.CoverStateSchema = CoverStateSchema;
103268
103520
  exports.CoverStatusSchema = CoverStatusSchema;
103269
103521
  exports.CreateIntegrationInputSchema = CreateIntegrationInputSchema;
103270
- exports.CreateScopedTokenInputSchema = CreateScopedTokenInputSchema;
103271
- exports.CreateScopedTokenResultSchema = CreateScopedTokenResultSchema;
103272
103522
  exports.CreateUserInputSchema = CreateUserInputSchema;
103523
+ exports.CredentialScopeSchema = CredentialScopeSchema;
103524
+ exports.CredentialTokenClaimsSchema = CredentialTokenClaimsSchema;
103273
103525
  exports.CustomActionInputSchema = CustomActionInputSchema;
103274
103526
  exports.CustomModelDescriptorSchema = CustomModelDescriptorSchema;
103275
103527
  exports.DATABASE_SNAPSHOT_PARTIAL_SUFFIX = DATABASE_SNAPSHOT_PARTIAL_SUFFIX;
@@ -103649,6 +103901,7 @@ exports.LABEL_SUPPLY_VOCABULARIES = LABEL_SUPPLY_VOCABULARIES;
103649
103901
  exports.LEGACY_READ_ONLY_CONFIG_KEY = LEGACY_READ_ONLY_CONFIG_KEY;
103650
103902
  exports.LINKED_DEVICES_SLOT = LINKED_DEVICES_SLOT;
103651
103903
  exports.LINKED_LABEL_STEP_PREFIX = LINKED_LABEL_STEP_PREFIX;
103904
+ exports.LLM_PROFILE_KIND_PATTERN = LLM_PROFILE_KIND_PATTERN;
103652
103905
  exports.LOAD_CONTRIBUTION_ATTRIBUTIONS = LOAD_CONTRIBUTION_ATTRIBUTIONS;
103653
103906
  exports.LOAD_CONTRIBUTION_ROLES = LOAD_CONTRIBUTION_ROLES;
103654
103907
  exports.LOCATION_DESCRIPTION_MAX = LOCATION_DESCRIPTION_MAX;
@@ -103685,10 +103938,18 @@ exports.LlmGenerateErrSchema = LlmGenerateErrSchema;
103685
103938
  exports.LlmGenerateOkSchema = LlmGenerateOkSchema;
103686
103939
  exports.LlmGenerateResultSchema = LlmGenerateResultSchema;
103687
103940
  exports.LlmImageSchema = LlmImageSchema;
103941
+ exports.LlmListModelsErrorCodeSchema = LlmListModelsErrorCodeSchema;
103942
+ exports.LlmListModelsInputSchema = LlmListModelsInputSchema;
103943
+ exports.LlmListModelsResultSchema = LlmListModelsResultSchema;
103944
+ exports.LlmModelFeaturesSchema = LlmModelFeaturesSchema;
103945
+ exports.LlmModelInfoSchema = LlmModelInfoSchema;
103688
103946
  exports.LlmNodeModelSchema = LlmNodeModelSchema;
103947
+ exports.LlmProfileFieldSchema = LlmProfileFieldSchema;
103689
103948
  exports.LlmProfileKindDescriptorSchema = LlmProfileKindDescriptorSchema;
103690
103949
  exports.LlmProfileKindSchema = LlmProfileKindSchema;
103691
103950
  exports.LlmProfileSchema = LlmProfileSchema;
103951
+ exports.LlmProviderConfigSchema = LlmProviderConfigSchema;
103952
+ exports.LlmProviderWidgetSchema = LlmProviderWidgetSchema;
103692
103953
  exports.LlmRefusalSourceSchema = LlmRefusalSourceSchema;
103693
103954
  exports.LlmRetryPolicySchema = LlmRetryPolicySchema;
103694
103955
  exports.LlmRuntimeAppleCompleteInputSchema = LlmRuntimeAppleCompleteInputSchema;
@@ -104147,6 +104408,11 @@ exports.PIPELINE_ANALYTICS_CAP_NAME = PIPELINE_ANALYTICS_CAP_NAME;
104147
104408
  exports.PIPELINE_FLOW_CAPABILITY_NAMES = PIPELINE_FLOW_CAPABILITY_NAMES;
104148
104409
  exports.PIPELINE_OWNER_CAPABILITY_NAMES = PIPELINE_OWNER_CAPABILITY_NAMES;
104149
104410
  exports.PIPELINE_RAMP = PIPELINE_RAMP;
104411
+ exports.PREFERENCES_MAX_DEVICE_ID_LENGTH = PREFERENCES_MAX_DEVICE_ID_LENGTH;
104412
+ exports.PREFERENCES_MAX_NAMESPACES = PREFERENCES_MAX_NAMESPACES;
104413
+ exports.PREFERENCES_MAX_VALUE_BYTES = PREFERENCES_MAX_VALUE_BYTES;
104414
+ exports.PREFERENCES_NAMESPACE_PATTERN = PREFERENCES_NAMESPACE_PATTERN;
104415
+ exports.PREFERENCES_SELF_SCOPE = PREFERENCES_SELF_SCOPE;
104150
104416
  exports.PRIVACY_MASK_CAP_NAME = PRIVACY_MASK_CAP_NAME;
104151
104417
  exports.PROVIDER_KIND_CAP_NAMES = PROVIDER_KIND_CAP_NAMES;
104152
104418
  exports.PROVIDER_PIN_FIELD = require_sleep.PROVIDER_PIN_FIELD;
@@ -104186,6 +104452,19 @@ exports.PlaintextSecretError = require_sleep.PlaintextSecretError;
104186
104452
  exports.PolygonPointSchema = PolygonPointSchema;
104187
104453
  exports.PoolMemoryWatchdog = PoolMemoryWatchdog;
104188
104454
  exports.PowerMeterStatusSchema = PowerMeterStatusSchema;
104455
+ exports.PreferenceDeviceIdSchema = PreferenceDeviceIdSchema;
104456
+ exports.PreferenceNamespaceSchema = PreferenceNamespaceSchema;
104457
+ exports.PreferenceRowSchema = PreferenceRowSchema;
104458
+ exports.PreferenceValueSchema = PreferenceValueSchema;
104459
+ exports.PreferencesChangedSinceInputSchema = PreferencesChangedSinceInputSchema;
104460
+ exports.PreferencesChangedSinceOutputSchema = PreferencesChangedSinceOutputSchema;
104461
+ exports.PreferencesDeleteInputSchema = PreferencesDeleteInputSchema;
104462
+ exports.PreferencesDeleteOutputSchema = PreferencesDeleteOutputSchema;
104463
+ exports.PreferencesGetInputSchema = PreferencesGetInputSchema;
104464
+ exports.PreferencesGetOutputSchema = PreferencesGetOutputSchema;
104465
+ exports.PreferencesPutInputSchema = PreferencesPutInputSchema;
104466
+ exports.PreferencesPutOutputSchema = PreferencesPutOutputSchema;
104467
+ exports.PreferencesSelfScopeSchema = PreferencesSelfScopeSchema;
104189
104468
  exports.PresenceStatusSchema = PresenceStatusSchema;
104190
104469
  exports.PressureSensorStatusSchema = PressureSensorStatusSchema;
104191
104470
  exports.PrivacyMaskOptionsSchema = PrivacyMaskOptionsSchema;
@@ -104434,6 +104713,7 @@ exports.SETTINGS_ARRAY_ADOPTS_PREFIX = require_sleep.SETTINGS_ARRAY_ADOPTS_PREFI
104434
104713
  exports.SETTINGS_BROKERS_ADOPTS_PREFIX = require_sleep.SETTINGS_BROKERS_ADOPTS_PREFIX;
104435
104714
  exports.SHARE_SOURCE_SETTING_KEY = SHARE_SOURCE_SETTING_KEY;
104436
104715
  exports.SHARE_VIEW_KINDS = require_sleep.SHARE_VIEW_KINDS;
104716
+ exports.SHARE_VIEW_MAX_DEVICES = SHARE_VIEW_MAX_DEVICES;
104437
104717
  exports.SINGLE_HUB_ADDRESS_ROLES = SINGLE_HUB_ADDRESS_ROLES;
104438
104718
  exports.SOURCE_CAPS = require_composition.SOURCE_CAPS;
104439
104719
  exports.SOURCE_CAP_ACTIVE_FIELD = require_composition.SOURCE_CAP_ACTIVE_FIELD;
@@ -104467,7 +104747,6 @@ exports.SceneUnavailableSchema = SceneUnavailableSchema;
104467
104747
  exports.SceneUncoveredPolicySchema = SceneUncoveredPolicySchema;
104468
104748
  exports.SceneVerdictSchema = SceneVerdictSchema;
104469
104749
  exports.ScopedTokenSchema = ScopedTokenSchema;
104470
- exports.ScopedTokenSummarySchema = ScopedTokenSummarySchema;
104471
104750
  exports.ScoredObjectEventSchema = ScoredObjectEventSchema;
104472
104751
  exports.ScriptRunnerStatusSchema = ScriptRunnerStatusSchema;
104473
104752
  exports.SearchResultSchema = SearchResultSchema;
@@ -104498,6 +104777,8 @@ exports.SettingsRecordSchema = SettingsRecordSchema;
104498
104777
  exports.SettingsSchemaWithValuesSchema = SettingsSchemaWithValuesSchema;
104499
104778
  exports.SettingsUpdateResultSchema = SettingsUpdateResultSchema;
104500
104779
  exports.ShareSourceSchema = ShareSourceSchema;
104780
+ exports.ShareViewGrantSchema = ShareViewGrantSchema;
104781
+ exports.ShareViewScopeSchema = ShareViewScopeSchema;
104501
104782
  exports.ShareWeightsSchema = ShareWeightsSchema;
104502
104783
  exports.SiteLocationSchema = SiteLocationSchema;
104503
104784
  exports.SiteLocationSourceSchema = SiteLocationSourceSchema;
@@ -104858,6 +105139,7 @@ exports.canConvertUnit = canConvertUnit;
104858
105139
  exports.canonicalEgressPlan = canonicalEgressPlan;
104859
105140
  exports.canonicalIconKey = canonicalIconKey;
104860
105141
  exports.canonicalizeAppCallback = canonicalizeAppCallback;
105142
+ exports.capabilityScopesOf = capabilityScopesOf;
104861
105143
  exports.capacitySessionsOf = capacitySessionsOf;
104862
105144
  exports.carbonMonoxideCapability = carbonMonoxideCapability;
104863
105145
  exports.cellsToRects = cellsToRects;
@@ -105147,6 +105429,7 @@ exports.isBaseConditionKey = isBaseConditionKey;
105147
105429
  exports.isBatteryPresenceFault = isBatteryPresenceFault;
105148
105430
  exports.isClusterScopedStep = isClusterScopedStep;
105149
105431
  exports.isCollectionArrayMethod = isCollectionArrayMethod;
105432
+ exports.isCredentialTokenPayload = isCredentialTokenPayload;
105150
105433
  exports.isDefaultAlarmProfileId = isDefaultAlarmProfileId;
105151
105434
  exports.isDefaultAppConnectionEndpoint = isDefaultAppConnectionEndpoint;
105152
105435
  exports.isDefinitiveDeviceRefusal = isDefinitiveDeviceRefusal;
@@ -105312,6 +105595,7 @@ exports.parseAppAuthCallback = parseAppAuthCallback;
105312
105595
  exports.parseAppFlowRequest = parseAppFlowRequest;
105313
105596
  exports.parseAppPageLang = parseAppPageLang;
105314
105597
  exports.parseCameraStreamConfig = parseCameraStreamConfig;
105598
+ exports.parseCredentialScopes = parseCredentialScopes;
105315
105599
  exports.parseDeviceEnrollmentLink = parseDeviceEnrollmentLink;
105316
105600
  exports.parseExpression = require_composition.parseExpression;
105317
105601
  exports.parseJsonArray = require_sleep.parseJsonArray;
@@ -105483,7 +105767,10 @@ exports.schemaDeclaresAnyField = require_sleep.schemaDeclaresAnyField;
105483
105767
  exports.scopeInherits = scopeInherits;
105484
105768
  exports.scopeKey = require_sleep.scopeKey;
105485
105769
  exports.scopesAllowAddon = scopesAllowAddon;
105770
+ exports.scopesAllowAddonRoutes = scopesAllowAddonRoutes;
105486
105771
  exports.scopesAllowDeviceCap = scopesAllowDeviceCap;
105772
+ exports.scopesAllowOwnPreferences = scopesAllowOwnPreferences;
105773
+ exports.scopesGrantAdmin = scopesGrantAdmin;
105487
105774
  exports.scoreRuntimes = scoreRuntimes;
105488
105775
  exports.scriptRunnerCapability = scriptRunnerCapability;
105489
105776
  exports.scrubKnownSecrets = require_sleep.scrubKnownSecrets;
@@ -105507,6 +105794,7 @@ exports.settingsArrayAdoptsFrom = require_sleep.settingsArrayAdoptsFrom;
105507
105794
  exports.settingsBelow = settingsBelow;
105508
105795
  exports.settingsBrokersAdoptsFrom = require_sleep.settingsBrokersAdoptsFrom;
105509
105796
  exports.settingsStoreCapability = settingsStoreCapability;
105797
+ exports.shareViewGrantOf = shareViewGrantOf;
105510
105798
  exports.shortHostname = shortHostname;
105511
105799
  exports.shortSecretRefHash = require_sleep.shortSecretRefHash;
105512
105800
  exports.signalPercentFromBars = signalPercentFromBars;