Commit graph

8 commits

Author SHA1 Message Date
0bca340920 feat(02-02): add /model command and fix stdout buffer overflow
- Add /model command to switch models per-session (persisted in metadata)
- Support aliases: sonnet, opus, haiku → full model IDs
- Add load_persona_for_session() helper that applies model override
- Increase asyncio subprocess stdout buffer to 10MB (fixes crash on
  large stream-json lines from image tool results)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 22:42:23 +00:00
2d0d4da992 fix(02-02): typing indicator lifecycle, model identity, tool permissions
- Fix typing indicator not showing: clean up stale typing tasks between
  messages and use dynamic event lookup in callbacks instead of capturing
  a specific event at creation time
- Fix stream-json input format: use nested message object for stdin NDJSON
- Switch --system-prompt to --append-system-prompt so Claude Code's
  default system prompt (with model identity) is preserved
- Add --dangerously-skip-permissions for full tool access in subprocess
- Use full model ID (claude-sonnet-4-5-20250929) in default persona

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 22:10:02 +00:00
6a115a4947 refactor(02-01): persistent subprocess with stream-json I/O
- Replace fresh-process-per-turn with persistent subprocess model
- Accept NDJSON messages on stdin via --input-format stream-json
- Emit stream-json events on stdout including tool_use events
- Add on_tool_use callback for progress notifications
- Persistent stdout/stderr readers run for process lifetime
- Result events mark not busy but don't exit reader loop
- stdin.write + drain pattern prevents pipe buffer deadlock
- Auto-start process if not running when send_message called
- Crash recovery restarts persistent process with --continue
2026-02-04 19:15:46 +00:00
d878931e79 feat(01-03): add timing profiler for response latency debugging
Instruments the full message pipeline with [TIMING] log entries:
- Message age (Telegram delivery delay)
- Subprocess state (cold-start vs reused)
- Process spawn, first stdout, first assistant text
- Telegram send latency, total wall time

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 18:30:05 +00:00
2302b75e14 fix(01-02): read model/max_turns from persona settings object
Persona JSON nests model and max_turns under "settings" but the
subprocess was looking for them at the top level, so --model and
--max-turns were never passed to claude CLI.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 18:18:38 +00:00
3cc97adcd0 fix(01-03): don't treat SIGTERM as crash, fix async callbacks in crash handler
- Only auto-restart on positive exit codes (genuine crashes), not negative
  return codes (signals like SIGTERM from our own process management)
- Add iscoroutinefunction check for on_error in crash handler max-retry path

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 17:58:27 +00:00
3a62e01f6f feat(01-03): wire session manager and Claude subprocess into Telegram bot
- Add /new and /session commands to create and switch sessions
- Route plain text messages to active session's Claude subprocess
- Auto-spawn subprocess when switching to session with no process
- Update help text with session commands
- Handle async callbacks in ClaudeSubprocess (inspect.iscoroutinefunction)
- Preserve all existing bot commands (/status, /pbs, etc.)
- Use block=False for non-blocking message handling

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 17:40:43 +00:00
8fce10c5ba feat(01-02): create ClaudeSubprocess module for process management
- Spawns Claude Code CLI with stream-json output in session directories
- Reads stdout/stderr concurrently via asyncio.gather (no pipe deadlock)
- Handles process lifecycle with clean termination (no zombies)
- Queues messages during processing using asyncio.Queue
- Auto-restarts on crash with --continue flag (max 3 retries)
- Parses stream-json events (assistant, result, system) to callbacks
- Supports persona configuration (system_prompt, model, max_turns)
- Uses terminate() + wait_for() + kill() fallback pattern

Based on research: .planning/phases/01-session-process-foundation/01-RESEARCH.md
2026-02-04 17:33:49 +00:00