@tomtom-org/maps-sdk-plugin-agent-toolkit 0.2.6 → 0.2.11

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/dist/index.d.ts CHANGED
@@ -2,6 +2,9 @@ import { BaseMapModule } from '../../../../map/dist';
2
2
  import { BBox } from '../../../../core/dist';
3
3
  import { BBox as BBox_2 } from '../../../../../core/dist';
4
4
  import { CommonPlaceProps } from '../../../../core/dist';
5
+ import { CustomGeoJSONLayerSpec } from '../../../../map/dist';
6
+ import { CustomGeoJSONModule } from '../../../../map/dist';
7
+ import { FeatureCollection } from 'geojson';
5
8
  import { GeometriesModule } from '../../../../map/dist';
6
9
  import { GeometryTheme } from '../../../../map/dist';
7
10
  import { HillshadeModule } from '../../../../map/dist';
@@ -36,6 +39,28 @@ import { TrafficIncidentsModule } from '../../../../map/dist';
36
39
  import { WaypointLike } from '../../../../core/dist';
37
40
  import { z } from 'zod';
38
41
 
42
+ /**
43
+ * Options accepted by {@link BYODState.addEntry}.
44
+ *
45
+ * @group Agent Toolkit
46
+ */
47
+ declare type AddBYODEntryOptions = {
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.
53
+ */
54
+ layers?: CustomGeoJSONLayerSpec[];
55
+ /** Provenance for the data. Defaults to `{ kind: 'integrator' }`. */
56
+ source?: BYODSource;
57
+ /**
58
+ * Semantic entry id. Auto-suffixed (`-2`, `-3`, …) on collision. Defaults
59
+ * to `byod-N`.
60
+ */
61
+ explicitId?: string;
62
+ };
63
+
39
64
  declare type AnalysisOutputFormat = 'json' | 'chart';
40
65
 
41
66
  /**
@@ -57,7 +82,7 @@ declare type AnalysisOutputFormat = 'json' | 'chart';
57
82
  *
58
83
  * @group Agent Toolkit
59
84
  */
60
- export declare const BASE_SYSTEM_PROMPT = "You are a helpful map assistant with access to a TomTom interactive map and location services.\nIf a request is completely unrelated to geospatial topics, gracefully decline and steer the user back to map-related tasks you can help with.\n\nCOORDINATE ORDER:\n- All coordinates are [longitude, latitude] (GeoJSON standard)\n- All bounding boxes are [minLng, minLat, maxLng, maxLat]\n\nTOOL EXECUTION:\n- Call context-independent tools in the same step (parallel execution).\n- Many service tools have a show or showOnMap parameter \u2014 use it to display results on the map in one step instead of calling a separate show tool afterward.\n- Use standalone updatePlacesDisplay / updateRoutesDisplay / showWaypoints only when displaying results already in context from a previous step.\n\nSESSION STATE & ENTRIES:\n- Three append-only histories live in the session: `places`, `routes`, `ranges`. Each tool call that produces results stores a new ENTRY (id like `places-3`, `routes-1`, `ranges-0`) \u2014 these ids stay stable and are accepted by every show / recall / processX tool.\n- Each slice has an `entryMode`: `multiple` (default \u2014 overlay several entries on the map) or `single` (only the latest entry stays; switching to it auto-drops every older entry from history). Inspect via `recallState` / `recallPlaces` / `recallRoutes` / `recallRanges`. Flip with `setEntryMode({ slice, mode })` when the user asks to \"only show one at a time\" or \"let me overlay multiple\".\n- Mode is sticky across turns \u2014 under `single`, calling another `discoverPlaces` automatically replaces the previous places entry.\n- Always check `recallX` (or `recallState`) before guessing entry ids; never invent them.\n\nLOCATION REFERENCE:\n- \"near me\" / \"my location\" / \"where I am\" \u2192 getCurrentLocation (user's physical GPS position, may prompt permission)\n- \"in this area\" / \"here on the map\" / \"near the map center\" \u2192 getViewport (map's current view)\n- If getCurrentLocation fails due to permission denial, fall back to getViewport as the reference point\n\nRESPONSE FORMATTING:\n- Use markdown in all responses\n- Show key information in bold\n- Use bullet lists when presenting multiple items or results\n- Keep responses concise \u2014 lead with the most relevant information\n\n";
85
+ export declare const BASE_SYSTEM_PROMPT = "You are a helpful map assistant with access to a TomTom interactive map and location services.\nIf a request is completely unrelated to geospatial topics, gracefully decline and steer the user back to map-related tasks you can help with.\n\nCOORDINATE ORDER:\n- All coordinates are [longitude, latitude] (GeoJSON standard)\n- All bounding boxes are [minLng, minLat, maxLng, maxLat]\n\nTOOL EXECUTION:\n- Call context-independent tools in the same step (parallel execution).\n- Many service tools have a show or showOnMap parameter \u2014 use it to display results on the map in one step instead of calling a separate show tool afterward.\n- Use standalone updatePlacesDisplay / updateRoutesDisplay / updateWaypointsDisplay only when displaying results already in context from a previous step.\n\nSESSION STATE & ENTRIES:\n- Seven append-only histories live in the session: `places`, `routes`, `ranges`, `customGeometries`, `trafficAreaAnalytics`, `trafficIncidents`, `byod`. Each tool call that produces results stores a new ENTRY (id like `places-3`, `routes-1`, `byod-0`) \u2014 these ids stay stable and are accepted by every show / recall / `processData` / `analyseData` tool via the matching `*EntryIDs` field.\n- Each slice has an `entryMode`: `multiple` (default \u2014 overlay several entries on the map) or `single` (only the latest entry stays; switching to it auto-drops every older entry from history). Inspect via `recallState` / `recallPlaces` / `recallRoutes` / `recallRanges` / `recallGeometries` / `recallByod` (traffic slices surface via `recallState`). Flip with `setEntryMode({ slice, mode })` when the user asks to \"only show one at a time\" or \"let me overlay multiple\".\n- Mode is sticky across turns \u2014 under `single`, calling another `discoverPlaces` automatically replaces the previous places entry.\n- Always check `recallX` (or `recallState`) before guessing entry ids; never invent them.\n\nLOCATION REFERENCE:\n- \"near me\" / \"my location\" / \"where I am\" \u2192 getCurrentLocation (user's physical GPS position, may prompt permission)\n- \"in this area\" / \"here on the map\" / \"near the map center\" \u2192 getViewport (map's current view)\n- If getCurrentLocation fails due to permission denial, fall back to getViewport as the reference point\n\nRESPONSE FORMATTING:\n- Use markdown in all responses\n- Show key information in bold\n- Use bullet lists when presenting multiple items or results\n- Keep responses concise \u2014 lead with the most relevant information\n\n";
61
86
 
62
87
  /**
63
88
  * State for base map display: style, language, viewport, layers, and hillshade.
@@ -80,6 +105,122 @@ declare class BaseMapState implements StateSlice {
80
105
 
81
106
  /* Excluded from this release type: buildSystemPrompt */
82
107
 
