The deployment has a single Claude OAuth credential and a single Codex ChatGPT account, so the N-account rotation machinery only added state files, cooldown bookkeeping and code paths that never ran. Removed: - Claude token rotation (token-rotation.ts, token-rotation-base.ts): rotate-on-limit, per-token cooldowns, token-rotation-state.json. CLAUDE_CODE_OAUTH_TOKENS is still read, but only its first entry. - Codex account rotation (codex-token-rotation.ts): account pool, rotate-on-429/auth, dead-auth/cooldown tracking, round-robin advance, d7 auto-rotate, codex-rotation-state.json, manual account switch. - Account index plumbing in token-refresh, claude-credentials-path (CLAUDE_ACCOUNTS_DIR / ~/.claude-accounts/<n>), Claude/Codex usage collectors, the dashboard rows and the Codex warm-up. - provider-retry.ts rotation loops and the Codex retry path. Kept: - Codex exclusive auth lease (one Codex run at a time), the 15-minute waitForCodexAuthLease, and a usage-poll lease that skips while a run holds the account (codex-auth.ts). - Session auth copy and write-back of refreshed tokens (syncCodexSessionAuthBack, syncClaudeSessionAuthBack). - Codex auth path: ~/.codex-accounts/0/auth.json, else ~/.codex/auth.json (now resolved per run, so a re-login needs no restart). - Claude token refresh loop, CLAUDE_CREDENTIALS_PATH and the CLAUDE_TOKEN_REFRESH_* / CLAUDE_USAGE_USE_HOME_CREDENTIALS flags; an auth-expired run still force-refreshes the token and retries once. - Error classification (classifyClaudeTrigger, classifyCodexTrigger). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4.6 KiB
name, description
| name | description |
|---|---|
| setup | Run initial EJClaw setup for the unified single-service Discord architecture. |
EJClaw Setup
설치는 bash setup.sh로 부트스트랩하고, 나머지는 bun run setup -- --step <name>으로 진행합니다. 현재 기준 채널은 디스코드만 지원합니다.
EJClaw는 현재 단일 서비스로 동작합니다:
- ejclaw — 통합 런타임 서비스
owner 역할의 코드 기본값은 Codex(OWNER_AGENT_TYPE, reviewer 기본값은 Claude Code)이며, .env에서 바꿀 수 있습니다(현재 운영 배포는 owner=claude-code, reviewer=codex, arbiter=claude-code). Codex는 별도 서비스가 아니라 같은 ejclaw 서비스 안에서 내부 러너/역할 라우팅으로 실행됩니다.
1. 부트스트랩
bash setup.sh
- Bun 1.3 이상과 의존성이 준비되어야 합니다(
setup.sh가 Bun을 확인합니다). - 실패하면
logs/setup.log를 먼저 봅니다.
2. 현재 상태 확인
bun run setup -- --step environment
여기서 확인할 것:
.env존재 여부- 기존 등록 그룹 존재 여부
- 이미 초기화된 설치인지 여부
3. 필수 환경 변수
기본 환경 변수 (.env)
.env에 최소한 아래 값이 있어야 합니다.
DISCORD_OWNER_BOT_TOKEN=... # owner 봇 토큰
DISCORD_REVIEWER_BOT_TOKEN=... # reviewer 봇 토큰
DISCORD_ARBITER_BOT_TOKEN=... # arbiter 봇 토큰
# 구 이름(DISCORD_BOT_TOKEN 등)은 더 이상 지원되지 않으며, 남아 있으면 시작 시 오류로 종료됩니다
CLAUDE_CODE_OAUTH_TOKEN=... # 또는 ANTHROPIC_API_KEY=...
ASSISTANT_NAME=claude # 트리거 이름 (@claude)
권장:
GROQ_API_KEY=... # Discord 음성 전사 (Groq Whisper)
Codex 관련 선택 설정은 별도 서비스 파일이 아니라 같은 .env 또는 서비스 환경 변수에 넣습니다:
# 같은 .env 또는 서비스 Environment=에 추가 가능
CODEX_MODEL=gpt-5.5
CODEX_EFFORT=xhigh
Codex는 API 키가 아니라 OAuth로만 인증합니다(러너가 OPENAI_API_KEY를 일부러 제거함). 로그인:
CODEX_HOME=$HOME/.codex-accounts/0 ./node_modules/.bin/codex login --device-auth
선택 환경 변수
# 사용량 대시보드
STATUS_CHANNEL_ID=... # 상태 업데이트 디스코드 채널
USAGE_DASHBOARD=true
# 고급 설정
MAX_CONCURRENT_AGENTS=5
4. 러너 빌드
bun run setup -- --step runners
이 단계는 아래 두 러너를 빌드합니다.
runners/agent-runner(Claude Code)runners/codex-runner(Codex)
서비스는 하나지만, 내부 역할 라우팅과 paired 흐름에서 두 러너를 모두 쓸 수 있어서 둘 다 빌드합니다.
실패하면 보통 bun run build:runners 출력과 각 러너의 package.json 의존성을 같이 보면 됩니다.
5. 디스코드 채널 등록
먼저 디스코드에서 개발자 모드를 켜고 채널 ID를 복사합니다. 등록 JID는 dc:<channel_id> 형식입니다.
채널 등록은 기본적으로 한 번 하면 됩니다.
예시:
bun run setup -- --step register -- \
--jid dc:123456789012345678 \
--name "My Server #general" \
--folder discord_general
다른 채널 예시 (모든 방은 동등하며 자기 방만 다룹니다):
bun run setup -- --step register -- \
--jid dc:123456789012345678 \
--name "My Server #ops" \
--folder discord_ops
6. 서비스 시작
bun run setup -- --step service
이 명령은:
- ejclaw 서비스를 설치하고 시작합니다
Linux systemd만 지원합니다: ~/.config/systemd/user/ejclaw.service
수동으로 서비스 관리:
# Linux (systemd)
systemctl --user status ejclaw
systemctl --user restart ejclaw
# 로그
journalctl --user -u ejclaw -f
7. 최종 검증
bun run setup -- --step verify
성공 기준:
- ejclaw 서비스가 running
- Claude 인증이 configured
CHANNEL_AUTH에discord- 등록 그룹 수가 1 이상
빠른 문제 해결
- 빌드 문제:
bun run typecheck,bun run test,bun run build:runners - Claude 서비스 문제:
journalctl --user -u ejclaw -f - Codex 실행 문제: 같은
ejclaw서비스 로그와CODEX_MODEL,CODEX_EFFORT, Codex 인증 파일(~/.codex-accounts/0/auth.json)을 확인 - 디스코드 연결 문제:
.env의DISCORD_OWNER_BOT_TOKEN/DISCORD_REVIEWER_BOT_TOKEN/DISCORD_ARBITER_BOT_TOKEN과 등록된dc:*JID 확인 - 응답 문제:
journalctl --user -u ejclaw -f