Commit Graph
278 Commits
Author SHA1 Message Date
walker1211andGitHub 35b6210cd2 fix: support Claude subcommands and background sessions
Squash merge PR #1240.\n\nValidated locally from the PR head because trusted-author GitHub CI was skipped for this fork PR:\n- bun run validate\n- bun run build:all\n- bun run test:all\n- CCS_E2E_SKIP_BUILD=1 bun run test:e2e
2026-05-14 10:18:23 -04:00
Tam Nhu Tran 1c72b4b8d5 refactor(cliproxy): flatten module structure and colocate tests (#1135)
- Split types.ts (331 LOC) into 4 concern-based files under types/:
  platform-types, binary-types, provider-types, config-types
- Preserve backward compat via barrel re-export (types.ts → types/index)
- Reorganize 53 root-level files into 8 subdirectories:
  accounts/, ai-providers/, auth/, binary/, config/, executor/,
  management/, proxy/, quota/, routing/, services/, sync/
- Reduce src/cliproxy/ root from 65 to 8 files (target: ≤10)
- Colocate 87 unit tests from tests/unit/cliproxy/ into
  src/cliproxy/*/__tests__/ (13 colocated test directories)
- Update import paths across 40+ consumer files
- Add TDD backward-compat test for types split

Refs #1135
2026-04-29 17:06:39 -04:00
Tam Nhu Tran 5013d411a7 feat(cliproxy): self-pause exhausted quota accounts 2026-04-28 20:35:15 -04:00
Tam Nhu Tran fe297142da test(cliproxy): isolate routing HTTP module test 2026-04-28 14:34:27 -04:00
Tam Nhu Tran 73c82b3567 Merge remote-tracking branch 'origin/dev' into kai/fix/1118-ai-provider-model-rules 2026-04-28 14:27:53 -04:00
Tam Nhu Tran 9a28ca55d8 fix(cliproxy): tolerate plain AI provider model rules 2026-04-28 14:19:21 -04:00
Tam Nhu Tran aa7f155161 test(cliproxy): stabilize routing endpoint coverage 2026-04-28 14:07:15 -04:00
Tam Nhu Tran 8ef703024b fix(cliproxy): probe routing via management endpoint 2026-04-28 14:02:58 -04:00
Kai (Tam Nhu) TranandGitHub b6432f783e Merge pull request #1114 from yousiki/fix/claude-utilization-percent-unit
fix(cliproxy): use explicit utilization unit per Claude payload form
2026-04-28 13:41:31 -04:00
Kai (Tam Nhu) TranandGitHub a8e0d95bc8 Merge pull request #1117 from kaitranntt/kai/feat/1115-session-affinity
feat: add local CLIProxy session affinity controls
2026-04-28 13:37:37 -04:00
Tam Nhu Tran 5267c421ca fix(cliproxy): harden session affinity behavior 2026-04-28 13:27:05 -04:00
Tam Nhu Tran 4309db89c3 feat(cliproxy): add local session affinity controls 2026-04-28 12:17:26 -04:00
yousiki 942a8ce12d fix(cliproxy): parse Codex additional_rate_limits for Spark quota
The Codex wham/usage API moved GPT-5.3 Codex Spark quota out of
code_review_rate_limit (now null) into a new additional_rate_limits[]
array. Parse the new field and surface it as Spark windows in the quota
view. Adds explicit category/cadence/featureLabel metadata on
CodexQuotaWindow so display logic does not depend on label sniffing.
The legacy label-sniffing path is preserved as a fallback so cached
windows from older versions still render correctly.
2026-04-27 15:07:44 +09:00
yousiki 9808ebfe36 fix(cliproxy): use explicit utilization unit per Claude payload form
Anthropic OAuth usage returns utilization as a percent (0-100) while the
older policy-limits restrictions payload returns a 0-1 ratio. The shared
heuristic "value <= 1 means ratio" misinterpreted percent values like
1.0, rendering 1% Sonnet usage as 100% used. Pass the unit explicitly
from each payload branch so the same boundary value is interpreted
correctly in either format.
2026-04-27 15:06:04 +09:00
Kai (Tam Nhu) TranandGitHub db3becfbe0 Merge pull request #1104 from sgaluza/sgaluza/fix-test-mock-contamination
test(cliproxy): replace process-wide mock.module with DI seams
2026-04-26 10:17:45 -04:00
Sergey Galuza a7871283d4 test(cliproxy): replace process-wide mock.module with DI seams
Bun's `mock.module()` is process-wide and is NOT undone by `mock.restore()`.
Two test files used module-level mocks that leaked across test runs,
silently breaking unrelated suites that imported the mocked modules
transitively:

- tests/unit/cliproxy/version-checker-stale-cache.test.ts mocked
  binary/version-checker, contaminating cliproxy-stats-routes-install
  and cliproxy-stats-routes-model-update suites that import a route
  module which transitively imports version-checker.
- tests/unit/cliproxy/service-manager-startup.test.ts mocked 8 modules
  at top level (binary-manager, stats-fetcher, etc.), contaminating any
  later file that imports them.

CI happens to be green because file ordering on the GitHub runner places
victim files BEFORE contaminators in `bun test`. On Linux locally the
order is reversed, producing 6 reproducible test failures on every
`bun run test:fast` run. A change in OS, bun version, or new test files
that import the mocked modules could silently flip the CI runner's
order and surface these failures unexpectedly.

Replaced module-level mocks with explicit dependency-injection seams in
production code, following the existing pattern in version-checker.ts
and version-cache.ts (`fetchJsonFn?`, `fetchLatestVersionFn?`):

- src/cliproxy/types.ts: `BinaryManagerConfig.checkForUpdatesFn` (optional)
- src/cliproxy/binary/lifecycle.ts: route through new fn with default
- src/cliproxy/service-manager.ts: `ensureCliproxyService(deps?)` with
  optional `ensureBinaryFn`, `detectRunningProxyFn`,
  `configNeedsRegenerationFn`, `withStartupLockFn`

All deps fields are optional with real-implementation defaults, so
production callers are unchanged. Tests now inject deterministic stubs
through call-site parameters instead of module-level mocks.

Verified locally: \`bun run validate\` is now 2540 pass / 0 fail
(previously 2534 pass / 6 fail at the same upstream/main HEAD).

Built [OnSteroids](https://onsteroids.ai)
2026-04-26 09:43:09 +02:00
Kai (Tam Nhu) TranandGitHub 5dd5878bb4 Merge pull request #1086 from BlackJulySnow/main
feat: add extra models support for API profiles
2026-04-25 12:07:01 -04:00
Tam Nhu Tran 7f14c565df test: cover --extra-models parsing and CLIProxy sync dedup 2026-04-25 11:30:44 -04:00
Tam Nhu Tran 4efd61ee34 feat: add gpt-5.5 to codex model catalogs 2026-04-24 10:30:59 -04:00
Tam Nhu Tran 7dd9aba810 chore: merge main hotfixes into dev 2026-04-23 23:49:18 -04:00
Tam Nhu Tran 7a9e67e6dc fix: route codex remote https through local proxy chain 2026-04-23 23:00:59 -04:00
Tam Nhu Tran 3d22bb07f0 fix(cliproxy): route plus backend to maintained fork 2026-04-23 21:25:29 -04:00
Tam Nhu Tran 50fa27f0a5 test(browser): split Browser MCP hook coverage by domain 2026-04-22 23:07:50 -04:00
Kai (Tam Nhu) TranandGitHub 142381078e Merge pull request #1069 from sgaluza/feat/opus-4-7-adaptive-thinking
fix(cliproxy): use adaptive thinking for Opus 4.7 + add 'max' level
2026-04-22 22:03:21 -04:00
Tam Nhu Tran 71deda553a fix(cliproxy): preserve adaptive thinking on opus 4.7 paths 2026-04-22 21:43:11 -04:00
Tam Nhu Tran f6c86b79fc feat(cliproxy): separate core and plus provider sections 2026-04-22 19:51:20 -04:00
Sergey GaluzaandOnSteroids 45fe7ab086 feat(cliproxy): add 'max' thinking level for Claude Opus 4.7
Anthropic exposes `max` as a distinct adaptive-thinking effort above
`xhigh` on Opus 4.7. Previously the validator aliased user input `max`
down to `xhigh`, so users couldn't reach the real top-tier effort
through CCS.

Extend the validator:
- Add `max` to VALID_THINKING_LEVELS and THINKING_LEVEL_RANK (rank 6,
  above xhigh)
- Add `max` to THINKING_LEVEL_BUDGETS (65536, CCS-internal numeric
  mapping for closest-level lookups)
- Widen ThinkingSupport.maxLevel union to include 'max'

The existing `max: 'xhigh'` alias in findClosestLevel is kept as a
graceful fallback for models whose levels list does not include `max`
(e.g. Codex `gpt-5.4`), because exact-match on validLevels takes
priority — so Opus 4.7 returns `max` directly while Codex still maps
`max` -> `xhigh`.

Update the claude.claude-opus-4-7 catalog entry to expose
`['low', 'medium', 'high', 'xhigh', 'max']` with `maxLevel: 'max'`.

Built [OnSteroids](https://onsteroids.ai)

Co-Authored-By: OnSteroids <built@onsteroids.ai>
2026-04-22 21:32:14 +02:00
Sergey GaluzaandOnSteroids 46920dbc08 fix(cliproxy): use adaptive thinking for Claude Opus 4.7
Per Anthropic docs, Claude Opus 4.7 only supports adaptive thinking;
manual `thinking.type: "enabled"` with `budget_tokens` is rejected
with HTTP 400.

Switch the claude provider's `claude-opus-4-7` entry from
`type: 'budget'` to `type: 'levels'` with the effort tiers exposed
by the API: `low | medium | high | xhigh`. The proxy is expected to
translate these into `thinking.type: "adaptive"` with the effort
parameter.

Opus 4.6 and Sonnet 4.6 keep `type: 'budget'` for now since the
deprecated mode is still functional on those models.

Built [OnSteroids](https://onsteroids.ai)

Co-Authored-By: OnSteroids <built@onsteroids.ai>
2026-04-22 21:09:21 +02:00
Tam Nhu Tran e2ca197397 fix: preserve codex effort suffixes in dashboard profiles 2026-04-22 14:24:00 -04:00
Tam Nhu Tran 3e7ce1743b hotfix: preserve plus fallback state and guard variant updates 2026-04-22 08:52:17 -04:00
Tam Nhu Tran dd90ea7e2f hotfix: close cliproxy plus fallback gaps 2026-04-22 08:52:17 -04:00
Tam Nhu Tran b8b48a99ba hotfix(cliproxy): fallback from deleted CLIProxyAPIPlus to original backend
The upstream router-for-me/CLIProxyAPIPlus repo was deleted, breaking any
install/update path that resolved backend: plus. Existing users with
`backend: plus` saved in config.yaml hit 404s on every bootstrap.

Changes:
- Flip DEFAULT_BACKEND from 'plus' to 'original' (platform-detector.ts)
- Flip default cliproxy.backend in createEmptyUnifiedConfig() to 'original'
- Runtime 404 fallback: getConfiguredBackend() degrades 'plus' -> 'original'
  with a one-time warning, so existing installations keep working without a
  manual reconfig step
- Update CLIProxyBackend docblock to document the fallback behavior
- Update tests to match new default

Retains the 'plus' type and BACKEND_CONFIG entry for forward compatibility
once CCS self-maintains its own Plus fork.

Closes #1062
2026-04-22 08:52:17 -04:00
Tam Nhu Tran 5b5f4a5ef5 hotfix: preserve plus fallback state and guard variant updates 2026-04-22 08:45:05 -04:00
Tam Nhu Tran 7b1a7f3a09 hotfix: close cliproxy plus fallback gaps 2026-04-22 08:35:26 -04:00
Tam Nhu Tran 60cbdce83d hotfix(cliproxy): fallback from deleted CLIProxyAPIPlus to original backend
The upstream router-for-me/CLIProxyAPIPlus repo was deleted, breaking any
install/update path that resolved backend: plus. Existing users with
`backend: plus` saved in config.yaml hit 404s on every bootstrap.

Changes:
- Flip DEFAULT_BACKEND from 'plus' to 'original' (platform-detector.ts)
- Flip default cliproxy.backend in createEmptyUnifiedConfig() to 'original'
- Runtime 404 fallback: getConfiguredBackend() degrades 'plus' -> 'original'
  with a one-time warning, so existing installations keep working without a
  manual reconfig step
- Update CLIProxyBackend docblock to document the fallback behavior
- Update tests to match new default

Retains the 'plus' type and BACKEND_CONFIG entry for forward compatibility
once CCS self-maintains its own Plus fork.

Closes #1062
2026-04-22 08:04:12 -04:00
Tam Nhu Tran 478d64a50a fix(cliproxy): quarantine exhausted quota accounts 2026-04-21 12:34:07 -04:00
Tam Nhu Tran 039ed63a39 fix(browser): harden runtime policy edge cases 2026-04-20 21:01:19 -04:00
Tam Nhu Tran 571538dc1c fix(cliproxy): scope Opus 4.7 rollout to verified providers 2026-04-20 13:26:53 -04:00
Sergey Galuza 7492688eff test(cliproxy): cover Claude Opus 4.7 in Claude provider catalog
Adds a unit test verifying that `claude-opus-4-7` is registered in
the `claude` provider with its provider-specific settings:

- `thinking.zeroAllowed: false` (contrasts with AGY where it is true)
- `extendedContext: true` (1M context via Anthropic API)

Addresses PResto atrvd/ccs#8 issue #4 (suggestion).

Built [OnSteroids](https://onsteroids.ai)
2026-04-20 19:00:39 +02:00
Sergey Galuza 61058123e1 feat(cliproxy): add Claude Opus 4.7 support
Adds Claude Opus 4.7 as a new model to the AGY (Antigravity) and Claude
provider catalogs, with pricing, Cursor IDE support, and updated defaults
across the codebase.

- Add claude-opus-4-7-thinking and claude-opus-4-7 to AGY catalog
  (defaultModel bumped to claude-opus-4-7-thinking)
- Add claude-opus-4-7 entry to Claude provider catalog
- Register claude-opus-4-7-thinking fork alias in CLIProxy config
  (CLIPROXY_CONFIG_VERSION bumped 17 -> 18)
- Add pricing for claude-opus-4-7 and claude-opus-4-7-thinking
  ($5/$25 per million, matching Opus 4.6)
- Add claude-4.7-opus and claude-4.7-opus-fast-mode to Cursor catalog
- Update ANTHROPIC_DEFAULT_OPUS_MODEL in base-claude settings to 4.7
- Update Droid adapter and code-reviewer fallback models to 4.7
- Update unit tests for model-catalog and model-pricing

Opus 4.6 is retained as a supported fallback in both catalogs.

Built [OnSteroids](https://onsteroids.ai)
2026-04-20 17:49:18 +02:00
Tam Nhu Tran 485fe4ba1c test(cliproxy): assert routing persistence via unified config loader
The previous assertion read the generated CLIProxy config.yaml directly via
getConfigPathForPort(). On the self-hosted CI runner this produced ENOENT even
though applyCliproxyRoutingStrategy returned 'config-only', indicating the
read path and write path diverged in the full test-suite context.

Verify persistence via loadUnifiedConfig() instead — that's the canonical
source mutateUnifiedConfig writes to, independent of regenerateConfig's
file-path resolution.
2026-04-19 15:27:24 -04:00
Tam Nhu Tran 00d902b6e6 test(cliproxy): cover legacy connector removal cleanup 2026-04-18 20:39:46 -04:00
Tam Nhu Tran 16f81fc8a5 fix(cliproxy): preserve legacy openai-compat connectors on restart 2026-04-18 20:05:05 -04:00
Tam Nhu Tran 5e1e8070e8 test(cliproxy): isolate routing strategy service state 2026-04-18 17:28:34 -04:00
Tam Nhu Tran bc1606da75 test(cliproxy): pin routing strategy test env scope 2026-04-16 23:35:08 -04:00
Tam Nhu Tran d3de83e157 fix(cliproxy): pin routing config regeneration path
- capture the resolved local cliproxy config/auth paths before regenerating
  routing strategy config
- thread explicit override paths into regenerateConfig so scoped config writes
  stay deterministic during the full test suite
- add regression coverage for explicit config path overrides
2026-04-16 23:29:10 -04:00
Tam Nhu Tran 6b53df0147 fix(cliproxy): align delegated gemini auth recovery 2026-04-16 14:15:03 -04:00
Tam Nhu Tran 4845b797de test(cliproxy): stabilize routing strategy config scope 2026-04-16 14:06:27 -04:00
Tam Nhu Tran 637a591dca fix(cliproxy): avoid duplicate gemini management retries 2026-04-16 12:59:15 -04:00
Tam Nhu Tran 9dc6374851 fix(cliproxy): delegate gemini refresh to upstream 2026-04-16 12:49:51 -04:00