Synthetic transcripts

synthetic_user_event()

Builds a native ~cc_transcript.models.UserEvent from text or content blocks.

Usage

Source

synthetic_user_event(
    text="",
    *,
    blocks=(),
    uuid="synthetic",
    **meta,
)

Serializes a user envelope and parses it through the native backend, so the result is a real view accepted anywhere parsed events are — including ~cc_transcript.activity.SessionActivity.from_events(). Extra keywords forward to the envelope metadata (session_id, timestamp, …).

Example

>>> synthetic_user_event("fix the bug", session_id="s1").text

‘fix the bug’

Raises

ValueError
When the envelope does not parse to exactly one UserEvent.

synthetic_assistant_event()

Builds a native ~cc_transcript.models.AssistantEvent from text or content blocks.

Usage

Source

synthetic_assistant_event(text="", *, blocks=(), uuid="synthetic", **meta)

Serializes an assistant envelope and parses it through the native backend, so the result is a real view accepted anywhere parsed events are — including ~cc_transcript.activity.SessionActivity.from_events(). Extra keywords forward to the envelope metadata (session_id, timestamp, …) and message fields (stop_reason, usage, model).

Example

>>> synthetic_assistant_event("on it", stop_reason="end_turn").text

‘on it’

Raises

ValueError
When the envelope does not parse to exactly one AssistantEvent.

user_line()

A type: user envelope; blocks are message.content entries.

Usage

Source

user_line(
    uuid,
    text="",
    *,
    blocks=(),
    tool_use_result=None,
    tool_denial_kind=None,
    interrupted=False,
    **meta_kw
)

With blocks the content is a list — text (when non-empty) becomes a leading text block, exactly as a real transcript carries it. interrupted sets interruptedMessageId so the parser derives interrupted=True.

assistant_line()

An type: assistant envelope; blocks are message.content entries.

Usage

Source

assistant_line(
    uuid,
    text="",
    *,
    model="claude-opus-4-7",
    blocks=(),
    stop_reason=None,
    usage=None,
    **meta_kw
)

text_block()

A text content block carrying text.

Usage

Source

text_block(text)

thinking_block()

A thinking content block carrying thinking.

Usage

Source

thinking_block(thinking)

tool_use()

A tool_use content block invoking name with input under id id.

Usage

Source

tool_use(id, name, input)

tool_result()

A tool_result content block for tool_use_id; is_error marks a failed call.

Usage

Source

tool_result(tool_use_id, content="ok", *, is_error=False)

meta_fields()

The envelope-level fields the parser lifts into ~cc_transcript.models.EntryMeta.

Usage

Source

meta_fields(
    uuid,
    *,
    session_id="s",
    timestamp=BASE,
    secs=0,
    parent_uuid=None,
    cwd="/repo",
    git_branch="main",
    version="1.2.3",
    is_sidechain=False,
    is_meta=False,
    entrypoint="cli",
    is_compact_summary=False,
    is_visible_in_transcript_only=False,
    user_type=None,
    slug=None
)

Optional string fields are omitted when None so the parser’s .get chains reproduce a None attribute; booleans always serialize.

mode_line()

A mode/permission-mode envelope the parser lifts into ~cc_transcript.models.ModeEvent.

Usage

Source

mode_line(value, *, session_id="s", channel="mode")

system_line()

A type: system envelope; fields carry the subtype-specific detail keys.

Usage

Source

system_line(subtype, *, content=None, level=None, **fields)

other_line()

An unmodeled-type envelope lifted into ~cc_transcript.models.OtherEvent; raw is the line.

Usage

Source

other_line(type, **fields)