Commit Graph
62 Commits
Author SHA1 Message Date
Tam Nhu Tran 05e1c35203 refactor: merge facade adoption from #1169 into executor extraction 2026-05-03 11:54:04 -04:00
Tam Nhu Tran 4f6e61739c refactor(config): adopt config-loader-facade across the codebase
Issue #1161. Sweeps 127 files to import from
src/config/config-loader-facade.ts instead of unified-config-loader or
utils/config-manager directly.

WRITE callers (32 files): replaced raw saveUnifiedConfig /
mutateUnifiedConfig / updateUnifiedConfig calls with the facade's
cache-coherent wrappers saveConfig / mutateConfig / updateConfig. This
fixes a latent stale-cache window where direct writes through the
underlying loader bypassed the facade's memoization.

READ callers (95 files): mechanical import-path migration only —
function names unchanged because the facade re-exports them. No
behavior change.

Also updated:
- tests/unit/utils/browser/browser-setup.test.ts (DI interface rename)
- src/management/checks/image-analysis-check.ts (dynamic import rename)
- src/web-server/health-service.ts (dynamic require rename)
- src/ccs.ts (path prefix fix from sweep script)

After sweep: zero raw write callers remain outside src/config/. Direct
imports of config-manager remain only for symbols not in the facade
(getConfigPath, getCcsDirSource, etc). Behavior unchanged; full suite
passes 1824/1824.

Out of scope: switching loadOrCreateUnifiedConfig() callers to
getCachedConfig() — needs per-callsite cache-safety analysis. Tracked
as follow-up.

Refs #1161
2026-05-03 01:42:53 -04:00
Tam Nhu Tran 09268e7e33 refactor(cliproxy/executor): extract model-warnings + claude-launcher and polish orchestrator
Phases 08+09+10 of #1162. Final extractions and orchestrator cleanup:

- src/cliproxy/executor/model-warnings.ts (80 LOC):
  warnBrokenModels — handles composite + simple paths, broken-model
  notification with replacement suggestions.
- src/cliproxy/executor/claude-launcher.ts (161 LOC):
  launchClaude — final args assembly (web search, image analysis, browser
  tool args), trace context env, Windows shell escaping, spawn,
  quota monitor wiring, cleanup handlers.
- New tests: 227 + 217 LOC.
- index.ts cleanup: numbered section comments through orchestrator,
  removed ~17 now-unused imports, re-export block preserved.

index.ts: 665 -> 550 LOC. Final reduction across all 10 phases:
1428 -> 550 (-878, -61%). Behavior unchanged; full suite passes
1824/1824. The remaining 550 LOC is the natural orchestrator floor —
further extraction would require a 15-field context struct, which is
manufactured complexity rather than genuine separation of concerns.

Closes phases 02-10 of #1162.

Refs #1162
2026-05-02 22:39:13 -04:00
Tam Nhu Tran 8b39d8a25f refactor(cliproxy/executor): extract proxy-chain-builder from index.ts
Phase 07 of #1162. Splits tool-sanitization + codex-reasoning proxy spawn
out of the orchestrator:

- src/cliproxy/executor/proxy-chain-builder.ts (185 LOC):
  buildProxyChain + ProxyChainContext / ProxyChainResult types.
  DI escape hatch (_ToolSanitizationProxy / _CodexReasoningProxy) for
  testability without refactoring the proxy classes (Bun module cache
  blocks mock.module of already-loaded modules).
- 9 unit tests covering codex-only, tool-san only, both-together,
  spawn failure swallowing, env propagation.

index.ts: 716 -> 665 LOC (-51). HTTPS tunnel kept inline because
tunnelPort is needed by image-analysis resolution before first-pass
buildClaudeEnvironment — folding it in would also require moving image
analysis. Two-pass buildClaudeEnvironment dance preserved exactly.
Behavior unchanged; full suite passes 1824/1824.

Refs #1162
2026-05-02 22:32:37 -04:00
Tam Nhu Tran 8b7e7f4847 refactor(cliproxy/executor): extract auth-coordinator from index.ts
Phase 06 of #1162. Splits the largest remaining concern out of the
orchestrator into a focused module:

