Files
EJClaw/.claude/skills/debug/SKILL.md
Codex ce4547daa6 feat: replace session commands with a natural-language stop
Remove the /compact, /clear and /stop session commands. They were gated
to the main room or SESSION_COMMAND_ALLOWED_SENDERS, neither of which
exists in this deployment, so nobody could use them. The agent-runner
/compact passthrough goes with them.

Instead, a short human message whose whole intent is "stop" (그만, 멈춰,
중단해, 하지 마, 취소, stop, cancel, ...; see src/stop-intent.ts) stops the
room when it has something to stop: a running or queued run, an open
paired task, or unprocessed human messages before it. The message loop
then
- advances the room cursors past the stop message (memory + router_state)
- completes the open paired task as user_stopped, cancels its open turns
  and drops its execution lease
- closes stdin with a user-stop reason and kills the agent through the
  existing GroupQueue.closeStdin/killProcess
- replies "진행 중이던 작업을 중단했습니다." once
When nothing is running the message is handled as a normal message.

The user-stop close reason is treated like a human interruption, so the
killed paired turn releases its lease without counting a failure and
queues no follow-up, and the turn controller does not post the generic
failure text on top of the stop reply.

advanceLastAgentCursor no longer moves a cursor backwards, so a run that
finishes after the stop cannot rewind the cursor and re-dispatch the
stop message (the respawn seen when an agent was only killed).

Stale SESSION_COMMAND_* keys in .env are now ignored instead of failing
startup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 19:26:10 +09:00

3.8 KiB

name, description
name description
debug Debug EJClaw runtime issues on the current Discord-only, host-process architecture.

EJClaw Debugging

현재 기준 EJClaw는 디스코드 전용이고, 에이전트는 컨테이너가 아니라 호스트 프로세스로 실행됩니다. 디버깅은 채널, 서비스, 러너, DB 등록, 자격 증명 순서로 좁혀갑니다.

빠른 점검 순서

  1. 타입과 테스트부터 확인
    bun run typecheck
    bun run test
    
  2. 서비스 상태 확인
    bun run setup -- --step verify
    
  3. 런타임 로그 확인
    journalctl --user -u ejclaw -f
    ls -t groups/*/logs/agent-*.log | head
    
  4. 러너 빌드 확인
    bun run build:runners
    

핵심 파일

  • src/index.ts - 메시지 루프, 세션 명령, 라우팅
  • src/channels/discord.ts - 디스코드 수신/송신, 멘션, 첨부파일, 음성 전사
  • src/agent-runner.ts - 러너 실행, 환경 변수 전달, 워크디렉터리 처리
  • runners/agent-runner/src/index.ts - Claude Code 러너
  • runners/codex-runner/src/index.ts - Codex 러너
  • src/db.ts - 등록 그룹, 세션, 스케줄 저장
  • setup/register.ts - 디스코드 채널 등록
  • setup/verify.ts - 설치 상태 검증

자주 보는 문제

봇이 아예 말이 없음

grep -nE '^DISCORD_(OWNER|REVIEWER|ARBITER)_BOT_TOKEN=' .env
bun run setup -- --step verify
  • DISCORD_OWNER_BOT_TOKEN / DISCORD_REVIEWER_BOT_TOKEN / DISCORD_ARBITER_BOT_TOKEN이 없으면 채널이 안 붙습니다. 구 이름(DISCORD_BOT_TOKEN 등)이 남아 있으면 시작 시 오류로 종료됩니다.
  • ASSIGNED_ROOMS=0이면 채널 등록이 안 된 상태입니다.
  • 메인 채널이 아니면 디스코드 멘션이나 트리거 조건을 먼저 확인합니다.

에이전트가 실행 직후 죽음

grep -nE '^(CLAUDE_CODE_OAUTH_TOKEN|ANTHROPIC_API_KEY|OPENAI_API_KEY|CODEX_OPENAI_API_KEY)=' .env
ls -t groups/*/logs/agent-*.log | head -3
  • Claude 계열은 CLAUDE_CODE_OAUTH_TOKEN 또는 ANTHROPIC_API_KEY가 필요합니다.
  • Codex는 API 키가 아니라 OAuth 인증 파일(~/.codex-accounts/0/auth.json)을 씁니다. 만료됐으면 CODEX_HOME=$HOME/.codex-accounts/0 ./node_modules/.bin/codex login --device-auth로 다시 로그인합니다. 실패 원인은 paired_turn_attempts.last_error에서 확인합니다.
  • 러너 로그에 인증 실패나 CLI 실행 오류가 바로 찍힙니다.

음성 전사가 안 됨

grep -nE '^(GROQ_API_KEY|OPENAI_API_KEY)=' .env
journalctl --user -u ejclaw -f | grep -iE 'transcri|audio|whisper|groq'
  • 기본 우선순위는 Groq Whisper, 없으면 OpenAI Whisper fallback입니다.
  • 키가 없으면 디스코드 채널은 음성 첨부를 텍스트로 확장하지 못합니다.

등록은 되어 있는데 응답이 이상함

bun -e "import {Database} from 'bun:sqlite'; const db=new Database('store/messages.db',{readonly:true}); console.table(db.query('select chat_jid, folder, room_mode, requires_trigger, is_main, owner_agent_type, work_dir from room_settings').all())"
  • chat_jid는 dc:<channel_id> 형식이어야 합니다. tribunal 방인데 work_dir가 비어 있으면 첫 턴에 자동 복구됩니다.
  • folder는 discord_main 또는 discord_<name> 형태를 유지합니다.
  • 작업 중단("그만", "stop")이 안 먹으면 로그의 Stopped room work on user request와 src/stop-intent.ts 판정 규칙을 같이 봅니다.

원칙

  • 채널 문제와 에이전트 문제를 섞지 말고 분리해서 봅니다.
  • .env, DB 등록, 서비스, 러너 빌드 중 하나라도 틀리면 상위 증상이 비슷하게 보입니다.
  • 컨테이너 전제 문서는 무시하고 runners/*와 setup/* 기준으로 확인합니다.