@tomtom-org/maps-sdk-plugin-agent-toolkit 0.13.0 → 0.15.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 CHANGED
@@ -1,8 +1,8 @@
1
1
  TOMTOM MAPS SDK FOR JAVASCRIPT LICENSE AGREEMENT (“AGREEMENT”)
2
2
 
3
- Last update: September 2026
3
+ Last update: October 2026
4
4
 
5
- By downloading or accessing the “TomTom Maps SDK for JavaScript” (the “SDK”), you are entering into a binding agreement with TomTom Global Content B.V. (“TomTom”). The SDK comprises all software, binaries and source code made available by TomTom for it, whether through the TomTom Developer Portal or public code repositories (e.g. GitHub). This Agreement with TomTom consists of the terms and conditions below together with the Data Processing Schedule. You should not use the SDK if you cannot agree to both.
5
+ By downloading or accessing the “TomTom Maps SDK for JavaScript” (the “SDK”), you are entering into a binding agreement with TomTom Global Content B.V. (“TomTom”). The SDK comprises all software, binaries and source code made available by TomTom for it, whether through the TomTom Developer Portal, package registries (e.g. npm) or otherwise. The example applications that TomTom publishes in public code repositories (e.g. GitHub) are not part of the SDK: they are licensed separately, under the license distributed with them. This Agreement with TomTom consists of the terms and conditions below together with the Data Processing Schedule. You should not use the SDK if you cannot agree to both.
6
6
 
7
7
  You may not use the SDK or accept this Agreement if you are barred from receiving it under the laws of the European Union or of any other country, including the country in which you are resident or from which you use the SDK. If you accept this Agreement on behalf of your employer or another entity, you represent and warrant that you have full legal authority to bind that employer or entity. If you do not have that authority, you may not accept this Agreement or use the SDK on their behalf.
8
8
 
@@ -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. Other than as permitted by applicable legislation, you are prohibited from copying (except for backup purposes), modifying, adapting, (re)distributing, renting, lending, publicly presenting, decompiling, reverse engineering, disassembling or creating derivative works of the SDK or any part of it. Notwithstanding the foregoing, where the SDK is hosted on a public repository (e.g. GitHub, which allows forking under its terms of service), you may: (i) fork the repository solely for the purpose of submitting a pull request to TomTom, provided that such fork remains hosted within the platform and is not used as a basis for a separate or competing product or service; and (ii) download a local copy of the source code solely for the purpose of debugging your Permitted Application, provided that such copy is not shared or redistributed. The availability of the source code in a public repository does not constitute “Open-Source” licensing and grants you no rights under any Open Source Initiative (OSI) approved license. Neither that availability, nor any rights granted by the platform’s terms of service with respect to viewing or forking within the platform, shall be construed as a grant of rights to modify, fork or redistribute the SDK beyond those expressly granted in Clause 1 and this Clause 3.2.
17
+ 3.2. Other than as permitted by applicable legislation, you are prohibited from copying (except for backup purposes), modifying, adapting, (re)distributing, renting, lending, publicly presenting, decompiling, reverse engineering, disassembling or creating derivative works of the SDK or any part of it. Notwithstanding the foregoing, you may inspect the SDK as distributed to you, including any source code embedded in its source maps, solely for the purpose of debugging your Permitted Application, provided that it is not shared or redistributed. The readability of the SDK’s source code in its distribution does not constitute “Open-Source” licensing and grants you no rights under any Open Source Initiative (OSI) approved license, nor shall it be construed as a grant of rights to modify, fork or redistribute the SDK beyond those expressly granted 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
 
@@ -78,7 +78,7 @@ You may not use the SDK or accept this Agreement if you are barred from receivin
78
78
 
79
79
  11.4. The TomTom APIs and the SDK are provided as “Commercial Computer Software” or “restricted computer software”. Use, duplication or disclosure by the U.S. Government or a U.S. Government subcontractor is subject to the restrictions set forth in 48 C.F.R. Section 12.212 or 48 C.F.R. 227.2702, as applicable, or successor provisions. In respect of the Map API and Search API, the manufacturer is TomTom Global Content B.V.
80
80
 
81
- 11.5. By submitting any suggestion, bug fix or code contribution (“Contribution”) to TomTom (e.g. via a GitHub Pull Request), you grant TomTom a perpetual, irrevocable, worldwide, royalty-free and non-exclusive license to use, reproduce, modify and distribute the Contribution as part of the SDK. You represent that you have the legal right to grant this license and that the Contribution does not infringe any third-party intellectual property rights.
81
+ 11.5. By submitting any suggestion, bug fix or code contribution (“Contribution”) to TomTom (e.g. via a GitHub issue or discussion), you grant TomTom a perpetual, irrevocable, worldwide, royalty-free and non-exclusive license to use, reproduce, modify and distribute the Contribution as part of the SDK. You represent that you have the legal right to grant this license and that the Contribution does not infringe any third-party intellectual property rights.
82
82
 