- src/cliproxy/executor/auth-coordinator.ts (397 LOC):
  handleLogout, handleImport, resolveSkipLocalAuth, runAntigravityGate,
  ensureProviderAuthentication, runPreflightQuotaCheck,
  runAccountSafetyGuards, ensureModelConfiguration,
  ensureProviderSettingsFile. Preserves load-bearing ordering of
  antigravity gate -> auth -> token refresh -> quota check.
- 36 unit tests covering --auth/--logout/--import early exit,
  antigravity gate refusal/acceptance, OAuth trigger paths, composite
  providers, remote-proxy skipLocalAuth.

index.ts: 895 -> 716 LOC (-179). Behavior unchanged; full suite passes
1824/1824. Module is 397 LOC (over the <200 ideal) — kept whole because
the auth ordering contract should not be split across files.

Refs #1162
2026-05-02 22:03:46 -04:00
Tam Nhu Tran bc48613bbd refactor(cliproxy/executor): extract browser-setup and account-resolution
Phases 04+05 of #1162. Splits two more concerns out of the orchestrator:

- src/cliproxy/executor/browser-launch-setup.ts (118 LOC):
  resolveBrowserLaunchFlags + resolveBrowserRuntime. Encapsulates browser
  flag resolution, attach config, blocked-override warning, and runtime
  setup including MCP sync.
- src/cliproxy/executor/account-resolution.ts (197 LOC):
  resolveRuntimeQuotaMonitorProviders, resolveAccounts (--accounts /
  --use / --nickname / OAuth ban-risk warn / default touch),
  applyAccountSafetyGuards, touchDefaultAccount.
- New tests: 184 + 430 LOC covering both modules.

index.ts: 1045 -> 895 LOC (-150). resolveRuntimeQuotaMonitorProviders
re-exported from index.ts for __testExports backwards compat. Behavior
unchanged; full suite passes 1824/1824.

Refs #1162
2026-05-02 21:47:54 -04:00
Tam Nhu Tran 968681f261 refactor(cliproxy/executor): extract proxy-resolver from index.ts
Phase 03 of #1162. Splits proxy + binary resolution out of the orchestrator
into a focused module:

- src/cliproxy/executor/proxy-resolver.ts (196 LOC):
  ResolvedProxy + ResolveExecutorProxyContext interfaces, resolveExecutorProxy
  function. Encapsulates proxy config resolution, port mutation, remote
  reachability check, fallback prompt, local backend selection, and
  binary acquisition.
- src/cliproxy/executor/__tests__/proxy-resolver.test.ts: 10 unit tests
  covering local/remote/fallback paths.

index.ts: 1168 -> 1045 LOC (-123). Removes 9 now-unused imports. Browser
flag handling intentionally left in index.ts for Phase 04. Behavior
unchanged; full suite passes 1824/1824.

Refs #1162
2026-05-02 21:38:38 -04:00
Tam Nhu Tran 19d24954be refactor(cliproxy/executor): extract arg-parser from index.ts
Phases 01+02 of #1162. Splits executor flag parsing/validation out of the
1428-LOC orchestrator into a focused module:

New files:
- src/cliproxy/executor/arg-parser.ts (~500 LOC):
  readOptionValue, hasGitLabTokenLoginFlag, getGitLabTokenLoginFlagName,
  CCS_FLAGS + filterCcsFlags, ParsedExecutorFlags + parseExecutorFlags,
  validateFlagCombinations (process.exit semantics preserved for parity).
- src/cliproxy/executor/__tests__/arg-parser.test.ts: 45 unit tests.
- src/cliproxy/executor/__tests__/index-characterization.test.ts:
  TDD baseline (16 pass + 7 skipped scenarios at the spawn/dynamic-import
  boundary; mock simplification deferred to a follow-up phase).

index.ts: 1428 -> 1175 LOC (-253). Re-exports preserved at module bottom
for backwards compatibility. Behavior unchanged; full test suite passes
(1824/1824).

