Skip to content

(feat) Add Ramclouds provider and integrate Amp CLI support#257

Open
fdkgenie wants to merge 51 commits intodecolua:masterfrom
fdkgenie:master
Open

(feat) Add Ramclouds provider and integrate Amp CLI support#257
fdkgenie wants to merge 51 commits intodecolua:masterfrom
fdkgenie:master

Conversation

@fdkgenie
Copy link

@fdkgenie fdkgenie commented Mar 6, 2026

  • Adds Ramclouds as a new API Key provider with base URL https://ramclouds.me/v1.

  • Add auto-fetch models for Ramclouds provider

  • Fixed syntax errors in autoFetchModels.js (removed duplicate lines)

  • Added Ramclouds to validation endpoint

  • Added automatic model fetching when creating provider connections

  • Updated /v1/models API to prioritize dynamically fetched models over static ones

  • Updated test-models endpoint to use fetched models from connection data

  • Updated provider detail page to reactively compute models using useMemo

  • Implemented /api/providers/[id]/models endpoint to fetch models from provider APIs

  • Updated ModelSelectModal to use dynamic models from providerSpecificData

  • Updated CLI Tools and MITM pages to prioritize dynamic models over static config
    This ensures that when adding Ramclouds with a valid API key, the system
    automatically fetches and displays all 12 available models instead of
    falling back to the static "auto" model.

  • Add Amp CLI support to CLI Tools configuration

  • Added Amp CLI configuration to cliTools.js with settings and secrets file paths

  • Created API endpoint /api/cli-tools/amp-settings for managing Amp configuration

  • Created AmpToolCard component for Amp CLI configuration UI

  • Integrated Amp CLI into CLI Tools page with status checking and auto-apply

  • Added Amp logo (amp.svg) to public/providers

Configuration supports:

  • Base URL configuration (~/.config/amp/settings.json)
  • API key management (~/.local/share/amp/secrets.json)
  • Environment variable alternatives (AMP_URL, AMP_API_KEY)
  • Manual configuration export for copy-paste setup

Claude AI and others added 11 commits March 6, 2026 14:44
Co-authored-by: fdkgenie <75261157+fdkgenie@users.noreply.github.com>
- Fixed syntax errors in autoFetchModels.js (removed duplicate lines)
- Added Ramclouds to validation endpoint
- Added automatic model fetching when creating provider connections
- Updated /v1/models API to prioritize dynamically fetched models over static ones
- Updated test-models endpoint to use fetched models from connection data
- Updated provider detail page to reactively compute models using useMemo

This ensures that when adding Ramclouds with a valid API key, the system
automatically fetches and displays all 12 available models instead of
falling back to the static "auto" model.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Added Amp CLI configuration to cliTools.js with settings and secrets file paths
- Created API endpoint /api/cli-tools/amp-settings for managing Amp configuration
- Created AmpToolCard component for Amp CLI configuration UI
- Integrated Amp CLI into CLI Tools page with status checking and auto-apply
- Added Amp logo (amp.svg) to public/providers

Configuration supports:
- Base URL configuration (~/.config/amp/settings.json)
- API key management (~/.local/share/amp/secrets.json)
- Environment variable alternatives (AMP_URL, AMP_API_KEY)
- Manual configuration export for copy-paste setup

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Added comprehensive Amp CLI integration with:

**Settings & Configuration:**
- Added ampUpstreamUrl, ampUpstreamApiKey, ampRestrictManagementToLocalhost to settings
- Added 6 default Amp modes with model mappings (Smart, Rush, Oracle, Librarian, Search, Review)
- Created settings UI in profile page for Amp upstream configuration

**Server-Side Proxy Endpoints:**
- /api/provider/[provider]/[...path] - Routes provider API requests
  - Checks if model is mapped locally → uses local 9router providers
  - If not mapped → forwards to ampcode.com as reverse proxy
- /api/auth/[...path] - Proxies management API auth requests
- /api/threads/[...path] - Proxies threads management API
- /api/user/[...path] - Proxies user management API
- All management APIs authenticate with 9router API keys and forward to upstream

