gambn

Agent Dual Proxy — Development skill for Claude Code

Development community

Local dual-path proxy for CLI agents: auto-selects a working gateway among proxies and direct, verifies the channel, and fails over without restarting the agent.

How to install Agent Dual Proxy

This entry records only its repository, not the path inside it, so there is no exact command to give. Open gambn/agent-dual-proxy and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

What Agent Dual Proxy does

Local dual-path proxy for CLI agents: auto-selects a working gateway among proxies and direct, verifies the channel, and fails over without restarting the agent.

Alternatives in Development

  • Claude Code Rails Upgrade Skill — 🤖 The one and only Claude Code Skill to Upgrade Rails by FastRuby.io -- Based on 60,000 dev/hours of experien 410 ★
  • Watch Job — Watch a VASP job and diagnose/fix issues if it fails 155 ★
  • Aod.Project Plan — Create implementation plan with dual sign-off (PM + Architect) - Streamlined v2 89 ★

README

agent-dual-proxy

[中文](README.md) · [English](README.en.md)

[![CI](https://github.com/gambn/agent-dual-proxy/actions/workflows/ci.yml/badge.svg)](https://github.com/gambn/agent-dual-proxy/actions/workflows/ci.yml) [![npm](https://img.shields.io/npm/v/agent-dual-proxy.svg)](https://www.npmjs.com/package/agent-dual-proxy)

**Agent 的网关管理器:在多个网关之间在线自动切换,让模型请求不再被一条不稳的路卡死。**

它把「agent 到模型端点的网络路径」当成可管理的资源:在配置的上游、额外指定的代理、启动环境里的代理和直连之间自动选一条能通的;运行中用真实请求持续验证,失败立刻切到下一条——不需要重启 agent,也不需要改客户端配置。

快速开始

# 独立 CLI
npm install -g agent-dual-proxy

# 给 Claude Code 等 CLI agent 套上
agent-gateway run claude --resume

要求 Node.js ≥ 22.0.0。内置短名覆盖 Claude Code、Codex CLI、Gemini CLI、Aider、OpenCode、Qwen Code、Cursor CLI、Droid、Amp、Crush、Goose、GitHub Copilot CLI 和 pi;完整对照见 [docs/agents.md](docs/agents.md)。不在表里的命令用 `agent-gateway run -- [args...]`。

从源码安装(可选):

git clone https://github.com/gambn/agent-dual-proxy.git
cd agent-dual-proxy
npm install

两种用法,同一份核心:

  • AGENT 启动器(推荐):agent-gateway run ,起代理 + 注入代理变量 + exec,agent 退出时代理跟着关;
  • 独立进程:dual-proxy 跑一个常驻代理,或挂 systemd 用户服务。

它解决什么

上游代理并不稳定:同一个代理可能对 A 站通、对 B 站不通,也可能整段时间全挂;本机同时装着两个代理时,哪个能用还会变。只认一条路的客户端在这种时候会成片失败,而在死路上重试只是拖延。

这一层把候选路都握在手里,按 host 选:

客户端 → 127.0.0.1:7898
           ├── 网关 A(TLS 探测通过)→ 上游代理
           ├── 网关 B(TLS 探测通过)→ 上游代理
           └── 都探测失败 → 直连

健康检查用一个真实请求把同一组候选走一遍,谁先给出 <500 的响应,谁就成为全局首选。

行为

  • 候选网关 = upstreamHost:upstreamPort(或 upstreamUrl)+ gateways + 启动环境的 HTTP(S)_PROXY/ALL_PROXY,去重并排除自身监听端口,最后补 direct。
  • 上游代理认证:upstreamUrl、gateways 或环境变量里的 HTTP 代理 URL 可带 user:pass;连接代理时会带 Proxy-Authorization: Basic。0.7.0 只支持 http:// 上游代理:upstreamUrl 传 https:// 会报错;额外候选(gateways、--gateway、GATEWAY、启动环境代理)里的 https:// 或非法值会给脱敏 warning 后跳过。Basic 只是 base64,不是加密,只建议回环或受信任网络。
  • CONNECT(HTTPS):443 上先对候选做 TLS 握手探测,通过的才用来开隧道;失败换下一条。
  • 普通 HTTP:请求体先缓冲(上限 8 MB),按同一顺序换路重放;建连用 attemptTimeoutMs(已知路径用 fastFailTimeoutMs),等响应头用 `responseTimeout