Skip to content

helpers

helpers

raw_text_block

raw_text_block(text: str) -> dict[str, Any]

A raw text content-block dict.

raw_tool_use

raw_tool_use(
    name: str,
    input: dict[str, Any] | None = None,
    id: str = "tu_x",
    **extra: Any,
) -> dict[str, Any]

A raw tool_use content-block dict.

raw_tool_result_block

raw_tool_result_block(
    tool_use_id: str = "tu_x",
    content: list[Any] | str = "ok",
    is_error: bool = False,
) -> dict[str, Any]

A raw tool_result content-block dict.

raw_msg

raw_msg(
    role: str,
    content: list[dict[str, Any]] | str = "",
    **raw: Any,
) -> dict[str, Any]

A raw transcript line wrapping content (a block list or plain text) under message.

raw_text

raw_text(role: str, text: str) -> dict[str, Any]

A raw transcript line carrying a single text block.

raw_assistant

raw_assistant(*blocks: dict[str, Any]) -> dict[str, Any]

A raw assistant line wrapping the given content blocks (e.g. raw_tool_use(...)).

raw_tool_msg

raw_tool_msg(
    name: str,
    input: dict[str, Any] | None = None,
    id: str = "tu_x",
    **extra: Any,
) -> dict[str, Any]

A raw assistant line carrying a single tool_use block (the common single-tool case).

raw_tool_result

raw_tool_result(
    tool_use_id: str = "tu_x",
    content: list[Any] | str = "ok",
    tool_use_result: dict[str, Any] | None = None,
    is_error: bool = False,
) -> dict[str, Any]

A raw user line carrying one tool_result block, with optional top-level toolUseResult.

raw_notification

raw_notification(
    tool_use_id: str,
    task_id: str = "task-1",
    status: str = "completed",
    **extra: Any,
) -> dict[str, Any]

A raw queue-operation line carrying a <task-notification> for tool_use_id.

async_agent_launch

async_agent_launch(
    id: str = "tu_x", input: dict[str, Any] | None = None
) -> list[dict[str, Any]]

A two-line async Agent launch: tool_use + tool_result with isAsync toolUseResult.

workflow_launch

workflow_launch(id: str = 'tu_x') -> list[dict[str, Any]]

A two-line Workflow launch: tool_use + tool_result whose toolUseResult has no isAsync.

make_transcript

make_transcript(
    *messages: dict[str, Any] | list[dict[str, Any]],
) -> Transcript

Build a Transcript from raw message dicts, given either as varargs or a single list.

waiting_evt

waiting_evt(
    raw_messages: list[dict[str, Any]],
) -> PreToolUseEvent

A Bash echo PreToolUse event over the given raw transcript, ready for check_condition.

assistant_msg

assistant_msg(
    *tools: tuple[str, dict[str, Any]],
) -> TranscriptMessage

An assistant TranscriptMessage whose content is a ToolUseBlock per (name, input) tuple.

text_msg

text_msg(text: str = 'done') -> TranscriptMessage

An assistant TranscriptMessage carrying a single text block.

tool_result_msg

tool_result_msg(
    tool_use_id: str, text: str
) -> TranscriptMessage

A user TranscriptMessage carrying a single tool_result block.