Commit Graph

384 Commits

Author SHA1 Message Date
Eyejoker
83d7bf3d51 feat: merge per-group codex config overlay 2026-03-23 04:20:55 +09:00
Eyejoker
f49d0f1732 fix: restore mentionless paired room bot flow 2026-03-23 04:18:44 +09:00
Eyejoker
be521eb903 fix: require triggers for paired bot messages 2026-03-23 04:15:22 +09:00
Eyejoker
1974f8a6dc refactor: remove active follow-up piping 2026-03-23 04:13:53 +09:00
Eyejoker
3435b99cfc fix: remove silent run budget 2026-03-23 04:07:12 +09:00
Eyejoker
562067352a fix: keep finals separate after silent retries 2026-03-23 03:54:19 +09:00
Eyejoker
290cd95e51 fix: separate finals from tracked progress 2026-03-23 03:54:04 +09:00
Eyejoker
78145c1d46 fix: simplify follow-up lifecycle after output 2026-03-23 02:23:59 +09:00
Eyejoker
58868b02d1 style: format message runtime helper 2026-03-23 02:20:10 +09:00
Eyejoker
1a702d61e3 simplify runtime turn and progress handling 2026-03-23 02:19:48 +09:00
Eyejoker
b83cc95963 fix: restore best-effort progress and requeue stale follow-ups
Two v1/v2 regressions fixed:

1. Progress messages became too brittle: editMessage failure killed all
   subsequent progress updates for the turn. Now resets progressMessageId
   and recreates on next update instead of permanently stopping.

2. Follow-up messages stuck in active agent without output: after 10s of
   no output, closeStdin and requeue the follow-up as a fresh run with
   cursor rollback, instead of silently dropping it.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-23 01:28:52 +09:00
Eyejoker
b5fccf23c4 style: format restart recovery test 2026-03-23 01:00:45 +09:00
Eyejoker
28eb8c6cb1 fix: harden restart recovery flow 2026-03-23 01:00:14 +09:00
Eyejoker
a1324726b1 style: format after runtime unification
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-23 00:44:04 +09:00
Eyejoker
d4fc498268 refactor: unify runtime into single message-runtime path
Remove duplicate processGroupMessages, runAgent, startMessageLoop, and
recoverPendingMessages from index.ts. All message processing now flows
through createMessageRuntime() in message-runtime.ts, eliminating the
dual-path issue that caused the v1 follow-up turn reset bug.

index.ts reduced from ~2300 to ~1210 lines.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-23 00:43:57 +09:00
Eyejoker
badb900a23 style: format files after pre-commit prettier run
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-23 00:11:44 +09:00
Eyejoker
b647502a10 feat: add seq cursor, work_items, provider fallback, and delivery reliability
Major reliability improvements to the message processing pipeline:

- Add messages.seq monotonic cursor replacing timestamp-based cursors,
  preventing message loss from timestamp collisions with LIMIT queries
- Add work_items table separating agent production from delivery,
  enabling delivery retry without re-running the agent
- Propagate Discord send failures instead of silently swallowing them
- Add Claude 429 → Kimi K2.5 automatic provider fallback with cooldown
- Fix follow-up turn state reset in live index.ts path (not just
  message-runtime.ts) to prevent final output from being lost
- Add restart context tracking for graceful restart announcements
- Lazy migration from timestamp cursors to seq cursors for existing data

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-23 00:11:32 +09:00
Eyejoker
dd15585941 fix: pass actual chat JID to agent runner instead of group folder
watch_ci tasks in perf channel were silently failing because
NANOCLAW_CHAT_JID was set to the group folder name (e.g. "eyejokerdb-4")
instead of the actual Discord JID. The scheduler rejected the task with
"target group not registered".

Also adds a fallback in ipc.ts to resolve folder names to registered
JIDs when a folder name is passed instead of a JID.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-21 14:27:00 +09:00
Eyejoker
2c8260135f style: format message-runtime files
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-21 12:29:12 +09:00
Eyejoker
9b741be902 fix: resolve session race condition and follow-up turn output loss
Two bugs fixed:

