@tomtom-org/maps-sdk-plugin-agent-toolkit 0.2.4 → 0.2.6
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 +28 -13
- package/dist/index.d.ts +1411 -150
- package/dist/index.es.js +1 -1
- package/dist/index.es.js.map +1 -1
- package/package.json +17 -11
package/dist/index.d.ts
CHANGED
|
@@ -1,34 +1,43 @@
|
|
|
1
|
-
import { BaseMapModule } from '
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { BaseMapModule } from '../../../../map/dist';
|
|
2
|
+
import { BBox } from '../../../../core/dist';
|
|
3
|
+
import { BBox as BBox_2 } from '../../../../../core/dist';
|
|
4
|
+
import { CommonPlaceProps } from '../../../../core/dist';
|
|
5
|
+
import { GeometriesModule } from '../../../../map/dist';
|
|
6
|
+
import { GeometryTheme } from '../../../../map/dist';
|
|
7
|
+
import { HillshadeModule } from '../../../../map/dist';
|
|
5
8
|
import { LanguageModel } from 'ai';
|
|
6
9
|
import { Map as Map_2 } from 'maplibre-gl';
|
|
7
10
|
import { ModelMessage } from 'ai';
|
|
8
|
-
import { Place } from '
|
|
9
|
-
import {
|
|
10
|
-
import { Places } from '
|
|
11
|
-
import { PlacesModule } from '
|
|
12
|
-
import { PlanningWaypoint } from '
|
|
13
|
-
import { POIsModule } from '
|
|
14
|
-
import {
|
|
11
|
+
import { Place } from '../../../../core/dist';
|
|
12
|
+
import { PlaceConnectionDisplay } from '../../../../map/dist';
|
|
13
|
+
import { Places } from '../../../../core/dist';
|
|
14
|
+
import { PlacesModule } from '../../../../map/dist';
|
|
15
|
+
import { PlanningWaypoint } from '../../../../map/dist';
|
|
16
|
+
import { POIsModule } from '../../../../map/dist';
|
|
17
|
+
import { PolygonFeature } from '../../../../core/dist';
|
|
18
|
+
import { PolygonFeatures } from '../../../../core/dist';
|
|
15
19
|
import { Position } from 'geojson';
|
|
16
20
|
import { PrepareStepFunction } from 'ai';
|
|
17
|
-
import { ReachableRangeBudget } from '
|
|
18
|
-
import { Routes } from '
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import { TomTomMap } from '../../map/dist';
|
|
21
|
+
import { ReachableRangeBudget } from '../../../../services/dist';
|
|
22
|
+
import { Routes } from '../../../../core/dist';
|
|
23
|
+
import { RoutingModule } from '../../../../map/dist';
|
|
24
|
+
import { TomTomMap } from '../../../../map/dist';
|
|
25
|
+
import { TomTomMap as TomTomMap_2 } from '../../map/dist';
|
|
22
26
|
import { ToolLoopAgent } from 'ai';
|
|
23
|
-
import { TrafficAreaAnalytics } from '
|
|
24
|
-
import { TrafficAreaAnalyticsConfig } from '
|
|
25
|
-
import { TrafficAreaAnalyticsModule } from '
|
|
26
|
-
import { TrafficFlowModule } from '
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
27
|
+
import { TrafficAreaAnalytics } from '../../../../core/dist';
|
|
28
|
+
import { TrafficAreaAnalyticsConfig } from '../../../../map/dist';
|
|
29
|
+
import { TrafficAreaAnalyticsModule } from '../../../../map/dist';
|
|
30
|
+
import { TrafficFlowModule } from '../../../../map/dist';
|
|
31
|
+
import { TrafficIncident } from '../../../../core/dist';
|
|
32
|
+
import { TrafficIncident as TrafficIncident_2 } from '../../../../../core/dist';
|
|
33
|
+
import { TrafficIncidentDetailsByBBoxParams } from '../../../../services/dist';
|
|
34
|
+
import { TrafficIncidentOverlayModule } from '../../../../map/dist';
|
|
35
|
+
import { TrafficIncidentsModule } from '../../../../map/dist';
|
|
36
|
+
import { WaypointLike } from '../../../../core/dist';
|
|
30
37
|
import { z } from 'zod';
|
|
31
38
|
|
|
39
|
+
declare type AnalysisOutputFormat = 'json' | 'chart';
|
|
40
|
+
|
|
32
41
|
/**
|
|
33
42
|
* The base system prompt that teaches the LLM how to use the agent toolkit tools.
|
|
34
43
|
*
|
|
@@ -48,7 +57,7 @@ import { z } from 'zod';
|
|
|
48
57
|
*
|
|
49
58
|
* @group Agent Toolkit
|
|
50
59
|
*/
|
|
51
|
-
export declare const BASE_SYSTEM_PROMPT = "You are a helpful map assistant with access to a TomTom interactive map and location services.\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
|
|
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";
|
|
52
61
|
|
|
53
62
|
/**
|
|
54
63
|
* State for base map display: style, language, viewport, layers, and hillshade.
|
|
@@ -206,83 +215,218 @@ export declare const createDefaultClassifier: (options: {
|
|
|
206
215
|
* ```
|
|
207
216
|
* @group Agent Toolkit
|
|
208
217
|
*/
|
|
209
|
-
export declare const createMapAgent: <CS extends ToolState = ToolState>(map:
|
|
218
|
+
export declare const createMapAgent: <CS extends ToolState = ToolState>(map: TomTomMap_2, options: MapAgentOptions<CS>) => MapAgentInstance<CS>;
|
|
210
219
|
|
|
211
220
|
/**
|
|
212
|
-
*
|
|
213
|
-
*
|
|
221
|
+
* A single aggregation/analysis result attached to a custom-geometries entry.
|
|
222
|
+
* Produced by the `analyseGeometries` tool; `data` is whatever the dynamic code returned.
|
|
214
223
|
*
|
|
215
|
-
* @
|
|
216
|
-
|
|
224
|
+
* @group Agent Toolkit
|
|
225
|
+
*/
|
|
226
|
+
export declare type CustomGeometriesAnalysis = {
|
|
227
|
+
/** Unique name within the parent entry (used as a key for future UI). */
|
|
228
|
+
name: string;
|
|
229
|
+
timestamp: number;
|
|
230
|
+
/** Optional human-readable description of what the analysis computed. */
|
|
231
|
+
description?: string;
|
|
232
|
+
/** How `data` should be interpreted — plain JSON or a Chart.js configuration. */
|
|
233
|
+
outputFormat: AnalysisOutputFormat;
|
|
234
|
+
/** Arbitrary aggregation result returned by the dynamic code. */
|
|
235
|
+
data: unknown;
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
/**
|
|
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).
|
|
217
242
|
*
|
|
218
243
|
* @group Agent Toolkit
|
|
219
244
|
*/
|
|
220
|
-
export declare
|
|
245
|
+
export declare type CustomGeometriesEntry = {
|
|
246
|
+
id: string;
|
|
247
|
+
timestamp: number;
|
|
248
|
+
label: string;
|
|
249
|
+
/** The polygons stored on this entry (Polygon / MultiPolygon GeoJSON Features). */
|
|
250
|
+
features: PolygonFeature[];
|
|
251
|
+
/** Inputs and operation that produced this entry. */
|
|
252
|
+
provenance: GeometryProvenance;
|
|
253
|
+
/** Accumulated analysis results linked to this entry. */
|
|
254
|
+
_analysis?: CustomGeometriesAnalysis[];
|
|
255
|
+
/**
|
|
256
|
+
* Per-entry GeometriesModule. Each entry owns its own module so display state
|
|
257
|
+
* (theme, current features) lives on the entry instead of a shared slice-level
|
|
258
|
+
* module. Lazy-initialised via CustomGeometriesState helpers.
|
|
259
|
+
*/
|
|
260
|
+
_module?: GeometriesModule;
|
|
261
|
+
/** Theme that the geometries module is currently configured with. */
|
|
262
|
+
_shownTheme?: 'filled' | 'outline' | 'inverted';
|
|
263
|
+
/** True while this entry's `_module` is rendering on the map. */
|
|
264
|
+
_shown?: boolean;
|
|
265
|
+
};
|
|
221
266
|
|
|
222
267
|
/**
|
|
223
|
-
*
|
|
268
|
+
* State for derived / custom geometries — output of `processGeometries` and any future
|
|
269
|
+
* polygon-producing tool whose result doesn't belong to a place or a reachable-range entry.
|
|
270
|
+
*
|
|
271
|
+
* Each entry owns a dedicated GeometriesModule, lazy-initialised on first show, mirroring
|
|
272
|
+
* the per-entry display model used by {@link RangeState}. Provenance metadata captures the
|
|
273
|
+
* input sources (tagged ids) and the operation that produced the polygons.
|
|
274
|
+
*
|
|
275
|
+
* @group Agent Toolkit
|
|
276
|
+
*/
|
|
277
|
+
declare class CustomGeometriesState implements ShownEntriesSlice, StateSlice {
|
|
278
|
+
private readonly _ttMap;
|
|
279
|
+
private _entries;
|
|
280
|
+
private _entryMode;
|
|
281
|
+
/** Subscribe to state changes — see {@link CustomGeometriesStateEvents}. */
|
|
282
|
+
readonly events: StateEvents<CustomGeometriesStateEvents>;
|
|
283
|
+
constructor(_ttMap: TomTomMap);
|
|
284
|
+
get entries(): readonly CustomGeometriesEntry[];
|
|
285
|
+
get latestEntry(): CustomGeometriesEntry | undefined;
|
|
286
|
+
/** Set of custom-geometries entry ids currently rendered on the map. */
|
|
287
|
+
get shownEntryIds(): ReadonlySet<string>;
|
|
288
|
+
/**
|
|
289
|
+
* Display policy: `multiple` (default) lets several derived-geometry entries render side
|
|
290
|
+
* by side; `single` enforces "at most one entry on the map" — switching to it auto-hides
|
|
291
|
+
* older entries.
|
|
292
|
+
*/
|
|
293
|
+
get entryMode(): EntryMode;
|
|
294
|
+
setEntryMode(mode: EntryMode): Promise<void>;
|
|
295
|
+
findById(entryId: string): CustomGeometriesEntry | undefined;
|
|
296
|
+
/**
|
|
297
|
+
* Append a new entry. If `explicitId` collides, the slice auto-suffixes (`-2`, `-3`, ...).
|
|
298
|
+
* Returns the assigned id. Under `single` mode the new entry replaces every older one.
|
|
299
|
+
*/
|
|
300
|
+
addEntry(features: PolygonFeature<CommonPlaceProps>[], provenance: CustomGeometriesEntry['provenance'], label: string, explicitId?: string): string;
|
|
301
|
+
/** Attach an analysis to an existing entry (replace if a result of the same name exists). */
|
|
302
|
+
addAnalysisToEntry(entryId: string, analysis: CustomGeometriesAnalysis): boolean;
|
|
303
|
+
/** Lazy-init the entry's GeometriesModule, applying / re-applying the requested theme. */
|
|
304
|
+
getEntryGeometriesModule(entryId: string, theme?: GeometryTheme): Promise<GeometriesModule>;
|
|
305
|
+
/**
|
|
306
|
+
* Render this entry's polygons. `mode` is scoped to this entry's own layer:
|
|
307
|
+
* - `'replace'` (default) — show exactly `entry.features`, clearing whatever the
|
|
308
|
+
* entry's module had rendered before.
|
|
309
|
+
* - `'add'` — merge `entry.features` with the polygons currently shown on this entry's
|
|
310
|
+
* layer (deduped by feature id). Mostly only meaningful when re-showing the same entry.
|
|
311
|
+
*
|
|
312
|
+
* Cross-entry visibility is handled separately: under `entryMode === 'single'` other
|
|
313
|
+
* shown entries are hidden first; otherwise the caller uses `hideEntry` / the
|
|
314
|
+
* tools' `hidePreviousEntries` option.
|
|
315
|
+
*/
|
|
316
|
+
showEntry(entryId: string, theme?: GeometryTheme, mode?: 'add' | 'replace'): Promise<void>;
|
|
317
|
+
private _hideOthersUnderSingleMode;
|
|
318
|
+
hideEntry(entryId: string): Promise<void>;
|
|
319
|
+
/** Drop a single entry from history (clears its module first). No-op when unknown. */
|
|
320
|
+
removeEntry(entryId: string): Promise<void>;
|
|
321
|
+
private _requireEntry;
|
|
322
|
+
private _uniqueEntryId;
|
|
323
|
+
reset(): void;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Events fired by {@link CustomGeometriesState}. Subscribe via
|
|
328
|
+
* `state.customGeometries.events.on(type, handler)`.
|
|
329
|
+
*
|
|
330
|
+
* @group Agent Toolkit
|
|
331
|
+
*/
|
|
332
|
+
declare type CustomGeometriesStateEvents = {
|
|
333
|
+
/** History changed — entry added or cleared via `reset()`. */
|
|
334
|
+
'entries-change': readonly CustomGeometriesEntry[];
|
|
335
|
+
/** Set of entries currently rendered on the map changed. */
|
|
336
|
+
'shown-change': ReadonlySet<string>;
|
|
337
|
+
/** A new analysis was attached to (or replaced on) an entry. */
|
|
338
|
+
'analysis-added': {
|
|
339
|
+
entryId: string;
|
|
340
|
+
analysis: CustomGeometriesAnalysis;
|
|
341
|
+
};
|
|
342
|
+
/** Display policy switched between `single` and `multiple`. */
|
|
343
|
+
'mode-change': EntryMode;
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Default tool set for the agent toolkit. Each entry is a {@link ToolDefinition}
|
|
348
|
+
* — either a static `ToolEntry` or a `ToolEntryBuilder` that tailors the tool to
|
|
349
|
+
* {@link ToolBuildOptions} (e.g. feature flags) at agent-creation time.
|
|
350
|
+
*
|
|
224
351
|
* Included automatically by createMapAgent unless includeDefaultTools is false.
|
|
225
352
|
* Use resolveTools() for manual composition outside createMapAgent.
|
|
226
353
|
*
|
|
227
354
|
* @group Agent Toolkit
|
|
228
355
|
*/
|
|
229
356
|
export declare const DEFAULT_TOOLS: {
|
|
230
|
-
locatePlace:
|
|
231
|
-
reverseGeocode:
|
|
232
|
-
discoverPlaces:
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
357
|
+
locatePlace: ToolDefinition;
|
|
358
|
+
reverseGeocode: ToolDefinition;
|
|
359
|
+
discoverPlaces: ToolDefinition;
|
|
360
|
+
processPlaces: ToolDefinition;
|
|
361
|
+
processGeometries: ToolDefinition;
|
|
362
|
+
processRoutes: ToolDefinition;
|
|
363
|
+
analyseGeometries: ToolDefinition;
|
|
364
|
+
analysePlaces: ToolDefinition;
|
|
365
|
+
analyseRoutes: ToolDefinition;
|
|
366
|
+
setRoute: ToolDefinition;
|
|
367
|
+
addWaypointsToRoute: ToolDefinition;
|
|
368
|
+
removeWaypointsFromRoute: ToolDefinition;
|
|
369
|
+
replaceWaypointInRoute: ToolDefinition;
|
|
370
|
+
getPOICategoryCodes: ToolDefinition;
|
|
371
|
+
getTrafficIncidents: ToolDefinition;
|
|
372
|
+
analyseIncidents: ToolDefinition;
|
|
373
|
+
focusIncidents: ToolDefinition;
|
|
374
|
+
startTrafficIncidentsMonitor: ToolDefinition;
|
|
375
|
+
stopTrafficIncidentsMonitor: ToolDefinition;
|
|
376
|
+
getTrafficAreaAnalytics: ToolDefinition;
|
|
377
|
+
queryTrafficAnalytics: ToolDefinition;
|
|
378
|
+
updatePlacesDisplay: ToolDefinition;
|
|
379
|
+
updateRoutesDisplay: ToolDefinition;
|
|
380
|
+
showTrafficAreaAnalytics: ToolDefinition;
|
|
381
|
+
showWaypoints: ToolDefinition;
|
|
382
|
+
getShownPlaces: ToolDefinition;
|
|
383
|
+
getShownRoutes: ToolDefinition;
|
|
384
|
+
getShownWaypoints: ToolDefinition;
|
|
385
|
+
getShownRouteTrafficIncidents: ToolDefinition;
|
|
386
|
+
getShownIncidents: ToolDefinition;
|
|
387
|
+
clearMap: ToolDefinition;
|
|
388
|
+
flyTo: ToolDefinition;
|
|
389
|
+
getViewport: ToolDefinition;
|
|
390
|
+
recallGeometries: ToolDefinition;
|
|
391
|
+
recallPlaces: ToolDefinition;
|
|
392
|
+
recallRoutes: ToolDefinition;
|
|
393
|
+
getCurrentWaypoints: ToolDefinition;
|
|
394
|
+
getStandardMapStyles: ToolDefinition;
|
|
395
|
+
setMapStandardStyle: ToolDefinition;
|
|
396
|
+
setRouteTheme: ToolDefinition;
|
|
397
|
+
setLanguage: ToolDefinition;
|
|
398
|
+
toggleBaseMapLayerGroups: ToolDefinition;
|
|
399
|
+
togglePOIs: ToolDefinition;
|
|
400
|
+
toggleTrafficFlow: ToolDefinition;
|
|
401
|
+
toggleTrafficIncidents: ToolDefinition;
|
|
402
|
+
getMapStyleLayers: ToolDefinition;
|
|
403
|
+
setLayoutProperties: ToolDefinition;
|
|
404
|
+
setPaintProperties: ToolDefinition;
|
|
405
|
+
setPitchBearing: ToolDefinition;
|
|
406
|
+
zoomInOrOut: ToolDefinition;
|
|
407
|
+
executeMaplibreCode: ToolDefinition;
|
|
408
|
+
calculateBBox: ToolDefinition;
|
|
409
|
+
formatDistance: ToolDefinition;
|
|
410
|
+
formatDuration: ToolDefinition;
|
|
411
|
+
getCurrentLocation: ToolDefinition;
|
|
412
|
+
help: ToolDefinition;
|
|
413
|
+
findReachableAreas: ToolDefinition;
|
|
414
|
+
recallRanges: ToolDefinition;
|
|
415
|
+
recallState: ToolDefinition;
|
|
416
|
+
resetState: ToolDefinition;
|
|
417
|
+
setEntryMode: ToolDefinition;
|
|
284
418
|
};
|
|
285
419
|
|
|
420
|
+
/**
|
|
421
|
+
* Per-slice display policy. With `multiple` (default) several history entries can be on the
|
|
422
|
+
* map at once; with `single` only the most recent one stays. Switching from `multiple` to
|
|
423
|
+
* `single` automatically drops every entry except the latest (and clears their modules) so
|
|
424
|
+
* the map matches the new policy immediately.
|
|
425
|
+
*
|
|
426
|
+
* @group Agent Toolkit
|
|
427
|
+
*/
|
|
428
|
+
export declare type EntryMode = 'single' | 'multiple';
|
|
429
|
+
|
|
286
430
|
/**
|
|
287
431
|
* Extracts the text content of the last user message in a message array.
|
|
288
432
|
* Returns null if no user message is found or if content has no text.
|
|
@@ -291,6 +435,271 @@ export declare const DEFAULT_TOOLS: {
|
|
|
291
435
|
*/
|
|
292
436
|
export declare const extractLastUserText: (messages: ReadonlyArray<ModelMessage>) => string | null;
|
|
293
437
|
|
|
438
|
+
/**
|
|
439
|
+
* Feature-flag bag for {@link createMapAgent}. Toggles in-flight or
|
|
440
|
+
* opt-in agent-toolkit behaviour. Individual flags vary in stability —
|
|
441
|
+
* some may graduate to stable public options, others are internal-only
|
|
442
|
+
* experiments that can change or disappear without notice. Check each
|
|
443
|
+
* flag's own doc for its current status.
|
|
444
|
+
*
|
|
445
|
+
* @experimental
|
|
446
|
+
*
|
|
447
|
+
* @group Agent Toolkit
|
|
448
|
+
*/
|
|
449
|
+
export declare type FeatureFlags = {
|
|
450
|
+
/* Excluded from this release type: experimentalSearch */
|
|
451
|
+
};
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* Produce a compact, LLM-readable summary of the differences between two digests, or `null` when
|
|
455
|
+
* nothing changed. The output is short enough to prepend to a user prompt without bloating the
|
|
456
|
+
* conversation; longer per-field diffs are deliberately omitted.
|
|
457
|
+
*
|
|
458
|
+
* @example
|
|
459
|
+
* ```ts
|
|
460
|
+
* const prev = getStateDigest(state);
|
|
461
|
+
* // ... user clicks around in the UI ...
|
|
462
|
+
* const diff = formatStateDigestDiff(prev, getStateDigest(state));
|
|
463
|
+
* // → '[map state changed since last response: places shown as pins: "amsterdam-cinemas"; route now "routes-2"]'
|
|
464
|
+
* ```
|
|
465
|
+
*
|
|
466
|
+
* @group Agent Toolkit
|
|
467
|
+
*/
|
|
468
|
+
export declare const formatStateDigestDiff: (prev: StateDigest, next: StateDigest) => string | null;
|
|
469
|
+
|
|
470
|
+
/** Tagged id for any polygon source in session state. */
|
|
471
|
+
export declare type GeometriesId = z.infer<typeof geometriesIdSchema>;
|
|
472
|
+
|
|
473
|
+
/** Possible kinds in a geometries id. */
|
|
474
|
+
export declare type GeometriesIdKind = 'place' | 'places' | 'ranges' | 'custom';
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* Tagged geometries id. The Zod schema is exposed so tools can plug it
|
|
478
|
+
* straight into their input shape (`z.array(geometriesIdSchema).min(1)`)
|
|
479
|
+
* — no string parsing on the way in.
|
|
480
|
+
*
|
|
481
|
+
* @group Agent Toolkit
|
|
482
|
+
*/
|
|
483
|
+
export declare const geometriesIdSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
484
|
+
kind: z.ZodLiteral<"place">;
|
|
485
|
+
id: z.ZodString;
|
|
486
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
487
|
+
kind: z.ZodLiteral<"places">;
|
|
488
|
+
id: z.ZodString;
|
|
489
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
490
|
+
kind: z.ZodLiteral<"ranges">;
|
|
491
|
+
id: z.ZodString;
|
|
492
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
493
|
+
kind: z.ZodLiteral<"custom">;
|
|
494
|
+
id: z.ZodString;
|
|
495
|
+
}, z.core.$strip>], "kind">;
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* Provenance metadata for a custom-geometries entry — captures every input
|
|
499
|
+
* source that fed the polygon-producing operation. `sourceIds` holds tagged
|
|
500
|
+
* ids in the same form `geometriesEntryIDs` accepts: `{ kind: 'place' }` for
|
|
501
|
+
* a single place footprint, `{ kind: 'places' }` for every footprint in a
|
|
502
|
+
* places entry, `{ kind: 'ranges' }` for an isochrone entry,
|
|
503
|
+
* `{ kind: 'custom' }` for a derived entry. `operation` is a short label for
|
|
504
|
+
* the kind of computation that produced the entry (e.g. `'union'`, `'buffer'`,
|
|
505
|
+
* `'h3-coverage'`).
|
|
506
|
+
*
|
|
507
|
+
* @group Agent Toolkit
|
|
508
|
+
*/
|
|
509
|
+
export declare type GeometryProvenance = {
|
|
510
|
+
/** Short label for the operation that produced this entry (free-form). */
|
|
511
|
+
operation?: string;
|
|
512
|
+
/** Tagged source ids that fed the producing operation. */
|
|
513
|
+
sourceIds: readonly GeometriesId[];
|
|
514
|
+
};
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* Snapshot the user-visible state surface. Call after every assistant turn (to record the
|
|
518
|
+
* "agent-known" baseline) and again before each user prompt (to detect what changed since).
|
|
519
|
+
*
|
|
520
|
+
* @group Agent Toolkit
|
|
521
|
+
*/
|
|
522
|
+
export declare const getStateDigest: (state: ToolState) => StateDigest;
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* Snapshot of an entry's focus subset. Returned by `getFocus` / payload on `focus-change`.
|
|
526
|
+
*
|
|
527
|
+
* @group Agent Toolkit
|
|
528
|
+
*/
|
|
529
|
+
declare type IncidentFocus = {
|
|
530
|
+
ids: Set<string>;
|
|
531
|
+
reason?: string;
|
|
532
|
+
};
|
|
533
|
+
|
|
534
|
+
/**
|
|
535
|
+
* One-shot polling loop scoped to a single bbox. Owns its timer, status, error,
|
|
536
|
+
* and captured area. Re-starting after `stop()` is allowed and resets all state.
|
|
537
|
+
*
|
|
538
|
+
* The monitor never knows about the entry that owns it — it surfaces ticks/errors
|
|
539
|
+
* through `events`, and the caller decides what to do with the snapshot.
|
|
540
|
+
*
|
|
541
|
+
* @group Agent Toolkit
|
|
542
|
+
*/
|
|
543
|
+
declare class IncidentMonitor {
|
|
544
|
+
private readonly _bbox;
|
|
545
|
+
readonly events: StateEvents<IncidentMonitorEvents>;
|
|
546
|
+
private _status;
|
|
547
|
+
private _area?;
|
|
548
|
+
private _error?;
|
|
549
|
+
private _intervalHandle?;
|
|
550
|
+
private _clearInterval?;
|
|
551
|
+
private _fetchIncidents?;
|
|
552
|
+
constructor(_bbox: BBox_2);
|
|
553
|
+
get status(): PollingStatus;
|
|
554
|
+
get monitoredArea(): MonitoredArea | undefined;
|
|
555
|
+
get error(): string | undefined;
|
|
556
|
+
/**
|
|
557
|
+
* True when the monitor is *currently* polling. Distinct from {@link isActive},
|
|
558
|
+
* which also covers `stopped-error` — a state where the timer is gone but the
|
|
559
|
+
* monitor still carries an unacknowledged error. Use this for "is the entry
|
|
560
|
+
* being polled right now"; use `isActive` for "is there anything to clean up".
|
|
561
|
+
*/
|
|
562
|
+
get isRunning(): boolean;
|
|
563
|
+
/** True when the monitor has any polling activity (running or stopped-error). */
|
|
564
|
+
get isActive(): boolean;
|
|
565
|
+
/**
|
|
566
|
+
* Begin polling. Captures `deps` for the lifetime of the run, fires the first tick
|
|
567
|
+
* immediately, then schedules an interval. No-op when already running.
|
|
568
|
+
*/
|
|
569
|
+
start(area: MonitoredArea, deps: IncidentMonitorDeps, intervalMs?: number): void;
|
|
570
|
+
/** Stop polling and reset state. No-op when idle. */
|
|
571
|
+
stop(): void;
|
|
572
|
+
private _tick;
|
|
573
|
+
private _failed;
|
|
574
|
+
private _releaseTimer;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* Dependency injection for an {@link IncidentMonitor}. Production code wires
|
|
579
|
+
* `fetchIncidents` to `trafficIncidentDetails`; tests can pass a deterministic fake
|
|
580
|
+
* and override the timer.
|
|
581
|
+
*
|
|
582
|
+
* The fetcher returns just the incidents — the monitor stamps `takenAt` itself
|
|
583
|
+
* so every consumer of one tick (entry data, derived analyses, sandbox `now`)
|
|
584
|
+
* agrees on the same canonical moment.
|
|
585
|
+
*
|
|
586
|
+
* @group Agent Toolkit
|
|
587
|
+
*/
|
|
588
|
+
declare type IncidentMonitorDeps = {
|
|
589
|
+
fetchIncidents: (bbox: BBox_2) => Promise<TrafficIncident_2[]>;
|
|
590
|
+
/** Override for tests. Defaults to the global `setInterval`. */
|
|
591
|
+
setInterval?: (fn: () => void, ms: number) => unknown;
|
|
592
|
+
clearInterval?: (handle: unknown) => void;
|
|
593
|
+
};
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* Events fired by {@link IncidentMonitor}. The slice subscribes once and re-emits
|
|
597
|
+
* translated copies (`monitor-tick` / `monitor-error`) keyed by entry id.
|
|
598
|
+
*/
|
|
599
|
+
declare type IncidentMonitorEvents = {
|
|
600
|
+
/** A poll succeeded. Payload: the fresh snapshot. */
|
|
601
|
+
tick: IncidentSnapshot;
|
|
602
|
+
/** A poll failed — the monitor has cleared its timer and moved to `stopped-error`. */
|
|
603
|
+
error: string;
|
|
604
|
+
};
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* Per-entry analysis registry: owns re-executing specs *and* the timeline of
|
|
608
|
+
* their results. One thing, three parts — name, recipe (spec), output history —
|
|
609
|
+
* kept together instead of split across sibling fields.
|
|
610
|
+
*
|
|
611
|
+
* Each named analysis keeps a bounded chronological history (see
|
|
612
|
+
* {@link MAX_HISTORY_PER_ANALYSIS}) so consumers can trend results over time;
|
|
613
|
+
* `getResult(name)` returns the most recent, `history(name)` the full timeline.
|
|
614
|
+
*
|
|
615
|
+
* Errors from individual specs are dropped silently — replay should never break
|
|
616
|
+
* the monitor tick that triggered it.
|
|
617
|
+
*
|
|
618
|
+
* @group Agent Toolkit
|
|
619
|
+
*/
|
|
620
|
+
declare class IncidentsAnalyses {
|
|
621
|
+
private _specs;
|
|
622
|
+
private readonly _historyByName;
|
|
623
|
+
get specs(): readonly IncidentsAnalysisSpec[];
|
|
624
|
+
/**
|
|
625
|
+
* Latest result for each registered spec, in registration order. Specs whose
|
|
626
|
+
* history is empty (e.g. only failed runs) are skipped. UI layers that "render
|
|
627
|
+
* whatever analyses this entry has" should iterate this instead of poking at
|
|
628
|
+
* private history state.
|
|
629
|
+
*/
|
|
630
|
+
get results(): readonly IncidentsAnalysis[];
|
|
631
|
+
/** Full timeline for a single named analysis, oldest first. Empty when unknown. */
|
|
632
|
+
history(name: string): readonly IncidentsAnalysis[];
|
|
633
|
+
/** Most recent result for a given analysis name, or undefined. */
|
|
634
|
+
getResult(name: string): IncidentsAnalysis | undefined;
|
|
635
|
+
/**
|
|
636
|
+
* Register a spec, or replace an existing one with the same name. When the new spec
|
|
637
|
+
* differs from the existing one (code, outputFormat, or description), drops history
|
|
638
|
+
* for that name — old results belong to a different analysis and must not leak into
|
|
639
|
+
* `getResult` / `results`, which describe the *current* spec. Identical re-registers
|
|
640
|
+
* are no-ops and preserve history (so trend continuity survives idempotent retries).
|
|
641
|
+
*/
|
|
642
|
+
register(spec: IncidentsAnalysisSpec): void;
|
|
643
|
+
/** Drop a spec by name. No-op when unknown. Result history is preserved. */
|
|
644
|
+
unregister(name: string): void;
|
|
645
|
+
/**
|
|
646
|
+
* Append a result to the timeline for its name, evicting the oldest entry
|
|
647
|
+
* when the per-name cap is hit. Used by the slice for one-shot tool runs and
|
|
648
|
+
* by {@link replay} for each fresh tick.
|
|
649
|
+
*/
|
|
650
|
+
attach(result: IncidentsAnalysis): void;
|
|
651
|
+
/**
|
|
652
|
+
* Re-run every registered spec against `data`, threading the previous result
|
|
653
|
+
* from the timeline. `sampledAt` is the canonical moment for this replay —
|
|
654
|
+
* shared with the entry data and the sandbox's `now`, so consumers can join
|
|
655
|
+
* across them safely. Each fresh result is appended before being returned.
|
|
656
|
+
* Failed specs are skipped.
|
|
657
|
+
*/
|
|
658
|
+
replay(data: TrafficIncident[], sampledAt: number): Promise<IncidentsAnalysis[]>;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* A single aggregation/analysis result attached to a traffic-incidents entry.
|
|
663
|
+
* Produced by the `analyseIncidents` tool; `data` is whatever the dynamic code returned.
|
|
664
|
+
*
|
|
665
|
+
* @group Agent Toolkit
|
|
666
|
+
*/
|
|
667
|
+
declare type IncidentsAnalysis = {
|
|
668
|
+
/** Unique name within the parent entry (used as a key for future UI). */
|
|
669
|
+
name: string;
|
|
670
|
+
timestamp: number;
|
|
671
|
+
/** Optional human-readable description of what the analysis computed. */
|
|
672
|
+
description?: string;
|
|
673
|
+
/** How `data` should be interpreted — plain JSON or a Chart.js configuration. */
|
|
674
|
+
outputFormat: AnalysisOutputFormat;
|
|
675
|
+
/** Arbitrary aggregation result returned by the dynamic code. */
|
|
676
|
+
data: unknown;
|
|
677
|
+
};
|
|
678
|
+
|
|
679
|
+
/**
|
|
680
|
+
* A registered, re-executing analysis. Produced by `analyseIncidents`; replayed by
|
|
681
|
+
* an entry's {@link IncidentsAnalyses} on every monitor-tick of its source.
|
|
682
|
+
*
|
|
683
|
+
* @group Agent Toolkit
|
|
684
|
+
*/
|
|
685
|
+
declare type IncidentsAnalysisSpec = {
|
|
686
|
+
name: string;
|
|
687
|
+
description?: string;
|
|
688
|
+
outputFormat: AnalysisOutputFormat;
|
|
689
|
+
code: string;
|
|
690
|
+
/** Source entry id the spec reads from. */
|
|
691
|
+
source: string;
|
|
692
|
+
};
|
|
693
|
+
|
|
694
|
+
export declare type IncidentSnapshot = {
|
|
695
|
+
takenAt: number;
|
|
696
|
+
incidents: TrafficIncident_2[];
|
|
697
|
+
};
|
|
698
|
+
|
|
699
|
+
declare type JSONValue = null | string | number | boolean | {
|
|
700
|
+
[key: string]: JSONValue;
|
|
701
|
+
} | JSONValue[];
|
|
702
|
+
|
|
294
703
|
/**
|
|
295
704
|
* The return type of createMapAgent().
|
|
296
705
|
* A real ToolLoopAgent instance with state access and cleanup.
|
|
@@ -396,6 +805,50 @@ export declare type MapAgentOptions<CS extends ToolState = ToolState> = {
|
|
|
396
805
|
outputSchemas?: boolean;
|
|
397
806
|
/** Max multi-step tool loop iterations. Default: 10. */
|
|
398
807
|
maxSteps?: number;
|
|
808
|
+
/**
|
|
809
|
+
* Opt into in-flight or experimental agent-toolkit behaviour. Stability
|
|
810
|
+
* varies per flag — see {@link FeatureFlags} and each flag's own doc.
|
|
811
|
+
*
|
|
812
|
+
* @experimental
|
|
813
|
+
*/
|
|
814
|
+
featureFlags?: FeatureFlags;
|
|
815
|
+
/**
|
|
816
|
+
* Provider-specific options forwarded to the AI SDK on every step. Keyed by
|
|
817
|
+
* provider id (`openai`, `azure`, `anthropic`, ...).
|
|
818
|
+
*
|
|
819
|
+
* Use this to enable reasoning summaries for gpt-5.x via the Responses API
|
|
820
|
+
* — without `reasoningSummary` the model thinks but returns no reasoning text:
|
|
821
|
+
*
|
|
822
|
+
* @example
|
|
823
|
+
* ```typescript
|
|
824
|
+
* createMapAgent(map, {
|
|
825
|
+
* model: azure.responses(deploymentId),
|
|
826
|
+
* providerOptions: {
|
|
827
|
+
* openai: { reasoningEffort: 'low', reasoningSummary: 'auto' },
|
|
828
|
+
* },
|
|
829
|
+
* });
|
|
830
|
+
* ```
|
|
831
|
+
*/
|
|
832
|
+
providerOptions?: ProviderOptions;
|
|
833
|
+
/**
|
|
834
|
+
* Per-step `providerOptions` override. Called once per step with the
|
|
835
|
+
* classifier-narrowed active toolset; the returned object is merged on top
|
|
836
|
+
* of `providerOptions` for that step. Use it to bump reasoning effort on
|
|
837
|
+
* turns that include a code-execution tool without paying the cost on
|
|
838
|
+
* simple fetch/toggle turns.
|
|
839
|
+
*
|
|
840
|
+
* @example
|
|
841
|
+
* ```typescript
|
|
842
|
+
* stepProviderOptions: ({ activeTools }) =>
|
|
843
|
+
* activeTools?.some((t) => CODE_EXEC.has(t))
|
|
844
|
+
* ? { openai: { reasoningEffort: 'medium' } }
|
|
845
|
+
* : undefined,
|
|
846
|
+
* ```
|
|
847
|
+
*/
|
|
848
|
+
stepProviderOptions?: (info: {
|
|
849
|
+
activeTools: string[] | undefined;
|
|
850
|
+
stepNumber: number;
|
|
851
|
+
}) => ProviderOptions | undefined;
|
|
399
852
|
};
|
|
400
853
|
|
|
401
854
|
/**
|
|
@@ -415,6 +868,30 @@ declare class MapPOIsState implements StateSlice {
|
|
|
415
868
|
reset(): void;
|
|
416
869
|
}
|
|
417
870
|
|
|
871
|
+
export declare type MonitoredArea = {
|
|
872
|
+
bbox: BBox_2;
|
|
873
|
+
capturedAt: number;
|
|
874
|
+
label?: string;
|
|
875
|
+
};
|
|
876
|
+
|
|
877
|
+
/**
|
|
878
|
+
* A single aggregation/analysis result attached to a places entry.
|
|
879
|
+
* Produced by the `analysePlaces` tool; `data` is whatever the dynamic code returned.
|
|
880
|
+
*
|
|
881
|
+
* @group Agent Toolkit
|
|
882
|
+
*/
|
|
883
|
+
export declare type PlacesAnalysis = {
|
|
884
|
+
/** Unique name within the parent entry (used as a key for future UI). */
|
|
885
|
+
name: string;
|
|
886
|
+
timestamp: number;
|
|
887
|
+
/** Optional human-readable description of what the analysis computed. */
|
|
888
|
+
description?: string;
|
|
889
|
+
/** How `data` should be interpreted — plain JSON or a Chart.js configuration. */
|
|
890
|
+
outputFormat: AnalysisOutputFormat;
|
|
891
|
+
/** Arbitrary aggregation result returned by the dynamic code. */
|
|
892
|
+
data: unknown;
|
|
893
|
+
};
|
|
894
|
+
|
|
418
895
|
/**
|
|
419
896
|
* A single entry in the place search history.
|
|
420
897
|
*
|
|
@@ -424,65 +901,234 @@ export declare type PlacesEntry = {
|
|
|
424
901
|
id: string;
|
|
425
902
|
timestamp: number;
|
|
426
903
|
label: string;
|
|
427
|
-
|
|
904
|
+
places: Place[];
|
|
905
|
+
/** Connections (lines between places) produced alongside this entry, rendered via PlacesModule.showConnections. */
|
|
906
|
+
connections?: PlaceConnectionDisplay[];
|
|
907
|
+
/**
|
|
908
|
+
* Boundary polygons attached to this entry. One feature per place that has a geometry data
|
|
909
|
+
* 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
|
|
911
|
+
* (`place.properties.dataSources.geometry.id`), matching the response shape of `geometryData`.
|
|
912
|
+
*/
|
|
913
|
+
geometries?: PolygonFeature<CommonPlaceProps>[];
|
|
914
|
+
/** Accumulated analysis results linked to this entry. */
|
|
915
|
+
_analysis?: PlacesAnalysis[];
|
|
916
|
+
/** Lazy place-id → Place index, built on first ID lookup through PlacesState.findPlaceById. */
|
|
917
|
+
_byId?: Record<string, Place>;
|
|
918
|
+
/** Lazy place-id → boundary polygon index, built on first lookup through PlacesState.getGeometryForPlace. */
|
|
919
|
+
_geometryByPlaceId?: Record<string, PolygonFeature<CommonPlaceProps>>;
|
|
920
|
+
/**
|
|
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.
|
|
924
|
+
*/
|
|
925
|
+
_modules?: {
|
|
926
|
+
pin?: PlacesModule;
|
|
927
|
+
baseMap?: PlacesModule;
|
|
928
|
+
pinClustered?: PlacesModule;
|
|
929
|
+
geometries?: GeometriesModule;
|
|
930
|
+
};
|
|
931
|
+
/** The marker theme currently rendering this entry, or undefined when hidden. */
|
|
932
|
+
_shownAs?: 'pin' | 'base-map' | 'pin-clustered';
|
|
428
933
|
};
|
|
429
934
|
|
|
935
|
+
/** How an entry is rendered on the map: as individual pins, base-map POIs, or clustered pins. */
|
|
936
|
+
declare type PlacesMarkerType = 'pin' | 'base-map' | 'pin-clustered';
|
|
937
|
+
|
|
430
938
|
/**
|
|
431
|
-
* State for place
|
|
939
|
+
* State for the places layer: an append-only history of place results plus per-entry display
|
|
940
|
+
* modules.
|
|
432
941
|
*
|
|
433
|
-
*
|
|
434
|
-
*
|
|
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.
|
|
435
946
|
*
|
|
436
947
|
* @group Agent Toolkit
|
|
437
948
|
*/
|
|
438
949
|
declare class PlacesState implements StateSlice {
|
|
439
950
|
private readonly _ttMap;
|
|
440
|
-
private _placesModule?;
|
|
441
951
|
private _entries;
|
|
442
|
-
|
|
443
|
-
|
|
952
|
+
private _entryMode;
|
|
953
|
+
/** Subscribe to state changes — see {@link PlacesStateEvents}. */
|
|
954
|
+
readonly events: StateEvents<PlacesStateEvents>;
|
|
444
955
|
constructor(_ttMap: TomTomMap);
|
|
445
|
-
|
|
446
|
-
|
|
956
|
+
/**
|
|
957
|
+
* Display policy: `multiple` (default) keeps every history entry available to render
|
|
958
|
+
* simultaneously; `single` enforces "at most one entry on the map at a time" and trims
|
|
959
|
+
* the history down to the latest entry whenever it's set.
|
|
960
|
+
*/
|
|
961
|
+
get entryMode(): EntryMode;
|
|
962
|
+
/**
|
|
963
|
+
* Switch the display policy. When moving from `multiple` → `single` we hide every entry
|
|
964
|
+
* older than the latest, drop them from history, and emit `entries-change` so listeners
|
|
965
|
+
* (the recents rail, recall tools, …) re-render. No-op when the mode hasn't changed.
|
|
966
|
+
*/
|
|
967
|
+
setEntryMode(mode: EntryMode): Promise<void>;
|
|
968
|
+
/**
|
|
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.
|
|
972
|
+
*/
|
|
973
|
+
getEntryPlacesModule(entryId: string, markerType: PlacesMarkerType): Promise<PlacesModule>;
|
|
974
|
+
/**
|
|
975
|
+
* Lazy-init and return the entry's place-geometries module (for POI footprints, municipality
|
|
976
|
+
* outlines). Re-applies themed config when the theme changes. Throws on unknown entry id.
|
|
977
|
+
*/
|
|
978
|
+
getEntryGeometriesModule(entryId: string, theme?: GeometryTheme): Promise<GeometriesModule>;
|
|
979
|
+
private _requireEntry;
|
|
447
980
|
get entries(): readonly PlacesEntry[];
|
|
448
981
|
/**
|
|
449
982
|
* This is used purely to pass data between tools in a context-dependent way,
|
|
450
983
|
* so we assume the most recent entry is the relevant one to show on the map.
|
|
451
984
|
*/
|
|
452
|
-
get latestPlace():
|
|
453
|
-
addPlaceResult(place:
|
|
454
|
-
|
|
455
|
-
|
|
985
|
+
get latestPlace(): Place[] | undefined;
|
|
986
|
+
addPlaceResult(place: Place | Places, label: string, explicitId?: string, connections?: PlaceConnectionDisplay[], geometries?: PolygonFeature<CommonPlaceProps>[]): string;
|
|
987
|
+
private _uniqueEntryId;
|
|
988
|
+
/**
|
|
989
|
+
* Attach an analysis result to an existing entry. Analysis names are unique
|
|
990
|
+
* within a single entry — adding one with an existing name replaces it.
|
|
991
|
+
* Returns true on success, false if the entry doesn't exist.
|
|
992
|
+
*/
|
|
993
|
+
addAnalysisToEntry(entryId: string, analysis: PlacesAnalysis): boolean;
|
|
994
|
+
findPlaceById(placeId: string): {
|
|
995
|
+
place: Place;
|
|
996
|
+
entryId: string;
|
|
997
|
+
} | undefined;
|
|
998
|
+
/**
|
|
999
|
+
* Returns the cached boundary polygon for a place id, or undefined if no geometry has been
|
|
1000
|
+
* fetched for it yet. Builds a lazy place-id → feature index per entry on first lookup.
|
|
1001
|
+
*/
|
|
1002
|
+
getGeometryForPlace(placeId: string): PolygonFeature<CommonPlaceProps> | undefined;
|
|
1003
|
+
/**
|
|
1004
|
+
* Fetches the boundary polygon for a place from the Geometry Data service and stores it on
|
|
1005
|
+
* the owning entry. Returns the cached feature if already fetched, or undefined if the place
|
|
1006
|
+
* is unknown or has no geometry data source.
|
|
1007
|
+
*/
|
|
1008
|
+
fetchPlaceGeometry(placeId: string): Promise<PolygonFeature<CommonPlaceProps> | undefined>;
|
|
1009
|
+
/**
|
|
1010
|
+
* Batch-fetches boundary polygons for every place in an entry that has a geometry data source
|
|
1011
|
+
* but is not yet cached. Issues one Geometry Data request per chunk of {@link GEOMETRY_DATA_BATCH_SIZE}
|
|
1012
|
+
* place ids (the API caps each request) and stores the merged result on `entry.geometries`.
|
|
1013
|
+
* Returns the full geometries list for the entry, or an empty array if the entry is unknown.
|
|
1014
|
+
*/
|
|
1015
|
+
fetchGeometriesForEntry(entryId: string): Promise<PolygonFeature<CommonPlaceProps>[]>;
|
|
1016
|
+
/**
|
|
1017
|
+
* Render the given polygons via the entry's GeometriesModule. The `mode` flag is
|
|
1018
|
+
* scoped to **this entry's layer only** — it does not touch other entries (use
|
|
1019
|
+
* the slice's per-entry hide/show methods for cross-entry visibility).
|
|
1020
|
+
*
|
|
1021
|
+
* - `mode: 'replace'` (default) — calls `module.show` with exactly these features, replacing
|
|
1022
|
+
* whatever was previously on this entry's layer. An empty array clears the layer.
|
|
1023
|
+
* - `mode: 'add'` — merges the new features with the polygons currently shown on this
|
|
1024
|
+
* entry's layer (deduped by `feature.id`) and re-renders the union. An empty array is a
|
|
1025
|
+
* no-op.
|
|
1026
|
+
*
|
|
1027
|
+
* `entryId` defaults to the latest entry that owns geometries — handy when callers only ever
|
|
1028
|
+
* render the most-recently produced footprints. Pass an explicit id to target an older one.
|
|
1029
|
+
*/
|
|
1030
|
+
showPlaceGeometries(features: PolygonFeature<CommonPlaceProps>[], theme?: GeometryTheme, mode?: 'add' | 'replace', entryId?: string): Promise<void>;
|
|
1031
|
+
private _latestGeometriesEntryId;
|
|
1032
|
+
private _buildGeometryIndex;
|
|
1033
|
+
/** IDs of all entries currently shown on the map. */
|
|
1034
|
+
get shownEntryIds(): ReadonlySet<string>;
|
|
1035
|
+
/** IDs of entries currently shown as individual pins. */
|
|
1036
|
+
get shownAsPinIds(): ReadonlySet<string>;
|
|
1037
|
+
/** IDs of entries currently shown as base-map POIs. */
|
|
1038
|
+
get shownAsBaseMapIds(): ReadonlySet<string>;
|
|
1039
|
+
/** IDs of entries currently shown as clustered pins. */
|
|
1040
|
+
get shownAsPinClusteredIds(): ReadonlySet<string>;
|
|
1041
|
+
private _idsShownAs;
|
|
1042
|
+
/** Marker type for a specific entry, or undefined if it is not shown. */
|
|
1043
|
+
getShownMarkerType(id: string): PlacesMarkerType | undefined;
|
|
456
1044
|
/** Return the union of all features belonging to currently-shown entries. */
|
|
457
|
-
getShownFeatures():
|
|
458
|
-
/**
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
1045
|
+
getShownFeatures(): Place[];
|
|
1046
|
+
/**
|
|
1047
|
+
* Replace the shown set for `markerType` with exactly these ids and re-render.
|
|
1048
|
+
* Entries currently shown as `markerType` but absent from `ids` are hidden;
|
|
1049
|
+
* entries in `ids` are switched to `markerType` (lazy-creating their module).
|
|
1050
|
+
*/
|
|
1051
|
+
setShownEntries(ids: readonly string[], markerType: PlacesMarkerType): Promise<Place[]>;
|
|
1052
|
+
/**
|
|
1053
|
+
* Add ids to the shown set under `markerType`. Any id previously shown as
|
|
1054
|
+
* a different marker type is moved (its previous module is cleared, the
|
|
1055
|
+
* new theme's module renders).
|
|
1056
|
+
*
|
|
1057
|
+
* Under `entryMode === 'single'` everything else is hidden first, so the
|
|
1058
|
+
* effective behaviour collapses to "show exactly the last id in the list".
|
|
1059
|
+
*/
|
|
1060
|
+
addShownEntries(ids: readonly string[], markerType: PlacesMarkerType): Promise<Place[]>;
|
|
1061
|
+
/** Remove ids from the shown set and clear their modules. */
|
|
1062
|
+
removeShownEntries(ids: readonly string[]): Promise<Place[]>;
|
|
464
1063
|
/** Clear everything from the map (does not touch entries history). */
|
|
465
1064
|
clearShownEntries(): Promise<void>;
|
|
466
|
-
|
|
1065
|
+
clearShownGeometries(ids?: readonly string[]): Promise<void>;
|
|
1066
|
+
/**
|
|
1067
|
+
* Drop a single entry from history. Hides it from the map first (clears every theme module
|
|
1068
|
+
* it owns) then removes it from `_entries`. Emits `entries-change` and, when the entry was
|
|
1069
|
+
* shown, `shown-change`. No-op when the id is unknown.
|
|
1070
|
+
*/
|
|
1071
|
+
removeEntry(id: string): Promise<void>;
|
|
1072
|
+
private _showEntryAs;
|
|
1073
|
+
private _hideEntry;
|
|
467
1074
|
reset(): void;
|
|
468
1075
|
}
|
|
469
1076
|
|
|
470
1077
|
/**
|
|
471
|
-
*
|
|
1078
|
+
* Events fired by {@link PlacesState}. Subscribe via `state.places.events.on(type, handler)`.
|
|
1079
|
+
*
|
|
1080
|
+
* @group Agent Toolkit
|
|
1081
|
+
*/
|
|
1082
|
+
declare type PlacesStateEvents = {
|
|
1083
|
+
/** History changed — entry added, replaced, or cleared via `reset()`. Payload: the full entries snapshot. */
|
|
1084
|
+
'entries-change': readonly PlacesEntry[];
|
|
1085
|
+
/** Set of entries currently rendered on the map changed (or marker type swapped). */
|
|
1086
|
+
'shown-change': ReadonlySet<string>;
|
|
1087
|
+
/** A new analysis was attached to (or replaced on) an entry. */
|
|
1088
|
+
'analysis-added': {
|
|
1089
|
+
entryId: string;
|
|
1090
|
+
analysis: PlacesAnalysis;
|
|
1091
|
+
};
|
|
1092
|
+
/** Boundary polygons were fetched and cached on an entry. */
|
|
1093
|
+
'geometries-change': {
|
|
1094
|
+
entryId: string;
|
|
1095
|
+
count: number;
|
|
1096
|
+
};
|
|
1097
|
+
/** Display policy switched between `single` and `multiple`. */
|
|
1098
|
+
'mode-change': EntryMode;
|
|
1099
|
+
};
|
|
1100
|
+
|
|
1101
|
+
export declare type PollingStatus = 'idle' | 'running' | 'stopped-error';
|
|
1102
|
+
|
|
1103
|
+
declare type ProviderOptions = Record<string, Record<string, JSONValue | undefined>>;
|
|
1104
|
+
|
|
1105
|
+
/**
|
|
1106
|
+
* A single entry in the reachable range history. Holds one or more
|
|
1107
|
+
* {@link ReachableRange} results that were computed together — typically
|
|
1108
|
+
* one per origin in a multi-origin call to `findReachableAreas`.
|
|
472
1109
|
*
|
|
473
1110
|
* @group Agent Toolkit
|
|
474
1111
|
*/
|
|
475
|
-
export declare type
|
|
1112
|
+
export declare type RangesEntry = {
|
|
476
1113
|
id: string;
|
|
477
1114
|
timestamp: number;
|
|
478
1115
|
label: string;
|
|
479
|
-
origin
|
|
480
|
-
|
|
481
|
-
|
|
1116
|
+
/** One or more ranges sharing this entry — typically one per origin. */
|
|
1117
|
+
ranges: ReachableRange[];
|
|
1118
|
+
/**
|
|
1119
|
+
* Per-entry display modules. Each entry owns a dedicated GeometriesModule (for the
|
|
1120
|
+
* isochrone polygons) and PlacesModule (for the origin pin(s)), so display state lives
|
|
1121
|
+
* on the entry instead of a shared slice-level module. Lazy-initialised via RangeState
|
|
1122
|
+
* helpers — undefined until first show.
|
|
1123
|
+
*/
|
|
1124
|
+
_modules?: {
|
|
1125
|
+
geometries?: GeometriesModule;
|
|
1126
|
+
places?: PlacesModule;
|
|
482
1127
|
};
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
1128
|
+
/** Theme that the geometries module is currently configured with. */
|
|
1129
|
+
_shownTheme?: 'filled' | 'outline' | 'inverted';
|
|
1130
|
+
/** True while any of this entry's modules are rendering on the map. */
|
|
1131
|
+
_shown?: boolean;
|
|
486
1132
|
};
|
|
487
1133
|
|
|
488
1134
|
/**
|
|
@@ -494,40 +1140,115 @@ export declare type RangeEntry = {
|
|
|
494
1140
|
*
|
|
495
1141
|
* @group Agent Toolkit
|
|
496
1142
|
*/
|
|
497
|
-
declare class RangeState implements
|
|
1143
|
+
declare class RangeState implements ShownEntriesSlice {
|
|
498
1144
|
private readonly _ttMap;
|
|
499
1145
|
private _entries;
|
|
500
|
-
private
|
|
501
|
-
|
|
502
|
-
|
|
1146
|
+
private _entryMode;
|
|
1147
|
+
/** Subscribe to state changes — see {@link RangeStateEvents}. */
|
|
1148
|
+
readonly events: StateEvents<RangeStateEvents>;
|
|
503
1149
|
constructor(_ttMap: TomTomMap);
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
1150
|
+
/** Set of ranges-entry ids currently rendered on the map. */
|
|
1151
|
+
get shownEntryIds(): ReadonlySet<string>;
|
|
1152
|
+
/**
|
|
1153
|
+
* Display policy: `multiple` (default) lets several reachable-area entries render side
|
|
1154
|
+
* by side; `single` forces "at most one ranges entry on the map" — `markEntryShown`
|
|
1155
|
+
* then hides any previously-shown entry first.
|
|
1156
|
+
*/
|
|
1157
|
+
get entryMode(): EntryMode;
|
|
1158
|
+
/**
|
|
1159
|
+
* Switch the display policy. When moving from `multiple` → `single` we hide every
|
|
1160
|
+
* non-latest entry, drop them from history, and emit `entries-change`. No-op when the
|
|
1161
|
+
* mode hasn't changed.
|
|
1162
|
+
*/
|
|
1163
|
+
setEntryMode(mode: EntryMode): Promise<void>;
|
|
1164
|
+
/**
|
|
1165
|
+
* Lazy-init the entry's GeometriesModule (for the isochrone/isodistance polygons),
|
|
1166
|
+
* applying the requested theme. Throws on unknown id.
|
|
1167
|
+
*/
|
|
1168
|
+
getEntryGeometriesModule(entryId: string, theme?: GeometryTheme): Promise<GeometriesModule>;
|
|
1169
|
+
/**
|
|
1170
|
+
* Lazy-init the entry's origin-pin PlacesModule. Each entry maintains its own pin module
|
|
1171
|
+
* so multiple ranges entries can be on the map simultaneously without the pins of one
|
|
1172
|
+
* overwriting another.
|
|
1173
|
+
*/
|
|
1174
|
+
getEntryPlacesModule(entryId: string): Promise<PlacesModule>;
|
|
1175
|
+
/**
|
|
1176
|
+
* Mark this entry as shown — records `_shown = true` and emits `shown-change`. The
|
|
1177
|
+
* caller is expected to push features into the lazy modules itself; this method only
|
|
1178
|
+
* keeps the `_shown` flag in sync with what the user sees.
|
|
1179
|
+
*
|
|
1180
|
+
* Under `entryMode === 'single'` any other shown entry is hidden first so two range
|
|
1181
|
+
* layers don't overlap.
|
|
1182
|
+
*/
|
|
1183
|
+
markEntryShown(entryId: string): Promise<void>;
|
|
1184
|
+
/** Hide every module on the entry (clear). No-op when the entry is unknown. */
|
|
1185
|
+
hideEntry(entryId: string): Promise<void>;
|
|
1186
|
+
/**
|
|
1187
|
+
* Drop a single entry from history. Hides it from the map first (clears its geometries +
|
|
1188
|
+
* origin-pin modules) then removes it from `_entries`. Emits `entries-change`. No-op when
|
|
1189
|
+
* the id is unknown.
|
|
1190
|
+
*/
|
|
1191
|
+
removeEntry(entryId: string): Promise<void>;
|
|
1192
|
+
private _requireEntry;
|
|
1193
|
+
get entries(): readonly RangesEntry[];
|
|
1194
|
+
get latestEntry(): RangesEntry | undefined;
|
|
1195
|
+
addEntry(entry: Omit<RangesEntry, 'id' | 'timestamp'>): string;
|
|
510
1196
|
reset(): void;
|
|
511
1197
|
}
|
|
512
1198
|
|
|
1199
|
+
/**
|
|
1200
|
+
* Events fired by {@link RangeState}. Subscribe via `state.ranges.events.on(type, handler)`.
|
|
1201
|
+
*
|
|
1202
|
+
* @group Agent Toolkit
|
|
1203
|
+
*/
|
|
1204
|
+
declare type RangeStateEvents = {
|
|
1205
|
+
/** Range history changed — entry added or cleared via `reset()`. */
|
|
1206
|
+
'entries-change': readonly RangesEntry[];
|
|
1207
|
+
/** Set of ranges entries currently rendered on the map changed (multi-show under `multiple`). */
|
|
1208
|
+
'shown-change': ReadonlySet<string>;
|
|
1209
|
+
/** Display policy switched between `single` and `multiple`. */
|
|
1210
|
+
'mode-change': EntryMode;
|
|
1211
|
+
};
|
|
1212
|
+
|
|
1213
|
+
/**
|
|
1214
|
+
* A single reachable area, scoped to one origin and one set of budgets.
|
|
1215
|
+
* One {@link RangesEntry} bundles one or more of these — useful for comparing
|
|
1216
|
+
* coverage from several origins under the same query.
|
|
1217
|
+
*
|
|
1218
|
+
* @group Agent Toolkit
|
|
1219
|
+
*/
|
|
1220
|
+
export declare type ReachableRange = {
|
|
1221
|
+
origin: {
|
|
1222
|
+
query?: string;
|
|
1223
|
+
position: Position;
|
|
1224
|
+
};
|
|
1225
|
+
budgets: ReachableRangeBudget[];
|
|
1226
|
+
/** Raw polygon result for use in subsequent geometry searches. Not exposed to the agent. */
|
|
1227
|
+
polygon?: PolygonFeatures;
|
|
1228
|
+
};
|
|
1229
|
+
|
|
513
1230
|
/**
|
|
514
1231
|
* Merges default tools with user overrides.
|
|
515
1232
|
*
|
|
516
|
-
* - `ToolEntry` values add or replace tools in `defaults`.
|
|
1233
|
+
* - `ToolEntry` (or builder) values add or replace tools in `defaults`.
|
|
517
1234
|
* - `false` values remove tools from `defaults`.
|
|
518
1235
|
* - Returns a new object — `defaults` is never mutated.
|
|
519
1236
|
*
|
|
1237
|
+
* Default entries may be {@link ToolEntryBuilder builders} that produce
|
|
1238
|
+
* their {@link ToolEntry} from build-time options. Builders pass through
|
|
1239
|
+
* untouched and are materialized later by `setupTools`.
|
|
1240
|
+
*
|
|
520
1241
|
* @param defaults - Base tool record (typically DEFAULT_TOOLS or empty).
|
|
521
1242
|
* @param overrides - User-provided additions, replacements, and exclusions.
|
|
522
1243
|
* @returns Resolved tool record ready for setupTools.
|
|
523
1244
|
*
|
|
524
1245
|
* @group Agent Toolkit
|
|
525
1246
|
*/
|
|
526
|
-
export declare const resolveTools: <S extends ToolState>(defaults: Record<string,
|
|
1247
|
+
export declare const resolveTools: <S extends ToolState>(defaults: Record<string, ToolDefinition<S>>, overrides?: { [K in ToolNameHint]?: ToolEntry<S> | false | undefined; }) => Record<string, ToolDefinition<S>>;
|
|
527
1248
|
|
|
528
1249
|
/**
|
|
529
1250
|
* Route planning parameters stored in routing state.
|
|
530
|
-
* Consumed by
|
|
1251
|
+
* Consumed by setRoute, addWaypointsToRoute, removeWaypointsFromRoute, and replaceWaypointInRoute.
|
|
531
1252
|
*
|
|
532
1253
|
* @group Agent Toolkit
|
|
533
1254
|
*/
|
|
@@ -545,6 +1266,24 @@ export declare type RouteParams = {
|
|
|
545
1266
|
};
|
|
546
1267
|
};
|
|
547
1268
|
|
|
1269
|
+
/**
|
|
1270
|
+
* A single aggregation/analysis result attached to a routes entry.
|
|
1271
|
+
* Produced by the `analyseRoutes` tool; `data` is whatever the dynamic code returned.
|
|
1272
|
+
*
|
|
1273
|
+
* @group Agent Toolkit
|
|
1274
|
+
*/
|
|
1275
|
+
export declare type RoutesAnalysis = {
|
|
1276
|
+
/** Unique name within the parent entry (used as a key for future UI). */
|
|
1277
|
+
name: string;
|
|
1278
|
+
timestamp: number;
|
|
1279
|
+
/** Optional human-readable description of what the analysis computed. */
|
|
1280
|
+
description?: string;
|
|
1281
|
+
/** How `data` should be interpreted — plain JSON or a Chart.js configuration. */
|
|
1282
|
+
outputFormat: AnalysisOutputFormat;
|
|
1283
|
+
/** Arbitrary aggregation result returned by the dynamic code. */
|
|
1284
|
+
data: unknown;
|
|
1285
|
+
};
|
|
1286
|
+
|
|
548
1287
|
/**
|
|
549
1288
|
* A single entry in the route calculation history.
|
|
550
1289
|
*
|
|
@@ -557,38 +1296,226 @@ export declare type RoutesEntry = {
|
|
|
557
1296
|
data: Routes;
|
|
558
1297
|
waypoints: WaypointLike[];
|
|
559
1298
|
params: RouteParams;
|
|
1299
|
+
/** Accumulated analysis results linked to this entry. */
|
|
1300
|
+
_analysis?: RoutesAnalysis[];
|
|
1301
|
+
/**
|
|
1302
|
+
* Per-entry RoutingModule. Each entry owns its own module so display state (which route
|
|
1303
|
+
* variant is selected, which waypoints are shown, layer theme) lives on the entry instead
|
|
1304
|
+
* of a shared slice-level module. Lazy-initialised via RoutingState helpers — undefined
|
|
1305
|
+
* until first show.
|
|
1306
|
+
*/
|
|
1307
|
+
_module?: RoutingModule;
|
|
1308
|
+
/** True while this entry's `_module` is rendering routes/waypoints on the map. */
|
|
1309
|
+
_shown?: boolean;
|
|
560
1310
|
};
|
|
561
1311
|
|
|
562
1312
|
/**
|
|
563
1313
|
* State for route calculation, waypoint management, and route planning parameters.
|
|
564
1314
|
*
|
|
565
|
-
*
|
|
566
|
-
*
|
|
567
|
-
* and
|
|
1315
|
+
* Each entry carries its own lazy-initialised RoutingModule (`entry._module`), so display
|
|
1316
|
+
* state lives on the entry instead of a shared slice-level module. Two routes can be rendered
|
|
1317
|
+
* concurrently by showing both entries, and switching the active route hides the previous
|
|
1318
|
+
* entry's module without disturbing its calculated data.
|
|
568
1319
|
*
|
|
569
1320
|
* @group Agent Toolkit
|
|
570
1321
|
*/
|
|
571
|
-
declare class RoutingState implements
|
|
1322
|
+
declare class RoutingState implements ShownEntriesSlice {
|
|
572
1323
|
private readonly _ttMap;
|
|
573
|
-
private _routingModule?;
|
|
574
1324
|
private _entries;
|
|
575
1325
|
private _planningSlots;
|
|
576
1326
|
private _params;
|
|
1327
|
+
private _entryMode;
|
|
1328
|
+
/**
|
|
1329
|
+
* 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).
|
|
1333
|
+
*/
|
|
1334
|
+
private _lastShownEntryId?;
|
|
1335
|
+
/** Subscribe to state changes — see {@link RoutingStateEvents}. */
|
|
1336
|
+
readonly events: StateEvents<RoutingStateEvents>;
|
|
577
1337
|
constructor(_ttMap: TomTomMap);
|
|
578
|
-
|
|
579
|
-
get
|
|
1338
|
+
/** Set of routes-entry ids currently rendered on the map. */
|
|
1339
|
+
get shownEntryIds(): ReadonlySet<string>;
|
|
1340
|
+
/**
|
|
1341
|
+
* Display policy: `multiple` (default) lets several entries render side-by-side;
|
|
1342
|
+
* `single` forces "at most one route on the map" — `showEntry` then hides any
|
|
1343
|
+
* previously-shown entry first.
|
|
1344
|
+
*/
|
|
1345
|
+
get entryMode(): EntryMode;
|
|
1346
|
+
/**
|
|
1347
|
+
* Switch the display policy. When moving from `multiple` → `single` we hide every
|
|
1348
|
+
* non-latest entry, drop them from history, and emit `entries-change`. No-op when the
|
|
1349
|
+
* mode hasn't changed.
|
|
1350
|
+
*/
|
|
1351
|
+
setEntryMode(mode: EntryMode): Promise<void>;
|
|
1352
|
+
/**
|
|
1353
|
+
* Lazy-init and return an entry's RoutingModule. Throws on unknown id. Callers that need
|
|
1354
|
+
* to show/hide should prefer the higher-level {@link showEntry} / {@link hideEntry}.
|
|
1355
|
+
*/
|
|
1356
|
+
getEntryRoutingModule(entryId: string): Promise<RoutingModule>;
|
|
1357
|
+
/**
|
|
1358
|
+
* Render the given entry's routes + waypoints on its own RoutingModule.
|
|
1359
|
+
*
|
|
1360
|
+
* Under `entryMode === 'single'` any other shown entry is hidden first so two route
|
|
1361
|
+
* layers don't pile up. Under `entryMode === 'multiple'` previously-shown entries stay
|
|
1362
|
+
* rendered, letting the caller overlay several routes at once.
|
|
1363
|
+
*
|
|
1364
|
+
* Emits `shown-change` once the new entry is up.
|
|
1365
|
+
*/
|
|
1366
|
+
showEntry(entryId: string): Promise<void>;
|
|
1367
|
+
/**
|
|
1368
|
+
* Hide the entry's routes + waypoints on its module (clear; the module stays cached).
|
|
1369
|
+
* No-op when the entry is unknown or already hidden.
|
|
1370
|
+
*/
|
|
1371
|
+
hideEntry(entryId: string): Promise<void>;
|
|
1372
|
+
/**
|
|
1373
|
+
* Drop a single entry from history. Hides it from the map first (clears its routing module)
|
|
1374
|
+
* then removes it from `_entries`. Emits `entries-change`. No-op when the id is unknown.
|
|
1375
|
+
*/
|
|
1376
|
+
removeEntry(entryId: string): Promise<void>;
|
|
1377
|
+
private _requireEntry;
|
|
1378
|
+
/**
|
|
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.
|
|
1382
|
+
*/
|
|
1383
|
+
get currentEntryModule(): RoutingModule | undefined;
|
|
580
1384
|
get entries(): readonly RoutesEntry[];
|
|
581
|
-
get currentRoutes():
|
|
582
|
-
get currentWaypoints():
|
|
1385
|
+
get currentRoutes(): Routes | undefined;
|
|
1386
|
+
get currentWaypoints(): WaypointLike[] | undefined;
|
|
583
1387
|
/** Sparse nullable slots being assembled before triggering a route calculation. */
|
|
584
1388
|
get planningSlots(): PlanningWaypoint[];
|
|
585
1389
|
get params(): RouteParams;
|
|
586
|
-
addRoutes(routes:
|
|
587
|
-
|
|
1390
|
+
addRoutes(routes: Routes, waypoints: WaypointLike[], label: string): string;
|
|
1391
|
+
/**
|
|
1392
|
+
* Attach an analysis result to an existing routes entry. Names are unique within a single
|
|
1393
|
+
* entry — adding one with an existing name replaces it. Returns true on success, false if
|
|
1394
|
+
* the entry doesn't exist.
|
|
1395
|
+
*/
|
|
1396
|
+
addAnalysisToEntry(entryId: string, analysis: RoutesAnalysis): boolean;
|
|
1397
|
+
setWaypointAt(index: number, waypoint: WaypointLike): void;
|
|
588
1398
|
setParams(params: Partial<RouteParams>): void;
|
|
589
1399
|
reset(): void;
|
|
590
1400
|
}
|
|
591
1401
|
|
|
1402
|
+
/**
|
|
1403
|
+
* Events fired by {@link RoutingState}. Subscribe via `state.routing.events.on(type, handler)`.
|
|
1404
|
+
*
|
|
1405
|
+
* @group Agent Toolkit
|
|
1406
|
+
*/
|
|
1407
|
+
declare type RoutingStateEvents = {
|
|
1408
|
+
/** Route history changed — new calculation stored, analysis attached, or cleared via `reset()`. */
|
|
1409
|
+
'entries-change': readonly RoutesEntry[];
|
|
1410
|
+
/** Sparse waypoint planning slots changed (origin/stop/destination assignment). */
|
|
1411
|
+
'planning-change': readonly PlanningWaypoint[];
|
|
1412
|
+
/** Route parameters (alternatives, cost model, depart/arrive time) changed. */
|
|
1413
|
+
'params-change': RouteParams;
|
|
1414
|
+
/** A new analysis was attached to (or replaced on) a routes entry. */
|
|
1415
|
+
'analysis-added': {
|
|
1416
|
+
entryId: string;
|
|
1417
|
+
analysis: RoutesAnalysis;
|
|
1418
|
+
};
|
|
1419
|
+
/** Set of routes entries currently rendered on the map changed (multi-show under `multiple`). */
|
|
1420
|
+
'shown-change': ReadonlySet<string>;
|
|
1421
|
+
/** Display policy switched between `single` and `multiple`. */
|
|
1422
|
+
'mode-change': EntryMode;
|
|
1423
|
+
};
|
|
1424
|
+
|
|
1425
|
+
/**
|
|
1426
|
+
* State slice that owns a set of "entries" (routes, ranges) where each entry can be hidden
|
|
1427
|
+
* individually by id and the slice exposes the currently-shown set. Implemented by
|
|
1428
|
+
* {@link RoutingState} and {@link RangeState}; consumed by helpers that need to hide
|
|
1429
|
+
* previously-shown entries before rendering a new one (see `hidePreviousShownEntries`).
|
|
1430
|
+
*
|
|
1431
|
+
* Not implemented by {@link PlacesState}, which uses a wider per-entry marker-type model
|
|
1432
|
+
* (`removeShownEntries(ids)` rather than `hideEntry(id)`).
|
|
1433
|
+
*
|
|
1434
|
+
* @group Agent Toolkit
|
|
1435
|
+
*/
|
|
1436
|
+
declare interface ShownEntriesSlice extends StateSlice {
|
|
1437
|
+
readonly entryMode: EntryMode;
|
|
1438
|
+
readonly shownEntryIds: ReadonlySet<string>;
|
|
1439
|
+
hideEntry(entryId: string): Promise<void>;
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1442
|
+
/**
|
|
1443
|
+
* Compact snapshot of the user-visible parts of `ToolState`. Designed to be diffable: every field
|
|
1444
|
+
* is serialisable to JSON and stable for `===` comparison when the underlying state hasn't changed.
|
|
1445
|
+
*
|
|
1446
|
+
* @group Agent Toolkit
|
|
1447
|
+
*/
|
|
1448
|
+
export declare type StateDigest = {
|
|
1449
|
+
places: {
|
|
1450
|
+
/** Entry ids currently rendered as individual pins, sorted ascending. */
|
|
1451
|
+
shownAsPin: string[];
|
|
1452
|
+
/** Entry ids currently rendered as base-map POIs, sorted ascending. */
|
|
1453
|
+
shownAsBaseMap: string[];
|
|
1454
|
+
/** Display policy in force on the slice — `multiple` (default) or `single`. */
|
|
1455
|
+
entryMode: EntryMode;
|
|
1456
|
+
};
|
|
1457
|
+
routes: {
|
|
1458
|
+
/** Routes-entry ids currently drawn on the map, sorted ascending. */
|
|
1459
|
+
shown: string[];
|
|
1460
|
+
/** Display policy in force on the slice — `multiple` (default) or `single`. */
|
|
1461
|
+
entryMode: EntryMode;
|
|
1462
|
+
};
|
|
1463
|
+
ranges: {
|
|
1464
|
+
/** Range-entry ids currently drawn on the map, sorted ascending. */
|
|
1465
|
+
shown: string[];
|
|
1466
|
+
/** Display policy in force on the slice — `multiple` (default) or `single`. */
|
|
1467
|
+
entryMode: EntryMode;
|
|
1468
|
+
};
|
|
1469
|
+
traffic: {
|
|
1470
|
+
/** Whether a TrafficAreaAnalytics visualization is active. */
|
|
1471
|
+
analyticsActive: boolean;
|
|
1472
|
+
};
|
|
1473
|
+
incidents: {
|
|
1474
|
+
/** Traffic-incidents entry ids currently rendered on the map, sorted ascending. */
|
|
1475
|
+
shown: string[];
|
|
1476
|
+
/** Entry ids currently being polled by the per-entry network monitor, sorted ascending. */
|
|
1477
|
+
monitored: string[];
|
|
1478
|
+
/** Display policy in force on the slice — `multiple` (default) or `single`. */
|
|
1479
|
+
entryMode: EntryMode;
|
|
1480
|
+
};
|
|
1481
|
+
};
|
|
1482
|
+
|
|
1483
|
+
/**
|
|
1484
|
+
* @module agent-toolkit-state
|
|
1485
|
+
*
|
|
1486
|
+
* Tiny typed event emitter used by every state slice (PlacesState, RoutingState, ...) to notify
|
|
1487
|
+
* subscribers when their internals change. The shape mirrors the SDK's `ModuleEvents` API
|
|
1488
|
+
* (`on(type, handler) => unsubscribe`, `off(type)`) so consumers see one consistent pattern across
|
|
1489
|
+
* the SDK and the agent toolkit. Designed to plug straight into React's `useSyncExternalStore`.
|
|
1490
|
+
*
|
|
1491
|
+
* @group Agent Toolkit
|
|
1492
|
+
*/
|
|
1493
|
+
/**
|
|
1494
|
+
* Generic typed event bus. The `EventMap` parameter declares the set of event names this emitter
|
|
1495
|
+
* supports along with each event's payload type — `on` and `emit` are then strongly typed against it.
|
|
1496
|
+
*
|
|
1497
|
+
* Usage from outside the slice (subscribe-only):
|
|
1498
|
+
* ```ts
|
|
1499
|
+
* const unsub = state.places.events.on('entries-change', (entries) => render(entries));
|
|
1500
|
+
* // ...
|
|
1501
|
+
* unsub();
|
|
1502
|
+
* ```
|
|
1503
|
+
*
|
|
1504
|
+
* @group Agent Toolkit
|
|
1505
|
+
*/
|
|
1506
|
+
declare class StateEvents<EventMap extends Record<string, unknown>> {
|
|
1507
|
+
private readonly handlers;
|
|
1508
|
+
/**
|
|
1509
|
+
* Subscribe to an event. Returns an unsubscribe function that removes only this handler.
|
|
1510
|
+
*/
|
|
1511
|
+
on<K extends keyof EventMap>(type: K, handler: (payload: EventMap[K]) => void): () => void;
|
|
1512
|
+
/** Remove all handlers for a given event type. Use the unsubscribe from `on` for single-handler removal. */
|
|
1513
|
+
off<K extends keyof EventMap>(type: K): void;
|
|
1514
|
+
/* Excluded from this release type: emit */
|
|
1515
|
+
/** Drop every handler for every type. Used by slice `reset()` to detach lingering listeners. */
|
|
1516
|
+
clear(): void;
|
|
1517
|
+
}
|
|
1518
|
+
|
|
592
1519
|
/**
|
|
593
1520
|
* Common interface for state slices. Implement `reset()` to participate
|
|
594
1521
|
* in cleanup when `destroy()` is called on the agent.
|
|
@@ -609,6 +1536,30 @@ export declare interface StateSlice {
|
|
|
609
1536
|
*/
|
|
610
1537
|
export declare const TOOL_NAMES: ToolName[];
|
|
611
1538
|
|
|
1539
|
+
/**
|
|
1540
|
+
* 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.
|
|
1543
|
+
*
|
|
1544
|
+
* @group Agent Toolkit
|
|
1545
|
+
*/
|
|
1546
|
+
export declare type ToolBuildOptions = {
|
|
1547
|
+
/** Active feature flags. */
|
|
1548
|
+
featureFlags?: FeatureFlags;
|
|
1549
|
+
};
|
|
1550
|
+
|
|
1551
|
+
/**
|
|
1552
|
+
* A registered tool definition: either a static {@link ToolEntry} or a
|
|
1553
|
+
* {@link ToolEntryBuilder} that builds one from {@link ToolBuildOptions} at
|
|
1554
|
+
* agent-creation time. Used wherever the tool registry, resolver, and
|
|
1555
|
+
* setup pipeline accept either form interchangeably.
|
|
1556
|
+
*
|
|
1557
|
+
* @typeParam S - The ToolState shape this tool requires. Default: base `ToolState`.
|
|
1558
|
+
*
|
|
1559
|
+
* @group Agent Toolkit
|
|
1560
|
+
*/
|
|
1561
|
+
export declare type ToolDefinition<S extends ToolState = ToolState> = ToolEntry<S> | ToolEntryBuilder<S>;
|
|
1562
|
+
|
|
612
1563
|
/**
|
|
613
1564
|
* A tool definition — the universal format for both built-in and third-party tools.
|
|
614
1565
|
* Combines execution (inputSchema + execute) with classifier metadata.
|
|
@@ -640,6 +1591,17 @@ export declare type ToolEntry<S extends ToolState = ToolState> = {
|
|
|
640
1591
|
dependsOn?: string[];
|
|
641
1592
|
};
|
|
642
1593
|
|
|
1594
|
+
/**
|
|
1595
|
+
* A builder that produces a {@link ToolEntry} from {@link ToolBuildOptions}.
|
|
1596
|
+
* Use this when a tool's metadata, schema, or executor depends on options
|
|
1597
|
+
* resolved at agent-creation time (e.g. feature flags).
|
|
1598
|
+
*
|
|
1599
|
+
* @typeParam S - The ToolState shape this tool requires. Default: base `ToolState`.
|
|
1600
|
+
*
|
|
1601
|
+
* @group Agent Toolkit
|
|
1602
|
+
*/
|
|
1603
|
+
export declare type ToolEntryBuilder<S extends ToolState = ToolState> = (options: ToolBuildOptions) => ToolEntry<S>;
|
|
1604
|
+
|
|
643
1605
|
/**
|
|
644
1606
|
* Metadata for an agent toolkit tool.
|
|
645
1607
|
*
|
|
@@ -691,7 +1653,7 @@ export declare type ToolNameHint = ToolName | (string & {});
|
|
|
691
1653
|
* function createMyTool(state: ToolState) {
|
|
692
1654
|
* return tool({
|
|
693
1655
|
* execute: async () => {
|
|
694
|
-
* const
|
|
1656
|
+
* const pins = await state.places.getPinPlacesModule();
|
|
695
1657
|
* state.routing.currentRoutes; // most recent routes
|
|
696
1658
|
* state.baseMap.mapLibreMap; // MapLibre instance
|
|
697
1659
|
* }
|
|
@@ -700,7 +1662,7 @@ export declare type ToolNameHint = ToolName | (string & {});
|
|
|
700
1662
|
* ```
|
|
701
1663
|
*/
|
|
702
1664
|
export declare type ToolState = {
|
|
703
|
-
/**
|
|
1665
|
+
/** Places layer: PlacesModule plus an append-only search history. */
|
|
704
1666
|
places: PlacesState;
|
|
705
1667
|
/** Map POI layer: visibility, filtering, and category management. */
|
|
706
1668
|
mapPOIs: MapPOIsState;
|
|
@@ -708,36 +1670,335 @@ export declare type ToolState = {
|
|
|
708
1670
|
routing: RoutingState;
|
|
709
1671
|
/** Base map display: style, language, viewport, layers, and hillshade. */
|
|
710
1672
|
baseMap: BaseMapState;
|
|
711
|
-
/** Traffic flow
|
|
712
|
-
|
|
1673
|
+
/** Traffic tile overlays: flow tiles + incident overlay tiles. */
|
|
1674
|
+
trafficTiles: TrafficTilesState;
|
|
1675
|
+
/** Traffic area analytics: aggregation module + last result + viz config. */
|
|
1676
|
+
trafficAreaAnalytics: TrafficAreaAnalyticsState;
|
|
1677
|
+
/** Traffic incidents: fetched entry history and per-entry rendering. */
|
|
1678
|
+
trafficIncidents: TrafficIncidentsState;
|
|
713
1679
|
/** Reachable range results: origin, budgets, and bbox summaries. */
|
|
714
1680
|
ranges: RangeState;
|
|
1681
|
+
/** Derived/custom polygon entries — output of processGeometries. */
|
|
1682
|
+
customGeometries: CustomGeometriesState;
|
|
715
1683
|
};
|
|
716
1684
|
|
|
717
1685
|
/**
|
|
718
|
-
* State for traffic
|
|
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}.
|
|
719
1689
|
*
|
|
720
1690
|
* @group Agent Toolkit
|
|
721
1691
|
*/
|
|
722
|
-
declare class
|
|
1692
|
+
declare class TrafficAreaAnalyticsState implements StateSlice {
|
|
723
1693
|
private readonly _ttMap;
|
|
724
|
-
private _trafficFlowModule?;
|
|
725
|
-
private _trafficIncidentsModule?;
|
|
726
1694
|
private _trafficAreaAnalyticsModule?;
|
|
727
1695
|
private _lastAreaAnalytics?;
|
|
728
1696
|
private _currentAnalyticsConfig?;
|
|
729
1697
|
private _configChangeUnsub?;
|
|
1698
|
+
/** Subscribe to state changes — see {@link TrafficAreaAnalyticsStateEvents}. */
|
|
1699
|
+
readonly events: StateEvents<TrafficAreaAnalyticsStateEvents>;
|
|
730
1700
|
constructor(_ttMap: TomTomMap);
|
|
731
|
-
getTrafficFlowModule(): Promise<TrafficFlowModule>;
|
|
732
|
-
getTrafficIncidentsModule(): Promise<TrafficIncidentsModule>;
|
|
733
1701
|
getTrafficAreaAnalyticsModule(): Promise<TrafficAreaAnalyticsModule>;
|
|
734
1702
|
get trafficAreaAnalyticsModule(): TrafficAreaAnalyticsModule | undefined;
|
|
735
1703
|
get lastAreaAnalytics(): TrafficAreaAnalytics | undefined;
|
|
736
1704
|
setLastAreaAnalytics(result: TrafficAreaAnalytics): void;
|
|
737
1705
|
/** Current visualization config, updated by module configChange events. */
|
|
738
1706
|
get currentAnalyticsConfig(): TrafficAreaAnalyticsConfig | undefined;
|
|
739
|
-
|
|
740
|
-
|
|
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;
|
|
1714
|
+
reset(): void;
|
|
1715
|
+
}
|
|
1716
|
+
|
|
1717
|
+
/**
|
|
1718
|
+
* Events fired by {@link TrafficAreaAnalyticsState}. Subscribe via
|
|
1719
|
+
* `state.trafficAreaAnalytics.events.on(type, handler)`.
|
|
1720
|
+
*
|
|
1721
|
+
* @group Agent Toolkit
|
|
1722
|
+
*/
|
|
1723
|
+
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;
|
|
1728
|
+
};
|
|
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;
|
|
1733
|
+
};
|
|
1734
|
+
|
|
1735
|
+
declare type TrafficIncidentsEntry = {
|
|
1736
|
+
id: string;
|
|
1737
|
+
timestamp: number;
|
|
1738
|
+
label: string;
|
|
1739
|
+
data: TrafficIncident[];
|
|
1740
|
+
/**
|
|
1741
|
+
* The captured query that produced this entry. Replayed by the monitor on each tick so
|
|
1742
|
+
* polling stays in the same slice the entry was loaded with. Reuses the loader's own
|
|
1743
|
+
* params shape; the entry stores a resolved {@link BBox} tuple in `bbox` (the loader
|
|
1744
|
+
* normalises any GeoJSON value before handing the params off).
|
|
1745
|
+
*/
|
|
1746
|
+
params: TrafficIncidentDetailsByBBoxParams & {
|
|
1747
|
+
bbox: BBox;
|
|
1748
|
+
};
|
|
1749
|
+
/**
|
|
1750
|
+
* Per-entry analysis registry: owns re-executing specs *and* their results.
|
|
1751
|
+
* Lazy-created on first {@link TrafficIncidentsState.setAnalysisSpec} or
|
|
1752
|
+
* {@link TrafficIncidentsState.addAnalysisToEntry}.
|
|
1753
|
+
*/
|
|
1754
|
+
_analyses?: IncidentsAnalyses;
|
|
1755
|
+
/**
|
|
1756
|
+
* Per-entry incident-details module. Each entry owns its own module so two areas can be
|
|
1757
|
+
* rendered on the map at the same time without sharing a single source. Lazy-initialised
|
|
1758
|
+
* via `TrafficIncidentsState.getEntryModule` — undefined until first show. Subscribe to
|
|
1759
|
+
* clicks via `module.events.on('click', ...)` once retrieved.
|
|
1760
|
+
*/
|
|
1761
|
+
_module?: TrafficIncidentOverlayModule;
|
|
1762
|
+
/** True while this entry is currently rendered on the map. */
|
|
1763
|
+
_shown?: boolean;
|
|
1764
|
+
/**
|
|
1765
|
+
* Focused subset on this entry — the agent's `focusIds` write-side. Drives the dim/highlight
|
|
1766
|
+
* affordance on `_module` and feeds `focusedFeatures(entryId)` for stepping through.
|
|
1767
|
+
*/
|
|
1768
|
+
_focus?: {
|
|
1769
|
+
ids: Set<string>;
|
|
1770
|
+
reason?: string;
|
|
1771
|
+
};
|
|
1772
|
+
/**
|
|
1773
|
+
* Per-entry polling loop. Lazy-created on first {@link TrafficIncidentsState.startMonitoring}
|
|
1774
|
+
* call; reused across stop/start cycles. Owns timer, status, error, captured area.
|
|
1775
|
+
*/
|
|
1776
|
+
_monitor?: IncidentMonitor;
|
|
1777
|
+
/**
|
|
1778
|
+
* Monotonic counter incremented on every {@link TrafficIncidentsState.replaceEntryData}
|
|
1779
|
+
* call. Used to detect out-of-order ticks: if a slow `module.show()` from an earlier
|
|
1780
|
+
* tick resolves after a newer tick has already overwritten `data`, the late path bails
|
|
1781
|
+
* before reapplying focus / replaying analyses.
|
|
1782
|
+
*/
|
|
1783
|
+
_tick?: number;
|
|
1784
|
+
};
|
|
1785
|
+
|
|
1786
|
+
/**
|
|
1787
|
+
* State for traffic incidents: entry history and map rendering via per-entry
|
|
1788
|
+
* TrafficIncidentOverlayModule. Each entry can be a separate area; under the default
|
|
1789
|
+
* `multiple` mode several entries can render at once.
|
|
1790
|
+
*
|
|
1791
|
+
* Each entry owns its own module (lazy-init on first show) plus an optional per-entry
|
|
1792
|
+
* background monitor. Subscribe to changes via `events.on('...')`.
|
|
1793
|
+
*
|
|
1794
|
+
* @group Agent Toolkit
|
|
1795
|
+
*/
|
|
1796
|
+
declare class TrafficIncidentsState implements StateSlice {
|
|
1797
|
+
private readonly _ttMap;
|
|
1798
|
+
private _entries;
|
|
1799
|
+
private _entryMode;
|
|
1800
|
+
/** Subscribe to state changes — see {@link TrafficIncidentsStateEvents}. */
|
|
1801
|
+
readonly events: StateEvents<TrafficIncidentsStateEvents>;
|
|
1802
|
+
constructor(_ttMap: TomTomMap);
|
|
1803
|
+
get entries(): readonly TrafficIncidentsEntry[];
|
|
1804
|
+
/**
|
|
1805
|
+
* Display policy: `multiple` (default) keeps every history entry available to render
|
|
1806
|
+
* simultaneously; `single` enforces "at most one entry on the map at a time" and trims
|
|
1807
|
+
* the history down to the latest entry whenever it's set.
|
|
1808
|
+
*/
|
|
1809
|
+
get entryMode(): EntryMode;
|
|
1810
|
+
/**
|
|
1811
|
+
* Switch the display policy. When moving from `multiple` → `single` we hide every entry
|
|
1812
|
+
* older than the latest, drop them from history, and emit `entries-change`. No-op when the
|
|
1813
|
+
* mode hasn't changed.
|
|
1814
|
+
*/
|
|
1815
|
+
setEntryMode(mode: EntryMode): Promise<void>;
|
|
1816
|
+
/** Set of entries currently rendered on the map. */
|
|
1817
|
+
get shownEntryIds(): ReadonlySet<TrafficIncidentsEntry['id']>;
|
|
1818
|
+
/**
|
|
1819
|
+
* Append a new entry to the history. Under `single` mode the new entry replaces every
|
|
1820
|
+
* older one (and tears their modules + monitors down). `sampledAt` is the moment the
|
|
1821
|
+
* data was captured — pass one canonical value per "moment" so future joins (entry
|
|
1822
|
+
* data ↔ derived analyses) are byte-equal. Returns the assigned id.
|
|
1823
|
+
*/
|
|
1824
|
+
addIncidentsEntry(data: TrafficIncident[], params: TrafficIncidentDetailsByBBoxParams & {
|
|
1825
|
+
bbox: BBox;
|
|
1826
|
+
}, label: string, sampledAt: number, explicitId?: string): string;
|
|
1827
|
+
/**
|
|
1828
|
+
* Replace an entry's data in place and repaint its module without moving the camera.
|
|
1829
|
+
* Used by the per-entry monitor tick so incident geometries and any open detail
|
|
1830
|
+
* panel stay in sync with the freshest snapshot. `sampledAt` is the canonical moment
|
|
1831
|
+
* for this update — propagated to the entry timestamp and to every analysis the
|
|
1832
|
+
* registry replays, so all derived data shares one tick. Returns true on success,
|
|
1833
|
+
* false when the entry is unknown.
|
|
1834
|
+
*/
|
|
1835
|
+
replaceEntryData(entryId: TrafficIncidentsEntry['id'], data: TrafficIncident[], sampledAt: number): Promise<boolean>;
|
|
1836
|
+
/**
|
|
1837
|
+
* Lazy-init and return the entry's TrafficIncidentOverlayModule. Consumers subscribe to
|
|
1838
|
+
* clicks directly on the returned module via `module.events.on('click', ...)`; use
|
|
1839
|
+
* `module.distinctIncidents(features)` inside the handler if a stacked-click count is
|
|
1840
|
+
* needed. Throws on unknown entry id.
|
|
1841
|
+
*/
|
|
1842
|
+
getEntryModule(entryId: TrafficIncidentsEntry['id']): Promise<TrafficIncidentOverlayModule>;
|
|
1843
|
+
/**
|
|
1844
|
+
* Render an entry on the map. Lazy-inits its module, pushes the entry's incidents, and
|
|
1845
|
+
* (when `fitBounds` is true) fits the camera to the entry's bbox. Emits `shown-change`
|
|
1846
|
+
* once the entry transitions to shown.
|
|
1847
|
+
*/
|
|
1848
|
+
showEntry(entryId: TrafficIncidentsEntry['id'], fitBounds?: boolean): Promise<void>;
|
|
1849
|
+
/**
|
|
1850
|
+
* Hide an entry — clears its module + drops focus. The module reference stays on the
|
|
1851
|
+
* entry for cheap re-show. No-op when the entry is unknown or already hidden.
|
|
1852
|
+
*/
|
|
1853
|
+
hideEntry(entryId: TrafficIncidentsEntry['id']): Promise<void>;
|
|
1854
|
+
/**
|
|
1855
|
+
* Drop an entry from history. Hides it from the map and stops its monitor if any.
|
|
1856
|
+
* Emits `entries-change` and, when the entry was shown, `shown-change`. No-op when the
|
|
1857
|
+
* id is unknown.
|
|
1858
|
+
*/
|
|
1859
|
+
removeEntry(entryId: TrafficIncidentsEntry['id']): Promise<void>;
|
|
1860
|
+
/**
|
|
1861
|
+
* Attach an analysis result to an existing entry. Names are unique within a single
|
|
1862
|
+
* entry — adding one with an existing name replaces it. Returns true on success, false
|
|
1863
|
+
* if the entry doesn't exist. Lazy-creates the entry's {@link IncidentsAnalyses}.
|
|
1864
|
+
*/
|
|
1865
|
+
addAnalysisToEntry(entryId: TrafficIncidentsEntry['id'], analysis: IncidentsAnalysis): boolean;
|
|
1866
|
+
/**
|
|
1867
|
+
* Register (or replace) a re-executing analysis spec on its source entry. Names are unique
|
|
1868
|
+
* per entry — adding one with an existing name replaces it. Lazy-creates the entry's
|
|
1869
|
+
* {@link IncidentsAnalyses} on first call.
|
|
1870
|
+
*/
|
|
1871
|
+
setAnalysisSpec(spec: IncidentsAnalysisSpec): void;
|
|
1872
|
+
/** Remove a spec by name from every entry that carries it. */
|
|
1873
|
+
removeAnalysisSpec(name: string): void;
|
|
1874
|
+
/** Snapshot of an entry's focus subset, or null when no focus is active or the entry is unknown. */
|
|
1875
|
+
getFocus(entryId: TrafficIncidentsEntry['id']): IncidentFocus | null;
|
|
1876
|
+
/**
|
|
1877
|
+
* Set the focus subset on a specific entry. Filters ids against the entry's current
|
|
1878
|
+
* incidents (drops unknown ones) and pushes the result onto the entry's module.
|
|
1879
|
+
* Returns the kept count and any dropped ids.
|
|
1880
|
+
*/
|
|
1881
|
+
setFocus(entryId: TrafficIncidentsEntry['id'], ids: readonly string[], reason?: string): {
|
|
1882
|
+
focusedCount: number;
|
|
1883
|
+
droppedIds: string[];
|
|
1884
|
+
};
|
|
1885
|
+
clearFocus(entryId: TrafficIncidentsEntry['id']): void;
|
|
1886
|
+
/**
|
|
1887
|
+
* The focused incidents in the order passed to {@link setFocus}. Empty when no focus is
|
|
1888
|
+
* active on the entry or when the entry is unknown. Used by UI layers that step through
|
|
1889
|
+
* the focused subset (prev/next).
|
|
1890
|
+
*/
|
|
1891
|
+
focusedFeatures(entryId: TrafficIncidentsEntry['id']): TrafficIncident[];
|
|
1892
|
+
/**
|
|
1893
|
+
* Fly the camera to the i-th focused incident on an entry (0-based). Wraps out-of-range
|
|
1894
|
+
* indices so callers can pass raw prev/next counters. No-op when the entry has no active
|
|
1895
|
+
* focus. Line geometries fitBounds; points flyTo with a sensible zoom.
|
|
1896
|
+
*/
|
|
1897
|
+
navigateFocus(entryId: TrafficIncidentsEntry['id'], index: number): void;
|
|
1898
|
+
/**
|
|
1899
|
+
* Walk entries newest-first to find which one currently holds an incident with this id.
|
|
1900
|
+
* Useful for UI layers that hold an incident id without remembering which entry produced it.
|
|
1901
|
+
*/
|
|
1902
|
+
findEntryWithIncident(incidentId: string): TrafficIncidentsEntry | undefined;
|
|
1903
|
+
/**
|
|
1904
|
+
* Start polling for an entry. Lazy-creates an {@link IncidentMonitor}, wires its events
|
|
1905
|
+
* once, then delegates to {@link IncidentMonitor.start}. No-op when polling is already
|
|
1906
|
+
* running. Throws on unknown entry id.
|
|
1907
|
+
*/
|
|
1908
|
+
startMonitoring(entryId: TrafficIncidentsEntry['id'], area: MonitoredArea, deps: IncidentMonitorDeps, opts?: {
|
|
1909
|
+
intervalMs?: number;
|
|
1910
|
+
}): void;
|
|
1911
|
+
/** Stop polling. No-op when idle or unknown. */
|
|
1912
|
+
stopMonitoring(entryId: TrafficIncidentsEntry['id']): void;
|
|
1913
|
+
/**
|
|
1914
|
+
* True when the entry is *currently* being polled. A monitor stuck in
|
|
1915
|
+
* `stopped-error` returns false here so the start tool can report a truthful
|
|
1916
|
+
* `alreadyRunning` and a fresh `start` call actually re-arms the timer
|
|
1917
|
+
* instead of silently being treated as a no-op.
|
|
1918
|
+
*/
|
|
1919
|
+
isMonitored(entryId: TrafficIncidentsEntry['id']): boolean;
|
|
1920
|
+
private _createMonitorForEntry;
|
|
1921
|
+
private _requireEntry;
|
|
1922
|
+
private _uniqueEntryId;
|
|
1923
|
+
private _rerunRegisteredSpecs;
|
|
1924
|
+
private _teardownEntry;
|
|
1925
|
+
reset(): void;
|
|
1926
|
+
}
|
|
1927
|
+
|
|
1928
|
+
/**
|
|
1929
|
+
* Events fired by {@link TrafficIncidentsState}. Subscribe via
|
|
1930
|
+
* `state.trafficIncidents.events.on(type, handler)` — returns an unsubscribe function.
|
|
1931
|
+
*
|
|
1932
|
+
* @group Agent Toolkit
|
|
1933
|
+
*/
|
|
1934
|
+
declare type TrafficIncidentsStateEvents = {
|
|
1935
|
+
/** History changed — entry added, replaced, removed, or cleared via `reset()`. Payload: full entries snapshot. */
|
|
1936
|
+
'entries-change': readonly TrafficIncidentsEntry[];
|
|
1937
|
+
/** Set of entries currently rendered on the map changed. */
|
|
1938
|
+
'shown-change': ReadonlySet<TrafficIncidentsEntry['id']>;
|
|
1939
|
+
/**
|
|
1940
|
+
* A fresh analysis result landed on an entry. Fires when a spec is first
|
|
1941
|
+
* registered, when it is replaced under the same name, AND on every monitor-tick
|
|
1942
|
+
* replay — the event is intentionally agnostic about whether the spec is new
|
|
1943
|
+
* or recomputed; subscribers re-render off the latest result either way.
|
|
1944
|
+
*/
|
|
1945
|
+
'analysis-change': {
|
|
1946
|
+
entryId: TrafficIncidentsEntry['id'];
|
|
1947
|
+
analysis: IncidentsAnalysis;
|
|
1948
|
+
};
|
|
1949
|
+
/** Focus subset for an entry changed (or cleared, when `focus === null`). */
|
|
1950
|
+
'focus-change': {
|
|
1951
|
+
entryId: TrafficIncidentsEntry['id'];
|
|
1952
|
+
focus: IncidentFocus | null;
|
|
1953
|
+
};
|
|
1954
|
+
/** Display policy switched between `single` and `multiple`. */
|
|
1955
|
+
'mode-change': EntryMode;
|
|
1956
|
+
/** A monitored entry produced a fresh snapshot (per-tick). */
|
|
1957
|
+
'monitor-tick': {
|
|
1958
|
+
entryId: TrafficIncidentsEntry['id'];
|
|
1959
|
+
snap: IncidentSnapshot;
|
|
1960
|
+
};
|
|
1961
|
+
/** A monitored entry's poll failed — slice has cleared the timer. */
|
|
1962
|
+
'monitor-error': {
|
|
1963
|
+
entryId: TrafficIncidentsEntry['id'];
|
|
1964
|
+
error: string;
|
|
1965
|
+
};
|
|
1966
|
+
/**
|
|
1967
|
+
* Polling began on an entry (idle → running). Skipped when `startMonitoring`
|
|
1968
|
+
* was a no-op against an already-running monitor.
|
|
1969
|
+
*/
|
|
1970
|
+
'monitor-start': {
|
|
1971
|
+
entryId: TrafficIncidentsEntry['id'];
|
|
1972
|
+
};
|
|
1973
|
+
/**
|
|
1974
|
+
* Polling halted on an entry. `reason: 'manual'` covers explicit
|
|
1975
|
+
* `stopMonitoring` and entry teardown (remove / single-mode trim / reset).
|
|
1976
|
+
* `reason: 'error'` fires alongside `monitor-error` — error-only listeners
|
|
1977
|
+
* keep using `monitor-error`; lifecycle listeners can rely on this alone.
|
|
1978
|
+
*/
|
|
1979
|
+
'monitor-stop': {
|
|
1980
|
+
entryId: TrafficIncidentsEntry['id'];
|
|
1981
|
+
reason: 'manual' | 'error';
|
|
1982
|
+
};
|
|
1983
|
+
};
|
|
1984
|
+
|
|
1985
|
+
/**
|
|
1986
|
+
* State for traffic tile overlays — flow tiles and incident overlay tiles. These are
|
|
1987
|
+
* raster/tile layers that the user toggles on top of the base map; result caching and
|
|
1988
|
+
* per-result rendering for incident *features* lives in {@link TrafficIncidentsState},
|
|
1989
|
+
* and analytics aggregations in {@link TrafficAreaAnalyticsState}.
|
|
1990
|
+
*
|
|
1991
|
+
* @group Agent Toolkit
|
|
1992
|
+
*/
|
|
1993
|
+
declare class TrafficTilesState implements StateSlice {
|
|
1994
|
+
private readonly _ttMap;
|
|
1995
|
+
private _trafficFlowModule?;
|
|
1996
|
+
private _trafficIncidentsModule?;
|
|
1997
|
+
constructor(_ttMap: TomTomMap);
|
|
1998
|
+
getTrafficFlowModule(): Promise<TrafficFlowModule>;
|
|
1999
|
+
getTrafficIncidentsModule(): Promise<TrafficIncidentsModule>;
|
|
2000
|
+
get trafficFlowModule(): TrafficFlowModule | undefined;
|
|
2001
|
+
get trafficIncidentsModule(): TrafficIncidentsModule | undefined;
|
|
741
2002
|
reset(): void;
|
|
742
2003
|
}
|
|
743
2004
|
|