Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove plexus.yaml entirely; adminKey/DATABASE_URL/PORT become env vars - Rename oauth_provider -> oauth_provider_type, settings -> system_settings, alias_type -> model_type - All PKs changed to integer surrogate keys with text UNIQUE slug/name columns - All enum-valued columns use PG native ENUMs + SQLite CHECK constraints - All JSON columns use jsonb universally (SQLite >= 3.38) - All timestamps use bigint (epoch ms) per project conventions - oauth_account replaced with oauth_credential_id FK to oauth_credentials table - Drop YAML config editor page (Config.tsx) - Drop auth.json backward compat references - Drop backward compat YAML section - Export endpoint returns structured JSON instead of YAML - Clarify Drizzle ORM used for all DB operations including import - Remove multi-instance cache invalidation and YAML editor open questions - No sentinel added to plexus.yaml on migration (empty-table check is sufficient) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…, quotas, etc.) Create Drizzle ORM schema definitions for all 9 new config tables for both SQLite and PostgreSQL dialects: - providers, provider_models, model_aliases, model_alias_targets - api_keys, user_quota_definitions, mcp_servers - system_settings, oauth_credentials Generate migrations for both dialects and register new tables in the database client initialization. https://claude.ai/code/session_017Kuqoku3RByiS6u4FxfAZD
Add ConfigRepository class that encapsulates all config operations against the database using Drizzle ORM. Handles: - Providers + provider models (with JSON serialization for both dialects) - Model aliases + targets - API keys - User quota definitions - MCP servers - System settings (key-value store) - OAuth credentials - Boolean/JSON conversion between SQLite and PostgreSQL https://claude.ai/code/session_017Kuqoku3RByiS6u4FxfAZD
Add ConfigService singleton that replaces YAML-file-based config: - In-memory PlexusConfig cache loaded from DB - CRUD operations that update DB then rebuild cache - YAML import for first-launch bootstrap (providers, aliases, keys, quotas, MCP servers, settings, exploration rates) - auth.json import for OAuth credentials - Export endpoint for backup - buildProviderQuotaConfigs mirrored from config.ts Update getConfig() in config.ts to delegate to ConfigService when available, falling back to file-based config for backward compat. https://claude.ai/code/session_017Kuqoku3RByiS6u4FxfAZD
Reorder initialization: database first, then config loading. On first launch (empty providers table), auto-import from plexus.yaml and auth.json if they exist. Subsequent launches load config directly from the database via ConfigService. https://claude.ai/code/session_017Kuqoku3RByiS6u4FxfAZD
Replace all YAML file read/write operations in config and user-quota routes with ConfigService CRUD calls. Add new granular endpoints: - GET/POST/DELETE /v0/management/providers/:slug - GET/POST /v0/management/aliases/:slug - GET/POST/DELETE /v0/management/keys/:name - GET/PATCH /v0/management/system-settings - GET /v0/management/config/export All operations now go through the database via ConfigService. https://claude.ai/code/session_017Kuqoku3RByiS6u4FxfAZD
Replace auth.json file I/O with database operations via ConfigService. OAuth credentials are now stored in the oauth_credentials table. Keep in-memory cache for fast lookups, with async DB writes on changes. Token refresh writes updated credentials back to DB. https://claude.ai/code/session_017Kuqoku3RByiS6u4FxfAZD
- Remove YAML parsing from frontend; all API calls now use JSON endpoints - Rewrite getKeys, saveKey, deleteKey to use /v0/management/keys endpoints - Rewrite getProviders, saveProvider to use /v0/management/providers endpoints - Rewrite getAliases, saveAlias to use /v0/management/aliases endpoints - Rewrite getModels to derive from /v0/management/providers - Remove unused saveProviders, getConfigQuotas, saveConfigQuota, deleteConfigQuota - Convert Config.tsx from YAML editor to read-only JSON config viewer - Update fetchConfigCached to parse JSON instead of YAML https://claude.ai/code/session_017Kuqoku3RByiS6u4FxfAZD
- Remove loadConfig, parseConfigFile, setupWatcher, getConfigPath from config.ts - Remove getAuthJsonPath (inline in index.ts for first-launch import) - Remove logConfigStats and file watcher variables - Remove unused fs, path, QuotaScheduler imports from config.ts - Remove YAML content type parser from config routes - Remove unused getConfig import from user-quotas routes - Remove unused loadConfig import from test setup https://claude.ai/code/session_017Kuqoku3RByiS6u4FxfAZD
- Add FK constraints for providers.oauth_credential_id (schema + migrations) - Fix hard-coded 'legacy' oauth_account by resolving from oauth_credentials - Add quota validation to PATCH endpoint matching POST rules - Stop swallowing operational errors in getConfig() fallback - Use __dirname for robust plexus.yaml discovery across working directories - Add clearAllData() rollback on failed bootstrap import - Fix OAuthAuthManager race condition with awaitable initialize() - Await database writes in setCredentials and token refresh - Fix non-atomic rename flows in frontend (create-first, delete-after) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Admin key is now exclusively read from the ADMIN_KEY environment variable instead of the config file or database. The server exits on startup if ADMIN_KEY is not set. DATABASE_URL defaults to sqlite://<DATA_DIR>/plexus.db when not provided. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Narrow type guard in config path finder (Boolean → typeof) - Add attemptCount/retryHistory to UnifiedTranscriptionResponse.plexus - Fix Fastify inject json() type mismatch in admin-auth test - Remove unused imports, fix TimeRange type mismatches across components - Widen getUsageRangeConfig/formatBucketLabel to accept 'custom' range - Add default case to getRangeConfig switch for exhaustiveness - Fix aggregateByTime references to out-of-scope variables Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove conflicting 0018* migration files from PR branch - Extract shared PG enums to postgres/enums.ts to fix circular dependency between providers.ts and oauth-credentials.ts - Generate new SQLite migration 0019_cool_the_hand.sql - Generate new PG migration 0019_misty_cannonball.sql - Run biome formatter
…torage - Update oauth.test.ts to verify credentials via OAuthAuthManager in-memory state instead of checking auth.json file (which no longer exists) - Remove file-based test setup (tempDir, authPath, AUTH_JSON env var) - Handle 'no such table: oauth_credentials' gracefully in loadFromDatabaseAsync and deleteCredentials to support test environments where migrations may not have created the table yet in the current worker's DB - Fix getConfig() fallback to include 'not initialized' in the error check - Update setConfigForTesting() to also prime ConfigService cache
d1db690 to
fcb75b0
Compare
|
Fixed some merge conflicts and test failures, and rebased on main. Initial migration seemed decent, but it seems like some bugs around provider management, especially for oauth providers: Delete Retain Doesn't Work: Failed to delete provider: Error: Internal server error 026-03-08 20:55:04 [info]: DELETE /v0/management/providers/copilot Cascade Delete didn't actually delete cascade in the models Copilot not working - fetch failure. |
Three bugs fixed: 1. DELETE route now returns actual error message instead of generic "Internal server error", so the frontend can display useful feedback. 2. Cascade delete now explicitly removes model_alias_targets referencing the provider slug (not connected by FK, only by text slug). 3. Non-cascade "Retain Targets" path no longer throws when provider has provider_models — it deletes the provider (FK cascades provider_models) while keeping model_alias_targets intact as intended. https://claude.ai/code/session_01U3HoiG5gcEYuYC7rTMqwy3
…ion-9XnZm Fix provider deletion: cascade cleanup and error reporting
…tions with validation
…te API usage method
…kers. Adjust claude code checker to use the usage endpoint
The PATCH /v0/management/debug handler referenced patchDebugSchema which was never defined or imported, causing a ReferenceError at runtime whenever the debug toggle was used from the UI.
Moves from yaml file to database.
Next steps will be encryption of keys.