Refs #1162
2026-05-02 21:17:07 -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 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
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 b3bc17639c fix(ui): surface the max thinking level in settings and help 2026-04-22 21:43:32 -04:00
Tam Nhu Tran dd90ea7e2f hotfix: close cliproxy plus fallback gaps 2026-04-22 08:52:17 -04:00
Tam Nhu Tran 039ed63a39 fix(browser): harden runtime policy edge cases 2026-04-20 21:01:19 -04:00
Tam Nhu Tran 7d02f55f9f feat(browser): add explicit runtime policy controls 2026-04-20 21:01:19 -04:00
Tam Nhu Tran ccdd0b6e8e fix(windows): align escaped wrapper shell handling
Use ComSpec-aware shell selection for escaped wrapper launches.

Apply it to the remaining Windows Claude launch paths.

Rewrite the Codex exec regression test to use scoped spies so the full suite stays isolated.
2026-04-19 14:27:27 -04:00
Tam Nhu Tran b52503300b fix(browser): bootstrap managed attach profile setup 2026-04-18 17:18:14 -04:00
Tam Nhu Tran 41bf5075e0 hotfix(browser): avoid aborting launch on missing managed profile
- skip managed Claude browser attach when the default CCS browser profile
  directory has not been created yet
- keep explicit env override flows failing fast so real misconfiguration still
  surfaces clearly
- add regression coverage for default and settings-profile launches
2026-04-16 22:59:43 -04:00
Tam Nhu Tran 4e30c9b080 feat(cli): add browser automation commands 2026-04-16 18:49:24 -04:00
Tam Nhu Tran 27f1416181 fix(cliproxy): avoid network-bound local startup
- skip CLIProxy auto-update checks on runtime bootstrap paths

- fail fast when local startup needs a missing binary instead of attempting installs

- add regression coverage for dashboard limited mode and startup test isolation
2026-04-15 22:55:11 -04:00
Tam Nhu Tran 87d93b651b fix(cursor): deprecate legacy bridge and harden gitlab auth 2026-04-15 01:23:15 -04:00
Tam Nhu Tran 2d9f8c9695 feat(cliproxy): integrate missing provider support 2026-04-15 00:26:12 -04:00
walkerandClaude Opus 4.6 eb8149e8fa feat(browser): 接入 CCS browser MCP 与最小交互闭环
新增 browser MCP 安装、Chrome 复用与运行时接线,
实现 navigate、click、type、take_screenshot 四个 phase-1 工具并补齐相关单测。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-13 11:19:16 +08:00
Tam Nhu Tran 64ecd8b3dc feat(image-analysis): make MCP-first provisioning self-healing 2026-04-08 13:36:05 -04:00
Tam Nhu Tran c1d4294708 fix(cliproxy): remove dead codex reconcile settings arg 2026-04-07 17:59:56 -04:00
Tam Nhu Tran f40d435a92 fix(kiro): harden idc and callback auth paths
- keep headless paste routing aligned with the selected Kiro auth method

- validate local callback replay targets and add prompt cancellation safeguards

- wire IDC params through the dashboard start route and support equals-form CLI flags
2026-04-05 02:04:11 -04:00
Tam Nhu Tran 0fbea0f335 fix(kiro): align auth flows with CLIProxyAPIPlus
- auto-select Builder ID for the default Kiro AWS auth flow

- support IDC auth flags and callback-based Kiro paste replay

- update regression coverage for Kiro auth routing
2026-04-05 02:04:11 -04:00
Tam Nhu Tran 77b488f8b1 fix(image-analysis): harden runtime and provisioning 2026-04-02 18:36:19 -04:00
Tam Nhu Tran 813b2dd4d0 feat(image-analysis): add provider-backed runtime 2026-04-02 15:44:13 -04:00
Tam Nhu Tran 3b61673ad2 fix(cliproxy): preserve image-analysis runtime readiness 2026-04-01 15:32:37 -04:00
Tam Nhu Tran cae5b710b8 fix(websearch): close review gaps in managed runtime 2026-03-30 23:02:20 -04:00
Tam Nhu Tran de7171d810 feat(websearch): finish managed third-party rollout
- steer third-party launches toward the managed WebSearch MCP tool

