# onecode-server **Repository Path**: henryqi91/onecode-server ## Basic Information - **Project Name**: onecode-server - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-06-27 - **Last Updated**: 2026-06-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # OneCode Server 基于 [Coder](https://coder.com/) 的 AI 开发环境平台,在 Kubernetes 上提供开箱即用的 VS Code Server / Claude Code / Hermes Agent 等开发工作区,集成 LLM 网关、Token 管理与多模型路由。 ## 核心能力 - **工作区即代码**:用 Terraform 模板定义开发环境,Coder 管理 Pod 生命周期 - **多 Agent 模板**:内置 VS Code Server、Hermes Agent、EurekaClaw、CoPaw、OpenNotebook、Dify、n8n 等模板 - **LLM 网关**:统一代理多套 LLM 上游(New API / OpenClaw 等),带审计日志与 UI - **Token 服务**:自动为新工作区签发 API Token,按用户隔离配额 - **OAuth 集成**:基于 Zero2x OAuth 的登录鉴权,关闭密码登录 - **双模型路由**:主对话模型 + 子代理模型(Haiku)分离配置 ## 架构 ```mermaid graph TB User[用户浏览器] --> Coder[Coder Server] Coder --> K8s[Kubernetes API] K8s --> WS1[工作区: vscode-server] K8s --> WS2[工作区: HermesAgent] K8s --> WS3[工作区: EurekaClaw] WS1 --> Gateway[LLM Gateway] WS2 --> Gateway WS3 --> Gateway Gateway --> NewAPI[New API / OpenClaw] Gateway --> TokenSvc[Token Service] TokenSvc --> NewAPI User --> OAuth[Zero2x OAuth] OAuth --> Coder ``` ## 目录结构 ``` . ├── k8s/ # Coder + 网关的 Kubernetes 部署清单 │ ├── coder.yaml # Coder Server Deployment / Service / RBAC │ ├── deploy-zero2x.sh # 一键部署脚本(TLS + 域名 + OAuth) │ ├── llm-gateway.*.yaml # LLM 网关 Deployment │ ├── ext-proxy.yaml # VS Code 插件市场反向代理(open-vsx.org) │ └── diagnose-logs.sh # 排障脚本 │ ├── llm-proxy/ # LLM 网关与 Token 服务(Python) │ ├── proxy.py # 平台级 LLM 网关,带审计日志与 UI │ ├── token_service.py # 自动签发 API Token │ ├── coder_ops_service.py # Coder 运维 API(工作区列表、限制) │ ├── patch_llm_gateway.py # 网关补丁工具 │ ├── fix_proxy_wrapper.py │ └── Dockerfile │ ├── templates/ # Coder 工作区模板(Terraform) │ ├── OneCode-vscode-server/ # 主模板:VS Code Server + Claude Code │ ├── OneCode-vscode-server-temporal/ # Temporal 集成版 │ ├── OneCode-HermesAgent/ # Hermes Agent 工作区 │ ├── OneCode-EurekaClaw/ # EurekaClaw 工作区 │ ├── OneCode-Openclaw/ # OpenClaw 工作区 │ ├── OneCode-CoPaw/ # CoPaw 工作区 │ ├── OneCode-OpenNotebook/ # OpenNotebook 工作区 │ ├── OneCode-dify/ # Dify 工作区 │ ├── OneCode-n8n/ # n8n 工作区 │ └── docker-code-server/ # 基础 Docker 模板 │ └── test-env/ # 测试环境配置(命名空间: onecode) ├── coder-onecode.yaml # 测试环境 Coder 部署 ├── llm-gateway.onecode.yaml └── OneCode-*-test/ # 各模板的测试变体 ``` ## 快速开始 ### 前置依赖 | 组件 | 版本 | 说明 | |---|---|---| | Kubernetes | ≥ 1.24 | 推荐内网集群 | | Coder | ≥ v2.17 | [coder/coder](https://github.com/coder/coder) | | kubectl | 与集群匹配 | 已配置 kubeconfig | | Terraform | ≥ 1.0 | 由 Coder provisioner 内部调用 | | 一个 LLM 上游 | - | New API / One API / OpenClaw 任选 | ### 1. 部署 Coder Server ```bash # 创建命名空间 kubectl create namespace ai-agents-internal # 创建镜像拉取凭据(替换为自己的仓库账号) kubectl -n ai-agents-internal create secret docker-registry acr-registry-secret \ --docker-server= \ --docker-username= \ --docker-password= # 应用 Coder 部署清单 kubectl apply -f k8s/coder.yaml # 或使用一键脚本(自动生成 TLS、配置域名) bash k8s/deploy-zero2x.sh ``` ### 2. 部署 LLM 网关 ```bash kubectl apply -f k8s/llm-gateway.ai-agents-internal.yaml ``` 网关默认监听 8081,环境变量: - `LLM_UPSTREAMS`:JSON 格式的多上游配置 - `NEW_API_URL`:New API / One API 地址 - `NEW_API_ADMIN_TOKEN`:管理员 Token(用于 Token Service 自动签发) ### 3. 推送工作区模板 ```bash # 登录 Coder coder login https:// --token # 推送主模板 coder templates push OneCode-vscode-server \ --directory templates/OneCode-vscode-server \ --yes ``` 用户即可在 Coder UI 中创建工作区。 ## 安全提示 ⚠️ **本项目已从历史中清除所有真实凭据**,但在使用本仓库前请注意: 1. **必须修改的占位符**(搜索 `REDACTED_`、``、`10.200.95.16` 等): - LLM Gateway / New API 地址 - 内网域名 `*.ai-agents-internal.svc.cluster.local`、`onecode.zero2x.org` - ACR 镜像仓库凭据 2. **生产环境务必**: - 使用强密码替换所有 `coderpassword` / `REDACTED_*` - 通过 kubectl create secret 或外部 Secret 管理凭据,不要写回 yaml - 启用 NetworkPolicy 限制工作区之间互通 3. **Token 轮换**:如 fork 自本仓库,请使用自己的 OAuth Client / API Key ## 依赖的开源项目 本项目仅包含部署与模板代码,工作区内的 Agent 能力依赖以下上游开源项目(需用户自行部署或克隆): | 项目 | 用途 | License | |---|---|---| | [coder/coder](https://github.com/coder/coder) | 工作区管理平台 | AGPL-3.0 | | [Calcium-Ion/new-api](https://github.com/Calcium-Ion/new-api) | LLM API 网关与计费 | MIT | | [anthropics/claude-code](https://www.anthropic.com/claude-code) | Claude Code CLI | 商用 | | [hermes-agent](https://github.com/) | 通用 AI Agent | - | | [EurekaClaw](https://github.com/) | AI 工作流 | - | | [CoPaw](https://github.com/) | 协作 Agent | - | | [open-notebook](https://github.com/) | 知识库 | - | 各模板对应的 Agent 源码**不在本仓库**,需单独获取。 ## 开发与调试 ```bash # 查看 Coder Pod 状态 bash k8s/diagnose-logs.sh # 本地调试 LLM 网关 cd llm-proxy && python proxy.py # 自定义模板参数 # 编辑 templates/OneCode-vscode-server/main.tf 中的 coder_parameter 块 ``` ## License 本仓库的部署与模板代码未附加开源协议,默认保留所有权利。如需使用,请联系作者。本仓库中引用的上游开源项目遵循各自的原协议。