**Client-Side UI:**
- Updated AmpToolCard with model mapping UI for 6 Amp modes
- Added model selector for each Amp mode
- Integrated with CLIToolsPageClient for model mappings state
- Updated amp-settings API to save model mappings

**Features:**
- Auto-decompression of gzipped responses from upstream
- Localhost restriction option for management APIs
- Model mapping storage in 9router settings
- Seamless routing between local and upstream models

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This aligns internal, user, auth, threads, and provider endpoint behavior with Amp expectations so login, startup checks, and execute flows work reliably with local 9router routing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Enhance Ramclouds provider and integrate Amp CLI support
- Implement /api/providers/[id]/models endpoint to fetch models from provider APIs
- Update ModelSelectModal to use dynamic models from providerSpecificData
- Update CLI Tools and MITM pages to prioritize dynamic models over static config
- Add Ramclouds provider logo
- Fallback to static models when dynamic fetch is unavailable
Add dynamic model fetching support for providers
@fdkgenie
Copy link
Author

fdkgenie commented Mar 6, 2026

@copilot @claude[agent] Review this pull request for potential conflicts

fdkgenie and others added 18 commits March 6, 2026 23:39
Resolves issue where proxy returned malformed payloads mixing JSON and SSE terminators (e.g., JSON body followed by `data: [DONE]`), causing SDK/client parsers to fail.

Changes:
- Correct stream intent: require explicit `stream: true` instead of defaulting to streaming when omitted
- Add upstream content-type validation: route non-SSE responses to JSON handler even when streaming is requested
- Gate [DONE] sentinel: only append SSE terminator when valid SSE data events were observed

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fixes issue where gemini-web-to-api returns non-streaming JSON but Claude Code CLI expects SSE format, causing "request ended without sending any chunks" error.

Changes:
- Add jsonToSseHandler to convert JSON responses to SSE streams
- Update chatCore to route JSON responses through converter when client requests streaming
- Preserve SSE headers in Amp CLI proxy route handler

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implemented medium-priority features:
- Multi-turn chat session with context preservation
- Parameter controls (temperature, top_p, max_tokens)
- System prompt support
- Persist default model and preferences to localStorage
- Enhanced streaming with character count display

This builds on the high-priority features already committed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…n, and batch eval

Implemented step 3 advanced features:
- Debug panel showing request/response headers and details
- Cost estimation with pricing data integration
- Batch evaluation mode to run multiple prompts sequentially
- Toggle between single and batch mode
- Summary statistics for batch runs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Changed from single column to 2-column layout for better balance:
- Left column: Input controls (model, prompts, parameters, batch mode)
- Right column: Output and results (output, chat session, debug panel, history)
- Responsive: stacks to 1 column on smaller screens (xl breakpoint)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
feat: Add comprehensive Playground UI for model testing
- Change package name to 9router-fdk
- Add bin/cli.js entry point with port 20127
- Add bin/postbuild.js to copy static assets
- Update data directory to ~/.9router-fdk
- Add auto-migration from ~/.9router
- Configure standalone build for npm publishing
- Restrict published files to bin and .next/standalone

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implement usage/quota tracking for Ramclouds provider using New-API's log/token endpoint.

Changes:
- Add getRamcloudsUsage() function in open-sse/services/usage.js
- Fetch quota data from /api/log/token endpoint
- Parse subscription info from latest log entry
- Convert token usage to USD format (500k tokens = $1)
- Add ramclouds to USAGE_SUPPORTED_PROVIDERS list

API Details:
- Endpoint: GET https://ramclouds.me/api/log/token
- Auth: Bearer token (API key)
- Response includes subscription_total, subscription_used, subscription_remain
- Supports plan detection (e.g., "Vip 50")

Tested with live API and confirmed working.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Update quota tracker UI to display both OAuth and API key providers that support usage tracking.

Changes:
- Remove authType === "oauth" filter in ProviderLimits component
- Support all providers in USAGE_SUPPORTED_PROVIDERS list
- Add Ramclouds parser in utils.js with USD conversion support
- Display USD values in QuotaTable component when available
- Update empty state message to be more generic

