This commit deletes the complete implementation of the agent loop, authentication module, web browsing utilities, chat prompt builder, database helper, and HTTP client. All corresponding header files and test harnesses are also removed. The diff shows the deletion of 6 source files and 6 header files totaling over 1000 lines of code, including the agent state machine, API key resolution logic, curl-based HTTP functions, SQLite database initialization and CRUD operations, and the JSON chat prompt construction.
Implement pthread-based parallel execution in tool_registry_execute to run tool calls concurrently, replacing the previous sequential loop. Add tool_thread_args_t struct and tool_thread_func wrapper for thread-safe execution. Introduce MAX_PARALLEL_PROBES constant and probe_t struct in network_port_scan_execute to enable concurrent socket probing with non-blocking connect patterns, replacing the single-threaded sequential port scan loop.
Implement context manager integration that detects API errors indicating context length exceeded, then automatically shrinks message history and retries the request. Add new messages API functions (remove_range, get_object, replace_at) and a new R_ERROR_CONTEXT_TOO_LONG error code to support this functionality.