mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-16 23:19:40 +02:00
Phase 1-3 of BYOK support. Introduces a 5th LLM tier 'byok' that routes to user-provided API keys via direct browser fetches. shared-llm additions: - LlmTier extended with 'byok' (rank 3, between mana-server and cloud) - ByokBackend: LlmBackend implementation that delegates key lookup to an app-provided resolver callback, then dispatches to the right provider adapter - 4 provider adapters: - OpenAI (gpt-5, gpt-4o, o1 family) - Anthropic (Claude Opus/Sonnet/Haiku 4.6) with CORS header - Gemini (2.5 Pro/Flash) — REST API with different message format - Mistral — OpenAI-compatible, reuses shared openai-compat adapter - Pricing table for 20+ models with USD per 1M tokens - estimateCost() + formatCost() helpers Keys stay device-local (IndexedDB in next phase). Browser-direct fetches mean keys never touch Mana's server. Updates two existing tier maps (memoro DetailView, SourceBadge) to include the new tier. Planning doc at docs/architecture/BYOK_PLAN.md. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
74 lines
1.8 KiB
TypeScript
74 lines
1.8 KiB
TypeScript
// Tiers + types
|
|
export { ALL_TIERS, TIER_RANK, tierLabel, type LlmTier } from './tiers';
|
|
export type {
|
|
CapabilityRequirements,
|
|
ChatMessage,
|
|
ContentClass,
|
|
GenerateOptions,
|
|
GenerateResult,
|
|
LlmBackend,
|
|
LlmSettings,
|
|
LlmTaskRequest,
|
|
LlmTaskResult,
|
|
} from './types';
|
|
export { DEFAULT_LLM_SETTINGS } from './types';
|
|
|
|
// Errors
|
|
export {
|
|
BackendUnreachableError,
|
|
EdgeLoadFailedError,
|
|
LlmError,
|
|
NoTierAvailableError,
|
|
ProviderBlockedError,
|
|
TierTooLowError,
|
|
} from './errors';
|
|
|
|
// Task contract
|
|
export { buildTaskRequest, type LlmTask } from './task';
|
|
|
|
// Persistent task queue
|
|
export {
|
|
LlmTaskQueue,
|
|
type EnqueueOptions,
|
|
type LlmTaskQueueOptions,
|
|
type QueuedTask,
|
|
type QueuedTaskState,
|
|
type TaskRegistry,
|
|
} from './queue';
|
|
|
|
// Orchestrator (rarely instantiated directly — most consumers use the
|
|
// store's singleton instead)
|
|
export { LlmOrchestrator, type LlmOrchestratorOptions } from './orchestrator';
|
|
|
|
// Backends (exported for tests + custom orchestrator setups)
|
|
export { BrowserBackend } from './backends/browser';
|
|
export { CloudBackend, type CloudBackendOptions } from './backends/cloud';
|
|
export { ManaServerBackend, type ManaServerBackendOptions } from './backends/mana-server';
|
|
export {
|
|
ByokBackend,
|
|
type ByokBackendOptions,
|
|
type ByokKeyResolver,
|
|
type ResolvedByokKey,
|
|
type ByokUsageCallback,
|
|
} from './backends/byok';
|
|
export {
|
|
BUILTIN_BYOK_PROVIDERS,
|
|
openaiProvider,
|
|
anthropicProvider,
|
|
geminiProvider,
|
|
mistralProvider,
|
|
type ByokProvider,
|
|
type ByokProviderId,
|
|
type ByokCallOptions,
|
|
} from './backends/byok-providers';
|
|
|
|
// Pricing
|
|
export { MODEL_PRICING, estimateCost, formatCost, type ModelPricing } from './pricing';
|
|
|
|
// Singleton store + Svelte 5 reactive hooks
|
|
export {
|
|
llmOrchestrator,
|
|
llmSettingsState,
|
|
updateLlmSettings,
|
|
useTaskAvailability,
|
|
} from './store.svelte';
|