Skip to main content

Crate agent_commander

Crate agent_commander 

Source
Expand description

Agent Commander - Main library interface A Rust library to control agents enclosed in CLI commands

Supports multiple CLI agents:

  • claude: Anthropic Claude Code CLI
  • codex: OpenAI Codex CLI
  • opencode: OpenCode CLI
  • agent: @link-assistant/agent (OpenCode fork with native permission modes)
  • qwen: Qwen Code CLI
  • gemini: Gemini CLI

Re-exports§

pub use cli_parser::parse_args;
pub use cli_parser::parse_start_agent_args;
pub use cli_parser::parse_stop_agent_args;
pub use cli_parser::show_start_agent_help;
pub use cli_parser::show_stop_agent_help;
pub use cli_parser::validate_start_agent_options;
pub use cli_parser::validate_stop_agent_options;
pub use cli_parser::StartAgentOptions;
pub use cli_parser::StopAgentOptions;
pub use cli_parser::ValidationResult;
pub use command_builder::build_agent_command;
pub use command_builder::build_base_command;
pub use command_builder::build_docker_stop_command;
pub use command_builder::build_piped_command;
pub use command_builder::build_screen_stop_command;
pub use command_builder::read_only_unsupported_error;
pub use command_builder::supports_read_only;
pub use command_builder::AgentCommandOptions;
pub use permissions::ask_scope;
pub use permissions::ask_unsupported_error;
pub use permissions::build_permission_response;
pub use permissions::normalize_permission_request;
pub use permissions::permission_parity;
pub use permissions::supports_ask;
pub use permissions::NormalizedPermissionRequest;
pub use permissions::PermissionParityRow;
pub use permissions::PermissionRelay;
pub use permissions::ASK_DECISIONS;
pub use permissions::ASK_SUPPORTED_TOOLS;
pub use executor::execute_command;
pub use executor::execute_detached;
pub use executor::execute_detached_with_env;
pub use executor::is_process_group_alive;
pub use executor::normalize_exit;
pub use executor::setup_signal_handler;
pub use executor::signal_from_exit_code;
pub use executor::signal_name;
pub use executor::start_command;
pub use executor::start_command_with_env;
pub use executor::start_command_with_stdin;
pub use executor::ExecutionResult;
pub use executor::ProcessHandle;
pub use executor::DEFAULT_KILL_AFTER;
pub use executor::DEFAULT_PIPE_DRAIN;
pub use background_tasks::assess_background_tasks;
pub use background_tasks::extract_observed_models;
pub use background_tasks::is_real_model_id;
pub use background_tasks::print_wait_ceiling_seconds;
pub use background_tasks::track_background_tasks;
pub use background_tasks::BackgroundTask;
pub use background_tasks::BackgroundTaskAssessment;
pub use background_tasks::BackgroundTaskState;
pub use background_tasks::StoppedBackgroundTask;
pub use background_tasks::PRINT_BG_CEILING_PATTERN;
pub use result_close::has_final_result;
pub use result_close::wait_for_exit_after_result;
pub use result_close::ResultCloseOptions;
pub use result_close::StdoutMessageReader;
pub use result_close::DEFAULT_RESULT_POLL;
pub use codex_rollout::apply_codex_rollout_context_usage;
pub use codex_rollout::apply_codex_rollout_usage_limit;
pub use codex_rollout::apply_codex_rollout_usage_windows;
pub use codex_rollout::can_resume_codex_session;
pub use codex_rollout::classify_codex_rate_limit_snapshot;
pub use codex_rollout::codex_rollout_context_usage;
pub use codex_rollout::codex_rollout_limit_facts;
pub use codex_rollout::codex_sessions_dir;
pub use codex_rollout::detect_codex_rollout_usage_limit;
pub use codex_rollout::find_codex_rollout_file;
pub use codex_rollout::is_codex_rollout_file_name;
pub use codex_rollout::read_codex_rollout_limit_facts;
pub use codex_rollout::CodexLimitVerdict;
pub use codex_rollout::CodexRolloutLimitFacts;
pub use codex_rollout::CodexRolloutOptions;
pub use codex_rollout::CODEX_ROLLOUT_LIMIT_SOURCE;
pub use codex_rollout::CODEX_SESSIONS_DIRNAME;
pub use codex_rollout::ROLLOUT_TAIL_BYTES;
pub use claude_transcript::apply_claude_transcript_usage_limit;
pub use claude_transcript::claude_project_slugs;
pub use claude_transcript::claude_transcript_api_error;
pub use claude_transcript::claude_transcript_candidates;
pub use claude_transcript::read_claude_transcript_api_error;
pub use claude_transcript::ClaudeTranscriptApiError;
pub use claude_transcript::ClaudeTranscriptOptions;
pub use claude_transcript::CLAUDE_TRANSCRIPT_LIMIT_SOURCE;
pub use claude_transcript::TRANSCRIPT_TAIL_BYTES;
pub use context_usage::claude_request_context_tokens;
pub use context_usage::context_reading_from_message;
pub use context_usage::extract_context_usage;
pub use context_usage::ContextReading;
pub use context_usage::ContextUsage;
pub use file_tail::read_file_tail;
pub use live_input::build_interrupt_frame;
pub use live_input::build_user_input_frame;
pub use live_input::live_input_unsupported_error;
pub use live_input::supports_live_input;
pub use result_metadata::build_normalized_result_metadata;
pub use result_metadata::BuildMetadataOptions;
pub use result_metadata::PricingInfo;
pub use result_metadata::ResultMetadata;
pub use error_text::first_error_text;
pub use error_text::stringify_error_value;
pub use error_text::MAX_ERROR_TEXT_LENGTH;
pub use usage_limit::classify_debug_lines;
pub use usage_limit::classify_rate_limit_event;
pub use usage_limit::detect_usage_limit_sources;
pub use usage_limit::extract_reset_time;
pub use usage_limit::extract_timezone;
pub use usage_limit::format_epoch_reset_time_utc;
pub use usage_limit::is_recoverable_tool_error;
pub use usage_limit::is_usage_limit_text;
pub use usage_limit::limit_scan_text;
pub use usage_limit::DebugLines;
pub use usage_limit::UsageLimitVerdict;
pub use structured_output::extract_structured_output;
pub use streaming::create_input_stream;
pub use streaming::create_output_stream;
pub use streaming::parse_json_records;
pub use streaming::parse_ndjson;
pub use streaming::parse_ndjson_line;
pub use streaming::stringify_ndjson;
pub use streaming::stringify_ndjson_line;
pub use streaming::JsonInputStream;
pub use streaming::JsonOutputStream;
pub use streaming::JsonRecordEvent;
pub use streaming::JsonRecordScanner;
pub use streaming::ParseError;
pub use tools::get_tool;
pub use tools::is_tool_supported;
pub use tools::list_tools;
pub use tools::AgentTool;
pub use tools::ClaudeTool;
pub use tools::CodexTool;
pub use tools::OpencodeTool;
pub use tools::Tool;
pub use tools::ToolRegistry;
pub use usage_windows::claude_rate_limit_windows;
pub use usage_windows::codex_rate_limit_windows;
pub use usage_windows::extract_usage_windows;
pub use usage_windows::merge_usage_windows;
pub use usage_windows::usage_windows_from_message;
pub use usage_windows::UsageWindow;
pub use usage_windows::USAGE_WINDOW_KINDS;
pub use tool_overrides::BuildCommandFn;
pub use tool_overrides::ExtractSessionIdFn;
pub use tool_overrides::ExtractUsageFn;
pub use tool_overrides::ParseOutputFn;
pub use tool_overrides::ToolOverrides;
pub use tool_version::build_version_command;
pub use tool_version::compare_versions;
pub use tool_version::get_tool_version;
pub use tool_version::parse_tool_version;
pub use tool_version::tool_version_from_output;
pub use tool_version::ToolVersion;
pub use tools::launch_options::check_launch_options_against;
pub use tools::launch_options::check_launch_options_supported;
pub use tools::launch_options::codex_mcp_servers_override;
pub use tools::launch_options::json_schema_arg;
pub use tools::launch_options::launch_capabilities;
pub use tools::launch_options::normalize_reasoning_effort;
pub use tools::launch_options::push_attachments;
pub use tools::launch_options::push_directories;
pub use tools::launch_options::to_toml_value;
pub use tools::launch_options::LaunchCapabilities;
pub use tools::launch_options::LaunchOptions;
pub use tools::launch_options::CLAUDE_REASONING_EFFORTS;
pub use tools::launch_options::CODEX_REASONING_EFFORTS;

