Expand description
Subagent watcher: monitors Claude Code session directories for subagent JSONL files and broadcasts activity events to WebSocket clients.
Claude Code spawns “subagents” via the Task tool. Each subagent writes its
conversation to a JSONL file under:
<claude-config>/projects/<encoded-workspace>/subagents/agent-<id>.jsonl
This module watches those directories and emits:
subagent:spawned— new subagent JSONL file detectedsubagent:activity— new events appended to a subagent filesubagent:completed— subagent finished (result event seen)
Structs§
- Jsonl
Meta 🔒 - Metadata extracted from the first JSONL line (the subagent init record).
- Session
Watch 🔒 - Subagent
Event - Subagent
Info - Subagent
State 🔒 - Subagent
Watcher - Watched
Agent 🔒
Enums§
Functions§
- derive_
claude_ config_ dir - Derive the Claude Code config directory for a host agent.
- encode_
workspace_ path - Encode a workspace path the same way Claude Code does for its projects dir.
- now_
millis 🔒 - parse_
event_ 🔒type - Parse a JSONL line into a SubagentEventType based on the
typefield. - read_
jsonl_ 🔒from_ offset - Read a JSONL file from a byte offset, parsing new subagent events. Returns (events, new_offset, optional_meta).