Expand description
Live Claude Code session id helpers.
task-journal already parses session ids out of Claude Code
transcripts (session::parser) — that is a passive, read-only
lookup of someone else’s identifier. This module is the other
direction: additively stamping the live session id onto the events
the journal itself emits (hooks + MCP tools), so downstream
consumers can correlate those events with the originating session
without time-window heuristics.
Source order: hook payload field session_id → CLAUDE_CODE_SESSION_ID
env var → None. None means standalone behaviour is unchanged —
nothing is added to meta.
Functions§
- live_
session_ id - Resolve the live session id: hook payload first, env var as fallback.
Nonewhen neither source provides one (standalone — caller adds nothing). - session_
id_ from_ env - Read
CLAUDE_CODE_SESSION_IDfrom the environment. Empty counts as absent. - session_
id_ from_ payload - Pull
session_idout of a Claude Code hook payload (or a pending-v2 chunk, which carries the same field). Empty strings count as absent. - stamp_
session_ id - Additively record
session_idinto a free-formmetavalue.