@tomtom-org/maps-sdk-plugin-agent-toolkit 0.15.0 → 0.16.0
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/LICENSE.txt +2 -2
- package/README.md +52 -52
- package/THIRD_PARTY.txt +2 -2
- package/dist/THIRD_PARTY.txt +2 -2
- package/dist/index.d.ts +13 -13
- package/dist/index.es.js +2 -2
- package/dist/third-party.json +2 -2
- package/dist/worker-libs-tTFEqlXk.js +1 -0
- package/package.json +14 -13
- package/dist/worker-libs-CUm6Y1-t.js +0 -1
package/LICENSE.txt
CHANGED
|
@@ -14,7 +14,7 @@ You may not use the SDK or accept this Agreement if you are barred from receivin
|
|
|
14
14
|
|
|
15
15
|
3.1. You agree to use the SDK only for purposes permitted by (a) this Agreement and (b) any applicable law, regulation or generally accepted practice or guideline in the relevant jurisdictions (including any laws regarding the export of data or software to and from the United States or other relevant countries).
|
|
16
16
|
|
|
17
|
-
3.2.
|
|
17
|
+
3.2. Except as permitted by applicable law or this Clause 3.2, you may not copy (except for backup purposes), modify, adapt, distribute, rent, lend, publicly present, decompile, reverse engineer, disassemble or create derivative works of the SDK. Solely for your Permitted Applications and subject to Clauses 3.3 to 3.5, you may: (a) inspect the SDK, including source code in its source maps, for debugging; (b) copy the SDK as reasonably necessary to develop, build, test and deploy them, including in internal repositories, mirrors and offline build environments used only by you, your Affiliates and your contractors; (c) modify the SDK to fix errors or security vulnerabilities, to maintain compatibility, or to prepare a Contribution under Clause 11.5, but you may not alter, circumvent or disable any functionality for authentication, metering, billing, the notices in Clause 5.2 or the data collection in Clause 4; and (d) distribute the SDK only as a bundled part of a Permitted Application, and not on a standalone basis or as a library. Modified versions remain part of the SDK, and TomTom need not support them. On termination, you must delete all copies held under (b), except copies already distributed under (d). The readability of the SDK's source code does not make it open source and grants no rights beyond those in Clause 1 and this Clause 3.2.
|
|
18
18
|
|
|
19
19
|
3.3. You may not use the SDK in connection with any illegal, fraudulent, dishonest or unethical activity or behaviour, and in particular not to create or develop, or help others create or develop, a product, service or library that competes, directly or indirectly, with the SDK or the TomTom APIs.
|
|
20
20
|
|
|
@@ -22,7 +22,7 @@ You may not use the SDK or accept this Agreement if you are barred from receivin
|
|
|
22
22
|
|
|
23
23
|
3.5. The SDK may include data or software that TomTom licenses from third parties, including open-source software. Such components are made available to you under the terms and conditions of their applicable licenses, and you shall comply with all requirements and restrictions that those third parties may require TomTom to impose on you (as may be updated and amended by TomTom from time to time). It is your responsibility to check, review and comply with those terms as they apply to the SDK licensed to you under this Agreement. The applicable third party and open-source notices are set out in the accompanying THIRD_PARTY.txt file. In the event of a conflict between this Agreement and an open-source license governing a specific dependency, that open-source license shall prevail solely with respect to that dependency.
|
|
24
24
|
|
|
25
|
-
4. PRIVACY: In order to improve the TomTom Developer Portal and the SDK, TomTom may collect certain usage related information from the software, including but not limited to general SDK and product identifiers, version numbers, and information on which tools and/or services in the SDK are used and how you use them. In addition, TomTom may collect your unique identifier and associated IP address for legitimate business reasons (such as, without limitation, the processing of invoices). This data is retained for a maximum period of 120 days and is maintained in accordance with our Privacy Policy.
|
|
25
|
+
4. PRIVACY: In order to improve the TomTom Developer Portal and the SDK, TomTom may collect certain usage related information from the software, including but not limited to general SDK and product identifiers, version numbers, and information on which tools and/or services in the SDK are used and how you use them. In addition, TomTom may collect your unique identifier and associated IP address for legitimate business reasons (such as, without limitation, the processing of invoices). This data is retained for a maximum period of 120 days and is maintained in accordance with our Privacy Policy (https://www.tomtom.com/privacy/).
|
|
26
26
|
|
|
27
27
|
5. INTELLECTUAL PROPERTY RIGHTS AND COPYRIGHT NOTICES:
|
|
28
28
|
|
package/README.md
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
# Agent Toolkit Plugin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This plugin is a headless conversational agent that gives large language models tool-based control over a [TomTom Map](https://docs.tomtom.com/maps-sdk-js/guides/map/tomtom-map) and TomTom location services. It's built on [Vercel AI SDK v6](https://ai-sdk.dev/).
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
The plugin has no UI, so you bring your own chat interface. It bundles no LLM provider, so you supply any AI SDK-compatible model.
|
|
6
6
|
|
|
7
|
-
> **Full documentation
|
|
7
|
+
> **Full documentation**, with guides, architecture diagrams and tutorials, lives at [docs.tomtom.com](https://docs.tomtom.com/maps-sdk-js/guides/plugins/agent-toolkit/overview).
|
|
8
8
|
|
|
9
9
|
## Design principles
|
|
10
10
|
|
|
11
|
-
1. **Client-side only** —
|
|
12
|
-
2. **No bundled LLM provider** — supply any AI SDK-compatible `LanguageModel
|
|
13
|
-
3. **Token-efficient** —
|
|
14
|
-
4. **Lazy module initialization** —
|
|
15
|
-
5. **Coordinate convention** — always `[longitude, latitude]
|
|
16
|
-
6. **Task-oriented tools** — tool boundaries follow user tasks, not SDK API surface, so
|
|
11
|
+
1. **Client-side only** — the agent runs on AI SDK's `DirectChatTransport` and `ToolLoopAgent`. You provide the model and need no server infrastructure.
|
|
12
|
+
2. **No bundled LLM provider** — you supply any AI SDK-compatible `LanguageModel`, which keeps the package provider-agnostic.
|
|
13
|
+
3. **Token-efficient** — the plugin summarizes every service response before it reaches the LLM. The full GeoJSON stays in `ToolState`.
|
|
14
|
+
4. **Lazy module initialization** — the plugin creates each map module on first use and caches it in state.
|
|
15
|
+
5. **Coordinate convention** — the plugin always uses and enforces `[longitude, latitude]`, the GeoJSON standard's order.
|
|
16
|
+
6. **Task-oriented tools** — tool boundaries follow user tasks, not the SDK's API surface, so one prompt maps to one tool call.
|
|
17
17
|
|
|
18
18
|
## Installation
|
|
19
19
|
|
|
@@ -81,11 +81,11 @@ function ChatPanel() {
|
|
|
81
81
|
}
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
For a full working app, see the [traffic agent example](https://docs.tomtom.com/maps-sdk-js/examples/map-traffic-agent-react).
|
|
85
85
|
|
|
86
86
|
## Tools reference
|
|
87
87
|
|
|
88
|
-
The plugin ships a `DEFAULT_TOOLS` registry
|
|
88
|
+
The plugin ships a `DEFAULT_TOOLS` registry that covers search, routing, traffic, reachable areas, BYOD GeoJSON, base-map control, MapLibre access and code-generated analysis. The agent gets every tool by default, and you can remove or replace each one through the [`tools` option](#composing-tool-sets). The [Agent Toolkit guide](https://docs.tomtom.com/maps-sdk-js/guides/plugins/agent-toolkit/tools) has the full per-tool reference.
|
|
89
89
|
|
|
90
90
|
### Location & search
|
|
91
91
|
|
|
@@ -96,26 +96,26 @@ The plugin ships a `DEFAULT_TOOLS` registry covering search, routing, traffic, r
|
|
|
96
96
|
| `discoverPlaces` | Search for places by text query or POI category within an area |
|
|
97
97
|
| `getPOICategoryCodes` | Look up TomTom POI category codes from natural-language names |
|
|
98
98
|
| `getCurrentLocation` | Get the user's physical GPS location from the browser |
|
|
99
|
-
| `getViewport` | Get current map center, zoom
|
|
99
|
+
| `getViewport` | Get the current map center, zoom and bounding box |
|
|
100
100
|
|
|
101
101
|
### Routing & reachable areas
|
|
102
102
|
|
|
103
103
|
| Tool | Description |
|
|
104
104
|
|---|---|
|
|
105
|
-
| `setRoute` | Calculate or recalculate a route — provide `locations` (waypoints), `parameters` (route options)
|
|
105
|
+
| `setRoute` | Calculate or recalculate a route — provide `locations` (waypoints), `parameters` (route options) or both |
|
|
106
106
|
| `addWaypointsToRoute` | Extend the current route — prepend a new origin, append a new destination, and/or insert intermediate stops |
|
|
107
107
|
| `removeWaypointsFromRoute` | Remove one or more waypoints by index from the current route |
|
|
108
|
-
| `replaceWaypointInRoute` | Overwrite a single waypoint of the current route in place — origin, destination
|
|
108
|
+
| `replaceWaypointInRoute` | Overwrite a single waypoint of the current route in place — origin, destination or by index |
|
|
109
109
|
| `getCurrentWaypoints` | Get the staged waypoint slots (origin, stops, destination) |
|
|
110
110
|
| `startRouteMonitor` | Recalculate an already-calculated route on a cadence (default 60 s) so its live-traffic delays stay current |
|
|
111
|
-
| `stopRouteMonitor` | Stop recalculating a route
|
|
112
|
-
| `findReachableAreas` | Calculate isochrone/isodistance polygons from one or more origins (private preview
|
|
111
|
+
| `stopRouteMonitor` | Stop recalculating a route. The entry keeps its last data |
|
|
112
|
+
| `findReachableAreas` | Calculate isochrone/isodistance polygons from one or more origins (in private preview, so the API key needs Calculate Reachable Range access) |
|
|
113
113
|
|
|
114
114
|
### Traffic
|
|
115
115
|
|
|
116
116
|
| Tool | Description |
|
|
117
117
|
|---|---|
|
|
118
|
-
| `getTrafficIncidents` | Fetch traffic incidents within an area (viewport, named place, route corridor, polygon, IDs)
|
|
118
|
+
| `getTrafficIncidents` | Fetch traffic incidents within an area (viewport, named place, route corridor, polygon, IDs). By default, the entry keeps refreshing |
|
|
119
119
|
| `setTrafficIncidentsMonitor` | Turn background refreshing of an already-loaded incidents entry on or off |
|
|
120
120
|
| `clusterIncidents` | Group loaded incidents into hotspots (DBSCAN) with road and category labels, delay totals and trends |
|
|
121
121
|
| `focusIncidents` | Highlight a subset of incidents (by id / category / severity) on the map and dim the rest |
|
|
@@ -128,30 +128,30 @@ The plugin ships a `DEFAULT_TOOLS` registry covering search, routing, traffic, r
|
|
|
128
128
|
| `createTracker` | Watch loaded entries with generated code and log an alert when its condition turns true (e.g. an incident near a hospital) |
|
|
129
129
|
| `getTrackers` | List the active trackers and whether each is firing |
|
|
130
130
|
| `getTrackerHistory` | Read the alerts and events trackers have logged, for one tracker or since a time |
|
|
131
|
-
| `clearTracker` | Stop a tracker
|
|
131
|
+
| `clearTracker` | Stop a tracker. The entries it watched stay |
|
|
132
132
|
|
|
133
133
|
### Bring-your-own-data (BYOD)
|
|
134
134
|
|
|
135
135
|
| Tool | Description |
|
|
136
136
|
|---|---|
|
|
137
|
-
| `addByodSource` | Ingest a customer-authored GeoJSON source (URL or inline `FeatureCollection`) and profile its shape
|
|
138
|
-
| `setByodLayers` | Restyle a BYOD entry
|
|
139
|
-
| `updateByodDisplay` | Show, hide
|
|
137
|
+
| `addByodSource` | Ingest a customer-authored GeoJSON source (URL or inline `FeatureCollection`) and profile its shape. The entry has no layers and renders nothing until the agent sets them with `setByodLayers` |
|
|
138
|
+
| `setByodLayers` | Restyle a BYOD entry by replacing its MapLibre layers (type and data-driven paint), using the entry's data `profile` |
|
|
139
|
+
| `updateByodDisplay` | Show, hide or clear BYOD layers on the map |
|
|
140
140
|
|
|
141
|
-
> See the [Bring your own data](https://docs.tomtom.com/maps-sdk-js/guides/plugins/agent-toolkit/byod) guide for ingestion patterns, visibility lifecycle
|
|
141
|
+
> See the [Bring your own data](https://docs.tomtom.com/maps-sdk-js/guides/plugins/agent-toolkit/byod) guide for ingestion patterns, the visibility lifecycle and how BYOD entries feed into `analyseData` / `processData`.
|
|
142
142
|
|
|
143
143
|
### Unified data tools — scope-aware code generation
|
|
144
144
|
|
|
145
145
|
| Tool | Description |
|
|
146
146
|
|---|---|
|
|
147
|
-
| `analyseData` | Aggregate
|
|
148
|
-
| `processData` | Transform entries into new `places`, `placeConnections`, `geometries`, `byod
|
|
147
|
+
| `analyseData` | Aggregate or chart entries (`places`, `routes`, `incidents`, `geometries`, `trafficAreaAnalytics`, `byod`) with dynamic JS. The scope the classifier emits narrows the schema each turn |
|
|
148
|
+
| `processData` | Transform entries, with dynamic JS, into new `places`, `placeConnections`, `geometries`, `byod` or a `fitOnMap` camera move |
|
|
149
149
|
| `monitorAnalysis` | Start or stop recomputing an `analyseData` analysis whenever its source entries change |
|
|
150
|
-
| `executeMaplibreCode` |
|
|
150
|
+
| `executeMaplibreCode` | Run arbitrary MapLibre JS against the live `Map` instance, an escape hatch for custom layers, animations and raster overlays |
|
|
151
151
|
|
|
152
|
-
> See [Code generation](https://docs.tomtom.com/maps-sdk-js/guides/plugins/agent-toolkit/code-generation) for the injected identifiers, output contracts
|
|
152
|
+
> See [Code generation](https://docs.tomtom.com/maps-sdk-js/guides/plugins/agent-toolkit/code-generation) for the injected identifiers, output contracts and threat model, and [Scope-aware data tools](https://docs.tomtom.com/maps-sdk-js/guides/plugins/agent-toolkit/scope-aware-data-tools) for how the per-turn classifier scope keeps the prompt small.
|
|
153
153
|
|
|
154
|
-
`analyseData`, `processData`, `createTracker` and `clusterIncidents` code is **always isolated in the browser
|
|
154
|
+
`analyseData`, `processData`, `createTracker` and `clusterIncidents` code is **always isolated in the browser**. It runs in a Web Worker inside a sandboxed, opaque-origin iframe with no DOM or network access, terminable on timeout. It needs no configuration, since the SDK lazily loads its own bundled turf and h3 for the worker. The environment, not a setting, decides where the code runs. The browser always isolates it, while Node and SSR always run it on the main thread. That boundary has no equivalent there, so the protection is defense-in-depth only. The optional `codeExecution` only tunes the isolated browser run:
|
|
155
155
|
|
|
156
156
|
```typescript
|
|
157
157
|
const agent = createMapAgent(map, {
|
|
@@ -160,17 +160,17 @@ const agent = createMapAgent(map, {
|
|
|
160
160
|
});
|
|
161
161
|
```
|
|
162
162
|
|
|
163
|
-
> **Experimental
|
|
163
|
+
> **Experimental.** The `e2e-tests/` suite verifies the isolation boundary (CSP egress-block, worker termination, opaque-origin isolation) and runs in CI as a dedicated job. If the iframe can't initialise, the code falls back to the main thread with a warning. The worker bundles `turf`, `h3` and `routeUtils`, so that code, route slicing included, runs fully in the browser. See the [code-generation guide](https://docs.tomtom.com/maps-sdk-js/guides/plugins/agent-toolkit/code-generation#data-tool-execution-isolation-experimental).
|
|
164
164
|
|
|
165
165
|
### Map display
|
|
166
166
|
|
|
167
167
|
| Tool | Description |
|
|
168
168
|
|---|---|
|
|
169
|
-
| `updatePlacesDisplay` | Show, hide
|
|
170
|
-
| `updateRoutesDisplay` | Show, hide
|
|
169
|
+
| `updatePlacesDisplay` | Show, hide or restyle place entries on the map |
|
|
170
|
+
| `updateRoutesDisplay` | Show, hide or swap route entries, switch the highlighted alternative or fit the camera |
|
|
171
171
|
| `updateWaypointsDisplay` | Show staged waypoint markers without the route line |
|
|
172
|
-
| `updateTrafficAreaAnalyticsDisplay` | Show, hide
|
|
173
|
-
| `clearMap` | Remove displayed places, routes, BYOD layers
|
|
172
|
+
| `updateTrafficAreaAnalyticsDisplay` | Show, hide or swap traffic-area-analytics entries |
|
|
173
|
+
| `clearMap` | Remove displayed places, routes, BYOD layers or all features |
|
|
174
174
|
|
|
175
175
|
### Map control
|
|
176
176
|
|
|
@@ -183,7 +183,7 @@ const agent = createMapAgent(map, {
|
|
|
183
183
|
| `setMapStandardStyle` | Switch map style (light, dark, satellite, driving, etc.) |
|
|
184
184
|
| `setLanguage` | Change the language for map labels and API responses |
|
|
185
185
|
| `setGeopoliticalView` | Show disputed borders and territory names from a country's view, for the map and later searches |
|
|
186
|
-
| `setMapStyling` | Set or reset what the base map shows and how it looks
|
|
186
|
+
| `setMapStyling` | Set or reset, by knob id, what the base map shows and how it looks. That covers layer groups such as 3D buildings, the built-in POI icons and their categories, the live traffic overlays and their filters, the hillshade and 3D terrain, sizes, colours, map presets, or a whole theme from a few colours or an image. It also sets the look of every layer the agent drew: places, routes and their sections, polygons, reachable areas, area analytics and fetched incidents. The classifier scope lists only the knob families a turn touches |
|
|
187
187
|
|
|
188
188
|
### MapLibre direct access
|
|
189
189
|
|
|
@@ -210,7 +210,7 @@ const agent = createMapAgent(map, {
|
|
|
210
210
|
|
|
211
211
|
## Customization
|
|
212
212
|
|
|
213
|
-
> See [Customizing tools](https://docs.tomtom.com/maps-sdk-js/guides/plugins/agent-toolkit/customizing-tools) for the full walkthrough
|
|
213
|
+
> See [Customizing tools](https://docs.tomtom.com/maps-sdk-js/guides/plugins/agent-toolkit/customizing-tools) for the full walkthrough. It covers registry resolution, removing or replacing defaults, adding scopable custom tools and starting from a blank slate.
|
|
214
214
|
|
|
215
215
|
### `createMapAgent` options
|
|
216
216
|
|
|
@@ -277,7 +277,7 @@ const agent = createMapAgent<MyState>(map, {
|
|
|
277
277
|
|
|
278
278
|
### Composing tool sets
|
|
279
279
|
|
|
280
|
-
The `tools` option
|
|
280
|
+
The plugin merges the `tools` option with the built-in defaults. To exclude a tool, set it to `false`.
|
|
281
281
|
|
|
282
282
|
```typescript
|
|
283
283
|
import { createMapAgent } from '@tomtom-org/maps-sdk-plugin-agent-toolkit';
|
|
@@ -307,7 +307,7 @@ createMapAgent(map, { model, includeDefaultTools: false, tools: { myTool } });
|
|
|
307
307
|
|
|
308
308
|
### Defining custom tools
|
|
309
309
|
|
|
310
|
-
|
|
310
|
+
To define custom tools type-safely, use `satisfies`:
|
|
311
311
|
|
|
312
312
|
```typescript
|
|
313
313
|
import { type ToolEntry, createMapAgent } from '@tomtom-org/maps-sdk-plugin-agent-toolkit';
|
|
@@ -361,9 +361,9 @@ type ToolEntry<S extends ToolState = ToolState, Scope = unknown> = {
|
|
|
361
361
|
|
|
362
362
|
## State management
|
|
363
363
|
|
|
364
|
-
> See the [State](https://docs.tomtom.com/maps-sdk-js/guides/plugins/agent-toolkit/state) guide for a per-slice deep dive, `entryMode` semantics (`multiple` vs `single`), inspecting state from your application
|
|
364
|
+
> See the [State](https://docs.tomtom.com/maps-sdk-js/guides/plugins/agent-toolkit/state) guide for a per-slice deep dive, `entryMode` semantics (`multiple` vs `single`), inspecting state from your application and adding custom slices.
|
|
365
365
|
|
|
366
|
-
`ToolState`
|
|
366
|
+
`ToolState` holds one slice per feature area. Each slice manages lazily initialized map modules and an append-only history of the results the session produces. The built-in slices are:
|
|
367
367
|
|
|
368
368
|
- `PlacesState` — place / geometry entry history
|
|
369
369
|
- `RoutingState` — route history, planning waypoint slots, route parameters
|
|
@@ -371,12 +371,12 @@ type ToolEntry<S extends ToolState = ToolState, Scope = unknown> = {
|
|
|
371
371
|
- `CustomGeometriesState` — derived polygon entries produced by `processData` (union, difference, h3-coverage, …)
|
|
372
372
|
- `BYODState` — bring-your-own-data GeoJSON layer entries
|
|
373
373
|
- `BaseMapState` — viewport, style, language, raw `mapLibreMap`
|
|
374
|
-
- `TrafficTilesState` — real-time traffic flow
|
|
374
|
+
- `TrafficTilesState` — visibility of the real-time traffic flow and incident tile overlays
|
|
375
375
|
- `TrafficAreaAnalyticsState` — historical traffic-area-analytics entries and per-entry visualisation
|
|
376
|
-
- `TrafficIncidentsState` — fetched incident entries, registered analyses, focused subsets
|
|
376
|
+
- `TrafficIncidentsState` — fetched incident entries, registered analyses, focused subsets and the optional polling monitor
|
|
377
377
|
- `MapPOIsState` — POI category visibility and filters
|
|
378
378
|
|
|
379
|
-
|
|
379
|
+
`createMapAgent` constructs the built-in slices. To add custom slices, define an interface that extends `ToolState` and pass it as the type parameter. You provide only the custom fields:
|
|
380
380
|
|
|
381
381
|
```typescript
|
|
382
382
|
interface MyState extends ToolState {
|
|
@@ -396,14 +396,14 @@ agent.state.places; // PlacesState — append-only history of place entries
|
|
|
396
396
|
|
|
397
397
|
> See the [What the agent sends, and where](https://docs.tomtom.com/maps-sdk-js/guides/plugins/agent-toolkit/what-the-agent-sends) guide for the full list.
|
|
398
398
|
|
|
399
|
-
- **What reaches your model provider**: every message and the system prompt
|
|
399
|
+
- **What reaches your model provider**: every message and the system prompt, plus the classifier's copy of earlier messages. By default, that copy holds up to eight messages of 300 characters each, and `classifier: false` turns it off. Tool results go too, including addresses, coordinates, the viewport, the device location, `analyseData` and `processData` output over your BYOD data, and up to 200 events per tracker.
|
|
400
400
|
- **The provider is your processor**: sign a DPA with it and pick an EEA region where it offers one.
|
|
401
|
-
- **What stays in memory**: `agent.state`, until the `resetState` tool or `agent.destroy()
|
|
402
|
-
- **To send less**: remove tools (`getCurrentLocation: false`), turn off the classifier
|
|
401
|
+
- **What stays in memory**: `agent.state`, until the `resetState` tool or `agent.destroy()` clears it. Nothing goes to browser storage. Chat history is yours, so erasing a user's data means clearing it and calling `agent.destroy()`.
|
|
402
|
+
- **To send less**: remove tools (`getCurrentLocation: false`), turn off the classifier or replace a tool with one that returns less.
|
|
403
403
|
|
|
404
404
|
## Intent classifier
|
|
405
405
|
|
|
406
|
-
The intent classifier is an optional per-turn optimization
|
|
406
|
+
The intent classifier is an optional per-turn optimization. It picks which tools the LLM sees, which cuts noise and improves accuracy. The [How it works](https://docs.tomtom.com/maps-sdk-js/guides/plugins/agent-toolkit/how-it-works) guide covers the full two-phase pipeline (classification, then the tool loop), prompt assembly and observability hooks.
|
|
407
407
|
|
|
408
408
|
```typescript
|
|
409
409
|
import { createMapAgent, createDefaultClassifier } from '@tomtom-org/maps-sdk-plugin-agent-toolkit';
|
|
@@ -424,13 +424,13 @@ const agent = createMapAgent(map, {
|
|
|
424
424
|
});
|
|
425
425
|
```
|
|
426
426
|
|
|
427
|
-
The classifier prompt
|
|
427
|
+
The plugin builds the classifier prompt on the fly from each tool's `classificationPrompt` and `relatedTools` metadata, so the prompt stays in sync when you add or rename tools.
|
|
428
428
|
|
|
429
429
|
## System prompt
|
|
430
430
|
|
|
431
|
-
The built-in `BASE_SYSTEM_PROMPT` covers identity, a capability summary, scope/rejection rules, response formatting, data-confidence rules, tool-execution guidance
|
|
431
|
+
The built-in `BASE_SYSTEM_PROMPT` covers identity, a capability summary, scope/rejection rules, response formatting, data-confidence rules, tool-execution guidance and session-state conventions. Per-tool mechanics (coordinate order, location-reference routing, etc.) live in the tool descriptions and the classifier prompt, not here.
|
|
432
432
|
|
|
433
|
-
`systemPrompt` accepts **either** a full replacement string **or** a section-overrides object (`Partial<Record<SystemPromptSection, string>>`)
|
|
433
|
+
`systemPrompt` accepts **either** a full replacement string **or** a section-overrides object (`Partial<Record<SystemPromptSection, string>>`). Sections you omit keep their defaults. For a section you override, you supply only its body, and the plugin adds the heading:
|
|
434
434
|
|
|
435
435
|
```typescript
|
|
436
436
|
import {
|
|
@@ -482,7 +482,7 @@ const agent = createMapAgent(map, {
|
|
|
482
482
|
|
|
483
483
|
### Wrapping default tools
|
|
484
484
|
|
|
485
|
-
|
|
485
|
+
To add logging, analytics or custom behavior around an existing tool, wrap it:
|
|
486
486
|
|
|
487
487
|
```typescript
|
|
488
488
|
import { DEFAULT_TOOLS, createMapAgent } from '@tomtom-org/maps-sdk-plugin-agent-toolkit';
|
|
@@ -544,9 +544,9 @@ agent.destroy(); // Reset all state slices (call on unmount)
|
|
|
544
544
|
|
|
545
545
|
## Public API exports
|
|
546
546
|
|
|
547
|
-
The main entry point is `createMapAgent
|
|
547
|
+
The main entry point is `createMapAgent`. `DEFAULT_TOOLS` and `BASE_SYSTEM_PROMPT` cover the most common customizations, as the examples above show.
|
|
548
548
|
|
|
549
|
-
For the complete, always-current list of exports
|
|
549
|
+
For the complete, always-current list of exports, including factories, tool-registry helpers, state introspection, the classifier and all types, see the [API reference](https://docs.tomtom.com/maps-sdk-js/reference).
|
|
550
550
|
|
|
551
551
|
## Dependencies
|
|
552
552
|
|
|
@@ -567,7 +567,7 @@ For the complete, always-current list of exports — factories, tool-registry he
|
|
|
567
567
|
- [How it works](https://docs.tomtom.com/maps-sdk-js/guides/plugins/agent-toolkit/how-it-works) — two-phase pipeline (classifier + tool loop), prompt assembly, observability
|
|
568
568
|
- [Tools](https://docs.tomtom.com/maps-sdk-js/guides/plugins/agent-toolkit/tools) — per-tool reference
|
|
569
569
|
- [State](https://docs.tomtom.com/maps-sdk-js/guides/plugins/agent-toolkit/state) — per-slice reference, entry modes, custom slices
|
|
570
|
-
- [Customizing tools](https://docs.tomtom.com/maps-sdk-js/guides/plugins/agent-toolkit/customizing-tools) — add, replace, remove
|
|
570
|
+
- [Customizing tools](https://docs.tomtom.com/maps-sdk-js/guides/plugins/agent-toolkit/customizing-tools) — add, replace, remove or start from a blank slate
|
|
571
571
|
- [Code generation](https://docs.tomtom.com/maps-sdk-js/guides/plugins/agent-toolkit/code-generation) — `analyseData` / `processData` / `createTracker` / `clusterIncidents` / `executeMaplibreCode` (threat model included)
|
|
572
572
|
- [Scope-aware data tools](https://docs.tomtom.com/maps-sdk-js/guides/plugins/agent-toolkit/scope-aware-data-tools) — per-turn scope mechanism
|
|
573
573
|
- [Bring your own data](https://docs.tomtom.com/maps-sdk-js/guides/plugins/agent-toolkit/byod) — ingest customer GeoJSON layers
|
package/THIRD_PARTY.txt
CHANGED
|
@@ -49,7 +49,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
49
49
|
---
|
|
50
50
|
|
|
51
51
|
Name: ai
|
|
52
|
-
Version: 6.0.
|
|
52
|
+
Version: 6.0.302
|
|
53
53
|
License: Apache-2.0
|
|
54
54
|
Bundled: false (peer dependency)
|
|
55
55
|
Description: AI SDK by Vercel - build apps like ChatGPT, Claude, Gemini, and more with a single interface for any model using the Vercel AI Gateway or go direct to OpenAI, Anthropic, Google, or any other model provider.
|
|
@@ -334,7 +334,7 @@ limitations under the License.
|
|
|
334
334
|
---
|
|
335
335
|
|
|
336
336
|
Name: maplibre-gl
|
|
337
|
-
Version: 6.
|
|
337
|
+
Version: 6.13.0
|
|
338
338
|
License: BSD-3-Clause
|
|
339
339
|
Bundled: false (peer dependency)
|
|
340
340
|
Description: BSD licensed community fork of mapbox-gl, a WebGL interactive maps library
|
package/dist/THIRD_PARTY.txt
CHANGED
|
@@ -39,7 +39,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
39
39
|
---
|
|
40
40
|
|
|
41
41
|
Name: ai
|
|
42
|
-
Version: 6.0.
|
|
42
|
+
Version: 6.0.302
|
|
43
43
|
License: Apache-2.0
|
|
44
44
|
Bundled: false (peer dependency)
|
|
45
45
|
Description: AI SDK by Vercel - build apps like ChatGPT, Claude, Gemini, and more with a single interface for any model using the Vercel AI Gateway or go direct to OpenAI, Anthropic, Google, or any other model provider.
|
|
@@ -324,7 +324,7 @@ limitations under the License.
|
|
|
324
324
|
---
|
|
325
325
|
|
|
326
326
|
Name: maplibre-gl
|
|
327
|
-
Version: 6.
|
|
327
|
+
Version: 6.13.0
|
|
328
328
|
License: BSD-3-Clause
|
|
329
329
|
Bundled: false (peer dependency)
|
|
330
330
|
Description: BSD licensed community fork of mapbox-gl, a WebGL interactive maps library
|
package/dist/index.d.ts
CHANGED
|
@@ -96,8 +96,8 @@ export declare const CHART_TYPES: Set<string>;
|
|
|
96
96
|
export declare const isChartConfiguration: (value: unknown) => value is ChartConfiguration;
|
|
97
97
|
/**
|
|
98
98
|
* GeoJSON Feature with a Polygon or MultiPolygon geometry. Generic over
|
|
99
|
-
* `properties` so callers that need a narrower property shape
|
|
100
|
-
*
|
|
99
|
+
* `properties` so callers that need a narrower property shape get the typed
|
|
100
|
+
* result without a cast.
|
|
101
101
|
*
|
|
102
102
|
* @ignore
|
|
103
103
|
*/
|
|
@@ -1041,8 +1041,8 @@ export declare const GEOMETRIES_SOURCE_IDS_DESC = "Tagged input ids that contrib
|
|
|
1041
1041
|
* Compact schema doc for the geometry polygons consumed/produced by sandboxed
|
|
1042
1042
|
* code in `processData` / `analyseData`, injected per source as
|
|
1043
1043
|
* `geometriesByEntry[key]`. Each item is a
|
|
1044
|
-
* `PolygonFeature
|
|
1045
|
-
*
|
|
1044
|
+
* `PolygonFeature`, and only its non-GeoJSON-standard bits are spelled out
|
|
1045
|
+
* here.
|
|
1046
1046
|
*/
|
|
1047
1047
|
/** @ignore */
|
|
1048
1048
|
export declare const GEOMETRIES_SCHEMA_DOC: string;
|
|
@@ -1261,7 +1261,7 @@ declare class PlacesState implements StateSlice {
|
|
|
1261
1261
|
* the most recent entry is the relevant one to show on the map.
|
|
1262
1262
|
*/
|
|
1263
1263
|
get latestPlace(): Place[] | undefined;
|
|
1264
|
-
addPlaceResult(place: Place | Places, label: string, explicitId?: string, connections?: PlaceConnectionDisplay[], geometries?: PolygonFeature
|
|
1264
|
+
addPlaceResult(place: Place | Places, label: string, explicitId?: string, connections?: PlaceConnectionDisplay[], geometries?: PolygonFeature[]): Promise<string>;
|
|
1265
1265
|
findPlaceById(placeId: string): {
|
|
1266
1266
|
place: Place;
|
|
1267
1267
|
entryId: string;
|
|
@@ -1271,20 +1271,20 @@ declare class PlacesState implements StateSlice {
|
|
|
1271
1271
|
* Returns the cached boundary polygon for a place id, or undefined if no geometry has been
|
|
1272
1272
|
* fetched for it yet. Builds a lazy place-id → feature index per entry on first lookup.
|
|
1273
1273
|
*/
|
|
1274
|
-
getGeometryForPlace(placeId: string): PolygonFeature
|
|
1274
|
+
getGeometryForPlace(placeId: string): PolygonFeature | undefined;
|
|
1275
1275
|
/**
|
|
1276
1276
|
* Fetches the boundary polygon for a place from the Geometry Data service and stores it on
|
|
1277
1277
|
* the owning entry. Returns the cached feature if already fetched, or undefined if the place
|
|
1278
1278
|
* is unknown or has no geometry data source.
|
|
1279
1279
|
*/
|
|
1280
|
-
fetchPlaceGeometry(placeId: string, options?: ToolExecuteOptions): Promise<PolygonFeature
|
|
1280
|
+
fetchPlaceGeometry(placeId: string, options?: ToolExecuteOptions): Promise<PolygonFeature | undefined>;
|
|
1281
1281
|
/**
|
|
1282
1282
|
* Batch-fetches boundary polygons for every place in an entry that has a geometry data source
|
|
1283
1283
|
* but is not yet cached. Issues one Geometry Data request per chunk of {@link GEOMETRY_DATA_BATCH_SIZE}
|
|
1284
1284
|
* place ids (the API caps each request) and stores the merged result on `entry.geometries`.
|
|
1285
1285
|
* Returns the full geometries list for the entry, or an empty array if the entry is unknown.
|
|
1286
1286
|
*/
|
|
1287
|
-
fetchGeometriesForEntry(entryId: string, options?: ToolExecuteOptions): Promise<PolygonFeature
|
|
1287
|
+
fetchGeometriesForEntry(entryId: string, options?: ToolExecuteOptions): Promise<PolygonFeature[]>;
|
|
1288
1288
|
/**
|
|
1289
1289
|
* Renders the given polygons via the entry's GeometriesModule. The `mode` flag applies to
|
|
1290
1290
|
* **this entry's layer only** and doesn't touch other entries. For cross-entry visibility,
|
|
@@ -1298,7 +1298,7 @@ declare class PlacesState implements StateSlice {
|
|
|
1298
1298
|
* `entryId` defaults to the latest entry that owns geometries, which suits callers that only
|
|
1299
1299
|
* render the most recently produced footprints. Pass an explicit id to target an older one.
|
|
1300
1300
|
*/
|
|
1301
|
-
showPlaceGeometries(features: PolygonFeature
|
|
1301
|
+
showPlaceGeometries(features: PolygonFeature[], fillStyle?: GeometryFillStyle, mode?: 'add' | 'replace', entryId?: string): Promise<void>;
|
|
1302
1302
|
private _latestGeometriesEntryId;
|
|
1303
1303
|
private _buildGeometryIndex;
|
|
1304
1304
|
/** IDs of all entries currently shown on the map. */
|
|
@@ -1366,11 +1366,11 @@ type PlacesEntry = BaseEntry<Place[]> & {
|
|
|
1366
1366
|
* produced by tools like `processData`. Each feature's `id` is the geometry-data-source id
|
|
1367
1367
|
* (`place.properties.dataSources.geometry.id`), matching the response shape of `geometryData`.
|
|
1368
1368
|
*/
|
|
1369
|
-
geometries?: PolygonFeature
|
|
1369
|
+
geometries?: PolygonFeature[];
|
|
1370
1370
|
/** Lazy place-id → Place index, built on first ID lookup through PlacesState.findPlaceById. */
|
|
1371
1371
|
_byId?: Record<string, Place>;
|
|
1372
1372
|
/** Lazy place-id → boundary polygon index, built on first lookup through PlacesState.getGeometryForPlace. */
|
|
1373
|
-
_geometryByPlaceId?: Record<string, PolygonFeature
|
|
1373
|
+
_geometryByPlaceId?: Record<string, PolygonFeature>;
|
|
1374
1374
|
/**
|
|
1375
1375
|
* Per-entry display modules. An entry is rendered under at most one marker type at a time,
|
|
1376
1376
|
* so a single PlacesModule covers all of them — `_showEntryAs` switches it via `updateConfig({ markerType })`.
|
|
@@ -3333,8 +3333,8 @@ export declare const routeUtils: {
|
|
|
3333
3333
|
readonly getCoordinateAtRouteProgress: (route: import("@tomtom-org/maps-sdk/core").Route, query: import("@tomtom-org/maps-sdk/core").RouteProgressQuery) => import("@tomtom-org/maps-sdk/core").RouteCoordinateAtProgress | undefined;
|
|
3334
3334
|
readonly getProgressAtNearestRoutePoint: (route: import("@tomtom-org/maps-sdk/core").Route, point: import("@tomtom-org/maps-sdk/core").HasLngLat) => import("@tomtom-org/maps-sdk/core").RouteCoordinateAtProgress | undefined;
|
|
3335
3335
|
readonly getRouteProgressBetween: (route: import("@tomtom-org/maps-sdk/core").Route, startPathIndex: number, endPathIndex: number) => import("@tomtom-org/maps-sdk/core").RouteSegmentProgress | undefined;
|
|
3336
|
-
readonly getRouteProgressForSection: (route: import("@tomtom-org/maps-sdk/core").Route, section: import("@tomtom-org/maps-sdk/core").
|
|
3337
|
-
readonly getSectionBBox: (route: import("@tomtom-org/maps-sdk/core").Route, section: import("@tomtom-org/maps-sdk/core").
|
|
3336
|
+
readonly getRouteProgressForSection: (route: import("@tomtom-org/maps-sdk/core").Route, section: import("@tomtom-org/maps-sdk/core").RouteSpan) => import("@tomtom-org/maps-sdk/core").RouteSegmentProgress | undefined;
|
|
3337
|
+
readonly getSectionBBox: (route: import("@tomtom-org/maps-sdk/core").Route, section: import("@tomtom-org/maps-sdk/core").RouteSpan) => import("@tomtom-org/maps-sdk/core").OptionalBBox;
|
|
3338
3338
|
};
|
|
3339
3339
|
//#endregion
|
|
3340
3340
|
//#region src/tools/shared/routes-schema-doc.d.ts
|