mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-16 12:15:57 +00:00
* fix(cliproxy): pass variant port to executor for isolation Variants configured with dedicated ports (8318-8417) were not using their assigned port. The executor always defaulted to 8317. Changes: - Add port field to ProfileDetectionResult interface - Pass variant.port from profile-detector to ccs.ts - Forward port to execClaudeWithCLIProxy options - Update executor priority: CLI flags > variant port > config.yaml > default Closes #228 * fix(cliproxy): propagate port in unified config and UI preset handlers Edge case fixes identified in codebase review: - Unified config variant detection: add settingsPath and port fields - Provider editor: use variant port in handleApplyPreset/handleCustomPresetApply - preset-utils: add optional port parameter to applyDefaultPreset() * chore(release): 7.11.1-dev.1 [skip ci] * fix(cliproxy): use correct default port (8317) for remote HTTP connections Root cause: Inconsistent default port logic across code paths. - Test Connection used 8317 (correct) - Actual API calls used 80 (wrong) Changes: - Add centralized getRemoteDefaultPort() helper in config-generator.ts - Fix proxy-target-resolver.ts to use shared helper - Fix rewriteLocalhostUrls() and getRemoteEnvVars() in config-generator.ts - Update remote-proxy-client.ts to use shared helper (DRY) Fixes all 3 reported issues: 1. Port empty → now correctly uses :8317 instead of :80 2. BASEURL construction → now includes correct port 3. CLIProxy Plus auth → now fetches from remote on correct port * chore(release): 7.11.1-dev.2 [skip ci] * feat(delegation): add Claude Code CLI flag passthrough Add explicit passthrough support for key Claude Code CLI flags: - --max-turns: Limit agentic turns (prevents infinite loops) - --fallback-model: Auto-fallback when model overloaded - --agents: Dynamic subagent JSON injection - --betas: Enable experimental features Maintain extraArgs catch-all for future Claude Code flags. Update help command with new "Delegation Flags" section. Closes #89 * test(delegation): add comprehensive CLI flag passthrough tests Add 45 test cases covering all edge cases for CLI flag passthrough: - DelegationHandler: timeout/max-turns/fallback-model/agents/betas validation - HeadlessExecutor: duplicate flag filtering, undefined vs truthy checks * chore(release): 7.11.1-dev.3 [skip ci] * fix(ui): enable cancel button during OAuth authentication Resolves #234 - Cancel button was disabled during authentication flow, preventing users from canceling the OAuth process. Changes: - Add auth-session-manager.ts for tracking active OAuth sessions - Add POST /cliproxy/auth/:provider/cancel endpoint to abort sessions - Kill spawned CLIProxy auth process when cancel is triggered - Enable Cancel button in AddAccountDialog during authentication - Add cancel support to QuickSetupWizard auth step - Update useCancelAuth hook to call backend cancel endpoint * chore(release): 7.11.1-dev.4 [skip ci] * fix(prompt): add stdin.pause() to prevent process hang after password input Fixes #236. The password() method called resume() on stdin but never paused it in cleanup, keeping the event loop alive indefinitely. * chore(release): 7.11.1-dev.5 [skip ci] * feat(cliproxy): add --allow-self-signed flag for HTTPS connections (#227) Previously, allowSelfSigned was hardcoded to true for all HTTPS protocol connections, forcing use of the native https module which has issues with Cloudflare-proxied connections causing timeouts. This change: - Adds --allow-self-signed CLI flag (default: false) - Adds CCS_ALLOW_SELF_SIGNED environment variable - Uses standard fetch API by default for HTTPS (works with valid certs) - Only uses native https module when --allow-self-signed is specified Usage: - For production HTTPS proxies with valid certs: no flag needed - For dev proxies with self-signed certs: use --allow-self-signed 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> * chore(release): 7.11.1-dev.6 [skip ci] --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Shun Kakinoki <39187513+shunkakinoki@users.noreply.github.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
221 lines
5.6 KiB
TypeScript
221 lines
5.6 KiB
TypeScript
/**
|
|
* CLIProxy Type Definitions
|
|
* Types for CLIProxyAPI binary management and execution
|
|
*/
|
|
|
|
/**
|
|
* Supported operating systems
|
|
*/
|
|
export type SupportedOS = 'darwin' | 'linux' | 'windows';
|
|
|
|
/**
|
|
* Supported CPU architectures
|
|
*/
|
|
export type SupportedArch = 'amd64' | 'arm64';
|
|
|
|
/**
|
|
* Archive extension based on platform
|
|
*/
|
|
export type ArchiveExtension = 'tar.gz' | 'zip';
|
|
|
|
/**
|
|
* Platform detection result
|
|
*/
|
|
export interface PlatformInfo {
|
|
/** Operating system (darwin, linux, windows) */
|
|
os: SupportedOS;
|
|
/** CPU architecture (amd64, arm64) */
|
|
arch: SupportedArch;
|
|
/** Full binary archive name (e.g., CLIProxyAPI_6.5.27_linux_amd64.tar.gz) */
|
|
binaryName: string;
|
|
/** Archive extension (tar.gz for Unix, zip for Windows) */
|
|
extension: ArchiveExtension;
|
|
}
|
|
|
|
/**
|
|
* Binary manager configuration
|
|
*/
|
|
export interface BinaryManagerConfig {
|
|
/** CLIProxyAPI version to download */
|
|
version: string;
|
|
/** GitHub releases base URL */
|
|
releaseUrl: string;
|
|
/** Local binary storage path (~/.ccs/bin/) */
|
|
binPath: string;
|
|
/** Maximum download retry attempts */
|
|
maxRetries: number;
|
|
/** Enable verbose logging */
|
|
verbose: boolean;
|
|
/** Force specific version (skip auto-upgrade to latest) */
|
|
forceVersion: boolean;
|
|
}
|
|
|
|
/**
|
|
* Download progress callback
|
|
*/
|
|
export interface DownloadProgress {
|
|
/** Total bytes to download */
|
|
total: number;
|
|
/** Bytes downloaded so far */
|
|
downloaded: number;
|
|
/** Download percentage (0-100) */
|
|
percentage: number;
|
|
}
|
|
|
|
/**
|
|
* Download progress callback function type
|
|
*/
|
|
export type ProgressCallback = (progress: DownloadProgress) => void;
|
|
|
|
/**
|
|
* Binary info after successful download/verification
|
|
*/
|
|
export interface BinaryInfo {
|
|
/** Full path to executable */
|
|
path: string;
|
|
/** CLIProxyAPI version */
|
|
version: string;
|
|
/** Platform info */
|
|
platform: PlatformInfo;
|
|
/** SHA256 checksum (verified) */
|
|
checksum: string;
|
|
}
|
|
|
|
/**
|
|
* Checksum verification result
|
|
*/
|
|
export interface ChecksumResult {
|
|
/** Whether checksum matched */
|
|
valid: boolean;
|
|
/** Expected checksum from checksums.txt */
|
|
expected: string;
|
|
/** Actual computed checksum */
|
|
actual: string;
|
|
}
|
|
|
|
/**
|
|
* Download result
|
|
*/
|
|
export interface DownloadResult {
|
|
/** Whether download succeeded */
|
|
success: boolean;
|
|
/** Path to downloaded file */
|
|
filePath?: string;
|
|
/** Error message if failed */
|
|
error?: string;
|
|
/** Number of retries attempted */
|
|
retries: number;
|
|
}
|
|
|
|
/**
|
|
* Supported CLIProxy providers
|
|
* - gemini: Google Gemini via OAuth
|
|
* - codex: OpenAI Codex via OAuth
|
|
* - agy: Antigravity via OAuth (short name for easy usage)
|
|
* - qwen: Qwen Code via OAuth (qwen3-coder)
|
|
* - iflow: iFlow via OAuth
|
|
* - kiro: Kiro (AWS CodeWhisperer) via OAuth
|
|
* - ghcp: GitHub Copilot via Device Code (OAuth through CLIProxyAPIPlus)
|
|
*/
|
|
export type CLIProxyProvider = 'gemini' | 'codex' | 'agy' | 'qwen' | 'iflow' | 'kiro' | 'ghcp';
|
|
|
|
/**
|
|
* CLIProxy config.yaml structure (minimal)
|
|
*/
|
|
export interface CLIProxyConfig {
|
|
port: number;
|
|
'api-keys': string[];
|
|
'auth-dir': string;
|
|
debug: boolean;
|
|
'gemini-api-key'?: Array<{
|
|
'api-key': string;
|
|
'base-url'?: string;
|
|
}>;
|
|
'codex-api-key'?: Array<{
|
|
'api-key': string;
|
|
'base-url'?: string;
|
|
}>;
|
|
'openai-compatibility'?: Array<{
|
|
name: string;
|
|
'base-url': string;
|
|
'api-key-entries': Array<{
|
|
'api-key': string;
|
|
}>;
|
|
}>;
|
|
}
|
|
|
|
/**
|
|
* Executor configuration
|
|
*/
|
|
export interface ExecutorConfig {
|
|
/** Port for CLIProxyAPI (default: 8317) */
|
|
port: number;
|
|
/** Timeout for proxy readiness in ms (default: 5000) */
|
|
timeout: number;
|
|
/** Enable verbose logging */
|
|
verbose: boolean;
|
|
/** Poll interval for port check in ms (default: 100) */
|
|
pollInterval: number;
|
|
/** Custom settings path for user-defined CLIProxy variants */
|
|
customSettingsPath?: string;
|
|
}
|
|
|
|
/**
|
|
* Model mapping for each provider
|
|
*/
|
|
export interface ProviderModelMapping {
|
|
/** Default model for requests */
|
|
defaultModel: string;
|
|
/** Model for Claude CLI's ANTHROPIC_MODEL */
|
|
claudeModel: string;
|
|
/** Model for Claude CLI's ANTHROPIC_DEFAULT_OPUS_MODEL */
|
|
opusModel?: string;
|
|
/** Model for Claude CLI's ANTHROPIC_DEFAULT_SONNET_MODEL */
|
|
sonnetModel?: string;
|
|
/** Model for Claude CLI's ANTHROPIC_DEFAULT_HAIKU_MODEL */
|
|
haikuModel?: string;
|
|
}
|
|
|
|
/**
|
|
* Provider configuration
|
|
*/
|
|
export interface ProviderConfig {
|
|
/** Provider name */
|
|
name: CLIProxyProvider;
|
|
/** Display name for UI */
|
|
displayName: string;
|
|
/** Model configuration */
|
|
models: ProviderModelMapping;
|
|
/** Whether OAuth is required */
|
|
requiresOAuth: boolean;
|
|
}
|
|
|
|
/**
|
|
* Resolved proxy configuration after merging CLI > ENV > config.yaml > defaults.
|
|
* Used by executor to determine local vs remote proxy mode.
|
|
*/
|
|
export interface ResolvedProxyConfig {
|
|
/** Proxy mode: 'local' spawns CLIProxyAPI locally, 'remote' connects to external server */
|
|
mode: 'local' | 'remote';
|
|
/** Remote proxy hostname/IP (only for remote mode) */
|
|
host?: string;
|
|
/** Proxy port (default: 8317) */
|
|
port: number;
|
|
/** Protocol for remote connection (default: http) */
|
|
protocol: 'http' | 'https';
|
|
/** Auth token for remote proxy authentication */
|
|
authToken?: string;
|
|
/** Enable fallback to local when remote unreachable (default: true) */
|
|
fallbackEnabled: boolean;
|
|
/** Auto-start local proxy if not running (default: true) */
|
|
autoStartLocal: boolean;
|
|
/** --remote-only flag: fail if remote unreachable, no fallback */
|
|
remoteOnly: boolean;
|
|
/** --local-proxy flag: force local mode, ignore remote config */
|
|
forceLocal: boolean;
|
|
/** Remote proxy connection timeout in ms (default: 2000) */
|
|
timeout?: number;
|
|
/** Allow self-signed certificates for HTTPS connections (default: true) */
|
|
allowSelfSigned?: boolean;
|
|
}
|