108
+ /**
109
+ * A single entry in the BYOD (bring-your-own-data) GeoJSON history. Each entry
110
+ * is a customer-authored layer the agent can read, render, query, or pipe
111
+ * through analyseData / processData.
112
+ *
113
+ * @group Agent Toolkit
114
+ */
115
+ export declare type BYODEntry = {
116
+ id: string;
117
+ timestamp: number;
118
+ label: string;
119
+ data: FeatureCollection;
120
+ /** Provenance for the data — used by recall tools and the UI. */
121
+ source: BYODSource;
122
+ /**
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).
126
+ */
127
+ layers: CustomGeoJSONLayerSpec[];
128
+ /**
129
+ * Per-entry CustomGeoJSONModule. Each entry owns its own module so display state
130
+ * (currently-rendered feature set, visibility) lives on the entry instead of a
131
+ * shared slice-level module. Lazy-initialised via BYODState helpers.
132
+ */
133
+ _module?: CustomGeoJSONModule;
134
+ /** True while this entry's `_module` is rendering on the map. */
135
+ _shown?: boolean;
136
+ };
137
+
138
+ /**
139
+ * Where a BYOD entry came from.
140
+ * - `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`.
143
+ *
144
+ * @group Agent Toolkit
145
+ */
146
+ export declare type BYODSource = {
147
+ kind: 'integrator';
148
+ description?: string;
149
+ } | {
150
+ kind: 'url';
151
+ url: string;
152
+ } | {
153
+ kind: 'inline';
154
+ description?: string;
155
+ };
156
+
157
+ /**
158
+ * State slice for BYOD (bring-your-own-data) GeoJSON layers — customer-owned
159
+ * data that doesn't fit places / routes / ranges / custom-geometries. Each
160
+ * entry wraps a {@link CustomGeoJSONModule} so the agent can render, query,
161
+ * and pipe it through analyseData / processData.
162
+ *
163
+ * Per-entry display model mirrors {@link CustomGeometriesState}: every entry
164
+ * owns its own module, lazy-initialised on first show.
165
+ *
166
+ * @group Agent Toolkit
167
+ */
168
+ declare class BYODState implements ShownEntriesSlice, StateSlice {
169
+ private readonly _ttMap;
170
+ private _entries;
171
+ private _entryMode;
172
+ /** Subscribe to state changes — see {@link BYODStateEvents}. */
173
+ readonly events: StateEvents<BYODStateEvents>;
174
+ constructor(_ttMap: TomTomMap);
175
+ get entries(): readonly BYODEntry[];
176
+ get latestEntry(): BYODEntry | undefined;
177
+ /** Set of BYOD entry ids currently rendered on the map. */
178
+ get shownEntryIds(): ReadonlySet<string>;
179
+ get entryMode(): EntryMode;
180
+ setEntryMode(mode: EntryMode): Promise<void>;
181
+ findById(entryId: string): BYODEntry | undefined;
182
+ /**
183
+ * Append a new BYOD entry. Under `single` mode the new entry replaces every older one (hides
184
+ * + drops them before the new entry is pushed, so the caller never sees the new entry
185
+ * rendered on top of a still-visible old one). Returns the assigned id.
186
+ */
187
+ addEntry(data: FeatureCollection, label: string, options?: AddBYODEntryOptions): Promise<string>;
188
+ /**
189
+ * 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.
193
+ */
194
+ getEntryModule(entryId: string): Promise<CustomGeoJSONModule>;
195
+ /** Render this entry on the map. */
196
+ showEntry(entryId: string): Promise<void>;
197
+ private _hideOthersUnderSingleMode;
198
+ hideEntry(entryId: string): Promise<void>;
199
+ /** Drop a single entry from history (clears its module first). No-op when unknown. */
200
+ removeEntry(entryId: string): Promise<void>;
201
+ private _requireEntry;
202
+ /**
203
+ * Hide every BYOD layer currently on the map. Map-only — history is kept.
204
+ * Implements {@link ClearableMapSlice}.
205
+ */
206
+ clearShown(): Promise<void>;
207
+ reset(): void;
208
+ }
209
+
210
+ /**
211
+ * Events fired by {@link BYODState}. Subscribe via `state.byod.events.on(type, handler)`.
212
+ *
213
+ * @group Agent Toolkit
214
+ */
215
+ declare type BYODStateEvents = {
216
+ /** History changed — entry added, removed, or cleared via `reset()`. */
217
+ 'entries-change': readonly BYODEntry[];
218
+ /** Set of entries currently rendered on the map changed. */
219
+ 'shown-change': ReadonlySet<string>;
220
+ /** Display policy switched between `single` and `multiple`. */
221
+ 'mode-change': EntryMode;
222
+ };
223
+
83
224
  /**
84
225
  * Result returned by {@link classifyUserIntent}.
85
226
  *
@@ -88,6 +229,14 @@ declare class BaseMapState implements StateSlice {
88
229
  export declare type ClassificationResult = {
89
230
  /** Tool names selected by the classifier. */
90
231
  activeToolNames: string[];
232
+ /**
233
+ * Optional per-tool scope. Keyed by tool name, value is the raw classifier
234
+ * output for that tool — validated against the tool's `scopeSchema` in
235
+ * `prepareStep` before any narrowing is applied. Tools without
236
+ * `scopeSchema`, or for which the classifier omitted a scope, retain
237
+ * their full description and inputSchema for the turn.
238
+ */
239
+ toolScopes?: Record<string, unknown>;
91
240
  /** Wall-clock time in ms for the classification step only (not the agent response). */
92
241
  timeMs: number;
93
242
  /** Token usage for the classification LLM call. */
