types
types ¶
InlineTests ¶
Inline test specification mapping inputs to expected outcomes.
A mapping whose keys are Input descriptors (or legacy str session
keys) and whose values are the expected hook result — Block, Warn,
or Allow.
Keys
Input: Structured test-input descriptor specifying tool, command, file,
content, and/or transcript context.
str: Legacy session-key format — replayed from a recorded session
during run_inline_tests when a fixture exists, else skipped.
Values
Block: The hook must block, optionally matching a regex pattern.
Warn: The hook must warn, optionally matching a regex pattern.
Allow: The hook must allow (return None or action "allow").
Example::
tests: InlineTests = {
Input(command="rm -rf /"): Block(pattern="dangerous"),
Input(command="ls"): Allow(),
}
TranscriptFixture ¶
A lightweight transcript stub for use in inline tests.
Wraps a list of raw message dicts that get parsed into a Transcript
when the test runs.
Block
dataclass
¶
Inline test expectation: the hook should block. Optional regex pattern matches the block message.
Warn
dataclass
¶
Inline test expectation: the hook should warn. Optional regex pattern matches the warning message.
Allow
dataclass
¶
Inline test expectation: the hook should allow (return None or action "allow").
Input
dataclass
¶
Input(
*,
command: str | None = None,
file: str | None = None,
content: str | None = None,
old: str | None = None,
tool: str | None = None,
prompt: str | None = None,
agent_type: str | None = None,
permission_mode: str | None = None,
transcript: Path
| TranscriptFixture
| list[dict[str, Any]]
| None = None,
)
Inline test input descriptor modeling an event payload. Set fields based on the target event type.