@tomtom-org/maps-sdk-plugin-agent-toolkit 0.17.0 → 0.17.2
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/CHANGELOG.md +768 -0
- package/README.md +18 -14
- package/dist/index.d.ts +975 -841
- package/dist/index.es.js +2 -2
- package/dist/{worker-libs-B6xqxvae.js → worker-libs-CGRly7A4.js} +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -120,7 +120,7 @@ The plugin ships a `DEFAULT_TOOLS` registry that covers search, routing, traffic
|
|
|
120
120
|
| `getTrafficIncidents` | Fetch traffic incidents within an area (viewport, named place, route corridor, polygon, IDs). By default, the entry keeps refreshing |
|
|
121
121
|
| `setTrafficIncidentsMonitor` | Turn background refreshing of an already-loaded incidents entry on or off |
|
|
122
122
|
| `clusterIncidents` | Group loaded incidents into hotspots (DBSCAN) with road and category labels, delay totals and trends |
|
|
123
|
-
| `focusIncidents` | Highlight a subset of incidents
|
|
123
|
+
| `focusIncidents` | Highlight a subset of incidents by id (`analyseData` can pick them by category or severity) on the map and dim the rest |
|
|
124
124
|
| `getTrafficAreaAnalytics` | Fetch historical traffic analytics (speed, congestion, travel time) for an area |
|
|
125
125
|
|
|
126
126
|
### Trackers
|
|
@@ -199,9 +199,9 @@ const agent = createMapAgent(map, {
|
|
|
199
199
|
|
|
200
200
|
| Tool | Description |
|
|
201
201
|
|---|---|
|
|
202
|
-
| `recallState` | Read session state: a snapshot of
|
|
202
|
+
| `recallState` | Read session state: a snapshot of the places, routes and ranges entries with the map style and layer configs, one kind's entries (`places`, `routes`, `ranges`, `geometries`, `byod`, …), or one entry by `{ kind, id }` |
|
|
203
203
|
| `setEntryMode` | Switch a slice between `multiple` (default) and `single` entry modes |
|
|
204
|
-
| `resetState` | Reset
|
|
204
|
+
| `resetState` | Reset every state slice and the map style to their defaults |
|
|
205
205
|
|
|
206
206
|
### Utilities
|
|
207
207
|
|
|
@@ -485,22 +485,26 @@ const agent = createMapAgent(map, {
|
|
|
485
485
|
|
|
486
486
|
### Wrapping default tools
|
|
487
487
|
|
|
488
|
-
To add logging, analytics or custom behavior around an existing tool, wrap it
|
|
488
|
+
To add logging, analytics or custom behavior around an existing tool, wrap it. `DEFAULT_TOOLS` types
|
|
489
|
+
each value as a `ToolDefinition`: `locatePlace` is a static `ToolEntry`, while builders such as
|
|
490
|
+
`discoverPlaces` are functions of `ToolBuildOptions` that return one.
|
|
489
491
|
|
|
490
492
|
```typescript
|
|
491
|
-
import { DEFAULT_TOOLS, createMapAgent } from '@tomtom-org/maps-sdk-plugin-agent-toolkit';
|
|
492
|
-
|
|
493
|
-
const
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
console.log('[Analytics]
|
|
493
|
+
import { DEFAULT_TOOLS, createMapAgent, type ToolEntry } from '@tomtom-org/maps-sdk-plugin-agent-toolkit';
|
|
494
|
+
|
|
495
|
+
const locatePlace = DEFAULT_TOOLS.locatePlace as ToolEntry;
|
|
496
|
+
|
|
497
|
+
const wrappedLocatePlace: ToolEntry = {
|
|
498
|
+
...locatePlace,
|
|
499
|
+
execute: async (input, state, options) => {
|
|
500
|
+
console.log('[Analytics] Locate:', input);
|
|
501
|
+
const result = await locatePlace.execute(input, state, options);
|
|
502
|
+
console.log('[Analytics] Result:', result);
|
|
499
503
|
return result;
|
|
500
504
|
},
|
|
501
505
|
};
|
|
502
506
|
|
|
503
|
-
createMapAgent(map, { model, tools: {
|
|
507
|
+
createMapAgent(map, { model, tools: { locatePlace: wrappedLocatePlace } });
|
|
504
508
|
```
|
|
505
509
|
|
|
506
510
|
### Common configuration patterns
|
|
@@ -585,4 +589,4 @@ See `LICENSE.txt`.
|
|
|
585
589
|
|
|
586
590
|
## Security
|
|
587
591
|
|
|
588
|
-
To report a security vulnerability, follow [
|
|
592
|
+
To report a security vulnerability, follow our [security policy](https://github.com/tomtom-international/maps-sdk-js/security/policy), which keeps it private.
|