smah.runner

class smah.runner.Runner(args, settings)[source]

Bases: object

MAX_PIPE_LENGTH = 2048
PIPE_HEAD_LENGTH = 1024
static copy_to_clipboard(text: str) → bool[source]

Best-effort clipboard copy.

Returns False whenever the optional pyperclip dependency is unavailable or the copy fails; callers must treat clipboard as a nice-to-have only.

Parameters:

text (str) – The text to copy.

Returns:

True if the text was copied, False otherwise.

Return type:

bool

inference_model(task: str) → Model | None[source]
static log_mode(mode: str, level: int = 20, show: bool = False) → None[source]
static log_pipe_plan(plan: dict, level: int = 10, show: bool = False)[source]
static log_query_plan(plan: dict, level: int = 10, show: bool = False)[source]
pipe(query: str, pipe: str) → str | None[source]
pipe_plan(query: str, pipe: str) → Tuple[bool, dict] | None[source]
static planner_response(response: Completion) → Tuple[bool, dict] | None[source]
static print_message(message: dict, format: bool = False, strip_cot=True, styles: dict | None = None)[source]
provider_for(model: Model) → Provider[source]

Resolve the configured provider implementation for a model (exits 3 on unknown keys).

query(query: str) → str | None[source]
query_plan(query: str) → Tuple[bool, dict] | None[source]
static replace_exec_tags(content: str)[source]
resume(id: int, title: str, plan: dict, pipe: str, messages: list) → None[source]
run(model: Model, thread: list, response_format: dict | _Unset = UNSET, tools: dict | _Unset = UNSET, options: dict | None = None, show: bool = False) → Completion[source]
static show_suggested_commands(commands: list[dict]) → None[source]

Print suggested commands for the user to review and run themselves.

SMAH never executes commands; this presentation is print-only by design. Each command is rendered in a clearly delimited panel with the model’s title/purpose (its explanation of what the command does and its impact), the command itself in a copy-friendly code block, and an explicit notice that SMAH does not run commands.

Parameters:

commands (list[dict]) – Commands extracted from the model response (dicts with title/purpose/command/shell keys).

Modules

prompts

response_parser

runner