83
83
  THIRD PARTY SOFTWARE NOTICES
84
84
 
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # TomTom Maps SDK - Agent Toolkit Plugin
1
+ # Agent Toolkit Plugin
2
2
 
3
3
  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, powered by [Vercel AI SDK v6](https://ai-sdk.dev/).
4
4
 
@@ -18,16 +18,18 @@ No UI is included — bring your own chat interface. No LLM provider is bundled
18
18
  ## Installation
19
19
 
20
20
  ```bash
21
- pnpm add @tomtom-org/maps-sdk @tomtom-org/maps-sdk-plugin-agent-toolkit ai zod maplibre-gl @turf/turf chart.js h3-js
21
+ pnpm add @tomtom-org/maps-sdk @tomtom-org/maps-sdk-plugin-agent-toolkit @tomtom-org/maps-sdk-plugin-map-theme ai zod maplibre-gl @turf/turf chart.js h3-js
22
22
  ```
23
23
 
24
- Install at least one AI SDK provider:
24
+ Install at least one AI SDK provider, plus `@ai-sdk/react` for the `useChat` example below:
25
25
 
26
26
  ```bash
27
27
  # Pick one (or more)
28
28
  pnpm add @ai-sdk/openai
29
29
  pnpm add @ai-sdk/anthropic
30
30
  pnpm add @ai-sdk/azure
31
+
32
+ pnpm add @ai-sdk/react
31
33
  ```
32
34
 
33
35
  ## Quick start
@@ -79,7 +81,7 @@ function ChatPanel() {
79
81
  }
80
82
  ```
81
83
 
82
- See [`examples/map-traffic-agent-react`](../../examples/map-traffic-agent-react) for a full working example.
84
+ See the [traffic agent example](https://docs.tomtom.com/maps-sdk-js/examples/map-traffic-agent-react) for a full working example.
83
85
 
84
86
  ## Tools reference
85
87
 
@@ -118,9 +120,6 @@ The plugin ships a `DEFAULT_TOOLS` registry covering search, routing, traffic, r
118
120
  | `clusterIncidents` | Group loaded incidents into hotspots (DBSCAN) with road and category labels, delay totals and trends |
119
121
  | `focusIncidents` | Highlight a subset of incidents (by id / category / severity) on the map and dim the rest |
120
122
  | `getTrafficAreaAnalytics` | Fetch historical traffic analytics (speed, congestion, travel time) for an area |
121
- | `toggleTilesTrafficFlow` | Toggle the real-time traffic-flow tile overlay |
122
- | `toggleTilesTrafficIncidents` | Toggle the real-time traffic-incidents tile overlay |
123
- | `setMapStyling` | Set or reset how the map looks — label/icon/road sizes, exit numbers and road arrows, POI and hillshade looks, congestion colours, map colours, map presets, or a whole theme from a few colours or an image |
124
123
 
125
124
  ### Trackers
126
125
 
@@ -152,25 +151,25 @@ The plugin ships a `DEFAULT_TOOLS` registry covering search, routing, traffic, r
152
151
 
153
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.
154
153
 
155
- `analyseData` / `processData` code is **always isolated in the browser** — a Web Worker in a sandboxed, opaque-origin iframe (no DOM/network; terminable on timeout), zero-config (the SDK lazily loads its own bundled turf/h3 for the worker). Where the code runs is chosen by environment, not configured: the browser always isolates; Node / SSR always run on the main thread (where that boundary has no equivalent — defense-in-depth only). The optional `codeExecution` only tunes the isolated browser run:
154
+ `analyseData`, `processData`, `createTracker` and `clusterIncidents` code is **always isolated in the browser** — a Web Worker in a sandboxed, opaque-origin iframe (no DOM/network; terminable on timeout), zero-config (the SDK lazily loads its own bundled turf/h3 for the worker). Where the code runs is chosen by environment, not configured: the browser always isolates; Node / SSR always run on the main thread (where that boundary has no equivalent — defense-in-depth only). The optional `codeExecution` only tunes the isolated browser run:
156
155
 
157
156
  ```typescript
158
157
  const agent = createMapAgent(map, {
159
158
  model,
160
- codeExecution: { timeoutMs: 5000 }, // wall-clock budget per isolated run (default 5000)
159
+ codeExecution: { timeoutMs: 5000 }, // wall-clock budget per isolated run (default 10000)
161
160
  });
162
161
  ```
163
162
 
164
- > **Experimental** — the isolation boundary is verified by the `e2e-tests/` suite (CSP egress-block, worker termination, opaque-origin isolation), which runs in CI as a dedicated job; if the iframe can't initialise it falls back to the main thread (with a warning). `turf` / `h3` / `routeUtils` are all bundled into the worker, so `analyseData` and `processData` (including route-slicing) run 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).
163
+ > **Experimental** — the isolation boundary is verified by the `e2e-tests/` suite (CSP egress-block, worker termination, opaque-origin isolation), which runs in CI as a dedicated job; if the iframe can't initialise it falls back to the main thread (with a warning). `turf` / `h3` / `routeUtils` are all bundled into the worker, 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).
165
164
 
166
165
  ### Map display
167
166
 
168
167
  | Tool | Description |
169
168
  |---|---|
170
169
  | `updatePlacesDisplay` | Show, hide, or restyle place entries on the map |
171
- | `updateRoutesDisplay` | Show, hide, or restyle route entries (line color, waypoint icons, fit camera) |
170
+ | `updateRoutesDisplay` | Show, hide, or swap route entries, switch the highlighted alternative, fit the camera |
172
171
  | `updateWaypointsDisplay` | Show staged waypoint markers without the route line |
173
- | `updateTrafficAreaAnalyticsDisplay` | Visualize traffic-area-analytics as hexgrid, heatmap, or tiles |
172
+ | `updateTrafficAreaAnalyticsDisplay` | Show, hide, or swap traffic-area-analytics entries |
174
173
  | `clearMap` | Remove displayed places, routes, BYOD layers, or all features |
175
174
 
176
175
  ### Map control
@@ -183,15 +182,15 @@ const agent = createMapAgent(map, {
183
182
  | `getStandardMapStyles` | List available standard map style presets |
184
183
  | `setMapStandardStyle` | Switch map style (light, dark, satellite, driving, etc.) |
185
184
  | `setLanguage` | Change the language for map labels and API responses |
186
- | `toggleTilesPOIs` | Show/hide built-in map POI icons with optional category filtering |
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, by knob id — 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 — and 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
 
190
190
  | Tool | Description |
191
191
  |---|---|
192
192
  | `getMapStyleLayers` | List MapLibre layer IDs with their paint/layout properties |
193
- | `setLayoutProperties` | Set MapLibre layout properties on named layers |
194
- | `setPaintProperties` | Set MapLibre paint properties (colors, widths, opacity) on named layers |
193
+ | `setLayerProperties` | Set MapLibre paint (colors, widths, opacity) and layout (visibility, text, sizes) properties on named layers |
195
194
 
196
195
  ### State & recall
197
196
 
@@ -337,11 +336,12 @@ createMapAgent(map, { model, tools: fleetTools });
337
336
  Every tool (built-in or custom) follows the `ToolEntry` interface:
338
337
 
339
338
  ```typescript
340
- type ToolEntry<S extends ToolState = ToolState> = {
339
+ type ToolEntry<S extends ToolState = ToolState, Scope = unknown> = {
341
340
  description: string; // Operational contract for the LLM
342
341
  inputSchema: z.ZodType; // Zod schema for input validation
343
342
  outputSchema?: z.ZodType; // Optional structured output schema
344
- execute: (input, state: S) => Promise<any>;
343
+ // options.signal is the turn's AbortSignal: forward it to the services calls the tool makes
344
+ execute: (input, state: S, options?: ToolExecuteOptions) => Promise<any>;
345
345
 
346
346
  // Classifier metadata (optional)
347
347
  classificationPrompt?: string; // One-liner for the intent classifier
@@ -350,6 +350,12 @@ type ToolEntry<S extends ToolState = ToolState> = {
350
350
  examplePrompts?: string[]; // Natural language prompt examples
351
351
  relatedTools?: string[]; // Tools often used together
352
352
  dependsOn?: string[]; // Tools that must run before this one
353
+ scopeSchema?: z.ZodType<Scope>; // Per-turn scope the classifier may emit to narrow the tool
354
+ scopePrompt?: string; // Classifier hint on when and how to scope the tool
355
+
356
+ // Loop control (optional)
357
+ alwaysActive?: boolean; // Visible on every step, whatever the classifier picks
358
+ endsTurnOnCall?: boolean; // Stop the loop on the step that calls this tool
353
359
  };
354
360
  ```
355
361
 
@@ -386,6 +392,15 @@ agent.state.fleet; // FleetState — custom slice
386
392
  agent.state.places; // PlacesState — append-only history of place entries
387
393
  ```
388
394
 
395
+ ## Privacy
396
+
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
+
399
+ - **What reaches your model provider**: every message and the system prompt; the classifier's copy (by default up to 8 earlier messages, 300 characters each; `classifier: false` turns it off); and tool results, including addresses, coordinates, the viewport, the device location, `analyseData` and `processData` output over your BYOD data, and up to 200 events per tracker.
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()`. 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
+
389
404
  ## Intent classifier
390
405
 
391
406
  The intent classifier is an optional per-turn optimization that selects which tools the LLM sees, reducing noise and improving accuracy. See the [How it works](https://docs.tomtom.com/maps-sdk-js/guides/plugins/agent-toolkit/how-it-works) guide for the full two-phase pipeline (classification → tool loop), prompt assembly, and observability hooks.
@@ -510,9 +525,8 @@ const agent = createMapAgent(map, {
510
525
  tools: {
511
526
  setMapStandardStyle: false,
512
527
  setLanguage: false,
513
- setLayoutProperties: false,
514
- setPaintProperties: false,
515
- toggleTilesPOIs: false,
528
+ setLayerProperties: false,
529
+ setMapStyling: false,
516
530
  },
517
531
  });
518
532
  ```
@@ -538,7 +552,8 @@ For the complete, always-current list of exports — factories, tool-registry he
538
552
 
539
553
  | Type | Package | Purpose |
540
554
  |---|---|---|
541
- | Peer | `@tomtom-org/maps-sdk` | TomTom Maps SDK (types, services, map modules) |
555
+ | Peer | `@tomtom-org/maps-sdk@>=1.0.0-rc.0 <1.0.0` | TomTom Maps SDK (types, services, map modules) — its 1.0.0 release candidates |
556
+ | Peer | `@tomtom-org/maps-sdk-plugin-map-theme@>=0.3.0` | Theming the map from a few colours or an image in `setMapStyling` |
542
557
  | Peer | `ai@^6` | Vercel AI SDK (ToolLoopAgent, tool types) |
543
558
  | Peer | `zod@^4` | Schema validation |
544
559
  | Peer | `maplibre-gl@^6` | Map rendering engine |
@@ -553,12 +568,12 @@ For the complete, always-current list of exports — factories, tool-registry he
553
568
  - [Tools](https://docs.tomtom.com/maps-sdk-js/guides/plugins/agent-toolkit/tools) — per-tool reference
554
569
  - [State](https://docs.tomtom.com/maps-sdk-js/guides/plugins/agent-toolkit/state) — per-slice reference, entry modes, custom slices
555
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
556
- - [Code generation](https://docs.tomtom.com/maps-sdk-js/guides/plugins/agent-toolkit/code-generation) — `analyseData` / `processData` / `executeMaplibreCode` (threat model included)
571
+ - [Code generation](https://docs.tomtom.com/maps-sdk-js/guides/plugins/agent-toolkit/code-generation) — `analyseData` / `processData` / `createTracker` / `clusterIncidents` / `executeMaplibreCode` (threat model included)
557
572
  - [Scope-aware data tools](https://docs.tomtom.com/maps-sdk-js/guides/plugins/agent-toolkit/scope-aware-data-tools) — per-turn scope mechanism
558
573
  - [Bring your own data](https://docs.tomtom.com/maps-sdk-js/guides/plugins/agent-toolkit/byod) — ingest customer GeoJSON layers
559
574
  - [AI SDK v6 documentation](https://ai-sdk.dev/)
560
575
  - [TomTom Maps SDK documentation](https://docs.tomtom.com/maps-sdk-js)
561
- - [Example application](../../examples/map-traffic-agent-react) — full chat interface implementation
576
+ - [Example application](https://docs.tomtom.com/maps-sdk-js/examples/map-traffic-agent-react) — full chat interface implementation
562
577
 
563
578
  ## License
564
579
 
package/THIRD_PARTY.txt CHANGED
@@ -334,7 +334,7 @@ limitations under the License.
334
334
  ---
335
335
 
336
336
  Name: maplibre-gl
337
- Version: 6.11.2
337
+ Version: 6.12.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
@@ -324,7 +324,7 @@ limitations under the License.
324
324
  ---
325
325
 
326
326
  Name: maplibre-gl
327
- Version: 6.11.2
327
+ Version: 6.12.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