feat: add weather map and wind tools

Add get_weather_map, which returns the latest NOAA radar, satellite or
lightning map over an area as an image, choosing a window the image
route accepts and reporting areas outside the product's coverage, and
get_wind, which samples GFS or IFS wind at a location with the wind
layer's own grid sampling.
This commit is contained in:
Sameh Khamis committed 2026-10-01 13:22:16 -07:00
1 parent c43c94ba5f
commit a3aa058569
10 files changed
+385 -14

No files matched your search

+2 -10
View File
@@ -8,7 +8,7 @@ import {
distanceKm,
resolveArea,
} from '../area.js';
import { LIMIT_SCHEMA, capRows, countNoun } from '../results.js';
import { LIMIT_SCHEMA, capRows, countNoun, toBase64 } from '../results.js';
const FRAME_TYPES = new Set(['image/jpeg', 'image/png', 'image/webp']);
const MAX_FRAME_BYTES = 3 * 1024 * 1024;
@@ -107,7 +107,7 @@ export const getCctvSnapshot = defineTool({
mime_type: frame.contentType,
bytes: frame.bytes.byteLength,
},
images: [{ mimeType: frame.contentType, data: base64(frame.bytes) }],
images: [{ mimeType: frame.contentType, data: toBase64(frame.bytes) }],
};
},
});
@@ -192,11 +192,3 @@ export const findRadioStations = defineTool({
};
},
});
/** Base64-encode bytes with the platform's btoa, in chunks. */
function base64(bytes) {
let binary = '';
for (let offset = 0; offset < bytes.length; offset += 0x8000)
binary += String.fromCharCode(...bytes.subarray(offset, offset + 0x8000));
return btoa(binary);
}