nextbillion-mcp 0.1.6 → 0.1.7

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.
Files changed (70) hide show
  1. package/dist/index.js +21391 -38
  2. package/package.json +6 -7
  3. package/dist/config.d.ts +0 -17
  4. package/dist/config.js +0 -32
  5. package/dist/config.js.map +0 -1
  6. package/dist/core/server.d.ts +0 -13
  7. package/dist/core/server.js +0 -62
  8. package/dist/core/server.js.map +0 -1
  9. package/dist/index.d.ts +0 -2
  10. package/dist/index.js.map +0 -1
  11. package/dist/log.d.ts +0 -7
  12. package/dist/log.js +0 -13
  13. package/dist/log.js.map +0 -1
  14. package/dist/nbclient/client.d.ts +0 -39
  15. package/dist/nbclient/client.js +0 -124
  16. package/dist/nbclient/client.js.map +0 -1
  17. package/dist/nbclient/errors.d.ts +0 -13
  18. package/dist/nbclient/errors.js +0 -36
  19. package/dist/nbclient/errors.js.map +0 -1
  20. package/dist/tools/index.d.ts +0 -7
  21. package/dist/tools/index.js +0 -35
  22. package/dist/tools/index.js.map +0 -1
  23. package/dist/tools/maps/polyline.d.ts +0 -16
  24. package/dist/tools/maps/polyline.js +0 -117
  25. package/dist/tools/maps/polyline.js.map +0 -1
  26. package/dist/tools/maps/static-map-image.d.ts +0 -25
  27. package/dist/tools/maps/static-map-image.js +0 -31
  28. package/dist/tools/maps/static-map-image.js.map +0 -1
  29. package/dist/tools/maps/static-route-map.d.ts +0 -28
  30. package/dist/tools/maps/static-route-map.js +0 -101
  31. package/dist/tools/maps/static-route-map.js.map +0 -1
  32. package/dist/tools/maps/static-shared.d.ts +0 -35
  33. package/dist/tools/maps/static-shared.js +0 -91
  34. package/dist/tools/maps/static-shared.js.map +0 -1
  35. package/dist/tools/places/geocode-batch.d.ts +0 -43
  36. package/dist/tools/places/geocode-batch.js +0 -54
  37. package/dist/tools/places/geocode-batch.js.map +0 -1
  38. package/dist/tools/places/geocode-reverse.d.ts +0 -30
  39. package/dist/tools/places/geocode-reverse.js +0 -33
  40. package/dist/tools/places/geocode-reverse.js.map +0 -1
  41. package/dist/tools/places/geocode-structured.d.ts +0 -40
  42. package/dist/tools/places/geocode-structured.js +0 -61
  43. package/dist/tools/places/geocode-structured.js.map +0 -1
  44. package/dist/tools/places/place-lookup.d.ts +0 -19
  45. package/dist/tools/places/place-lookup.js +0 -24
  46. package/dist/tools/places/place-lookup.js.map +0 -1
  47. package/dist/tools/places/postcode-lookup.d.ts +0 -13
  48. package/dist/tools/places/postcode-lookup.js +0 -56
  49. package/dist/tools/places/postcode-lookup.js.map +0 -1
  50. package/dist/tools/places/text-search.d.ts +0 -128
  51. package/dist/tools/places/text-search.js +0 -80
  52. package/dist/tools/places/text-search.js.map +0 -1
  53. package/dist/tools/routing/directions.d.ts +0 -59
  54. package/dist/tools/routing/directions.js +0 -116
  55. package/dist/tools/routing/directions.js.map +0 -1
  56. package/dist/tools/routing/distance-matrix.d.ts +0 -43
  57. package/dist/tools/routing/distance-matrix.js +0 -82
  58. package/dist/tools/routing/distance-matrix.js.map +0 -1
  59. package/dist/tools/routing/isochrone.d.ts +0 -22
  60. package/dist/tools/routing/isochrone.js +0 -67
  61. package/dist/tools/routing/isochrone.js.map +0 -1
  62. package/dist/tools/routing/search-along-route.d.ts +0 -17
  63. package/dist/tools/routing/search-along-route.js +0 -58
  64. package/dist/tools/routing/search-along-route.js.map +0 -1
  65. package/dist/tools/shared/geo.d.ts +0 -89
  66. package/dist/tools/shared/geo.js +0 -100
  67. package/dist/tools/shared/geo.js.map +0 -1
  68. package/dist/tools/types.d.ts +0 -46
  69. package/dist/tools/types.js +0 -23
  70. package/dist/tools/types.js.map +0 -1
