Skip to content

[WIP] Add FastAPI OpenAI-compatible LLM gateway with routing - #1

Closed
diegosouzapw with Copilot wants to merge 1 commit into
mainfrom
copilot/bootstrap-omniroute-gateway
Closed

diegosouzapw with Copilot wants to merge 1 commit into
mainfrom
copilot/bootstrap-omniroute-gateway

Conversation

Copilot AI commented Feb 13, 2026 •

Copy link
Copy Markdown
Contributor
  • Set up project structure and configuration files (pyproject.toml, .gitignore, etc.)
  • Implement core FastAPI application with /health endpoint
  • Implement provider abstraction layer (OpenAI, Anthropic stub)
  • Implement config-driven routing with weighted load balancing
  • Implement /v1/chat/completions endpoint with retries and fallback
  • Add Dockerfile and docker-compose.yml (with optional Redis)
  • Set up pytest with tests for all endpoints and features
  • Configure ruff and mypy for code quality
  • Set up GitHub Actions CI workflow
  • Write comprehensive README with usage examples
  • Create config.yaml example file
  • Add .github/copilot-instructions.md
  • Add AGENTS.md with build/test commands and conventions
Original prompt

Bootstrap OmniRoute: Python 3.12 + FastAPI OpenAI-compatible LLM gateway. Implement /v1/chat/completions and /health. Add provider abstraction (OpenAI, Anthropic stub), config-driven routing + weighted load balancing + retries/fallback. Include Dockerfile, docker-compose (optional Redis), pytest, ruff, mypy, GitHub Actions CI, and a solid README + config examples. Add .github/copilot-instructions.md and AGENTS.md with build/test commands and conventions.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI requested a review from diegosouzapw February 13, 2026 12:43
Copilot stopped work on behalf of diegosouzapw due to an error February 13, 2026 12:43
@diegosouzapw
diegosouzapw deleted the copilot/bootstrap-omniroute-gateway branch February 18, 2026 03:03
StealthIQ added a commit to StealthIQ/OmniRoute that referenced this pull request Feb 21, 2026
- Generate "Account cheaper-inference#1", "Account cheaper-inference#2" names for providers that use non-email identifiers
- Only use email as display name when it's a valid email (contains @)
- Hide email field in UI when value is not a real email address
diegosouzapw added a commit that referenced this pull request Feb 28, 2026
…ance, robustness

## Critical Fixes
- #1: Server readiness — waitForServer() polls before loading window
- #2: Restart timeout — 5s + SIGKILL prevents IPC handler from hanging
- #3: changePort — now stops/restarts server on new port

## Important Fixes
- #4: Tray cleanup — destroy old Tray before recreating
- #5: IPC emission — server-status & port-changed events
- #6: Disposer pattern — replaces removeAllListeners
- #7: useSyncExternalStore — eliminates 5x re-renders

## Minor: #8-#16 (dead code, CSP, platform titlebar, types, errors, version)

Tests: 76 / 15 suites (was 64/9)
diegosouzapw added a commit that referenced this pull request Mar 7, 2026
…ance, robustness

## Critical Fixes
- #1: Server readiness — waitForServer() polls before loading window
- #2: Restart timeout — 5s + SIGKILL prevents IPC handler from hanging
- #3: changePort — now stops/restarts server on new port

## Important Fixes
- #4: Tray cleanup — destroy old Tray before recreating
- #5: IPC emission — server-status & port-changed events
- #6: Disposer pattern — replaces removeAllListeners
- #7: useSyncExternalStore — eliminates 5x re-renders

## Minor: #8-#16 (dead code, CSP, platform titlebar, types, errors, version)