1. agent-runner error path race condition: when agent process exited
   with error, the promise resolved immediately without waiting for
   outputChain, allowing a late wrappedOnOutput to re-persist a stale
   session ID after clearSession had already run.

2. follow-up turn state not resetting: when a follow-up IPC message
   joined an active run, turn-level flags (finalOutputSentToUser,
   sawNonProgressOutput) from the first turn prevented the last
   progress from being promoted to a final message.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-21 12:29:00 +09:00
Eyejoker
767ab20d76 Restrict Codex task scheduling to CI watchers 2026-03-20 04:09:36 +09:00
Eyejoker
f3283f0314 style: format merged scheduler and db changes 2026-03-20 03:48:48 +09:00
Eyejoker
6eb72ad499 Merge origin/main into chore/nanoclaw-recursive-room 2026-03-20 03:48:29 +09:00
Eyejoker
f281a2ee52 style: apply formatter to runtime files 2026-03-20 03:42:22 +09:00
Eyejoker
a293a701f4 fix: restore regressions from discord-only refactor 2026-03-20 03:41:53 +09:00
Eyejoker
2b08851c2f style: format config and db 2026-03-20 01:08:15 +09:00
Eyejoker
bb0628e8f4 refactor: remove legacy container and non-discord remnants 2026-03-20 01:07:46 +09:00
Eyejoker
ea09560128 Add prompts for nanoclaw recursive improvement room 2026-03-20 00:20:39 +09:00
Eyejoker
41afcb91cf feat: integrate Memento MCP for shared memory across agents
- Add MEMENTO_MCP_SSE_URL/ACCESS_KEY/REMOTE_PATH to readEnvFile
- Merge .env vars into cleanEnv for runner process inheritance
- Claude Code runner: add memento-mcp via mcp-remote in mcpServers
- Codex runner: inject memento-mcp section into config.toml
- Various improvements: CI watch, task scheduler, DB, IPC auth
2026-03-20 00:12:43 +09:00
Eyejoker
e7200a1ed8 Fix Codex task target JID injection 2026-03-19 14:35:30 +09:00
Eyejoker
193119945a Add self-stopping CI watch tasks 2026-03-19 14:14:39 +09:00
Eyejoker
aa063ccea4 Reset Codex progress tracking between turns 2026-03-19 04:02:51 +09:00
Eyejoker
f2ad1331a9 Rebrand NanoClaw to EJClaw 2026-03-19 03:31:41 +09:00
Eyejoker
29b78fc286 Refine Codex progress message tracking 2026-03-19 03:22:31 +09:00
Eyejoker
779d57c392 Stabilize paired-room orchestration and Codex app-server flow 2026-03-19 02:57:14 +09:00
Eyejoker
b710d4a33d chore: update claude-agent-sdk to 0.2.76, read dashboard config from .env
- Bump @anthropic-ai/claude-agent-sdk 0.2.68 → 0.2.76
- Read STATUS_CHANNEL_ID and USAGE_DASHBOARD from .env file
2026-03-16 05:54:17 +09:00
Eyejoker
385f3a0349 feat: block follow-up IPC after closeStdin with closingStdin flag
Prevent piping new messages to an agent that is shutting down.
Reset flag on new process start and cleanup.
2026-03-16 05:39:35 +09:00
Eyejoker
ea03956d0a feat: show session ID in dashboard status display
Add session label (last 8 chars) next to each group status.
Export buildStatusContent and DashboardOptions for testing.
2026-03-16 05:36:30 +09:00
Eyejoker
6f38f1cd63 feat: add SESSION_COMMAND_USER_IDS for admin session command access
Allow configured user IDs to execute session commands (/clear etc.)
in non-main groups. Adds isAdminSender check alongside isFromMe.
2026-03-16 05:14:38 +09:00
Eyejoker
7e77f37948 refactor: extract dashboard and message-runtime from index.ts
- Extract dashboard code into src/dashboard.ts
- Extract message runtime into src/message-runtime.ts
- Improve group-queue with better concurrency handling
- Update agent-runner with enhanced env/config passing
- Simplify DB operations and cleanup unused code
- Update README for Codex SDK architecture
2026-03-16 05:08:19 +09:00
Eyejoker
e23315ed48 feat: usage/server dashboard with progress bars and aligned labels 2026-03-15 22:37:40 +09:00
Eyejoker
9a6d9f4c4b revert: roll back DB merge, keep useful improvements
Fully revert DB merge patch (WAL, composite PK, SERVICE_ID in IPC/
router_state/sessions). Return to proven split-DB architecture.