@@ -219,7 +368,7 @@ export declare const createMapAgent: <CS extends ToolState = ToolState>(map: Tom
219
368
 
220
369
  /**
221
370
  * A single aggregation/analysis result attached to a custom-geometries entry.
222
- * Produced by the `analyseGeometries` tool; `data` is whatever the dynamic code returned.
371
+ * Produced by `analyseData`; `data` is whatever the dynamic code returned.
223
372
  *
224
373
  * @group Agent Toolkit
225
374
  */
@@ -236,9 +385,9 @@ export declare type CustomGeometriesAnalysis = {
236
385
  };
237
386
 
238
387
  /**
239
- * A single entry in the custom-geometries history — output of
240
- * processGeometries (and any future polygon-producing tool that doesn't
241
- * naturally belong to places or ranges).
388
+ * A single entry in the custom-geometries history — output of `processData`
389
+ * (and any future polygon-producing tool that doesn't naturally belong to
390
+ * places or ranges).
242
391
  *
243
392
  * @group Agent Toolkit
244
393
  */
@@ -265,7 +414,7 @@ export declare type CustomGeometriesEntry = {
265
414
  };
266
415
 
267
416
  /**
268
- * State for derived / custom geometries — output of `processGeometries` and any future
417
+ * State for derived / custom geometries — output of `processData` and any future
269
418
  * polygon-producing tool whose result doesn't belong to a place or a reachable-range entry.
270
419
  *
271
420
  * Each entry owns a dedicated GeometriesModule, lazy-initialised on first show, mirroring
@@ -297,7 +446,7 @@ declare class CustomGeometriesState implements ShownEntriesSlice, StateSlice {
297
446
  * Append a new entry. If `explicitId` collides, the slice auto-suffixes (`-2`, `-3`, ...).
298
447
  * Returns the assigned id. Under `single` mode the new entry replaces every older one.
299
448
  */
300
- addEntry(features: PolygonFeature<CommonPlaceProps>[], provenance: CustomGeometriesEntry['provenance'], label: string, explicitId?: string): string;
449
+ addEntry(features: PolygonFeature<CommonPlaceProps>[], provenance: CustomGeometriesEntry['provenance'], label: string, explicitId?: string): Promise<string>;
301
450
  /** Attach an analysis to an existing entry (replace if a result of the same name exists). */
302
451
  addAnalysisToEntry(entryId: string, analysis: CustomGeometriesAnalysis): boolean;
303
452
  /** Lazy-init the entry's GeometriesModule, applying / re-applying the requested theme. */
@@ -319,7 +468,11 @@ declare class CustomGeometriesState implements ShownEntriesSlice, StateSlice {
319
468
  /** Drop a single entry from history (clears its module first). No-op when unknown. */
320
469
  removeEntry(entryId: string): Promise<void>;
321
470
  private _requireEntry;
322
- private _uniqueEntryId;
471
+ /**
472
+ * Hide every custom-geometries entry currently on the map. Map-only — history is kept.
473
+ * Implements {@link ClearableMapSlice}.
474
+ */
475
+ clearShown(): Promise<void>;
323
476
  reset(): void;
324
477
  }
325
478
 
@@ -343,6 +496,57 @@ declare type CustomGeometriesStateEvents = {
343
496
  'mode-change': EntryMode;
344
497
  };
345
498
 
499
+ /**
500
+ * Mapping from {@link DataEntryKind} (LLM-facing name) to the {@link ToolState} slice key
501
+ * that owns the entries for that kind. Used by `createMapAgent` to apply `entryMode` from
502
+ * `dataEntries[kind].entryMode` to the right slice.
503
+ *
504
+ * @group Agent Toolkit
505
+ */
506
+ export declare const DATA_ENTRY_KIND_TO_SLICE: {
507
+ readonly places: "places";
508
+ readonly routes: "routing";
509
+ readonly incidents: "trafficIncidents";
510
+ readonly customGeometries: "customGeometries";
511
+ readonly trafficAreaAnalytics: "trafficAreaAnalytics";
512
+ readonly byod: "byod";
513
+ readonly ranges: "ranges";
514
+ };
515
+
516
+ /**
517
+ * Per-kind configuration accepted by `createMapAgent`'s `dataEntries` option.
518
+ *
519
+ * @group Agent Toolkit
520
+ */
521
+ export declare type DataEntryConfig = {
522
+ /**
523
+ * When `false`, the kind is removed from the agent's tool surface entirely:
524
+ * - the kind disappears from `analyseData` / `processData` scope and input fields;
525
+ * - related recall / display / fetch tools are dropped from the registry
526
+ * (see {@link TOOLS_BY_DATA_ENTRY_KIND}).
527
+ *
528
+ * Default: `true`.
529
+ */
530
+ enabled?: boolean;
531
+ /**
532
+ * Initial entry-display policy for the underlying slice. `single` keeps only the latest
533
+ * entry on the map (others auto-hide); `multiple` (default) lets several coexist.
534
+ */
535
+ entryMode?: EntryMode;
536
+ };
537
+
538
+ /**
539
+ * Data-entry kind names — the vocabulary used by `dataEntries` on `createMapAgent`. Superset
540
+ * of the analyse/process input kinds (`EntryDataKind`) — adds `ranges`, which has its own
541
+ * entry-mode-supporting slice but is not a top-level input kind for those tools.
542
+ *
543
+ * The kind names are LLM-facing (`routes`, `incidents`) rather than slice names (`routing`,
544
+ * `trafficIncidents`); the slice mapping is internal — see {@link DATA_ENTRY_KIND_TO_SLICE}.
545
+ *
546
+ * @group Agent Toolkit
547
+ */
548
+ export declare type DataEntryKind = 'places' | 'routes' | 'incidents' | 'customGeometries' | 'trafficAreaAnalytics' | 'byod' | 'ranges';
549
+
346
550
  /**
347
551
  * Default tool set for the agent toolkit. Each entry is a {@link ToolDefinition}
348
552
  * — either a static `ToolEntry` or a `ToolEntryBuilder` that tailors the tool to
@@ -357,19 +561,14 @@ export declare const DEFAULT_TOOLS: {
357
561
  locatePlace: ToolDefinition;
358
562
  reverseGeocode: ToolDefinition;
359
563
  discoverPlaces: ToolDefinition;
360
- processPlaces: ToolDefinition;
361
- processGeometries: ToolDefinition;
362
- processRoutes: ToolDefinition;
363
- analyseGeometries: ToolDefinition;
364
- analysePlaces: ToolDefinition;
365
- analyseRoutes: ToolDefinition;
564
+ processData: ToolDefinition;
565
+ analyseData: ToolDefinition;
366
566
  setRoute: ToolDefinition;
367
567
  addWaypointsToRoute: ToolDefinition;
368
568
  removeWaypointsFromRoute: ToolDefinition;
369
569
  replaceWaypointInRoute: ToolDefinition;
370
570
  getPOICategoryCodes: ToolDefinition;
371
571
  getTrafficIncidents: ToolDefinition;
372
- analyseIncidents: ToolDefinition;
373
572
  focusIncidents: ToolDefinition;
374
573
  startTrafficIncidentsMonitor: ToolDefinition;
375
574
  stopTrafficIncidentsMonitor: ToolDefinition;
@@ -377,28 +576,26 @@ export declare const DEFAULT_TOOLS: {
377
576
  queryTrafficAnalytics: ToolDefinition;
378
577
  updatePlacesDisplay: ToolDefinition;
379
578
  updateRoutesDisplay: ToolDefinition;
380
- showTrafficAreaAnalytics: ToolDefinition;
381
- showWaypoints: ToolDefinition;
382
- getShownPlaces: ToolDefinition;
383
- getShownRoutes: ToolDefinition;
384
- getShownWaypoints: ToolDefinition;
385
- getShownRouteTrafficIncidents: ToolDefinition;
386
- getShownIncidents: ToolDefinition;
579
+ updateTrafficAreaAnalyticsDisplay: ToolDefinition;
580
+ updateWaypointsDisplay: ToolDefinition;
581
+ getShownTileIncidents: ToolDefinition;
387
582
  clearMap: ToolDefinition;
388
583
  flyTo: ToolDefinition;
389
584
  getViewport: ToolDefinition;
390
585
  recallGeometries: ToolDefinition;
391
586
  recallPlaces: ToolDefinition;
587
+ recallByod: ToolDefinition;
588
+ addByodLayer: ToolDefinition;
589
+ updateByodDisplay: ToolDefinition;
392
590
  recallRoutes: ToolDefinition;
393
591
  getCurrentWaypoints: ToolDefinition;
394
592
  getStandardMapStyles: ToolDefinition;
395
593
  setMapStandardStyle: ToolDefinition;
396
- setRouteTheme: ToolDefinition;
397
594
  setLanguage: ToolDefinition;
398
- toggleBaseMapLayerGroups: ToolDefinition;
399
- togglePOIs: ToolDefinition;
400
- toggleTrafficFlow: ToolDefinition;
401
- toggleTrafficIncidents: ToolDefinition;
595
+ toggleTilesBaseMapLayerGroups: ToolDefinition;
596
+ toggleTilesPOIs: ToolDefinition;
597
+ toggleTilesTrafficFlow: ToolDefinition;
598
+ toggleTilesTrafficIncidents: ToolDefinition;
402
599
  getMapStyleLayers: ToolDefinition;
403
600
  setLayoutProperties: ToolDefinition;
404
601
  setPaintProperties: ToolDefinition;
@@ -417,6 +614,31 @@ export declare const DEFAULT_TOOLS: {
417
614
  setEntryMode: ToolDefinition;
418
615
  };
419
616
 
617
+ /**
618
+ * Runtime enumeration of slice names that support entry mode. The `satisfies` clause
619
+ * makes drift a compile error: when a new {@link ToolState} slice gains `setEntryMode`,
620
+ * this constant has to be updated before the package will build.
621
+ *
622
+ * @group Agent Toolkit
623
+ */
624
+ export declare const ENTRY_MODE_SLICE_NAMES: readonly EntryModeSliceName[];
625
+
626
+ /**
627
+ * Tool-facing union of state slices that own analysable entries — the
628
+ * vocabulary used by tools that read from multiple slices (`analyseData`,
629
+ * `processData`) and by the classifier when proposing per-call scope.
630
+ *
631
+ * Distinct from {@link EntryModeSliceName}, which uses the literal state-slice
632
+ * keys (`routing`, `trafficIncidents`, …) for state-level operations.
633
+ *
634
+ * `ranges` is intentionally excluded: it feeds the analysis/processing tools
635
+ * only via `geometriesEntryIDs` (its isochrone polygons), not as a direct
636
+ * top-level input.
637
+ *
638
+ * @group Agent Toolkit
639
+ */
640
+ export declare type EntryDataKind = 'places' | 'routes' | 'incidents' | 'customGeometries' | 'trafficAreaAnalytics' | 'byod';
641
+
420
642
  /**
421
643
  * Per-slice display policy. With `multiple` (default) several history entries can be on the
422
644
  * map at once; with `single` only the most recent one stays. Switching from `multiple` to
@@ -427,6 +649,38 @@ export declare const DEFAULT_TOOLS: {
427
649
  */
428
650
  export declare type EntryMode = 'single' | 'multiple';
429
651
 
652
+ /**
653
+ * State slice that owns a history of entries and can be driven into `single` or `multiple`
654
+ * mode. Every {@link ToolState} slice with `setEntryMode` implements this shape, which lets
655
+ * callers (the `setEntryMode` tool, `createMapAgent`'s `dataEntries` option, …) handle the
656
+ * whole family uniformly without listing slice names.
657
+ *
658
+ * @group Agent Toolkit
659
+ */
660
+ export declare interface EntryModeSlice {
661
+ readonly entryMode: EntryMode;
662
+ readonly entries: readonly {
663
+ readonly id: string;
664
+ }[];
665
+ setEntryMode(mode: EntryMode): Promise<void>;
666
+ }
667
+
668
+ /**
669
+ * Compile-time union of {@link ToolState} keys whose slice supports {@link EntryMode}.
670
+ * Names match the {@link ToolState} keys exactly — `routing` (not `routes`),
671
+ * `customGeometries` (not `geometries`) — so the slice name in the tool API never drifts
672
+ * from the property on `state`.
673
+ *
674
+ * Auto-grows when a new slice implements `setEntryMode`: the union picks up the new key,
675
+ * and the runtime list {@link ENTRY_MODE_SLICE_NAMES} fails to type-check until the key
676
+ * is added there too.
677
+ *
678
+ * @group Agent Toolkit
679
+ */
680
+ export declare type EntryModeSliceName = {
681
+ [K in keyof ToolState]: ToolState[K] extends EntryModeSlice ? K : never;
682
+ }[keyof ToolState];
683
+
430
684
  /**
431
685
  * Extracts the text content of the last user message in a message array.
432
686
  * Returns null if no user message is found or if content has no text.
@@ -471,7 +725,7 @@ export declare const formatStateDigestDiff: (prev: StateDigest, next: StateDiges
471
725
  export declare type GeometriesId = z.infer<typeof geometriesIdSchema>;
472
726
 
473
727
  /** Possible kinds in a geometries id. */
474
- export declare type GeometriesIdKind = 'place' | 'places' | 'ranges' | 'custom';
728
+ export declare type GeometriesIdKind = 'place' | 'places' | 'ranges' | 'customGeometries';
475
729
 
476
730
  /**
477
731
  * Tagged geometries id. The Zod schema is exposed so tools can plug it
@@ -490,7 +744,7 @@ export declare const geometriesIdSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
490
744
  kind: z.ZodLiteral<"ranges">;
491
745
  id: z.ZodString;
492
746
  }, z.core.$strip>, z.ZodObject<{
493
- kind: z.ZodLiteral<"custom">;
747
+ kind: z.ZodLiteral<"customGeometries">;
494
748
  id: z.ZodString;
495
749
  }, z.core.$strip>], "kind">;
496
750
 
@@ -500,7 +754,7 @@ export declare const geometriesIdSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
500
754
  * ids in the same form `geometriesEntryIDs` accepts: `{ kind: 'place' }` for
501
755
  * a single place footprint, `{ kind: 'places' }` for every footprint in a
502
756
  * places entry, `{ kind: 'ranges' }` for an isochrone entry,
503
- * `{ kind: 'custom' }` for a derived entry. `operation` is a short label for
757
+ * `{ kind: 'customGeometries' }` for a derived entry. `operation` is a short label for
504
758
  * the kind of computation that produced the entry (e.g. `'union'`, `'buffer'`,
505
759
  * `'h3-coverage'`).
506
760
  *
@@ -513,6 +767,18 @@ export declare type GeometryProvenance = {
513
767
  sourceIds: readonly GeometriesId[];
514
768
  };
515
769
 
770
+ /**
771
+ * Returns each default tool's `examplePrompts` keyed by tool name. Builders are
772
+ * materialised with empty {@link ToolBuildOptions} so the prompts reflect the
773
+ * tool's default (full-surface) shape. Tools without prompts map to `[]`.
774
+ *
775
+ * Surface these in chat UIs to keep starter suggestions in sync with what the
776
+ * tools can actually do — the registry stays the single source of truth.
777
+ *
778
+ * @group Agent Toolkit
779
+ */
780
+ export declare const getDefaultToolPrompts: () => Record<ToolName, readonly string[]>;
781
+
516
782
  /**
517
783
  * Snapshot the user-visible state surface. Call after every assistant turn (to record the
518
784
  * "agent-known" baseline) and again before each user prompt (to detect what changed since).
@@ -660,11 +926,11 @@ declare class IncidentsAnalyses {
660
926
 
661
927
  /**
662
928
  * A single aggregation/analysis result attached to a traffic-incidents entry.
663
- * Produced by the `analyseIncidents` tool; `data` is whatever the dynamic code returned.
929
+ * Produced by `analyseData` (one-shot or `monitor`-rerun); `data` is whatever the dynamic code returned.
664
930
  *
665
931
  * @group Agent Toolkit
666
932
  */
667
- declare type IncidentsAnalysis = {
933
+ export declare type IncidentsAnalysis = {
668
934
  /** Unique name within the parent entry (used as a key for future UI). */
669
935
  name: string;
670
936
  timestamp: number;
@@ -677,8 +943,8 @@ declare type IncidentsAnalysis = {
677
943
  };
678
944
 
679
945
  /**
680
- * A registered, re-executing analysis. Produced by `analyseIncidents`; replayed by
681
- * an entry's {@link IncidentsAnalyses} on every monitor-tick of its source.
946
+ * A registered, re-executing analysis. Produced by `analyseData` with `monitor: { entryId }`;
947
+ * replayed by an entry's {@link IncidentsAnalyses} on every monitor-tick of its source.
682
948
  *
683
949
  * @group Agent Toolkit
684
950
  */
@@ -782,6 +1048,31 @@ export declare type MapAgentOptions<CS extends ToolState = ToolState> = {
782
1048
  * Accessible in custom tool `execute` via the state parameter.
783
1049
  */
784
1050
  state?: Omit<CS, keyof ToolState>;
1051
+ /**
1052
+ * Per-kind data-entry configuration. Each {@link DataEntryKind} accepts
1053
+ * `{ enabled?, entryMode? }`. Setting `enabled: false` removes the kind from the
1054
+ * agent's tool surface entirely — it disappears from `analyseData` / `processData`
1055
+ * scope and input fields, and the slice-specific recall / display / fetch tools
1056
+ * are dropped from the registry. `entryMode` is applied to the underlying slice
1057
+ * right after the agent state is built — before any tool runs.
1058
+ *
1059
+ * Keys are LLM-facing kind names (`routes`, `incidents`) — not slice names
1060
+ * (`routing`, `trafficIncidents`). The slice mapping is internal.
1061
+ *
1062
+ * @example
1063
+ * ```typescript
1064
+ * createMapAgent(map, {
1065
+ * model: openai('gpt-4o'),
1066
+ * dataEntries: {
1067
+ * routes: { entryMode: 'single' },
1068
+ * incidents: { entryMode: 'single' },
1069
+ * byod: { enabled: false }, // disables recallByod, addByodLayer, updateByodDisplay + byod scope on analyse/process
1070
+ * ranges: { enabled: false }, // disables findReachableAreas + recallRanges
1071
+ * },
1072
+ * });
1073
+ * ```
1074
+ */
1075
+ dataEntries?: Partial<Record<DataEntryKind, DataEntryConfig>>;
785
1076
  /**
786
1077
  * Pluggable classifier for automatic tool selection.
787
1078
  * - Omit to use the default LLM-based classifier (uses main model)
@@ -876,7 +1167,7 @@ export declare type MonitoredArea = {
876
1167
 
877
1168
  /**
878
1169
  * A single aggregation/analysis result attached to a places entry.
879
- * Produced by the `analysePlaces` tool; `data` is whatever the dynamic code returned.
1170
+ * Produced by `analyseData`; `data` is whatever the dynamic code returned.
880
1171
  *
881
1172
  * @group Agent Toolkit
882
1173
  */
@@ -907,7 +1198,7 @@ export declare type PlacesEntry = {
907
1198
  /**
908
1199
  * Boundary polygons attached to this entry. One feature per place that has a geometry data
909
1200
  * source (populated lazily via PlacesState.fetchPlaceGeometry), or a standalone result list
910
- * produced by tools like processGeometries. Each feature's `id` is the geometry-data-source id
1201
+ * produced by tools like `processData`. Each feature's `id` is the geometry-data-source id
911
1202
  * (`place.properties.dataSources.geometry.id`), matching the response shape of `geometryData`.
912
1203
  */
913
1204
  geometries?: PolygonFeature<CommonPlaceProps>[];
@@ -918,14 +1209,13 @@ export declare type PlacesEntry = {
918
1209
  /** Lazy place-id → boundary polygon index, built on first lookup through PlacesState.getGeometryForPlace. */
919
1210
  _geometryByPlaceId?: Record<string, PolygonFeature<CommonPlaceProps>>;
920
1211
  /**
921
- * Per-entry display modules. Each entry owns its own PlacesModule per marker theme and a
922
- * dedicated GeometriesModule, so display state lives on the entry rather than on a shared
923
- * slice-level module. Lazy-initialised via PlacesState helpers — undefined until first show.
1212
+ * Per-entry display modules. An entry is rendered under at most one marker theme at a time,
1213
+ * so a single PlacesModule covers all themes — `_showEntryAs` rethemes it via `applyTheme`.
1214
+ * A dedicated GeometriesModule renders the entry's boundary polygons.
1215
+ * Lazy-initialised via PlacesState helpers — undefined until first show.
924
1216
  */
925
1217
  _modules?: {
926
- pin?: PlacesModule;
927
- baseMap?: PlacesModule;
928
- pinClustered?: PlacesModule;
1218
+ places?: PlacesModule;
929
1219
  geometries?: GeometriesModule;
930
1220
  };
931
1221
  /** The marker theme currently rendering this entry, or undefined when hidden. */
@@ -939,10 +1229,10 @@ declare type PlacesMarkerType = 'pin' | 'base-map' | 'pin-clustered';
939
1229
  * State for the places layer: an append-only history of place results plus per-entry display
940
1230
  * modules.
941
1231
  *
942
- * Each entry owns its own PlacesModule (per marker theme: pin / base-map / pin-clustered) and
943
- * a dedicated GeometriesModule, lazy-initialised on first show. The slice no longer holds
944
- * shared modules — display state lives on the entry, so two entries can be rendered side by
945
- * side under different themes without sharing a single source.
1232
+ * Each entry owns a single PlacesModule (rethemed in-place via `applyTheme` when the marker
1233
+ * type changes — an entry only renders under one theme at a time) and a dedicated
1234
+ * GeometriesModule, lazy-initialised on first show. Display state lives on the entry, so two
1235
+ * entries can be rendered side by side under different themes without sharing a single source.
946
1236
  *
947
1237
  * @group Agent Toolkit
948
1238
  */
@@ -966,9 +1256,9 @@ declare class PlacesState implements StateSlice {
966
1256
  */
967
1257
  setEntryMode(mode: EntryMode): Promise<void>;
968
1258
  /**
969
- * Lazy-init and return the entry's PlacesModule for the given marker theme. Each entry
970
- * keeps a separate module per theme so flipping themes for one entry doesn't disturb
971
- * another. Throws when the entry id is unknown.
1259
+ * Lazy-init and return the entry's PlacesModule, rethemed to `markerType`. An entry only
1260
+ * ever renders under one theme at a time, so the same module is reused — flipping themes
1261
+ * calls `applyTheme` in place. Throws when the entry id is unknown.
972
1262
  */
973
1263
  getEntryPlacesModule(entryId: string, markerType: PlacesMarkerType): Promise<PlacesModule>;
974
1264
  /**
@@ -983,8 +1273,7 @@ declare class PlacesState implements StateSlice {
983
1273
  * so we assume the most recent entry is the relevant one to show on the map.
984
1274
  */
985
1275
  get latestPlace(): Place[] | undefined;
986
- addPlaceResult(place: Place | Places, label: string, explicitId?: string, connections?: PlaceConnectionDisplay[], geometries?: PolygonFeature<CommonPlaceProps>[]): string;
987
- private _uniqueEntryId;
1276
+ addPlaceResult(place: Place | Places, label: string, explicitId?: string, connections?: PlaceConnectionDisplay[], geometries?: PolygonFeature<CommonPlaceProps>[]): Promise<string>;
988
1277
  /**
989
1278
  * Attach an analysis result to an existing entry. Analysis names are unique
990
1279
  * within a single entry — adding one with an existing name replaces it.
@@ -1062,6 +1351,11 @@ declare class PlacesState implements StateSlice {
1062
1351
  removeShownEntries(ids: readonly string[]): Promise<Place[]>;
1063
1352
  /** Clear everything from the map (does not touch entries history). */
1064
1353
  clearShownEntries(): Promise<void>;
1354
+ /**
1355
+ * Hide every PlacesState rendering — pins AND attached boundary polygons. Map-only:
1356
+ * history (`entries`) is untouched. Implements {@link ClearableMapSlice}.
1357
+ */
1358
+ clearShown(): Promise<void>;
1065
1359
  clearShownGeometries(ids?: readonly string[]): Promise<void>;
1066
1360
  /**
1067
1361
  * Drop a single entry from history. Hides it from the map first (clears every theme module
@@ -1192,7 +1486,12 @@ declare class RangeState implements ShownEntriesSlice {
1192
1486
  private _requireEntry;
1193
1487
  get entries(): readonly RangesEntry[];
1194
1488
  get latestEntry(): RangesEntry | undefined;
1195
- addEntry(entry: Omit<RangesEntry, 'id' | 'timestamp'>): string;
1489
+ addEntry(entry: Omit<RangesEntry, 'id' | 'timestamp'>): Promise<string>;
1490
+ /**
1491
+ * Hide every reachable-range entry currently on the map. Map-only — history is kept.
1492
+ * Implements {@link ClearableMapSlice}.
1493
+ */
1494
+ clearShown(): Promise<void>;
1196
1495
  reset(): void;
1197
1496
  }
1198
1497
 
@@ -1268,7 +1567,7 @@ export declare type RouteParams = {
1268
1567
 
1269
1568
  /**
1270
1569
  * A single aggregation/analysis result attached to a routes entry.
1271
- * Produced by the `analyseRoutes` tool; `data` is whatever the dynamic code returned.
1570
+ * Produced by `analyseData`; `data` is whatever the dynamic code returned.
1272
1571
  *
1273
1572
  * @group Agent Toolkit
1274
1573
  */
@@ -1325,11 +1624,16 @@ declare class RoutingState implements ShownEntriesSlice {
1325
1624
  private _planningSlots;
1326
1625
  private _params;
1327
1626
  private _entryMode;
1627
+ /**
1628
+ * Slice-level "main color" applied to every RoutingModule on first show / re-show. Sticky
1629
+ * across entry swaps so the rendered route always uses the most recently requested color.
1630
+ * Set via {@link setMainColor}; persists for the lifetime of the slice (cleared on `reset`).
1631
+ */
1632
+ private _mainColor?;
1328
1633
  /**
1329
1634
  * The most recently `.showEntry`-ed id. Tracks "who was last brought up" so tools that
1330
- * operate on the focused module (`set-route-theme`, `get-shown-routes`, …) have a single
1331
- * pointer to read; the authoritative shown set is `shownEntryIds` (derived from each
1332
- * entry's `_shown` flag).
1635
+ * operate on the focused module have a single pointer to read; the authoritative shown
1636
+ * set is `shownEntryIds` (derived from each entry's `_shown` flag).
1333
1637
  */
1334
1638
  private _lastShownEntryId?;
1335
1639
  /** Subscribe to state changes — see {@link RoutingStateEvents}. */
@@ -1364,6 +1668,15 @@ declare class RoutingState implements ShownEntriesSlice {
1364
1668
  * Emits `shown-change` once the new entry is up.
1365
1669
  */
1366
1670
  showEntry(entryId: string): Promise<void>;
1671
+ /** Slice-level main color persisted across entry swaps. Undefined when no theme has been set. */
1672
+ get mainColor(): string | undefined;
1673
+ /**
1674
+ * Set the slice-level main color. The colour is applied immediately to every currently-shown
1675
+ * entry's RoutingModule and remembered so that subsequent {@link showEntry} calls apply it
1676
+ * automatically. Pass `undefined` to clear the sticky theme — currently-shown modules keep
1677
+ * their last paint until they're re-shown (MapLibre style restore handles full revert).
1678
+ */
1679
+ setMainColor(color: string | undefined): void;
1367
1680
  /**
1368
1681
  * Hide the entry's routes + waypoints on its module (clear; the module stays cached).
1369
1682
  * No-op when the entry is unknown or already hidden.
@@ -1376,9 +1689,8 @@ declare class RoutingState implements ShownEntriesSlice {
1376
1689
  removeEntry(entryId: string): Promise<void>;
1377
1690
  private _requireEntry;
1378
1691
  /**
1379
- * RoutingModule of the most-recently-shown entry, if any. Tools that operate on the
1380
- * "focused route" (e.g. setRouteTheme, getShownRoutes) read off it. Returns undefined
1381
- * when no entry is currently shown.
1692
+ * RoutingModule of the most-recently-shown entry, if any. Returns undefined when no
1693
+ * entry is currently shown.
1382
1694
  */
1383
1695
  get currentEntryModule(): RoutingModule | undefined;
1384
1696
  get entries(): readonly RoutesEntry[];
@@ -1387,7 +1699,7 @@ declare class RoutingState implements ShownEntriesSlice {
1387
1699
  /** Sparse nullable slots being assembled before triggering a route calculation. */
1388
1700
  get planningSlots(): PlanningWaypoint[];
1389
1701
  get params(): RouteParams;
1390
- addRoutes(routes: Routes, waypoints: WaypointLike[], label: string): string;
1702
+ addRoutes(routes: Routes, waypoints: WaypointLike[], label: string): Promise<string>;
1391
1703
  /**
1392
1704
  * Attach an analysis result to an existing routes entry. Names are unique within a single
1393
1705
  * entry — adding one with an existing name replaces it. Returns true on success, false if
@@ -1396,6 +1708,11 @@ declare class RoutingState implements ShownEntriesSlice {
1396
1708
  addAnalysisToEntry(entryId: string, analysis: RoutesAnalysis): boolean;
1397
1709
  setWaypointAt(index: number, waypoint: WaypointLike): void;
1398
1710
  setParams(params: Partial<RouteParams>): void;
1711
+ /**
1712
+ * Hide every route + waypoint set currently on the map. Map-only — history (`entries`)
1713
+ * stays intact. Implements {@link ClearableMapSlice}.
1714
+ */
1715
+ clearShown(): Promise<void>;
1399
1716
  reset(): void;
1400
1717
  }
1401
1718
 
@@ -1467,8 +1784,12 @@ export declare type StateDigest = {
1467
1784
  entryMode: EntryMode;
1468
1785
  };
1469
1786
  traffic: {
1470
- /** Whether a TrafficAreaAnalytics visualization is active. */
1471
- analyticsActive: boolean;
1787
+ /** Traffic-area-analytics entry ids currently rendered on the map, sorted ascending. */
1788
+ shown: string[];
1789
+ /** Display policy in force on the slice — `multiple` (default) or `single`. */
1790
+ entryMode: EntryMode;
1791
+ /** Total traffic-area-analytics entries in history (shown + hidden). */
1792
+ entryCount: number;
1472
1793
  };
1473
1794
  incidents: {
1474
1795
  /** Traffic-incidents entry ids currently rendered on the map, sorted ascending. */
@@ -1478,6 +1799,22 @@ export declare type StateDigest = {
1478
1799
  /** Display policy in force on the slice — `multiple` (default) or `single`. */
1479
1800
  entryMode: EntryMode;
1480
1801
  };
1802
+ customGeometries: {
1803
+ /** Custom-geometries entry ids currently rendered on the map, sorted ascending. */
1804
+ shown: string[];
1805
+ /** Display policy in force on the slice — `multiple` (default) or `single`. */
1806
+ entryMode: EntryMode;
1807
+ /** Total custom-geometries entries in history (shown + hidden). */
1808
+ entryCount: number;
1809
+ };
1810
+ byod: {
1811
+ /** BYOD entry ids currently rendered on the map, sorted ascending. */
1812
+ shown: string[];
1813
+ /** Display policy in force on the slice — `multiple` (default) or `single`. */
1814
+ entryMode: EntryMode;
1815
+ /** Total BYOD entries in history (shown + hidden). */
1816
+ entryCount: number;
1817
+ };
1481
1818
  };
1482
1819
 
1483
1820
  /**
@@ -1538,14 +1875,33 @@ export declare const TOOL_NAMES: ToolName[];
1538
1875
 
1539
1876
  /**
1540
1877
  * Build-time options passed to a {@link ToolEntryBuilder}. Lets each tool
1541
- * tailor its description, schema, or executor to flags or other config that
1542
- * are only known at agent-creation time.
1878
+ * tailor its description, schema, or executor to flags or per-turn scope
1879
+ * resolved by the classifier.
1880
+ *
1881
+ * @typeParam Scope - The per-tool scope shape. Defaults to `unknown` for the
1882
+ * generic builder signature; individual builders narrow this via their own
1883
+ * `Scope` generic so the `scope` argument is well-typed within the tool.
1543
1884
  *
1544
1885
  * @group Agent Toolkit
1545
1886
  */
1546
- export declare type ToolBuildOptions = {
1887
+ export declare type ToolBuildOptions<Scope = unknown> = {
1547
1888
  /** Active feature flags. */
1548
1889
  featureFlags?: FeatureFlags;
1890
+ /**
1891
+ * Per-turn scope emitted by the classifier (already validated against the
1892
+ * tool's {@link ToolEntry.scopeSchema}). `undefined` at agent-creation time
1893
+ * or when the classifier omits a scope for this tool — builders should
1894
+ * treat `undefined` as "produce the full surface".
1895
+ */
1896
+ scope?: Scope;
1897
+ /**
1898
+ * Subset of {@link EntryDataKind} the agent is configured to expose, derived
1899
+ * from `createMapAgent`'s `dataEntries` option. Builders for `analyseData`
1900
+ * and `processData` use this to narrow their static (unscoped) input surface
1901
+ * to the agent's enabled kinds. `undefined` means "no agent-level filtering —
1902
+ * every kind stays available".
1903
+ */
1904
+ enabledDataKinds?: readonly EntryDataKind[];
1549
1905
  };
1550
1906
 
1551
1907
  /**
@@ -1555,20 +1911,27 @@ export declare type ToolBuildOptions = {
1555
1911
  * setup pipeline accept either form interchangeably.
1556
1912
  *
1557
1913
  * @typeParam S - The ToolState shape this tool requires. Default: base `ToolState`.
1914
+ * @typeParam Scope - Optional per-tool scope shape (only relevant for builder
1915
+ * form). Defaults to `never` for non-scopable tools.
1558
1916
  *
1559
1917
  * @group Agent Toolkit
1560
1918
  */
1561
- export declare type ToolDefinition<S extends ToolState = ToolState> = ToolEntry<S> | ToolEntryBuilder<S>;
1919
+ export declare type ToolDefinition<S extends ToolState = ToolState, Scope = any> = ToolEntry<S, Scope> | ToolEntryBuilder<S, Scope>;
1562
1920
 
1563
1921
  /**
1564
1922
  * A tool definition — the universal format for both built-in and third-party tools.
1565
1923
  * Combines execution (inputSchema + execute) with classifier metadata.
1566
1924
  *
1567
1925
  * @typeParam S - The ToolState shape this tool requires. Default: base `ToolState`.
1926
+ * @typeParam Scope - Optional per-tool scope shape. When set via `scopeSchema`, the
1927
+ * classifier may emit a value of this shape per turn so the tool's `description`
1928
+ * and `inputSchema` can be rebuilt narrower for that step. Tools without scope
1929
+ * leave this at the default `unknown`; `scopeSchema` is then absent and no rebuild
1930
+ * ever runs for the tool.
1568
1931
  *
1569
1932
  * @group Agent Toolkit
1570
1933
  */
1571
- export declare type ToolEntry<S extends ToolState = ToolState> = {
1934
+ export declare type ToolEntry<S extends ToolState = ToolState, Scope = unknown> = {
1572
1935
  /** Description of the tool's purpose. */
1573
1936
  description: string;
1574
1937
  /** Zod schema defining the tool's input parameters. */
@@ -1589,18 +1952,36 @@ export declare type ToolEntry<S extends ToolState = ToolState> = {
1589
1952
  relatedTools?: string[];
1590
1953
  /** Tool names that must run before this one. */
1591
1954
  dependsOn?: string[];
1955
+ /**
1956
+ * Optional per-tool scope schema. When set, the classifier may emit a
1957
+ * scope value (validated against this schema) and `prepareStep` will
1958
+ * rebuild this tool's `description` + `inputSchema` by re-invoking its
1959
+ * {@link ToolEntryBuilder} with the parsed scope. Tools without a builder
1960
+ * cannot be scoped — `scopeSchema` is only meaningful on builder-produced
1961
+ * entries.
1962
+ */
1963
+ scopeSchema?: z.ZodType<Scope>;
1964
+ /**
1965
+ * Compact one-line hint for the classifier explaining when and how to scope
1966
+ * this tool (e.g. "Emit `{ kinds: ['places'] }` when only places entries
1967
+ * are relevant"). Appended to the tool's classifier-prompt entry.
1968
+ */
1969
+ scopePrompt?: string;
1592
1970
  };
1593
1971
 
1594
1972
  /**
1595
1973
  * A builder that produces a {@link ToolEntry} from {@link ToolBuildOptions}.
1596
1974
  * Use this when a tool's metadata, schema, or executor depends on options
1597
- * resolved at agent-creation time (e.g. feature flags).
1975
+ * resolved at agent-creation time (e.g. feature flags) or per turn
1976
+ * (classifier-emitted scope).
1598
1977
  *
1599
1978
  * @typeParam S - The ToolState shape this tool requires. Default: base `ToolState`.
1979
+ * @typeParam Scope - The per-tool scope shape, propagated to the produced
1980
+ * {@link ToolEntry} so the `scopeSchema` and runtime `scope` stay in lockstep.
1600
1981
  *
1601
1982
  * @group Agent Toolkit
1602
1983
  */
1603
- export declare type ToolEntryBuilder<S extends ToolState = ToolState> = (options: ToolBuildOptions) => ToolEntry<S>;
1984
+ export declare type ToolEntryBuilder<S extends ToolState = ToolState, Scope = unknown> = (options: ToolBuildOptions<Scope>) => ToolEntry<S, Scope>;
1604
1985
 
1605
1986
  /**
1606
1987
  * Metadata for an agent toolkit tool.
@@ -1624,6 +2005,8 @@ export declare type ToolMetadata = {
1624
2005
  relatedTools?: ToolNameHint[];
1625
2006
  /** Tool names that must run before this one. */
1626
2007
  dependsOn?: ToolNameHint[];
2008
+ /** When set, the classifier may emit `toolScopes[name]` for this tool to narrow per-turn. */
2009
+ scopePrompt?: string;
1627
2010
  };
1628
2011
 
1629
2012
  /**
@@ -1641,6 +2024,19 @@ export declare type ToolName = keyof typeof DEFAULT_TOOLS;
1641
2024
  */
1642
2025
  export declare type ToolNameHint = ToolName | (string & {});
1643
2026
 
2027
+ /**
2028
+ * Default tool names that should be dropped from the registry when a {@link DataEntryKind}
2029
+ * is disabled. Only default-tool names are listed here — user-supplied custom tools are
2030
+ * never filtered automatically; integrators that want to gate their own tools on enabled
2031
+ * kinds can read `dataEntries` themselves.
2032
+ *
2033
+ * Tools that span multiple kinds (`clearMap`, `recallState`, `setEntryMode`, …) are
2034
+ * intentionally absent — they keep working regardless of which kinds are disabled.
2035
+ *
2036
+ * @group Agent Toolkit
2037
+ */
2038
+ export declare const TOOLS_BY_DATA_ENTRY_KIND: Record<DataEntryKind, readonly string[]>;
2039
+
1644
2040
  /**
1645
2041
  * State passed to tool factory functions. Organized by feature area,
1646
2042
  * each sub-state mixes lazy module access with the current service data
@@ -1678,39 +2074,122 @@ export declare type ToolState = {
1678
2074
  trafficIncidents: TrafficIncidentsState;
1679
2075
  /** Reachable range results: origin, budgets, and bbox summaries. */
1680
2076
  ranges: RangeState;
1681
- /** Derived/custom polygon entries — output of processGeometries. */
2077
+ /** Derived/custom polygon entries — output of `processData`. */
1682
2078
  customGeometries: CustomGeometriesState;
2079
+ /** Bring-your-own-data GeoJSON layers — customer-authored data the agent can read and render. */
2080
+ byod: BYODState;
2081
+ };
2082
+
2083
+ /**
2084
+ * A single aggregation/analysis result attached to a traffic-area-analytics entry.
2085
+ * Produced by `analyseData`; `data` is whatever the dynamic code returned.
2086
+ *
2087
+ * @group Agent Toolkit
2088
+ */
2089
+ export declare type TrafficAreaAnalyticsAnalysis = {
2090
+ /** Unique name within the parent entry (used as a key for future UI). */
2091
+ name: string;
2092
+ timestamp: number;
2093
+ /** Optional human-readable description of what the analysis computed. */
2094
+ description?: string;
2095
+ /** How `data` should be interpreted — plain JSON or a Chart.js configuration. */
2096
+ outputFormat: AnalysisOutputFormat;
2097
+ /** Arbitrary aggregation result returned by the dynamic code. */
2098
+ data: unknown;
2099
+ };
2100
+
2101
+ /**
2102
+ * A single entry in the traffic-area-analytics history — output of one
2103
+ * `getTrafficAreaAnalytics` call. Mirrors the per-entry model used by
2104
+ * `RoutingState` / `CustomGeometriesState`: each entry owns its own
2105
+ * `TrafficAreaAnalyticsModule`, lazy-initialised on first show.
2106
+ *
2107
+ * @group Agent Toolkit
2108
+ */
2109
+ export declare type TrafficAreaAnalyticsEntry = {
2110
+ id: string;
2111
+ timestamp: number;
2112
+ label: string;
2113
+ /** The aggregated FeatureCollection result. */
2114
+ data: TrafficAreaAnalytics;
2115
+ /** Request parameters that produced this entry — provenance only, opaque to consumers. */
2116
+ params: TrafficAreaAnalyticsParams;
2117
+ /**
2118
+ * Per-entry TrafficAreaAnalyticsModule. Each entry owns its own so two entries can render
2119
+ * side-by-side. Lazy-initialised via {@link TrafficAreaAnalyticsState.getEntryModule}.
2120
+ */
2121
+ _module?: TrafficAreaAnalyticsModule;
2122
+ /** Latest viz config reflected from the module (mode / metric / scaleMode / …). */
2123
+ _config?: TrafficAreaAnalyticsConfig;
2124
+ /** Unsubscribe from this entry's module config-change wiring. Cleared on hide / remove. */
2125
+ _configChangeUnsub?: () => void;
2126
+ /** True while `_module` is rendering on the map. */
2127
+ _shown?: boolean;
2128
+ /** Accumulated analysis results linked to this entry. */
2129
+ _analysis?: TrafficAreaAnalyticsAnalysis[];
1683
2130
  };
1684
2131
 
1685
2132
  /**
1686
- * State for traffic area analytics — the lazy-init module, the last fetched
1687
- * aggregation result, and its currently-applied visualization config. Tile
1688
- * overlays (flow + incidents) live in {@link TrafficTilesState}.
2133
+ * Compact provenance metadata for a traffic-area-analytics entry — the request
2134
+ * parameters that produced the result. Kept opaque (`Record<string, unknown>`)
2135
+ * because the SDK call accepts a wide param shape and we just want to surface
2136
+ * enough context for `recall` / `digest` tools.
1689
2137
  *
1690
2138
  * @group Agent Toolkit
1691
2139
  */
1692
- declare class TrafficAreaAnalyticsState implements StateSlice {
2140
+ export declare type TrafficAreaAnalyticsParams = Record<string, unknown>;
2141
+
2142
+ /**
2143
+ * Append-only history of traffic-area-analytics aggregations, with per-entry
2144
+ * rendering. Each entry owns a dedicated {@link TrafficAreaAnalyticsModule},
2145
+ * lazy-initialised on first show. Mirrors the per-entry pattern used by
2146
+ * `RoutingState` / `CustomGeometriesState`.
2147
+ *
2148
+ * Live tile overlays (flow + incidents) live in {@link TrafficTilesState}.
2149
+ *
2150
+ * @group Agent Toolkit
2151
+ */
2152
+ declare class TrafficAreaAnalyticsState implements ShownEntriesSlice, StateSlice {
1693
2153
  private readonly _ttMap;
1694
- private _trafficAreaAnalyticsModule?;
1695
- private _lastAreaAnalytics?;
1696
- private _currentAnalyticsConfig?;
1697
- private _configChangeUnsub?;
2154
+ private _entries;
2155
+ private _entryMode;
1698
2156
  /** Subscribe to state changes — see {@link TrafficAreaAnalyticsStateEvents}. */
1699
2157
  readonly events: StateEvents<TrafficAreaAnalyticsStateEvents>;
1700
2158
  constructor(_ttMap: TomTomMap);
1701
- getTrafficAreaAnalyticsModule(): Promise<TrafficAreaAnalyticsModule>;
1702
- get trafficAreaAnalyticsModule(): TrafficAreaAnalyticsModule | undefined;
1703
- get lastAreaAnalytics(): TrafficAreaAnalytics | undefined;
1704
- setLastAreaAnalytics(result: TrafficAreaAnalytics): void;
1705
- /** Current visualization config, updated by module configChange events. */
1706
- get currentAnalyticsConfig(): TrafficAreaAnalyticsConfig | undefined;
1707
- /**
1708
- * Notify subscribers that an analytics result is now active on the map. Called from
1709
- * tool implementations after `module.show(...)` succeeds.
1710
- */
1711
- notifyAnalyticsShown(analytics: TrafficAreaAnalytics, module: TrafficAreaAnalyticsModule): void;
1712
- /** Notify subscribers that the active analytics visualization was cleared. */
1713
- notifyAnalyticsCleared(): void;
2159
+ get entries(): readonly TrafficAreaAnalyticsEntry[];
2160
+ get latestEntry(): TrafficAreaAnalyticsEntry | undefined;
2161
+ get shownEntryIds(): ReadonlySet<string>;
2162
+ get entryMode(): EntryMode;
2163
+ setEntryMode(mode: EntryMode): Promise<void>;
2164
+ findById(entryId: string): TrafficAreaAnalyticsEntry | undefined;
2165
+ /**
2166
+ * Append a new entry. Auto-suffixes the id on collision. Under `single` mode the new entry
2167
+ * replaces every older one (hidden + dropped from history).
2168
+ */
2169
+ addEntry(data: TrafficAreaAnalytics, label: string, params: TrafficAreaAnalyticsParams, explicitId?: string): Promise<string>;
2170
+ /**
2171
+ * Attach an analysis to an existing entry. Replaces the prior result keyed by `analysis.name`
2172
+ * on the same entry (mirrors PlacesState / CustomGeometriesState semantics). Returns `false`
2173
+ * when the entry id is unknown.
2174
+ */
2175
+ addAnalysisToEntry(entryId: string, analysis: TrafficAreaAnalyticsAnalysis): boolean;
2176
+ /**
2177
+ * Lazy-init the entry's TrafficAreaAnalyticsModule, wiring per-entry config-change events.
2178
+ * Throws on unknown id.
2179
+ */
2180
+ getEntryModule(entryId: string): Promise<TrafficAreaAnalyticsModule>;
2181
+ /** Render this entry's analytics on its own module. Under `single` mode, hides every other shown entry first. */
2182
+ showEntry(entryId: string): Promise<void>;
2183
+ /** Hide the entry's analytics on its module. No-op when unknown or already hidden. */
2184
+ hideEntry(entryId: string): Promise<void>;
2185
+ /** Drop a single entry from history. Hides it first, then removes; emits `entries-change`. No-op on unknown id. */
2186
+ removeEntry(entryId: string): Promise<void>;
2187
+ private _requireEntry;
2188
+ /**
2189
+ * Hide every traffic-area-analytics entry currently on the map. Map-only — history is kept.
2190
+ * Implements {@link ClearableMapSlice}.
2191
+ */
2192
+ clearShown(): Promise<void>;
1714
2193
  reset(): void;
1715
2194
  }
1716
2195
 
@@ -1721,18 +2200,25 @@ declare class TrafficAreaAnalyticsState implements StateSlice {
1721
2200
  * @group Agent Toolkit
1722
2201
  */
1723
2202
  declare type TrafficAreaAnalyticsStateEvents = {
1724
- /** Last fetched analytics result and its module are now active on the map. */
1725
- 'analytics-shown': {
1726
- analytics: TrafficAreaAnalytics;
1727
- module: TrafficAreaAnalyticsModule;
2203
+ /** History changed — entry added, removed, or cleared via `reset()`. */
2204
+ 'entries-change': readonly TrafficAreaAnalyticsEntry[];
2205
+ /** Set of entries currently rendered on the map changed. */
2206
+ 'shown-change': ReadonlySet<string>;
2207
+ /** Per-entry viz config changed (mode / metric / scaleMode / …). */
2208
+ 'config-change': {
2209
+ entryId: string;
2210
+ config: TrafficAreaAnalyticsConfig | undefined;
2211
+ };
2212
+ /** A new analysis was attached to (or replaced on) an entry. */
2213
+ 'analysis-added': {
2214
+ entryId: string;
2215
+ analysis: TrafficAreaAnalyticsAnalysis;
1728
2216
  };
1729
- /** The active analytics visualization was cleared or replaced. */
1730
- 'analytics-cleared': void;
1731
- /** Module-level visualization config changed (mode, metric, scaleMode, ...). */
1732
- 'config-change': TrafficAreaAnalyticsConfig | undefined;
2217
+ /** Display policy switched between `single` and `multiple`. */
2218
+ 'mode-change': EntryMode;
1733
2219
  };
1734
2220
 
1735
- declare type TrafficIncidentsEntry = {
2221
+ export declare type TrafficIncidentsEntry = {
1736
2222
  id: string;
1737
2223
  timestamp: number;
1738
2224
  label: string;
@@ -1823,7 +2309,7 @@ declare class TrafficIncidentsState implements StateSlice {
1823
2309
  */
1824
2310
  addIncidentsEntry(data: TrafficIncident[], params: TrafficIncidentDetailsByBBoxParams & {
1825
2311
  bbox: BBox;
1826
- }, label: string, sampledAt: number, explicitId?: string): string;
2312
+ }, label: string, sampledAt: number, explicitId?: string): Promise<string>;
1827
2313
  /**
1828
2314
  * Replace an entry's data in place and repaint its module without moving the camera.
1829
2315
  * Used by the per-entry monitor tick so incident geometries and any open detail
@@ -1919,9 +2405,13 @@ declare class TrafficIncidentsState implements StateSlice {
1919
2405
  isMonitored(entryId: TrafficIncidentsEntry['id']): boolean;
1920
2406
  private _createMonitorForEntry;
1921
2407
  private _requireEntry;
1922
- private _uniqueEntryId;
1923
2408
  private _rerunRegisteredSpecs;
1924
2409
  private _teardownEntry;
2410
+ /**
2411
+ * Hide every traffic-incidents entry currently on the map. Map-only — history is kept.
2412
+ * Implements {@link ClearableMapSlice}.
2413
+ */
2414
+ clearShown(): Promise<void>;
1925
2415
  reset(): void;
1926
2416
  }
1927
2417