Tests: 76 / 15 suites (was 64/9)
diegosouzapw added a commit that referenced this pull request Mar 9, 2026
feat(#255): add Ollama Cloud provider (api.ollama.com/v1)
- New registry entry 'ollama-cloud' (alias: ollamacloud)
- OpenAI-compatible, Bearer API key auth
- 7 pre-populated models: Gemma 3 27B, Llama 3.3 70B, Qwen3 72B,
  Devstral 24B, DeepSeek R2 671B, Phi 4 14B, Mistral Small 3.2 24B
- passthroughModels: true for dynamic model names

fix(#258): security hardening — all 9 findings addressed
- [CRITICAL] db-backups/export: add isAuthRequired + isAuthenticated guard
- [CRITICAL] db-backups/import: add isAuthRequired + isAuthenticated guard
- [HIGH] oauth/cursor/auto-import: add isAuthRequired + isAuthenticated guard
- [HIGH] oauth/kiro/auto-import: add isAuthRequired + isAuthenticated guard
- [LOW x4] oauth/[provider]/[action]: replace === with safeEqual()
  using crypto.timingSafeEqual() for CWE-208 (timing-oracle attacks)
  on email and workspaceId comparisons across all 3 handler branches
- [FALSE POSITIVE] Finding #1 (package.json 'reset-password' binary name)
  is not a hardcoded credential — no change needed

Tests: 590/594 pass (4 pre-existing failures in combo-circuit-breaker)
diegosouzapw added a commit that referenced this pull request Mar 10, 2026
TLS / Certificate Validation (#50)
- src/mitm/server.ts: rejectUnauthorized now defaults to true
  (opt-out via MITM_DISABLE_TLS_VERIFY=1 env var only)

Path Injection (#44, #41-#49)
- src/mitm/server.ts: safeLogPath() guards log filenames inside LOG_DIR
- src/lib/db/backup.ts: path.resolve() anchor + sep/slash guard on backupId
- src/shared/services/backupService.ts: safePath() helper anchors toolId
  and backupId within BACKUP_DIR (prevents path traversal)
- src/app/api/cli-tools/codex-profiles/route.ts: safeProfilePath() helper
  anchors profileId within PROFILES_DIR

Prototype Pollution (#18, #19, #20)
- src/lib/usage/usageHistory.ts: byModel/byAccount initialized with
  Object.create(null); assignments guarded with hasOwnProperty checks

Missing Workflow Permissions (#1-#8, #53)
- .github/workflows/ci.yml: added global permissions: contents: read

Dependabot CVE-2026-0540 (#16)
- dompurify updated to ^3.3.2 (fixes XSS vulnerability)
diegosouzapw added a commit that referenced this pull request Mar 14, 2026
Thanks @kfiramar! 🎉 Critical security fix — different startup paths were generating different `STORAGE_ENCRYPTION_KEY` values over the same SQLite database, causing `Unsupported state or unable to authenticate data` for all stored tokens.

Improvements added on top:
- Normalized `overridePath?.trim()` in `electron/main.js` to match `bootstrap-env.mjs` (addresses kilo-code-bot warning #1)
- Added explanatory comment documenting the `preferredEnv` merge order intent in Electron startup (addresses kilo-code-bot warning #3)

4 commits + 113-line test file. The fail-closed behaviour (refusing to mint a new key when encrypted rows exist) is an excellent safeguard. Merged!
diegosouzapw pushed a commit that referenced this pull request Mar 23, 2026
- FIX #1: Add null check for cred.password (prevent undefined access)
- FIX #2: Prioritize actual credentials over hardcoded account patterns
- FIX #3: Convert CommonJS require() to ES imports for consistency
- FIX #4: Move to App Router, add credential metadata response, document maintainer integration

Additional improvements:
- Better TypeScript error typing with optional chaining
- Improved error messages for missing dependencies
- Added maintainer TODO for provider system integration
- Proper Next.js App Router format (route.ts)

All bot warnings resolved. Ready for maintainer review.
prakersh pushed a commit to prakersh/OmniRoute that referenced this pull request Mar 26, 2026
…v-key-loading

Thanks @kfiramar! 🎉 Critical security fix — different startup paths were generating different `STORAGE_ENCRYPTION_KEY` values over the same SQLite database, causing `Unsupported state or unable to authenticate data` for all stored tokens.

Improvements added on top:
- Normalized `overridePath?.trim()` in `electron/main.js` to match `bootstrap-env.mjs` (addresses kilo-code-bot warning cheaper-inference#1)
- Added explanatory comment documenting the `preferredEnv` merge order intent in Electron startup (addresses kilo-code-bot warning cheaper-inference#3)

4 commits + 113-line test file. The fail-closed behaviour (refusing to mint a new key when encrypted rows exist) is an excellent safeguard. Merged!
prakersh pushed a commit to prakersh/OmniRoute that referenced this pull request Mar 26, 2026
- FIX cheaper-inference#1: Add null check for cred.password (prevent undefined access)
- FIX cheaper-inference#2: Prioritize actual credentials over hardcoded account patterns
- FIX cheaper-inference#3: Convert CommonJS require() to ES imports for consistency
- FIX cheaper-inference#4: Move to App Router, add credential metadata response, document maintainer integration

Additional improvements:
- Better TypeScript error typing with optional chaining
- Improved error messages for missing dependencies
- Added maintainer TODO for provider system integration
- Proper Next.js App Router format (route.ts)

All bot warnings resolved. Ready for maintainer review.
diegosouzapw pushed a commit that referenced this pull request Apr 3, 2026
benzntech referenced this pull request in benzntech/OmniRoute Apr 15, 2026
…CLI tools

Two critical bugs prevented the Dashboard CLI Tools feature from working:

Bug #1: keyId stripped by Zod validation
- Zod's safeParse() stripped the keyId field before backend could read it
- The real API key was never resolved from DB and written to settings.json
- Fix: Extract keyId from rawBody BEFORE validation in all 6 CLI settings routes
- Affected: claude, codex, droid, cline, openclaw, kilo settings routes

Bug #2: Key matching logic compared full key vs masked key
- Frontend compared full key (sk-31c4ea6a...) against masked key (sk-31c4****dfa6)
- They never matched, so the dropdown never showed the correct selected key
- Fix: Mask the token from file before comparing against the masked API keys list
- Affected: ClaudeToolCard.tsx

Also fixes model mapping being scrambled when key resolution failed.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
payne0420 referenced this pull request in payne0420/OmniRoute Apr 25, 2026
Round of fixes addressing the gemini-code-assist and chatgpt-codex review
comments on the initial PR.

## High priority

- **PoW solver no longer blocks the event loop** (gemini #1, #2). The 100k
  prekey solver and 500k proof-of-work solver were synchronous SHA3-512
  loops that pinned a CPU core for tens to hundreds of milliseconds per
  request. Both are now async and `await`-yield to the event loop every
  1000 iterations via setImmediate, so concurrent requests and I/O still
  get scheduled. Wall time is approximately the same; what changes is
  fairness, not throughput.

- **Real upstream streaming for stream=true requests** (codex cheaper-inference#6). The
  conv call now passes `stream: true` through to the TLS client when the
  caller asked for streaming. The TLS client uses tls-client-node's
  streamOutputPath primitive to write the response body to a temp file
  as it arrives, and we tail that file as a ReadableStream so clients
  see chunks in real time instead of getting one buffered burst at the
  end. Also peeks the first 256 bytes — if the response starts with
  `{` it's almost certainly a JSON error envelope, so we wait for the
  full body and surface as a non-streaming error response.

## Medium priority

- **Per-cookie device id** (gemini cheaper-inference#3). Replaced the single
  process-wide DEVICE_ID with a per-cookie SHA-256-derived UUID that's
  stable across requests for one connection but unique per cookie. This
  matches how the browser's persistent oai-did cookie behaves and
  avoids cross-account fingerprint sharing. Cache is bounded to 200
  entries with FIFO eviction.

- **Removed dead conv-cache code** (gemini cheaper-inference#4). The convCache /
  convLookup / convStore trio (~70 LOC) was unused — conversationId is
  hard-pinned to null because Temporary Chat conversation_ids 404 on
  reuse. Deleted entirely; the comment explains why we don't persist.

- **No more console.log in the conv 4xx path** (gemini cheaper-inference#5). Replaced
  with log?.warn so it respects the application's logging
  configuration.

- **Bound the warmup cache** (codex cheaper-inference#7). The (cookie, accessToken) ->
  timestamp map was unbounded; long-running multi-user deployments
  with rotating tokens would grow it forever. Now capped at 200
  entries with FIFO eviction (Map iteration order = insertion order).

- **Honor abort signals in TLS fetch** (codex cheaper-inference#8). tlsFetchChatGpt now
  checks options.signal before issuing the upstream call, after the
  call returns, and the streaming body listens for abort to stop
  tailing the temp file. tls-client-node's koffi binding can't cancel
  an in-flight request mid-call, but we no longer process / re-emit a
  response that the caller has already given up on.

## Tests

All 27 chatgpt-web tests still pass; updated several to find calls by
URL via findIndex rather than hardcoded indices, since the warmup
sequence (/me, /conversations, /models) and two-stage Sentinel
(prepare + chat-requirements) shifted positional offsets.

Manually verified end-to-end:
- Non-streaming completions
- Streaming completions (real-time chunks; SSE [DONE] terminator)
- Multi-turn with full history each turn (memory preserved correctly)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@diegosouzapw diegosouzapw mentioned this pull request Sep 29, 2026

@dlynch90 dlynch90 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — all 15 CodeRabbit findings triaged and resolved in 177231d.

@diegosouzapw diegosouzapw mentioned this pull request Oct 19, 2026
@juniorhillory-creator juniorhillory-creator mentioned this pull request Oct 23, 2026
1 of 7 tasks
@diegosouzapw diegosouzapw mentioned this pull request Oct 25, 2026
7 tasks done
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.

3 participants