/SKILL.md
# AegisGate Agent Skill > **What is this document?** This is an agent-executable skill document for AegisGate — an open-source LLM security gateway. It walks through installation, startup, token registration, upstream configuration, and client integration on a fresh machine. 本技能文档给 Agent 直接使用,目标是:在一台新机器上完成 AegisGate 的安装、启动、注册 token 或配置直连上游、以及客户端接入配置。 ## 0) What does AegisGate do? 先读项目要点(必须) - AegisGate 是 LLM 安全网关:请求侧脱敏/清洗,响应侧检测/自动净化(auto-sanitize);`responses` 结构化 `input`(含 function/tool 输出)也
npx skillsauth add ax128/aegisgate aegisgateInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
This skill has been flagged as suspicious. Review the scan results before using.
2 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
What is this document? This is an agent-executable skill document for AegisGate — an open-source LLM security gateway. It walks through installation, startup, token registration, upstream configuration, and client integration on a fresh machine.
本技能文档给 Agent 直接使用,目标是:在一台新机器上完成 AegisGate 的安装、启动、注册 token 或配置直连上游、以及客户端接入配置。
responses 结构化 input(含 function/tool 输出)也会在转发上游前做脱敏。http://<host>:18080/v1/__gw__/t/<TOKEN>/...http://<host>:18080/v2/__gw__/t/<TOKEN>,须携带 x-target-url: <完整目标URL> 请求头AEGIS_UPSTREAM_BASE_URL=<上游地址> 后,可直接请求 /v1/...,无需注册 token。v2 仍必须使用 token 路径。api_key,secret,token)。请求体中这些字段的值不做 PII 脱敏,直接透传到上游。适用于需要原始凭证通过的场景。支持以下匹配模式:
"field":"value" 或 "field": "value"field=valuefield:value?field=value/__gw__/register|lookup|unregister|add|remove)应只允许内网/管理机访问。uname -a
cat /etc/os-release
which docker || true
which docker-compose || true
git --version || true
python3 --version || true
sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo $VERSION_CODENAME) stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo systemctl enable --now docker
docker --version
docker compose version
可选(免 sudo):
sudo usermod -aG docker "$USER"
newgrp docker
git clone https://github.com/ax128/AegisGate.git
cd AegisGate
cd /path/to/AegisGate
docker network create cliproxyapi_default || true
docker network create sub2api-deploy_sub2api-network || true
docker compose up -d --build
docker compose ps
docker compose logs -f aegisgate
说明:仓库自带 docker-compose.yml 默认引用上述 external networks;如果你的环境不需要这些上游网络,需先覆盖或移除对应 network 挂载,再启动。
健康检查:
curl -sS http://127.0.0.1:18080/health
就绪检查(readiness,可选):
curl -sS http://127.0.0.1:18080/ready
python3 -m venv .venv
source .venv/bin/activate
python -m pip install -U pip
python -m pip install -e .
uvicorn aegisgate.core.gateway:app --host 127.0.0.1 --port 18080
注册上游并生成 token:
# gateway_key 从 cat config/aegis_gateway.key 获取
curl -X POST http://127.0.0.1:18080/__gw__/register \
-H "Content-Type: application/json" \
-d '{"upstream_base":"https://your-upstream.example.com/v1","gateway_key":"<AEGIS_GATEWAY_KEY>"}'
期望返回:
{
"token": "Ab3k9Qx7Yp",
"baseUrl": "http://127.0.0.1:18080/v1/__gw__/t/Ab3k9Qx7Yp"
}
注册时可附带脱敏豁免字段(如 api_key 字段值不做脱敏):
curl -X POST http://127.0.0.1:18080/__gw__/register \
-H "Content-Type: application/json" \
-d '{"upstream_base":"https://your-upstream.example.com/v1","gateway_key":"<AEGIS_GATEWAY_KEY>","whitelist_key":["api_key","secret"]}'
在 config/.env 中设置:
AEGIS_UPSTREAM_BASE_URL=https://your-upstream.example.com/v1
重启后直接请求 /v1/...,无需注册 token。/v2/... 不支持直连模式,仍需使用 /v2/__gw__/t/<TOKEN>/...:
curl -X POST http://127.0.0.1:18080/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <UPSTREAM_API_KEY>" \
-d '{"model":"gpt-4.1-mini","input":"hello"}'
curl -X POST "http://127.0.0.1:18080/v1/__gw__/t/<TOKEN>/responses" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <UPSTREAM_API_KEY>" \
-d '{"model":"gpt-4.1-mini","input":"hello"}'
curl -X POST "http://127.0.0.1:18080/v1/responses" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <UPSTREAM_API_KEY>" \
-d '{"model":"gpt-4.1-mini","input":"hello"}'
provider: openai_compatible
base_url: http://127.0.0.1:18080/v1/__gw__/t/<TOKEN>
api_key: <UPSTREAM_API_KEY>
model: gpt-4.1-mini
provider: openai_compatible
base_url: http://127.0.0.1:18080/v1
api_key: <UPSTREAM_API_KEY>
model: gpt-4.1-mini
说明:
[DONE] 断流恢复。base_url 携带 token 路径段。查看 token(按 upstream_base 查询已注册项):
curl -X POST http://127.0.0.1:18080/__gw__/lookup \
-H "Content-Type: application/json" \
-d '{"upstream_base":"https://your-upstream.example.com/v1","gateway_key":"<AEGIS_GATEWAY_KEY>"}'
删除 token:
curl -X POST http://127.0.0.1:18080/__gw__/unregister \
-H "Content-Type: application/json" \
-d '{"token":"<TOKEN>","gateway_key":"<AEGIS_GATEWAY_KEY>"}'
查看所有 token(最稳妥:直接读本机映射文件):
cat config/gw_tokens.json
通过 UI API 查看所有 token(GET /__ui__/api/tokens 不是 X-Gateway-Key 直调接口;需要 session cookie):
# 1) 登录 UI,获取 session cookie
curl -c /tmp/aegisgate-ui.cookie -X POST http://127.0.0.1:18080/__ui__/api/login \
-H "Content-Type: application/json" \
-d '{"password":"<AEGIS_GATEWAY_KEY>"}'
# 2) 使用已登录 session 查看 token 列表
curl -b /tmp/aegisgate-ui.cookie http://127.0.0.1:18080/__ui__/api/tokens
说明:
curl 调用 UI API 返回 401,通常是因为 AEGIS_LOCAL_UI_SECURE_COOKIE=true(默认)会下发 Secure cookie,http://127.0.0.1 场景下 cookie 不会被回传;此时请改用 HTTPS 访问 UI,或临时设置 AEGIS_LOCAL_UI_SECURE_COOKIE=false 后重启网关再测试(仅建议开发环境)。x-aegis-ui-csrf;可通过 GET /__ui__/api/bootstrap 读取当前 session 的 csrf token。查看日志:
docker compose logs -f aegisgate
重启:
docker compose restart aegisgate
升级:
git pull
docker compose up -d --build
health 是否正常(curl http://127.0.0.1:18080/health)。/v1/__gw__/t/<TOKEN>/...)或直连上游(AEGIS_UPSTREAM_BASE_URL 是否已设置)。upstream_base,用 POST /__gw__/lookup 反查 token;若只知道 token,可查看 config/gw_tokens.json 或登录 UI 后访问 /__ui__/api/tokens。同时确认上游地址与 API key 是否正确。.env 中 AEGIS_UPSTREAM_BASE_URL 是否正确,是否已重启。docker compose logs -f aegisgate 是否有 upstream 错误、自动净化(auto-sanitize)、阻断原因。127.0.0.1,通过反向代理做外部暴露控制。config/aegis_gateway.key(替换文件内容后重启服务)。whitelist_key 字段只填真正需要豁免脱敏的字段名,最小化敏感数据明文透传范围。tools
Use when work should span one or more detached tasks but still behave like one job with a single owner context. TaskFlow is the durable flow substrate under authoring layers like Lobster, ACPX, plugins, or plain code. Keep conditional logic in the caller; use TaskFlow for flow identity, child-task linkage, waiting state, revision-checked mutations, and user-facing emergence.
tools
# Lobster Lobster executes multi-step workflows with approval checkpoints. Use it when: - User wants a repeatable automation (triage, monitor, sync) - Actions need human approval before executing (send, post, delete) - Multiple tool calls should run as one deterministic operation ## When to use Lobster | User intent | Use Lobster? | | ------------------------------------------------------ | --------------------------
tools
# Lobster Lobster executes multi-step workflows with approval checkpoints. Use it when: - User wants a repeatable automation (triage, monitor, sync) - Actions need human approval before executing (send, post, delete) - Multiple tool calls should run as one deterministic operation ## When to use Lobster | User intent | Use Lobster? | | ------------------------------------------------------ | --------------------------
tools
A CLI tool for making authenticated requests to the X (Twitter) API. Use this skill when you need to post tweets, reply, quote, search, read posts, manage followers, send DMs, upload media, or interact with any X API v2 endpoint.