/* 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 <stddef.h>
#include <stdint.h>
#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, OpenRouter, and Gemini 3 and later. */
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);
/* Removes from the JSON text J (in place) what could steer a terminal when shown: the escapes
* \u0000-\u001f (but not the ones for newline and tab, which have their short forms), \u007f and
* \u0080-\u009f, and the raw bytes DEL and C1 as UTF-8. For the text a provider's search brings
* from the open web. */
void pic_json_strip_controls(char *j);
#endif