UNPKG

eve

Version:

Filesystem-first framework for durable backend AI agents that run anywhere.

1 lines 2.25 kB
import{isObject}from"#shared/guards.js";import{jsonSchema}from"ai";import{WEB_SEARCH_ANTHROPIC_OUTPUT_SCHEMA,WEB_SEARCH_GATEWAY_OUTPUT_SCHEMA,WEB_SEARCH_GOOGLE_OUTPUT_SCHEMA,WEB_SEARCH_OPENAI_OUTPUT_SCHEMA,WEB_SEARCH_TOOL_DEFINITION}from"#runtime/framework-tools/web-search.js";const UPSTREAM_TOOL_TYPE_TO_FRAMEWORK_NAME={web_search_20250305:WEB_SEARCH_TOOL_DEFINITION.name};function resolveFrameworkToolFromUpstreamType(e){return UPSTREAM_TOOL_TYPE_TO_FRAMEWORK_NAME[e]??null}function resolveGatewayPinForWebSearchBackend(e){switch(e){case`anthropic`:return`anthropic`;case`openai`:return`openai`;case`google`:return`google`;case`gateway`:return null}}function resolveWebSearchOutputSchema(e){switch(e){case`anthropic`:return WEB_SEARCH_ANTHROPIC_OUTPUT_SCHEMA;case`gateway`:return WEB_SEARCH_GATEWAY_OUTPUT_SCHEMA;case`google`:return WEB_SEARCH_GOOGLE_OUTPUT_SCHEMA;case`openai`:return WEB_SEARCH_OPENAI_OUTPUT_SCHEMA}}function mergeGatewayProviderPin(t,n){let r=isObject(t?.gateway)?t.gateway:void 0;if(r?.only!==void 0||r?.order!==void 0)return{...t};let i={...r,only:[n]};return{...t,gateway:i}}function resolveWebSearchBackend(e){let t=e.id.split(`/`)[0]??``;return t===`openai`||t.startsWith(`openai.`)?`openai`:t===`anthropic`||t.startsWith(`anthropic.`)?`anthropic`:t.startsWith(`google.`)?`google`:e.source===void 0?`gateway`:null}async function resolveWebSearchProviderTool(e){switch(e){case`openai`:{let{openai:t}=await import(`#compiled/@ai-sdk/openai/index.js`);return attachWebSearchOutputSchema(t.tools.webSearch({}),e)}case`anthropic`:{let{anthropic:t}=await import(`#compiled/@ai-sdk/anthropic/index.js`);return attachWebSearchOutputSchema(t.tools.webSearch_20250305(),e)}case`google`:{let{google:t}=await import(`#compiled/@ai-sdk/google/index.js`);return attachWebSearchOutputSchema(t.tools.googleSearch({}),e)}case`gateway`:{let{gateway:t}=await import(`ai`);return attachWebSearchOutputSchema(t.tools.perplexitySearch(),e)}}}function attachWebSearchOutputSchema(e,n){return{...e,outputSchema:jsonSchema(resolveWebSearchOutputSchema(n))}}export{mergeGatewayProviderPin,resolveFrameworkToolFromUpstreamType,resolveGatewayPinForWebSearchBackend,resolveWebSearchBackend,resolveWebSearchOutputSchema,resolveWebSearchProviderTool};