Keep:
- Docker/Apple Container cleanup
- Usage dashboard CLAUDE_CODE_OAUTH_TOKEN fallback
- Codex runner heartbeat
- Agent-runner stderr timeout reset
2026-03-15 22:35:53 +09:00
Eyejoker
e2d6476cdf refactor: rename container/ to runners/
No longer using Docker containers — agents run as direct host
processes. The directory name now reflects the actual purpose.

Updated all references across source code, docs, and skills.
2026-03-15 19:29:23 +09:00
Eyejoker
6f4b6f8df7 feat: prepare DB for shared access (WAL, service partitioning)
Phase 0-2 of data unification:
- Enable WAL mode + busy_timeout for safe concurrent access
- router_state: keys prefixed with SERVICE_ID (lazy migration)
- sessions: composite PK (group_folder, agent_type)
- registered_groups: filtered by SERVICE_AGENT_TYPE on load
- Logger: service name tag for unified log streams

All changes are backward-compatible with the current split setup.
Actual directory merge (Phase 3-4) is a separate step.
2026-03-15 19:26:34 +09:00
Eyejoker
26783e520e refactor: switch codex runner from app-server to SDK
Replace raw JSON-RPC app-server protocol with @openai/codex-sdk.
The SDK wraps `codex exec` which ensures complete task execution per
turn, fixing the issue where app-server mode ended turns prematurely
(agent saying "하겠습니다" without doing the work).

Also fix AGENTS.md copy in agent-runner (was copying instructions.md
which Codex CLI doesn't read).
2026-03-14 22:42:47 +09:00
Eyejoker
66bc3c6ff1 fix: skip discord-codex channel registration on codex service
The codex service uses its own DISCORD_BOT_TOKEN via systemd
EnvironmentFile, so the discord-codex secondary channel is only
relevant for the primary service. Removes spurious credential
missing warning on codex service startup.
2026-03-14 19:13:16 +09:00
Eyejoker
35356dd8a7 refactor: remove token-refresh, use env-based auth only
Delete token-refresh.ts and credentials.json sync. Auth is now
via CLAUDE_CODE_OAUTH_TOKEN in .env (1-year setup-token).
No more auto-refresh loop or credentials.json dependency.
2026-03-14 19:09:40 +09:00
Eyejoker
3546a35354 refactor: skip token auto-refresh when using env-based auth
When CLAUDE_CODE_OAUTH_TOKEN or ANTHROPIC_API_KEY is set in .env,
the credentials.json refresh loop is unnecessary. setup-token
generates a 1-year token, making auto-refresh redundant.
2026-03-14 19:01:30 +09:00
Eyejoker
e4eca65c7c feat: suppress Discord link embed previews on bot messages
Add MessageFlags.SuppressEmbeds to all send() calls so URLs in
agent responses don't generate large preview cards.
2026-03-14 03:29:26 +09:00
Eyejoker
f388323987 chore: increase text file inline limit from 8000 to 32000 chars
11k char deployment logs were getting truncated, cutting off the
actual error. 32k is safe for 200k context window.
2026-03-14 02:34:34 +09:00