mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 09:42:21 +00:00
feat: add aviation and satellite tools
Add aircraft_in_area, find_aircraft, get_aircraft_track and get_aircraft_info over the live aircraft sources, with an optional military feed, and next_satellite_pass and satellites_overhead over the satellite catalog and the existing pass predictor. Source failures from the live contract now become tool errors with the matching code, so a rate limit reaches clients as retry_later with a wait time. Tool schemas may use pattern.
This commit is contained in:
1 parent
9895942633
commit
22c3fe40b0
16 files changed
+1111
-16
No files matched your search
+8
-1
@@ -2,7 +2,7 @@
|
||||
* Validates tool arguments against the JSON Schema subset tool definitions use:
|
||||
* object, array, string, number, integer and boolean types; required,
|
||||
* properties, additionalProperties, items, enum, minimum, maximum, minLength,
|
||||
* maxLength, minItems and maxItems. Unsupported keywords are rejected when a
|
||||
* maxLength, pattern, minItems and maxItems. Unsupported keywords are rejected when a
|
||||
* tool is defined, so a schema can never promise checks that are not made.
|
||||
*/
|
||||
|
||||
@@ -19,6 +19,7 @@ const KEYWORDS = new Set([
|
||||
'maximum',
|
||||
'minLength',
|
||||
'maxLength',
|
||||
'pattern',
|
||||
'minItems',
|
||||
'maxItems',
|
||||
'default',
|
||||
@@ -42,6 +43,7 @@ export function assertSupportedSchema(schema, path = 'schema') {
|
||||
}
|
||||
if (!TYPES.has(schema.type))
|
||||
throw new TypeError(`${path} has unsupported type ${schema.type}`);
|
||||
if (schema.pattern !== undefined) new RegExp(schema.pattern, 'u');
|
||||
for (const [name, child] of Object.entries(schema.properties || {}))
|
||||
assertSupportedSchema(child, `${path}.${name}`);
|
||||
if (schema.items) assertSupportedSchema(schema.items, `${path}[]`);
|
||||
@@ -99,6 +101,11 @@ export function validateValue(schema, value, path = 'arguments') {
|
||||
fail(`must be at least ${schema.minLength} characters`);
|
||||
if (schema.maxLength != null && value.length > schema.maxLength)
|
||||
fail(`must be at most ${schema.maxLength} characters`);
|
||||
if (
|
||||
schema.pattern !== undefined &&
|
||||
!new RegExp(schema.pattern, 'u').test(value)
|
||||
)
|
||||
fail(`must match ${schema.pattern}`);
|
||||
break;
|
||||
case 'number':
|
||||
case 'integer':
|
||||
|
||||
Reference in new issue
Block a user