@tomtom-org/maps-sdk-plugin-agent-toolkit 0.2.12 → 0.3.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # TomTom Maps SDK - Agent Toolkit Plugin
2
2
 
3
- A headless conversational agent that gives Large Language Models tool-based control over a [TomTom Map](https://developer.tomtom.com/) and TomTom location services, powered by [Vercel AI SDK v6](https://ai-sdk.dev/).
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
 
5
5
  No UI is included — bring your own chat interface. No LLM provider is bundled — supply any AI SDK-compatible model.
6
6
 
@@ -69,7 +69,7 @@ function ChatPanel() {
69
69
  }
70
70
  ```
71
71
 
72
- See [`examples/map-chat-agent`](../../examples/map-chat-agent) for a full working example.
72
+ See [`examples/map-chat-agent-react`](../../examples/map-chat-agent-react) for a full working example.
73
73
 
74
74
  ## Tools reference
75
75
 
@@ -115,8 +115,9 @@ The plugin ships a `DEFAULT_TOOLS` registry covering search, routing, traffic, r
115
115
 
116
116
  | Tool | Description |
117
117
  |---|---|
118
- | `addByodLayer` | Ingest a customer-authored GeoJSON layer from a URL or inline `FeatureCollection` |
118
+ | `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 via `setByodLayers` |
119
119
  | `recallByod` | List BYOD entries, or retrieve a single entry's full `FeatureCollection` by id |
120
+ | `setByodLayers` | Restyle a BYOD entry — replace its MapLibre layers (type + data-driven paint) using the entry's data `profile` |
120
121
  | `updateByodDisplay` | Show, hide, or clear BYOD layers on the map |
121
122
 
122
123
  > See the [Bring your own data](https://docs.tomtom.com/maps-sdk-js/guides/plugins/agent-toolkit/byod) guide for ingestion patterns, visibility lifecycle, and how BYOD entries feed into `analyseData` / `processData`.
@@ -580,4 +581,4 @@ export type * from '@tomtom-org/maps-sdk-plugin-agent-toolkit';
580
581
  - [AI SDK v6 documentation](https://ai-sdk.dev/)
581
582
  - [TomTom Maps SDK documentation](https://developer.tomtom.com/)
582
583
  - [Engineering guidelines](./ENGINEERING-GUIDELINES.md) — tool design standards, state management, system prompt structure
583
- - [Example application](../../examples/map-chat-agent) — full chat interface implementation
584
+ - [Example application](../../examples/map-chat-agent-react) — full chat interface implementation
package/dist/index.d.ts CHANGED
@@ -46,10 +46,9 @@ import { z } from 'zod';
46
46
  */
47
47
  declare type AddBYODEntryOptions = {
48
48
  /**
49
- * Explicit MapLibre layer specs. When omitted, the slice inspects the
50
- * FeatureCollection and picks defaults by geometry type
51
- * (Point → circle, Line → line, Polygon → fill). Mixed-kind entries get
52
- * one layer per kind present.
49
+ * Explicit MapLibre layer specs. Layers are never derived automatically:
50
+ * when omitted the entry is created with no layers and renders nothing until
51
+ * they are set — by the agent via `setByodLayers`, or by passing them here.
53
52
  */
54
53
  layers?: CustomGeoJSONLayerSpec[];
55
54
  /** Provenance for the data. Defaults to `{ kind: 'integrator' }`. */
@@ -105,6 +104,44 @@ declare class BaseMapState implements StateSlice {
105
104
 
106
105
  /* Excluded from this release type: buildSystemPrompt */
107
106
 
107
+ /**
108
+ * A single analysis result attached to a BYOD entry. Produced by `analyseData`
109
+ * when the entry is passed via `byodEntryIDs`; `data` is whatever the dynamic
110
+ * code returned. Structurally identical to the other slices' analysis records
111
+ * so the shared attach helper treats every slice uniformly.
112
+ *
113
+ * @group Agent Toolkit
114
+ */
115
+ export declare type BYODAnalysis = {
116
+ /** Unique name within the parent entry (used as a key for the UI). */
117
+ name: string;
118
+ timestamp: number;
119
+ /** Optional human-readable description of what the analysis computed. */
120
+ description?: string;
121
+ /** How `data` should be interpreted — plain JSON or a Chart.js configuration. */
122
+ outputFormat: AnalysisOutputFormat;
123
+ /** Arbitrary analysis result returned by the dynamic code. */
124
+ data: unknown;
125
+ };
126
+
127
+ /**
128
+ * Token-frugal description of a BYOD FeatureCollection's runtime shape: feature
129
+ * count, the geometry types present, and a per-property profile. Stored on every
130
+ * {@link BYODEntry} and surfaced through `addByodSource` / `recallByod`
131
+ * so the model never has to receive raw GeoJSON just to learn the schema.
132
+ *
133
+ * @group Agent Toolkit
134
+ */
135
+ export declare type BYODDataProfile = {
136
+ featureCount: number;
137
+ /** GeoJSON geometry types present (Point / LineString / Polygon / …). */
138
+ geometryTypes: string[];
139
+ /** Per-property profile, highest-coverage first. Capped — see `propertiesOmitted`. */
140
+ properties: BYODPropertyProfile[];
141
+ /** Count of property keys omitted when the collection has more distinct keys than the cap. */
142
+ propertiesOmitted?: number;
143
+ };
144
+
108
145
  /**
109
146
  * A single entry in the BYOD (bring-your-own-data) GeoJSON history. Each entry
110
147
  * is a customer-authored layer the agent can read, render, query, or pipe
@@ -120,9 +157,16 @@ export declare type BYODEntry = {
120
157
  /** Provenance for the data — used by recall tools and the UI. */
121
158
  source: BYODSource;
122
159
  /**
123
- * MapLibre layer specs the slice will render this entry under. When omitted
124
- * at `addEntry` time the slice fills this in with sensible defaults based
125
- * on the entry's geometry types (Point → circle, Line → line, Polygon → fill).
160
+ * Runtime-inferred shape of `data` — geometry types and a per-property
161
+ * profile. Derived once at `addEntry` time (see `profileFeatureCollection`)
162
+ * so recall / ingest tools can describe the data to the model without
163
+ * shipping the full FeatureCollection.
164
+ */
165
+ profile: BYODDataProfile;
166
+ /**
167
+ * MapLibre layer specs the slice renders this entry under. Always explicit —
168
+ * empty until set via `setByodLayers` (the agent path) or by passing `layers`
169
+ * to `addEntry`. An entry with no layers renders nothing.
126
170
  */
127
171
  layers: CustomGeoJSONLayerSpec[];
128
172
  /**
@@ -133,13 +177,30 @@ export declare type BYODEntry = {
133
177
  _module?: CustomGeoJSONModule;
134
178
  /** True while this entry's `_module` is rendering on the map. */
135
179
  _shown?: boolean;
180
+ /**
181
+ * Analyses attached by `analyseData` (keyed by `name` — re-running an analysis with the
182
+ * same name replaces it). Empty / absent until the first analysis runs against this entry.
183
+ */
184
+ _analysis?: BYODAnalysis[];
185
+ };
186
+
187
+ /** Compact profile of one feature-`properties` key across the whole collection. */
188
+ export declare type BYODPropertyProfile = {
189
+ /** Property key as it appears in `feature.properties`. */
190
+ name: string;
191
+ /** Distinct JSON value types seen for this key (e.g. `["string"]`, `["number", "null"]`). */
192
+ types: string[];
193
+ /** Fraction of features carrying this key, 0–1 (1 = present on every feature). */
194
+ coverage: number;
195
+ /** Up to a few short, distinct example values — lets the LLM infer semantics. */
196
+ examples: Array<string | number | boolean>;
136
197
  };
137
198
 
138
199
  /**
139
200
  * Where a BYOD entry came from.
140
201
  * - `integrator`: seeded programmatically by the embedding app (e.g. user-uploaded file).
141
- * - `url`: fetched from a URL via `addByodLayer`.
142
- * - `inline`: passed as inline GeoJSON via `addByodLayer`.
202
+ * - `url`: fetched from a URL via `addByodSource`.
203
+ * - `inline`: passed as inline GeoJSON via `addByodSource`.
143
204
  *
144
205
  * @group Agent Toolkit
145
206
  */
@@ -185,11 +246,25 @@ declare class BYODState implements ShownEntriesSlice, StateSlice {
185
246
  * rendered on top of a still-visible old one). Returns the assigned id.
186
247
  */
187
248
  addEntry(data: FeatureCollection, label: string, options?: AddBYODEntryOptions): Promise<string>;
249
+ /**
250
+ * Replace the MapLibre layer specs an entry renders under. When the entry already owns a
251
+ * module (it has been shown at least once) the new specs are pushed live via the module's
252
+ * `applyConfig` runtime layer diff — no tear-down, no flicker. When no module exists yet the
253
+ * specs are stored and the next {@link showEntry} picks them up. Throws on an unknown id.
254
+ */
255
+ setEntryLayers(entryId: string, layers: CustomGeoJSONLayerSpec[]): void;
256
+ /**
257
+ * Attach an analysis to an existing entry (replace if a result of the same name exists).
258
+ * Mirrors {@link CustomGeometriesState.addAnalysisToEntry} so the shared `analyseData`
259
+ * attach helper treats BYOD like every other analysable slice. No-op (returns `false`)
260
+ * when the entry is unknown.
261
+ */
262
+ addAnalysisToEntry(entryId: string, analysis: BYODAnalysis): boolean;
188
263
  /**
189
264
  * Lazy-init the entry's CustomGeoJSONModule. The module is created with a
190
- * single source named `data`, configured with this entry's `layers`. Layer
191
- * changes after creation are not supported — drop the entry and add it back
192
- * to swap layers.
265
+ * single source named `data`, configured with this entry's `layers`. To swap
266
+ * layers after creation, call {@link setEntryLayers} — it pushes the new specs
267
+ * into this module via `applyConfig` rather than recreating it.
193
268
  */
194
269
  getEntryModule(entryId: string): Promise<CustomGeoJSONModule>;
195
270
  /** Render this entry on the map. */
@@ -219,6 +294,11 @@ declare type BYODStateEvents = {
219
294
  'shown-change': ReadonlySet<string>;
220
295
  /** Display policy switched between `single` and `multiple`. */
221
296
  'mode-change': EntryMode;
297
+ /** An analysis was attached to (or replaced on) an entry by `analyseData`. */
298
+ 'analysis-added': {
299
+ entryId: string;
300
+ analysis: BYODAnalysis;
301
+ };
222
302
  };
223
303
 
224
304
  /**
@@ -585,7 +665,8 @@ export declare const DEFAULT_TOOLS: {
585
665
  recallGeometries: ToolDefinition;
586
666
  recallPlaces: ToolDefinition;
587
667
  recallByod: ToolDefinition;
588
- addByodLayer: ToolDefinition;
668
+ addByodSource: ToolDefinition;
669
+ setByodLayers: ToolDefinition;
589
670
  updateByodDisplay: ToolDefinition;
590
671
  recallRoutes: ToolDefinition;
591
672
  getCurrentWaypoints: ToolDefinition;
@@ -721,10 +802,18 @@ export declare type FeatureFlags = {
721
802
  */
722
803
  export declare const formatStateDigestDiff: (prev: StateDigest, next: StateDigest) => string | null;
723
804
 
724
- /** Tagged id for any polygon source in session state. */
805
+ /**
806
+ * Tagged id for any polygon source in session state.
807
+ *
808
+ * @group Agent Toolkit
809
+ */
725
810
  export declare type GeometriesId = z.infer<typeof geometriesIdSchema>;
726
811
 
727
- /** Possible kinds in a geometries id. */
812
+ /**
813
+ * Possible kinds in a geometries id.
814
+ *
815
+ * @group Agent Toolkit
816
+ */
728
817
  export declare type GeometriesIdKind = 'place' | 'places' | 'ranges' | 'customGeometries';
729
818
 
730
819
  /**
@@ -957,6 +1046,12 @@ declare type IncidentsAnalysisSpec = {
957
1046
  source: string;
958
1047
  };
959
1048
 
1049
+ /**
1050
+ * A fresh batch of incidents from a single monitor tick, with the moment it was sampled.
1051
+ * Payload of {@link TrafficIncidentsStateEvents.monitor-tick}.
1052
+ *
1053
+ * @group Agent Toolkit
1054
+ */
960
1055
  export declare type IncidentSnapshot = {
961
1056
  takenAt: number;
962
1057
  incidents: TrafficIncident_2[];
@@ -1066,7 +1161,7 @@ export declare type MapAgentOptions<CS extends ToolState = ToolState> = {
1066
1161
  * dataEntries: {
1067
1162
  * routes: { entryMode: 'single' },
1068
1163
  * incidents: { entryMode: 'single' },
1069
- * byod: { enabled: false }, // disables recallByod, addByodLayer, updateByodDisplay + byod scope on analyse/process
1164
+ * byod: { enabled: false }, // disables recallByod, addByodSource, setByodLayers, updateByodDisplay + byod scope on analyse/process
1070
1165
  * ranges: { enabled: false }, // disables findReachableAreas + recallRanges
1071
1166
  * },
1072
1167
  * });
@@ -1159,6 +1254,12 @@ declare class MapPOIsState implements StateSlice {
1159
1254
  reset(): void;
1160
1255
  }
1161
1256
 
1257
+ /**
1258
+ * The geographic area a {@link TrafficIncidentsEntry} monitor is polling, captured at
1259
+ * monitor-start time and replayed on every tick.
1260
+ *
1261
+ * @group Agent Toolkit
1262
+ */
1162
1263
  export declare type MonitoredArea = {
1163
1264
  bbox: BBox_2;
1164
1265
  capturedAt: number;
@@ -1392,6 +1493,12 @@ declare type PlacesStateEvents = {
1392
1493
  'mode-change': EntryMode;
1393
1494
  };
1394
1495
 
1496
+ /**
1497
+ * Lifecycle state of a per-entry incidents monitor. `stopped-error` indicates the last
1498
+ * poll failed and the timer has been cleared — start the monitor again to retry.
1499
+ *
1500
+ * @group Agent Toolkit
1501
+ */
1395
1502
  export declare type PollingStatus = 'idle' | 'running' | 'stopped-error';
1396
1503
 
1397
1504
  declare type ProviderOptions = Record<string, Record<string, JSONValue | undefined>>;
@@ -2035,7 +2142,7 @@ export declare type ToolNameHint = ToolName | (string & {});
2035
2142
  *
2036
2143
  * @group Agent Toolkit
2037
2144
  */
2038
- export declare const TOOLS_BY_DATA_ENTRY_KIND: Record<DataEntryKind, readonly string[]>;
2145
+ export declare const TOOLS_BY_DATA_ENTRY_KIND: Record<DataEntryKind, readonly ToolName[]>;
2039
2146
 
2040
2147
  /**
2041
2148
  * State passed to tool factory functions. Organized by feature area,
@@ -2218,6 +2325,12 @@ declare type TrafficAreaAnalyticsStateEvents = {
2218
2325
  'mode-change': EntryMode;
2219
2326
  };
2220
2327
 
2328
+ /**
2329
+ * A single traffic-incidents history entry: the captured query, its incidents, and the
2330
+ * per-entry rendering / monitoring / analysis state owned by {@link TrafficIncidentsState}.
2331
+ *
2332
+ * @group Agent Toolkit
2333
+ */
2221
2334
  export declare type TrafficIncidentsEntry = {
2222
2335
  id: string;
2223
2336
  timestamp: number;
@@ -2321,9 +2434,8 @@ declare class TrafficIncidentsState implements StateSlice {
2321
2434
  replaceEntryData(entryId: TrafficIncidentsEntry['id'], data: TrafficIncident[], sampledAt: number): Promise<boolean>;
2322
2435
  /**
2323
2436
  * Lazy-init and return the entry's TrafficIncidentOverlayModule. Consumers subscribe to
2324
- * clicks directly on the returned module via `module.events.on('click', ...)`; use
2325
- * `module.distinctIncidents(features)` inside the handler if a stacked-click count is
2326
- * needed. Throws on unknown entry id.
2437
+ * clicks directly on the returned module via `module.events.on('click', ...)`;
2438
+ * Throws on unknown entry id.
2327
2439
  */
2328
2440
  getEntryModule(entryId: TrafficIncidentsEntry['id']): Promise<TrafficIncidentOverlayModule>;
2329
2441
  /**