Skip to main content

Module formal_ai_client

Module formal_ai_client 

Source
Expand description

Minimal client of the OpenAI-compatible agent-mode endpoint of Formal AI (POST /api/openai/v1/chat/completions), used by --use-formal-ai (issue #255). Mirrors js/src/lib/formal-ai-client.js. Only the bash function tool is offered: Formal AI picks the command, start decides whether and how it runs.

The runtime is always a loopback http:// server, so a small blocking HTTP/1.1 client over std::net is enough; it polls for cancellation and the time budget while it waits.

Structs§

ClientError
A failed exchange with Formal AI and the exit status it maps to.
Completion
One chat completion, normalized for the task loop.
HttpClient
Client bound to one runtime over HTTP.
ToolCall
One tool call Formal AI asked for.

Enums§

HttpError
Why an HTTP exchange failed.

Constants§

API_PREFIX
TOOL_NAMES

Traits§

CompletionClient
Something that answers chat completions (HTTP, or a replay in tests).

Functions§

bash_tool
The only tool offered to Formal AI.
http_request
One blocking HTTP/1.1 exchange with Connection: close.
parse_completion
Normalize one chat completion into what the loop needs.
parse_http_url
Host, port and path prefix of an http://host:port/prefix URL.