Skip to content

Architecture

22024735 edited this page Jul 11, 2026 · 1 revision

系统架构

当前 v0.4.92 架构

flowchart LR
    subgraph Client[Claude 客户端]
        CLI[Claude Code]
        Desktop[Claude Desktop]
    end

    subgraph Control[控制面 / Electron Main]
        GUI[EXE GUI]
        IPC[IPC Controller]
        Lifecycle[Proxy Lifecycle]
        Config[Config Manager]
        Health[Health and Events]
    end

    subgraph Integration[接管层]
        Patcher[Claude Config Patcher]
        Watcher[Desktop Drift Watcher]
        Hooks[Hook Observer]
        Discovery[Port and Upstream Discovery]
    end

    subgraph Data[数据面 / Local HTTP Proxy]
        Router[HTTP Router]
        Guard[Body and Route Guard]
        Orchestrator[Orchestrator]
        Token[Token Budget]
        Agent[Agent Protocol Guard]
        Vision[Vision Router]
        Recovery[Compact Chunk Rescue]
        Rewriter[Response Rewriter]
    end

    subgraph Local[本地持久化]
        Logs[Rotating Logs]
        Records[Request Records]
        PatchState[Patch State]
    end

    subgraph Upstream[上游服务]
        Switch[CC Switch]
        VisionAPI[Vision Models]
        LLM[Claude GLM OpenAI Compatible]
    end

    GUI --> IPC --> Lifecycle
    IPC --> Config
    Lifecycle --> Discovery
    Lifecycle --> Patcher --> Watcher
    Patcher --> PatchState

    CLI --> Router
    Desktop --> Router
    CLI -. observer hooks .-> Hooks --> Health

    Router --> Guard --> Orchestrator
    Orchestrator --> Token
    Orchestrator --> Agent
    Orchestrator --> Vision --> VisionAPI
    Orchestrator --> Recovery
    Orchestrator --> Switch --> LLM
    Orchestrator --> Rewriter
    Rewriter --> CLI
    Rewriter --> Desktop

    Router --> Logs
    Orchestrator --> Records
    Logs --> Health --> GUI
Loading

组件职责

组件 职责
控制面 Electron GUI / IPC 配置编辑、启停、状态和保护事件展示
生命周期 Proxy Runner 加载配置、选端口、发现上游、监听、接管和关闭
接管层 Claude Config Patcher 修改并恢复 Claude Code 与 Desktop 路由
观察层 Hook Observer 统计工具批次、重复调用和疑似截断,不保存工具正文
HTTP 层 Server 路由、请求体限制、Hook 鉴权、响应流转发
策略层 Orchestrator Vision、Token、Agent 协议、压缩、分块和重试决策
上游层 Upstream Client 将结构化请求转发给 CC Switch 或模型接口
持久化 Logger / Session Store 有界日志和请求保护记录

当前架构边界

控制面和数据面目前运行在同一个 Electron main process。它简化了安装和单用户使用,但同步磁盘写入、未处理异常或高并发请求可能影响 GUI 与代理。进程隔离属于 Production-Roadmap,不是 v0.4.92 已实现能力。

Clone this wiki locally