Sets process-level defaults for clients created through AutohandSDK.client or AutohandSDK.agent.
AutohandSDK.configure do |config|
config.cli_path = "/usr/local/bin/autohand"
config.env_vars = { "AUTOHAND_NO_BANNER" => "1" }
endLow-level session API around the CLI subprocess.
Starts a client, yields it, and closes it.
Start and stop the CLI subprocess.
Sends a prompt and returns an Enumerator of event hashes.
sdk.stream_prompt("Review lib/autohand_sdk/client.rb").each do |event|
puts event.inspect
endSends a prompt and returns the raw RPC result. Use stream_prompt for live output.
Aborts the current operation.
Responds to a permission request event.
sdk.permission_response(request_id: event["request_id"], decision: "allow_once")Convenience helpers:
#allow_permission(request_id, scope: :once)#deny_permission(request_id, scope: :once)#suggest_permission_alternative(request_id, alternative)
Scopes are :once, :session, :project, and :user.
#set_permission_mode(mode)#set_plan_mode(enabled)#enable_plan_mode#disable_plan_mode#set_model(model)#set_max_thinking_tokens(value)#apply_flag_settings(settings)
#get_state(include_context: nil)#get_messages(limit: nil, before: nil)#supported_models#supported_commands#get_context_usage#account_info
#reconnect_mcp_server(server_name)#toggle_mcp_server(server_name, enabled)#set_mcp_servers(servers)#get_hooks#add_hook(hook)#remove_hook(event, index)#toggle_hook(event, index)#test_hook(hook)#set_hooks_settings(settings)
High-level run lifecycle API.
Creates and starts an agent.
Returns an AutohandSDK::Run without waiting.
Runs to completion and returns:
{
id: "run_...",
status: "completed",
text: "...",
events: [...]
}Adds JSON-only instructions, waits for the run, parses the final response, and optionally validates it.
Streams a run directly.
#streamreturns an event enumerator.#waitreturns the final result hash.#json(validate: nil)parses the final text as JSON.#abortaborts the active run.
Installs and locates the Autohand Code CLI used by the SDK.
Downloads or copies the current platform CLI into ~/.autohand/bin by default and returns an InstallResult.
result = AutohandSDK::CLIInstaller.install!(force: true)
puts result.pathReturns the CLI executable path or raises AutohandSDK::ConfigurationError with an installation hint.
The command-line wrapper exposes the same behavior:
bundle exec autohand-sdk install-cli
bundle exec autohand-sdk cli-path
bundle exec autohand-sdk doctor