This enables Ramclouds (API key provider) to appear in the quota tracker dashboard alongside OAuth providers like Antigravity, Kiro, GitHub, and Codex.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove authType check that blocked API key connections from accessing usage endpoint. Now both OAuth and API key providers can fetch usage data.

Changes:
- Remove "Only OAuth connections have usage APIs" check
- Only refresh credentials for OAuth connections
- API key providers (like Ramclouds) can now access /api/usage/[connectionId]

This fixes the "Usage not available for API key connections" error for Ramclouds quota tracker.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Update getUsageForProvider to accept both accessToken and apiKey
- Fix Ramclouds usage to show proper empty state with plan info
- Improve message when no usage data is available yet

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
feat: Add Ramclouds quota tracker support
Published to npm with beta tag for Ramclouds quota tracker release.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Claude AI and others added 22 commits March 8, 2026 07:00
- Add Electron-based system tray implementation
- Display model in use (provider/model)
- Show context info (input/output/cached/total tokens, time)
- Display quota tracker for all providers (24h stats)
- Add MITM server toggle control
- Include autostart option (placeholder for future implementation)
- Add periodic refresh (5s) for real-time data
- Create comprehensive documentation

Co-authored-by: fdkgenie <75261157+fdkgenie@users.noreply.github.com>
- Add cli.js: Electron main process with server management
- Add trayManager.js: System tray manager with dynamic menus
- Add postbuild.js: Post-build preparation script
- Add bin/README.md: Comprehensive tray feature documentation
- Update .gitignore: Allow bin/ directory to be tracked

Co-authored-by: fdkgenie <75261157+fdkgenie@users.noreply.github.com>
Co-authored-by: fdkgenie <75261157+fdkgenie@users.noreply.github.com>
Co-authored-by: fdkgenie <75261157+fdkgenie@users.noreply.github.com>
- Add fallback icon if canvas fails to load
- Add try-catch for open dashboard functionality
- Improve error handling throughout tray manager

Co-authored-by: fdkgenie <75261157+fdkgenie@users.noreply.github.com>
Complete documentation of all implemented features, technical details, and testing status

Co-authored-by: fdkgenie <75261157+fdkgenie@users.noreply.github.com>
- Add USD formatting to systray quota display (e.g., "79% (used $41.29 / $200.00)")
- Calculate and display daily reset time at 0h ICT (UTC+7) for Ramclouds
- Parse usedUSD and totalUSD from quota data in tray
- Add resetAt field to Ramclouds usage API response
- Show countdown timer in web UI quota tracker

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