- add opt-in trace diagnostics across launch, MCP, provider, and headless paths

- extend docs and regression coverage for the first-class runtime

Refs #862
2026-03-30 22:41:51 -04:00
Tam Nhu Tran e260df7178 feat: add first-class CCS WebSearch runtime 2026-03-30 16:10:39 -04:00
Tam Nhu Tran c73f33872a feat(cliproxy): support duplicate-email codex accounts
- keep Codex team and personal auth files as separate identities

- resolve quota and live monitor stats by token file-backed account id

- surface duplicate-aware account labels across the dashboard and variant UI
2026-03-30 15:30:11 -04:00
Tam Nhu Tran 2251312411 fix(cliproxy): centralize gemini compatibility and fallback hints 2026-03-27 17:38:31 -04:00
Tam Nhu Tran 5ac91e0cac fix(cliproxy): align gemini 3.1 preset compatibility 2026-03-27 16:39:40 -04:00
Tam Nhu Tran bdb7ac2937 feat(cliproxy): allow optional provider nicknames
- stop requiring manual unique nicknames for no-email providers by default

- preserve explicit nickname validation and same-account reauth semantics

- persist optional nicknames through dashboard manual callback flows
2026-03-23 11:02:08 -04:00
Tam Nhu Tran 551591ef18 fix(cliproxy): make codex defaults free-plan safe 2026-03-16 13:43:23 -04:00
Tam Nhu Tran 0b9f9826e2 feat(continuity): support cross-profile continuity inheritance from account profiles 2026-03-03 02:49:17 +07:00
Tam Nhu Tran b602ab99ab fix(auth): harden agy safety endpoints and config writes
- add safer error responses for settings/auth routes to avoid leaking internals

- guard sensitive AGY settings endpoints to localhost when dashboard auth is off

- validate start-route bodies and reject OAuth start in remote mode for consistency

- preserve cliproxy.kiro_no_incognito and token_refresh during config merges

- enforce AGY acknowledgement in remote auth-token run/auth command paths
2026-02-24 18:09:36 +07:00
Tam Nhu Tran 3b1271b5e4 fix(agy): enforce multi-step responsibility acknowledgement for antigravity oauth 2026-02-24 17:23:02 +07:00
Tam Nhu Tran 2385d9028a feat(cliproxy): add Claude quota windows and account failover 2026-02-22 01:19:02 +07:00
Tam Nhu Tran 954baecfe4 fix(thinking): handle clear no-op and tighten override coverage 2026-02-19 16:26:56 +07:00
Tam Nhu Tran 92e2ec111d fix(thinking): harden codex reasoning controls across cli and dashboard 2026-02-19 14:13:41 +07:00
Tam Nhu Tran c48ed2ea7f feat(thinking): complete thinking UX/DX for all providers
- Fix codex off-mode bug: add disableEffort to CodexReasoningProxy
  so mode=off actually skips reasoning injection
- Add CCS_THINKING env var (priority: flag > env > config)
- Add startup feedback: [i] Thinking: <level> (<source>)
- Add ccs config thinking CLI subcommand with --mode, --override,
  --tier, --provider-override, --clear-override
- Dashboard: add manual override selector when mode=manual
- Dashboard: add provider overrides collapsible section
- Dashboard: update info box with CCS_THINKING env var docs
- Update help-command.ts with CCS_THINKING and config thinking

Closes #583
2026-02-19 12:45:23 +07:00
Tam Nhu Tran 476eabe08f fix(cliproxy): warn gemini and agy users about issue 509 2026-02-19 10:12:57 +07:00
Tam Nhu Tran e425f477a4 fix(cli): add kiro auth-method flag wiring and help
- parse and validate --kiro-auth-method for Kiro and Kiro composite tiers

- pass selected method through auth/import flows

- document supported Kiro auth-method values in ccs --help

Refs #552

Refs #233
2026-02-14 13:33:37 +07:00
Tam Nhu Tran f9df3cfa7a fix(cliproxy): unify codex reasoning flags and thinking flow 2026-02-14 07:44:59 +07:00