@mapbox/mcp-server 0.5.4-dev-5 → 0.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonjs/config/toolConfig.d.ts.map +1 -1
- package/dist/commonjs/config/toolConfig.js +2 -0
- package/dist/commonjs/config/toolConfig.js.map +1 -1
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +2 -0
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/schemas/shared.d.ts +36 -0
- package/dist/commonjs/schemas/shared.d.ts.map +1 -0
- package/dist/commonjs/schemas/shared.js +35 -0
- package/dist/commonjs/schemas/shared.js.map +1 -0
- package/dist/commonjs/tools/BaseTool.d.ts +1 -1
- package/dist/commonjs/tools/BaseTool.d.ts.map +1 -1
- package/dist/commonjs/tools/BaseTool.js +4 -2
- package/dist/commonjs/tools/BaseTool.js.map +1 -1
- package/dist/commonjs/tools/MapboxApiBasedTool.d.ts +2 -47
- package/dist/commonjs/tools/MapboxApiBasedTool.d.ts.map +1 -1
- package/dist/commonjs/tools/MapboxApiBasedTool.js +3 -16
- package/dist/commonjs/tools/MapboxApiBasedTool.js.map +1 -1
- package/dist/commonjs/tools/MapboxApiBasedTool.schema.d.ts +47 -0
- package/dist/commonjs/tools/MapboxApiBasedTool.schema.d.ts.map +1 -0
- package/dist/commonjs/tools/MapboxApiBasedTool.schema.js +21 -0
- package/dist/commonjs/tools/MapboxApiBasedTool.schema.js.map +1 -0
- package/dist/commonjs/tools/category-list-tool/CategoryListTool.d.ts +3 -17
- package/dist/commonjs/tools/category-list-tool/CategoryListTool.d.ts.map +1 -1
- package/dist/commonjs/tools/category-list-tool/CategoryListTool.js +4 -20
- package/dist/commonjs/tools/category-list-tool/CategoryListTool.js.map +1 -1
- package/dist/commonjs/tools/category-list-tool/CategoryListTool.schema.d.ts +16 -0
- package/dist/commonjs/tools/category-list-tool/CategoryListTool.schema.d.ts.map +1 -0
- package/dist/commonjs/tools/category-list-tool/CategoryListTool.schema.js +23 -0
- package/dist/commonjs/tools/category-list-tool/CategoryListTool.schema.js.map +1 -0
- package/dist/commonjs/tools/category-search-tool/CategorySearchTool.d.ts +2 -76
- package/dist/commonjs/tools/category-search-tool/CategorySearchTool.d.ts.map +1 -1
- package/dist/commonjs/tools/category-search-tool/CategorySearchTool.js +4 -86
- package/dist/commonjs/tools/category-search-tool/CategorySearchTool.js.map +1 -1
- package/dist/commonjs/tools/category-search-tool/CategorySearchTool.schema.d.ts +76 -0
- package/dist/commonjs/tools/category-search-tool/CategorySearchTool.schema.d.ts.map +1 -0
- package/dist/commonjs/tools/category-search-tool/CategorySearchTool.schema.js +83 -0
- package/dist/commonjs/tools/category-search-tool/CategorySearchTool.schema.js.map +1 -0
- package/dist/commonjs/tools/directions-tool/DirectionsTool.d.ts +3 -51
- package/dist/commonjs/tools/directions-tool/DirectionsTool.d.ts.map +1 -1
- package/dist/commonjs/tools/directions-tool/DirectionsTool.js +8 -249
- package/dist/commonjs/tools/directions-tool/DirectionsTool.js.map +1 -1
- package/dist/commonjs/tools/directions-tool/DirectionsTool.schema.d.ts +51 -0
- package/dist/commonjs/tools/directions-tool/DirectionsTool.schema.d.ts.map +1 -0
- package/dist/commonjs/tools/directions-tool/DirectionsTool.schema.js +242 -0
- package/dist/commonjs/tools/directions-tool/DirectionsTool.schema.js.map +1 -0
- package/dist/commonjs/tools/directions-tool/cleanResponseData.d.ts +1 -1
- package/dist/commonjs/tools/directions-tool/cleanResponseData.d.ts.map +1 -1
- package/dist/commonjs/tools/directions-tool/cleanResponseData.js +2 -0
- package/dist/commonjs/tools/directions-tool/cleanResponseData.js.map +1 -1
- package/dist/commonjs/tools/isochrone-tool/IsochroneTool.d.ts +3 -52
- package/dist/commonjs/tools/isochrone-tool/IsochroneTool.d.ts.map +1 -1
- package/dist/commonjs/tools/isochrone-tool/IsochroneTool.js +4 -61
- package/dist/commonjs/tools/isochrone-tool/IsochroneTool.js.map +1 -1
- package/dist/commonjs/tools/isochrone-tool/IsochroneTool.schema.d.ts +51 -0
- package/dist/commonjs/tools/isochrone-tool/IsochroneTool.schema.d.ts.map +1 -0
- package/dist/commonjs/tools/isochrone-tool/IsochroneTool.schema.js +66 -0
- package/dist/commonjs/tools/isochrone-tool/IsochroneTool.schema.js.map +1 -0
- package/dist/commonjs/tools/matrix-tool/MatrixTool.d.ts +3 -43
- package/dist/commonjs/tools/matrix-tool/MatrixTool.d.ts.map +1 -1
- package/dist/commonjs/tools/matrix-tool/MatrixTool.js +4 -59
- package/dist/commonjs/tools/matrix-tool/MatrixTool.js.map +1 -1
- package/dist/commonjs/tools/matrix-tool/MatrixTool.schema.d.ts +42 -0
- package/dist/commonjs/tools/matrix-tool/MatrixTool.schema.d.ts.map +1 -0
- package/dist/commonjs/tools/matrix-tool/MatrixTool.schema.js +56 -0
- package/dist/commonjs/tools/matrix-tool/MatrixTool.schema.js.map +1 -0
- package/dist/commonjs/tools/reverse-geocode-tool/ReverseGeocodeTool.d.ts +2 -33
- package/dist/commonjs/tools/reverse-geocode-tool/ReverseGeocodeTool.d.ts.map +1 -1
- package/dist/commonjs/tools/reverse-geocode-tool/ReverseGeocodeTool.js +4 -57
- package/dist/commonjs/tools/reverse-geocode-tool/ReverseGeocodeTool.js.map +1 -1
- package/dist/commonjs/tools/reverse-geocode-tool/ReverseGeocodeTool.schema.d.ts +33 -0
- package/dist/commonjs/tools/reverse-geocode-tool/ReverseGeocodeTool.schema.d.ts.map +1 -0
- package/dist/commonjs/tools/reverse-geocode-tool/ReverseGeocodeTool.schema.js +49 -0
- package/dist/commonjs/tools/reverse-geocode-tool/ReverseGeocodeTool.schema.js.map +1 -0
- package/dist/commonjs/tools/search-and-geocode-tool/SearchAndGeocodeTool.d.ts +2 -94
- package/dist/commonjs/tools/search-and-geocode-tool/SearchAndGeocodeTool.d.ts.map +1 -1
- package/dist/commonjs/tools/search-and-geocode-tool/SearchAndGeocodeTool.js +4 -82
- package/dist/commonjs/tools/search-and-geocode-tool/SearchAndGeocodeTool.js.map +1 -1
- package/dist/commonjs/tools/search-and-geocode-tool/SearchAndGeocodeTool.schema.d.ts +94 -0
- package/dist/commonjs/tools/search-and-geocode-tool/SearchAndGeocodeTool.schema.d.ts.map +1 -0
- package/dist/commonjs/tools/search-and-geocode-tool/SearchAndGeocodeTool.schema.js +81 -0
- package/dist/commonjs/tools/search-and-geocode-tool/SearchAndGeocodeTool.schema.js.map +1 -0
- package/dist/commonjs/tools/static-map-image-tool/StaticMapImageTool.d.ts +3 -170
- package/dist/commonjs/tools/static-map-image-tool/StaticMapImageTool.d.ts.map +1 -1
- package/dist/commonjs/tools/static-map-image-tool/StaticMapImageTool.js +4 -333
- package/dist/commonjs/tools/static-map-image-tool/StaticMapImageTool.js.map +1 -1
- package/dist/commonjs/tools/static-map-image-tool/StaticMapImageTool.schema.d.ts +312 -0
- package/dist/commonjs/tools/static-map-image-tool/StaticMapImageTool.schema.d.ts.map +1 -0
- package/dist/commonjs/tools/static-map-image-tool/StaticMapImageTool.schema.js +338 -0
- package/dist/commonjs/tools/static-map-image-tool/StaticMapImageTool.schema.js.map +1 -0
- package/dist/commonjs/tools/toolRegistry.d.ts.map +1 -1
- package/dist/commonjs/tools/toolRegistry.js +2 -0
- package/dist/commonjs/tools/toolRegistry.js.map +1 -1
- package/dist/commonjs/tools/version-tool/VersionTool.d.ts +2 -4
- package/dist/commonjs/tools/version-tool/VersionTool.d.ts.map +1 -1
- package/dist/commonjs/tools/version-tool/VersionTool.js +4 -3
- package/dist/commonjs/tools/version-tool/VersionTool.js.map +1 -1
- package/dist/commonjs/tools/version-tool/VersionTool.schema.d.ts +3 -0
- package/dist/commonjs/tools/version-tool/VersionTool.schema.d.ts.map +1 -0
- package/dist/commonjs/tools/version-tool/VersionTool.schema.js +8 -0
- package/dist/commonjs/tools/version-tool/VersionTool.schema.js.map +1 -0
- package/dist/commonjs/{tools/directions-tool/formatIsoDateTime.d.ts → utils/dateUtils.d.ts} +1 -1
- package/dist/commonjs/utils/dateUtils.d.ts.map +1 -0
- package/dist/commonjs/{tools/directions-tool/formatIsoDateTime.js → utils/dateUtils.js} +3 -1
- package/dist/commonjs/utils/dateUtils.js.map +1 -0
- package/dist/commonjs/utils/fetchRequest.d.ts.map +1 -1
- package/dist/commonjs/utils/fetchRequest.js +2 -0
- package/dist/commonjs/utils/fetchRequest.js.map +1 -1
- package/dist/commonjs/utils/versionUtils-cjs.cjs.map +1 -1
- package/dist/commonjs/utils/versionUtils-cjs.d.cts.map +1 -1
- package/dist/commonjs/utils/versionUtils.js +2 -0
- package/dist/commonjs/version.json +4 -4
- package/dist/esm/config/toolConfig.d.ts.map +1 -1
- package/dist/esm/config/toolConfig.js +2 -0
- package/dist/esm/config/toolConfig.js.map +1 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/schemas/shared.d.ts +36 -0
- package/dist/esm/schemas/shared.d.ts.map +1 -0
- package/dist/esm/schemas/shared.js +32 -0
- package/dist/esm/schemas/shared.js.map +1 -0
- package/dist/esm/tools/BaseTool.d.ts +1 -1
- package/dist/esm/tools/BaseTool.d.ts.map +1 -1
- package/dist/esm/tools/BaseTool.js +4 -2
- package/dist/esm/tools/BaseTool.js.map +1 -1
- package/dist/esm/tools/MapboxApiBasedTool.d.ts +2 -47
- package/dist/esm/tools/MapboxApiBasedTool.d.ts.map +1 -1
- package/dist/esm/tools/MapboxApiBasedTool.js +2 -15
- package/dist/esm/tools/MapboxApiBasedTool.js.map +1 -1
- package/dist/esm/tools/MapboxApiBasedTool.schema.d.ts +47 -0
- package/dist/esm/tools/MapboxApiBasedTool.schema.d.ts.map +1 -0
- package/dist/esm/tools/MapboxApiBasedTool.schema.js +18 -0
- package/dist/esm/tools/MapboxApiBasedTool.schema.js.map +1 -0
- package/dist/esm/tools/category-list-tool/CategoryListTool.d.ts +3 -17
- package/dist/esm/tools/category-list-tool/CategoryListTool.d.ts.map +1 -1
- package/dist/esm/tools/category-list-tool/CategoryListTool.js +3 -19
- package/dist/esm/tools/category-list-tool/CategoryListTool.js.map +1 -1
- package/dist/esm/tools/category-list-tool/CategoryListTool.schema.d.ts +16 -0
- package/dist/esm/tools/category-list-tool/CategoryListTool.schema.d.ts.map +1 -0
- package/dist/esm/tools/category-list-tool/CategoryListTool.schema.js +20 -0
- package/dist/esm/tools/category-list-tool/CategoryListTool.schema.js.map +1 -0
- package/dist/esm/tools/category-search-tool/CategorySearchTool.d.ts +2 -76
- package/dist/esm/tools/category-search-tool/CategorySearchTool.d.ts.map +1 -1
- package/dist/esm/tools/category-search-tool/CategorySearchTool.js +3 -85
- package/dist/esm/tools/category-search-tool/CategorySearchTool.js.map +1 -1
- package/dist/esm/tools/category-search-tool/CategorySearchTool.schema.d.ts +76 -0
- package/dist/esm/tools/category-search-tool/CategorySearchTool.schema.d.ts.map +1 -0
- package/dist/esm/tools/category-search-tool/CategorySearchTool.schema.js +80 -0
- package/dist/esm/tools/category-search-tool/CategorySearchTool.schema.js.map +1 -0
- package/dist/esm/tools/directions-tool/DirectionsTool.d.ts +3 -51
- package/dist/esm/tools/directions-tool/DirectionsTool.d.ts.map +1 -1
- package/dist/esm/tools/directions-tool/DirectionsTool.js +4 -245
- package/dist/esm/tools/directions-tool/DirectionsTool.js.map +1 -1
- package/dist/esm/tools/directions-tool/DirectionsTool.schema.d.ts +51 -0
- package/dist/esm/tools/directions-tool/DirectionsTool.schema.d.ts.map +1 -0
- package/dist/esm/tools/directions-tool/DirectionsTool.schema.js +239 -0
- package/dist/esm/tools/directions-tool/DirectionsTool.schema.js.map +1 -0
- package/dist/esm/tools/directions-tool/cleanResponseData.d.ts +1 -1
- package/dist/esm/tools/directions-tool/cleanResponseData.d.ts.map +1 -1
- package/dist/esm/tools/directions-tool/cleanResponseData.js +2 -0
- package/dist/esm/tools/directions-tool/cleanResponseData.js.map +1 -1
- package/dist/esm/tools/isochrone-tool/IsochroneTool.d.ts +3 -52
- package/dist/esm/tools/isochrone-tool/IsochroneTool.d.ts.map +1 -1
- package/dist/esm/tools/isochrone-tool/IsochroneTool.js +3 -60
- package/dist/esm/tools/isochrone-tool/IsochroneTool.js.map +1 -1
- package/dist/esm/tools/isochrone-tool/IsochroneTool.schema.d.ts +51 -0
- package/dist/esm/tools/isochrone-tool/IsochroneTool.schema.d.ts.map +1 -0
- package/dist/esm/tools/isochrone-tool/IsochroneTool.schema.js +63 -0
- package/dist/esm/tools/isochrone-tool/IsochroneTool.schema.js.map +1 -0
- package/dist/esm/tools/matrix-tool/MatrixTool.d.ts +3 -43
- package/dist/esm/tools/matrix-tool/MatrixTool.d.ts.map +1 -1
- package/dist/esm/tools/matrix-tool/MatrixTool.js +3 -58
- package/dist/esm/tools/matrix-tool/MatrixTool.js.map +1 -1
- package/dist/esm/tools/matrix-tool/MatrixTool.schema.d.ts +42 -0
- package/dist/esm/tools/matrix-tool/MatrixTool.schema.d.ts.map +1 -0
- package/dist/esm/tools/matrix-tool/MatrixTool.schema.js +53 -0
- package/dist/esm/tools/matrix-tool/MatrixTool.schema.js.map +1 -0
- package/dist/esm/tools/reverse-geocode-tool/ReverseGeocodeTool.d.ts +2 -33
- package/dist/esm/tools/reverse-geocode-tool/ReverseGeocodeTool.d.ts.map +1 -1
- package/dist/esm/tools/reverse-geocode-tool/ReverseGeocodeTool.js +3 -56
- package/dist/esm/tools/reverse-geocode-tool/ReverseGeocodeTool.js.map +1 -1
- package/dist/esm/tools/reverse-geocode-tool/ReverseGeocodeTool.schema.d.ts +33 -0
- package/dist/esm/tools/reverse-geocode-tool/ReverseGeocodeTool.schema.d.ts.map +1 -0
- package/dist/esm/tools/reverse-geocode-tool/ReverseGeocodeTool.schema.js +46 -0
- package/dist/esm/tools/reverse-geocode-tool/ReverseGeocodeTool.schema.js.map +1 -0
- package/dist/esm/tools/search-and-geocode-tool/SearchAndGeocodeTool.d.ts +2 -94
- package/dist/esm/tools/search-and-geocode-tool/SearchAndGeocodeTool.d.ts.map +1 -1
- package/dist/esm/tools/search-and-geocode-tool/SearchAndGeocodeTool.js +3 -81
- package/dist/esm/tools/search-and-geocode-tool/SearchAndGeocodeTool.js.map +1 -1
- package/dist/esm/tools/search-and-geocode-tool/SearchAndGeocodeTool.schema.d.ts +94 -0
- package/dist/esm/tools/search-and-geocode-tool/SearchAndGeocodeTool.schema.d.ts.map +1 -0
- package/dist/esm/tools/search-and-geocode-tool/SearchAndGeocodeTool.schema.js +78 -0
- package/dist/esm/tools/search-and-geocode-tool/SearchAndGeocodeTool.schema.js.map +1 -0
- package/dist/esm/tools/static-map-image-tool/StaticMapImageTool.d.ts +3 -170
- package/dist/esm/tools/static-map-image-tool/StaticMapImageTool.d.ts.map +1 -1
- package/dist/esm/tools/static-map-image-tool/StaticMapImageTool.js +3 -332
- package/dist/esm/tools/static-map-image-tool/StaticMapImageTool.js.map +1 -1
- package/dist/esm/tools/static-map-image-tool/StaticMapImageTool.schema.d.ts +312 -0
- package/dist/esm/tools/static-map-image-tool/StaticMapImageTool.schema.d.ts.map +1 -0
- package/dist/esm/tools/static-map-image-tool/StaticMapImageTool.schema.js +335 -0
- package/dist/esm/tools/static-map-image-tool/StaticMapImageTool.schema.js.map +1 -0
- package/dist/esm/tools/toolRegistry.d.ts.map +1 -1
- package/dist/esm/tools/toolRegistry.js +2 -0
- package/dist/esm/tools/toolRegistry.js.map +1 -1
- package/dist/esm/tools/version-tool/VersionTool.d.ts +2 -4
- package/dist/esm/tools/version-tool/VersionTool.d.ts.map +1 -1
- package/dist/esm/tools/version-tool/VersionTool.js +4 -3
- package/dist/esm/tools/version-tool/VersionTool.js.map +1 -1
- package/dist/esm/tools/version-tool/VersionTool.schema.d.ts +3 -0
- package/dist/esm/tools/version-tool/VersionTool.schema.d.ts.map +1 -0
- package/dist/esm/tools/version-tool/VersionTool.schema.js +5 -0
- package/dist/esm/tools/version-tool/VersionTool.schema.js.map +1 -0
- package/dist/esm/{tools/directions-tool/formatIsoDateTime.d.ts → utils/dateUtils.d.ts} +1 -1
- package/dist/esm/utils/dateUtils.d.ts.map +1 -0
- package/dist/esm/{tools/directions-tool/formatIsoDateTime.js → utils/dateUtils.js} +3 -1
- package/dist/esm/utils/dateUtils.js.map +1 -0
- package/dist/esm/utils/fetchRequest.d.ts.map +1 -1
- package/dist/esm/utils/fetchRequest.js +2 -0
- package/dist/esm/utils/fetchRequest.js.map +1 -1
- package/dist/esm/utils/versionUtils.d.ts.map +1 -1
- package/dist/esm/utils/versionUtils.js +2 -0
- package/dist/esm/utils/versionUtils.js.map +1 -1
- package/dist/esm/version.json +4 -4
- package/package.json +3 -3
- package/dist/commonjs/tools/directions-tool/formatIsoDateTime.d.ts.map +0 -1
- package/dist/commonjs/tools/directions-tool/formatIsoDateTime.js.map +0 -1
- package/dist/esm/tools/directions-tool/formatIsoDateTime.d.ts.map +0 -1
- package/dist/esm/tools/directions-tool/formatIsoDateTime.js.map +0 -1
|
@@ -1,93 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// Copyright (c) Mapbox, Inc.
|
|
3
|
+
// Licensed under the MIT License.
|
|
2
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
5
|
exports.CategorySearchTool = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
6
|
const MapboxApiBasedTool_js_1 = require("../MapboxApiBasedTool.js");
|
|
6
7
|
const fetchRequest_js_1 = require("../../utils/fetchRequest.js");
|
|
7
|
-
const
|
|
8
|
-
category: zod_1.z
|
|
9
|
-
.string()
|
|
10
|
-
.describe('The canonical place category name to search for (e.g., "restaurant", "hotel", "cafe"). To get the full list of supported categories, use the category_list_tool.'),
|
|
11
|
-
language: zod_1.z
|
|
12
|
-
.string()
|
|
13
|
-
.optional()
|
|
14
|
-
.describe('ISO language code for the response (e.g., "en", "es", "fr", "de", "ja")'),
|
|
15
|
-
limit: zod_1.z
|
|
16
|
-
.number()
|
|
17
|
-
.min(1)
|
|
18
|
-
.max(25)
|
|
19
|
-
.optional()
|
|
20
|
-
.default(10)
|
|
21
|
-
.describe('Maximum number of results to return (1-25)'),
|
|
22
|
-
proximity: zod_1.z
|
|
23
|
-
.union([
|
|
24
|
-
zod_1.z.object({
|
|
25
|
-
longitude: zod_1.z.number().min(-180).max(180),
|
|
26
|
-
latitude: zod_1.z.number().min(-90).max(90)
|
|
27
|
-
}),
|
|
28
|
-
zod_1.z.string().transform((val) => {
|
|
29
|
-
// Handle special case of 'ip'
|
|
30
|
-
if (val === 'ip') {
|
|
31
|
-
return 'ip';
|
|
32
|
-
}
|
|
33
|
-
// Handle JSON-stringified object: "{\"longitude\": -82.458107, \"latitude\": 27.937259}"
|
|
34
|
-
if (val.startsWith('{') && val.endsWith('}')) {
|
|
35
|
-
try {
|
|
36
|
-
const parsed = JSON.parse(val);
|
|
37
|
-
if (typeof parsed === 'object' &&
|
|
38
|
-
parsed !== null &&
|
|
39
|
-
typeof parsed.longitude === 'number' &&
|
|
40
|
-
typeof parsed.latitude === 'number') {
|
|
41
|
-
return { longitude: parsed.longitude, latitude: parsed.latitude };
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
catch {
|
|
45
|
-
// Fall back to other formats
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
// Handle string that looks like an array: "[-82.451668, 27.942964]"
|
|
49
|
-
if (val.startsWith('[') && val.endsWith(']')) {
|
|
50
|
-
const coords = val
|
|
51
|
-
.slice(1, -1)
|
|
52
|
-
.split(',')
|
|
53
|
-
.map((s) => Number(s.trim()));
|
|
54
|
-
if (coords.length === 2 && !isNaN(coords[0]) && !isNaN(coords[1])) {
|
|
55
|
-
return { longitude: coords[0], latitude: coords[1] };
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
// Handle comma-separated string: "-82.451668,27.942964"
|
|
59
|
-
const parts = val.split(',').map((s) => Number(s.trim()));
|
|
60
|
-
if (parts.length === 2 && !isNaN(parts[0]) && !isNaN(parts[1])) {
|
|
61
|
-
return { longitude: parts[0], latitude: parts[1] };
|
|
62
|
-
}
|
|
63
|
-
throw new Error('Invalid proximity format. Expected {longitude, latitude}, "longitude,latitude", or "ip"');
|
|
64
|
-
})
|
|
65
|
-
])
|
|
66
|
-
.optional()
|
|
67
|
-
.describe('Location to bias results towards. Either coordinate object with longitude and latitude or "ip" for IP-based location'),
|
|
68
|
-
bbox: zod_1.z
|
|
69
|
-
.object({
|
|
70
|
-
minLongitude: zod_1.z.number().min(-180).max(180),
|
|
71
|
-
minLatitude: zod_1.z.number().min(-90).max(90),
|
|
72
|
-
maxLongitude: zod_1.z.number().min(-180).max(180),
|
|
73
|
-
maxLatitude: zod_1.z.number().min(-90).max(90)
|
|
74
|
-
})
|
|
75
|
-
.optional()
|
|
76
|
-
.describe('Bounding box to limit results within specified bounds'),
|
|
77
|
-
country: zod_1.z
|
|
78
|
-
.array(zod_1.z.string().length(2))
|
|
79
|
-
.optional()
|
|
80
|
-
.describe('Array of ISO 3166 alpha 2 country codes to limit results'),
|
|
81
|
-
poi_category_exclusions: zod_1.z
|
|
82
|
-
.array(zod_1.z.string())
|
|
83
|
-
.optional()
|
|
84
|
-
.describe('Array of POI categories to exclude from results'),
|
|
85
|
-
format: zod_1.z
|
|
86
|
-
.enum(['json_string', 'formatted_text'])
|
|
87
|
-
.optional()
|
|
88
|
-
.default('formatted_text')
|
|
89
|
-
.describe('Output format: "json_string" returns raw GeoJSON data as a JSON string that can be parsed; "formatted_text" returns human-readable text with place names, addresses, and coordinates. Both return as text content but json_string contains parseable JSON data while formatted_text is for display.')
|
|
90
|
-
});
|
|
8
|
+
const CategorySearchTool_schema_js_1 = require("./CategorySearchTool.schema.js");
|
|
91
9
|
class CategorySearchTool extends MapboxApiBasedTool_js_1.MapboxApiBasedTool {
|
|
92
10
|
fetch;
|
|
93
11
|
name = 'category_search_tool';
|
|
@@ -100,7 +18,7 @@ class CategorySearchTool extends MapboxApiBasedTool_js_1.MapboxApiBasedTool {
|
|
|
100
18
|
openWorldHint: true
|
|
101
19
|
};
|
|
102
20
|
constructor(fetch = fetchRequest_js_1.fetchClient) {
|
|
103
|
-
super({ inputSchema: CategorySearchInputSchema });
|
|
21
|
+
super({ inputSchema: CategorySearchTool_schema_js_1.CategorySearchInputSchema });
|
|
104
22
|
this.fetch = fetch;
|
|
105
23
|
}
|
|
106
24
|
formatGeoJsonToText(geoJsonResponse) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CategorySearchTool.js","sourceRoot":"","sources":["../../../../src/tools/category-search-tool/CategorySearchTool.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CategorySearchTool.js","sourceRoot":"","sources":["../../../../src/tools/category-search-tool/CategorySearchTool.ts"],"names":[],"mappings":";AAAA,6BAA6B;AAC7B,kCAAkC;;;AAGlC,oEAA8D;AAC9D,iEAA0D;AAC1D,iFAA2E;AAE3E,MAAa,kBAAmB,SAAQ,0CAEvC;IAYqB;IAXpB,IAAI,GAAG,sBAAsB,CAAC;IAC9B,WAAW,GACT,4XAA4X,CAAC;IAC/X,WAAW,GAAG;QACZ,KAAK,EAAE,sBAAsB;QAC7B,YAAY,EAAE,IAAI;QAClB,eAAe,EAAE,KAAK;QACtB,cAAc,EAAE,IAAI;QACpB,aAAa,EAAE,IAAI;KACpB,CAAC;IAEF,YAAoB,QAAiC,6BAAW;QAC9D,KAAK,CAAC,EAAE,WAAW,EAAE,wDAAyB,EAAE,CAAC,CAAC;QADhC,UAAK,GAAL,KAAK,CAAuC;IAEhE,CAAC;IAEO,mBAAmB,CAAC,eAAoB;QAC9C,IACE,CAAC,eAAe;YAChB,CAAC,eAAe,CAAC,QAAQ;YACzB,eAAe,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EACrC,CAAC;YACD,OAAO,wJAAwJ,CAAC;QAClK,CAAC;QAED,MAAM,OAAO,GAAG,eAAe,CAAC,QAAQ,CAAC,GAAG,CAC1C,CAAC,OAAY,EAAE,KAAa,EAAE,EAAE;YAC9B,MAAM,KAAK,GAAG,OAAO,CAAC,UAAU,IAAI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AAI,CAAC,EAAE,CAAC;QAChE,CAAC;IACH,CAAC;CACF;AA9ID,gDA8IC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const CategorySearchInputSchema: z.ZodObject<{
|
|
3
|
+
category: z.ZodString;
|
|
4
|
+
language: z.ZodOptional<z.ZodString>;
|
|
5
|
+
limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
6
|
+
proximity: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
7
|
+
longitude: z.ZodNumber;
|
|
8
|
+
latitude: z.ZodNumber;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
longitude: number;
|
|
11
|
+
latitude: number;
|
|
12
|
+
}, {
|
|
13
|
+
longitude: number;
|
|
14
|
+
latitude: number;
|
|
15
|
+
}>, z.ZodEffects<z.ZodString, "ip" | {
|
|
16
|
+
longitude: any;
|
|
17
|
+
latitude: any;
|
|
18
|
+
}, string>]>>;
|
|
19
|
+
bbox: z.ZodOptional<z.ZodObject<{
|
|
20
|
+
minLongitude: z.ZodNumber;
|
|
21
|
+
minLatitude: z.ZodNumber;
|
|
22
|
+
maxLongitude: z.ZodNumber;
|
|
23
|
+
maxLatitude: z.ZodNumber;
|
|
24
|
+
}, "strip", z.ZodTypeAny, {
|
|
25
|
+
minLongitude: number;
|
|
26
|
+
minLatitude: number;
|
|
27
|
+
maxLongitude: number;
|
|
28
|
+
maxLatitude: number;
|
|
29
|
+
}, {
|
|
30
|
+
minLongitude: number;
|
|
31
|
+
minLatitude: number;
|
|
32
|
+
maxLongitude: number;
|
|
33
|
+
maxLatitude: number;
|
|
34
|
+
}>>;
|
|
35
|
+
country: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
36
|
+
poi_category_exclusions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
37
|
+
format: z.ZodDefault<z.ZodOptional<z.ZodEnum<["json_string", "formatted_text"]>>>;
|
|
38
|
+
}, "strip", z.ZodTypeAny, {
|
|
39
|
+
limit: number;
|
|
40
|
+
category: string;
|
|
41
|
+
format: "json_string" | "formatted_text";
|
|
42
|
+
language?: string | undefined;
|
|
43
|
+
proximity?: {
|
|
44
|
+
longitude: number;
|
|
45
|
+
latitude: number;
|
|
46
|
+
} | "ip" | {
|
|
47
|
+
longitude: any;
|
|
48
|
+
latitude: any;
|
|
49
|
+
} | undefined;
|
|
50
|
+
bbox?: {
|
|
51
|
+
minLongitude: number;
|
|
52
|
+
minLatitude: number;
|
|
53
|
+
maxLongitude: number;
|
|
54
|
+
maxLatitude: number;
|
|
55
|
+
} | undefined;
|
|
56
|
+
country?: string[] | undefined;
|
|
57
|
+
poi_category_exclusions?: string[] | undefined;
|
|
58
|
+
}, {
|
|
59
|
+
category: string;
|
|
60
|
+
language?: string | undefined;
|
|
61
|
+
limit?: number | undefined;
|
|
62
|
+
proximity?: string | {
|
|
63
|
+
longitude: number;
|
|
64
|
+
latitude: number;
|
|
65
|
+
} | undefined;
|
|
66
|
+
bbox?: {
|
|
67
|
+
minLongitude: number;
|
|
68
|
+
minLatitude: number;
|
|
69
|
+
maxLongitude: number;
|
|
70
|
+
maxLatitude: number;
|
|
71
|
+
} | undefined;
|
|
72
|
+
country?: string[] | undefined;
|
|
73
|
+
poi_category_exclusions?: string[] | undefined;
|
|
74
|
+
format?: "json_string" | "formatted_text" | undefined;
|
|
75
|
+
}>;
|
|
76
|
+
//# sourceMappingURL=CategorySearchTool.schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CategorySearchTool.schema.d.ts","sourceRoot":"","sources":["../../../../src/tools/category-search-tool/CategorySearchTool.schema.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmFpC,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Mapbox, Inc.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.CategorySearchInputSchema = void 0;
|
|
6
|
+
const zod_1 = require("zod");
|
|
7
|
+
const shared_js_1 = require("../../schemas/shared.js");
|
|
8
|
+
exports.CategorySearchInputSchema = zod_1.z.object({
|
|
9
|
+
category: zod_1.z
|
|
10
|
+
.string()
|
|
11
|
+
.describe('The canonical place category name to search for (e.g., "restaurant", "hotel", "cafe"). To get the full list of supported categories, use the category_list_tool.'),
|
|
12
|
+
language: shared_js_1.languageSchema.optional(),
|
|
13
|
+
limit: zod_1.z
|
|
14
|
+
.number()
|
|
15
|
+
.min(1)
|
|
16
|
+
.max(25)
|
|
17
|
+
.optional()
|
|
18
|
+
.default(10)
|
|
19
|
+
.describe('Maximum number of results to return (1-25)'),
|
|
20
|
+
proximity: zod_1.z
|
|
21
|
+
.union([
|
|
22
|
+
zod_1.z.object({
|
|
23
|
+
longitude: zod_1.z.number().min(-180).max(180),
|
|
24
|
+
latitude: zod_1.z.number().min(-90).max(90)
|
|
25
|
+
}),
|
|
26
|
+
zod_1.z.string().transform((val) => {
|
|
27
|
+
// Handle special case of 'ip'
|
|
28
|
+
if (val === 'ip') {
|
|
29
|
+
return 'ip';
|
|
30
|
+
}
|
|
31
|
+
// Handle JSON-stringified object: "{\"longitude\": -82.458107, \"latitude\": 27.937259}"
|
|
32
|
+
if (val.startsWith('{') && val.endsWith('}')) {
|
|
33
|
+
try {
|
|
34
|
+
const parsed = JSON.parse(val);
|
|
35
|
+
if (typeof parsed === 'object' &&
|
|
36
|
+
parsed !== null &&
|
|
37
|
+
typeof parsed.longitude === 'number' &&
|
|
38
|
+
typeof parsed.latitude === 'number') {
|
|
39
|
+
return { longitude: parsed.longitude, latitude: parsed.latitude };
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
// Fall back to other formats
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// Handle string that looks like an array: "[-82.451668, 27.942964]"
|
|
47
|
+
if (val.startsWith('[') && val.endsWith(']')) {
|
|
48
|
+
const coords = val
|
|
49
|
+
.slice(1, -1)
|
|
50
|
+
.split(',')
|
|
51
|
+
.map((s) => Number(s.trim()));
|
|
52
|
+
if (coords.length === 2 && !isNaN(coords[0]) && !isNaN(coords[1])) {
|
|
53
|
+
return { longitude: coords[0], latitude: coords[1] };
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// Handle comma-separated string: "-82.451668,27.942964"
|
|
57
|
+
const parts = val.split(',').map((s) => Number(s.trim()));
|
|
58
|
+
if (parts.length === 2 && !isNaN(parts[0]) && !isNaN(parts[1])) {
|
|
59
|
+
return { longitude: parts[0], latitude: parts[1] };
|
|
60
|
+
}
|
|
61
|
+
throw new Error('Invalid proximity format. Expected {longitude, latitude}, "longitude,latitude", or "ip"');
|
|
62
|
+
})
|
|
63
|
+
])
|
|
64
|
+
.optional()
|
|
65
|
+
.describe('Location to bias results towards. Either coordinate object with longitude and latitude or "ip" for IP-based location'),
|
|
66
|
+
bbox: shared_js_1.bboxSchema
|
|
67
|
+
.describe('Bounding box to limit results within specified bounds')
|
|
68
|
+
.optional(),
|
|
69
|
+
country: zod_1.z
|
|
70
|
+
.array(zod_1.z.string().length(2))
|
|
71
|
+
.optional()
|
|
72
|
+
.describe('Array of ISO 3166 alpha 2 country codes to limit results'),
|
|
73
|
+
poi_category_exclusions: zod_1.z
|
|
74
|
+
.array(zod_1.z.string())
|
|
75
|
+
.optional()
|
|
76
|
+
.describe('Array of POI categories to exclude from results'),
|
|
77
|
+
format: zod_1.z
|
|
78
|
+
.enum(['json_string', 'formatted_text'])
|
|
79
|
+
.optional()
|
|
80
|
+
.default('formatted_text')
|
|
81
|
+
.describe('Output format: "json_string" returns raw GeoJSON data as a JSON string that can be parsed; "formatted_text" returns human-readable text with place names, addresses, and coordinates. Both return as text content but json_string contains parseable JSON data while formatted_text is for display.')
|
|
82
|
+
});
|
|
83
|
+
//# sourceMappingURL=CategorySearchTool.schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CategorySearchTool.schema.js","sourceRoot":"","sources":["../../../../src/tools/category-search-tool/CategorySearchTool.schema.ts"],"names":[],"mappings":";AAAA,6BAA6B;AAC7B,kCAAkC;;;AAElC,6BAAwB;AACxB,uDAAqE;AAExD,QAAA,yBAAyB,GAAG,OAAC,CAAC,MAAM,CAAC;IAChD,QAAQ,EAAE,OAAC;SACR,MAAM,EAAE;SACR,QAAQ,CACP,kKAAkK,CACnK;IACH,QAAQ,EAAE,0BAAc,CAAC,QAAQ,EAAE;IACnC,KAAK,EAAE,OAAC;SACL,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,GAAG,CAAC,EAAE,CAAC;SACP,QAAQ,EAAE;SACV,OAAO,CAAC,EAAE,CAAC;SACX,QAAQ,CAAC,4CAA4C,CAAC;IACzD,SAAS,EAAE,OAAC;SACT,KAAK,CAAC;QACL,OAAC,CAAC,MAAM,CAAC;YACP,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;YACxC,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;SACtC,CAAC;QACF,OAAC,CAAC,MAAM,EAAE,CAAC,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE;YAC3B,8BAA8B;YAC9B,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;gBACjB,OAAO,IAAa,CAAC;YACvB,CAAC;YACD,yFAAyF;YACzF,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,Q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C,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;YAC1D,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC/D,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;YACrD,CAAC;YACD,MAAM,IAAI,KAAK,CACb,yFAAyF,CAC1F,CAAC;QACJ,CAAC,CAAC;KACH,CAAC;SACD,QAAQ,EAAE;SACV,QAAQ,CACP,sHAAsH,CACvH;IACH,IAAI,EAAE,sBAAU;SACb,QAAQ,CAAC,uDAAuD,CAAC;SACjE,QAAQ,EAAE;IACb,OAAO,EAAE,OAAC;SACP,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;SAC3B,QAAQ,EAAE;SACV,QAAQ,CAAC,0DAA0D,CAAC;IACvE,uBAAuB,EAAE,OAAC;SACvB,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC;SACjB,QAAQ,EAAE;SACV,QAAQ,CAAC,iDAAiD,CAAC;IAC9D,MAAM,EAAE,OAAC;SACN,IAAI,CAAC,CAAC,aAAa,EAAE,gBAAgB,CAAC,CAAC;SACvC,QAAQ,EAAE;SACV,OAAO,CAAC,gBAAgB,CAAC;SACzB,QAAQ,CACP,qSAAqS,CACtS;CACJ,CAAC,CAAC"}
|
|
@@ -1,54 +1,6 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
1
|
+
import type { z } from 'zod';
|
|
2
2
|
import { MapboxApiBasedTool } from '../MapboxApiBasedTool.js';
|
|
3
|
-
|
|
4
|
-
coordinates: z.ZodArray<z.ZodObject<{
|
|
5
|
-
longitude: z.ZodNumber;
|
|
6
|
-
latitude: z.ZodNumber;
|
|
7
|
-
}, "strip", z.ZodTypeAny, {
|
|
8
|
-
longitude: number;
|
|
9
|
-
latitude: number;
|
|
10
|
-
}, {
|
|
11
|
-
longitude: number;
|
|
12
|
-
latitude: number;
|
|
13
|
-
}>, "many">;
|
|
14
|
-
routing_profile: z.ZodDefault<z.ZodOptional<z.ZodEnum<["driving-traffic", "driving", "walking", "cycling"]>>>;
|
|
15
|
-
geometries: z.ZodDefault<z.ZodOptional<z.ZodEnum<["none", "geojson"]>>>;
|
|
16
|
-
max_height: z.ZodOptional<z.ZodNumber>;
|
|
17
|
-
max_width: z.ZodOptional<z.ZodNumber>;
|
|
18
|
-
max_weight: z.ZodOptional<z.ZodNumber>;
|
|
19
|
-
alternatives: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
20
|
-
depart_at: z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>;
|
|
21
|
-
arrive_by: z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>;
|
|
22
|
-
exclude: z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>;
|
|
23
|
-
}, "strip", z.ZodTypeAny, {
|
|
24
|
-
coordinates: {
|
|
25
|
-
longitude: number;
|
|
26
|
-
latitude: number;
|
|
27
|
-
}[];
|
|
28
|
-
routing_profile: "driving-traffic" | "driving" | "walking" | "cycling";
|
|
29
|
-
geometries: "none" | "geojson";
|
|
30
|
-
alternatives: boolean;
|
|
31
|
-
max_height?: number | undefined;
|
|
32
|
-
max_width?: number | undefined;
|
|
33
|
-
max_weight?: number | undefined;
|
|
34
|
-
depart_at?: string | undefined;
|
|
35
|
-
arrive_by?: string | undefined;
|
|
36
|
-
exclude?: string | undefined;
|
|
37
|
-
}, {
|
|
38
|
-
coordinates: {
|
|
39
|
-
longitude: number;
|
|
40
|
-
latitude: number;
|
|
41
|
-
}[];
|
|
42
|
-
routing_profile?: "driving-traffic" | "driving" | "walking" | "cycling" | undefined;
|
|
43
|
-
geometries?: "none" | "geojson" | undefined;
|
|
44
|
-
max_height?: number | undefined;
|
|
45
|
-
max_width?: number | undefined;
|
|
46
|
-
max_weight?: number | undefined;
|
|
47
|
-
alternatives?: boolean | undefined;
|
|
48
|
-
depart_at?: string | undefined;
|
|
49
|
-
arrive_by?: string | undefined;
|
|
50
|
-
exclude?: string | undefined;
|
|
51
|
-
}>;
|
|
3
|
+
import { DirectionsInputSchema } from './DirectionsTool.schema.js';
|
|
52
4
|
export declare class DirectionsTool extends MapboxApiBasedTool<typeof DirectionsInputSchema> {
|
|
53
5
|
private fetch;
|
|
54
6
|
name: string;
|
|
@@ -61,6 +13,6 @@ export declare class DirectionsTool extends MapboxApiBasedTool<typeof Directions
|
|
|
61
13
|
openWorldHint: boolean;
|
|
62
14
|
};
|
|
63
15
|
constructor(fetch?: typeof globalThis.fetch);
|
|
64
|
-
protected execute(input: z.infer<typeof DirectionsInputSchema>, accessToken: string): Promise<
|
|
16
|
+
protected execute(input: z.infer<typeof DirectionsInputSchema>, accessToken: string): Promise<unknown>;
|
|
65
17
|
}
|
|
66
18
|
//# sourceMappingURL=DirectionsTool.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DirectionsTool.d.ts","sourceRoot":"","sources":["../../../../src/tools/directions-tool/DirectionsTool.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DirectionsTool.d.ts","sourceRoot":"","sources":["../../../../src/tools/directions-tool/DirectionsTool.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAI9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAInE,qBAAa,cAAe,SAAQ,kBAAkB,CACpD,OAAO,qBAAqB,CAC7B;IAYa,OAAO,CAAC,KAAK;IAXzB,IAAI,SAAqB;IACzB,WAAW,SACgF;IAC3F,WAAW;;;;;;MAMT;gBAEkB,KAAK,GAAE,OAAO,UAAU,CAAC,KAAmB;cAGhD,OAAO,CACrB,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,EAC5C,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,OAAO,CAAC;CAqKpB"}
|
|
@@ -1,256 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// Copyright (c) Mapbox, Inc.
|
|
3
|
+
// Licensed under the MIT License.
|
|
2
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DirectionsTool =
|
|
5
|
+
exports.DirectionsTool = void 0;
|
|
4
6
|
const node_url_1 = require("node:url");
|
|
5
|
-
const zod_1 = require("zod");
|
|
6
7
|
const MapboxApiBasedTool_js_1 = require("../MapboxApiBasedTool.js");
|
|
7
8
|
const cleanResponseData_js_1 = require("./cleanResponseData.js");
|
|
8
|
-
const
|
|
9
|
+
const dateUtils_js_1 = require("../../utils/dateUtils.js");
|
|
9
10
|
const fetchRequest_js_1 = require("../../utils/fetchRequest.js");
|
|
11
|
+
const DirectionsTool_schema_js_1 = require("./DirectionsTool.schema.js");
|
|
10
12
|
// Docs: https://docs.mapbox.com/api/navigation/directions/
|
|
11
|
-
/**
|
|
12
|
-
* Validates ISO 8601 date-time formats used by Mapbox Directions API
|
|
13
|
-
* for both depart_at and arrive_by parameters
|
|
14
|
-
*/
|
|
15
|
-
const validateIsoDateTime = (val, ctx) => {
|
|
16
|
-
if (!val)
|
|
17
|
-
return; // Optional, so empty is fine
|
|
18
|
-
// ISO 8601 regex patterns for the valid formats mentioned in the docs
|
|
19
|
-
// 1. YYYY-MM-DDThh:mm:ssZ (exactly one Z at the end)
|
|
20
|
-
// 2. YYYY-MM-DDThh:mm:ss±hh:mm (timezone offset with colon)
|
|
21
|
-
// 3. YYYY-MM-DDThh:mm (no seconds, no timezone)
|
|
22
|
-
// 4. YYYY-MM-DDThh:mm:ss (with seconds but no timezone) - will be converted to format 3
|
|
23
|
-
const iso8601Pattern = /^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$)|(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{2}:\d{2}$)|(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$)|(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$)/;
|
|
24
|
-
if (!iso8601Pattern.test(val)) {
|
|
25
|
-
ctx.addIssue({
|
|
26
|
-
code: zod_1.z.ZodIssueCode.custom,
|
|
27
|
-
message: 'Invalid date-time format. Must be in ISO 8601 format: YYYY-MM-DDThh:mm:ssZ, YYYY-MM-DDThh:mmss±hh:mm, YYYY-MM-DDThh:mm, or YYYY-MM-DDThh:mm:ss',
|
|
28
|
-
path: []
|
|
29
|
-
});
|
|
30
|
-
return; // Stop further validation if format is invalid
|
|
31
|
-
}
|
|
32
|
-
// Parse the date-time components to validate ranges
|
|
33
|
-
try {
|
|
34
|
-
// Extract date and time components
|
|
35
|
-
let dateTimeComponents;
|
|
36
|
-
if (val.includes('Z')) {
|
|
37
|
-
// Format 1: YYYY-MM-DDThh:mm:ssZ
|
|
38
|
-
dateTimeComponents = val.substring(0, val.indexOf('Z')).split('T');
|
|
39
|
-
}
|
|
40
|
-
else if (val.includes('+') || val.includes('-', 10)) {
|
|
41
|
-
// Check for timezone offset (skip the date's hyphens)
|
|
42
|
-
// Format 2: YYYY-MM-DDThh:mmss±hh:mm
|
|
43
|
-
const timezoneSeparatorIndex = Math.max(val.lastIndexOf('+'), val.lastIndexOf('-'));
|
|
44
|
-
dateTimeComponents = val.substring(0, timezoneSeparatorIndex).split('T');
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
// Format 3: YYYY-MM-DDThh:mm
|
|
48
|
-
dateTimeComponents = val.split('T');
|
|
49
|
-
}
|
|
50
|
-
const [datePart, timePart] = dateTimeComponents;
|
|
51
|
-
const [, month, day] = datePart.split('-').map(Number);
|
|
52
|
-
let hours = 0, minutes = 0, seconds = 0;
|
|
53
|
-
if (timePart.includes(':')) {
|
|
54
|
-
const timeParts = timePart.split(':').map(Number);
|
|
55
|
-
hours = timeParts[0];
|
|
56
|
-
minutes = timeParts[1];
|
|
57
|
-
if (timeParts.length > 2)
|
|
58
|
-
seconds = timeParts[2];
|
|
59
|
-
}
|
|
60
|
-
// Validate ranges
|
|
61
|
-
if (month < 1 || month > 12) {
|
|
62
|
-
ctx.addIssue({
|
|
63
|
-
code: zod_1.z.ZodIssueCode.custom,
|
|
64
|
-
message: `Invalid month: ${month}. Must be between 1 and 12.`,
|
|
65
|
-
path: []
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
// Check days in month (simplified - doesn't account for leap years)
|
|
69
|
-
const daysInMonth = [0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
70
|
-
if (day < 1 || day > daysInMonth[month]) {
|
|
71
|
-
ctx.addIssue({
|
|
72
|
-
code: zod_1.z.ZodIssueCode.custom,
|
|
73
|
-
message: `Invalid day: ${day}. Must be between 1 and ${daysInMonth[month]} for month ${month}.`,
|
|
74
|
-
path: []
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
if (hours < 0 || hours > 23) {
|
|
78
|
-
ctx.addIssue({
|
|
79
|
-
code: zod_1.z.ZodIssueCode.custom,
|
|
80
|
-
message: `Invalid hours: ${hours}. Must be between 0 and 23.`,
|
|
81
|
-
path: []
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
if (minutes < 0 || minutes > 59) {
|
|
85
|
-
ctx.addIssue({
|
|
86
|
-
code: zod_1.z.ZodIssueCode.custom,
|
|
87
|
-
message: `Invalid minutes: ${minutes}. Must be between 0 and 59.`,
|
|
88
|
-
path: []
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
if (seconds < 0 || seconds > 59) {
|
|
92
|
-
ctx.addIssue({
|
|
93
|
-
code: zod_1.z.ZodIssueCode.custom,
|
|
94
|
-
message: `Invalid seconds: ${seconds}. Must be between 0 and 59.`,
|
|
95
|
-
path: []
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
catch (error) {
|
|
100
|
-
ctx.addIssue({
|
|
101
|
-
code: zod_1.z.ZodIssueCode.custom,
|
|
102
|
-
message: `Error parsing date-time components: ${error}`,
|
|
103
|
-
path: []
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
exports.DirectionsInputSchema = zod_1.z.object({
|
|
108
|
-
coordinates: zod_1.z
|
|
109
|
-
.array(zod_1.z.object({
|
|
110
|
-
longitude: zod_1.z
|
|
111
|
-
.number()
|
|
112
|
-
.min(-180, 'Longitude must be between -180 and 180 degrees')
|
|
113
|
-
.max(180, 'Longitude must be between -180 and 180 degrees'),
|
|
114
|
-
latitude: zod_1.z
|
|
115
|
-
.number()
|
|
116
|
-
.min(-90, 'Latitude must be between -90 and 90 degrees')
|
|
117
|
-
.max(90, 'Latitude must be between -90 and 90 degrees')
|
|
118
|
-
}))
|
|
119
|
-
.min(2, 'At least two coordinate pairs are required.')
|
|
120
|
-
.max(25, 'Up to 25 coordinate pairs are supported.')
|
|
121
|
-
.describe('Array of coordinate objects with longitude and latitude properties to visit in order. ' +
|
|
122
|
-
'Must include at least 2 coordinate pairs (starting and ending points). ' +
|
|
123
|
-
'Up to 25 coordinates total are supported.'),
|
|
124
|
-
routing_profile: zod_1.z
|
|
125
|
-
.enum(['driving-traffic', 'driving', 'walking', 'cycling'])
|
|
126
|
-
.optional()
|
|
127
|
-
.default('driving-traffic')
|
|
128
|
-
.describe('Routing profile for different modes of transport. Options: \n' +
|
|
129
|
-
'- driving-traffic (default): automotive with current traffic conditions\n' +
|
|
130
|
-
'- driving: automotive based on typical traffic\n' +
|
|
131
|
-
'- walking: pedestrian/hiking\n' +
|
|
132
|
-
'- cycling: bicycle'),
|
|
133
|
-
geometries: zod_1.z
|
|
134
|
-
.enum(['none', 'geojson'])
|
|
135
|
-
.optional()
|
|
136
|
-
.default('none')
|
|
137
|
-
.describe('The format of the returned geometry. Options: \n' +
|
|
138
|
-
'- none (default): no geometry object is returned at all, use this if you do not need all of the intermediate coordinates.\n' +
|
|
139
|
-
'- geojson: as GeoJSON LineString (might be very long as there could be a lot of points)'),
|
|
140
|
-
max_height: zod_1.z
|
|
141
|
-
.number()
|
|
142
|
-
.min(0, 'Vehicle height must be between 0 and 10 meters')
|
|
143
|
-
.max(10, 'Vehicle height must be between 0 and 10 meters')
|
|
144
|
-
.optional()
|
|
145
|
-
.describe('The max vehicle height, in meters. The Directions API will compute a route that includes only roads ' +
|
|
146
|
-
'with a height limit greater than or equal to the max vehicle height. ' +
|
|
147
|
-
'Must be between 0 and 10 meters. The default value is 1.6 meters. ' +
|
|
148
|
-
'Only available for driving and driving-traffic profiles.'),
|
|
149
|
-
max_width: zod_1.z
|
|
150
|
-
.number()
|
|
151
|
-
.min(0, 'Vehicle width must be between 0 and 10 meters')
|
|
152
|
-
.max(10, 'Vehicle width must be between 0 and 10 meters')
|
|
153
|
-
.optional()
|
|
154
|
-
.describe('The max vehicle width, in meters. The Directions API will compute a route that includes only roads ' +
|
|
155
|
-
'with a width limit greater than or equal to the max vehicle width. ' +
|
|
156
|
-
'Must be between 0 and 10 meters. The default value is 1.9 meters. ' +
|
|
157
|
-
'Only available for driving and driving-traffic profiles.'),
|
|
158
|
-
max_weight: zod_1.z
|
|
159
|
-
.number()
|
|
160
|
-
.min(0, 'Vehicle weight must be between 0 and 100 metric tons')
|
|
161
|
-
.max(100, 'Vehicle weight must be between 0 and 100 metric tons')
|
|
162
|
-
.optional()
|
|
163
|
-
.describe('The max vehicle weight, in metric tons (1000 kg). The Directions API will compute a route that includes only roads ' +
|
|
164
|
-
'with a weight limit greater than or equal to the max vehicle weight. ' +
|
|
165
|
-
'Must be between 0 and 100 metric tons. The default value is 2.5 metric tons. ' +
|
|
166
|
-
'Only available for driving and driving-traffic profiles.'),
|
|
167
|
-
alternatives: zod_1.z
|
|
168
|
-
.boolean()
|
|
169
|
-
.optional()
|
|
170
|
-
.default(false)
|
|
171
|
-
.describe('Whether to try to return alternative routes (true) or not (false, default). ' +
|
|
172
|
-
'Up to two alternatives may be returned.'),
|
|
173
|
-
depart_at: zod_1.z
|
|
174
|
-
.string()
|
|
175
|
-
.optional()
|
|
176
|
-
.superRefine(validateIsoDateTime)
|
|
177
|
-
.describe('The departure time in ISO 8601 format (YYYY-MM-DDThh:mm:ssZ, YYYY-MM-DDThh:mmss±hh:mm, or YYYY-MM-DDThh:mm). ' +
|
|
178
|
-
'This parameter is only available for the driving and driving-traffic profiles. ' +
|
|
179
|
-
'The travel time will be calculated based on historical and real-time traffic data.'),
|
|
180
|
-
arrive_by: zod_1.z
|
|
181
|
-
.string()
|
|
182
|
-
.optional()
|
|
183
|
-
.superRefine(validateIsoDateTime)
|
|
184
|
-
.describe('The desired arrival time in ISO 8601 format (YYYY-MM-DDThh:mm:ssZ, YYYY-MM-DDThh:mmss±hh:mm, or YYYY-MM-DDThh:mm). ' +
|
|
185
|
-
'This parameter is only available for the driving profile and is not supported by other profiles, not even driving-traffic. ' +
|
|
186
|
-
'The travel time will be calculated based on historical and real-time traffic data.'),
|
|
187
|
-
exclude: zod_1.z
|
|
188
|
-
.string()
|
|
189
|
-
.optional()
|
|
190
|
-
.superRefine((val, ctx) => {
|
|
191
|
-
if (!val)
|
|
192
|
-
return; // Optional, so empty is fine
|
|
193
|
-
const items = val.split(',').map((item) => item.trim());
|
|
194
|
-
for (const item of items) {
|
|
195
|
-
// Check if it's a point exclusion
|
|
196
|
-
if (item.startsWith('point(') && item.endsWith(')')) {
|
|
197
|
-
const coordStr = item.substring(6, item.length - 1).trim();
|
|
198
|
-
const [lngStr, latStr] = coordStr.split(' ');
|
|
199
|
-
// Validate both parts exist
|
|
200
|
-
if (!lngStr || !latStr) {
|
|
201
|
-
ctx.addIssue({
|
|
202
|
-
code: zod_1.z.ZodIssueCode.custom,
|
|
203
|
-
message: `Invalid point format in exclude parameter: '${item}'. Format should be point(<lng> <lat>)`,
|
|
204
|
-
path: []
|
|
205
|
-
});
|
|
206
|
-
continue;
|
|
207
|
-
}
|
|
208
|
-
// Parse and validate longitude
|
|
209
|
-
const lng = Number(lngStr);
|
|
210
|
-
if (isNaN(lng) || lng < -180 || lng > 180) {
|
|
211
|
-
ctx.addIssue({
|
|
212
|
-
code: zod_1.z.ZodIssueCode.custom,
|
|
213
|
-
message: `Invalid longitude in exclude parameter: '${lngStr}'. Must be a number between -180 and 180`,
|
|
214
|
-
path: []
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
// Parse and validate latitude
|
|
218
|
-
const lat = Number(latStr);
|
|
219
|
-
if (isNaN(lat) || lat < -90 || lat > 90) {
|
|
220
|
-
ctx.addIssue({
|
|
221
|
-
code: zod_1.z.ZodIssueCode.custom,
|
|
222
|
-
message: `Invalid latitude in exclude parameter: '${latStr}'. Must be a number between -90 and 90`,
|
|
223
|
-
path: []
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
// Check if it's one of the enum values
|
|
228
|
-
else if (![
|
|
229
|
-
'toll',
|
|
230
|
-
'cash_only_tolls',
|
|
231
|
-
'motorway',
|
|
232
|
-
'ferry',
|
|
233
|
-
'unpaved',
|
|
234
|
-
'tunnel',
|
|
235
|
-
'country_border',
|
|
236
|
-
'state_border'
|
|
237
|
-
].includes(item)) {
|
|
238
|
-
ctx.addIssue({
|
|
239
|
-
code: zod_1.z.ZodIssueCode.custom,
|
|
240
|
-
message: `Invalid exclude option: '${item}'. Available options are: toll, motorway, ferry, unpaved, tunnel, country_border, state_border, or point(<lng> <lat>)`,
|
|
241
|
-
path: []
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
})
|
|
246
|
-
.describe('Whether to exclude certain road types and custom locations from routing. ' +
|
|
247
|
-
'Multiple values can be specified as a comma-separated list. ' +
|
|
248
|
-
'Available options:\n' +
|
|
249
|
-
'- All profiles: ferry, cash_only_tolls\n' +
|
|
250
|
-
'- Driving/Driving-traffic profiles only: motorway, toll, unpaved, tunnel, country_border, state_border or point(<lng> <lat>)\n' +
|
|
251
|
-
'For custom locations you can use Point exclusions (note lng and lat are space separated and at most 50 points are allowed)\n' +
|
|
252
|
-
'Note: country_border excludes all controlled country borders; borders within the Schengen Area are not excluded.')
|
|
253
|
-
});
|
|
254
13
|
class DirectionsTool extends MapboxApiBasedTool_js_1.MapboxApiBasedTool {
|
|
255
14
|
fetch;
|
|
256
15
|
name = 'directions_tool';
|
|
@@ -263,7 +22,7 @@ class DirectionsTool extends MapboxApiBasedTool_js_1.MapboxApiBasedTool {
|
|
|
263
22
|
openWorldHint: true
|
|
264
23
|
};
|
|
265
24
|
constructor(fetch = fetchRequest_js_1.fetchClient) {
|
|
266
|
-
super({ inputSchema:
|
|
25
|
+
super({ inputSchema: DirectionsTool_schema_js_1.DirectionsInputSchema });
|
|
267
26
|
this.fetch = fetch;
|
|
268
27
|
}
|
|
269
28
|
async execute(input, accessToken) {
|
|
@@ -348,11 +107,11 @@ class DirectionsTool extends MapboxApiBasedTool_js_1.MapboxApiBasedTool {
|
|
|
348
107
|
queryParams.append('overview', 'full');
|
|
349
108
|
// Add depart_at or arrive_by parameter if provided, converting format if needed
|
|
350
109
|
if (input.depart_at) {
|
|
351
|
-
const formattedDateTime = (0,
|
|
110
|
+
const formattedDateTime = (0, dateUtils_js_1.formatIsoDateTime)(input.depart_at);
|
|
352
111
|
queryParams.append('depart_at', formattedDateTime);
|
|
353
112
|
}
|
|
354
113
|
else if (input.arrive_by) {
|
|
355
|
-
const formattedDateTime = (0,
|
|
114
|
+
const formattedDateTime = (0, dateUtils_js_1.formatIsoDateTime)(input.arrive_by);
|
|
356
115
|
queryParams.append('arrive_by', formattedDateTime);
|
|
357
116
|
}
|
|
358
117
|
// Add vehicle dimension parameters if provided
|