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. It offers the
bash tool and the structured read tool, plus edit and write when
workspace changes are allowed (issue #258): Formal AI picks the call, start
decides whether and how it runs.
An HTTP error keeps a bounded, sanitized excerpt of its body (the error type, message and a preview) and the attempt count, so a failing runtime names its cause (issue #257).
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§
- Client
Error - A failed exchange with Formal AI and the exit status it maps to.
- Completion
- One chat completion, normalized for the task loop.
- Http
Client - Client bound to one runtime over HTTP.
- Tool
Call - One tool call Formal AI asked for.
Enums§
- Http
Error - Why an HTTP exchange failed.
Constants§
- API_
PREFIX - BASH_
NAMES - Names Formal AI may use for the bash tool.
- GAP_
SCHEMAS - Known structured gaps Formal AI answers instead of claiming success.
- TOOL_
NAMES - Every tool name start accepts.
Traits§
- Completion
Client - Something that answers chat completions (HTTP, or a replay in tests).
Functions§
- bash_
tool - The bash tool offered to Formal AI.
- http_
error_ details - Structured diagnostics of an HTTP error response: httpStatus, errorType, errorMessage, bodyPreview and bodyChars (same keys as JavaScript).
- http_
error_ message Formal AI returned HTTP <status>: [<type>: ]<message or preview>.- http_
request - One blocking HTTP/1.1 exchange with
Connection: close. - offered_
tools - Tools offered to Formal AI: the change tools only when the effect mode allows changes, so the advertised contract matches the policy.
- parse_
completion - Normalize one chat completion into what the loop needs.
- parse_
http_ url - Host, port and path prefix of an
http://host:port/prefixURL. - recognize_
capability_ gap - Recognize a final answer that is exactly a known Formal AI capability gap: {schema, target, reason, missingCapabilities, complete, verified}. Only the runtime’s own answer counts: text that a tool result in this run contained (file data echoed back) is never taken as a gap.
- sanitize_
diagnostic - One line of untrusted diagnostic text, bounded and without credentials: known secrets, authorization headers, bearer or basic credentials and credential-named fields are masked, and control characters become spaces.