Tool renderers for approval widgets - registry pattern.
Split a unified diff back into the lines it was assembled from.
Deliberately not splitlines(). Every diff reaching this function is
"\n"-joined from lines that themselves came from splitlines() or
split("\n"), so no element can contain a line boundary and "\n" is the
exact inverse. splitlines() also breaks on \r, \v, \f, U+2028,
U+2029 and U+0085, which splits a single diff line into fragments. The tail
fragment carries no +/- marker, so it would render as an unmarked note —
on the approval prompt that means changed content shown as neutral metadata.
Check any new producer against that invariant rather than against a list of the current ones.
Collect summary info and diff for HITL approvals.
Format a path for display.
Return whether a path points at a credential/secret file.
Best-effort, filename-based, case-insensitive heuristic. It matches .env
and its variants (e.g. .env.local), well-known credential filenames, and
private-key/keystore suffixes, and is used to suppress diff/content
rendering for those files so their contents are not shown in the terminal
UI or scrollback. It classifies by name only, not content, so
secret-bearing files with unrecognized names still render.
Coerce arbitrary tool-arg content into a displayable string.
Strings pass through unchanged; other values are JSON-formatted for
readability, falling back to str() when serialization fails.
Get the renderer for a tool by name.
Approval widget for edit_file - shows clean diff with colors.
Generic approval widget for unknown tools.
Approval widget for write_file - shows file content with syntax highlighting.
Base class for tool approval widgets.
Strategy for building a tool's HITL approval widget.
Each renderer maps a tool name to a (widget_class, data) pair that
controls what the user sees in the approval box. Tools not registered
in _RENDERER_REGISTRY fall through to the default, which dumps all
args as key: value lines via GenericApprovalWidget.
Renderer for write_file tool - shows full file content.
Renderer for task tool — interrupt description provides full context.
Renderer for delete tool - shows removed file content when available.
Renderer for edit_file tool - shows unified diff.