Skip to content

refactor(provider): slim provider stack from ~11k to ~4k lines#2

Merged
Rexopia merged 9 commits intomainfrom
auth-provider-cleanup
Mar 5, 2026
Merged

refactor(provider): slim provider stack from ~11k to ~4k lines#2
Rexopia merged 9 commits intomainfrom
auth-provider-cleanup

Conversation

@Rexopia
Copy link
Owner

@Rexopia Rexopia commented Mar 1, 2026

Summary

  • Delete 8 provider files (~7,900 lines): anthropic.rs, openai.rs, gemini.rs, ollama.rs, copilot.rs, glm.rs, openrouter.rs, openai_codex.rs
  • Add anthropic_oauth.rs: lean Anthropic Messages API with OAuth/API-key dual auth via AuthService
  • Rename openai_codex.rsopenai_oauth.rs: OpenAI Codex OAuth provider (content unchanged)
  • Simplify compatible.rs (2,210 → ~480 lines): pure base_url + Bearer API key, removed AuthStyle enum, special auth modes, config file support, and 7 constructor variants → single 3-arg new()
  • Update mod.rs: all compatible-layer providers use simplified constructor; GLM (JWT) dropped; OpenRouter now goes through compatible layer

Net change: -5,861 lines (1,075 added / 6,936 deleted)

Test plan

  • cargo build passes
  • cargo fmt --check clean
  • cargo clippy --all-targets -- -D warnings clean (0 warnings)
  • cargo test — 437 tests passed, 0 failed

🤖 Generated with Claude Code

Rexopia and others added 9 commits March 1, 2026 15:01
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ToolResult carries success/output/error fields, enabling tools to report
security denials as business logic rather than program errors. All
callsites (dispatcher, loop_, agent_cmd, agentctl) updated.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…e-limiting

Ported from zeroclaw's SecurityPolicy with layered defense:
- AutonomyLevel (ReadOnly/Supervised/Full)
- Path validation (traversal, null bytes, workspace confinement, symlink escape)
- Command allowlist (quote-aware lexer, injection blocking, risk classification)
- Sliding-window rate limiting (ActionTracker)
- 57 tests covering security bypass vectors

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implements: shell, file_read, file_write, file_edit, glob_search, content_search.
All tools inject Arc<SecurityPolicy> for path ACL, command filtering, and rate-limiting.
RuntimeAdapter trait abstracts shell execution for testability.

Replaces demo echo/datetime tools in agent_cmd.rs with real tools.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Resolve collapsible_if, dead_code, unused imports/labels/mut,
too_many_arguments, and unnecessary_map_or clippy lints. Apply
cargo fmt to all files. 488 tests pass, 0 warnings.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- I-1: Deduplicate is_valid_env_var_name (pub(crate) in policy.rs, import in shell.rs)
- I-2: Remove record_action() from FileReadTool (reads don't consume rate-limit budget)
- I-3: ContentSearchTool builds tokio::process::Command directly (no std→tokio conversion)
- S-1: Document env sandboxing intent in ShellTool
- S-2: Standardize OnceLock → LazyLock for compiled regexes
- S-3: GlobSearchTool uses spawn_blocking to avoid blocking async runtime
- S-4: Remove undocumented max_results arg extraction from ContentSearchTool
- S-5: Add ToolResult::ok()/denied() convenience constructors, apply in FileReadTool

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Tools: shell, file_read, file_write, file_edit, glob_search, content_search
SecurityPolicy: 3-layer path ACL, command allowlist, rate-limiting, autonomy levels

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Delete 8 independent provider files (anthropic, openai, gemini, ollama,
copilot, glm, openrouter, openai_codex) and replace with:
- anthropic_oauth.rs: lean Anthropic Messages API with OAuth/API-key dual auth
- openai_oauth.rs: renamed from openai_codex.rs (OpenAI Codex OAuth provider)
- compatible.rs: simplified from 2,210 to ~480 lines — pure base_url + Bearer
  API key, no AuthStyle enum, no special auth modes, no config files

All existing compatible-layer providers (openai, moonshot, qwen, minimax,
deepseek, groq, mistral, xai, openrouter) now use the 3-arg constructor.
GLM (JWT auth) dropped for now. 437 tests pass, clippy/fmt clean.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Rexopia Rexopia merged commit 5d829bc into main Mar 5, 2026
2 checks passed
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.

1 participant