feat: add place search and routing tools

Add search_places and places_nearby over the app's Google Places routes,
and plan_route over its OpenStreetMap routing. The place search service
reports when no search key is configured, so an unconfigured server is
not mistaken for an empty result, and rate limits become retry_later.
Route endpoints accept a place name or coordinates.
This commit is contained in:
Sameh Khamis committed 2026-10-01 12:16:01 -07:00
1 parent 85fee59da1
commit e680a59bf5
14 files changed
+596 -23

No files matched your search

+8 -12
View File
@@ -8,7 +8,13 @@ import {
distanceKm,
resolveArea,
} from '../area.js';
import { LIMIT_SCHEMA, capRows, countNoun, isoTime } from '../results.js';
import {
LIMIT_SCHEMA,
capRows,
countNoun,
isoTime,
thinEvenly,
} from '../results.js';
const ICAO24_SCHEMA = Object.freeze({
type: 'string',
@@ -200,7 +206,7 @@ export const getAircraftTrack = defineTool({
const points = [...track.records].sort(
(a, b) => a.observedAtMs - b.observedAtMs,
);
const kept = thin(points, MAX_TRACK_POINTS);
const kept = thinEvenly(points, MAX_TRACK_POINTS);
const first = points[0];
const last = points.at(-1);
return {
@@ -224,16 +230,6 @@ export const getAircraftTrack = defineTool({
},
});
/** Keep the first and last items and evenly spaced items between them. */
function thin(items, max) {
if (items.length <= max) return items;
const step = (items.length - 1) / (max - 1);
return Array.from(
{ length: max },
(_, index) => items[Math.round(index * step)],
);
}
export const getAircraftInfo = defineTool({
name: 'get_aircraft_info',
title: 'Aircraft type and route',