@@ -1,24 +0,0 @@
1
- import * as z from 'zod/v4';
2
- import { summarizePlaces, ViewSchema } from '../shared/geo.js';
3
- import { READ_ONLY, textResult } from '../types.js';
4
- const Schema = z.object({
5
- id: z.string().min(1).describe('Unique place id, as returned by the other place/geocoding tools'),
6
- view: ViewSchema.optional(),
7
- });
8
- export const placeLookup = {
9
- name: 'place_lookup',
10
- title: 'Place Lookup',
11
- description: 'Fetch the full details (address, position, access points, categories, contacts) of a place ' +
12
- 'by its unique id. Ids come from the results of place_search, geocode_forward, autosuggest, ' +
13
- 'autocomplete, or search_along_route.',
14
- inputSchema: Schema,
15
- annotations: READ_ONLY,
16
- async run(args, nb) {
17
- const response = await nb.getJson('/lookup', {
18
- id: args.id,
19
- view: args.view,
20
- });
21
- return textResult(summarizePlaces(response, 'place'), response);
22
- },
23
- };
24
- //# sourceMappingURL=place-lookup.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"place-lookup.js","sourceRoot":"","sources":["../../../src/tools/places/place-lookup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,UAAU,EAAe,MAAM,aAAa,CAAC;AAEjE,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;IACtB,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,iEAAiE,CAAC;IACjG,IAAI,EAAE,UAAU,CAAC,QAAQ,EAAE;CAC5B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,WAAW,GAA0B;IAChD,IAAI,EAAE,cAAc;IACpB,KAAK,EAAE,cAAc;IACrB,WAAW,EACT,6FAA6F;QAC7F,6FAA6F;QAC7F,sCAAsC;IACxC,WAAW,EAAE,MAAM;IACnB,WAAW,EAAE,SAAS;IACtB,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE;QAChB,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,OAAO,CAA0B,SAAS,EAAE;YACpE,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC,CAAC;QACH,OAAO,UAAU,CAAC,eAAe,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,CAAC;IAClE,CAAC;CACF,CAAC"}
@@ -1,13 +0,0 @@
1
- import * as z from 'zod/v4';
2
- import { type NbTool } from '../types.js';
3
- declare const Schema: z.ZodObject<{
4
- postal_code: z.ZodOptional<z.ZodString>;
5
- country: z.ZodOptional<z.ZodString>;
6
- coordinate: z.ZodOptional<z.ZodObject<{
7
- latitude: z.ZodNumber;
8
- longitude: z.ZodNumber;
9
- }, z.core.$strip>>;
10
- geojson_boundary: z.ZodOptional<z.ZodBoolean>;
11
- }, z.core.$strip>;
12
- export declare const postcodeLookup: NbTool<typeof Schema>;
13
- export {};
@@ -1,56 +0,0 @@
1
- import * as z from 'zod/v4';
2
- import { CoordinateSchema } from '../shared/geo.js';
3
- import { READ_ONLY, textResult, ToolInputError } from '../types.js';
4
- const Schema = z.object({
5
- postal_code: z
6
- .string()
7
- .optional()
8
- .describe('Postal/ZIP code to look up (requires `country`; do not combine with `coordinate`)'),
9
- country: z
10
- .string()
11
- .optional()
12
- .describe('Country of the postal code — name, alpha-2, or alpha-3 ISO code. Required with `postal_code`'),
13
- coordinate: CoordinateSchema.optional().describe('Find the postal code containing this location (alternative to `postal_code`)'),
14
- geojson_boundary: z
15
- .boolean()
16
- .optional()
17
- .describe('Return the boundary polygon in GeoJSON format instead of the default point-list format'),
18
- });
19
- const SUPPORTED_COUNTRIES = 'USA, India, UK, Netherlands, Austria, Germany, Indonesia, France, Singapore, Philippines, ' +
20
- 'Canada, Australia, New Zealand, Italy, Brazil, Mexico, Spain';
21
- export const postcodeLookup = {
22
- name: 'postcode_lookup',
23
- title: 'Postcode Lookup',
24
- description: 'Get the centroid and boundary polygon of a postal/ZIP code, or find which postal code a ' +
25
- `coordinate belongs to. One lookup per call. Supported countries: ${SUPPORTED_COUNTRIES}.`,
26
- inputSchema: Schema,
27
- annotations: READ_ONLY,
28
- async run(args, nb) {
29
- if (args.postal_code && args.coordinate) {
30
- throw new ToolInputError('Provide either `postal_code` or `coordinate`, not both.');
31
- }
32
- if (!args.postal_code && !args.coordinate) {
33
- throw new ToolInputError('Provide `postal_code` (with `country`) or `coordinate`.');
34
- }
35
- if (args.postal_code && !args.country) {
36
- throw new ToolInputError('`country` is required when `postal_code` is provided.');
37
- }
38
- const response = await nb.postJson('/postalcode', {}, {
39
- postalcode: args.postal_code,
40
- country: args.country,
41
- at: args.coordinate
42
- ? { lat: args.coordinate.latitude, lng: args.coordinate.longitude }
43
- : undefined,
44
- format: args.geojson_boundary ? 'geojson' : undefined,
45
- });
46
- const places = response.places;
47
- const place = Array.isArray(places) ? places[0] : undefined;
48
- const geopoint = place?.geopoint;
49
- const summary = place
50
- ? `Postal code ${place.postalCode} (${place.address ?? place.country}), centroid ` +
51
- `(${geopoint?.lat}, ${geopoint?.lng}), boundary included in structured content.`
52
- : 'No postal code found.';
53
- return textResult(summary, response);
54
- },
55
- };
56
- //# sourceMappingURL=postcode-lookup.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"postcode-lookup.js","sourceRoot":"","sources":["../../../src/tools/places/postcode-lookup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,cAAc,EAAe,MAAM,aAAa,CAAC;AAEjF,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;IACtB,WAAW,EAAE,CAAC;SACX,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CAAC,mFAAmF,CAAC;IAChG,OAAO,EAAE,CAAC;SACP,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CACP,8FAA8F,CAC/F;IACH,UAAU,EAAE,gBAAgB,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAC9C,8EAA8E,CAC/E;IACD,gBAAgB,EAAE,CAAC;SAChB,OAA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GAAI,QAAwD,CAAC,MAAM,CAAC;QAChF,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC5D,MAAM,QAAQ,GAAG,KAAK,EAAE,QAA+C,CAAC;QACxE,MAAM,OAAO,GAAG,KAAK;YACnB,CAAC,CAAC,eAAe,KAAK,CAAC,UAAU,KAAK,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,cAAc;gBAChF,IAAI,QAAQ,EAAE,GAAG,KAAK,QAAQ,EAAE,GAAG,6CAA6C;YAClF,CAAC,CAAC,uBAAuB,CAAC;QAC5B,OAAO,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACvC,CAAC;CACF,CAAC"}
@@ -1,128 +0,0 @@
1
- import * as z from 'zod/v4';
2
- import { type NbTool } from '../types.js';
3
- declare const ForwardGeocodeSchema: z.ZodObject<{
4
- near: z.ZodOptional<z.ZodObject<{
5
- latitude: z.ZodNumber;
6
- longitude: z.ZodNumber;
7
- }, z.core.$strip>>;
8
- radius_m: z.ZodOptional<z.ZodNumber>;
9
- country_codes: z.ZodOptional<z.ZodArray<z.ZodString>>;
10
- bounding_box: z.ZodOptional<z.ZodObject<{
11
- west: z.ZodNumber;
12
- south: z.ZodNumber;
13
- east: z.ZodNumber;
14
- north: z.ZodNumber;
15
- }, z.core.$strip>>;
16
- limit: z.ZodOptional<z.ZodNumber>;
17
- language: z.ZodOptional<z.ZodString>;
18
- view: z.ZodOptional<z.ZodEnum<{
19
- AR: "AR";
20
- CN: "CN";
21
- IL: "IL";
22
- IN: "IN";
23
- MA: "MA";
24
- PK: "PK";
25
- RU: "RU";
26
- TR: "TR";
27
- TW: "TW";
28
- Unified: "Unified";
29
- }>>;
30
- query: z.ZodString;
31
- types: z.ZodOptional<z.ZodArray<z.ZodEnum<{
32
- addressBlock: "addressBlock";
33
- area: "area";
34
- houseNumber: "houseNumber";
35
- intersection: "intersection";
36
- place: "place";
37
- street: "street";
38
- }>>>;
39
- }, z.core.$strip>;
40
- export declare const geocodeForward: NbTool<typeof ForwardGeocodeSchema>;
41
- export declare const placeSearch: NbTool<z.ZodObject<{
42
- near: z.ZodOptional<z.ZodObject<{
43
- latitude: z.ZodNumber;
44
- longitude: z.ZodNumber;
45
- }, z.core.$strip>>;
46
- radius_m: z.ZodOptional<z.ZodNumber>;
47
- country_codes: z.ZodOptional<z.ZodArray<z.ZodString>>;
48
- bounding_box: z.ZodOptional<z.ZodObject<{
49
- west: z.ZodNumber;
50
- south: z.ZodNumber;
51
- east: z.ZodNumber;
52
- north: z.ZodNumber;
53
- }, z.core.$strip>>;
54
- limit: z.ZodOptional<z.ZodNumber>;
55
- language: z.ZodOptional<z.ZodString>;
56
- view: z.ZodOptional<z.ZodEnum<{
57
- AR: "AR";
58
- CN: "CN";
59
- IL: "IL";
60
- IN: "IN";
61
- MA: "MA";
62
- PK: "PK";
63
- RU: "RU";
64
- TR: "TR";
65
- TW: "TW";
66
- Unified: "Unified";
67
- }>>;
68
- query: z.ZodString;
69
- }, z.core.$strip>>;
70
- export declare const autosuggest: NbTool<z.ZodObject<{
71
- near: z.ZodOptional<z.ZodObject<{
72
- latitude: z.ZodNumber;
73
- longitude: z.ZodNumber;
74
- }, z.core.$strip>>;
75
- radius_m: z.ZodOptional<z.ZodNumber>;
76
- country_codes: z.ZodOptional<z.ZodArray<z.ZodString>>;
77
- bounding_box: z.ZodOptional<z.ZodObject<{
78
- west: z.ZodNumber;
79
- south: z.ZodNumber;
80
- east: z.ZodNumber;
81
- north: z.ZodNumber;
82
- }, z.core.$strip>>;
83
- limit: z.ZodOptional<z.ZodNumber>;
84
- language: z.ZodOptional<z.ZodString>;
85
- view: z.ZodOptional<z.ZodEnum<{
86
- AR: "AR";
87
- CN: "CN";
88
- IL: "IL";
89
- IN: "IN";
90
- MA: "MA";
91
- PK: "PK";
92
- RU: "RU";
93
- TR: "TR";
94
- TW: "TW";
95
- Unified: "Unified";
96
- }>>;
97
- query: z.ZodString;
98
- }, z.core.$strip>>;
99
- export declare const autocomplete: NbTool<z.ZodObject<{
100
- near: z.ZodOptional<z.ZodObject<{
101
- latitude: z.ZodNumber;
102
- longitude: z.ZodNumber;
103
- }, z.core.$strip>>;
104
- radius_m: z.ZodOptional<z.ZodNumber>;
105
- country_codes: z.ZodOptional<z.ZodArray<z.ZodString>>;
106
- bounding_box: z.ZodOptional<z.ZodObject<{
107
- west: z.ZodNumber;
108
- south: z.ZodNumber;
109
- east: z.ZodNumber;
110
- north: z.ZodNumber;
111
- }, z.core.$strip>>;
112
- limit: z.ZodOptional<z.ZodNumber>;
113
- language: z.ZodOptional<z.ZodString>;
114
- view: z.ZodOptional<z.ZodEnum<{
115
- AR: "AR";
116
- CN: "CN";
117
- IL: "IL";
118
- IN: "IN";
119
- MA: "MA";
120
- PK: "PK";
121
- RU: "RU";
122
- TR: "TR";
123
- TW: "TW";
124
- Unified: "Unified";
125
- }>>;
126
- query: z.ZodString;
127
- }, z.core.$strip>>;
128
- export {};
@@ -1,80 +0,0 @@
1
- import * as z from 'zod/v4';
2
- import { placesFilterQuery, PlacesFilterShape, PlaceTypesSchema, summarizePlaces, } from '../shared/geo.js';
3
- import { READ_ONLY, textResult } from '../types.js';
4
- const TextSearchSchema = z.object({
5
- query: z.string().min(1).describe('Free-text search query'),
6
- ...PlacesFilterShape,
7
- });
8
- /**
9
- * place_search, autosuggest and autocomplete share the exact same request surface
10
- * (`q` + geographic filters) against different endpoints; only the ranking/matching
11
- * behavior differs. geocode_forward is defined separately below because it
12
- * additionally supports the `types` filter (which these endpoints do not).
13
- */
14
- function textSearchTool(options) {
15
- return {
16
- name: options.name,
17
- title: options.title,
18
- description: options.description,
19
- inputSchema: TextSearchSchema,
20
- annotations: READ_ONLY,
21
- async run(args, nb) {
22
- const response = await nb.getJson(options.path, {
23
- q: args.query,
24
- ...placesFilterQuery(args),
25
- });
26
- return textResult(summarizePlaces(response, options.noun), response);
27
- },
28
- };
29
- }
30
- const ForwardGeocodeSchema = z.object({
31
- query: z.string().min(1).describe('Free-text search query'),
32
- ...PlacesFilterShape,
33
- types: PlaceTypesSchema.optional(),
34
- });
35
- export const geocodeForward = {
36
- name: 'geocode_forward',
37
- title: 'Forward Geocode',
38
- description: 'Convert a free-text address, place name, locality, or administrative area into geographic ' +
39
- 'coordinates and a complete postal address. Tolerates incomplete or partly incorrect queries. ' +
40
- 'Provide `near`, `country_codes`, or `bounding_box` for more relevant results. ' +
41
- 'For many addresses at once use geocode_batch; for POI/business search use place_search.',
42
- inputSchema: ForwardGeocodeSchema,
43
- annotations: READ_ONLY,
44
- async run(args, nb) {
45
- const response = await nb.getJson('/geocode', {
46
- q: args.query,
47
- ...placesFilterQuery(args),
48
- types: args.types?.join(','),
49
- });
50
- return textResult(summarizePlaces(response, 'match'), response);
51
- },
52
- };
53
- export const placeSearch = textSearchTool({
54
- name: 'place_search',
55
- title: 'Search Places',
56
- description: 'Search for places, points of interest, and businesses with a free-text query (e.g. ' +
57
- '"gas station", "coffee near the station"), ranked by relevance. Provide `near`, ' +
58
- '`country_codes`, or `bounding_box` to anchor the search. For plain address-to-coordinates ' +
59
- 'conversion use geocode_forward instead.',
60
- path: '/discover',
61
- noun: 'place',
62
- });
63
- export const autosuggest = textSearchTool({
64
- name: 'autosuggest',
65
- title: 'Autosuggest',
66
- description: 'Suggest address and place candidates from an incomplete or misspelled query (typo-tolerant, ' +
67
- 'e.g. "aqaurium" still matches aquariums). Intended for search-as-you-type experiences. ' +
68
- 'For prefix completion of valid addresses use autocomplete.',
69
- path: '/autosuggest',
70
- noun: 'suggestion',
71
- });
72
- export const autocomplete = textSearchTool({
73
- name: 'autocomplete',
74
- title: 'Autocomplete',
75
- description: 'Complete valid street addresses and administrative areas from a partial query prefix ' +
76
- '(e.g. "stat" → "State Capitol…"). For typo-tolerant fuzzy suggestions use autosuggest.',
77
- path: '/autocomplete',
78
- noun: 'completion',
79
- });
80
- //# sourceMappingURL=text-search.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"text-search.js","sourceRoot":"","sources":["../../../src/tools/places/text-search.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,UAAU,EAAe,MAAM,aAAa,CAAC;AAEjE,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,wBAAwB,CAAC;IAC3D,GAAG,iBAAiB;CACrB,CAAC,CAAC;AAEH;;;;;GAKG;AACH,SAAS,cAAc,CAAC,OAMvB;IACC,OAAO;QACL,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,WAAW,EAAE,gBAAgB;QAC7B,WAAW,EAAE,SAAS;QACtB,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE;YAChB,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,OAAO,CAA0B,OAAO,CAAC,IAAI,EAAE;gBACvE,CAAC,EAAE,IAAI,CAAC,KAAK;gBACb,GAAG,iBAAiB,CAAC,IAAI,CAAC;aAC3B,CAAC,CAAC;YACH,OAAO,UAAU,CAAC,eAAe,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,CAAC;QACvE,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,w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EAAE,cAAc;IACrB,WAAW,EACT,uFAAuF;QACvF,wFAAwF;IAC1F,IAAI,EAAE,eAAe;IACrB,IAAI,EAAE,YAAY;CACnB,CAAC,CAAC"}
@@ -1,59 +0,0 @@
1
- import * as z from 'zod/v4';
2
- import { type NbTool } from '../types.js';
3
- declare const Schema: z.ZodObject<{
4
- origin: z.ZodObject<{
5
- latitude: z.ZodNumber;
6
- longitude: z.ZodNumber;
7
- }, z.core.$strip>;
8
- destination: z.ZodObject<{
9
- latitude: z.ZodNumber;
10
- longitude: z.ZodNumber;
11
- }, z.core.$strip>;
12
- waypoints: z.ZodOptional<z.ZodArray<z.ZodObject<{
13
- latitude: z.ZodNumber;
14
- longitude: z.ZodNumber;
15
- }, z.core.$strip>>>;
16
- mode: z.ZodOptional<z.ZodEnum<{
17
- bike: "bike";
18
- car: "car";
19
- motorcycle: "motorcycle";
20
- truck: "truck";
21
- walk: "walk";
22
- }>>;
23
- service: z.ZodOptional<z.ZodEnum<{
24
- fast: "fast";
25
- flexible: "flexible";
26
- }>>;
27
- route_type: z.ZodOptional<z.ZodEnum<{
28
- fastest: "fastest";
29
- shortest: "shortest";
30
- }>>;
31
- departure_time: z.ZodOptional<z.ZodNumber>;
32
- avoid: z.ZodOptional<z.ZodArray<z.ZodEnum<{
33
- ferry: "ferry";
34
- highway: "highway";
35
- left_turn: "left_turn";
36
- none: "none";
37
- right_turn: "right_turn";
38
- service_road: "service_road";
39
- sharp_turn: "sharp_turn";
40
- toll: "toll";
41
- tunnel: "tunnel";
42
- uturn: "uturn";
43
- }>>>;
44
- honor_restrictions: z.ZodOptional<z.ZodBoolean>;
45
- alternatives: z.ZodOptional<z.ZodBoolean>;
46
- steps: z.ZodOptional<z.ZodBoolean>;
47
- geometry: z.ZodOptional<z.ZodEnum<{
48
- polyline: "polyline";
49
- polyline6: "polyline6";
50
- }>>;
51
- truck_size_cm: z.ZodOptional<z.ZodObject<{
52
- height: z.ZodNumber;
53
- width: z.ZodNumber;
54
- length: z.ZodNumber;
55
- }, z.core.$strip>>;
56
- truck_weight_kg: z.ZodOptional<z.ZodNumber>;
57
- }, z.core.$strip>;
58
- export declare const directions: NbTool<typeof Schema>;
59
- export {};
@@ -1,116 +0,0 @@
1
- import * as z from 'zod/v4';
2
- import { CoordinateSchema, toLatLng, toLatLngList } from '../shared/geo.js';
3
- import { READ_ONLY, textResult, ToolInputError } from '../types.js';
4
- const AVOID_VALUES = [
5
- 'toll',
6
- 'highway',
7
- 'ferry',
8
- 'sharp_turn',
9
- 'uturn',
10
- 'service_road',
11
- 'left_turn',
12
- 'right_turn',
13
- 'tunnel',
14
- 'none',
15
- ];
16
- const Schema = z.object({
17
- origin: CoordinateSchema.describe('Route start (must be a routable land location)'),
18
- destination: CoordinateSchema.describe('Route end (must be a routable land location)'),
19
- waypoints: z
20
- .array(CoordinateSchema)
21
- .max(200)
22
- .optional()
23
- .describe('Intermediate stops visited in order (max 200)'),
24
- mode: z
25
- .enum(['car', 'truck', 'motorcycle', 'bike', 'walk'])
26
- .optional()
27
- .describe('Travel mode (default car). Modes other than car/truck require service=flexible'),
28
- service: z
29
- .enum(['flexible', 'fast'])
30
- .optional()
31
- .describe('API variant: "flexible" (default) supports all modes, departure_time, route_type, full ' +
32
- 'avoid list and truck options; "fast" is lower latency but limited to car/truck and ' +
33
- 'avoid toll/ferry/highway only'),
34
- route_type: z
35
- .enum(['fastest', 'shortest'])
36
- .optional()
37
- .describe('Optimization objective (flexible only, default fastest)'),
38
- departure_time: z
39
- .number()
40
- .int()
41
- .optional()
42
- .describe('Departure as a UNIX timestamp in seconds, for typical-traffic routing (flexible only)'),
43
- avoid: z
44
- .array(z.enum(AVOID_VALUES))
45
- .optional()
46
- .describe('Road features to avoid when alternatives exist. Fast service supports only toll/ferry/highway'),
47
- honor_restrictions: z
48
- .boolean()
49
- .optional()
50
- .describe('When true, enforce restricted-area rules: no route is generated if origin, destination, ' +
51
- 'or a waypoint is inside a restricted area. Default false: route anyway with a warning ' +
52
- '(flexible service only)'),
53
- alternatives: z
54
- .boolean()
55
- .optional()
56
- .describe('Return up to 3 alternative routes (only without waypoints)'),
57
- steps: z.boolean().optional().describe('Include turn-by-turn steps (fast service only)'),
58
- geometry: z
59
- .enum(['polyline', 'polyline6'])
60
- .optional()
61
- .describe('Route geometry encoding (default polyline, precision 5 — directly usable with static_route_map)'),
62
- truck_size_cm: z
63
- .object({ height: z.number(), width: z.number(), length: z.number() })
64
- .optional()
65
- .describe('Truck dimensions in cm (flexible + mode=truck only)'),
66
- truck_weight_kg: z
67
- .number()
68
- .int()
69
- .max(100_000)
70
- .optional()
71
- .describe('Truck gross weight in kg (flexible + mode=truck only)'),
72
- });
73
- export const directions = {
74
- name: 'directions',
75
- title: 'Directions',
76
- description: 'Calculate a route between two points with optional intermediate waypoints. Returns distance ' +
77
- '(meters), duration (seconds), and encoded polyline geometry per route; pass the geometry to ' +
78
- 'static_route_map to render it. Traffic-aware.',
79
- inputSchema: Schema,
80
- annotations: READ_ONLY,
81
- async run(args, nb) {
82
- const service = args.service ?? 'flexible';
83
- if (service === 'fast' && args.mode && args.mode !== 'car' && args.mode !== 'truck') {
84
- throw new ToolInputError(`mode=${args.mode} requires service=flexible.`);
85
- }
86
- // POST accepts up to 200 waypoints and avoids URL-length limits; params match GET.
87
- const response = await nb.postJson('/directions/json', service === 'flexible' ? { option: 'flexible' } : {}, {
88
- origin: toLatLng(args.origin),
89
- destination: toLatLng(args.destination),
90
- waypoints: args.waypoints?.length ? toLatLngList(args.waypoints) : undefined,
91
- mode: args.mode,
92
- route_type: args.route_type,
93
- departure_time: args.departure_time,
94
- avoid: args.avoid?.length ? args.avoid.join('|') : undefined,
95
- honor_restrictions: args.honor_restrictions,
96
- alternatives: args.alternatives,
97
- altcount: args.alternatives ? 3 : undefined,
98
- steps: service === 'fast' ? args.steps : undefined,
99
- geometry: args.geometry ?? 'polyline',
100
- truck_size: args.truck_size_cm
101
- ? `${args.truck_size_cm.height},${args.truck_size_cm.width},${args.truck_size_cm.length}`
102
- : undefined,
103
- truck_weight: args.truck_weight_kg,
104
- });
105
- const routes = response.routes ?? [];
106
- const lines = routes.map((route, index) => {
107
- const km = typeof route.distance === 'number' ? (route.distance / 1000).toFixed(1) : '?';
108
- const minutes = typeof route.duration === 'number' ? Math.round(route.duration / 60) : '?';
109
- return `Route ${index + 1}: ${km} km, ~${minutes} min`;
110
- });
111
- return textResult(lines.length > 0
112
- ? `${lines.join('\n')}\nGeometry (encoded polyline) is in structured content.`
113
- : 'No route found.', response);
114
- },
115
- };
116
- //# sourceMappingURL=directions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"directions.js","sourceRoot":"","sources":["../../../src/tools/routing/directions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,cAAc,EAAe,MAAM,aAAa,CAAC;AAEjF,MAAM,YAAY,GAAG;IACnB,MAAM;IACN,SAAS;IACT,OAAO;IACP,YAAY;IACZ,OAAO;IACP,cAAc;IACd,WAAW;IACX,YAAY;IACZ,QAAQ;IACR,MAAM;CACE,CAAC;AAEX,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;IACtB,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,gDAAgD,CAAC;IACnF,WAAW,EAAE,gBAAgB,CAAC,QAAQ,CAAC,8CAA8C,CAAC;IACtF,SAAS,EAAE,CAAC;SACT,KAAK,CAAC,gBAAgB,CAAC;SACvB,GAAG,CAAC,GAAG,CAAC;SACR,QAAQ,EAAE;SACV,QAAQ,CAAC,+CAA+C,CAAC;IAC5D,IAAI,EAAE,CAAC;SACJ,IAAI,CAAC,CAAC,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;SACpD,QAAQ,EAAE;SACV,QAA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AAM,CAAC;QACzD,CAAC,CAAC,CAAC;QACH,OAAO,UAAU,CACf,KAAK,CAAC,MAAM,GAAG,CAAC;YACd,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,yDAAyD;YAC9E,CAAC,CAAC,iBAAiB,EACrB,QAAQ,CACT,CAAC;IACJ,CAAC;CACF,CAAC"}
@@ -1,43 +0,0 @@
1
- import * as z from 'zod/v4';
2
- import { type NbTool } from '../types.js';
3
- declare const Schema: z.ZodObject<{
4
- origins: z.ZodArray<z.ZodObject<{
5
- latitude: z.ZodNumber;
6
- longitude: z.ZodNumber;
7
- }, z.core.$strip>>;
8
- destinations: z.ZodArray<z.ZodObject<{
9
- latitude: z.ZodNumber;
10
- longitude: z.ZodNumber;
11
- }, z.core.$strip>>;
12
- mode: z.ZodOptional<z.ZodEnum<{
13
- bike: "bike";
14
- car: "car";
15
- motorcycle: "motorcycle";
16
- truck: "truck";
17
- walk: "walk";
18
- }>>;
19
- service: z.ZodOptional<z.ZodEnum<{
20
- fast: "fast";
21
- flexible: "flexible";
22
- }>>;
23
- route_type: z.ZodOptional<z.ZodEnum<{
24
- fastest: "fastest";
25
- shortest: "shortest";
26
- }>>;
27
- departure_time: z.ZodOptional<z.ZodNumber>;
28
- avoid: z.ZodOptional<z.ZodArray<z.ZodEnum<{
29
- ferry: "ferry";
30
- highway: "highway";
31
- none: "none";
32
- toll: "toll";
33
- }>>>;
34
- honor_restrictions: z.ZodOptional<z.ZodBoolean>;
35
- truck_size_cm: z.ZodOptional<z.ZodObject<{
36
- height: z.ZodNumber;
37
- width: z.ZodNumber;
38
- length: z.ZodNumber;
39
- }, z.core.$strip>>;
40
- truck_weight_kg: z.ZodOptional<z.ZodNumber>;
41
- }, z.core.$strip>;
42
- export declare const distanceMatrix: NbTool<typeof Schema>;
43
- export {};
@@ -1,82 +0,0 @@
1
- import * as z from 'zod/v4';
2
- import { CoordinateSchema, toLatLngList } from '../shared/geo.js';
3
- import { READ_ONLY, textResult, ToolInputError } from '../types.js';
4
- const Schema = z.object({
5
- origins: z.array(CoordinateSchema).min(1).max(1000).describe('Start points (matrix rows)'),
6
- destinations: z.array(CoordinateSchema).min(1).max(1000).describe('End points (matrix columns)'),
7
- mode: z
8
- .enum(['car', 'truck', 'motorcycle', 'bike', 'walk'])
9
- .optional()
10
- .describe('Travel mode (default car). Modes other than car/truck require service=flexible'),
11
- service: z
12
- .enum(['fast', 'flexible'])
13
- .optional()
14
- .describe('API variant: "fast" (default) supports up to 1000x1000 points; "flexible" adds ' +
15
- 'departure_time, route_type, truck options and more modes but is limited to 50x50 points ' +
16
- 'within a ~8000 km area'),
17
- route_type: z
18
- .enum(['fastest', 'shortest'])
19
- .optional()
20
- .describe('Optimization objective (flexible only, default fastest)'),
21
- departure_time: z
22
- .number()
23
- .int()
24
- .optional()
25
- .describe('Departure as a UNIX timestamp in seconds, for typical-traffic results (flexible only)'),
26
- avoid: z
27
- .array(z.enum(['toll', 'highway', 'ferry', 'none']))
28
- .optional()
29
- .describe('Road features to avoid'),
30
- honor_restrictions: z
31
- .boolean()
32
- .optional()
33
- .describe('When true, enforce restricted-area rules for origin/destination points instead of ' +
34
- 'routing through with a warning (flexible service only)'),
35
- truck_size_cm: z
36
- .object({ height: z.number(), width: z.number(), length: z.number() })
37
- .optional()
38
- .describe('Truck dimensions in cm (flexible + mode=truck only)'),
39
- truck_weight_kg: z
40
- .number()
41
- .int()
42
- .max(100_000)
43
- .optional()
44
- .describe('Truck gross weight in kg (flexible + mode=truck only)'),
45
- });
46
- export const distanceMatrix = {
47
- name: 'distance_matrix',
48
- title: 'Distance Matrix',
49
- description: 'Compute travel distances (meters) and durations (seconds) for every origin→destination ' +
50
- 'pair in one call (one-to-many or many-to-many). Far more efficient than repeated ' +
51
- 'directions calls — always prefer this for multiple pairs. Response has one row per origin ' +
52
- 'with one element per destination, in input order.',
53
- inputSchema: Schema,
54
- annotations: READ_ONLY,
55
- async run(args, nb) {
56
- const service = args.service ?? 'fast';
57
- if (service === 'fast' && args.mode && args.mode !== 'car' && args.mode !== 'truck') {
58
- throw new ToolInputError(`mode=${args.mode} requires service=flexible.`);
59
- }
60
- if (service === 'flexible' && (args.origins.length > 50 || args.destinations.length > 50)) {
61
- throw new ToolInputError('service=flexible is limited to 50 origins x 50 destinations; use service=fast for larger matrices.');
62
- }
63
- const response = await nb.postJson('/distancematrix/json', service === 'flexible' ? { option: 'flexible' } : {}, {
64
- origins: toLatLngList(args.origins),
65
- destinations: toLatLngList(args.destinations),
66
- mode: args.mode,
67
- route_type: args.route_type,
68
- departure_time: args.departure_time,
69
- avoid: args.avoid?.length ? args.avoid.join('|') : undefined,
70
- honor_restrictions: args.honor_restrictions,
71
- truck_size: args.truck_size_cm
72
- ? `${args.truck_size_cm.height},${args.truck_size_cm.width},${args.truck_size_cm.length}`
73
- : undefined,
74
- truck_weight: args.truck_weight_kg,
75
- });
76
- const rows = response.rows ?? [];
77
- return textResult(`Computed a ${args.origins.length}x${args.destinations.length} matrix ` +
78
- `(${rows.length} rows returned). Durations are seconds, distances are meters; ` +
79
- 'full matrix is in structured content.', response);
80
- },
81
- };
82
- //# sourceMappingURL=distance-matrix.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"distance-matrix.js","sourceRoot":"","sources":["../../../src/tools/routing/distance-matrix.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,cAAc,EAAe,MAAM,aAAa,CAAC;AAEjF,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;IACtB,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,4BAA4B,CAAC;IAC1F,YAAY,EAAE,CAA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