fix: tighten tool answers found in local testing

Unknown aircraft tracks read as empty instead of a server error, aircraft
info names the aircraft and flight, the HUD caption sends the app's caption
context, and satellite pass, satellites overhead and nearby places take a
place name or point like the other tools.
This commit is contained in:
Sameh Khamis committed 2026-10-01 14:01:25 -07:00
1 parent 1a03e7483d
commit ec1adbdc19
9 files changed
+119 -64

No files matched your search

+29 -2
View File
@@ -25,6 +25,7 @@ const AWARENESS_RADIUS_KM = 250;
const SECTIONS = [
{
key: 'weather',
label: 'Weather',
tool: getWeather,
args: (area, center) => ({
location: { lat: center.lat, lon: center.lon },
@@ -32,26 +33,31 @@ const SECTIONS = [
},
{
key: 'earthquakes',
label: 'Earthquakes',
tool: getEarthquakes,
args: (area) => ({ area: area.argument, limit: SECTION_LIMIT }),
},
{
key: 'fires',
label: 'Active fires',
tool: getActiveFires,
args: (area) => ({ area: area.argument, limit: SECTION_LIMIT }),
},
{
key: 'aircraft',
label: 'Aircraft',
tool: aircraftInArea,
args: (area) => ({ area: area.argument, limit: SECTION_LIMIT }),
},
{
key: 'vessels',
label: 'Ships',
tool: vesselsInArea,
args: (area) => ({ area: area.argument, limit: SECTION_LIMIT }),
},
{
key: 'cyclones',
label: 'Tropical cyclones',
tool: getCyclones,
args: (area) => ({ area: area.argument }),
},
@@ -181,9 +187,30 @@ export const getHudCaption = defineTool({
},
requires: ['weather', 'summary'],
async run(args, context) {
const { area, center, lines } = await buildBrief(args, context);
const { area, center, brief, lines } = await buildBrief(args, context);
// The app's caption context: place labels and the layers that answered,
// with their feed state.
const answered = SECTIONS.filter(
({ key }) => brief[key] && !brief[key].unavailable,
);
const layers = answered.map(({ key, label }) => ({
id: key,
name: label,
feedState: 'nominal',
}));
const response = await context.services.summary.summarize(
{ location: area.label, center, observations: lines },
{
placeLabels: [area.label],
location: area.label,
center,
observations: lines,
enabledLayerLabels: layers.map((layer) => layer.name),
enabledLayers: layers,
feedProvenance: {
overall: layers.length ? 'nominal' : null,
layers,
},
},
{ signal: context.signal },
);
const caption = response?.data?.summary;