← 返回
未分类 中文

Aegis Bridge

Orchestrate Claude Code sessions via Aegis HTTP/MCP bridge. Use when spawning CC sessions for coding tasks, implementing issues, reviewing PRs, fixing CI, ba...
通过 Aegis HTTP/MCP 桥接编排 Claude Code 会话,用于在编码、实现 issues、审查PR、修复 CI 等场景下启动会话。
onestepat4time onestepat4time 来源
未分类 clawhub v0.1.0 1 版本 99864.1 Key: 无需
★ 0
Stars
📥 735
下载
💾 1
安装
1
版本
#latest

概述

Aegis — CC Session Orchestration

Aegis manages interactive Claude Code sessions via HTTP API (port 9100) or MCP tools. Each session runs CC in tmux with JSONL transcript parsing and bidirectional communication.

Prerequisites

  1. Aegis server running: curl -s http://127.0.0.1:9100/v1/health
  2. MCP configured (optional, for native tool access): see scripts/setup-mcp.sh
  3. Verify health: bash scripts/health-check.sh

Core Workflow

create → send prompt → poll status → handle permissions → read result → quality gate → cleanup

Step 1: Create Session

MCP: create_session(workDir, name?, prompt?)

HTTP:

SID=$(curl -s -X POST http://127.0.0.1:9100/v1/sessions \
  -H "Content-Type: application/json" \
  -d '{"workDir":"/path/to/project","name":"task-name"}' \
  | jq -r '.id')

> ⚠️ workDir must exist on disk or creation fails silently (returns null id).

Wait 8-10s for CC to boot. Check promptDelivery.delivered in the response — if false, resend via send_message after CC boots.

Step 2: Send Prompt

MCP: send_message(sessionId, text)

HTTP:

curl -s -X POST http://127.0.0.1:9100/v1/sessions/$SID/send \
  -H "Content-Type: application/json" \
  -d '{"text":"Your task here"}'

Step 3: Poll Until Idle

MCP: get_status(sessionId) — check status field

HTTP:

STATUS=$(curl -s http://127.0.0.1:9100/v1/sessions/$SID/read | jq -r '.status')

Step 4: Handle Permission Prompts

While polling, react to non-idle states:

StatusAction
----------------
idleDone — read result
workingWait (poll every 5s)
permission_promptPOST .../approve (trust folder, tool use)
bash_approvalPOST .../approve or POST .../reject
plan_modePOST .../approve (option 1) or POST .../escape
ask_questionPOST .../send with answer
unknownGET .../pane for raw terminal output

Step 5: Read Transcript

MCP: get_transcript(sessionId)

HTTP: curl -s http://127.0.0.1:9100/v1/sessions/$SID/read

Returns { messages[], status, statusText }. Each message: { role, contentType, text, timestamp }.

Step 6: Quality Gate

Before accepting output, verify:

  1. Check transcript for tool errors or failed assertions
  2. Run tsc --noEmit and build via send_message if needed
  3. Confirm tests pass (request CC to run them)
  4. Check for common issues: missing imports, hardcoded values, incomplete implementations

Step 7: Cleanup

MCP: kill_session(sessionId)

HTTP: curl -s -X DELETE http://127.0.0.1:9100/v1/sessions/$SID

Always cleanup — idle sessions consume tmux windows and memory.

Common Patterns

Implement Issue

create_session(workDir=repo, name="impl-#123", prompt="Implement issue #123. Read the issue description first, then write code. Don't explain, just implement. Run tests when done.")
→ poll → approve permissions → read transcript → verify tests pass → cleanup

Review PR

create_session(workDir=repo, name="review-PR-456", prompt="Review PR #456. Focus on: security issues, test coverage, API design. Be concise.")
→ poll → read transcript → extract review comments

Fix CI

create_session(workDir=repo, name="fix-ci", prompt="CI is failing on main. Run the failing test suite, identify the root cause, and fix it. Don't add skip/only annotations.")
→ poll → approve bash commands → verify CI green → cleanup

Batch Tasks

Spawn multiple sessions in parallel, then poll all:

for task in "task-a" "task-b" "task-c"; do
  curl -s -X POST http://127.0.0.1:9100/v1/sessions \
    -H "Content-Type: application/json" \
    -d "{\"workDir\":\"$REPO\",\"name\":\"$task\",\"prompt\":\"$task description\"}" \
    | jq -r '.id' >> /tmp/session-ids.txt
done
# Poll all until done
while read SID; do ... done < /tmp/session-ids.txt

Stall Detection and Recovery

A session is stalled when working for >5 minutes with no transcript change.

Detection

HASH1=$(curl -s http://127.0.0.1:9100/v1/sessions/$SID/read | jq -r '.messages | length')
sleep 30
HASH2=$(curl -s http://127.0.0.1:9100/v1/sessions/$SID/read | jq -r '.messages | length')
# If HASH1 == HASH2 and status is still "working", likely stalled

Recovery Options (in order)

  1. Nudge — send send_message("Continue. What's blocking you?")
  2. InterruptPOST .../interrupt then resend the task
  3. Refine — send a simplified or decomposed version of the task
  4. Pivot — kill session, create new one with a different approach
  5. Escalate — abandon automated approach, notify human

Troubleshooting

ProblemFix
--------------
Connection refused on 9100Aegis not running. Check scripts/health-check.sh
Session stuck at unknownGET .../pane for raw output. May need POST .../escape
Permission loop (approve keeps coming)Likely bash approval. Check transcript for the command. Reject if unsafe
promptDelivery: "failed"CC didn't boot yet. Wait 10s and resend via send_message
Session not appearing in list_sessionsCheck workDir filter. Session may have been killed
High memory usageKill idle sessions. Use list_sessions to find orphans

MCP Tool Reference

When MCP is configured, 21 tools are available natively:

Session Lifecycle

ToolDescription
-------------------
create_sessionSpawn new CC session (workDir, name, prompt)
list_sessionsList sessions, filter by status/workDir
get_statusDetailed session status + health
kill_sessionKill session + cleanup resources
batch_create_sessionsSpawn multiple sessions at once

Communication

ToolDescription
-------------------
send_messageSend text to a session
send_bashExecute bash via ! prefix
send_commandSend /slash command
get_transcriptRead conversation transcript
capture_paneRaw terminal output
get_session_summarySummary with message counts + duration

Permission Handling

ToolDescription
-------------------
approve_permissionApprove pending prompt
reject_permissionReject pending prompt
escape_sessionSend Escape key (dismiss dialogs)
interrupt_sessionSend Ctrl+C

Monitoring

ToolDescription
-------------------
server_healthServer version, uptime, session counts
get_session_metricsPer-session performance metrics
get_session_latencyLatency measurements

Advanced

ToolDescription
-------------------
list_pipelinesList multi-step pipelines
create_pipelineCreate orchestrated pipeline
get_swarmSwarm status for parallel sessions

For full API reference, see references/api-quick-ref.md.

For agent templates, see references/agent-template.md.

For heartbeat/dev-loop templates, see references/heartbeat-template.md.

版本历史

共 1 个版本

  • v0.1.0 当前
    2026-05-03 03:45 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

ai-agent

self-improving agent

pskoett
捕获经验教训、错误及修正内容,以实现持续改进。适用于以下场景:(1)命令或操作意外失败;(2)用户纠正Claude(如“不,那不对……”“实际上……”);(3)用户请求的功能不存在;(4)外部API或工具出现故障;(5)Claude发现自身
★ 4,109 📥 830,934
ai-agent

Find Skills

guipi888
场景驱动+关键词双模式技能发现工具。当用户用自然语言描述场景/需求(如"我想做一个海报""帮我分析股票"),或明确说"安装技能/find skills/找个skill"时,自动从官方内置、本地已安装、SkillHub、虾评、GitHub、C
★ 1,473 📥 535,861
dev-programming

Aegis Bridge

onestepat4time
通过 Aegis HTTP/MCP 桥接编排 Claude Code 会话,用于在编码、实现 issues、审查PR、修复 CI 等场景下启动会话。
★ 0 📥 495