Consolidate the CLI tray flow on systray modules and remove obsolete Electron tray implementation files to keep the release footprint focused and maintainable.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Ensure published installs can resolve systray modules by shipping src/cli and correcting the bin entry format for npm.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
feat: Add USD quota display and reset time tracking for Ramclouds
…uppression (#11)

* sync: restore upstream MITM implementation from decolua/master

Synced MITM code with upstream repository to use the official implementation:

- Restored executeElevatedPowerShell function in dns/dnsConfig.js
- Updated manager.js to use executeElevatedPowerShell instead of VBScript
- Improved UAC elevation handling with proper error handling
- Restored upstream DNS entry management logic

This brings the MITM implementation in line with the production npm package
(9router@0.3.36) while keeping local postbuild.js for standalone build support.

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

* refactor: remove standalone build to match npm package structure

Removed standalone build configuration to align with upstream npm package
(9router@0.3.36) which uses standard Next.js build without standalone mode.

Changes:
- Removed output: "standalone" from next.config.mjs
- Deleted bin/postbuild.js (no longer needed)
- Updated build script to remove postbuild step

Benefits:
- MITM server can directly access src/mitm/ files
- No need for manual dependency copying
- Simpler build process matching upstream
- Smaller maintenance burden

This approach matches how the official npm package works, where MITM
server.js spawns from src/mitm/server.js with all dependencies in place.

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

* fix: update CLI to use next start instead of standalone build

Changed bin/cli.js to spawn Next.js server using `next start` command
instead of running standalone server.js from .next/standalone/.

Changes:
- Check for .next/ directory instead of .next/standalone/
- Spawn `next start -p <port> -H <host>` instead of node server.js
- Set cwd to project root instead of standalone directory

This matches the standard Next.js build approach used by npm package
and eliminates the need for standalone build mode.

Tested: Server starts successfully and responds to API requests.

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

* fix(mitm): improve server stability, path config, and stream detection

- paths.js: rename data dir from .9router to .9router-fdk
- manager.js: ensure MITM_DIR exists before use, fix ownership when dir is root-owned
- server.js: change ROUTER_URL port to 20127, wrap in async init for Root CA generation, add Gemini stream detection for :streamGenerateContent, improve logging
- dns/dnsConfig.js: export execWithPassword for use in manager.js

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat: add support for alicode-intl provider (cherry-pick 7582247)

- Add alicode-intl to constants, providerModels, providers config
- Add alicode/alicode-intl provider icons
- Update provider page, test utils, validate route for alicode-intl
- Resolve package.json conflict: keep 9router-fdk structure, set dev/dev:alt port to 20127

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat(gemini-cli): add proper User-Agent and X-Goog-Api-Client headers

Match native GeminiCLI client fingerprint to avoid upstream rejection.
Also fix base executor to call transformRequest before buildHeaders so
subclasses can store model context for header generation.

Made-with: Cursor

* fix mitm routing and macOS cert trust for antigravity

Amp-Thread-ID: https://ampcode.com/threads/T-019cdf3c-cc5f-7111-a72a-0050647561e7
Co-authored-by: Amp <amp@ampcode.com>

* feat: add always fallback model for mitm + fix claude tool cache_control conflict

Amp-Thread-ID: https://ampcode.com/threads/T-019cdf3c-cc5f-7111-a72a-0050647561e7
Co-authored-by: Amp <amp@ampcode.com>

* fix(mitm): fix Copilot /responses API - route, output array, [DONE] suppression

- MITM: route /responses requests to /v1/responses instead of /v1/chat/completions
- response.completed: include output[] array (messages, tool calls, reasoning)
- stream.js: suppress [DONE] sentinel for openai-responses format SSE

Amp-Thread-ID: https://ampcode.com/threads/T-019cdfb4-90d7-767e-9fe9-ba65232c636c
Co-authored-by: Amp <amp@ampcode.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Peter Steinberger <steipete@gmail.com>
Co-authored-by: Amp <amp@ampcode.com>
* Amp CLI configuration docs

* Addressing PR comments (#10)

* Initial plan

* Implement Amp CLI login flow and fix secrets.json handling

Co-authored-by: fdkgenie <75261157+fdkgenie@users.noreply.github.com>

* Add comprehensive Amp CLI implementation report

Added detailed documentation covering:
- Implementation details and code changes
- Checklist status tracking
- Usage instructions for end users and developers
- Architecture notes and file formats
- Security considerations
- Testing performed
- Known limitations and future enhancements

Co-authored-by: fdkgenie <75261157+fdkgenie@users.noreply.github.com>

---------

Co-authored-by: anthropic-code-agent[bot] <242468646+Claude@users.noreply.github.com>
Co-authored-by: fdkgenie <75261157+fdkgenie@users.noreply.github.com>

---------

Co-authored-by: Claude <242468646+Claude@users.noreply.github.com>
- Add support for standalone Next.js builds in CLI
- Convert all CLI files from .js to .cjs for better compatibility
- Update working directory detection to support both dev and standalone builds
- Fix server startup to use correct working directory
- Update package.json with proper bin configuration

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Pre-load all CLI modules at file top level
- Fixes 'require is not defined in ES module scope' error
- Allows menu system to work properly with package.json type: module
- Update files array to include only source files
- Exclude .next/standalone to reduce package size
- Package will build on user's machine via prepack script
- Revert files array to include .next/standalone
- Keep src/cli for CLI functionality
- Fix .npmignore to not exclude critical standalone files
- Add autoFetchModels call to OAuth exchange endpoint
- Add autoFetchModels call to OAuth poll endpoint (device code flow)
- Models are now automatically fetched when users connect via OAuth
- Ensures ramclouds and other providers have models available immediately
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.

2 participants