/* 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" #include "sqlite3.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, OpenRouter and Gemini 3 and later (Google Search grounding, which * shares a request with function tools only from Gemini 3; earlier Geminis get 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); /* The messages of an Anthropic request with the search of earlier replies turned into what a request * that declares no provider search may carry (malloc'd); NULL when they hold none. */ char *pic_websearch_demote(sqlite3 *db, const char *json); #endif