Modules§

background_tasks
Claude Code background tasks and print-mode turns (hive-mind#2301, #3015).
claude_transcript
Claude Code session transcripts (hive-mind#3570).
cli_parser
Parse CLI arguments Simple argument parser without external dependencies
codex_rollout
Codex rollouts (hive-mind#2888, #3570).
command_builder
Build command strings for different agent tools
context_usage
Context-window usage of a run (issue #57).
error_text
Human-readable rendering of structured error payloads
executor
Execute commands while continuously draining both process pipes.
file_tail
Bounded reads of append-only session files (Codex rollouts, Claude transcripts).
live_input
Live input for a running agent (issue #57).
permissions
Permission normalization and relay for the uniform per-command approval (“ask”) mode.
result_close
Close a process that lingers after its final result (hive-mind#1280, #3015).
result_metadata
Normalized result metadata for tool-specific agent output.
streaming
JSON Streaming utilities Support for NDJSON (Newline Delimited JSON) input and output
structured_output
Structured output: the final answer shaped by the json_schema launch option (issue #57).
tool_overrides
Per-run tool overrides (issue #57).
tool_version
Probe the installed CLI version of a tool (issue #57).
tools
Tool configurations and utilities Provides configuration for different CLI agents: claude, codex, opencode, agent, gemini, qwen
tui
Interactive terminal launch and capture for supported agent clients.
usage_limit
Usage-limit detection shared by every tool’s result metadata
usage_windows
Normalized usage windows (issue #57).

Structs§

Agent
Agent controller
AgentOptions
Agent options for creating a controller
AgentResult
Agent result from stop()
AgentStartOptions
Agent start options
AgentStopOptions
Agent stop options

Enums§

InheritEnv
Which variables of the host environment a tool inherits (issue #60)

Functions§

agent
Create an agent controller (convenience function)
build_child_environment
Build the child environment passed to spawn.
escape_arg
Shell quoting for ToolOverrides::build_command implementations Escape an argument for shell usage.
file_content_arg
Render flag "$(cat file)": the value reaches the tool as one argument, but the shell command line only holds the file path (issue #60).