Skip to content

refactor: modularize providerRegistry.ts (Issue #3594) - #3617

Closed
oyi77 wants to merge 49 commits into
diegosouzapw:release/v3.8.24from
oyi77:refactor/modularize-providerRegistry
Closed

oyi77 wants to merge 49 commits into
diegosouzapw:release/v3.8.24from
oyi77:refactor/modularize-providerRegistry

Conversation

@oyi77

@oyi77 oyi77 commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR addresses the high-priority massive file open-sse/config/providerRegistry.ts (4,676 lines) as part of the WordPress-style Plugin System modularization effort tracked in #3594.

Changes

  • Extracted types, shared constants, and dependencies into open-sse/config/providers/shared.ts.
  • Split the monolithic REGISTRY object into 5 alphabetical domain chunks:
    • a-c.ts
    • d-h.ts
    • i-o.ts
    • p-s.ts
    • t-z.ts
  • Assembled the registry in open-sse/config/providers/index.ts and re-exported it from providerRegistry.ts to maintain full backward compatibility for existing imports.

Verification

  • npm run typecheck:core passes.
  • npx eslint open-sse/config/providers/* has 0 errors/warnings.
  • No production behavior changes, strictly structural.

Resolves part of #3594.

@oyi77
oyi77 requested a review from diegosouzapw as a code owner June 11, 2026 05:34
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@oyi77
oyi77 force-pushed the refactor/modularize-providerRegistry branch from 16ddf2f to 501f833 Compare June 11, 2026 05:40
@oyi77

oyi77 commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

Update: Addressed architectural feedback!

The previous alphabetical grouping (a-c.ts, d-h.ts, etc.) was indeed an anti-pattern for a true WordPress-style plugin system.

I have completely refactored the extraction to establish a strict One-File-Per-Provider architecture. There are now exactly 159 individual provider files inside open-sse/config/providers/registry/.

This means when we add a new provider in the future, it's just a matter of dropping a new standalone .ts file into that directory, and the index.ts handles the rest.

Typechecking and linting both pass cleanly.

@oyi77
oyi77 force-pushed the refactor/modularize-providerRegistry branch from 501f833 to 65071ae Compare June 11, 2026 05:48
@oyi77

oyi77 commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

Update 2: Sub-categorization and DRY Headers!

As requested, I've further refined the one-file-per-provider structure.

  1. Sub-Categorization: Highly-related provider variants are now grouped into dedicated sub-directories. For example:

    • minimax and minimax-cn → registry/minimax/default.ts and registry/minimax/cn.ts
    • glm, glm-cn, glmt → registry/glm/default.ts, registry/glm/cn.ts, registry/glm/t.ts
    • opencode, opencode-go, opencode-zen → registry/opencode/default.ts, etc.
      This keeps the top-level registry/ folder clean and organized while maintaining the strictly modular 1-file-per-variant rule.
  2. DRY Helpers: I scanned the 159 extracted files for duplicated logic and extracted them into reusable helpers inside shared.ts:

    • getClaudeCliHeaders() for the massive 14-line Claude CLI header block shared by agentrouter and claude.
    • getAnthropicCompatHeaders() for the recurring Anthropic-Version headers in providers like minimax, minimax-cn, zai, and bailian-coding-plan.
    • buildAntigravityUrl() for the repeating streaming/non-streaming logic shared between agy and antigravity.

All tests, typings, and ESLint checks pass locally. This sets up a flawless foundation for the plugin system!

@oyi77
oyi77 force-pushed the refactor/modularize-providerRegistry branch from 65071ae to 5b9177b Compare June 11, 2026 05:50
@oyi77

oyi77 commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

Update 3: True Folder-as-Module Refactor!

As an ultimate refinement to the plugin architecture, I've refactored all 159 individual provider files into the folder-as-module pattern.

Now, every single provider lives in its own dedicated directory with an index.ts file.
For example:

  • registry/openai/index.ts
  • registry/anthropic/index.ts

And the variants elegantly nest inside their parent's folder:

  • registry/minimax/index.ts (default)
  • registry/minimax/cn/index.ts (variant)
  • registry/opencode/index.ts (default)
  • registry/opencode/go/index.ts (variant)

This provides exactly the foundation needed for a WordPress-style plugin system. When a provider gets complex, it can now have local utils.ts, types.ts, or tests/ co-located directly inside its own folder without polluting the global scope!

All tests and linting verified 100% green.

@diegosouzapw
diegosouzapw changed the base branch from main to release/v3.8.23 June 12, 2026 01:19
zhiru and others added 20 commits June 12, 2026 02:40
…osouzapw#3685) (diegosouzapw#3702)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…API (diegosouzapw#3712)

Integrated into release/v3.8.23. Vertex dynamic model discovery — surfaces image models (imagen-*, gemini-*-image), embeddings and audio from the live Generative Language catalog, with cached→static fallback and the shared parseGeminiModelsList helper. Validated: parser test 5/5, typecheck:core clean.
Integrated into release/v3.8.23. Makes the diegosouzapw#3588 reasoning token buffer safe and configurable: only inflates max_tokens when the model has a known, non-default output cap and the buffered value fits inside it; otherwise preserves/clamps the client limit. Adds the reasoningTokenBufferEnabled kill switch (default ON). Validated: combo-routing-engine 81/81, combo-config 25/25, combo-quality-validator-reasoning 12/12, phase1f 10/10, typecheck:core clean.
…3408 LOC (-654) (diegosouzapw#3717)

Phase 1g-1j of diegosouzapw#3501: client 4062→3408 LOC. Pure extraction (ProviderPlaygroundPanel, useCommandCodeAuth, useExternalLinkFlow+ExternalLinkModal, useAuthFileHandlers) + loadConnProxies ReferenceError fix + phase1f test path fix.

Co-authored-by: oyi77 <14921983+oyi77@users.noreply.github.com>
…2553 LOC (-855) (diegosouzapw#3721)

Phase 1k-1m of diegosouzapw#3501: client 3408→2553 LOC. Pure extraction (useModelImportHandlers+ImportProgressModal, useModelVisibilityHandlers, ProviderModelsSection).

Co-authored-by: oyi77 <14921983+oyi77@users.noreply.github.com>
… release branch

The fix itself reached main pre-tag via cherry-pick diegosouzapw#3591, but its changelog
bullet (commit e33fdd4) only ever existed on release/v3.8.20 after the
squash-merge. Restored under [3.8.20] per the 2026-06-12 release-branch
leftover audit (_tasks/release-audit/release-leftovers-audit-2026-06-12.md).
…1376 LOC (-1177) (diegosouzapw#3725)

Phase 1n-1s of diegosouzapw#3501: client 2553→1376 LOC. Pure extraction (ConnectionsListPanel, ConnectionsHeaderToolbar, ZedImportCard, BatchTestResultsModal, AdaptaTutorialModal, useApiKeySave + helpers).

Co-authored-by: oyi77 <14921983+oyi77@users.noreply.github.com>
…cation, and success-decay recovery (diegosouzapw#3629)

Integrated into release/v3.8.23
… LOC (≤800 TARGET REACHED ✅) (diegosouzapw#3727)

Phase 1t of diegosouzapw#3501: client 1376→781 LOC (≤800 reached). Original god-component 12,882→781 (−94%).

Co-authored-by: oyi77 <14921983+oyi77@users.noreply.github.com>
diegosouzapw and others added 14 commits June 13, 2026 02:22
Integrated into release/v3.8.21 — chatCore phase modularization. Adjusted: re-derive idempotencyKey for the save path after the check moved into the module (co-authored). Thanks @oyi77!
…iegosouzapw#3588 (combo reasoning buffer)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…drop shadow/guardrails doc-fiction (diegosouzapw#3496) (diegosouzapw#3602)

Integrated into release/v3.8.21 — implements GET /api/guardrails + POST /api/guardrails/test, removes shadow/guardrails doc-fiction. TDD-validated (5/5) + check-docs-symbols/typecheck/eslint green.
Split-out PR C from diegosouzapw#3584. Isolates textual reasoning wrappers (<think>/<thinking>/<thought>/<internal_thought>, including malformed/open tags) into reasoning_content across both the non-streaming sanitizer and the Gemini streaming translator, with split-chunk buffering. Additive to the existing textual tool-call pipeline; does not touch the diegosouzapw#3569 native functionResponse path. Integrated into release/v3.8.21. Thanks @dhaern!
)

Split-out PR A from diegosouzapw#3584. Normalizes the Antigravity/agy Gemini 3.5 Flash tier IDs to clean public names (gemini-3.5-flash-low/medium/high), maps them to the live upstream IDs at the executor boundary, and removes Antigravity from the global model resolver so the executor owns wire normalization. Maintainer follow-up: kept gemini-3.5-flash-preview as a hidden backward-compat alias routing to the High tier (so saved combos/configs keep working). Live-validated the tier set via the agy CLI catalog. Integrated into release/v3.8.21. Thanks @dhaern!
…pw#3604)

Split-out PR B from diegosouzapw#3584. Normalizes Antigravity/agy provider quotas: prefers retrieveUserQuota for live consumption, falls back to fetchAvailableModels and local usage_history, sanitizes cached Provider Limits so retired upstream IDs are not re-exposed, and schedules a deduplicated post-usage refresh. Maintainer follow-up: decoupled the post-usage refresh via a lightweight usageEvents bus (usageHistory no longer dynamic-imports providerLimits) so it does not pull the executors/translator graph into the typecheck-core surface — typecheck:core stays at 0. Integrated into release/v3.8.21. Thanks @dhaern!
…zapw#3604 (provider quotas) + diegosouzapw#3605 (reasoning wrappers)

Co-authored-by: diegosouzapw <diegosouza.pw@gmail.com>
… plugins

Refactors the massive 4676-line providerRegistry.ts into a strictly modular folder-as-module pattern in open-sse/config/providers/registry/.
This fully adopts the WordPress-style plugin system paradigm: every provider (and its variants) has its own dedicated directory and index.ts. Highly-related provider variants (e.g. minimax, minimax-cn) are grouped seamlessly as nested plugins (e.g. registry/minimax/index.ts, registry/minimax/cn/index.ts).

The core registry object is auto-assembled and re-exported to maintain backward compatibility.
@oyi77
oyi77 force-pushed the refactor/modularize-providerRegistry branch from 5b9177b to e9af965 Compare June 12, 2026 19:22
@diegosouzapw
diegosouzapw changed the base branch from release/v3.8.23 to release/v3.8.24 June 13, 2026 02:52
@diegosouzapw

Copy link
Copy Markdown
Owner

Thanks @oyi77 for the modularization work on open-sse/config/providerRegistry.ts (Issue #3594). I can't merge this as it currently stands — and the reason is structural, not about the quality of the split:

  1. It's a stacked/cumulative chain. This branch carries ~49–55 commits all starting from chore(release): open v3.8.23 development cycle, and the per-PR additions grow monotonically (refactor: modularize providerRegistry.ts (Issue #3594) #3617 ≈ +22k → refactor: modularize 3.1K-line providers.ts constants (Issue #3594) #3646 ≈ +52k). Each refactor branch is built on top of the previous one, so merging any single PR drags in all the earlier refactors too. That makes each PR impossible to review in isolation and guarantees conflicts between them.

  2. The base is stale (v3.8.23 era). Since these were cut, release/v3.8.24 has merged dozens of PRs — including changes to the very files several of these PRs modularize (e.g. providerRegistry.ts grew via fix(providers): correct Ollama Cloud kimi-k2.7-code capabilities (#3761) #3768, validation.ts via fix(providers): repair qwen-web validation + stop mislabeling benign redirects as SSRF (#3288, #3758) #3767, plus combo/stream/usage edits). GitHub now reports this PR as CONFLICTING, and the conflicts are substantial.

What would let this land: re-cut it as a single, independent PR branched from the current release/v3.8.24 tip, modularizing only open-sse/config/providerRegistry.ts (not stacked on the other refactors), small enough to review on its own. One file per PR, rebased on current release. I'll gladly review and merge them in that form — the god-file modularization goal is worth it; it's the 14-deep stack on a 2-week-old base that can't go in. Leaving this open so nothing is lost.

@oyi77

oyi77 commented Jun 13, 2026

Copy link
Copy Markdown
Contributor Author

Closed in favor of clean re-cut — see #3793 (providerRegistry), #3798 (combo), #3797 (validation), #3796 (imageGeneration), #3795 (usage), #3794 (providers). Only modularization commits were cherry-picked onto current release/v3.8.24 — no stacked dependencies, no unrelated changes.

@oyi77 oyi77 closed this Jun 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.