/** * Top-level provider mode — the user's intent, not the concrete vendor. * * - `on-device`: the user wants inference to run locally (privacy, offline, latency). * - `motebit-cloud`: the user wants the default product experience (subscription, auto-routing). * - `byok`: the user brings their own API key to a named vendor. */ export type ProviderMode = "on-device" | "motebit-cloud" | "byok"; /** * On-device backend kinds. Not every backend is available on every platform: * * - `apple-fm`: Apple Foundation Models (iOS/macOS 26+ only). * - `mlx`: MLX runtime (Apple Silicon, iOS 16+ / macOS). * - `webllm`: MLC WebLLM in-browser (web surface + WebGPU only). * - `local-server`: auto-detected local OpenAI-compatible server * (Ollama, LM Studio, llama.cpp, Jan, vLLM, …). Vendor-agnostic. */ export type OnDeviceBackend = "apple-fm" | "mlx" | "webllm" | "local-server"; /** * BYOK vendors — the only ones where the user holds the API key directly. * * Closed-set additive registry; fourth instance of the agility-as-role * pattern (`docs/doctrine/agility-as-role.md` — alongside `SuiteId` for * cryptosuites, "permissive floor" for licenses, `GuestRail`/`SovereignRail` * for settlement). The role is "foundation-model vendor accessible via * OpenAI-compatible wire protocol (or Anthropic's, for Anthropic itself)." * Adding a vendor is a registry append + dispatch arm + default-model * entry; the closure is enforced by exhaustive-switch typechecks in * `provider-resolver.ts` and the api-extractor baseline gate. * * `deepseek` lands as the fourth instance — DeepSeek V3 is roughly * Claude-Sonnet-class on tool-use benchmarks at ~10× cheaper pricing, * served via DeepSeek's OpenAI-compatible API. Closes the doctrinal * asymmetry where motebit's "intelligence is pluggable" founding claim * (`CLAUDE.md` opening) was contradicted by a 3-vendor registry of * exclusively-expensive Big Tech providers. The role stays closed at * the wire-vocab boundary; affordability lands now for capital- * constrained users via the additive registry shape. */ export type ByokVendor = "anthropic" | "openai" | "google" | "groq" | "deepseek"; /** On-device mode config. */ export interface OnDeviceProviderConfig { mode: "on-device"; backend: OnDeviceBackend; /** Model identifier. Meaning depends on backend (MLX name, WebLLM id, server tag, …). */ model?: string; /** For `local-server`: endpoint URL (e.g., http://localhost:11434). Auto-detected otherwise. */ endpoint?: string; /** Optional temperature override. */ temperature?: number; /** Optional max_tokens override. */ maxTokens?: number; /** * Opt into auto-routing across the on-device backend's available * models per turn. When `true` AND `backend` supports multi-model * routing (`local-server` today; `apple-fm` / `mlx` / `webllm` are * single-model surfaces where per-turn routing has no models to * choose between), surface runtimes consume the third-consumer * half of the auto-routing primitive * (`@motebit/policy::dispatchOnDeviceRouting`) to pick the best * model for each turn's `TaskShape` from the backend's catalog. * When `false` or omitted, the surface uses the single configured * `model` (backward-compat default). * * Doctrine: `docs/doctrine/auto-routing-as-protocol-primitive.md` * § "PR 3 — on-device consumer". The primitive lives in * `@motebit/policy/on-device-router.ts`; surface wiring is the * consumer site registered in the drift gate * `check-routing-decision-coverage` (#95). No balance filter — * on-device runs on the user's hardware with zero marginal * $/token cost. * * Per `feedback_sovereignty_orthogonal`: orthogonal to tier — * on-device auto-routing is never subscription-gated. The user * owns the hardware; the surface's job is to compose the * canonical dispatcher over it. */ autoRoute?: boolean; } /** Motebit Cloud mode config — the subscription-backed product. */ export interface MotebitCloudProviderConfig { mode: "motebit-cloud"; /** Optional preferred model. When omitted, the relay picks. */ model?: string; /** Signed proxy token — included as x-proxy-token for authenticated requests. */ proxyToken?: string; /** Override proxy base URL (dev/staging). */ baseUrl?: string; temperature?: number; maxTokens?: number; } /** BYOK mode config — user supplies the API key. */ export interface ByokProviderConfig { mode: "byok"; vendor: ByokVendor; apiKey: string; model?: string; /** * Optional custom base URL. Used e.g. for Google via the OpenAI-compatible * endpoint (`https://generativelanguage.googleapis.com/v1beta/openai`). */ baseUrl?: string; temperature?: number; maxTokens?: number; /** * Opt into auto-routing across the vendor's available models per turn. * When `true`, surface runtimes consume the second-consumer half of the * auto-routing primitive (`@motebit/policy::dispatchByokRouting`) to * pick the best model for each turn's `TaskShape` from the vendor's * catalog. When `false` or omitted, the surface uses the single * configured `model` (backward-compat default). * * Doctrine: `docs/doctrine/auto-routing-as-protocol-primitive.md` * § "PR 2 — BYOK consumer". The primitive lives in `@motebit/policy`; * the per-surface wiring (web today; desktop/mobile mirror following) * is the consumer site registered in the drift gate * `check-routing-decision-coverage` (#95). No balance filter — BYOK * users pay providers directly; balance is motebit-cloud-specific. * * Per `feedback_sovereignty_orthogonal`: this flag is orthogonal to * tier — BYOK auto-routing is never subscription-gated. The user * already has the vendor's key; the surface's job is to compose the * canonical dispatcher over it. */ autoRoute?: boolean; } /** Union of all three modes. Surfaces persist this shape. */ export type UnifiedProviderConfig = OnDeviceProviderConfig | MotebitCloudProviderConfig | ByokProviderConfig; /** * Heuristic: is this URL pointing at a local inference server? * Shared across all surfaces so the migration behaves identically everywhere. */ export declare function isLocalServerUrl(url: string | undefined | null): boolean; /** Sensible default when no config has ever been persisted. */ export declare function defaultProviderConfig(): MotebitCloudProviderConfig; /** * Whether inference under this provider mode is free to the user — the * user's own compute (`on-device`) or own vendor API key (`byok`) pays * for it, not a metered allocation the operator bills. `motebit-cloud` * is metered (subscription / proxy allocation), so background work the * user did not initiate must stay opt-in there. * * Single source of truth for the "proactive consolidation defaults ON * only when inference is free" policy (`docs/doctrine/proactive-interior.md`). * Every surface (web / desktop / mobile) consumes this instead of inlining * the mode comparison, so the default-on policy cannot drift between them. * Exhaustive switch: a future `ProviderMode` entry forces an explicit * free-or-metered decision here rather than silently defaulting on. */ export declare function inferenceIsFreeToUser(mode: ProviderMode): boolean; //# sourceMappingURL=provider-mode.d.ts.map