Splinter can now talk to a real endpoint: --endpoint plus --model shapes the whole conversation into one chat/completions request and parses the reply back. The seam changed from a raw string to the conversation, because a provider adapter cannot invent history and the loop must not depend on vendor JSON: - sp_conv: owned messages (role, name, call_id, content, raw tool_calls), geometric growth, trim from the front. Copy on push, so a compaction step must produce a new array - which is what makes it reviewable. - sp_openai_request(): conversation + tool table -> JSON body. - sp_openai_reply(): choices[0].message -> content + calls, and it keeps the provider's raw tool_calls array to hand back verbatim next round. - provider error objects, empty choice lists, non-JSON bodies and empty bodies each produce a distinct, quoted error instead of a silent empty answer. - transport_openai: curl, body through a temp file, status from curl's -w, key from the environment only. - libmcp's JSON parser is vendored and instantiated exactly once (src/json.c); two instantiations would be a link error rather than a silent duplicate. Proven end to end against a local stub speaking the real wire format: request 1 (1 message, 2 tools, 448 bytes) -> tool_call for echo; splinter ran the tool, request 2 (3 messages, 682 bytes) -> final text; the session log holds user, observation, assistant. Nine test binaries green, including test_openai (request shape, tool_call parsing, raw array kept, four failing reply shapes) and test_conv.
16 KiB
Executable File
16 KiB
Executable File