import { createActionTools } from '../../../src/voice/actionSchemas.js'; import { ACTION_DESCRIPTIONS } from './toolDescriptions.js'; /** Every voice tool, as the Realtime session describes them. */ export const GEV_REALTIME_TOOLS = createActionTools(ACTION_DESCRIPTIONS); /** * The session's tools: the app actions, then additional function tools * whose names no action already uses. */ export function realtimeSessionTools(additional = []) { const names = new Set(GEV_REALTIME_TOOLS.map((tool) => tool.name)); return [ ...GEV_REALTIME_TOOLS, ...additional.filter((tool) => !names.has(tool.name)), ]; } /** Tools that need an operator-configured Overpass (OVERPASS_UPSTREAMS). */ export const OVERPASS_ONLY_TOOLS = Object.freeze(['osm_query']); /** * The tools one session is offered. Bulk OpenStreetMap place search runs * only on an operator's Overpass, so without one `osm_query` is left out * rather than offered and refused. * @param {Array<{name: string}>} tools * @param {{overpass?: boolean}} [options] */ export function offeredTools(tools, { overpass = false } = {}) { return overpass ? tools : tools.filter((tool) => !OVERPASS_ONLY_TOOLS.includes(tool.name)); } /** * The app actions one session is offered. * @param {{overpass?: boolean}} [options] */ export function realtimeTools({ overpass = false } = {}) { return offeredTools(GEV_REALTIME_TOOLS, { overpass }); }