/* The provider's own web search (websearch_native.c): when the model's provider runs searches * itself, a request declares that server tool where the session's web_search function would be, * and the search happens on the provider's side, billed per search to the user's account there. * The model sees one tool name, web_search, either way; pic's function (Brave, websearch.c) is * what it gets when the provider has none or this conversation may not use it. */ #ifndef PIC_WEBSEARCH_NATIVE_H #define PIC_WEBSEARCH_NATIVE_H #include #include #include "pic.h" /* For a request of model M in SUBMISSION's conversation, with TOOLS the session's tools (a JSON * array of {name,description,input_schema}): when the provider's own search applies, TOOLS * without the web_search function (malloc'd) and *NATIVE the server tool's declaration in the * wire shape (malloc'd); else NULL and *NATIVE NULL, and the request goes as it was. * * It applies when TOOLS holds web_search (so --exclude-tools turns it off), the setting webSearch * is auto, offline is off, the conversation's permission mode is allow or ask-edits (pic cannot * ask before a call the provider makes, so the modes that ask or refuse changes get the function, * which pic gates), and the provider has a search that M and its sign-in can use: Anthropic, * OpenAI with an API key, xAI and OpenRouter. (Gemini is not among them: its search shares a request * with function tools only from Gemini 3, with server-side tool parts that must be passed back, * which the Gemini decoder does not keep; it gets the function.) */ char *pic_websearch_native(pic_store *s, int64_t submission, const pic_model *m, const char *tools, char **native); /* TOOLS with NATIVE put first in the array (malloc'd): for a wire whose tools are the neutral shape. */ char *pic_websearch_prepend(const char *tools, const char *native); /* Whether some provider with its own search has a credential here: web_search is offered then * even with no Brave key. */ int pic_websearch_native_possible(void); #endif