refactor(provider-auth): extract model-provider auth out of chat-legacy
Pure refactor, zero behavior change. Unblocks deleting legacy chat and lets the sandbox runtime answer provider-auth status without importing the mastra chat world.
Why
packages/chat-legacy was misnamed. Of its 74 files, most were per-machine model-provider auth (ChatService, OAuth flow controllers, API-key storage, anthropic env config) and AI naming (getSmallModel, generateTitleFromMessage) — not chat. Those non-chat consumers are precisely why the legacy chat UI has been undeletable: host-service's auth.* router, workspace AI naming, and the desktop settings/models + onboarding screens all reached into a package whose name implied it was disposable.
Concretely for sandboxes: the sandbox API includes auth.getAnthropicStatus/getOpenAIStatus, both backed by ctx.runtime.auth = a ChatService from chat-legacy. Without this split, a sandbox image would pull in @mastra/mcp, @mastra/memory, and mastracode just to answer "is Anthropic configured?".
What moved
git mv throughout — 53 renames, only 3 relative-import edits; everything else byte-identical.
chat-legacy/src/server/desktop/**→provider-auth/src/server/**(43 files)chat-legacy/src/server/shared/**→provider-auth/src/server/shared/**(AI naming; kept server-only so node deps stay out of the renderer bundle)chat-legacy/src/shared/**→provider-auth/src/shared/**(isomorphic slash-command parsers)chat-service-provider.tsx→provider-auth/src/client/
One known wart, deliberate
ChatServiceRouter is a single tRPC router with two namespaces: auth.* (16 provider-auth procedures) and workspace.* (slash commands, file search, MCP overview). Splitting it into two independently-typed clients would mean a second React tRPC context, provider, query cache, and new IPC paths — a rewiring, not a move, and therefore behavior-changing. So the whole router moved, dragging slash-commands/, router/file-search/, router/mcp-overview/ and the isomorphic src/shared along as passengers in a package named provider-auth.
Leaving them behind was not an option: server/slash-commands/resolver.ts imports src/shared, so a split would create a provider-auth ↔ chat-legacy workspace cycle, which turbo rejects outright. The chat-deletion PR should remove those passengers at the same time it deletes chat-legacy. Dependency direction is now one-way and clean: chat-legacy → provider-auth, never the reverse (verified: zero chat-legacy references inside provider-auth).
Result
- host-service imports chat-legacy zero times
- chat-legacy is down to 21 files, all genuinely chat, imported by 13 files — entirely the v1 ChatPane tree plus its Electron-main runtime router. That is now an exact, verified deletion list
biome.jsonc's frozen sync-subprocess allowlist entry was repointed so the ratchet exemption doesn't silently un-freeze
Verification
lint exit 0 · typecheck exit 0 (37/37, all affected packages cache-miss) · sherif exit 0 · provider-auth 106/106 · chat-legacy 24/24 · host-service 1072/1072 (neither known flake appeared) · desktop 2695/2695
Summary by cubic
Extracts model-provider auth and AI naming from @superset/chat-legacy into @superset/provider-auth with no behavior changes. This unblocks deleting the legacy chat UI and lets non-chat runtimes depend on provider-auth without pulling the chat stack.
- Moves ChatService, OAuth flows, auth storage, small-model selection, title generation, slash-commands, file search, and MCP overview into
@superset/provider-authvia git mv (byte-identical except a few import paths). - Keeps the single tRPC
ChatServiceRouter(namespacesauth.*andworkspace.*) intact to avoid behavior-changing rewiring; these features now live in@superset/provider-auth. @superset/host-serviceand Desktop now import@superset/provider-auth; they no longer import@superset/chat-legacy. Dependency direction is one-way:@superset/chat-legacy→@superset/provider-auth.@superset/chat-legacynow only holds the v1 chat pane and its runtime router (21 files), forming a clean deletion list.- Updates
biome.jsoncratchet path for the Anthropic env check.
Migration notes
- Replace imports:
@superset/chat-legacy/server/desktop→@superset/provider-auth/server@superset/chat-legacy/server/shared→@superset/provider-auth/server/shared@superset/chat-legacy/shared→@superset/provider-auth/shared@superset/chat-legacy/client(ChatServiceProvider, chatServiceTrpc) →@superset/provider-auth/client
- Continue using
@superset/chat-legacy/clientonly for ChatRuntimeService. No API changes expected; typecheck will surface any missed paths.
Summary by CodeRabbit
-
New Features
- Added centralized authentication for OpenAI and Anthropic, including API keys, OAuth, credential storage, and environment configuration.
- Added support for Anthropic OAuth and Claude Code credentials.
- Added slash-command discovery, aliases, argument parsing, built-in commands, and project/global command resolution.
- Added MCP server overview and workspace file search capabilities.
- Added automatic AI-assisted workspace naming and title generation.
-
Refactor
- Migrated chat and provider authentication functionality to the new authentication service.