Module subagent_watcher

Module subagent_watcher 

Source
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 detected
  • subagent:activity — new events appended to a subagent file
  • subagent:completed — subagent finished (result event seen)

Structs§

JsonlMeta 🔒
Metadata extracted from the first JSONL line (the subagent init record).
SessionWatch 🔒
SubagentEvent
SubagentInfo
SubagentState 🔒
SubagentWatcher
WatchedAgent 🔒

Enums§

SubagentEventType
SubagentStatus

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 type field.
read_jsonl_from_offset 🔒
Read a JSONL file from a byte offset, parsing new subagent events. Returns (events, new_offset, optional_meta).