Skip to content

Instantly share code, notes, and snippets.

@link2004
Created March 21, 2026 05:00
Show Gist options
  • Select an option

  • Save link2004/86af8bf18287e5eb62384d4fbc381136 to your computer and use it in GitHub Desktop.

Select an option

Save link2004/86af8bf18287e5eb62384d4fbc381136 to your computer and use it in GitHub Desktop.
e2btest Agent Platform API Documentation

e2btest — Agent Platform API

スキルをアップロードするだけでエージェントアプリが作れるプラットフォーム。

アーキテクチャ

Lovable (UI) ←WebSocket→ server.mjs (HTTP + WS proxy)
                              └─ @ccpocket/bridge (内部 port 18765)
                                   └─ Claude Code CLI → CLAUDE.md + スキル自動ロード

セットアップ

環境変数

変数名 必須 デフォルト 説明
ANTHROPIC_API_KEY Claude API キー
PORT 8080 サーバーポート
BRIDGE_PORT 18765 内部 Bridge ポート
BRIDGE_HOST 127.0.0.1 Bridge ホスト

起動

npm start
# or
node server.mjs

REST API

Base URL: http://localhost:8080 (本番: https://e2btest-production.up.railway.app)

全エンドポイントに以下の CORS ヘッダーが付与されます:

Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, DELETE, OPTIONS
Access-Control-Allow-Headers: Content-Type

GET /health

ヘルスチェック。

Response 200

{
  "status": "ok",
  "activeSessions": 3
}

GET /agents

登録済みエージェント一覧を取得。

Response 200

{
  "agents": ["general", "game-creator"]
}

POST /agents/:name

ZIP ファイルをアップロードして新しいエージェントを登録。

Parameters

名前 位置 説明
name path string エージェント名(英数字・ハイフン・アンダースコアのみ)

Request

  • Content-Type: application/octet-stream
  • Body: ZIP ファイル (raw binary)

処理内容

  1. ZIP を agents/{name}/ に展開
  2. ネストされたディレクトリを自動フラット化
  3. macOS ジャンクファイル (__MACOSX) を削除
  4. CLAUDE.md がなければ自動生成
  5. .md ファイルを .claude/skills/ に自動配置
  6. common/.claude/skills/ から共通スキルを注入

Response 201

{
  "ok": true,
  "name": "agent-name",
  "projectPath": "/agents/agent-name"
}

Error 500

{
  "error": "error message"
}

DELETE /agents/:name

エージェントを削除。

Parameters

名前 位置 説明
name path string エージェント名

Response 200

{ "ok": true }

Error 404

{ "error": "Not found" }

GET /agents/:name/files/:path

エージェントが生成したファイルを取得。

Parameters

名前 位置 説明
name path string エージェント名
path path string ファイルパス(エージェントディレクトリからの相対パス)

対応 MIME タイプ: mp4, mp3, wav, png, jpg, jpeg, gif, webp, pdf, zip, html, css, js, json, md, txt

Response 200 — 適切な Content-Type + Content-Disposition: inline

Error 404

{ "error": "File not found" }

URL 例:

https://e2btest-production.up.railway.app/agents/remotion/files/koike-video/out/koike.mp4

WebSocket API

Endpoint: ws://localhost:8080 (本番: wss://e2btest-production.up.railway.app)

HTTP と同一ポートで WebSocket をリッスンします。内部で ccpocket Bridge Server へプロキシされます。


Client → Server メッセージ

start — セッション開始

{
  "type": "start",
  "prompt": "こんにちは",
  "projectPath": "/agents/general",
  "permissionMode": "bypassPermissions"
}
フィールド 必須 説明
type "start"
prompt string 初回プロンプト
projectPath string エージェントのパス(デフォルト: /agents/{name}
permissionMode string "default" or "bypassPermissions"

input — 追加入力

{
  "type": "input",
  "sessionId": "uuid-string",
  "text": "続きをお願いします"
}

approve — ツール実行を承認

{
  "type": "approve",
  "sessionId": "uuid-string",
  "toolUseId": "tool-123"
}

reject — ツール実行を拒否

{
  "type": "reject",
  "sessionId": "uuid-string",
  "toolUseId": "tool-123",
  "message": "理由(任意)"
}

answer — AskUserQuestion への回答

{
  "type": "answer",
  "sessionId": "uuid-string",
  "toolUseId": "tool-123",
  "answer": "選択肢ラベル"
}

stop_session — セッション停止

{
  "type": "stop_session",
  "sessionId": "uuid-string"
}

Server → Client メッセージ

system — セッション初期化

{
  "type": "system",
  "subtype": "init",
  "sessionId": "uuid-string",
  "model": "claude-sonnet-4-20250514"
}

status — ステータス変更

{
  "type": "status",
  "sessionId": "uuid-string",
  "status": "starting | idle | running | waiting_approval | compacting"
}

stream_delta — テキストストリーミング

{
  "type": "stream_delta",
  "delta": "テキストの断片"
}

thinking_delta — 思考プロセスのストリーミング

{
  "type": "thinking_delta",
  "delta": "思考テキストの断片"
}

assistant — アシスタントメッセージ(完了時)

{
  "type": "assistant",
  "message": {
    "role": "assistant",
    "content": [
      { "type": "text", "text": "回答テキスト" },
      { "type": "tool_use", "id": "tool-123", "name": "Bash", "input": { "command": "ls" } }
    ]
  }
}

tool_result — ツール実行結果

{
  "type": "tool_result",
  "toolUseId": "tool-123",
  "content": "実行結果"
}

permission_request — 許可リクエスト

{
  "type": "permission_request",
  "sessionId": "uuid-string",
  "toolUseId": "tool-123",
  "toolName": "Bash",
  "input": { "command": "rm -rf /tmp/test" }
}

result — ターン完了

{
  "type": "result",
  "isError": false,
  "duration": 5200,
  "cost": 0.03,
  "totalCost": 0.15
}

error — エラー

{
  "type": "error",
  "message": "エラーの説明"
}

セッション管理

  • セッションは activeSessions Map で追跡
  • TTL: 5 分間の非アクティブで自動停止
  • クリーンアップ間隔: 30 秒ごとにチェック
  • アイドルセッションは Bridge に stop_session を送信して停止

メッセージフロー

Client                              Server
  │                                   │
  │── start { prompt } ────────────>│
  │<──── status { starting } ───────│
  │<──── system { init } ───────────│
  │<──── status { running } ────────│
  │<──── stream_delta { ... } ──────│  (複数回)
  │<──── thinking_delta { ... } ────│  (複数回)
  │<──── assistant { message } ─────│
  │<──── tool_result { ... } ───────│
  │<──── result { cost, duration } ─│
  │<──── status { idle } ───────────│
  │                                   │
  │── input { text } ──────────────>│
  │<──── status { running } ────────│
  │<──── ...                         │

エージェントのディレクトリ構造

/agents/
├── {name}/
│   ├── CLAUDE.md              # エージェントの人格・指示
│   ├── .claude/
│   │   └── skills/            # Claude Code スキル
│   │       ├── skill-a.md
│   │       ├── skill-b.md
│   │       └── file-share.md  # 共通スキル(自動注入)
│   └── [生成ファイル]
└── common/
    └── .claude/
        └── skills/            # 全エージェント共通スキル
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment