@tomtom-org/maps-sdk-plugin-agent-toolkit 0.12.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +4 -4
- package/README.md +16 -10
- package/THIRD_PARTY.txt +1 -1
- package/dist/THIRD_PARTY.txt +1 -1
- package/dist/index.d.ts +741 -743
- package/dist/index.es.js +1 -2
- package/dist/third-party.json +1 -1
- package/dist/{worker-libs-DWDQlHOr.js → worker-libs-CUm6Y1-t.js} +1 -2
- package/package.json +8 -7
- package/dist/index.es.js.map +0 -1
- package/dist/worker-libs-DWDQlHOr.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { LanguageModel, ModelMessage, PrepareStepFunction, ToolLoopAgent } from
|
|
|
10
10
|
type JobSpec = {
|
|
11
11
|
/** Ids of every entry this job reads. The engine re-runs the job when any of them changes. */
|
|
12
12
|
affectedEntryIds: readonly string[];
|
|
13
|
-
/** The recipe, opaque to the engine
|
|
13
|
+
/** The recipe, opaque to the engine and the single home of the code, compared on re-arm to detect change. */
|
|
14
14
|
code: string;
|
|
15
15
|
/** Whether the engine scans this job. A paused job (`false`) is retained but never run. */
|
|
16
16
|
active: boolean;
|
|
@@ -21,20 +21,20 @@ type JobSpec = {
|
|
|
21
21
|
};
|
|
22
22
|
/** A registered job, handed back to the owner as the reference linking a sink record to its recurrence. */
|
|
23
23
|
interface Job {
|
|
24
|
-
/** Ids of every entry this job reads (immutable
|
|
24
|
+
/** Ids of every entry this job reads (immutable, as a re-arm with different sources is a different job). */
|
|
25
25
|
readonly affectedEntryIds: readonly string[];
|
|
26
|
-
/** The recipe behind this job
|
|
26
|
+
/** The recipe behind this job, which a re-arm compares to decide whether to drop stale history. */
|
|
27
27
|
readonly code: string;
|
|
28
28
|
/** Whether the engine currently scans this job. */
|
|
29
29
|
readonly active: boolean;
|
|
30
|
-
/**
|
|
30
|
+
/** Pauses (`false`) or resumes (`true`) scanning. A paused job keeps its recipe for later promotion. */
|
|
31
31
|
setActive(active: boolean): void;
|
|
32
|
-
/**
|
|
32
|
+
/** Removes the job from the engine. The owner drops its stored reference. */
|
|
33
33
|
unregister(): void;
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
|
-
* Session-level recurrence engine
|
|
37
|
-
*
|
|
36
|
+
* Session-level recurrence engine, held on `ToolState` as `state.engine`, which the state factory
|
|
37
|
+
* constructs and wires. Owners ({@link Analyses}, {@link EventsState}) register jobs and keep the returned
|
|
38
38
|
* handles.
|
|
39
39
|
*
|
|
40
40
|
* @group Agent Toolkit
|
|
@@ -45,12 +45,12 @@ declare class JobEngine {
|
|
|
45
45
|
private scanning;
|
|
46
46
|
private scheduled;
|
|
47
47
|
private pending;
|
|
48
|
-
/**
|
|
48
|
+
/** Registers a job and returns its handle, which the owner stores as its reference to the recurrence. */
|
|
49
49
|
register(spec: JobSpec): Job;
|
|
50
50
|
/** @internal — called by {@link JobHandle.unregister}. */
|
|
51
51
|
drop(job: JobHandle): void;
|
|
52
52
|
/**
|
|
53
|
-
*
|
|
53
|
+
* Subscribes the scan to every input slice's `entries-change`, exactly once per session. The state
|
|
54
54
|
* factory calls this at construction (it holds the slices), so every `ToolState` gets a live engine
|
|
55
55
|
* without the job builders having to wire lazily.
|
|
56
56
|
*/
|
|
@@ -61,7 +61,7 @@ declare class JobEngine {
|
|
|
61
61
|
private hasActiveJob;
|
|
62
62
|
private scheduleScan;
|
|
63
63
|
private runScan;
|
|
64
|
-
/**
|
|
64
|
+
/** Drops every job. `destroyState` calls it automatically (duck-typed `reset`). Subscriptions persist
|
|
65
65
|
* (harmless without jobs), mirroring the one-shot `wired` guard. */
|
|
66
66
|
reset(): void;
|
|
67
67
|
}
|
|
@@ -80,8 +80,8 @@ declare class JobHandle implements Job {
|
|
|
80
80
|
//#region src/tools/shared/sandbox-code.d.ts
|
|
81
81
|
export type AnalysisOutputFormat = 'json' | 'chart';
|
|
82
82
|
/**
|
|
83
|
-
* Compact sandbox-code blurb shared by
|
|
84
|
-
* `
|
|
83
|
+
* Compact sandbox-code blurb shared by every code-generation tool, through
|
|
84
|
+
* `buildSandboxToolsDoc`. Keeps the
|
|
85
85
|
* "what's in scope / what's forbidden" rules short and consistent across all
|
|
86
86
|
* code-generation tools so the LLM is prompted the same way each time. Pass
|
|
87
87
|
* the names of the injected identifiers (the params the AsyncFunction body
|
|
@@ -118,11 +118,11 @@ export declare const ANALYSE_OUTPUT_FORMAT_DESCRIPTION: string;
|
|
|
118
118
|
*/
|
|
119
119
|
export declare const buildAnalyseReturnPrompt: (jsonExamples: string, chartLabelExample?: string) => string;
|
|
120
120
|
/**
|
|
121
|
-
* Validates the value returned by
|
|
121
|
+
* Validates the value returned by sandboxed code: rejects
|
|
122
122
|
* `undefined`, JSON-normalizes via `toJsonSafe`, and — when
|
|
123
123
|
* `outputFormat: "chart"` — checks the result is a Chart.js
|
|
124
|
-
* `ChartConfiguration`. Centralises the contract shared by
|
|
125
|
-
*
|
|
124
|
+
* `ChartConfiguration`. Centralises the contract shared by `analyseData` and every
|
|
125
|
+
* recurring re-run (`sandbox-replay.ts`: monitored analyses, trackers, `clusterIncidents` code).
|
|
126
126
|
*
|
|
127
127
|
* @ignore
|
|
128
128
|
*/
|
|
@@ -137,11 +137,11 @@ export declare const sandboxedGlobalShadows: readonly ["fetch", "XMLHttpRequest"
|
|
|
137
137
|
export declare const WORKER_PROVIDED_PARAMS: readonly ["turf", "h3", "routeUtils", "log", "cluster"];
|
|
138
138
|
/**
|
|
139
139
|
* Pluggable strategy for executing sandbox code. The default
|
|
140
|
-
* {@link mainThreadExecutor} compiles
|
|
141
|
-
* executor
|
|
140
|
+
* {@link mainThreadExecutor} compiles and runs in the host realm. An alternative
|
|
141
|
+
* executor, such as the iframe-worker one, can run the same code in a locked-down
|
|
142
142
|
* realm off the main thread while honouring this exact contract.
|
|
143
143
|
*
|
|
144
|
-
* `run` MUST resolve to `{ value }` or `{ error }` and never reject
|
|
144
|
+
* `run` MUST resolve to `{ value }` or `{ error }` and never reject. Execution
|
|
145
145
|
* failures are reported as `{ error }` via {@link formatSandboxExecutionError}.
|
|
146
146
|
*
|
|
147
147
|
* @group Agent Toolkit
|
|
@@ -152,7 +152,7 @@ export type SandboxExecutor = {
|
|
|
152
152
|
} | {
|
|
153
153
|
error: string;
|
|
154
154
|
}>;
|
|
155
|
-
/**
|
|
155
|
+
/** Releases any held resources (iframe / worker). No-op for the main-thread executor. */
|
|
156
156
|
destroy?(): void;
|
|
157
157
|
};
|
|
158
158
|
/**
|
|
@@ -168,7 +168,7 @@ export declare const mainThreadExecutor: SandboxExecutor;
|
|
|
168
168
|
* Compiles `code` as the body of an `async` function that takes the named
|
|
169
169
|
* `paramNames`, sanitises injected redeclarations, runs it with `args`, and
|
|
170
170
|
* returns either `{ value }` or `{ error }`. Centralises the AsyncFunction
|
|
171
|
-
* dance shared by every sandbox-running tool (
|
|
171
|
+
* dance shared by every sandbox-running tool (analyseData, processData, createTracker, clusterIncidents) so
|
|
172
172
|
* each callsite only owns its inputs and result handling.
|
|
173
173
|
*
|
|
174
174
|
* In addition to the caller's `paramNames`, a fixed set of network / storage /
|
|
@@ -207,18 +207,18 @@ export declare const formatSandboxExecutionError: (verb: string, error: unknown)
|
|
|
207
207
|
/**
|
|
208
208
|
* @module agent-toolkit-state
|
|
209
209
|
*
|
|
210
|
-
*
|
|
211
|
-
* subscribers when
|
|
212
|
-
* (`on(type, handler) => unsubscribe`, `off(type)`) so consumers see one consistent pattern across
|
|
213
|
-
* the SDK and the agent toolkit.
|
|
210
|
+
* A tiny typed event emitter that every state slice (PlacesState, RoutingState, ...) uses to notify
|
|
211
|
+
* subscribers when its internals change. Its shape mirrors the SDK's `ModuleEvents` API
|
|
212
|
+
* (`on(type, handler) => unsubscribe`, `off(type)`), so consumers see one consistent pattern across
|
|
213
|
+
* the SDK and the agent toolkit. It plugs straight into React's `useSyncExternalStore`.
|
|
214
214
|
*
|
|
215
215
|
* @group Agent Toolkit
|
|
216
216
|
*/
|
|
217
217
|
/**
|
|
218
|
-
*
|
|
219
|
-
*
|
|
218
|
+
* A generic typed event bus. The `EventMap` parameter declares the event names this emitter supports
|
|
219
|
+
* and each event's payload type, and `on` and `emit` are strongly typed against it.
|
|
220
220
|
*
|
|
221
|
-
*
|
|
221
|
+
* Outside the slice, you can only subscribe:
|
|
222
222
|
* ```ts
|
|
223
223
|
* const unsub = state.places.events.on('entries-change', ({ entries }) => render(entries));
|
|
224
224
|
* // ...
|
|
@@ -230,10 +230,10 @@ export declare const formatSandboxExecutionError: (verb: string, error: unknown)
|
|
|
230
230
|
declare class StateEvents<EventMap extends Record<string, unknown>> {
|
|
231
231
|
private readonly handlers;
|
|
232
232
|
/**
|
|
233
|
-
*
|
|
233
|
+
* Subscribes to an event and returns an unsubscribe function that removes only this handler.
|
|
234
234
|
*/
|
|
235
235
|
on<K extends keyof EventMap>(type: K, handler: (payload: EventMap[K]) => void): () => void;
|
|
236
|
-
/**
|
|
236
|
+
/** Removes all handlers for an event type. To remove one handler, call the unsubscribe `on` returns. */
|
|
237
237
|
off<K extends keyof EventMap>(type: K): void;
|
|
238
238
|
/**
|
|
239
239
|
* Fire an event. Internal — only the owning slice should call this. We don't make it `protected`
|
|
@@ -243,7 +243,7 @@ declare class StateEvents<EventMap extends Record<string, unknown>> {
|
|
|
243
243
|
* @internal
|
|
244
244
|
*/
|
|
245
245
|
emit<K extends keyof EventMap>(type: K, payload: EventMap[K]): void;
|
|
246
|
-
/**
|
|
246
|
+
/** Removes every handler for every type. A slice's `reset()` calls it to detach lingering listeners. */
|
|
247
247
|
clear(): void;
|
|
248
248
|
}
|
|
249
249
|
//#endregion
|
|
@@ -268,12 +268,12 @@ type EntryAnalysis = {
|
|
|
268
268
|
data: unknown;
|
|
269
269
|
};
|
|
270
270
|
/**
|
|
271
|
-
* One analysis tracked by the session-level {@link Analyses} registry
|
|
272
|
-
* `analyseData` analysis, one-shot or monitored, across every entry kind.
|
|
273
|
-
* the bounded result `history`. The recipe (`code` / `inputs`) and recurrence are NOT
|
|
274
|
-
* the analysis's {@link Job} (see `_jobs`). `affectedEntryIds` is the per-entry
|
|
275
|
-
* ({@link Analyses.getAnalysesForEntry})
|
|
276
|
-
* is the current result
|
|
271
|
+
* One analysis tracked by the session-level {@link Analyses} registry, the single home for every
|
|
272
|
+
* `analyseData` analysis, one-shot or monitored, across every entry kind. It is pure sink state,
|
|
273
|
+
* metadata plus the bounded result `history`. The recipe (`code` / `inputs`) and recurrence are NOT
|
|
274
|
+
* here. They live on the analysis's {@link Job} (see `_jobs`). `affectedEntryIds` is the per-entry
|
|
275
|
+
* lookup key ({@link Analyses.getAnalysesForEntry}). `history` is the result timeline (oldest first),
|
|
276
|
+
* whose latest is the current result, threaded back into the sandbox code as `previous`.
|
|
277
277
|
*
|
|
278
278
|
* @group Agent Toolkit
|
|
279
279
|
*/
|
|
@@ -289,8 +289,8 @@ type AnalysisRecord = {
|
|
|
289
289
|
history: EntryAnalysis[];
|
|
290
290
|
};
|
|
291
291
|
/**
|
|
292
|
-
* {@link Analyses.register}
|
|
293
|
-
* results land) and no recipe (that lives on the {@link Job}).
|
|
292
|
+
* The input of {@link Analyses.register}, the record's metadata. It has no `history` (the registry
|
|
293
|
+
* builds that as results land) and no recipe (that lives on the {@link Job}).
|
|
294
294
|
*
|
|
295
295
|
* @group Agent Toolkit
|
|
296
296
|
*/
|
|
@@ -311,15 +311,15 @@ type AnalysesEvents = {
|
|
|
311
311
|
};
|
|
312
312
|
};
|
|
313
313
|
/**
|
|
314
|
-
*
|
|
315
|
-
* `_analyses` stores.
|
|
316
|
-
* its own bounded result history. Entries carry no analysis state
|
|
317
|
-
* {@link getAnalysesForEntry}.
|
|
314
|
+
* The session-level registry of EVERY analysis, the single source of truth that replaces the per-entry
|
|
315
|
+
* `_analyses` stores. It holds one {@link AnalysisRecord} per analysis (keyed by `analysisId`), each
|
|
316
|
+
* with its own bounded result history. Entries carry no analysis state. Per-entry views call
|
|
317
|
+
* {@link getAnalysesForEntry}. `ToolState` holds it as `state.analyses`.
|
|
318
318
|
*
|
|
319
|
-
*
|
|
320
|
-
* registry keeps each monitored analysis's {@link Job} handle in `_jobs` (keyed by `analysisId`)
|
|
321
|
-
* can pause
|
|
322
|
-
* job for later promotion.
|
|
319
|
+
* It is a pure sink of metadata and result history. The recurrence lives on the {@link JobEngine}.
|
|
320
|
+
* This registry keeps each monitored analysis's {@link Job} handle in `_jobs` (keyed by `analysisId`)
|
|
321
|
+
* so it can pause or resume it ({@link job}) or compare its `code` on re-arm. A one-shot analysis keeps
|
|
322
|
+
* a paused job for later promotion.
|
|
323
323
|
*
|
|
324
324
|
* @group Agent Toolkit
|
|
325
325
|
*/
|
|
@@ -327,36 +327,37 @@ declare class Analyses {
|
|
|
327
327
|
private readonly _records;
|
|
328
328
|
/** analysisId → the {@link Job} backing it (one-shot = paused). The reference linking record to engine. */
|
|
329
329
|
private readonly _jobs;
|
|
330
|
-
/**
|
|
330
|
+
/** The {@link AnalysesEvents} emitter, fired whenever a result is attached or recomputed. */
|
|
331
331
|
readonly events: StateEvents<AnalysesEvents>;
|
|
332
332
|
/**
|
|
333
|
-
*
|
|
334
|
-
*
|
|
335
|
-
* history
|
|
333
|
+
* Inserts or replaces a record's metadata, NOT its result (use {@link attachResult}) or its recipe,
|
|
334
|
+
* which lives on the {@link Job}. Re-registering an existing `analysisId` preserves its result
|
|
335
|
+
* history. Callers drop stale history explicitly with {@link resetHistory} when the recipe changes.
|
|
336
336
|
*/
|
|
337
337
|
register(input: AnalysisRegistration): void;
|
|
338
|
-
/**
|
|
338
|
+
/** Stores the {@link Job} backing an analysis, the reference linking this record to the engine. */
|
|
339
339
|
setJob(analysisId: string, job: Job): void;
|
|
340
340
|
/** The {@link Job} backing an analysis, if monitored or a retained one-shot. */
|
|
341
341
|
job(analysisId: string): Job | undefined;
|
|
342
|
-
/**
|
|
342
|
+
/** Drops an analysis's result history. A re-arm calls it when the recipe changed (stale `previous`). */
|
|
343
343
|
resetHistory(analysisId: string): void;
|
|
344
344
|
/**
|
|
345
|
-
*
|
|
345
|
+
* Appends a result to a record's timeline, evicting the oldest when the per-analysis cap is hit. A
|
|
346
346
|
* same-timestamp re-run (an id-stability re-read of an unchanged snapshot) overwrites the last entry
|
|
347
|
-
* rather than duplicating it.
|
|
347
|
+
* rather than duplicating it. It emits `analysis-change`, unless the `analysisId` is unknown
|
|
348
|
+
* (a no-op).
|
|
348
349
|
*/
|
|
349
350
|
attachResult(analysisId: string, result: EntryAnalysis): void;
|
|
350
351
|
/**
|
|
351
|
-
*
|
|
352
|
-
*
|
|
353
|
-
*
|
|
352
|
+
* Returns the latest result of every analysis attached to `entryId`, in registration order,
|
|
353
|
+
* replacing the old per-entry `_analyses.results`. It scans records linearly, fine at session scale
|
|
354
|
+
* (one record per distinct analyseData name+sources, plus one per clustered incidents entry).
|
|
354
355
|
*/
|
|
355
356
|
getAnalysesForEntry(entryId: string): readonly EntryAnalysis[];
|
|
356
357
|
/**
|
|
357
|
-
*
|
|
358
|
-
* `record.history.at(-1)` for each one's latest result.
|
|
359
|
-
*
|
|
358
|
+
* Returns every analysis record in registration order, the combined cross-entry view. Read
|
|
359
|
+
* `record.history.at(-1)` for each one's latest result. Tracker verdicts are not analyses, so every
|
|
360
|
+
* record here is operator-facing.
|
|
360
361
|
*/
|
|
361
362
|
all(): readonly AnalysisRecord[];
|
|
362
363
|
/** Full result timeline for one analysis, oldest first. Empty when unknown. */
|
|
@@ -366,14 +367,14 @@ declare class Analyses {
|
|
|
366
367
|
get(analysisId: string): AnalysisRecord | undefined;
|
|
367
368
|
/** Whether the analysis is currently recomputed on source change (its job exists and is active). */
|
|
368
369
|
isMonitored(analysisId: string): boolean;
|
|
369
|
-
/**
|
|
370
|
+
/** Removes an analysis, tearing down its job and dropping the record and handle. */
|
|
370
371
|
remove(analysisId: string): void;
|
|
371
372
|
/**
|
|
372
|
-
*
|
|
373
|
-
* `unregister(name)`
|
|
373
|
+
* Removes every record sharing a `name`, across all source entries, as the old per-entry
|
|
374
|
+
* `unregister(name)` dropped a named analysis wherever it was attached.
|
|
374
375
|
*/
|
|
375
376
|
removeByName(name: string): void;
|
|
376
|
-
/**
|
|
377
|
+
/** Drops every record and job handle. `destroyState` calls it automatically (duck-typed `reset`). */
|
|
377
378
|
reset(): void;
|
|
378
379
|
}
|
|
379
380
|
//#endregion
|
|
@@ -568,39 +569,38 @@ interface FeatureCollection$1<G extends Geometry | null = Geometry, P = GeoJsonP
|
|
|
568
569
|
/**
|
|
569
570
|
* @module agent-toolkit-state
|
|
570
571
|
*
|
|
571
|
-
*
|
|
572
|
-
* custom-geometries
|
|
573
|
-
* history of entries
|
|
574
|
-
*
|
|
575
|
-
*
|
|
576
|
-
* runtime state).
|
|
572
|
+
* The shared base shape for the per-slice history entries of places, routes, ranges, byod,
|
|
573
|
+
* custom-geometries, traffic-area-analytics and traffic-incidents. Every slice keeps an append-only
|
|
574
|
+
* history of entries that share four fields: an `id`, a `timestamp`, a `label`, and a single `data`
|
|
575
|
+
* payload. They live here, so each slice's entry type is `BaseEntry<TPayload> & { … }` plus only the
|
|
576
|
+
* fields unique to that slice, its per-entry display and runtime state.
|
|
577
577
|
*
|
|
578
578
|
* @group Agent Toolkit
|
|
579
579
|
*/
|
|
580
580
|
/**
|
|
581
|
-
* The fields
|
|
582
|
-
* (`id`), provenance (`timestamp`, `label`)
|
|
583
|
-
* this with its own per-entry display state
|
|
581
|
+
* The fields every history entry shares across the toolkit's state slices, namely identity
|
|
582
|
+
* (`id`), provenance (`timestamp`, `label`) and the slice's payload (`data`). Each slice intersects
|
|
583
|
+
* this with its own per-entry display state, such as `type RoutesEntry = BaseEntry<Routes> & { … }`.
|
|
584
584
|
*
|
|
585
|
-
* @typeParam TData -
|
|
586
|
-
* `TrafficIncident[]
|
|
585
|
+
* @typeParam TData - The entry's payload type, such as `Routes`, `Place[]`, `FeatureCollection` or
|
|
586
|
+
* `TrafficIncident[]`. It is the single result the entry was created to hold.
|
|
587
587
|
*
|
|
588
588
|
* @group Agent Toolkit
|
|
589
589
|
*/
|
|
590
590
|
type BaseEntry<TData> = {
|
|
591
591
|
/**
|
|
592
|
-
*
|
|
593
|
-
* existing entries on collision
|
|
592
|
+
* The stable, slice-unique entry id, such as `places-0` or a caller-supplied id deduped against
|
|
593
|
+
* existing entries on collision. Tools and recall surfaces address the entry by it.
|
|
594
594
|
*/
|
|
595
595
|
id: string;
|
|
596
596
|
/**
|
|
597
|
-
*
|
|
598
|
-
* bumped on each in-place replace
|
|
597
|
+
* The creation or last-refresh time, in milliseconds since the epoch. It is set when the entry is
|
|
598
|
+
* added and bumped on each in-place replace. A monitored re-run stamps the source sample time.
|
|
599
599
|
*/
|
|
600
600
|
timestamp: number;
|
|
601
|
-
/**
|
|
601
|
+
/** A short, human-readable label, shown in recall and recents surfaces. */
|
|
602
602
|
label: string;
|
|
603
|
-
/** The entry's payload
|
|
603
|
+
/** The entry's payload, the single result it was created to hold. */
|
|
604
604
|
data: TData;
|
|
605
605
|
};
|
|
606
606
|
//#endregion
|
|
@@ -700,7 +700,7 @@ type BYODEntry = BaseEntry<FeatureCollection$1> & {
|
|
|
700
700
|
/**
|
|
701
701
|
* State for base map display: style, language, viewport and layers.
|
|
702
702
|
*
|
|
703
|
-
*
|
|
703
|
+
* It exposes the TomTomMap and MapLibre instances directly, alongside
|
|
704
704
|
* lazy-initialized BaseMapModule, StylingFoundationsModule and TerrainModule.
|
|
705
705
|
*
|
|
706
706
|
* @group Agent Toolkit
|
|
@@ -910,18 +910,18 @@ export declare const applyFitOnMap: (state: ToolState, fit: FitOnMapInput) => z.
|
|
|
910
910
|
//#endregion
|
|
911
911
|
//#region src/tools/shared/geocode-areas.d.ts
|
|
912
912
|
/**
|
|
913
|
-
* Administrative-
|
|
914
|
-
* (`within` mode). Restricting the geocode to these (via `entityTypeSet`)
|
|
915
|
-
*
|
|
916
|
-
*
|
|
917
|
-
* postcode).
|
|
913
|
+
* Administrative-area geography types accepted when resolving a query to a *containing area*
|
|
914
|
+
* (`within` mode). Restricting the geocode to these (via `entityTypeSet`) stops streets and POIs
|
|
915
|
+
* from drowning the area. Without it, "De Pijp" and "Westminster" geocode to Streets at rank 0.
|
|
916
|
+
* Excludes `Country` (too coarse) and `PostalCodeArea` (homonym noise, such as "A10" matching a
|
|
917
|
+
* Kazakh postcode).
|
|
918
918
|
*/
|
|
919
919
|
export declare const AREA_GEOGRAPHY_TYPES: GeographyType[];
|
|
920
920
|
/**
|
|
921
|
-
* Geocodes `query` restricted to administrative
|
|
921
|
+
* Geocodes `query` restricted to administrative area geographies (not streets/POIs), biased toward
|
|
922
922
|
* `bias` (the map centre). Because `geographyTypes` filters to areas, every result carries a
|
|
923
|
-
* `boundingBox`. Callers choose among the candidates
|
|
924
|
-
* centre bias is used rather than a hard viewport-bbox filter so out-of-view areas still resolve.
|
|
923
|
+
* `boundingBox`. Callers choose among the candidates, for example the one nearest the current view.
|
|
924
|
+
* A centre bias is used rather than a hard viewport-bbox filter, so out-of-view areas still resolve.
|
|
925
925
|
*/
|
|
926
926
|
export declare const geocodeAreas: (query: string, opts?: {
|
|
927
927
|
bias?: Position;
|
|
@@ -937,8 +937,8 @@ export declare const geocodeAreas: (query: string, opts?: {
|
|
|
937
937
|
export type GeometriesIdKind = 'place' | 'places' | 'ranges' | 'customGeometries';
|
|
938
938
|
/**
|
|
939
939
|
* Tagged geometries id. The Zod schema is exposed so tools can plug it
|
|
940
|
-
* straight into their input shape (`z.array(geometriesIdSchema).min(1)`)
|
|
941
|
-
*
|
|
940
|
+
* straight into their input shape (`z.array(geometriesIdSchema).min(1)`),
|
|
941
|
+
* with no string parsing on the way in.
|
|
942
942
|
*
|
|
943
943
|
* @group Agent Toolkit
|
|
944
944
|
*/
|
|
@@ -1007,10 +1007,10 @@ export declare const GEOMETRIES_SOURCE_IDS_DESC = "Tagged input ids that contrib
|
|
|
1007
1007
|
* @module agent-toolkit-tools
|
|
1008
1008
|
*
|
|
1009
1009
|
* Compact schema doc for the geometry polygons consumed/produced by sandboxed
|
|
1010
|
-
* code in `processData` / `analyseData
|
|
1010
|
+
* code in `processData` / `analyseData`, injected per source as
|
|
1011
1011
|
* `geometriesByEntry[key]`. Each item is a
|
|
1012
|
-
* `PolygonFeature<CommonPlaceProps
|
|
1013
|
-
* spelled out here.
|
|
1012
|
+
* `PolygonFeature<CommonPlaceProps>`, and only its non-GeoJSON-standard bits
|
|
1013
|
+
* are spelled out here.
|
|
1014
1014
|
*/
|
|
1015
1015
|
/** @ignore */
|
|
1016
1016
|
export declare const GEOMETRIES_SCHEMA_DOC: string;
|
|
@@ -1029,8 +1029,8 @@ type CustomGeometriesAnalysis = EntryAnalysis;
|
|
|
1029
1029
|
//#endregion
|
|
1030
1030
|
//#region src/state/digest.d.ts
|
|
1031
1031
|
/**
|
|
1032
|
-
*
|
|
1033
|
-
*
|
|
1032
|
+
* A compact, diffable snapshot of the user-visible parts of `ToolState`. Every field serialises to
|
|
1033
|
+
* JSON and stays stable for `===` comparison while the underlying state is unchanged.
|
|
1034
1034
|
*
|
|
1035
1035
|
* @group Agent Toolkit
|
|
1036
1036
|
*/
|
|
@@ -1040,25 +1040,25 @@ type StateDigest = {
|
|
|
1040
1040
|
shownAsPin: string[];
|
|
1041
1041
|
/** Entry ids currently rendered as base-map POIs, sorted ascending. */
|
|
1042
1042
|
shownAsBaseMap: string[];
|
|
1043
|
-
/**
|
|
1043
|
+
/** The slice's display policy, `multiple` (default) or `single`. */
|
|
1044
1044
|
entryMode: EntryMode;
|
|
1045
1045
|
};
|
|
1046
1046
|
routes: {
|
|
1047
1047
|
/** Routes-entry ids currently drawn on the map, sorted ascending. */
|
|
1048
1048
|
shown: string[];
|
|
1049
|
-
/**
|
|
1049
|
+
/** The slice's display policy, `multiple` (default) or `single`. */
|
|
1050
1050
|
entryMode: EntryMode;
|
|
1051
1051
|
};
|
|
1052
1052
|
ranges: {
|
|
1053
1053
|
/** Range-entry ids currently drawn on the map, sorted ascending. */
|
|
1054
1054
|
shown: string[];
|
|
1055
|
-
/**
|
|
1055
|
+
/** The slice's display policy, `multiple` (default) or `single`. */
|
|
1056
1056
|
entryMode: EntryMode;
|
|
1057
1057
|
};
|
|
1058
1058
|
traffic: {
|
|
1059
1059
|
/** Traffic-area-analytics entry ids currently rendered on the map, sorted ascending. */
|
|
1060
1060
|
shown: string[];
|
|
1061
|
-
/**
|
|
1061
|
+
/** The slice's display policy, `multiple` (default) or `single`. */
|
|
1062
1062
|
entryMode: EntryMode;
|
|
1063
1063
|
/** Total traffic-area-analytics entries in history (shown + hidden). */
|
|
1064
1064
|
entryCount: number;
|
|
@@ -1068,13 +1068,13 @@ type StateDigest = {
|
|
|
1068
1068
|
shown: string[];
|
|
1069
1069
|
/** Entry ids currently being polled by the per-entry network monitor, sorted ascending. */
|
|
1070
1070
|
monitored: string[];
|
|
1071
|
-
/**
|
|
1071
|
+
/** The slice's display policy, `multiple` (default) or `single`. */
|
|
1072
1072
|
entryMode: EntryMode;
|
|
1073
1073
|
};
|
|
1074
1074
|
customGeometries: {
|
|
1075
1075
|
/** Custom-geometries entry ids currently rendered on the map, sorted ascending. */
|
|
1076
1076
|
shown: string[];
|
|
1077
|
-
/**
|
|
1077
|
+
/** The slice's display policy, `multiple` (default) or `single`. */
|
|
1078
1078
|
entryMode: EntryMode;
|
|
1079
1079
|
/** Total custom-geometries entries in history (shown + hidden). */
|
|
1080
1080
|
entryCount: number;
|
|
@@ -1082,23 +1082,23 @@ type StateDigest = {
|
|
|
1082
1082
|
byod: {
|
|
1083
1083
|
/** BYOD entry ids currently rendered on the map, sorted ascending. */
|
|
1084
1084
|
shown: string[];
|
|
1085
|
-
/**
|
|
1085
|
+
/** The slice's display policy, `multiple` (default) or `single`. */
|
|
1086
1086
|
entryMode: EntryMode;
|
|
1087
1087
|
/** Total BYOD entries in history (shown + hidden). */
|
|
1088
1088
|
entryCount: number;
|
|
1089
1089
|
};
|
|
1090
1090
|
};
|
|
1091
1091
|
/**
|
|
1092
|
-
*
|
|
1093
|
-
* "agent-known" baseline
|
|
1092
|
+
* Takes a snapshot of the user-visible state surface. Call it after every assistant turn to record
|
|
1093
|
+
* the "agent-known" baseline, and again before each user prompt to detect what changed since.
|
|
1094
1094
|
*
|
|
1095
1095
|
* @group Agent Toolkit
|
|
1096
1096
|
*/
|
|
1097
1097
|
export declare const getStateDigest: (state: ToolState) => StateDigest;
|
|
1098
1098
|
/**
|
|
1099
|
-
*
|
|
1099
|
+
* Returns a compact, LLM-readable summary of the differences between two digests, or `null` if
|
|
1100
1100
|
* nothing changed. The output is short enough to prepend to a user prompt without bloating the
|
|
1101
|
-
* conversation
|
|
1101
|
+
* conversation, so it deliberately omits longer per-field diffs.
|
|
1102
1102
|
*
|
|
1103
1103
|
* @example
|
|
1104
1104
|
* ```ts
|
|
@@ -1143,12 +1143,12 @@ type PlacesAnalysis = EntryAnalysis;
|
|
|
1143
1143
|
//#endregion
|
|
1144
1144
|
//#region src/state/places/state.d.ts
|
|
1145
1145
|
/**
|
|
1146
|
-
* The marker looks an entry can
|
|
1147
|
-
* pins.
|
|
1148
|
-
* the agent. Every tool enum for marker types derives from this array
|
|
1146
|
+
* The marker looks an entry can render with, namely individual pins, base-map POIs, or clustered
|
|
1147
|
+
* pins. It is a type-checked subset of the SDK's `PlacesMarkerType` that doesn't offer `circle-icon`
|
|
1148
|
+
* to the agent. Every tool enum for marker types derives from this array instead of repeating it.
|
|
1149
1149
|
*/
|
|
1150
1150
|
declare const placesMarkerTypes: readonly ["pin", "base-map", "pin-clustered"];
|
|
1151
|
-
/** How an entry
|
|
1151
|
+
/** How an entry renders on the map, one of {@link placesMarkerTypes}. */
|
|
1152
1152
|
type PlacesMarkerType = (typeof placesMarkerTypes)[number];
|
|
1153
1153
|
/**
|
|
1154
1154
|
* Events fired by {@link PlacesState}. Subscribe via `state.places.events.on(type, handler)`.
|
|
@@ -1157,33 +1157,33 @@ type PlacesMarkerType = (typeof placesMarkerTypes)[number];
|
|
|
1157
1157
|
*/
|
|
1158
1158
|
type PlacesStateEvents = {
|
|
1159
1159
|
/**
|
|
1160
|
-
*
|
|
1161
|
-
* snapshot after the change
|
|
1162
|
-
*
|
|
1163
|
-
* `affectedEntryIds
|
|
1160
|
+
* An entry was added or replaced, or `reset()` cleared the history. `entries` is the full
|
|
1161
|
+
* snapshot after the change, and `changedIds` lists the ids of the entries this change added,
|
|
1162
|
+
* replaced in place, or removed. The {@link JobEngine} matches these against each job's
|
|
1163
|
+
* `affectedEntryIds`.
|
|
1164
1164
|
*/
|
|
1165
1165
|
'entries-change': {
|
|
1166
1166
|
entries: readonly PlacesEntry[];
|
|
1167
1167
|
changedIds: readonly string[];
|
|
1168
1168
|
};
|
|
1169
|
-
/**
|
|
1169
|
+
/** The set of entries rendered on the map, or a marker type, changed. */
|
|
1170
1170
|
'shown-change': ReadonlySet<string>;
|
|
1171
1171
|
/** Boundary polygons were fetched and cached on an entry. */
|
|
1172
1172
|
'geometries-change': {
|
|
1173
1173
|
entryId: string;
|
|
1174
1174
|
count: number;
|
|
1175
1175
|
};
|
|
1176
|
-
/**
|
|
1176
|
+
/** The display policy switched between `single` and `multiple`. */
|
|
1177
1177
|
'mode-change': EntryMode;
|
|
1178
1178
|
};
|
|
1179
1179
|
/**
|
|
1180
|
-
*
|
|
1180
|
+
* The state for the places layer, an append-only history of place results plus per-entry display
|
|
1181
1181
|
* modules.
|
|
1182
1182
|
*
|
|
1183
|
-
* Each entry owns a single PlacesModule
|
|
1184
|
-
*
|
|
1185
|
-
*
|
|
1186
|
-
* entries can
|
|
1183
|
+
* Each entry owns a single PlacesModule and a dedicated GeometriesModule, both initialised lazily
|
|
1184
|
+
* on first show. An entry renders under one marker type at a time, so `updateConfig` switches its
|
|
1185
|
+
* PlacesModule in place when the marker type changes. Display state lives on the entry, so two
|
|
1186
|
+
* entries can render side by side under different marker types without sharing a single source.
|
|
1187
1187
|
*
|
|
1188
1188
|
* @group Agent Toolkit
|
|
1189
1189
|
*/
|
|
@@ -1191,37 +1191,38 @@ declare class PlacesState implements StateSlice {
|
|
|
1191
1191
|
private readonly _ttMap;
|
|
1192
1192
|
private _entries;
|
|
1193
1193
|
private _entryMode;
|
|
1194
|
-
/**
|
|
1194
|
+
/** The state change events, listed in {@link PlacesStateEvents}. */
|
|
1195
1195
|
readonly events: StateEvents<PlacesStateEvents>;
|
|
1196
1196
|
constructor(_ttMap: TomTomMap);
|
|
1197
1197
|
/**
|
|
1198
|
-
*
|
|
1199
|
-
* simultaneously
|
|
1200
|
-
*
|
|
1198
|
+
* The display policy. `multiple` (default) keeps every history entry available to render
|
|
1199
|
+
* simultaneously. `single` allows at most one entry on the map at a time and trims the
|
|
1200
|
+
* history to the latest entry whenever it's set.
|
|
1201
1201
|
*/
|
|
1202
1202
|
get entryMode(): EntryMode;
|
|
1203
1203
|
/**
|
|
1204
|
-
*
|
|
1205
|
-
*
|
|
1206
|
-
*
|
|
1204
|
+
* Switches the display policy. Moving from `multiple` to `single` hides every entry older
|
|
1205
|
+
* than the latest, drops them from history, and emits `entries-change` so listeners (the
|
|
1206
|
+
* recents rail, recall tools, …) re-render. Does nothing if the mode hasn't changed.
|
|
1207
1207
|
*/
|
|
1208
1208
|
setEntryMode(mode: EntryMode): Promise<void>;
|
|
1209
1209
|
/**
|
|
1210
|
-
*
|
|
1211
|
-
*
|
|
1212
|
-
*
|
|
1210
|
+
* Returns the entry's PlacesModule, created on first call and switched to `markerType`. An entry
|
|
1211
|
+
* renders under only one marker type at a time, so flipping marker types reuses the same module
|
|
1212
|
+
* and calls `updateConfig` in place. Throws if the entry id is unknown.
|
|
1213
1213
|
*/
|
|
1214
1214
|
getEntryPlacesModule(entryId: string, markerType: PlacesMarkerType): Promise<PlacesModule>;
|
|
1215
1215
|
/**
|
|
1216
|
-
*
|
|
1217
|
-
*
|
|
1216
|
+
* Returns the entry's place-geometries module for POI footprints and municipality outlines,
|
|
1217
|
+
* created on first call. Re-applies the config when the fill style changes. Throws on an
|
|
1218
|
+
* unknown entry id.
|
|
1218
1219
|
*/
|
|
1219
1220
|
getEntryGeometriesModule(entryId: string, fillStyle?: GeometryFillStyle): Promise<GeometriesModule>;
|
|
1220
1221
|
private _requireEntry;
|
|
1221
1222
|
get entries(): readonly PlacesEntry[];
|
|
1222
1223
|
/**
|
|
1223
|
-
*
|
|
1224
|
-
*
|
|
1224
|
+
* Only passes data between tools in a context-dependent way, so it assumes
|
|
1225
|
+
* the most recent entry is the relevant one to show on the map.
|
|
1225
1226
|
*/
|
|
1226
1227
|
get latestPlace(): Place[] | undefined;
|
|
1227
1228
|
addPlaceResult(place: Place | Places, label: string, explicitId?: string, connections?: PlaceConnectionDisplay[], geometries?: PolygonFeature<CommonPlaceProps>[]): Promise<string>;
|
|
@@ -1249,18 +1250,17 @@ declare class PlacesState implements StateSlice {
|
|
|
1249
1250
|
*/
|
|
1250
1251
|
fetchGeometriesForEntry(entryId: string, options?: ToolExecuteOptions): Promise<PolygonFeature<CommonPlaceProps>[]>;
|
|
1251
1252
|
/**
|
|
1252
|
-
*
|
|
1253
|
-
*
|
|
1254
|
-
* the slice's per-entry hide
|
|
1253
|
+
* Renders the given polygons via the entry's GeometriesModule. The `mode` flag applies to
|
|
1254
|
+
* **this entry's layer only** and doesn't touch other entries. For cross-entry visibility,
|
|
1255
|
+
* use the slice's per-entry hide and show methods.
|
|
1255
1256
|
*
|
|
1256
|
-
* - `mode: 'replace'` (default)
|
|
1257
|
-
* whatever was
|
|
1258
|
-
* - `mode: 'add'`
|
|
1259
|
-
*
|
|
1260
|
-
* no-op.
|
|
1257
|
+
* - `mode: 'replace'` (default) calls `module.show` with exactly these features, replacing
|
|
1258
|
+
* whatever was on this entry's layer before. An empty array clears the layer.
|
|
1259
|
+
* - `mode: 'add'` merges the new features with the polygons shown on this entry's layer,
|
|
1260
|
+
* deduped by `feature.id`, and re-renders the union. An empty array does nothing.
|
|
1261
1261
|
*
|
|
1262
|
-
* `entryId` defaults to the latest entry that owns geometries
|
|
1263
|
-
* render the most
|
|
1262
|
+
* `entryId` defaults to the latest entry that owns geometries, which suits callers that only
|
|
1263
|
+
* render the most recently produced footprints. Pass an explicit id to target an older one.
|
|
1264
1264
|
*/
|
|
1265
1265
|
showPlaceGeometries(features: PolygonFeature<CommonPlaceProps>[], fillStyle?: GeometryFillStyle, mode?: 'add' | 'replace', entryId?: string): Promise<void>;
|
|
1266
1266
|
private _latestGeometriesEntryId;
|
|
@@ -1276,37 +1276,36 @@ declare class PlacesState implements StateSlice {
|
|
|
1276
1276
|
private _idsShownAs;
|
|
1277
1277
|
/** Marker type for a specific entry, or undefined if it is not shown. */
|
|
1278
1278
|
getShownMarkerType(id: string): PlacesMarkerType | undefined;
|
|
1279
|
-
/**
|
|
1279
|
+
/** Returns the union of all features belonging to the shown entries. */
|
|
1280
1280
|
getShownFeatures(): Place[];
|
|
1281
1281
|
/**
|
|
1282
|
-
*
|
|
1283
|
-
* Entries
|
|
1284
|
-
*
|
|
1282
|
+
* Replaces the shown set for `markerType` with exactly these ids and re-renders.
|
|
1283
|
+
* Entries shown as `markerType` but absent from `ids` are hidden. Entries in `ids`
|
|
1284
|
+
* switch to `markerType`, creating their module if needed.
|
|
1285
1285
|
*/
|
|
1286
1286
|
setShownEntries(ids: readonly string[], markerType: PlacesMarkerType): Promise<Place[]>;
|
|
1287
1287
|
/**
|
|
1288
|
-
*
|
|
1289
|
-
*
|
|
1290
|
-
* marker type).
|
|
1288
|
+
* Adds ids to the shown set under `markerType`. Any id shown as a different
|
|
1289
|
+
* marker type moves, and its module switches to the new marker type.
|
|
1291
1290
|
*
|
|
1292
|
-
*
|
|
1293
|
-
*
|
|
1291
|
+
* With `entryMode === 'single'`, everything else is hidden first, so in effect
|
|
1292
|
+
* only the last id in the list is shown.
|
|
1294
1293
|
*/
|
|
1295
1294
|
addShownEntries(ids: readonly string[], markerType: PlacesMarkerType): Promise<Place[]>;
|
|
1296
|
-
/**
|
|
1295
|
+
/** Removes ids from the shown set and clears their modules. */
|
|
1297
1296
|
removeShownEntries(ids: readonly string[]): Promise<Place[]>;
|
|
1298
|
-
/**
|
|
1297
|
+
/** Clears everything from the map but leaves the entries history untouched. */
|
|
1299
1298
|
clearShownEntries(): Promise<void>;
|
|
1300
1299
|
/**
|
|
1301
|
-
*
|
|
1302
|
-
* history (`entries`)
|
|
1300
|
+
* Hides every PlacesState rendering, both pins and attached boundary polygons, but leaves
|
|
1301
|
+
* the history (`entries`) untouched. Implements {@link ClearableMapSlice}.
|
|
1303
1302
|
*/
|
|
1304
1303
|
clearShown(): Promise<void>;
|
|
1305
1304
|
clearShownGeometries(ids?: readonly string[]): Promise<void>;
|
|
1306
1305
|
/**
|
|
1307
|
-
*
|
|
1308
|
-
*
|
|
1309
|
-
*
|
|
1306
|
+
* Drops a single entry from history. It first hides the entry by clearing every module it
|
|
1307
|
+
* owns, then removes it from `_entries`. Emits `entries-change`, plus `shown-change` if the
|
|
1308
|
+
* entry was shown. Does nothing if the id is unknown.
|
|
1310
1309
|
*/
|
|
1311
1310
|
removeEntry(id: string): Promise<void>;
|
|
1312
1311
|
private _showEntryAs;
|
|
@@ -1403,25 +1402,25 @@ type RangesEntry = BaseEntry<ReachableRange[]> & {
|
|
|
1403
1402
|
*/
|
|
1404
1403
|
type RangeStateEvents = {
|
|
1405
1404
|
/**
|
|
1406
|
-
*
|
|
1407
|
-
* after the change
|
|
1408
|
-
*
|
|
1405
|
+
* An entry was added, or `reset()` cleared the range history. `entries` is the full snapshot
|
|
1406
|
+
* after the change, and `changedIds` lists the ids of the entries this change added, replaced
|
|
1407
|
+
* in place, or removed.
|
|
1409
1408
|
*/
|
|
1410
1409
|
'entries-change': {
|
|
1411
1410
|
entries: readonly RangesEntry[];
|
|
1412
1411
|
changedIds: readonly string[];
|
|
1413
1412
|
};
|
|
1414
|
-
/**
|
|
1413
|
+
/** The set of ranges entries rendered on the map changed (multi-show under `multiple`). */
|
|
1415
1414
|
'shown-change': ReadonlySet<string>;
|
|
1416
|
-
/**
|
|
1415
|
+
/** The display policy switched between `single` and `multiple`. */
|
|
1417
1416
|
'mode-change': EntryMode;
|
|
1418
1417
|
};
|
|
1419
1418
|
/**
|
|
1420
1419
|
* State for reachable range results.
|
|
1421
1420
|
*
|
|
1422
|
-
*
|
|
1423
|
-
*
|
|
1424
|
-
*
|
|
1421
|
+
* It stores semantic summaries of calculated ranges (origin, budgets), plus the raw polygon
|
|
1422
|
+
* geometry internally for geometry searches such as discoverPlaces withinRange.
|
|
1423
|
+
* ReachableRangesModule displays them on the map.
|
|
1425
1424
|
*
|
|
1426
1425
|
* @group Agent Toolkit
|
|
1427
1426
|
*/
|
|
@@ -1429,56 +1428,55 @@ declare class RangeState implements ShownEntriesSlice {
|
|
|
1429
1428
|
private readonly _ttMap;
|
|
1430
1429
|
private _entries;
|
|
1431
1430
|
private _entryMode;
|
|
1432
|
-
/**
|
|
1431
|
+
/** The state change events, listed in {@link RangeStateEvents}. */
|
|
1433
1432
|
readonly events: StateEvents<RangeStateEvents>;
|
|
1434
1433
|
constructor(_ttMap: TomTomMap);
|
|
1435
1434
|
/** Set of ranges-entry ids currently rendered on the map. */
|
|
1436
1435
|
get shownEntryIds(): ReadonlySet<string>;
|
|
1437
1436
|
/**
|
|
1438
|
-
*
|
|
1439
|
-
* by side
|
|
1440
|
-
*
|
|
1437
|
+
* The display policy. `multiple` (default) lets several reachable-area entries render
|
|
1438
|
+
* side by side. `single` allows at most one ranges entry on the map, so `markEntryShown`
|
|
1439
|
+
* first hides any previously-shown entry.
|
|
1441
1440
|
*/
|
|
1442
1441
|
get entryMode(): EntryMode;
|
|
1443
1442
|
/**
|
|
1444
|
-
*
|
|
1445
|
-
*
|
|
1446
|
-
*
|
|
1443
|
+
* Switches the display policy. Moving from `multiple` to `single` hides every non-latest
|
|
1444
|
+
* entry, drops them from history, and emits `entries-change`. Does nothing if the mode
|
|
1445
|
+
* hasn't changed.
|
|
1447
1446
|
*/
|
|
1448
1447
|
setEntryMode(mode: EntryMode): Promise<void>;
|
|
1449
1448
|
/**
|
|
1450
|
-
*
|
|
1451
|
-
*
|
|
1449
|
+
* Initialises the entry's ReachableRangesModule for the isochrone/isodistance polygons
|
|
1450
|
+
* lazily and applies the requested fill style. Throws on unknown id.
|
|
1452
1451
|
*/
|
|
1453
1452
|
getEntryRangesModule(entryId: string, fillStyle?: GeometryFillStyle): Promise<ReachableRangesModule>;
|
|
1454
1453
|
/**
|
|
1455
|
-
*
|
|
1456
|
-
* your own (per-feature colours, border widths)
|
|
1454
|
+
* Initialises the entry's plain GeometriesModule lazily for drawing the entry's polygons in a
|
|
1455
|
+
* style of your own (per-feature colours, border widths) instead of as reachable-range bands.
|
|
1457
1456
|
* Updates only the fill style when it changes, keeping the styling applied since. Throws on
|
|
1458
1457
|
* unknown id.
|
|
1459
1458
|
*/
|
|
1460
1459
|
getEntryGeometriesModule(entryId: string, fillStyle?: GeometryFillStyle): Promise<GeometriesModule>;
|
|
1461
1460
|
/**
|
|
1462
|
-
*
|
|
1463
|
-
* so
|
|
1464
|
-
* overwriting another.
|
|
1461
|
+
* Initialises the entry's origin-pin PlacesModule lazily. Each entry has its own pin module,
|
|
1462
|
+
* so several ranges entries can share the map without one's pins overwriting another's.
|
|
1465
1463
|
*/
|
|
1466
1464
|
getEntryPlacesModule(entryId: string): Promise<PlacesModule>;
|
|
1467
1465
|
/**
|
|
1468
|
-
*
|
|
1469
|
-
* caller
|
|
1470
|
-
*
|
|
1466
|
+
* Marks the entry as shown by recording `_shown = true` and emitting `shown-change`. The
|
|
1467
|
+
* caller pushes features into the lazy modules itself. This method only keeps the `_shown`
|
|
1468
|
+
* flag in sync with what the user sees.
|
|
1471
1469
|
*
|
|
1472
|
-
*
|
|
1470
|
+
* With `entryMode === 'single'`, any other shown entry is hidden first so two range
|
|
1473
1471
|
* layers don't overlap.
|
|
1474
1472
|
*/
|
|
1475
1473
|
markEntryShown(entryId: string): Promise<void>;
|
|
1476
|
-
/**
|
|
1474
|
+
/** Clears every module on the entry. Does nothing if the entry is unknown. */
|
|
1477
1475
|
hideEntry(entryId: string): Promise<void>;
|
|
1478
1476
|
/**
|
|
1479
|
-
*
|
|
1480
|
-
*
|
|
1481
|
-
*
|
|
1477
|
+
* Drops a single entry from history. It clears the entry's ranges and origin-pin modules to
|
|
1478
|
+
* hide it, then removes it from `_entries`. Emits `entries-change`. Does nothing if the id is
|
|
1479
|
+
* unknown.
|
|
1482
1480
|
*/
|
|
1483
1481
|
removeEntry(entryId: string): Promise<void>;
|
|
1484
1482
|
private _requireEntry;
|
|
@@ -1486,8 +1484,8 @@ declare class RangeState implements ShownEntriesSlice {
|
|
|
1486
1484
|
get latestEntry(): RangesEntry | undefined;
|
|
1487
1485
|
addEntry(entry: Omit<RangesEntry, 'id' | 'timestamp'>): Promise<string>;
|
|
1488
1486
|
/**
|
|
1489
|
-
*
|
|
1490
|
-
*
|
|
1487
|
+
* Hides every reachable-range entry on the map but keeps the history. Implements
|
|
1488
|
+
* {@link ClearableMapSlice}.
|
|
1491
1489
|
*/
|
|
1492
1490
|
clearShown(): Promise<void>;
|
|
1493
1491
|
reset(): void;
|
|
@@ -1516,8 +1514,8 @@ type RouteSnapshot = {
|
|
|
1516
1514
|
routes: Routes;
|
|
1517
1515
|
};
|
|
1518
1516
|
/**
|
|
1519
|
-
*
|
|
1520
|
-
* failed and the timer
|
|
1517
|
+
* The lifecycle state of a per-entry route monitor. `stopped-error` means the last recalculation
|
|
1518
|
+
* failed and the timer was cleared. To retry, start the monitor again.
|
|
1521
1519
|
*
|
|
1522
1520
|
* @group Agent Toolkit
|
|
1523
1521
|
*/
|
|
@@ -1525,11 +1523,11 @@ type RoutePollingStatus = 'idle' | 'running' | 'stopped-error';
|
|
|
1525
1523
|
//#endregion
|
|
1526
1524
|
//#region src/state/routing/monitor/monitor.d.ts
|
|
1527
1525
|
/**
|
|
1528
|
-
*
|
|
1529
|
-
* over `calculateRoute`
|
|
1530
|
-
*
|
|
1526
|
+
* The injected dependencies of a {@link RouteMonitor}. Production code wires `recalculate` to a
|
|
1527
|
+
* closure over `calculateRoute` and the entry's waypoints and params, so each tick re-runs the same
|
|
1528
|
+
* route. Tests pass a deterministic fake and override the timer.
|
|
1531
1529
|
*
|
|
1532
|
-
* The recalculator returns
|
|
1530
|
+
* The recalculator returns only the routes. The monitor stamps `takenAt` itself, so every consumer of
|
|
1533
1531
|
* one tick (entry data, derived analyses) agrees on the same canonical moment.
|
|
1534
1532
|
*
|
|
1535
1533
|
* @group Agent Toolkit
|
|
@@ -1542,21 +1540,21 @@ type RouteMonitorDeps = {
|
|
|
1542
1540
|
};
|
|
1543
1541
|
/**
|
|
1544
1542
|
* Events fired by {@link RouteMonitor}. The slice subscribes once and re-emits translated copies
|
|
1545
|
-
* (`monitor-tick
|
|
1543
|
+
* (`monitor-tick`, `monitor-error`) keyed by entry id.
|
|
1546
1544
|
*/
|
|
1547
1545
|
type RouteMonitorEvents = {
|
|
1548
|
-
/** A recalculation succeeded.
|
|
1546
|
+
/** A recalculation succeeded. The payload is the fresh snapshot. */
|
|
1549
1547
|
tick: RouteSnapshot;
|
|
1550
|
-
/** A recalculation failed
|
|
1548
|
+
/** A recalculation failed, so the monitor cleared its timer and moved to `stopped-error`. */
|
|
1551
1549
|
error: string;
|
|
1552
1550
|
};
|
|
1553
1551
|
/**
|
|
1554
|
-
*
|
|
1555
|
-
* error.
|
|
1552
|
+
* A one-shot polling loop that recalculates a single route on an interval. It owns its timer, status,
|
|
1553
|
+
* and error. Restarting it after `stop()` resets all state.
|
|
1556
1554
|
*
|
|
1557
|
-
* The monitor never knows about the entry that owns it
|
|
1558
|
-
* waypoints
|
|
1559
|
-
* `IncidentMonitor
|
|
1555
|
+
* The monitor never knows about the entry that owns it. The `recalculate` closure captures the
|
|
1556
|
+
* waypoints and params, and the caller decides what to do with each fresh snapshot. It mirrors
|
|
1557
|
+
* `IncidentMonitor`. Routes carry live traffic, so periodic recalculation keeps the entry fresh.
|
|
1560
1558
|
*
|
|
1561
1559
|
* @group Agent Toolkit
|
|
1562
1560
|
*/
|
|
@@ -1569,19 +1567,20 @@ declare class RouteMonitor {
|
|
|
1569
1567
|
private _recalculate?;
|
|
1570
1568
|
get status(): RoutePollingStatus;
|
|
1571
1569
|
get error(): string | undefined;
|
|
1572
|
-
/**
|
|
1570
|
+
/** Whether the monitor is *currently* recalculating on its interval. */
|
|
1573
1571
|
get isRunning(): boolean;
|
|
1574
|
-
/**
|
|
1572
|
+
/** Whether the monitor has any activity (running or stopped-error). */
|
|
1575
1573
|
get isActive(): boolean;
|
|
1576
1574
|
/**
|
|
1577
|
-
*
|
|
1578
|
-
* immediately
|
|
1575
|
+
* Starts polling. It captures `deps` for the lifetime of the run, fires the first recalculation
|
|
1576
|
+
* immediately unless `skipInitialTick` is set, then schedules an interval. Does nothing if
|
|
1577
|
+
* already running.
|
|
1579
1578
|
*
|
|
1580
|
-
* `skipInitialTick`
|
|
1581
|
-
*
|
|
1579
|
+
* Set `skipInitialTick` if you just calculated the route and only want the recurring refresh,
|
|
1580
|
+
* since an eager first tick would duplicate that recalculation.
|
|
1582
1581
|
*/
|
|
1583
1582
|
start(deps: RouteMonitorDeps, intervalMs?: number, skipInitialTick?: boolean): void;
|
|
1584
|
-
/**
|
|
1583
|
+
/** Stops polling and resets state. Does nothing when idle. */
|
|
1585
1584
|
stop(): void;
|
|
1586
1585
|
private _tick;
|
|
1587
1586
|
private _failed;
|
|
@@ -1651,9 +1650,9 @@ type RoutesEntry = BaseEntry<Routes> & {
|
|
|
1651
1650
|
*/
|
|
1652
1651
|
type RoutingStateEvents = {
|
|
1653
1652
|
/**
|
|
1654
|
-
*
|
|
1655
|
-
* `entries` is the full snapshot after the change
|
|
1656
|
-
* this
|
|
1653
|
+
* A calculation was stored, an analysis attached, or `reset()` cleared the history.
|
|
1654
|
+
* `entries` is the full snapshot after the change, and `changedIds` lists the ids of the
|
|
1655
|
+
* entries this change added, replaced in place, or removed.
|
|
1657
1656
|
*/
|
|
1658
1657
|
'entries-change': {
|
|
1659
1658
|
entries: readonly RoutesEntry[];
|
|
@@ -1663,28 +1662,28 @@ type RoutingStateEvents = {
|
|
|
1663
1662
|
'planning-change': readonly PlanningWaypoint[];
|
|
1664
1663
|
/** Route parameters (alternatives, cost model, depart/arrive time) changed. */
|
|
1665
1664
|
'params-change': RouteParams;
|
|
1666
|
-
/**
|
|
1665
|
+
/** The set of routes entries rendered on the map changed (multi-show under `multiple`). */
|
|
1667
1666
|
'shown-change': ReadonlySet<string>;
|
|
1668
|
-
/**
|
|
1667
|
+
/** The display policy switched between `single` and `multiple`. */
|
|
1669
1668
|
'mode-change': EntryMode;
|
|
1670
|
-
/** Monitoring began on an entry (idle → running). Skipped
|
|
1669
|
+
/** Monitoring began on an entry (idle → running). Skipped if already running. */
|
|
1671
1670
|
'monitor-start': {
|
|
1672
1671
|
entryId: string;
|
|
1673
1672
|
};
|
|
1674
1673
|
/**
|
|
1675
|
-
* Monitoring halted on an entry. `reason: 'manual'` covers explicit `stopMonitoring` and
|
|
1676
|
-
* teardown (remove
|
|
1674
|
+
* Monitoring halted on an entry. `reason: 'manual'` covers an explicit `stopMonitoring` and
|
|
1675
|
+
* entry teardown (remove, reset). `reason: 'error'` fires alongside `monitor-error`.
|
|
1677
1676
|
*/
|
|
1678
1677
|
'monitor-stop': {
|
|
1679
1678
|
entryId: string;
|
|
1680
1679
|
reason: 'manual' | 'error';
|
|
1681
1680
|
};
|
|
1682
|
-
/** A monitored route was recalculated
|
|
1681
|
+
/** A monitored route was recalculated on a tick. The entry's data was updated in place. */
|
|
1683
1682
|
'monitor-tick': {
|
|
1684
1683
|
entryId: string;
|
|
1685
1684
|
snap: RouteSnapshot;
|
|
1686
1685
|
};
|
|
1687
|
-
/** A monitored route's recalculation failed
|
|
1686
|
+
/** A monitored route's recalculation failed, so the monitor cleared its timer and stopped. */
|
|
1688
1687
|
'monitor-error': {
|
|
1689
1688
|
entryId: string;
|
|
1690
1689
|
error: string;
|
|
@@ -1694,9 +1693,9 @@ type RoutingStateEvents = {
|
|
|
1694
1693
|
* State for route calculation, waypoint management, and route planning parameters.
|
|
1695
1694
|
*
|
|
1696
1695
|
* Each entry carries its own lazy-initialised RoutingModule (`entry._module`), so display
|
|
1697
|
-
* state lives on the entry instead of a shared slice-level module.
|
|
1698
|
-
*
|
|
1699
|
-
*
|
|
1696
|
+
* state lives on the entry instead of a shared slice-level module. To render two routes at once,
|
|
1697
|
+
* show both entries. Switching the active route hides the previous entry's module without
|
|
1698
|
+
* disturbing its calculated data.
|
|
1700
1699
|
*
|
|
1701
1700
|
* @group Agent Toolkit
|
|
1702
1701
|
*/
|
|
@@ -1718,34 +1717,34 @@ declare class RoutingState implements ShownEntriesSlice {
|
|
|
1718
1717
|
* set is `shownEntryIds` (derived from each entry's `_shown` flag).
|
|
1719
1718
|
*/
|
|
1720
1719
|
private _lastShownEntryId?;
|
|
1721
|
-
/**
|
|
1720
|
+
/** The state change events, listed in {@link RoutingStateEvents}. */
|
|
1722
1721
|
readonly events: StateEvents<RoutingStateEvents>;
|
|
1723
1722
|
constructor(_ttMap: TomTomMap);
|
|
1724
1723
|
/** Set of routes-entry ids currently rendered on the map. */
|
|
1725
1724
|
get shownEntryIds(): ReadonlySet<string>;
|
|
1726
1725
|
/**
|
|
1727
|
-
*
|
|
1728
|
-
* `single`
|
|
1729
|
-
* previously-shown entry
|
|
1726
|
+
* The display policy. `multiple` (default) lets several entries render side-by-side.
|
|
1727
|
+
* `single` allows at most one route on the map, so `showEntry` first hides any
|
|
1728
|
+
* previously-shown entry.
|
|
1730
1729
|
*/
|
|
1731
1730
|
get entryMode(): EntryMode;
|
|
1732
1731
|
/**
|
|
1733
|
-
*
|
|
1734
|
-
*
|
|
1735
|
-
*
|
|
1732
|
+
* Switches the display policy. Moving from `multiple` to `single` hides every non-latest
|
|
1733
|
+
* entry, drops them from history, and emits `entries-change`. Does nothing if the mode
|
|
1734
|
+
* hasn't changed.
|
|
1736
1735
|
*/
|
|
1737
1736
|
setEntryMode(mode: EntryMode): Promise<void>;
|
|
1738
1737
|
/**
|
|
1739
|
-
*
|
|
1740
|
-
*
|
|
1738
|
+
* Returns an entry's RoutingModule, created on first call. Throws on unknown id. To show or
|
|
1739
|
+
* hide it, prefer the higher-level {@link showEntry} and {@link hideEntry}.
|
|
1741
1740
|
*/
|
|
1742
1741
|
getEntryRoutingModule(entryId: string): Promise<RoutingModule>;
|
|
1743
1742
|
/**
|
|
1744
|
-
*
|
|
1743
|
+
* Renders the given entry's routes and waypoints on its own RoutingModule.
|
|
1745
1744
|
*
|
|
1746
|
-
*
|
|
1747
|
-
* layers don't pile up.
|
|
1748
|
-
* rendered,
|
|
1745
|
+
* With `entryMode === 'single'`, any other shown entry is hidden first so two route
|
|
1746
|
+
* layers don't pile up. With `entryMode === 'multiple'`, previously-shown entries stay
|
|
1747
|
+
* rendered, so the caller can overlay several routes at once.
|
|
1749
1748
|
*
|
|
1750
1749
|
* Emits `shown-change` once the new entry is up. Pass `showWaypoints: false` to render the
|
|
1751
1750
|
* route lines without origin/stop/destination pins, and `showSummaryBubbles: false` to drop the
|
|
@@ -1755,29 +1754,28 @@ declare class RoutingState implements ShownEntriesSlice {
|
|
|
1755
1754
|
showWaypoints?: boolean;
|
|
1756
1755
|
showSummaryBubbles?: boolean;
|
|
1757
1756
|
}): Promise<void>;
|
|
1758
|
-
/**
|
|
1757
|
+
/** The slice-level route colour, persisted across entry swaps. Undefined if none was set. */
|
|
1759
1758
|
get color(): string | undefined;
|
|
1760
1759
|
/**
|
|
1761
|
-
*
|
|
1762
|
-
*
|
|
1763
|
-
*
|
|
1764
|
-
*
|
|
1760
|
+
* Sets the slice-level route colour. It applies immediately to every shown entry's
|
|
1761
|
+
* RoutingModule, and later {@link showEntry} calls apply it automatically. Pass `undefined` to
|
|
1762
|
+
* clear the sticky colour. Shown modules then keep their last paint until they're re-shown,
|
|
1763
|
+
* and MapLibre style restore handles the full revert.
|
|
1765
1764
|
*/
|
|
1766
1765
|
setColor(color: string | undefined): void;
|
|
1767
1766
|
/**
|
|
1768
|
-
*
|
|
1769
|
-
*
|
|
1767
|
+
* Hides the entry's routes and waypoints by clearing its module, which stays cached.
|
|
1768
|
+
* Does nothing if the entry is unknown or already hidden.
|
|
1770
1769
|
*/
|
|
1771
1770
|
hideEntry(entryId: string): Promise<void>;
|
|
1772
1771
|
/**
|
|
1773
|
-
*
|
|
1774
|
-
*
|
|
1772
|
+
* Drops a single entry from history. It clears the entry's routing module to hide it, then
|
|
1773
|
+
* removes it from `_entries`. Emits `entries-change`. Does nothing if the id is unknown.
|
|
1775
1774
|
*/
|
|
1776
1775
|
removeEntry(entryId: string): Promise<void>;
|
|
1777
1776
|
private _requireEntry;
|
|
1778
1777
|
/**
|
|
1779
|
-
* RoutingModule of the most
|
|
1780
|
-
* entry is currently shown.
|
|
1778
|
+
* The RoutingModule of the most recently shown entry, or undefined if no entry is shown.
|
|
1781
1779
|
*/
|
|
1782
1780
|
get currentEntryModule(): RoutingModule | undefined;
|
|
1783
1781
|
get entries(): readonly RoutesEntry[];
|
|
@@ -1790,15 +1788,15 @@ declare class RoutingState implements ShownEntriesSlice {
|
|
|
1790
1788
|
setWaypointAt(index: number, waypoint: WaypointLike): void;
|
|
1791
1789
|
setParams(params: Partial<RouteParams>): void;
|
|
1792
1790
|
/**
|
|
1793
|
-
*
|
|
1791
|
+
* Replaces a route entry's data in place after a monitor recalculated it. Bumps `_tick`, updates
|
|
1794
1792
|
* `data`/`timestamp`, emits `entries-change`, and re-renders the route on its module when shown.
|
|
1795
|
-
* The `_tick` guard bails if a newer tick overwrote `data` while `showRoutes` awaited.
|
|
1796
|
-
*
|
|
1793
|
+
* The `_tick` guard bails if a newer tick overwrote `data` while `showRoutes` awaited. Returns
|
|
1794
|
+
* false if the entry is unknown. Mirrors `TrafficIncidentsState.replaceEntryData`.
|
|
1797
1795
|
*/
|
|
1798
1796
|
replaceRouteData(entryId: string, routes: Routes, sampledAt: number): Promise<boolean>;
|
|
1799
1797
|
private _createMonitorForEntry;
|
|
1800
1798
|
/**
|
|
1801
|
-
*
|
|
1799
|
+
* Arms background recalculation on an entry. Lazy-creates its monitor, then starts polling with
|
|
1802
1800
|
* the caller-supplied `recalculate` closure. Emits `monitor-start` on the idle → running
|
|
1803
1801
|
* transition. Throws on unknown id.
|
|
1804
1802
|
*/
|
|
@@ -1806,13 +1804,13 @@ declare class RoutingState implements ShownEntriesSlice {
|
|
|
1806
1804
|
intervalMs?: number;
|
|
1807
1805
|
skipInitialTick?: boolean;
|
|
1808
1806
|
}): void;
|
|
1809
|
-
/**
|
|
1807
|
+
/** Stops recalculating an entry but keeps its last data. Emits `monitor-stop`. Does nothing if not running. */
|
|
1810
1808
|
stopMonitoring(entryId: string): void;
|
|
1811
|
-
/**
|
|
1809
|
+
/** Whether the entry is being recalculated on its interval. */
|
|
1812
1810
|
isMonitored(entryId: string): boolean;
|
|
1813
1811
|
/**
|
|
1814
|
-
*
|
|
1815
|
-
*
|
|
1812
|
+
* Hides every route and waypoint set on the map but keeps the history (`entries`) intact.
|
|
1813
|
+
* Implements {@link ClearableMapSlice}.
|
|
1816
1814
|
*/
|
|
1817
1815
|
clearShown(): Promise<void>;
|
|
1818
1816
|
reset(): void;
|
|
@@ -1834,10 +1832,10 @@ export interface StateSlice {
|
|
|
1834
1832
|
//#endregion
|
|
1835
1833
|
//#region src/state/trackers.d.ts
|
|
1836
1834
|
/**
|
|
1837
|
-
* The features within
|
|
1838
|
-
* `featureIds` is the matched
|
|
1839
|
-
* logic (proximity, threshold, filter)
|
|
1840
|
-
*
|
|
1835
|
+
* The features within one source entry that matched the rule, the per-entry unit of a {@link Verdict}.
|
|
1836
|
+
* `featureIds` is the matched subset, not the whole entry. A rule selects features by arbitrary sandbox
|
|
1837
|
+
* logic (proximity, threshold, filter). The entry holds every feature, so without re-running the rule
|
|
1838
|
+
* that selection can't be recovered from `entryId` alone, and the verdict records exactly what matched.
|
|
1841
1839
|
* These are the features the UI highlights and the `summary` cites.
|
|
1842
1840
|
*/
|
|
1843
1841
|
type MemberRef = {
|
|
@@ -1845,24 +1843,24 @@ type MemberRef = {
|
|
|
1845
1843
|
featureIds: string[];
|
|
1846
1844
|
};
|
|
1847
1845
|
/**
|
|
1848
|
-
* What a tracker's sandboxed `evaluateCode` returns
|
|
1849
|
-
* and read back by the reducer. `members` groups matches by source entry so a verdict can span
|
|
1850
|
-
*
|
|
1851
|
-
* incidents group
|
|
1846
|
+
* What a tracker's sandboxed `evaluateCode` returns, stored verbatim as the rule analysis's `data`
|
|
1847
|
+
* and read back by the reducer. `members` groups matches by source entry, so a verdict can span
|
|
1848
|
+
* several entry kinds. For example, "an incident within 100m of a hospital" returns a hospitals group
|
|
1849
|
+
* and an incidents group. `summary` is a grounded headline the code produces deterministically.
|
|
1852
1850
|
*/
|
|
1853
1851
|
type Verdict = {
|
|
1854
1852
|
active: boolean;
|
|
1855
1853
|
members: MemberRef[];
|
|
1856
1854
|
summary: string;
|
|
1857
1855
|
};
|
|
1858
|
-
/** Toast-worthy (`alert`)
|
|
1856
|
+
/** Toast-worthy (`alert`) or quietly-logged (`event`), discriminating events in one store. */
|
|
1859
1857
|
type TrackerEventType = 'alert' | 'event';
|
|
1860
|
-
/** Rising edge (`opened`)
|
|
1858
|
+
/** Rising edge (`opened`) or falling edge (`resolved`), the only two statuses in the rising-edge model. */
|
|
1861
1859
|
type TrackerEventStatus = 'opened' | 'resolved';
|
|
1862
|
-
/**
|
|
1860
|
+
/** A tracker crossing an edge, kept as the durable record the feed and toasts render. */
|
|
1863
1861
|
type TrackerEvent = {
|
|
1864
1862
|
id: string;
|
|
1865
|
-
/** Source-data sample time of the recompute that fired it
|
|
1863
|
+
/** Source-data sample time of the recompute that fired it, **not** wall-clock. */
|
|
1866
1864
|
at: number;
|
|
1867
1865
|
trackerId: string;
|
|
1868
1866
|
trackerName: string;
|
|
@@ -1870,39 +1868,39 @@ type TrackerEvent = {
|
|
|
1870
1868
|
kind: TrackerEventStatus;
|
|
1871
1869
|
summary: string;
|
|
1872
1870
|
members: MemberRef[];
|
|
1873
|
-
/**
|
|
1871
|
+
/** The rising-edge time of the episode this closes, present on `resolved`. */
|
|
1874
1872
|
openedAt?: number;
|
|
1875
1873
|
};
|
|
1876
1874
|
/**
|
|
1877
|
-
*
|
|
1878
|
-
* tracker's {@link Job}, not here. `affectedEntryIds` are the entries the rule watches
|
|
1879
|
-
* `members` are the ones that matched.
|
|
1875
|
+
* A tracker is one rule, a natural-language condition plus its rising-edge state. The compiled code
|
|
1876
|
+
* lives on the tracker's {@link Job}, not here. `affectedEntryIds` are the entries the rule watches,
|
|
1877
|
+
* and a verdict's `members` are the ones that matched.
|
|
1880
1878
|
*/
|
|
1881
1879
|
type Tracker = {
|
|
1882
1880
|
id: string;
|
|
1883
1881
|
name: string;
|
|
1884
|
-
/** Natural-language condition (LLM-readable)
|
|
1882
|
+
/** Natural-language condition (LLM-readable). The compiled code lives on the tracker's job. */
|
|
1885
1883
|
rule: string;
|
|
1886
|
-
/**
|
|
1884
|
+
/** The ids of every entry the rule reads, the per-entry lookup key ({@link EventsState.trackersForEntry}). */
|
|
1887
1885
|
affectedEntryIds: readonly string[];
|
|
1888
1886
|
enabled: boolean;
|
|
1889
|
-
/**
|
|
1887
|
+
/** Whether the verdict was active at the last recompute, the one bit of rising-edge memory. */
|
|
1890
1888
|
wasActive: boolean;
|
|
1891
1889
|
/** Rising-edge time of the current open episode, if active. */
|
|
1892
1890
|
openedAt?: number;
|
|
1893
1891
|
};
|
|
1894
1892
|
/** Events emitted by {@link EventsState}. */
|
|
1895
1893
|
type TrackerStateEvents = {
|
|
1896
|
-
/** The tracker set or a tracker's live state changed (create
|
|
1894
|
+
/** The tracker set or a tracker's live state changed (create, clear, enable, edge crossed). */
|
|
1897
1895
|
'trackers-change': readonly Tracker[];
|
|
1898
|
-
/** A tracker crossed an edge
|
|
1896
|
+
/** A tracker crossed an edge. The freshly-logged event drives toasts and feed appends. */
|
|
1899
1897
|
'tracker-event': TrackerEvent;
|
|
1900
1898
|
};
|
|
1901
1899
|
/**
|
|
1902
|
-
* Generic tracker store
|
|
1903
|
-
*
|
|
1904
|
-
* {@link JobEngine}
|
|
1905
|
-
* {@link Job} handle backing each tracker (`_jobs`) so pausing a tracker pauses its job.
|
|
1900
|
+
* Generic tracker store and rising-edge reducer, held on `ToolState` as `state.trackers`. It only
|
|
1901
|
+
* stores and reacts. Tools register and unregister trackers and register their rule jobs on the
|
|
1902
|
+
* {@link JobEngine}, and each job's `run` feeds verdicts here via {@link ingestVerdict}. Keeps the
|
|
1903
|
+
* {@link Job} handle backing each tracker (`_jobs`), so pausing a tracker pauses its job.
|
|
1906
1904
|
*
|
|
1907
1905
|
* @group Agent Toolkit
|
|
1908
1906
|
*/
|
|
@@ -1914,24 +1912,24 @@ declare class EventsState implements StateSlice {
|
|
|
1914
1912
|
private _seq;
|
|
1915
1913
|
readonly events: StateEvents<TrackerStateEvents>;
|
|
1916
1914
|
/**
|
|
1917
|
-
*
|
|
1918
|
-
* (`wasActive: false`) and feeds the arm-time verdict via {@link ingestVerdict}
|
|
1919
|
-
* condition already live at creation crosses false→true and fires one `opened` alert. Emits
|
|
1915
|
+
* Registers a tracker. The caller (createTracker) registers it with the rising-edge bit clear
|
|
1916
|
+
* (`wasActive: false`) and feeds the arm-time verdict via {@link ingestVerdict} after this call. A
|
|
1917
|
+
* condition already live at creation then crosses false→true and fires one `opened` alert. Emits
|
|
1920
1918
|
* `trackers-change`.
|
|
1921
1919
|
*/
|
|
1922
1920
|
register(tracker: Tracker): void;
|
|
1923
|
-
/**
|
|
1921
|
+
/** Stores the {@link Job} backing a tracker, which links it to the engine. */
|
|
1924
1922
|
setJob(trackerId: string, job: Job): void;
|
|
1925
|
-
/**
|
|
1923
|
+
/** Removes a tracker and tears down its job. */
|
|
1926
1924
|
unregister(trackerId: string): void;
|
|
1927
|
-
/**
|
|
1925
|
+
/** Pauses or resumes a tracker and its job. A paused job never recomputes or crosses edges. */
|
|
1928
1926
|
setEnabled(trackerId: string, enabled: boolean): boolean;
|
|
1929
1927
|
/** Live trackers, as copies so external mutation can't corrupt the store. */
|
|
1930
1928
|
get trackers(): readonly Tracker[];
|
|
1931
1929
|
get(trackerId: string): Tracker | undefined;
|
|
1932
1930
|
/**
|
|
1933
|
-
*
|
|
1934
|
-
* "show all trackers for this area" in the UI.
|
|
1931
|
+
* The trackers whose rule reads `entryId`, such as every tracker watching a given incidents area.
|
|
1932
|
+
* Drives "show all trackers for this area" in the UI.
|
|
1935
1933
|
*/
|
|
1936
1934
|
trackersForEntry(entryId: string): readonly Tracker[];
|
|
1937
1935
|
/**
|
|
@@ -1942,13 +1940,14 @@ declare class EventsState implements StateSlice {
|
|
|
1942
1940
|
trackerId?: string;
|
|
1943
1941
|
sinceMs?: number;
|
|
1944
1942
|
}): readonly TrackerEvent[];
|
|
1945
|
-
/**
|
|
1943
|
+
/** Clears all trackers, the log and job handles. `destroyState` calls it automatically. */
|
|
1946
1944
|
reset(): void;
|
|
1947
1945
|
/**
|
|
1948
|
-
*
|
|
1949
|
-
* on each recompute
|
|
1950
|
-
* flipping false→true logs `opened` (alert)
|
|
1951
|
-
*
|
|
1946
|
+
* Feeds a freshly computed verdict through the rising-edge reducer. The tracker's job `run` calls it
|
|
1947
|
+
* on each recompute and once at arm time. It bails fast unless the tracker is live and enabled. A
|
|
1948
|
+
* verdict flipping false→true logs `opened` (alert), and true→false logs `resolved` (event).
|
|
1949
|
+
* Active→active and inactive→inactive change nothing. `at` is the source-data sample time of the
|
|
1950
|
+
* recompute.
|
|
1952
1951
|
*/
|
|
1953
1952
|
ingestVerdict(trackerId: string, verdict: Verdict, at: number): void;
|
|
1954
1953
|
private append;
|
|
@@ -2014,29 +2013,28 @@ type TrafficAreaAnalyticsEntry = BaseEntry<TrafficAreaAnalytics> & {
|
|
|
2014
2013
|
*/
|
|
2015
2014
|
type TrafficAreaAnalyticsStateEvents = {
|
|
2016
2015
|
/**
|
|
2017
|
-
*
|
|
2018
|
-
* snapshot after the change
|
|
2019
|
-
*
|
|
2016
|
+
* An entry was added or removed, or `reset()` cleared the history. `entries` is the full
|
|
2017
|
+
* snapshot after the change, and `changedIds` lists the ids of the entries this change added,
|
|
2018
|
+
* replaced in place, or removed.
|
|
2020
2019
|
*/
|
|
2021
2020
|
'entries-change': {
|
|
2022
2021
|
entries: readonly TrafficAreaAnalyticsEntry[];
|
|
2023
2022
|
changedIds: readonly string[];
|
|
2024
2023
|
};
|
|
2025
|
-
/**
|
|
2024
|
+
/** The set of entries rendered on the map changed. */
|
|
2026
2025
|
'shown-change': ReadonlySet<string>;
|
|
2027
|
-
/**
|
|
2026
|
+
/** An entry's viz config (mode, metric, scaleMode, …) changed. */
|
|
2028
2027
|
'config-change': {
|
|
2029
2028
|
entryId: string;
|
|
2030
2029
|
config: TrafficAreaAnalyticsModuleConfig | undefined;
|
|
2031
2030
|
};
|
|
2032
|
-
/**
|
|
2031
|
+
/** The display policy switched between `single` and `multiple`. */
|
|
2033
2032
|
'mode-change': EntryMode;
|
|
2034
2033
|
};
|
|
2035
2034
|
/**
|
|
2036
|
-
*
|
|
2037
|
-
* rendering.
|
|
2038
|
-
*
|
|
2039
|
-
* `RoutingState` / `CustomGeometriesState`.
|
|
2035
|
+
* An append-only history of traffic-area-analytics aggregations, with per-entry
|
|
2036
|
+
* rendering. As in `RoutingState` and `CustomGeometriesState`, each entry owns a
|
|
2037
|
+
* dedicated {@link TrafficAreaAnalyticsModule}, initialised lazily on first show.
|
|
2040
2038
|
*
|
|
2041
2039
|
* Live tile overlays (flow + incidents) live in {@link TrafficTilesState}.
|
|
2042
2040
|
*
|
|
@@ -2046,7 +2044,7 @@ declare class TrafficAreaAnalyticsState implements ShownEntriesSlice, StateSlice
|
|
|
2046
2044
|
private readonly _ttMap;
|
|
2047
2045
|
private _entries;
|
|
2048
2046
|
private _entryMode;
|
|
2049
|
-
/**
|
|
2047
|
+
/** The state change events, listed in {@link TrafficAreaAnalyticsStateEvents}. */
|
|
2050
2048
|
readonly events: StateEvents<TrafficAreaAnalyticsStateEvents>;
|
|
2051
2049
|
constructor(_ttMap: TomTomMap);
|
|
2052
2050
|
get entries(): readonly TrafficAreaAnalyticsEntry[];
|
|
@@ -2056,25 +2054,25 @@ declare class TrafficAreaAnalyticsState implements ShownEntriesSlice, StateSlice
|
|
|
2056
2054
|
setEntryMode(mode: EntryMode): Promise<void>;
|
|
2057
2055
|
findById(entryId: string): TrafficAreaAnalyticsEntry | undefined;
|
|
2058
2056
|
/**
|
|
2059
|
-
*
|
|
2060
|
-
*
|
|
2057
|
+
* Appends a new entry and suffixes its id on collision. In `single` mode it replaces every
|
|
2058
|
+
* older one, which is hidden and dropped from history.
|
|
2061
2059
|
*/
|
|
2062
2060
|
addEntry(data: TrafficAreaAnalytics, label: string, params: TrafficAreaAnalyticsParams, explicitId?: string): Promise<string>;
|
|
2063
2061
|
/**
|
|
2064
|
-
*
|
|
2065
|
-
* Throws on unknown id.
|
|
2062
|
+
* Initialises the entry's TrafficAreaAnalyticsModule lazily, wiring its config-change
|
|
2063
|
+
* events. Throws on unknown id.
|
|
2066
2064
|
*/
|
|
2067
2065
|
getEntryModule(entryId: string): Promise<TrafficAreaAnalyticsModule>;
|
|
2068
|
-
/**
|
|
2066
|
+
/** Renders the entry's analytics on its own module. In `single` mode, hides every other shown entry first. */
|
|
2069
2067
|
showEntry(entryId: string): Promise<void>;
|
|
2070
|
-
/**
|
|
2068
|
+
/** Hides the entry's analytics on its module. Does nothing if unknown or already hidden. */
|
|
2071
2069
|
hideEntry(entryId: string): Promise<void>;
|
|
2072
|
-
/**
|
|
2070
|
+
/** Hides a single entry, then drops it from history and emits `entries-change`. Does nothing for an unknown id. */
|
|
2073
2071
|
removeEntry(entryId: string): Promise<void>;
|
|
2074
2072
|
private _requireEntry;
|
|
2075
2073
|
/**
|
|
2076
|
-
*
|
|
2077
|
-
*
|
|
2074
|
+
* Hides every traffic-area-analytics entry on the map but keeps the history. Implements
|
|
2075
|
+
* {@link ClearableMapSlice}.
|
|
2078
2076
|
*/
|
|
2079
2077
|
clearShown(): Promise<void>;
|
|
2080
2078
|
reset(): void;
|
|
@@ -2095,7 +2093,7 @@ type IncidentsAnalysis = EntryAnalysis;
|
|
|
2095
2093
|
//#region src/state/traffic-incidents/clustering.d.ts
|
|
2096
2094
|
/** Direction a cluster's total delay is trending across recent snapshots. */
|
|
2097
2095
|
type ClusterTrend = 'growing' | 'fading' | 'steady' | 'new';
|
|
2098
|
-
/** Tuneable parameters for {@link runClustering}
|
|
2096
|
+
/** Tuneable parameters for {@link runClustering}, all optional with sensible defaults. */
|
|
2099
2097
|
type ClusteringParams = {
|
|
2100
2098
|
/** DBSCAN neighbourhood radius in km. Default: 0.5 */
|
|
2101
2099
|
eps?: number;
|
|
@@ -2107,13 +2105,13 @@ type ClusteringParams = {
|
|
|
2107
2105
|
preFilter?: {
|
|
2108
2106
|
/** Categories to exclude entirely. Default: `['roadworks', 'road-closed']` */
|
|
2109
2107
|
excludeCategories?: string[];
|
|
2110
|
-
/** Incidents with `delayInSeconds` below this are excluded
|
|
2108
|
+
/** Incidents in excludeCategories with `delayInSeconds` below this are excluded. Default: 1 (excludes 0-delay) */
|
|
2111
2109
|
minDelaySeconds?: number;
|
|
2112
2110
|
};
|
|
2113
2111
|
};
|
|
2114
2112
|
/** A single cluster produced by {@link runClustering}. */
|
|
2115
2113
|
type ClusterResult = {
|
|
2116
|
-
/**
|
|
2114
|
+
/** A stable identifier, reused across runs when member overlap >= 50%. */
|
|
2117
2115
|
id: string;
|
|
2118
2116
|
/** Geographic centre of the cluster `[lng, lat]`. */
|
|
2119
2117
|
centroid: [number, number];
|
|
@@ -2131,12 +2129,12 @@ type ClusterResult = {
|
|
|
2131
2129
|
primaryRoads: string[];
|
|
2132
2130
|
/** Most-frequent incident category across members (e.g. "jam"). */
|
|
2133
2131
|
primaryCategory: string;
|
|
2134
|
-
/** Trend across recent snapshots
|
|
2132
|
+
/** Trend across recent snapshots (see {@link classifyTrend}). */
|
|
2135
2133
|
trend: ClusterTrend;
|
|
2136
2134
|
/**
|
|
2137
|
-
* Rolling window of `totalDelaySeconds` across recent matched snapshots
|
|
2138
|
-
*
|
|
2139
|
-
* via the previous run
|
|
2135
|
+
* Rolling window of `totalDelaySeconds` across recent matched snapshots,
|
|
2136
|
+
* bounded to {@link TREND_WINDOW}. Internal trend state threaded forward
|
|
2137
|
+
* via the previous run, not display data.
|
|
2140
2138
|
*/
|
|
2141
2139
|
delaySamples: number[];
|
|
2142
2140
|
};
|
|
@@ -2146,7 +2144,7 @@ type ClusteringOutput = {
|
|
|
2146
2144
|
};
|
|
2147
2145
|
/**
|
|
2148
2146
|
* {@link runClustering} output plus the moment it was computed. The extra `sampledAt` lets the sandbox
|
|
2149
|
-
* `cluster()` primitive thread the trend window forward without the caller juggling timestamps
|
|
2147
|
+
* `cluster()` primitive thread the trend window forward without the caller juggling timestamps. It is
|
|
2150
2148
|
* stamped onto the result and read back off `previous` on the next call.
|
|
2151
2149
|
*
|
|
2152
2150
|
* @group Agent Toolkit
|
|
@@ -2178,8 +2176,8 @@ type IncidentSnapshot = {
|
|
|
2178
2176
|
incidents: TrafficIncident[];
|
|
2179
2177
|
};
|
|
2180
2178
|
/**
|
|
2181
|
-
*
|
|
2182
|
-
* poll failed and the timer
|
|
2179
|
+
* The lifecycle state of a per-entry incidents monitor. `stopped-error` means the last
|
|
2180
|
+
* poll failed and the timer was cleared. To retry, start the monitor again.
|
|
2183
2181
|
*
|
|
2184
2182
|
* @group Agent Toolkit
|
|
2185
2183
|
*/
|
|
@@ -2187,13 +2185,13 @@ type PollingStatus = 'idle' | 'running' | 'stopped-error';
|
|
|
2187
2185
|
//#endregion
|
|
2188
2186
|
//#region src/state/traffic-incidents/monitor/monitor.d.ts
|
|
2189
2187
|
/**
|
|
2190
|
-
*
|
|
2191
|
-
* `fetchIncidents` to `trafficIncidentDetails
|
|
2188
|
+
* The injected dependencies of an {@link IncidentMonitor}. Production code wires
|
|
2189
|
+
* `fetchIncidents` to `trafficIncidentDetails`. Tests can pass a deterministic fake
|
|
2192
2190
|
* and override the timer.
|
|
2193
2191
|
*
|
|
2194
|
-
* The fetcher returns
|
|
2195
|
-
*
|
|
2196
|
-
*
|
|
2192
|
+
* The fetcher returns only the incidents. The monitor stamps `takenAt` itself, so
|
|
2193
|
+
* every consumer of one tick (entry data, derived analyses, sandbox `now`) agrees
|
|
2194
|
+
* on the same canonical moment.
|
|
2197
2195
|
*
|
|
2198
2196
|
* @group Agent Toolkit
|
|
2199
2197
|
*/
|
|
@@ -2205,19 +2203,19 @@ type IncidentMonitorDeps = {
|
|
|
2205
2203
|
};
|
|
2206
2204
|
/**
|
|
2207
2205
|
* Events fired by {@link IncidentMonitor}. The slice subscribes once and re-emits
|
|
2208
|
-
* translated copies (`monitor-tick
|
|
2206
|
+
* translated copies (`monitor-tick`, `monitor-error`) keyed by entry id.
|
|
2209
2207
|
*/
|
|
2210
2208
|
type IncidentMonitorEvents = {
|
|
2211
2209
|
/** A poll succeeded. Payload: the fresh snapshot. */
|
|
2212
2210
|
tick: IncidentSnapshot;
|
|
2213
|
-
/** A poll failed
|
|
2211
|
+
/** A poll failed, so the monitor cleared its timer and moved to `stopped-error`. */
|
|
2214
2212
|
error: string;
|
|
2215
2213
|
};
|
|
2216
2214
|
/**
|
|
2217
|
-
*
|
|
2218
|
-
* and captured area.
|
|
2215
|
+
* A one-shot polling loop scoped to a single bbox. It owns its timer, status, error,
|
|
2216
|
+
* and captured area. Restarting it after `stop()` resets all state.
|
|
2219
2217
|
*
|
|
2220
|
-
* The monitor never knows about the entry that owns it
|
|
2218
|
+
* The monitor never knows about the entry that owns it. It surfaces ticks and errors
|
|
2221
2219
|
* through `events`, and the caller decides what to do with the snapshot.
|
|
2222
2220
|
*
|
|
2223
2221
|
* @group Agent Toolkit
|
|
@@ -2236,25 +2234,26 @@ declare class IncidentMonitor {
|
|
|
2236
2234
|
get monitoredArea(): MonitoredArea | undefined;
|
|
2237
2235
|
get error(): string | undefined;
|
|
2238
2236
|
/**
|
|
2239
|
-
*
|
|
2240
|
-
*
|
|
2241
|
-
*
|
|
2242
|
-
*
|
|
2237
|
+
* Whether the monitor is *currently* polling. Unlike {@link isActive}, it excludes
|
|
2238
|
+
* `stopped-error`, a state where the timer is gone but the monitor still carries an
|
|
2239
|
+
* unacknowledged error. Use this to ask "is the entry being polled right now", and
|
|
2240
|
+
* `isActive` to ask "is there anything to clean up".
|
|
2243
2241
|
*/
|
|
2244
2242
|
get isRunning(): boolean;
|
|
2245
|
-
/**
|
|
2243
|
+
/** Whether the monitor has any polling activity (running or stopped-error). */
|
|
2246
2244
|
get isActive(): boolean;
|
|
2247
2245
|
/**
|
|
2248
|
-
*
|
|
2249
|
-
* immediately
|
|
2246
|
+
* Starts polling. It captures `deps` for the lifetime of the run, fires the first tick
|
|
2247
|
+
* immediately unless `skipInitialTick` is set, then schedules an interval. Does nothing if
|
|
2248
|
+
* already running.
|
|
2250
2249
|
*
|
|
2251
|
-
* `skipInitialTick`
|
|
2252
|
-
* arming monitoring on the entry it just loaded
|
|
2253
|
-
* tick would
|
|
2250
|
+
* Set `skipInitialTick` if you just fetched the data yourself, as getTrafficIncidents does
|
|
2251
|
+
* when arming monitoring on the entry it just loaded. The entry is already fresh, so an eager
|
|
2252
|
+
* first tick would duplicate that fetch. Standalone callers leave it false, so the monitor
|
|
2254
2253
|
* produces an initial snapshot without waiting a full interval.
|
|
2255
2254
|
*/
|
|
2256
2255
|
start(area: MonitoredArea, deps: IncidentMonitorDeps, intervalMs?: number, skipInitialTick?: boolean): void;
|
|
2257
|
-
/**
|
|
2256
|
+
/** Stops polling and resets state. Does nothing when idle. */
|
|
2258
2257
|
stop(): void;
|
|
2259
2258
|
private _tick;
|
|
2260
2259
|
private _failed;
|
|
@@ -2263,12 +2262,12 @@ declare class IncidentMonitor {
|
|
|
2263
2262
|
//#endregion
|
|
2264
2263
|
//#region src/state/traffic-incidents/state.d.ts
|
|
2265
2264
|
/**
|
|
2266
|
-
* Dedicated per-entry clustering state. Incident clustering is
|
|
2265
|
+
* Dedicated per-entry clustering state. Incident clustering is **not** a generic analysis. It is typed,
|
|
2267
2266
|
* first-class incidents state with its own home here. `output` is the latest {@link SandboxClusteringOutput}
|
|
2268
|
-
* (the DBSCAN groups
|
|
2269
|
-
* `tools/state/clusters-runtime.ts`
|
|
2270
|
-
*
|
|
2271
|
-
* tools-agnostic.
|
|
2267
|
+
* (the DBSCAN groups and the moment they were computed). `recipe` is how to recompute it, and
|
|
2268
|
+
* `tools/state/clusters-runtime.ts` reuses it on each monitor tick so clusters stay live. `recipe` is
|
|
2269
|
+
* opaque here (a tools-layer `ClusterRecipe`). The slice never interprets it, which keeps the state
|
|
2270
|
+
* layer tools-agnostic.
|
|
2272
2271
|
*
|
|
2273
2272
|
* @group Agent Toolkit
|
|
2274
2273
|
*/
|
|
@@ -2327,7 +2326,7 @@ type TrafficIncidentsEntry = BaseEntry<TrafficIncident[]> & {
|
|
|
2327
2326
|
_tick?: number;
|
|
2328
2327
|
};
|
|
2329
2328
|
/**
|
|
2330
|
-
* Snapshot of an entry's focus subset
|
|
2329
|
+
* Snapshot of an entry's focus subset, returned by `getFocus` and carried by `focus-change`.
|
|
2331
2330
|
*
|
|
2332
2331
|
* @group Agent Toolkit
|
|
2333
2332
|
*/
|
|
@@ -2337,14 +2336,14 @@ type IncidentFocus = {
|
|
|
2337
2336
|
};
|
|
2338
2337
|
/**
|
|
2339
2338
|
* Events fired by {@link TrafficIncidentsState}. Subscribe via
|
|
2340
|
-
* `state.trafficIncidents.events.on(type, handler)
|
|
2339
|
+
* `state.trafficIncidents.events.on(type, handler)`, which returns an unsubscribe function.
|
|
2341
2340
|
*
|
|
2342
2341
|
* @group Agent Toolkit
|
|
2343
2342
|
*/
|
|
2344
2343
|
type TrafficIncidentsStateEvents = {
|
|
2345
2344
|
/**
|
|
2346
|
-
*
|
|
2347
|
-
* full snapshot after the change
|
|
2345
|
+
* An entry was added, replaced or removed, or `reset()` cleared the history. `entries` is the
|
|
2346
|
+
* full snapshot after the change, and `changedIds` lists the ids of the entries this change
|
|
2348
2347
|
* added, replaced in place, or removed. The {@link JobEngine} and the clustering re-run
|
|
2349
2348
|
* match these against the entries they depend on.
|
|
2350
2349
|
*/
|
|
@@ -2352,46 +2351,46 @@ type TrafficIncidentsStateEvents = {
|
|
|
2352
2351
|
entries: readonly TrafficIncidentsEntry[];
|
|
2353
2352
|
changedIds: readonly string[];
|
|
2354
2353
|
};
|
|
2355
|
-
/**
|
|
2354
|
+
/** The set of entries rendered on the map changed. */
|
|
2356
2355
|
'shown-change': ReadonlySet<TrafficIncidentsEntry['id']>;
|
|
2357
|
-
/**
|
|
2356
|
+
/** An entry's focus subset changed, or was cleared if `focus === null`. */
|
|
2358
2357
|
'focus-change': {
|
|
2359
2358
|
entryId: TrafficIncidentsEntry['id'];
|
|
2360
2359
|
focus: IncidentFocus | null;
|
|
2361
2360
|
};
|
|
2362
|
-
/**
|
|
2361
|
+
/** The display policy switched between `single` and `multiple`. */
|
|
2363
2362
|
'mode-change': EntryMode;
|
|
2364
|
-
/** A monitored entry produced a fresh snapshot
|
|
2363
|
+
/** A monitored entry's tick produced a fresh snapshot. */
|
|
2365
2364
|
'monitor-tick': {
|
|
2366
2365
|
entryId: TrafficIncidentsEntry['id'];
|
|
2367
2366
|
snap: IncidentSnapshot;
|
|
2368
2367
|
};
|
|
2369
|
-
/** A monitored entry's poll failed
|
|
2368
|
+
/** A monitored entry's poll failed, and the slice cleared the timer. */
|
|
2370
2369
|
'monitor-error': {
|
|
2371
2370
|
entryId: TrafficIncidentsEntry['id'];
|
|
2372
2371
|
error: string;
|
|
2373
2372
|
};
|
|
2374
2373
|
/**
|
|
2375
|
-
* Polling began on an entry (idle → running). Skipped
|
|
2376
|
-
*
|
|
2374
|
+
* Polling began on an entry (idle → running). Skipped if `startMonitoring`
|
|
2375
|
+
* found the monitor already running.
|
|
2377
2376
|
*/
|
|
2378
2377
|
'monitor-start': {
|
|
2379
2378
|
entryId: TrafficIncidentsEntry['id'];
|
|
2380
2379
|
};
|
|
2381
2380
|
/**
|
|
2382
|
-
* Polling halted on an entry. `reason: 'manual'` covers explicit
|
|
2383
|
-
* `stopMonitoring` and entry teardown (remove
|
|
2384
|
-
* `reason: 'error'` fires alongside `monitor-error
|
|
2385
|
-
* keep using `monitor-error
|
|
2381
|
+
* Polling halted on an entry. `reason: 'manual'` covers an explicit
|
|
2382
|
+
* `stopMonitoring` and entry teardown (remove, single-mode trim, reset).
|
|
2383
|
+
* `reason: 'error'` fires alongside `monitor-error`. Error-only listeners
|
|
2384
|
+
* keep using `monitor-error`, and lifecycle listeners can rely on this alone.
|
|
2386
2385
|
*/
|
|
2387
2386
|
'monitor-stop': {
|
|
2388
2387
|
entryId: TrafficIncidentsEntry['id'];
|
|
2389
2388
|
reason: 'manual' | 'error';
|
|
2390
2389
|
};
|
|
2391
2390
|
/**
|
|
2392
|
-
* An entry's clustering result
|
|
2393
|
-
* UI that renders cluster pins re-derives
|
|
2394
|
-
* async to the monitor tick, so the fresh result lands here a step later.
|
|
2391
|
+
* An entry's clustering result was set, recomputed on a tick, or cleared (`clusters === null`).
|
|
2392
|
+
* UI that renders cluster pins re-derives from this, not from `entries-change`, because the
|
|
2393
|
+
* clustering re-run is async to the monitor tick, so the fresh result lands here a step later.
|
|
2395
2394
|
*/
|
|
2396
2395
|
'clusters-change': {
|
|
2397
2396
|
entryId: TrafficIncidentsEntry['id'];
|
|
@@ -2399,11 +2398,11 @@ type TrafficIncidentsStateEvents = {
|
|
|
2399
2398
|
};
|
|
2400
2399
|
};
|
|
2401
2400
|
/**
|
|
2402
|
-
* State for traffic incidents
|
|
2403
|
-
* TrafficIncidentDetailsModule. Each entry can be a separate area
|
|
2401
|
+
* State for traffic incidents, with entry history and map rendering via per-entry
|
|
2402
|
+
* TrafficIncidentDetailsModule. Each entry can be a separate area, and in the default
|
|
2404
2403
|
* `multiple` mode several entries can render at once.
|
|
2405
2404
|
*
|
|
2406
|
-
* Each entry owns its own module
|
|
2405
|
+
* Each entry owns its own module, initialised lazily on first show, plus an optional
|
|
2407
2406
|
* background monitor. Subscribe to changes via `events.on('...')`.
|
|
2408
2407
|
*
|
|
2409
2408
|
* @group Agent Toolkit
|
|
@@ -2413,84 +2412,84 @@ declare class TrafficIncidentsState implements StateSlice {
|
|
|
2413
2412
|
private _entries;
|
|
2414
2413
|
private _entryMode;
|
|
2415
2414
|
private readonly _clusters;
|
|
2416
|
-
/**
|
|
2415
|
+
/** The state change events, listed in {@link TrafficIncidentsStateEvents}. */
|
|
2417
2416
|
readonly events: StateEvents<TrafficIncidentsStateEvents>;
|
|
2418
2417
|
constructor(_ttMap: TomTomMap);
|
|
2419
2418
|
get entries(): readonly TrafficIncidentsEntry[];
|
|
2420
2419
|
/**
|
|
2421
|
-
*
|
|
2422
|
-
* simultaneously
|
|
2423
|
-
*
|
|
2420
|
+
* The display policy. `multiple` (default) keeps every history entry available to render
|
|
2421
|
+
* simultaneously. `single` allows at most one entry on the map at a time and trims the
|
|
2422
|
+
* history to the latest entry whenever it's set.
|
|
2424
2423
|
*/
|
|
2425
2424
|
get entryMode(): EntryMode;
|
|
2426
2425
|
/**
|
|
2427
|
-
*
|
|
2428
|
-
*
|
|
2429
|
-
* mode hasn't changed.
|
|
2426
|
+
* Switches the display policy. Moving from `multiple` to `single` hides every entry older
|
|
2427
|
+
* than the latest, drops them from history, and emits `entries-change`. Does nothing if
|
|
2428
|
+
* the mode hasn't changed.
|
|
2430
2429
|
*/
|
|
2431
2430
|
setEntryMode(mode: EntryMode): Promise<void>;
|
|
2432
2431
|
/** Set of entries currently rendered on the map. */
|
|
2433
2432
|
get shownEntryIds(): ReadonlySet<TrafficIncidentsEntry['id']>;
|
|
2434
2433
|
/**
|
|
2435
|
-
*
|
|
2436
|
-
* older one
|
|
2437
|
-
* data was captured
|
|
2438
|
-
* data ↔ derived analyses) are byte-equal.
|
|
2434
|
+
* Appends a new entry to the history and returns its assigned id. In `single` mode the new
|
|
2435
|
+
* entry replaces every older one and tears down their modules and monitors. `sampledAt` is
|
|
2436
|
+
* the moment the data was captured. Pass one canonical value per "moment" so future joins
|
|
2437
|
+
* (entry data ↔ derived analyses) are byte-equal.
|
|
2439
2438
|
*/
|
|
2440
2439
|
addIncidentsEntry(data: TrafficIncident[], params: TrafficIncidentDetailsByBBoxParams & {
|
|
2441
2440
|
bbox: BBox;
|
|
2442
2441
|
}, label: string, sampledAt: number, explicitId?: string): Promise<string>;
|
|
2443
2442
|
/**
|
|
2444
|
-
*
|
|
2445
|
-
*
|
|
2446
|
-
*
|
|
2447
|
-
*
|
|
2448
|
-
*
|
|
2449
|
-
*
|
|
2450
|
-
*
|
|
2451
|
-
* Returns true on success, false
|
|
2443
|
+
* Replaces an entry's data in place and repaints its module without moving the camera.
|
|
2444
|
+
* The per-entry monitor tick uses it so incident geometries and any open detail panel
|
|
2445
|
+
* stay in sync with the freshest snapshot. `sampledAt` is the canonical moment for this
|
|
2446
|
+
* update, propagated to the entry timestamp before the `entries-change` emit. That emit
|
|
2447
|
+
* drives analysis replay. The session-level {@link JobEngine} re-runs every job bound to
|
|
2448
|
+
* this entry off the change **asynchronously**, a microtask later. The slice itself owns
|
|
2449
|
+
* no analysis logic.
|
|
2450
|
+
* Returns true on success, false if the entry is unknown.
|
|
2452
2451
|
*/
|
|
2453
2452
|
replaceEntryData(entryId: TrafficIncidentsEntry['id'], data: TrafficIncident[], sampledAt: number): Promise<boolean>;
|
|
2454
2453
|
/**
|
|
2455
|
-
*
|
|
2456
|
-
* clicks
|
|
2454
|
+
* Returns the entry's TrafficIncidentDetailsModule, created on first call. To handle
|
|
2455
|
+
* clicks, subscribe on the returned module via `module.events.on('click', ...)`.
|
|
2457
2456
|
* Throws on unknown entry id.
|
|
2458
2457
|
*/
|
|
2459
2458
|
getEntryModule(entryId: TrafficIncidentsEntry['id']): Promise<TrafficIncidentDetailsModule>;
|
|
2460
2459
|
/**
|
|
2461
|
-
*
|
|
2462
|
-
*
|
|
2463
|
-
*
|
|
2460
|
+
* Renders an entry on the map. Lazy-inits its module, pushes the entry's incidents, and
|
|
2461
|
+
* fits the camera to the entry's bbox if `fitBounds` is true. Emits `shown-change` once
|
|
2462
|
+
* the entry transitions to shown.
|
|
2464
2463
|
*/
|
|
2465
2464
|
showEntry(entryId: TrafficIncidentsEntry['id'], fitBounds?: boolean): Promise<void>;
|
|
2466
2465
|
/**
|
|
2467
|
-
*
|
|
2468
|
-
* entry for cheap re-show.
|
|
2466
|
+
* Hides an entry by clearing its module and dropping focus. The module reference stays
|
|
2467
|
+
* on the entry for cheap re-show. Does nothing if the entry is unknown or already hidden.
|
|
2469
2468
|
*/
|
|
2470
2469
|
hideEntry(entryId: TrafficIncidentsEntry['id']): Promise<void>;
|
|
2471
2470
|
/**
|
|
2472
|
-
*
|
|
2473
|
-
*
|
|
2474
|
-
*
|
|
2471
|
+
* Drops an entry from history, hiding it from the map and stopping any monitor. Emits
|
|
2472
|
+
* `entries-change`, plus `shown-change` if the entry was shown. Does nothing if the id
|
|
2473
|
+
* is unknown.
|
|
2475
2474
|
*/
|
|
2476
2475
|
removeEntry(entryId: TrafficIncidentsEntry['id']): Promise<void>;
|
|
2477
2476
|
/**
|
|
2478
|
-
*
|
|
2479
|
-
* unknown
|
|
2480
|
-
* and its monitor-tick re-run (`tools/state/clusters-runtime.ts`).
|
|
2477
|
+
* Stores or replaces an entry's clustering record and emits `clusters-change`. Does nothing if the
|
|
2478
|
+
* entry is unknown, because clusters are entry-scoped and an orphan record is meaningless.
|
|
2479
|
+
* `clusterIncidents` and its monitor-tick re-run (`tools/state/clusters-runtime.ts`) call it.
|
|
2481
2480
|
*/
|
|
2482
2481
|
setClusters(entryId: TrafficIncidentsEntry['id'], record: ClustersRecord): void;
|
|
2483
|
-
/**
|
|
2482
|
+
/** The latest clustering output for an entry, or undefined if none was computed. */
|
|
2484
2483
|
getClusters(entryId: TrafficIncidentsEntry['id']): SandboxClusteringOutput | undefined;
|
|
2485
|
-
/**
|
|
2484
|
+
/** The full clustering record (recipe and output) for an entry, which the re-run reads back. */
|
|
2486
2485
|
getClustersRecord(entryId: TrafficIncidentsEntry['id']): ClustersRecord | undefined;
|
|
2487
|
-
/**
|
|
2486
|
+
/** Drops an entry's clustering and emits `clusters-change` with `null`. Does nothing if none is stored. */
|
|
2488
2487
|
clearClusters(entryId: TrafficIncidentsEntry['id']): void;
|
|
2489
|
-
/** Snapshot of an entry's focus subset, or null
|
|
2488
|
+
/** Snapshot of an entry's focus subset, or null if no focus is active or the entry is unknown. */
|
|
2490
2489
|
getFocus(entryId: TrafficIncidentsEntry['id']): IncidentFocus | null;
|
|
2491
2490
|
/**
|
|
2492
|
-
*
|
|
2493
|
-
* incidents
|
|
2491
|
+
* Sets the focus subset on a specific entry. Filters ids against the entry's current
|
|
2492
|
+
* incidents, dropping unknown ones, and pushes the result onto the entry's module.
|
|
2494
2493
|
* Returns the kept count and any dropped ids.
|
|
2495
2494
|
*/
|
|
2496
2495
|
setFocus(entryId: TrafficIncidentsEntry['id'], ids: readonly string[], reason?: string): {
|
|
@@ -2499,46 +2498,46 @@ declare class TrafficIncidentsState implements StateSlice {
|
|
|
2499
2498
|
};
|
|
2500
2499
|
clearFocus(entryId: TrafficIncidentsEntry['id']): void;
|
|
2501
2500
|
/**
|
|
2502
|
-
* The focused incidents in the order passed to {@link setFocus}
|
|
2503
|
-
* active on the entry or
|
|
2504
|
-
*
|
|
2501
|
+
* The focused incidents in the order passed to {@link setFocus}, or empty if no focus is
|
|
2502
|
+
* active on the entry or the entry is unknown. UI layers use it to step through the
|
|
2503
|
+
* focused subset (prev/next).
|
|
2505
2504
|
*/
|
|
2506
2505
|
focusedFeatures(entryId: TrafficIncidentsEntry['id']): TrafficIncident[];
|
|
2507
2506
|
/**
|
|
2508
|
-
*
|
|
2509
|
-
* indices so callers can pass raw prev/next counters.
|
|
2510
|
-
* focus. Line geometries fitBounds
|
|
2507
|
+
* Flies the camera to the i-th focused incident on an entry (0-based). Wraps out-of-range
|
|
2508
|
+
* indices, so callers can pass raw prev/next counters. Does nothing if the entry has no active
|
|
2509
|
+
* focus. Line geometries use fitBounds, points flyTo with a sensible zoom.
|
|
2511
2510
|
*/
|
|
2512
2511
|
navigateFocus(entryId: TrafficIncidentsEntry['id'], index: number): void;
|
|
2513
2512
|
/**
|
|
2514
|
-
*
|
|
2515
|
-
*
|
|
2513
|
+
* Walks entries newest-first to find the one that holds an incident with this id. UI layers
|
|
2514
|
+
* use it when they hold an incident id without remembering which entry produced it.
|
|
2516
2515
|
*/
|
|
2517
2516
|
findEntryWithIncident(incidentId: string): TrafficIncidentsEntry | undefined;
|
|
2518
2517
|
/**
|
|
2519
|
-
*
|
|
2520
|
-
* once, then delegates to {@link IncidentMonitor.start}.
|
|
2518
|
+
* Starts polling for an entry. Lazy-creates an {@link IncidentMonitor}, wires its events
|
|
2519
|
+
* once, then delegates to {@link IncidentMonitor.start}. Does nothing if polling is already
|
|
2521
2520
|
* running. Throws on unknown entry id.
|
|
2522
2521
|
*/
|
|
2523
2522
|
startMonitoring(entryId: TrafficIncidentsEntry['id'], area: MonitoredArea, deps: IncidentMonitorDeps, opts?: {
|
|
2524
2523
|
intervalMs?: number;
|
|
2525
2524
|
skipInitialTick?: boolean;
|
|
2526
2525
|
}): void;
|
|
2527
|
-
/**
|
|
2526
|
+
/** Stops polling. Does nothing if idle or unknown. */
|
|
2528
2527
|
stopMonitoring(entryId: TrafficIncidentsEntry['id']): void;
|
|
2529
2528
|
/**
|
|
2530
|
-
*
|
|
2531
|
-
* `stopped-error` returns false here so the start tool can report a truthful
|
|
2529
|
+
* Whether the entry is *currently* being polled. A monitor stuck in
|
|
2530
|
+
* `stopped-error` returns false here, so the start tool can report a truthful
|
|
2532
2531
|
* `alreadyRunning` and a fresh `start` call actually re-arms the timer
|
|
2533
|
-
* instead of silently
|
|
2532
|
+
* instead of silently doing nothing.
|
|
2534
2533
|
*/
|
|
2535
2534
|
isMonitored(entryId: TrafficIncidentsEntry['id']): boolean;
|
|
2536
2535
|
private _createMonitorForEntry;
|
|
2537
2536
|
private _requireEntry;
|
|
2538
2537
|
private _teardownEntry;
|
|
2539
2538
|
/**
|
|
2540
|
-
*
|
|
2541
|
-
*
|
|
2539
|
+
* Hides every traffic-incidents entry on the map but keeps the history. Implements
|
|
2540
|
+
* {@link ClearableMapSlice}.
|
|
2542
2541
|
*/
|
|
2543
2542
|
clearShown(): Promise<void>;
|
|
2544
2543
|
reset(): void;
|
|
@@ -2546,9 +2545,9 @@ declare class TrafficIncidentsState implements StateSlice {
|
|
|
2546
2545
|
//#endregion
|
|
2547
2546
|
//#region src/state/traffic-tiles/state.d.ts
|
|
2548
2547
|
/**
|
|
2549
|
-
* State for traffic tile overlays
|
|
2550
|
-
* raster/tile layers that the user toggles on top of the base map
|
|
2551
|
-
* per-result rendering for incident *features*
|
|
2548
|
+
* State for traffic tile overlays, the flow tiles and incident overlay tiles. These are
|
|
2549
|
+
* raster/tile layers that the user toggles on top of the base map. Result caching and
|
|
2550
|
+
* per-result rendering for incident *features* live in {@link TrafficIncidentsState},
|
|
2552
2551
|
* and analytics aggregations in {@link TrafficAreaAnalyticsState}.
|
|
2553
2552
|
*
|
|
2554
2553
|
* @group Agent Toolkit
|
|
@@ -2585,15 +2584,15 @@ export declare const hidePreviousShownEntries: (slice: ShownEntriesSlice, keepEn
|
|
|
2585
2584
|
*/
|
|
2586
2585
|
export type QueryAs = 'poi' | 'place';
|
|
2587
2586
|
/**
|
|
2588
|
-
* Resolves a query string to up to `limit` Places
|
|
2589
|
-
* otherwise.
|
|
2587
|
+
* Resolves a query string to up to `limit` Places, using POI search when `queryAs === 'poi'`,
|
|
2588
|
+
* otherwise geocoding. The optional `bias` narrows the search to a region.
|
|
2590
2589
|
*/
|
|
2591
2590
|
export declare const locatePlaces: (query: string, queryAs: QueryAs, options: {
|
|
2592
2591
|
limit: number;
|
|
2593
2592
|
bias?: GeoBias;
|
|
2594
2593
|
}, execOptions?: ToolExecuteOptions) => Promise<Place[]>;
|
|
2595
2594
|
/**
|
|
2596
|
-
*
|
|
2595
|
+
* Finds the best match for a query as the `locatePlace` tool does, for a custom tool that needs one place.
|
|
2597
2596
|
* A failed or cancelled request rejects, so catch it in `execute`.
|
|
2598
2597
|
*
|
|
2599
2598
|
* @param bias - Favours results near a position, such as the map centre from {@link getViewportBias}.
|
|
@@ -2616,7 +2615,7 @@ export declare const locatePlace: (query: string, queryAs: QueryAs, bias?: GeoBi
|
|
|
2616
2615
|
//#region src/tools/shared/location-input.d.ts
|
|
2617
2616
|
/** @ignore */
|
|
2618
2617
|
export type ResolvedLocation = {
|
|
2619
|
-
/**
|
|
2618
|
+
/** A resolved Place with address metadata, or a bare [lng, lat] tuple. */
|
|
2620
2619
|
place: WaypointLike;
|
|
2621
2620
|
position: Position;
|
|
2622
2621
|
name: string;
|
|
@@ -2749,8 +2748,8 @@ export type ResolvedEntries = {
|
|
|
2749
2748
|
trafficAreaAnalytics: TrafficAreaAnalyticsEntry[];
|
|
2750
2749
|
byod: BYODEntry[];
|
|
2751
2750
|
};
|
|
2752
|
-
/** Newest `timestamp` across every resolved source entry, or undefined when none carry one
|
|
2753
|
-
* canonical `sampledAt` for a recurring sandbox run over these inputs. */
|
|
2751
|
+
/** Newest `timestamp` across every resolved source entry, or undefined when none carry one, as
|
|
2752
|
+
* the canonical `sampledAt` for a recurring sandbox run over these inputs. */
|
|
2754
2753
|
export declare const latestTimestamp: (resolved: ResolvedEntries) => number | undefined;
|
|
2755
2754
|
/**
|
|
2756
2755
|
* Sandbox-facing inputs. Each kind is exposed as a single `<kind>ByEntry` record keyed by the entry id
|
|
@@ -2775,9 +2774,9 @@ export type SandboxInputs = {
|
|
|
2775
2774
|
incidentsByEntry: Record<string, TrafficIncident[]> | undefined;
|
|
2776
2775
|
/**
|
|
2777
2776
|
* Per-source polygons collected from every requested source (place / places / ranges / customGeometries).
|
|
2778
|
-
*
|
|
2779
|
-
* `place`
|
|
2780
|
-
* its origin in `properties._source` (`{ kind, id }`).
|
|
2777
|
+
* The key is the tagged source `${kind}:${id}`, not a bare id, since the same id can recur across kinds
|
|
2778
|
+
* (e.g. a `place` and a `customGeometries` entry). This keeps the kind unambiguous. Each feature also
|
|
2779
|
+
* self-describes its origin in `properties._source` (`{ kind, id }`).
|
|
2781
2780
|
*/
|
|
2782
2781
|
geometriesByEntry: Record<string, PolygonFeature[]> | undefined;
|
|
2783
2782
|
/**
|
|
@@ -2787,7 +2786,7 @@ export type SandboxInputs = {
|
|
|
2787
2786
|
*/
|
|
2788
2787
|
trafficAreaAnalyticsByEntry: Record<string, TrafficAreaAnalytics> | undefined;
|
|
2789
2788
|
/**
|
|
2790
|
-
* Per-entry BYOD, keyed by entry id. Each value is a FeatureCollection
|
|
2789
|
+
* Per-entry BYOD, keyed by entry id. Each value is a FeatureCollection. Mixed geometry types are normal
|
|
2791
2790
|
* (BYOD layers can be Point / LineString / Polygon).
|
|
2792
2791
|
*/
|
|
2793
2792
|
byodByEntry: Record<string, FeatureCollection$1> | undefined;
|
|
@@ -2835,21 +2834,20 @@ export declare const prepareMultiInputs: (ids: MultiInputIds, state: ToolState)
|
|
|
2835
2834
|
*/
|
|
2836
2835
|
export declare const BY_ENTRY_VIEWS_DOC: string;
|
|
2837
2836
|
/**
|
|
2838
|
-
* Names injected into the sandbox by analyseData
|
|
2837
|
+
* Names injected into the sandbox by analyseData, processData, createTracker and clusterIncidents, in fixed order.
|
|
2839
2838
|
*
|
|
2840
2839
|
* @ignore
|
|
2841
2840
|
*/
|
|
2842
2841
|
export declare const MULTI_INPUT_SANDBOX_PARAMS: readonly ["placesByEntry", "routesByEntry", "incidentsByEntry", "geometriesByEntry", "trafficAreaAnalyticsByEntry", "byodByEntry", "h3", "turf", "routeUtils", "cluster"];
|
|
2843
2842
|
/**
|
|
2844
2843
|
* Common "tools available in the sandbox" prompt section, shared verbatim by
|
|
2845
|
-
* analyseData and
|
|
2846
|
-
*
|
|
2847
|
-
*
|
|
2848
|
-
* the cross-kind turf cheat-sheet ({@link CROSS_KIND_OPS_DOC})
|
|
2849
|
-
* ({@link ROUTE_UTILS_DOC})
|
|
2850
|
-
*
|
|
2851
|
-
*
|
|
2852
|
-
* a block ending in a blank line, ready to drop straight into either tool's `code` doc.
|
|
2844
|
+
* analyseData, processData, clusterIncidents and createTracker so the injected-library docs
|
|
2845
|
+
* live in ONE place and the tools never drift. It documents `turf` / `h3` (base usage rules
|
|
2846
|
+
* via {@link buildSandboxCodePrompt}) and the per-entry input views. With `scoped`, the helper
|
|
2847
|
+
* docs follow the active kinds: the cross-kind turf cheat-sheet ({@link CROSS_KIND_OPS_DOC})
|
|
2848
|
+
* when more than one is active, `routeUtils` ({@link ROUTE_UTILS_DOC}) with `routes`, and
|
|
2849
|
+
* `cluster` with `incidents`. Returns a block ending in a blank line, ready to drop straight
|
|
2850
|
+
* into a tool's `code` doc.
|
|
2853
2851
|
*
|
|
2854
2852
|
* @ignore
|
|
2855
2853
|
*/
|
|
@@ -3224,7 +3222,7 @@ export declare const areaWhereSchema: z.ZodObject<{
|
|
|
3224
3222
|
widthMeters: z.ZodNumber;
|
|
3225
3223
|
}, z.core.$strip>>;
|
|
3226
3224
|
}, z.core.$strip>;
|
|
3227
|
-
/** The `where` fields resolve-where.ts resolves
|
|
3225
|
+
/** The `where` fields resolve-where.ts resolves, inferred from {@link areaWhereSchema}. */
|
|
3228
3226
|
export type AreaWhere = z.infer<typeof areaWhereSchema>;
|
|
3229
3227
|
//#endregion
|
|
3230
3228
|
//#region src/tools/shared/resolve-where.d.ts
|
|
@@ -3255,8 +3253,8 @@ export declare const resolveGlobal: () => ResolvedBias;
|
|
|
3255
3253
|
export type ResolvedArea = {
|
|
3256
3254
|
bbox: BBox;
|
|
3257
3255
|
polygon?: Polygon | MultiPolygon;
|
|
3258
|
-
/** The
|
|
3259
|
-
* data was actually loaded for,
|
|
3256
|
+
/** The grounded match label (`freeformAddress, <countryCode>` for a `query` area), meaning what the
|
|
3257
|
+
* data was actually loaded for, not the query echo. It lets a consumer surface where a query really
|
|
3260
3258
|
* resolved. */
|
|
3261
3259
|
label?: string;
|
|
3262
3260
|
source: AreaSource;
|
|
@@ -3283,12 +3281,12 @@ export declare const isResolveError: (r: unknown) => r is ResolveError;
|
|
|
3283
3281
|
* @module agent-toolkit-tools
|
|
3284
3282
|
*
|
|
3285
3283
|
* The `routeUtils` namespace injected into sandboxed model-authored code, so a routes input can be
|
|
3286
|
-
* sliced and measured without re-implementing it.
|
|
3287
|
-
* (`sandbox/sdk-utils-worker-entry.ts`) is bundled standalone at SDK build time,
|
|
3284
|
+
* sliced and measured without re-implementing it. It has its own module because the worker entry
|
|
3285
|
+
* (`sandbox/sdk-utils-worker-entry.ts`) is bundled standalone at SDK build time, and importing it
|
|
3288
3286
|
* from `multi-input.ts` would pull that module's prompt text into the worker bundle.
|
|
3289
3287
|
*
|
|
3290
|
-
* Every function here depends only on `@turf/turf`
|
|
3291
|
-
* pure local helpers, which
|
|
3288
|
+
* Every function here depends only on `@turf/turf` (available in the worker as `self.turf`) and
|
|
3289
|
+
* pure local helpers, which makes the set portable into the sandbox.
|
|
3292
3290
|
*/
|
|
3293
3291
|
/**
|
|
3294
3292
|
* @ignore
|
|
@@ -3308,8 +3306,8 @@ export declare const routeUtils: {
|
|
|
3308
3306
|
*
|
|
3309
3307
|
* Compact schema documentation for the `Route` properties shape, reused by
|
|
3310
3308
|
* every tool whose LLM-authored code reads a Routes FeatureCollection
|
|
3311
|
-
* (`analyseData`, `processData`)
|
|
3312
|
-
* Only the non-GeoJSON-standard bits are spelled out
|
|
3309
|
+
* (`analyseData`, `processData`), injected per entry as `routesByEntry[id]`.
|
|
3310
|
+
* Only the non-GeoJSON-standard bits are spelled out, since `Route` is a LineString Feature.
|
|
3313
3311
|
*/
|
|
3314
3312
|
/** @ignore */
|
|
3315
3313
|
export declare const ROUTES_SCHEMA_DOC: string;
|
|
@@ -3348,7 +3346,7 @@ export declare const showResultsOnMap: (state: ToolState, placesEntryIds: readon
|
|
|
3348
3346
|
//#endregion
|
|
3349
3347
|
//#region src/tools/shared/tool-state-where-context.d.ts
|
|
3350
3348
|
/** Adapts the live `ToolState` to the narrow `WhereContext` the resolver depends on. Keeping this
|
|
3351
|
-
* mapping in one place
|
|
3349
|
+
* mapping in one place lets resolveAreas stay testable without a ToolState. */
|
|
3352
3350
|
export declare const toolStateToWhereContext: (state: ToolState, options?: ToolExecuteOptions) => WhereContext;
|
|
3353
3351
|
//#endregion
|
|
3354
3352
|
//#region src/tools/shared/viewport-bias.d.ts
|
|
@@ -3359,8 +3357,8 @@ export declare const toolStateToWhereContext: (state: ToolState, options?: ToolE
|
|
|
3359
3357
|
*/
|
|
3360
3358
|
export declare const MIN_VIEWPORT_BIAS_ZOOM = 6;
|
|
3361
3359
|
/**
|
|
3362
|
-
*
|
|
3363
|
-
* {@link locatePlace}'s `bias`. Below `minZoom
|
|
3360
|
+
* Returns the map centre, to favour search results in view. Pass it as `{ position }` to a service's `geoBias`
|
|
3361
|
+
* or to {@link locatePlace}'s `bias`. Below `minZoom`, the view is too wide to say where the user means.
|
|
3364
3362
|
*
|
|
3365
3363
|
* @param map - The agent's base-map slice, `state.baseMap` in a tool's `execute`.
|
|
3366
3364
|
* @returns The centre as `[longitude, latitude]`, or `undefined` below `minZoom`.
|
|
@@ -3425,26 +3423,26 @@ type CustomGeometriesEntry = BaseEntry<PolygonFeature[]> & {
|
|
|
3425
3423
|
*/
|
|
3426
3424
|
type CustomGeometriesStateEvents = {
|
|
3427
3425
|
/**
|
|
3428
|
-
*
|
|
3429
|
-
* the change
|
|
3426
|
+
* An entry was added, or `reset()` cleared the history. `entries` is the full snapshot after
|
|
3427
|
+
* the change, and `changedIds` lists the ids of the entries this change added, replaced in
|
|
3430
3428
|
* place, or removed.
|
|
3431
3429
|
*/
|
|
3432
3430
|
'entries-change': {
|
|
3433
3431
|
entries: readonly CustomGeometriesEntry[];
|
|
3434
3432
|
changedIds: readonly string[];
|
|
3435
3433
|
};
|
|
3436
|
-
/**
|
|
3434
|
+
/** The set of entries rendered on the map changed. */
|
|
3437
3435
|
'shown-change': ReadonlySet<string>;
|
|
3438
|
-
/**
|
|
3436
|
+
/** The display policy switched between `single` and `multiple`. */
|
|
3439
3437
|
'mode-change': EntryMode;
|
|
3440
3438
|
};
|
|
3441
3439
|
/**
|
|
3442
|
-
*
|
|
3440
|
+
* The state for derived or custom geometries, the output of `processData` and any future
|
|
3443
3441
|
* polygon-producing tool whose result doesn't belong to a place or a reachable-range entry.
|
|
3444
3442
|
*
|
|
3445
|
-
*
|
|
3446
|
-
*
|
|
3447
|
-
*
|
|
3443
|
+
* As in {@link RangeState}, each entry owns a dedicated GeometriesModule, initialised lazily
|
|
3444
|
+
* on first show. Provenance metadata captures the input sources (tagged ids) and the
|
|
3445
|
+
* operation that produced the polygons.
|
|
3448
3446
|
*
|
|
3449
3447
|
* @group Agent Toolkit
|
|
3450
3448
|
*/
|
|
@@ -3452,7 +3450,7 @@ declare class CustomGeometriesState implements ShownEntriesSlice, StateSlice {
|
|
|
3452
3450
|
private readonly _ttMap;
|
|
3453
3451
|
private _entries;
|
|
3454
3452
|
private _entryMode;
|
|
3455
|
-
/**
|
|
3453
|
+
/** The state change events, listed in {@link CustomGeometriesStateEvents}. */
|
|
3456
3454
|
readonly events: StateEvents<CustomGeometriesStateEvents>;
|
|
3457
3455
|
constructor(_ttMap: TomTomMap);
|
|
3458
3456
|
get entries(): readonly CustomGeometriesEntry[];
|
|
@@ -3460,40 +3458,40 @@ declare class CustomGeometriesState implements ShownEntriesSlice, StateSlice {
|
|
|
3460
3458
|
/** Set of custom-geometries entry ids currently rendered on the map. */
|
|
3461
3459
|
get shownEntryIds(): ReadonlySet<string>;
|
|
3462
3460
|
/**
|
|
3463
|
-
*
|
|
3464
|
-
* by side
|
|
3461
|
+
* The display policy. `multiple` (default) lets several derived-geometry entries render
|
|
3462
|
+
* side by side. `single` allows at most one entry on the map, and switching to it hides
|
|
3465
3463
|
* older entries.
|
|
3466
3464
|
*/
|
|
3467
3465
|
get entryMode(): EntryMode;
|
|
3468
3466
|
setEntryMode(mode: EntryMode): Promise<void>;
|
|
3469
3467
|
findById(entryId: string): CustomGeometriesEntry | undefined;
|
|
3470
3468
|
/**
|
|
3471
|
-
*
|
|
3472
|
-
*
|
|
3469
|
+
* Appends a new entry and returns its assigned id. If `explicitId` collides, the slice adds a
|
|
3470
|
+
* suffix (`-2`, `-3`, ...). In `single` mode the new entry replaces every older one.
|
|
3473
3471
|
*/
|
|
3474
3472
|
addEntry(features: PolygonFeature<CommonPlaceProps>[], provenance: CustomGeometriesEntry['provenance'], label: string, explicitId?: string): Promise<string>;
|
|
3475
|
-
/**
|
|
3473
|
+
/** Initialises the entry's GeometriesModule lazily and applies the requested fill style. */
|
|
3476
3474
|
getEntryGeometriesModule(entryId: string, fillStyle?: GeometryFillStyle): Promise<GeometriesModule>;
|
|
3477
3475
|
/**
|
|
3478
|
-
*
|
|
3479
|
-
* - `'replace'` (default)
|
|
3480
|
-
* entry's module
|
|
3481
|
-
* - `'add'`
|
|
3482
|
-
*
|
|
3476
|
+
* Renders the entry's polygons. `mode` applies to this entry's own layer only:
|
|
3477
|
+
* - `'replace'` (default) shows exactly `entry.data` and clears whatever the
|
|
3478
|
+
* entry's module rendered before.
|
|
3479
|
+
* - `'add'` merges `entry.data` with the polygons shown on this entry's layer,
|
|
3480
|
+
* deduped by feature id. It matters mostly when re-showing the same entry.
|
|
3483
3481
|
*
|
|
3484
|
-
*
|
|
3485
|
-
*
|
|
3486
|
-
*
|
|
3482
|
+
* Other entries are handled separately. With `entryMode === 'single'`, other shown
|
|
3483
|
+
* entries are hidden first. Otherwise the caller uses `hideEntry` or the tools'
|
|
3484
|
+
* `hidePreviousEntries` option.
|
|
3487
3485
|
*/
|
|
3488
3486
|
showEntry(entryId: string, fillStyle?: GeometryFillStyle, mode?: 'add' | 'replace'): Promise<void>;
|
|
3489
3487
|
private _hideOthersUnderSingleMode;
|
|
3490
3488
|
hideEntry(entryId: string): Promise<void>;
|
|
3491
|
-
/**
|
|
3489
|
+
/** Clears an entry's module, then drops the entry from history. Does nothing for an unknown id. */
|
|
3492
3490
|
removeEntry(entryId: string): Promise<void>;
|
|
3493
3491
|
private _requireEntry;
|
|
3494
3492
|
/**
|
|
3495
|
-
*
|
|
3496
|
-
*
|
|
3493
|
+
* Hides every custom-geometries entry on the map but keeps the history. Implements
|
|
3494
|
+
* {@link ClearableMapSlice}.
|
|
3497
3495
|
*/
|
|
3498
3496
|
clearShown(): Promise<void>;
|
|
3499
3497
|
reset(): void;
|
|
@@ -3501,16 +3499,16 @@ declare class CustomGeometriesState implements ShownEntriesSlice, StateSlice {
|
|
|
3501
3499
|
//#endregion
|
|
3502
3500
|
//#region src/state/state.d.ts
|
|
3503
3501
|
/**
|
|
3504
|
-
*
|
|
3505
|
-
* map at once
|
|
3506
|
-
* `single` automatically drops every entry except the latest
|
|
3502
|
+
* The per-slice display policy. With `multiple` (default), several history entries can be on the
|
|
3503
|
+
* map at once. With `single`, only the most recent one stays. Switching from `multiple` to
|
|
3504
|
+
* `single` automatically drops every entry except the latest and clears their modules, so
|
|
3507
3505
|
* the map matches the new policy immediately.
|
|
3508
3506
|
*
|
|
3509
3507
|
* @group Agent Toolkit
|
|
3510
3508
|
*/
|
|
3511
3509
|
type EntryMode = 'single' | 'multiple';
|
|
3512
3510
|
/**
|
|
3513
|
-
*
|
|
3511
|
+
* A state slice that owns a history of entries and can be set to `single` or `multiple`
|
|
3514
3512
|
* mode. Every {@link ToolState} slice with `setEntryMode` implements this shape, which lets
|
|
3515
3513
|
* callers (the `setEntryMode` tool, `createMapAgent`'s `dataEntries` option, …) handle the
|
|
3516
3514
|
* whole family uniformly without listing slice names.
|
|
@@ -3525,12 +3523,12 @@ interface EntryModeSlice {
|
|
|
3525
3523
|
setEntryMode(mode: EntryMode): Promise<void>;
|
|
3526
3524
|
}
|
|
3527
3525
|
/**
|
|
3528
|
-
*
|
|
3529
|
-
*
|
|
3526
|
+
* The data-entry kind names that `dataEntries` on `createMapAgent` uses. They extend the
|
|
3527
|
+
* analyse/process input kinds (`EntryDataKind`) with `ranges`, which has its own
|
|
3530
3528
|
* entry-mode-supporting slice but is not a top-level input kind for those tools.
|
|
3531
3529
|
*
|
|
3532
|
-
* The kind names are LLM-facing (`routes`, `incidents`)
|
|
3533
|
-
* `trafficIncidents`)
|
|
3530
|
+
* The kind names are LLM-facing (`routes`, `incidents`) instead of slice names (`routing`,
|
|
3531
|
+
* `trafficIncidents`). The slice mapping is internal (see {@link DATA_ENTRY_KIND_TO_SLICE}).
|
|
3534
3532
|
*
|
|
3535
3533
|
* @group Agent Toolkit
|
|
3536
3534
|
*/
|
|
@@ -3543,22 +3541,22 @@ type DataEntryKind = 'places' | 'routes' | 'incidents' | 'customGeometries' | 't
|
|
|
3543
3541
|
type DataEntryConfig = {
|
|
3544
3542
|
/**
|
|
3545
3543
|
* When `false`, the kind is removed from the agent's tool surface entirely:
|
|
3546
|
-
* -
|
|
3547
|
-
* -
|
|
3544
|
+
* - The kind disappears from the `analyseData` and `processData` scope and input fields.
|
|
3545
|
+
* - Related recall, display and fetch tools are dropped from the registry
|
|
3548
3546
|
* (see {@link TOOLS_BY_DATA_ENTRY_KIND}).
|
|
3549
3547
|
*
|
|
3550
|
-
*
|
|
3548
|
+
* Defaults to `true`.
|
|
3551
3549
|
*/
|
|
3552
3550
|
enabled?: boolean;
|
|
3553
3551
|
/**
|
|
3554
|
-
*
|
|
3555
|
-
* entry on the map
|
|
3552
|
+
* The initial entry-display policy for the underlying slice. `single` keeps only the latest
|
|
3553
|
+
* entry on the map and hides the others. `multiple` (default) lets several coexist.
|
|
3556
3554
|
*/
|
|
3557
3555
|
entryMode?: EntryMode;
|
|
3558
3556
|
};
|
|
3559
3557
|
/**
|
|
3560
|
-
*
|
|
3561
|
-
*
|
|
3558
|
+
* Maps each {@link DataEntryKind} (LLM-facing name) to the {@link ToolState} slice key that
|
|
3559
|
+
* owns its entries. `createMapAgent` uses it to apply `entryMode` from
|
|
3562
3560
|
* `dataEntries[kind].entryMode` to the right slice.
|
|
3563
3561
|
*
|
|
3564
3562
|
* @group Agent Toolkit
|
|
@@ -3573,34 +3571,33 @@ export declare const DATA_ENTRY_KIND_TO_SLICE: {
|
|
|
3573
3571
|
readonly ranges: "ranges";
|
|
3574
3572
|
};
|
|
3575
3573
|
/**
|
|
3576
|
-
*
|
|
3577
|
-
* Names match the {@link ToolState} keys exactly
|
|
3578
|
-
* `customGeometries` (not `geometries`)
|
|
3574
|
+
* The compile-time union of {@link ToolState} keys whose slice supports {@link EntryMode}.
|
|
3575
|
+
* Names match the {@link ToolState} keys exactly, such as `routing` (not `routes`) and
|
|
3576
|
+
* `customGeometries` (not `geometries`), so the slice name in the tool API never drifts
|
|
3579
3577
|
* from the property on `state`.
|
|
3580
3578
|
*
|
|
3581
|
-
*
|
|
3582
|
-
*
|
|
3583
|
-
* is added there too.
|
|
3579
|
+
* When a new slice implements `setEntryMode`, the union picks up its key, and the runtime
|
|
3580
|
+
* list {@link ENTRY_MODE_SLICE_NAMES} fails to type-check until the key is added there too.
|
|
3584
3581
|
*
|
|
3585
3582
|
* @group Agent Toolkit
|
|
3586
3583
|
*/
|
|
3587
3584
|
type EntryModeSliceName = { [K in keyof ToolState]: ToolState[K] extends EntryModeSlice ? K : never; }[keyof ToolState];
|
|
3588
3585
|
/**
|
|
3589
|
-
*
|
|
3590
|
-
*
|
|
3591
|
-
*
|
|
3586
|
+
* The runtime list of slice names that support entry mode. Its `satisfies` clause makes
|
|
3587
|
+
* drift a compile error. When a new {@link ToolState} slice gains `setEntryMode`, the
|
|
3588
|
+
* package won't build until this constant is updated.
|
|
3592
3589
|
*
|
|
3593
3590
|
* @group Agent Toolkit
|
|
3594
3591
|
*/
|
|
3595
3592
|
export declare const ENTRY_MODE_SLICE_NAMES: readonly EntryModeSliceName[];
|
|
3596
3593
|
/**
|
|
3597
|
-
*
|
|
3598
|
-
* individually by id and
|
|
3599
|
-
*
|
|
3600
|
-
*
|
|
3594
|
+
* A state slice that owns a set of "entries" (routes, ranges), each of which can be hidden
|
|
3595
|
+
* individually by id, and exposes the shown set. {@link RoutingState} and {@link RangeState}
|
|
3596
|
+
* implement it. Helpers that hide previously-shown entries before rendering a new one
|
|
3597
|
+
* consume it (see `hidePreviousShownEntries`).
|
|
3601
3598
|
*
|
|
3602
|
-
*
|
|
3603
|
-
* (`removeShownEntries(ids)`
|
|
3599
|
+
* {@link PlacesState} doesn't implement it, because it uses a wider per-entry marker-type
|
|
3600
|
+
* model (`removeShownEntries(ids)` instead of `hideEntry(id)`).
|
|
3604
3601
|
*
|
|
3605
3602
|
* @group Agent Toolkit
|
|
3606
3603
|
*/
|
|
@@ -3618,17 +3615,17 @@ interface ShownEntriesSlice extends StateSlice {
|
|
|
3618
3615
|
*/
|
|
3619
3616
|
type BYODStateEvents = {
|
|
3620
3617
|
/**
|
|
3621
|
-
*
|
|
3622
|
-
* snapshot after the change
|
|
3623
|
-
*
|
|
3618
|
+
* An entry was added or removed, or `reset()` cleared the history. `entries` is the full
|
|
3619
|
+
* snapshot after the change, and `changedIds` lists the ids of the entries this change added,
|
|
3620
|
+
* replaced in place, or removed.
|
|
3624
3621
|
*/
|
|
3625
3622
|
'entries-change': {
|
|
3626
3623
|
entries: readonly BYODEntry[];
|
|
3627
3624
|
changedIds: readonly string[];
|
|
3628
3625
|
};
|
|
3629
|
-
/**
|
|
3626
|
+
/** The set of entries rendered on the map changed. */
|
|
3630
3627
|
'shown-change': ReadonlySet<string>;
|
|
3631
|
-
/**
|
|
3628
|
+
/** The display policy switched between `single` and `multiple`. */
|
|
3632
3629
|
'mode-change': EntryMode;
|
|
3633
3630
|
};
|
|
3634
3631
|
/**
|
|
@@ -3638,9 +3635,9 @@ type BYODStateEvents = {
|
|
|
3638
3635
|
*/
|
|
3639
3636
|
type AddBYODEntryOptions = {
|
|
3640
3637
|
/**
|
|
3641
|
-
* Explicit MapLibre layer specs
|
|
3642
|
-
*
|
|
3643
|
-
* they are
|
|
3638
|
+
* Explicit MapLibre layer specs, never derived automatically. You pass them here,
|
|
3639
|
+
* or the agent sets them via `setByodLayers`. Until then the entry renders nothing.
|
|
3640
|
+
* Either way they are only stored, and {@link BYODState.showEntry} renders them.
|
|
3644
3641
|
*/
|
|
3645
3642
|
layers?: CustomGeoJSONLayerSpec[];
|
|
3646
3643
|
/** Provenance for the data. Defaults to `{ kind: 'integrator' }`. */
|
|
@@ -3652,9 +3649,9 @@ type AddBYODEntryOptions = {
|
|
|
3652
3649
|
explicitId?: string;
|
|
3653
3650
|
};
|
|
3654
3651
|
/**
|
|
3655
|
-
*
|
|
3656
|
-
*
|
|
3657
|
-
*
|
|
3652
|
+
* The verdict a {@link ByodSourceUrlValidator} returns. `{ valid: true }` explicitly allows
|
|
3653
|
+
* the fetch, and `{ valid: false, reason }` blocks it and surfaces the `reason` to the model
|
|
3654
|
+
* as the tool error.
|
|
3658
3655
|
*
|
|
3659
3656
|
* @group Agent Toolkit
|
|
3660
3657
|
*/
|
|
@@ -3665,30 +3662,30 @@ type ByodSourceUrlValidation = {
|
|
|
3665
3662
|
reason: string;
|
|
3666
3663
|
};
|
|
3667
3664
|
/**
|
|
3668
|
-
*
|
|
3669
|
-
*
|
|
3670
|
-
*
|
|
3671
|
-
*
|
|
3672
|
-
*
|
|
3673
|
-
*
|
|
3674
|
-
* The toolkit can't enforce SSRF guarantees the host itself can't, so it
|
|
3675
|
-
* the URL surface open
|
|
3676
|
-
*
|
|
3677
|
-
*
|
|
3678
|
-
*
|
|
3665
|
+
* An app-supplied authorization hook for BYOD source URLs. `addByodSource` runs it
|
|
3666
|
+
* after the built-in scheme, size and timeout policy and before the network fetch.
|
|
3667
|
+
* Return `{ valid: true }` to allow the fetch or `{ valid: false, reason }` to
|
|
3668
|
+
* block it (see {@link ByodSourceUrlValidation}). It may be sync or async, such as
|
|
3669
|
+
* an allowlist lookup.
|
|
3670
|
+
*
|
|
3671
|
+
* The toolkit can't enforce SSRF guarantees the host itself can't, so by default it
|
|
3672
|
+
* leaves the URL surface open. This hook lets a deployment add its own policy, such
|
|
3673
|
+
* as refusing cloud-metadata endpoints (`169.254.169.254`) or allowing only known
|
|
3674
|
+
* hosts, without the SDK prescribing one for everyone. Set it via the
|
|
3675
|
+
* `byod.validateSourceUrl` option on `createMapAgent`, or assign
|
|
3679
3676
|
* `state.byod.sourceUrlValidator` directly.
|
|
3680
3677
|
*
|
|
3681
3678
|
* @group Agent Toolkit
|
|
3682
3679
|
*/
|
|
3683
3680
|
type ByodSourceUrlValidator = (url: URL) => ByodSourceUrlValidation | Promise<ByodSourceUrlValidation>;
|
|
3684
3681
|
/**
|
|
3685
|
-
*
|
|
3686
|
-
* data that doesn't fit places
|
|
3687
|
-
*
|
|
3688
|
-
*
|
|
3682
|
+
* The state slice for BYOD (bring-your-own-data) GeoJSON layers, the customer-owned
|
|
3683
|
+
* data that doesn't fit places, routes, ranges or custom geometries. Each entry
|
|
3684
|
+
* wraps a {@link CustomGeoJSONModule} so the agent can render, query, and pipe it
|
|
3685
|
+
* through analyseData or processData.
|
|
3689
3686
|
*
|
|
3690
|
-
*
|
|
3691
|
-
*
|
|
3687
|
+
* As in {@link CustomGeometriesState}, every entry owns its own module, initialised
|
|
3688
|
+
* lazily on first show.
|
|
3692
3689
|
*
|
|
3693
3690
|
* @group Agent Toolkit
|
|
3694
3691
|
*/
|
|
@@ -3696,12 +3693,12 @@ declare class BYODState implements ShownEntriesSlice, StateSlice {
|
|
|
3696
3693
|
private readonly _ttMap;
|
|
3697
3694
|
private _entries;
|
|
3698
3695
|
private _entryMode;
|
|
3699
|
-
/**
|
|
3696
|
+
/** The state change events, listed in {@link BYODStateEvents}. */
|
|
3700
3697
|
readonly events: StateEvents<BYODStateEvents>;
|
|
3701
3698
|
/**
|
|
3702
|
-
*
|
|
3703
|
-
* {@link ByodSourceUrlValidator}.
|
|
3704
|
-
*
|
|
3699
|
+
* The optional authorization hook for `addByodSource` URL fetches (see
|
|
3700
|
+
* {@link ByodSourceUrlValidator}). If unset, only the built-in scheme, size
|
|
3701
|
+
* and timeout policy applies.
|
|
3705
3702
|
*/
|
|
3706
3703
|
sourceUrlValidator?: ByodSourceUrlValidator;
|
|
3707
3704
|
constructor(_ttMap: TomTomMap);
|
|
@@ -3713,35 +3710,35 @@ declare class BYODState implements ShownEntriesSlice, StateSlice {
|
|
|
3713
3710
|
setEntryMode(mode: EntryMode): Promise<void>;
|
|
3714
3711
|
findById(entryId: string): BYODEntry | undefined;
|
|
3715
3712
|
/**
|
|
3716
|
-
*
|
|
3717
|
-
*
|
|
3718
|
-
* rendered on top of a still-visible old one
|
|
3713
|
+
* Appends a new BYOD entry and returns its assigned id. In `single` mode the new entry
|
|
3714
|
+
* replaces every older one. It hides and drops them before pushing the new entry, so the
|
|
3715
|
+
* caller never sees it rendered on top of a still-visible old one.
|
|
3719
3716
|
*/
|
|
3720
3717
|
addEntry(data: FeatureCollection$1, label: string, options?: AddBYODEntryOptions): Promise<string>;
|
|
3721
3718
|
/**
|
|
3722
|
-
*
|
|
3723
|
-
* module
|
|
3724
|
-
*
|
|
3725
|
-
*
|
|
3719
|
+
* Replaces the MapLibre layer specs an entry renders under. If the entry already owns a
|
|
3720
|
+
* module because it was shown at least once, the module's `applyConfig` runtime layer diff
|
|
3721
|
+
* pushes the new specs live, without tear-down or flicker. Otherwise the specs are stored
|
|
3722
|
+
* and the next {@link showEntry} picks them up. Throws on an unknown id.
|
|
3726
3723
|
*/
|
|
3727
3724
|
setEntryLayers(entryId: string, layers: CustomGeoJSONLayerSpec[]): void;
|
|
3728
3725
|
/**
|
|
3729
|
-
*
|
|
3730
|
-
*
|
|
3731
|
-
*
|
|
3732
|
-
*
|
|
3726
|
+
* Initialises the entry's CustomGeoJSONModule lazily. The module has a single
|
|
3727
|
+
* source named `data`, configured with this entry's `layers`. To swap layers
|
|
3728
|
+
* afterwards, call {@link setEntryLayers}, which pushes the new specs into this
|
|
3729
|
+
* module via `applyConfig` instead of recreating it.
|
|
3733
3730
|
*/
|
|
3734
3731
|
getEntryModule(entryId: string): Promise<CustomGeoJSONModule>;
|
|
3735
|
-
/**
|
|
3732
|
+
/** Renders the entry on the map. */
|
|
3736
3733
|
showEntry(entryId: string): Promise<void>;
|
|
3737
3734
|
private _hideOthersUnderSingleMode;
|
|
3738
3735
|
hideEntry(entryId: string): Promise<void>;
|
|
3739
|
-
/**
|
|
3736
|
+
/** Clears an entry's module, then drops the entry from history. Does nothing for an unknown id. */
|
|
3740
3737
|
removeEntry(entryId: string): Promise<void>;
|
|
3741
3738
|
private _requireEntry;
|
|
3742
3739
|
/**
|
|
3743
|
-
*
|
|
3744
|
-
*
|
|
3740
|
+
* Hides every BYOD layer on the map but keeps the history. Implements
|
|
3741
|
+
* {@link ClearableMapSlice}.
|
|
3745
3742
|
*/
|
|
3746
3743
|
clearShown(): Promise<void>;
|
|
3747
3744
|
reset(): void;
|
|
@@ -3751,15 +3748,15 @@ declare class BYODState implements ShownEntriesSlice, StateSlice {
|
|
|
3751
3748
|
/**
|
|
3752
3749
|
* @module agent-toolkit-system-prompt
|
|
3753
3750
|
*
|
|
3754
|
-
*
|
|
3751
|
+
* The behavioural contract (persona, tone, dual-response, cadence) lives here.
|
|
3755
3752
|
*
|
|
3756
|
-
* Tool mechanics
|
|
3757
|
-
* which-tool-next
|
|
3758
|
-
*
|
|
3759
|
-
*
|
|
3760
|
-
*
|
|
3761
|
-
*
|
|
3762
|
-
*
|
|
3753
|
+
* Tool mechanics (call shape, return shape, error handling, when-to-use vs.
|
|
3754
|
+
* which-tool-next) live in each tool's description string and Zod schema. Each
|
|
3755
|
+
* tool re-explains its own role, and the LLM sees those alongside this prompt.
|
|
3756
|
+
* The intent classifier (see `utils/intent-classifier.ts`) also scopes tools per
|
|
3757
|
+
* step, so a tool's description is only in context while that tool is active.
|
|
3758
|
+
* Keep cross-cutting safety rules here, where they are always present, and leave
|
|
3759
|
+
* per-tool mechanics to the tool.
|
|
3763
3760
|
*
|
|
3764
3761
|
* If you find yourself adding lines here to fix an LLM mistake, ask first
|
|
3765
3762
|
* whether the fix belongs in a tool description or a tool error message.
|
|
@@ -3775,14 +3772,14 @@ declare class BYODState implements ShownEntriesSlice, StateSlice {
|
|
|
3775
3772
|
*/
|
|
3776
3773
|
type SystemPromptSection = 'identity' | 'capabilities' | 'rejectionRules' | 'responseFormatting' | 'dataConfidence' | 'toolExecution' | 'sessionState';
|
|
3777
3774
|
/**
|
|
3778
|
-
* Per-section body overrides. Each key replaces that section's body
|
|
3779
|
-
* sections fall back to {@link SYSTEM_PROMPT_SECTIONS}.
|
|
3780
|
-
*
|
|
3775
|
+
* Per-section body overrides. Each key replaces that section's body, and omitted
|
|
3776
|
+
* sections fall back to {@link SYSTEM_PROMPT_SECTIONS}. {@link composeSystemPrompt}
|
|
3777
|
+
* and `MapAgentOptions.systemPrompt` accept them.
|
|
3781
3778
|
*
|
|
3782
3779
|
* @remarks
|
|
3783
3780
|
* To *extend* rather than replace a section, read its current default from the
|
|
3784
|
-
* exported {@link SYSTEM_PROMPT_SECTIONS} map and override with a derived string
|
|
3785
|
-
*
|
|
3781
|
+
* exported {@link SYSTEM_PROMPT_SECTIONS} map and override with a derived string,
|
|
3782
|
+
* e.g. append a rule, prepend a note, or hand the default to a coding agent to
|
|
3786
3783
|
* rewrite under some criteria:
|
|
3787
3784
|
*
|
|
3788
3785
|
* ```typescript
|
|
@@ -3796,35 +3793,35 @@ type SystemPromptSection = 'identity' | 'capabilities' | 'rejectionRules' | 'res
|
|
|
3796
3793
|
*/
|
|
3797
3794
|
type SystemPromptSectionOverrides = Partial<Record<SystemPromptSection, string>>;
|
|
3798
3795
|
/**
|
|
3799
|
-
* The default body text for each base-prompt section
|
|
3796
|
+
* The default body text for each base-prompt section, without its heading.
|
|
3800
3797
|
*
|
|
3801
3798
|
* @remarks
|
|
3802
|
-
* Each value
|
|
3803
|
-
* `RESPONSE FORMATTING:`)
|
|
3804
|
-
*
|
|
3799
|
+
* Each value holds only the section's content. {@link composeSystemPrompt} adds the
|
|
3800
|
+
* structural heading (e.g. `RESPONSE FORMATTING:`), so an override passes just the
|
|
3801
|
+
* body. For example, `composeSystemPrompt({ responseFormatting: 'Reply in Spanish.' })`
|
|
3805
3802
|
* still renders under the `RESPONSE FORMATTING:` heading.
|
|
3806
3803
|
*
|
|
3807
|
-
* The
|
|
3808
|
-
* - `identity` — who the assistant is and its tone of voice
|
|
3804
|
+
* The behavioural prose is split so each concern is overridable on its own:
|
|
3805
|
+
* - `identity` — who the assistant is and its tone of voice, the natural hook to
|
|
3809
3806
|
* rebrand or set a persona.
|
|
3810
3807
|
* - `capabilities` — the map environment plus a compact summary of what the
|
|
3811
|
-
* toolkit can do.
|
|
3812
|
-
* as tools change
|
|
3813
|
-
* classifier prompt. It also gives `rejectionRules` something concrete to
|
|
3814
|
-
* the user back toward.
|
|
3808
|
+
* toolkit can do. It stays at the group level (not per-tool) so it does not
|
|
3809
|
+
* drift as tools change. The exact mechanics live in each tool's description and
|
|
3810
|
+
* the classifier prompt. It also gives `rejectionRules` something concrete to
|
|
3811
|
+
* steer the user back toward.
|
|
3815
3812
|
* - `rejectionRules` — how to handle in-scope / mixed / out-of-scope / illegal
|
|
3816
3813
|
* requests, and the requirement to always explain a rejection.
|
|
3817
3814
|
* - `dataConfidence` — how to surface incomplete, partial, stale, or conflicting
|
|
3818
3815
|
* data instead of presenting it as complete.
|
|
3819
3816
|
*
|
|
3820
3817
|
* Location-reference routing ("near me" → getCurrentLocation, "here" →
|
|
3821
|
-
* getViewport) is intentionally
|
|
3818
|
+
* getViewport) is intentionally **not** a section. It is a tool-selection rule
|
|
3822
3819
|
* already owned by the classifier prompt and the two tools' cross-referencing
|
|
3823
3820
|
* descriptions.
|
|
3824
3821
|
*
|
|
3825
|
-
* This map is the canonical source of the default body text
|
|
3826
|
-
*
|
|
3827
|
-
*
|
|
3822
|
+
* This map is the exported, canonical source of the default body text. A consumer
|
|
3823
|
+
* can read a default and override it with a derived value (extend, prefix, or
|
|
3824
|
+
* rewrite it). See {@link SystemPromptSectionOverrides}.
|
|
3828
3825
|
*
|
|
3829
3826
|
* @group Agent Toolkit
|
|
3830
3827
|
*/
|
|
@@ -3833,8 +3830,8 @@ export declare const SYSTEM_PROMPT_SECTIONS: Record<SystemPromptSection, string>
|
|
|
3833
3830
|
* Composes the base system prompt from {@link SYSTEM_PROMPT_SECTIONS}, applying
|
|
3834
3831
|
* any per-section overrides.
|
|
3835
3832
|
*
|
|
3836
|
-
* @param overrides - Replacement **body** text keyed by section
|
|
3837
|
-
* sections fall back to the default.
|
|
3833
|
+
* @param overrides - Replacement **body** text keyed by section. Omitted
|
|
3834
|
+
* sections fall back to the default. It adds the section heading itself,
|
|
3838
3835
|
* so an override does not repeat it. Pass the result to
|
|
3839
3836
|
* `MapAgentOptions.systemPrompt`.
|
|
3840
3837
|
* @returns The composed system prompt string.
|
|
@@ -3859,9 +3856,9 @@ export declare const composeSystemPrompt: (overrides?: SystemPromptSectionOverri
|
|
|
3859
3856
|
* The base system prompt that teaches the LLM how to use the agent toolkit tools.
|
|
3860
3857
|
*
|
|
3861
3858
|
* @remarks
|
|
3862
|
-
* Equivalent to `composeSystemPrompt()` with no overrides.
|
|
3863
|
-
*
|
|
3864
|
-
*
|
|
3859
|
+
* Equivalent to `composeSystemPrompt()` with no overrides. It is exported so you
|
|
3860
|
+
* can reference or extend it when you provide a custom system prompt via
|
|
3861
|
+
* `MapAgentOptions.systemPrompt`. To replace just one section, use
|
|
3865
3862
|
* {@link composeSystemPrompt} instead of rebuilding the whole string.
|
|
3866
3863
|
*
|
|
3867
3864
|
* @example
|
|
@@ -3915,12 +3912,12 @@ export declare const buildSystemPrompt: ({ customPrompt, prefix, suffix }?: Buil
|
|
|
3915
3912
|
//#endregion
|
|
3916
3913
|
//#region src/tools/tool-registry.d.ts
|
|
3917
3914
|
/**
|
|
3918
|
-
* Default tool set for the agent toolkit. Each entry is a {@link ToolDefinition}
|
|
3919
|
-
*
|
|
3915
|
+
* Default tool set for the agent toolkit. Each entry is a {@link ToolDefinition},
|
|
3916
|
+
* either a static `ToolEntry` or a `ToolEntryBuilder` that tailors the tool to
|
|
3920
3917
|
* {@link ToolBuildOptions} (e.g. feature flags) at agent-creation time.
|
|
3921
3918
|
*
|
|
3922
|
-
*
|
|
3923
|
-
*
|
|
3919
|
+
* createMapAgent includes it automatically unless includeDefaultTools is false.
|
|
3920
|
+
* For manual composition outside createMapAgent, use resolveTools().
|
|
3924
3921
|
*
|
|
3925
3922
|
* @group Agent Toolkit
|
|
3926
3923
|
*/
|
|
@@ -3961,11 +3958,8 @@ export declare const DEFAULT_TOOLS: {
|
|
|
3961
3958
|
getStandardMapStyles: ToolDefinition;
|
|
3962
3959
|
setMapStandardStyle: ToolDefinition;
|
|
3963
3960
|
setLanguage: ToolDefinition;
|
|
3964
|
-
|
|
3965
|
-
toggleTilesBaseMapLayerGroups: ToolDefinition;
|
|
3961
|
+
setGeopoliticalView: ToolDefinition;
|
|
3966
3962
|
setMapStyling: ToolDefinition;
|
|
3967
|
-
toggleTilesTrafficFlow: ToolDefinition;
|
|
3968
|
-
toggleTilesTrafficIncidents: ToolDefinition;
|
|
3969
3963
|
getMapStyleLayers: ToolDefinition;
|
|
3970
3964
|
setLayoutProperties: ToolDefinition;
|
|
3971
3965
|
setPaintProperties: ToolDefinition;
|
|
@@ -3995,12 +3989,12 @@ type ToolName = keyof typeof DEFAULT_TOOLS;
|
|
|
3995
3989
|
export declare const TOOL_NAMES: ToolName[];
|
|
3996
3990
|
/**
|
|
3997
3991
|
* Default tool names that should be dropped from the registry when a {@link DataEntryKind}
|
|
3998
|
-
* is disabled. Only default-tool names are listed here
|
|
3999
|
-
* never filtered automatically
|
|
4000
|
-
*
|
|
3992
|
+
* is disabled. Only default-tool names are listed here. User-supplied custom tools are
|
|
3993
|
+
* never filtered automatically. To gate your own tools on enabled kinds, read
|
|
3994
|
+
* `dataEntries` yourself.
|
|
4001
3995
|
*
|
|
4002
3996
|
* Tools that span multiple kinds (`clearMap`, `recallState`, `setEntryMode`, …) are
|
|
4003
|
-
* intentionally absent
|
|
3997
|
+
* intentionally absent, since they keep working regardless of which kinds are disabled.
|
|
4004
3998
|
*
|
|
4005
3999
|
* @group Agent Toolkit
|
|
4006
4000
|
*/
|
|
@@ -4011,7 +4005,7 @@ export declare const TOOLS_BY_DATA_ENTRY_KIND: Record<DataEntryKind, readonly To
|
|
|
4011
4005
|
* tool's default (full-surface) shape. Tools without prompts map to `[]`.
|
|
4012
4006
|
*
|
|
4013
4007
|
* Surface these in chat UIs to keep starter suggestions in sync with what the
|
|
4014
|
-
* tools can actually do
|
|
4008
|
+
* tools can actually do. The registry stays the single source of truth.
|
|
4015
4009
|
*
|
|
4016
4010
|
* @group Agent Toolkit
|
|
4017
4011
|
*/
|
|
@@ -4027,16 +4021,19 @@ type ClassificationResult = {
|
|
|
4027
4021
|
/** Tool names selected by the classifier. */
|
|
4028
4022
|
activeToolNames: string[];
|
|
4029
4023
|
/**
|
|
4030
|
-
*
|
|
4031
|
-
* output for that tool
|
|
4032
|
-
* `
|
|
4033
|
-
* `scopeSchema`, or
|
|
4034
|
-
*
|
|
4024
|
+
* The optional per-tool scope, keyed by tool name. Each value is the raw
|
|
4025
|
+
* classifier output for that tool, which `prepareStep` validates against
|
|
4026
|
+
* the tool's `scopeSchema` before applying any narrowing. Tools without
|
|
4027
|
+
* `scopeSchema`, or with no scope from the classifier, keep their full
|
|
4028
|
+
* description and inputSchema for the turn.
|
|
4035
4029
|
*/
|
|
4036
4030
|
toolScopes?: Record<string, unknown>;
|
|
4037
|
-
/**
|
|
4031
|
+
/** The wall-clock time in ms of the classification step, excluding the agent response. */
|
|
4038
4032
|
timeMs: number;
|
|
4039
|
-
/**
|
|
4033
|
+
/**
|
|
4034
|
+
* Token usage of the classification, summed over its one LLM call, or two when the first
|
|
4035
|
+
* answer fails validation.
|
|
4036
|
+
*/
|
|
4040
4037
|
usage: {
|
|
4041
4038
|
inputTokens: number;
|
|
4042
4039
|
outputTokens: number;
|
|
@@ -4050,8 +4047,8 @@ type ClassificationResult = {
|
|
|
4050
4047
|
*/
|
|
4051
4048
|
type ClassifierOptions = {
|
|
4052
4049
|
/**
|
|
4053
|
-
*
|
|
4054
|
-
*
|
|
4050
|
+
* The language model for structured generation, ideally a fast, low-cost
|
|
4051
|
+
* one such as gpt-4o-mini.
|
|
4055
4052
|
*/
|
|
4056
4053
|
chatModel: LanguageModel;
|
|
4057
4054
|
/** Per-tool metadata used to build the classifier prompt. */
|
|
@@ -4069,10 +4066,10 @@ type ConversationMessage = {
|
|
|
4069
4066
|
content: string;
|
|
4070
4067
|
};
|
|
4071
4068
|
/**
|
|
4072
|
-
*
|
|
4069
|
+
* Classifies a user conversation to pick the tools to activate.
|
|
4073
4070
|
*
|
|
4074
4071
|
* The `conversation` should contain the last user message plus a compaction
|
|
4075
|
-
* of the
|
|
4072
|
+
* of the earlier chat history, each message truncated to save tokens.
|
|
4076
4073
|
*
|
|
4077
4074
|
* @example
|
|
4078
4075
|
* ```typescript
|
|
@@ -4088,14 +4085,14 @@ type ConversationMessage = {
|
|
|
4088
4085
|
export declare const classifyUserIntent: (conversation: ConversationMessage[], options: ClassifierOptions) => Promise<ClassificationResult>;
|
|
4089
4086
|
/**
|
|
4090
4087
|
* Extracts the text content of the last user message in a message array.
|
|
4091
|
-
* Returns null if no user message
|
|
4088
|
+
* Returns `null` if there is no user message or its content has no text.
|
|
4092
4089
|
*
|
|
4093
4090
|
* @group Agent Toolkit
|
|
4094
4091
|
*/
|
|
4095
4092
|
export declare const extractLastUserText: (messages: ReadonlyArray<ModelMessage>) => string | null;
|
|
4096
4093
|
/**
|
|
4097
|
-
* Creates the default LLM-based classifier
|
|
4098
|
-
*
|
|
4094
|
+
* Creates the default LLM-based classifier, which selects the minimal tool set for each user
|
|
4095
|
+
* message with structured generation.
|
|
4099
4096
|
*
|
|
4100
4097
|
* @param options.model - Language model for classification (ideally fast/cheap like gpt-4o-mini)
|
|
4101
4098
|
* @param options.maxHistoryMessages - Max prior turns for context. Default: 8
|
|
@@ -4122,14 +4119,14 @@ type ProviderOptions = Record<string, Record<string, JSONValue | undefined>>;
|
|
|
4122
4119
|
*/
|
|
4123
4120
|
export type ToolNameHint = ToolName | (string & {});
|
|
4124
4121
|
/**
|
|
4125
|
-
* Tool-facing union of state slices that own analysable entries
|
|
4122
|
+
* Tool-facing union of state slices that own analysable entries, the
|
|
4126
4123
|
* vocabulary used by tools that read from multiple slices (`analyseData`,
|
|
4127
4124
|
* `processData`) and by the classifier when proposing per-call scope.
|
|
4128
4125
|
*
|
|
4129
4126
|
* Distinct from {@link EntryModeSliceName}, which uses the literal state-slice
|
|
4130
4127
|
* keys (`routing`, `trafficIncidents`, …) for state-level operations.
|
|
4131
4128
|
*
|
|
4132
|
-
* `ranges` is intentionally excluded
|
|
4129
|
+
* `ranges` is intentionally excluded. It feeds the analysis/processing tools
|
|
4133
4130
|
* only via `geometriesEntryIDs` (its isochrone polygons), not as a direct
|
|
4134
4131
|
* top-level input.
|
|
4135
4132
|
*
|
|
@@ -4137,8 +4134,8 @@ export type ToolNameHint = ToolName | (string & {});
|
|
|
4137
4134
|
*/
|
|
4138
4135
|
export type EntryDataKind = 'places' | 'routes' | 'incidents' | 'customGeometries' | 'trafficAreaAnalytics' | 'byod';
|
|
4139
4136
|
/**
|
|
4140
|
-
* State passed to tool factory functions
|
|
4141
|
-
*
|
|
4137
|
+
* State passed to tool factory functions, organised by feature area.
|
|
4138
|
+
* Each sub-state mixes lazy module access with the current service data
|
|
4142
4139
|
* produced during the session.
|
|
4143
4140
|
*
|
|
4144
4141
|
* @group Agent Toolkit
|
|
@@ -4148,7 +4145,7 @@ export type EntryDataKind = 'places' | 'routes' | 'incidents' | 'customGeometrie
|
|
|
4148
4145
|
* function createMyTool(state: ToolState) {
|
|
4149
4146
|
* return tool({
|
|
4150
4147
|
* execute: async () => {
|
|
4151
|
-
* const
|
|
4148
|
+
* const places = await state.places.getEntryPlacesModule('places-0', 'pin');
|
|
4152
4149
|
* state.routing.currentRoutes; // most recent routes
|
|
4153
4150
|
* state.baseMap.mapLibreMap; // MapLibre instance
|
|
4154
4151
|
* }
|
|
@@ -4157,68 +4154,69 @@ export type EntryDataKind = 'places' | 'routes' | 'incidents' | 'customGeometrie
|
|
|
4157
4154
|
* ```
|
|
4158
4155
|
*/
|
|
4159
4156
|
export type ToolState = {
|
|
4160
|
-
/**
|
|
4157
|
+
/** The places layer's PlacesModule and append-only search history. */
|
|
4161
4158
|
places: PlacesState;
|
|
4162
|
-
/** Map POI layer
|
|
4159
|
+
/** Map POI layer visibility, filtering and category management. */
|
|
4163
4160
|
mapPOIs: MapPOIsState;
|
|
4164
4161
|
/** Route calculation, waypoint management, and planning parameter state. */
|
|
4165
4162
|
routing: RoutingState;
|
|
4166
|
-
/**
|
|
4163
|
+
/** The displayed base map's style, language, viewport and layers. */
|
|
4167
4164
|
baseMap: BaseMapState;
|
|
4168
|
-
/** Traffic
|
|
4165
|
+
/** Traffic flow tiles and incident overlay tiles. */
|
|
4169
4166
|
trafficTiles: TrafficTilesState;
|
|
4170
|
-
/** Traffic area analytics
|
|
4167
|
+
/** Traffic area analytics aggregation module, last result and viz config. */
|
|
4171
4168
|
trafficAreaAnalytics: TrafficAreaAnalyticsState;
|
|
4172
|
-
/**
|
|
4169
|
+
/** Fetched traffic incident entry history and per-entry rendering. */
|
|
4173
4170
|
trafficIncidents: TrafficIncidentsState;
|
|
4174
|
-
/** Reachable range results
|
|
4171
|
+
/** Reachable range results, with origin, budgets and bbox summaries. */
|
|
4175
4172
|
ranges: RangeState;
|
|
4176
|
-
/** Derived/custom polygon entries
|
|
4173
|
+
/** Derived/custom polygon entries that `processData` outputs. */
|
|
4177
4174
|
customGeometries: CustomGeometriesState;
|
|
4178
|
-
/** Bring-your-own-data GeoJSON layers
|
|
4175
|
+
/** Bring-your-own-data GeoJSON layers, customer-authored data the agent can read and render. */
|
|
4179
4176
|
byod: BYODState;
|
|
4180
4177
|
/**
|
|
4181
|
-
* Strategy used to run code-generation tools (`analyseData
|
|
4182
|
-
*
|
|
4183
|
-
*
|
|
4178
|
+
* Strategy used to run code-generation tools (`analyseData`, `processData`, `createTracker`,
|
|
4179
|
+
* `clusterIncidents`). `createToolState` initialises it to the env-resolved executor, and
|
|
4180
|
+
* `createMapAgent` re-resolves it with {@link MapAgentOptions.codeExecution}. Tools read this
|
|
4184
4181
|
* to select where sandbox code runs.
|
|
4185
4182
|
*/
|
|
4186
4183
|
codeExecution: SandboxExecutor;
|
|
4187
4184
|
/**
|
|
4188
4185
|
* The single recurrence engine. Owners (`analyses`, `trackers`) register entry-anchored jobs and keep
|
|
4189
|
-
* the returned handles
|
|
4190
|
-
*
|
|
4186
|
+
* the returned handles. The engine re-runs each active job when its source entries change. It is generic
|
|
4187
|
+
* and never interprets a job's recipe (the tools layer builds the run closure). See {@link JobEngine}.
|
|
4191
4188
|
*/
|
|
4192
4189
|
engine: JobEngine;
|
|
4193
4190
|
/**
|
|
4194
4191
|
* Single session-level registry of every analysis (one-shot + recurring) across all entry kinds.
|
|
4195
4192
|
* Results live here, and per-entry views read them on demand via {@link Analyses.getAnalysesForEntry}.
|
|
4196
|
-
* `analyseData` registers a record
|
|
4193
|
+
* `analyseData` registers a record and a job on {@link JobEngine}. `monitorAnalysis` toggles the job's
|
|
4197
4194
|
* active flag.
|
|
4198
4195
|
*/
|
|
4199
4196
|
analyses: Analyses;
|
|
4200
4197
|
/**
|
|
4201
|
-
* Generic trackers
|
|
4202
|
-
* alert/event when its rule's {@link Verdict} crosses an edge (`ingestVerdict`)
|
|
4203
|
-
* {@link TrackerEvent} log.
|
|
4198
|
+
* Generic trackers, rising-edge reducers fed by their own {@link JobEngine} jobs. A tracker fires an
|
|
4199
|
+
* alert/event when its rule's {@link Verdict} crosses an edge (`ingestVerdict`). The slice
|
|
4200
|
+
* keeps the durable {@link TrackerEvent} log.
|
|
4204
4201
|
*/
|
|
4205
4202
|
trackers: EventsState;
|
|
4206
4203
|
};
|
|
4207
4204
|
/**
|
|
4208
|
-
* Tunes
|
|
4209
|
-
*
|
|
4210
|
-
*
|
|
4211
|
-
*
|
|
4212
|
-
*
|
|
4205
|
+
* Tunes the sandbox execution of `analyseData`, `processData`, `createTracker` and
|
|
4206
|
+
* `clusterIncidents` code. **Where** the code runs is
|
|
4207
|
+
* not configurable, since the environment decides. In the browser, it is a
|
|
4208
|
+
* sandboxed, opaque-origin iframe + Web Worker (no DOM/storage access, no network
|
|
4209
|
+
* via CSP, terminable on timeout). In Node / SSR, where that boundary has no
|
|
4210
|
+
* equivalent, it is the main thread. The options below only tune the isolated browser run.
|
|
4213
4211
|
*
|
|
4214
4212
|
* @group Agent Toolkit
|
|
4215
4213
|
*/
|
|
4216
4214
|
export type CodeExecutionConfig = {
|
|
4217
|
-
/** Wall-clock budget per isolated (browser) run, in ms.
|
|
4215
|
+
/** Wall-clock budget per isolated (browser) run, in ms. Defaults to 10000. */
|
|
4218
4216
|
timeoutMs?: number;
|
|
4219
4217
|
/**
|
|
4220
|
-
* Optional override of the worker's library source. By default the SDK loads its own
|
|
4221
|
-
* inlined turf/h3 UMD (a separate lazy chunk), so this is rarely needed
|
|
4218
|
+
* Optional override of the worker's library source. By default, the SDK loads its own
|
|
4219
|
+
* inlined turf/h3 UMD (a separate lazy chunk), so this is rarely needed. Supply it only
|
|
4222
4220
|
* to pin a specific build or add libraries. Return UMD/IIFE JavaScript that defines
|
|
4223
4221
|
* `self.turf` and `self.h3` (string or Promise of one).
|
|
4224
4222
|
*/
|
|
@@ -4227,11 +4225,11 @@ export type CodeExecutionConfig = {
|
|
|
4227
4225
|
/**
|
|
4228
4226
|
* Per-call options handed to a tool's `execute`, separate from its parsed input.
|
|
4229
4227
|
*
|
|
4230
|
-
* `signal` is the AI SDK's own `abortSignal` for the tool call
|
|
4228
|
+
* `signal` is the AI SDK's own `abortSignal` for the tool call, which fires when the model's
|
|
4231
4229
|
* turn is cancelled. Forward it to any `@tomtom-org/maps-sdk/services` call the tool makes
|
|
4232
|
-
* (as `signal`) so a cancelled turn also cancels its in-flight HTTP requests.
|
|
4230
|
+
* (as `signal`), so a cancelled turn also cancels its in-flight HTTP requests.
|
|
4233
4231
|
*
|
|
4234
|
-
* Do NOT forward it into work that outlives the turn
|
|
4232
|
+
* Do NOT forward it into work that outlives the turn, such as a monitor's recurring tick or any
|
|
4235
4233
|
* deferred job. Those fire after the signal has aborted, and a monitor treats a rejected tick
|
|
4236
4234
|
* as fatal (it clears its own interval), so a leaked signal kills the monitor rather than
|
|
4237
4235
|
* cancelling a request.
|
|
@@ -4242,14 +4240,14 @@ export type ToolExecuteOptions = {
|
|
|
4242
4240
|
signal?: AbortSignal;
|
|
4243
4241
|
};
|
|
4244
4242
|
/**
|
|
4245
|
-
* A tool definition
|
|
4246
|
-
*
|
|
4243
|
+
* A tool definition, the universal format for both built-in and third-party tools.
|
|
4244
|
+
* It combines execution (inputSchema + execute) with classifier metadata.
|
|
4247
4245
|
*
|
|
4248
4246
|
* @typeParam S - The ToolState shape this tool requires. Default: base `ToolState`.
|
|
4249
4247
|
* @typeParam Scope - Optional per-tool scope shape. When set via `scopeSchema`, the
|
|
4250
4248
|
* classifier may emit a value of this shape per turn so the tool's `description`
|
|
4251
4249
|
* and `inputSchema` can be rebuilt narrower for that step. Tools without scope
|
|
4252
|
-
* leave this at the default `unknown
|
|
4250
|
+
* leave this at the default `unknown`. `scopeSchema` is then absent and no rebuild
|
|
4253
4251
|
* ever runs for the tool.
|
|
4254
4252
|
*
|
|
4255
4253
|
* @group Agent Toolkit
|
|
@@ -4262,20 +4260,20 @@ export type ToolEntry<S extends ToolState = ToolState, Scope = unknown> = {
|
|
|
4262
4260
|
/** Optional Zod schema describing the tool's structured output. */
|
|
4263
4261
|
outputSchema?: z.ZodType;
|
|
4264
4262
|
/**
|
|
4265
|
-
* Function that executes the tool.
|
|
4263
|
+
* Function that executes the tool. It receives the parsed input and the agent's state.
|
|
4266
4264
|
*
|
|
4267
4265
|
* If this calls a `@tomtom-org/maps-sdk/services` function directly, wrap its params with
|
|
4268
|
-
* `withAgentToolkitHeaders` (`tools/shared/agent-headers.ts`) before passing them in
|
|
4266
|
+
* `withAgentToolkitHeaders` (`tools/shared/agent-headers.ts`) before passing them in, for example
|
|
4269
4267
|
* `const requestParams = withAgentToolkitHeaders({ position }); await reverseGeocode(requestParams);`.
|
|
4270
|
-
* This tags the request so TomTom's traffic analytics attribute it to agent-toolkit
|
|
4271
|
-
*
|
|
4268
|
+
* This tags the request so TomTom's traffic analytics attribute it to agent-toolkit. The guard
|
|
4269
|
+
* test in `tools/shared/tests/agent-headers.test.ts` picks up an untagged call.
|
|
4272
4270
|
*/
|
|
4273
4271
|
execute: (input: any, state: S, options?: ToolExecuteOptions) => Promise<any>;
|
|
4274
4272
|
/** Compact one-liner for the intent classifier prompt. */
|
|
4275
4273
|
classificationPrompt?: string;
|
|
4276
4274
|
/** Category tags (e.g. 'location', 'routing'). */
|
|
4277
4275
|
tags?: string[];
|
|
4278
|
-
/** Usage examples (e.g. 'geocode("Amsterdam")'). */
|
|
4276
|
+
/** Usage examples (e.g. 'geocode("Amsterdam")'), passed on in the metadata a custom classifier receives. */
|
|
4279
4277
|
examples?: string[];
|
|
4280
4278
|
/** Natural language prompts (e.g. 'Where is the Louvre?'). */
|
|
4281
4279
|
examplePrompts?: string[];
|
|
@@ -4284,27 +4282,27 @@ export type ToolEntry<S extends ToolState = ToolState, Scope = unknown> = {
|
|
|
4284
4282
|
/** Tool names that must run before this one. */
|
|
4285
4283
|
dependsOn?: string[];
|
|
4286
4284
|
/**
|
|
4287
|
-
*
|
|
4288
|
-
* unioned into the per-turn `activeTools` set, so the model can always reach it. Use sparingly
|
|
4285
|
+
* Whether this tool stays active on every step regardless of the classifier's selection. Its name is
|
|
4286
|
+
* unioned into the per-turn `activeTools` set, so the model can always reach it. Use it sparingly,
|
|
4289
4287
|
* for tools that may be needed to set up *any* request (e.g. asking the user to clarify intent).
|
|
4290
|
-
*
|
|
4288
|
+
* It has no effect on the fail-open path (when classification is skipped, every tool is active).
|
|
4291
4289
|
*/
|
|
4292
4290
|
alwaysActive?: boolean;
|
|
4293
4291
|
/**
|
|
4294
|
-
*
|
|
4295
|
-
* whose turn must be a single silent tool call (e.g. clarifyIntent rendering a form). Leave unset
|
|
4296
|
-
* let the model take one more step after the tool returns
|
|
4297
|
-
* before the loop stops naturally on a no-tool-call step. A tool that semantically awaits the user
|
|
4292
|
+
* Whether to halt the agent loop on the SAME step that calls this tool, with no trailing step. Use for
|
|
4293
|
+
* tools whose turn must be a single silent tool call (e.g. clarifyIntent rendering a form). Leave unset
|
|
4294
|
+
* to let the model take one more step after the tool returns, for example to present the tool's result
|
|
4295
|
+
* as text before the loop stops naturally on a no-tool-call step. A tool that semantically awaits the user
|
|
4298
4296
|
* conveys that through its own result (e.g. clarifyIntent's `status: 'awaiting_user_response'`), not
|
|
4299
4297
|
* this flag.
|
|
4300
4298
|
*/
|
|
4301
4299
|
endsTurnOnCall?: boolean;
|
|
4302
4300
|
/**
|
|
4303
4301
|
* Optional per-tool scope schema. When set, the classifier may emit a
|
|
4304
|
-
* scope value (validated against this schema) and `prepareStep`
|
|
4305
|
-
*
|
|
4302
|
+
* scope value (validated against this schema), and `prepareStep` then
|
|
4303
|
+
* rebuilds this tool's `description` + `inputSchema` by re-invoking its
|
|
4306
4304
|
* {@link ToolEntryBuilder} with the parsed scope. Tools without a builder
|
|
4307
|
-
* cannot be scoped
|
|
4305
|
+
* cannot be scoped, so `scopeSchema` is only meaningful on builder-produced
|
|
4308
4306
|
* entries.
|
|
4309
4307
|
*/
|
|
4310
4308
|
scopeSchema?: z.ZodType<Scope>;
|
|
@@ -4323,13 +4321,13 @@ export type ToolEntry<S extends ToolState = ToolState, Scope = unknown> = {
|
|
|
4323
4321
|
export type ToolMetadata = {
|
|
4324
4322
|
/** Tool identifier, derived from the config key. */
|
|
4325
4323
|
name: string;
|
|
4326
|
-
/** Description of the tool's purpose
|
|
4324
|
+
/** Description of the tool's purpose, used by the SDK's system prompt. */
|
|
4327
4325
|
description: string;
|
|
4328
4326
|
/** Compact one-liner for the intent classifier prompt. */
|
|
4329
4327
|
classificationPrompt?: string;
|
|
4330
4328
|
/** Category tags used by the help tool for filtering (e.g. 'location', 'routing'). */
|
|
4331
4329
|
tags?: string[];
|
|
4332
|
-
/** Usage examples (e.g. 'geocode("Amsterdam")'). */
|
|
4330
|
+
/** Usage examples (e.g. 'geocode("Amsterdam")'), for a custom classifier. The help tool does not show them. */
|
|
4333
4331
|
examples?: string[];
|
|
4334
4332
|
/** Natural language prompts shown by the help tool (e.g. 'Where is the Louvre?'). */
|
|
4335
4333
|
examplePrompts?: string[];
|
|
@@ -4337,9 +4335,9 @@ export type ToolMetadata = {
|
|
|
4337
4335
|
relatedTools?: ToolNameHint[];
|
|
4338
4336
|
/** Tool names that must run before this one. */
|
|
4339
4337
|
dependsOn?: ToolNameHint[];
|
|
4340
|
-
/**
|
|
4338
|
+
/** Whether this tool stays active on every step regardless of the classifier's selection. */
|
|
4341
4339
|
alwaysActive?: boolean;
|
|
4342
|
-
/**
|
|
4340
|
+
/** Whether to halt the agent loop on the step that calls this tool (no trailing step), e.g. clarifyIntent rendering a form. */
|
|
4343
4341
|
endsTurnOnCall?: boolean;
|
|
4344
4342
|
/** When set, the classifier may emit `toolScopes[name]` for this tool to narrow per-turn. */
|
|
4345
4343
|
scopePrompt?: string;
|
|
@@ -4363,9 +4361,9 @@ export type ClassifierContext = {
|
|
|
4363
4361
|
*/
|
|
4364
4362
|
export type Classifier = (context: ClassifierContext) => Promise<ClassificationResult | null>;
|
|
4365
4363
|
/**
|
|
4366
|
-
* Feature-flag bag for {@link createMapAgent}.
|
|
4367
|
-
* opt-in agent-toolkit behaviour. Individual flags vary in stability
|
|
4368
|
-
*
|
|
4364
|
+
* Feature-flag bag for {@link createMapAgent}. It toggles in-flight or
|
|
4365
|
+
* opt-in agent-toolkit behaviour. Individual flags vary in stability.
|
|
4366
|
+
* Some may graduate to stable public options, and others are internal-only
|
|
4369
4367
|
* experiments that can change or disappear without notice. Check each
|
|
4370
4368
|
* flag's own doc for its current status.
|
|
4371
4369
|
*
|
|
@@ -4385,7 +4383,7 @@ export type FeatureFlags = {
|
|
|
4385
4383
|
readonly [flag: string]: never;
|
|
4386
4384
|
};
|
|
4387
4385
|
/**
|
|
4388
|
-
* Build-time options passed to a {@link ToolEntryBuilder}.
|
|
4386
|
+
* Build-time options passed to a {@link ToolEntryBuilder}. They let each tool
|
|
4389
4387
|
* tailor its description, schema, or executor to flags or per-turn scope
|
|
4390
4388
|
* resolved by the classifier.
|
|
4391
4389
|
*
|
|
@@ -4400,8 +4398,8 @@ export type ToolBuildOptions<Scope = unknown> = {
|
|
|
4400
4398
|
featureFlags?: FeatureFlags;
|
|
4401
4399
|
/**
|
|
4402
4400
|
* Per-turn scope emitted by the classifier (already validated against the
|
|
4403
|
-
* tool's {@link ToolEntry.scopeSchema}). `undefined` at agent-creation
|
|
4404
|
-
* or when the classifier omits a scope for this tool
|
|
4401
|
+
* tool's {@link ToolEntry.scopeSchema}). It is `undefined` at agent-creation
|
|
4402
|
+
* time or when the classifier omits a scope for this tool. Builders should
|
|
4405
4403
|
* treat `undefined` as "produce the full surface".
|
|
4406
4404
|
*/
|
|
4407
4405
|
scope?: Scope;
|
|
@@ -4409,8 +4407,8 @@ export type ToolBuildOptions<Scope = unknown> = {
|
|
|
4409
4407
|
* Subset of {@link EntryDataKind} the agent is configured to expose, derived
|
|
4410
4408
|
* from `createMapAgent`'s `dataEntries` option. Builders for `analyseData`
|
|
4411
4409
|
* and `processData` use this to narrow their static (unscoped) input surface
|
|
4412
|
-
* to the agent's enabled kinds. `undefined` means
|
|
4413
|
-
* every kind stays available
|
|
4410
|
+
* to the agent's enabled kinds. `undefined` means no agent-level filtering, so
|
|
4411
|
+
* every kind stays available.
|
|
4414
4412
|
*/
|
|
4415
4413
|
enabledDataKinds?: readonly EntryDataKind[];
|
|
4416
4414
|
};
|
|
@@ -4430,8 +4428,8 @@ export type ToolEntryBuilder<S extends ToolState = ToolState, Scope = unknown> =
|
|
|
4430
4428
|
/**
|
|
4431
4429
|
* A registered tool definition: either a static {@link ToolEntry} or a
|
|
4432
4430
|
* {@link ToolEntryBuilder} that builds one from {@link ToolBuildOptions} at
|
|
4433
|
-
* agent-creation time.
|
|
4434
|
-
*
|
|
4431
|
+
* agent-creation time. The tool registry, resolver and setup pipeline
|
|
4432
|
+
* accept either form interchangeably.
|
|
4435
4433
|
*
|
|
4436
4434
|
* @typeParam S - The ToolState shape this tool requires. Default: base `ToolState`.
|
|
4437
4435
|
* @typeParam Scope - Optional per-tool scope shape (only relevant for builder
|
|
@@ -4450,7 +4448,7 @@ export type ToolExecutionInfo = {
|
|
|
4450
4448
|
toolName: string;
|
|
4451
4449
|
/** Wall-clock duration of `execute`, in milliseconds (includes any network/IO). */
|
|
4452
4450
|
durationMs: number;
|
|
4453
|
-
/**
|
|
4451
|
+
/** Whether the tool threw or returned the standardized `{ error: string }` shape. */
|
|
4454
4452
|
isError: boolean;
|
|
4455
4453
|
/** Error message when `isError` is true (the thrown message or the returned `error`). */
|
|
4456
4454
|
errorMessage?: string;
|
|
@@ -4492,19 +4490,19 @@ export type MapAgentOptions<CS extends ToolState = ToolState> = {
|
|
|
4492
4490
|
* the exported `SYSTEM_PROMPT_SECTIONS` map and override with a derived value
|
|
4493
4491
|
* (e.g. ``responseFormatting: `${SYSTEM_PROMPT_SECTIONS.responseFormatting}\n- Answer in Spanish.` ``).
|
|
4494
4492
|
*
|
|
4495
|
-
* A full string ignores `systemPromptPrefix` and `systemPromptSuffix
|
|
4496
|
-
*
|
|
4493
|
+
* A full string ignores `systemPromptPrefix` and `systemPromptSuffix`.
|
|
4494
|
+
* Section overrides still honour both.
|
|
4497
4495
|
*/
|
|
4498
4496
|
systemPrompt?: string | SystemPromptSectionOverrides;
|
|
4499
4497
|
/**
|
|
4500
4498
|
* Text prepended above the whole prompt as a preamble, separated by a blank
|
|
4501
|
-
* line and carrying no heading.
|
|
4502
|
-
* overrides
|
|
4499
|
+
* line and carrying no heading. It applies on top of the base prompt or section
|
|
4500
|
+
* overrides, unless `systemPrompt` is a full replacement string.
|
|
4503
4501
|
*/
|
|
4504
4502
|
systemPromptPrefix?: string;
|
|
4505
4503
|
/**
|
|
4506
4504
|
* Additional text appended under an `ADDITIONAL INSTRUCTIONS` heading.
|
|
4507
|
-
*
|
|
4505
|
+
* It applies on top of the base prompt or section overrides, unless
|
|
4508
4506
|
* `systemPrompt` is a full replacement string.
|
|
4509
4507
|
*/
|
|
4510
4508
|
systemPromptSuffix?: string;
|
|
@@ -4516,7 +4514,8 @@ export type MapAgentOptions<CS extends ToolState = ToolState> = {
|
|
|
4516
4514
|
includeDefaultTools?: boolean;
|
|
4517
4515
|
/**
|
|
4518
4516
|
* Tool overrides merged with default tools.
|
|
4519
|
-
* - `ToolEntry
|
|
4517
|
+
* - {@link ToolDefinition} values (a `ToolEntry`, a builder, or a `DEFAULT_TOOLS` value) add a new
|
|
4518
|
+
* tool or replace a default.
|
|
4520
4519
|
* - `false` values exclude a default tool.
|
|
4521
4520
|
*
|
|
4522
4521
|
* When omitted, all default tools are used as-is.
|
|
@@ -4536,22 +4535,22 @@ export type MapAgentOptions<CS extends ToolState = ToolState> = {
|
|
|
4536
4535
|
* });
|
|
4537
4536
|
* ```
|
|
4538
4537
|
*/
|
|
4539
|
-
tools?: { [K in ToolNameHint]?:
|
|
4538
|
+
tools?: { [K in ToolNameHint]?: ToolDefinition<CS> | false | undefined; };
|
|
4540
4539
|
/**
|
|
4541
4540
|
* Custom state slices merged alongside built-in state.
|
|
4542
|
-
* Only custom slices need to be provided
|
|
4543
|
-
*
|
|
4541
|
+
* Only custom slices need to be provided, since built-in slices are created automatically.
|
|
4542
|
+
* Custom tools read them in `execute` via the state parameter.
|
|
4544
4543
|
*/
|
|
4545
4544
|
state?: Omit<CS, keyof ToolState>;
|
|
4546
4545
|
/**
|
|
4547
4546
|
* Per-kind data-entry configuration. Each {@link DataEntryKind} accepts
|
|
4548
4547
|
* `{ enabled?, entryMode? }`. Setting `enabled: false` removes the kind from the
|
|
4549
|
-
* agent's tool surface entirely
|
|
4550
|
-
* scope and input fields, and
|
|
4551
|
-
* are dropped from the registry. `
|
|
4552
|
-
* right after the agent state is built
|
|
4548
|
+
* agent's tool surface entirely. It disappears from `analyseData` / `processData`
|
|
4549
|
+
* scope and input fields, and its slice-specific display / fetch tools
|
|
4550
|
+
* ({@link TOOLS_BY_DATA_ENTRY_KIND}) are dropped from the registry. `recallState` stays.
|
|
4551
|
+
* `entryMode` is applied to the underlying slice right after the agent state is built, before any tool runs.
|
|
4553
4552
|
*
|
|
4554
|
-
* Keys are LLM-facing kind names (`routes`, `incidents`)
|
|
4553
|
+
* Keys are LLM-facing kind names (`routes`, `incidents`), not slice names
|
|
4555
4554
|
* (`routing`, `trafficIncidents`). The slice mapping is internal.
|
|
4556
4555
|
*
|
|
4557
4556
|
* @example
|
|
@@ -4561,8 +4560,8 @@ export type MapAgentOptions<CS extends ToolState = ToolState> = {
|
|
|
4561
4560
|
* dataEntries: {
|
|
4562
4561
|
* routes: { entryMode: 'single' },
|
|
4563
4562
|
* incidents: { entryMode: 'single' },
|
|
4564
|
-
* byod: { enabled: false }, //
|
|
4565
|
-
* ranges: { enabled: false }, //
|
|
4563
|
+
* byod: { enabled: false }, // drops addByodSource, setByodLayers, updateByodDisplay + byod scope on analyse/process
|
|
4564
|
+
* ranges: { enabled: false }, // drops findReachableAreas
|
|
4566
4565
|
* },
|
|
4567
4566
|
* });
|
|
4568
4567
|
* ```
|
|
@@ -4587,17 +4586,17 @@ export type MapAgentOptions<CS extends ToolState = ToolState> = {
|
|
|
4587
4586
|
*/
|
|
4588
4587
|
byod?: {
|
|
4589
4588
|
/**
|
|
4590
|
-
*
|
|
4591
|
-
* {@link ByodSourceUrlValidator}. Return `{ valid: true }` to allow or
|
|
4592
|
-
* `{ valid: false, reason }` to block (sync or async).
|
|
4589
|
+
* Authorises each `addByodSource` URL before it is fetched (see
|
|
4590
|
+
* {@link ByodSourceUrlValidator}). Return `{ valid: true }` to allow or
|
|
4591
|
+
* `{ valid: false, reason }` to block (sync or async). It runs in addition
|
|
4593
4592
|
* to the built-in scheme / size / timeout policy.
|
|
4594
4593
|
*/
|
|
4595
4594
|
validateSourceUrl?: ByodSourceUrlValidator;
|
|
4596
4595
|
};
|
|
4597
4596
|
/**
|
|
4598
|
-
* Tunes
|
|
4599
|
-
*
|
|
4600
|
-
* main thread in Node/SSR)
|
|
4597
|
+
* Tunes the data tools' sandbox execution (see {@link CodeExecutionConfig}).
|
|
4598
|
+
* The environment, not this option, chooses where the code runs (off-thread iframe-worker
|
|
4599
|
+
* in the browser, main thread in Node/SSR). These options only adjust the isolated
|
|
4601
4600
|
* browser run (`timeoutMs`, `loadWorkerLibrarySource`).
|
|
4602
4601
|
*
|
|
4603
4602
|
* @experimental
|
|
@@ -4631,11 +4630,11 @@ export type MapAgentOptions<CS extends ToolState = ToolState> = {
|
|
|
4631
4630
|
* Defaults to `true`. Set to `false` for providers that don't support structured tool outputs.
|
|
4632
4631
|
*/
|
|
4633
4632
|
outputSchemas?: boolean;
|
|
4634
|
-
/**
|
|
4633
|
+
/** Maximum multi-step tool loop iterations. Defaults to 10. */
|
|
4635
4634
|
maxSteps?: number;
|
|
4636
4635
|
/**
|
|
4637
4636
|
* Opt into in-flight or experimental agent-toolkit behaviour. Stability
|
|
4638
|
-
* varies per flag
|
|
4637
|
+
* varies per flag (see {@link FeatureFlags} and each flag's own doc).
|
|
4639
4638
|
*
|
|
4640
4639
|
* @experimental
|
|
4641
4640
|
*/
|
|
@@ -4644,8 +4643,8 @@ export type MapAgentOptions<CS extends ToolState = ToolState> = {
|
|
|
4644
4643
|
* Provider-specific options forwarded to the AI SDK on every step. Keyed by
|
|
4645
4644
|
* provider id (`openai`, `azure`, `anthropic`, ...).
|
|
4646
4645
|
*
|
|
4647
|
-
* Use this to enable reasoning summaries for gpt-5.x via the Responses API
|
|
4648
|
-
*
|
|
4646
|
+
* Use this to enable reasoning summaries for gpt-5.x via the Responses API.
|
|
4647
|
+
* Without `reasoningSummary`, the model thinks but returns no reasoning text.
|
|
4649
4648
|
*
|
|
4650
4649
|
* @example
|
|
4651
4650
|
* ```typescript
|
|
@@ -4660,7 +4659,7 @@ export type MapAgentOptions<CS extends ToolState = ToolState> = {
|
|
|
4660
4659
|
providerOptions?: ProviderOptions;
|
|
4661
4660
|
/**
|
|
4662
4661
|
* Per-step `providerOptions` override. Called once per step with the
|
|
4663
|
-
* classifier-narrowed active toolset
|
|
4662
|
+
* classifier-narrowed active toolset. The returned object is merged on top
|
|
4664
4663
|
* of `providerOptions` for that step. Use it to bump reasoning effort on
|
|
4665
4664
|
* turns that include a code-execution tool without paying the cost on
|
|
4666
4665
|
* simple fetch/toggle turns.
|
|
@@ -4679,15 +4678,15 @@ export type MapAgentOptions<CS extends ToolState = ToolState> = {
|
|
|
4679
4678
|
}) => ProviderOptions | undefined;
|
|
4680
4679
|
};
|
|
4681
4680
|
/**
|
|
4682
|
-
* The return type of createMapAgent()
|
|
4683
|
-
*
|
|
4681
|
+
* The return type of createMapAgent(), a real ToolLoopAgent instance
|
|
4682
|
+
* with state access and cleanup.
|
|
4684
4683
|
*
|
|
4685
4684
|
* @group Agent Toolkit
|
|
4686
4685
|
*/
|
|
4687
4686
|
export type MapAgentInstance<CS extends ToolState = ToolState> = ToolLoopAgent & {
|
|
4688
4687
|
/** Live agent state (built-in + custom slices). */
|
|
4689
4688
|
readonly state: CS;
|
|
4690
|
-
/**
|
|
4689
|
+
/** Tears down by resetting all state slices that have a reset() method. */
|
|
4691
4690
|
destroy(): void;
|
|
4692
4691
|
};
|
|
4693
4692
|
//#endregion
|
|
@@ -4695,13 +4694,12 @@ export type MapAgentInstance<CS extends ToolState = ToolState> = ToolLoopAgent &
|
|
|
4695
4694
|
/**
|
|
4696
4695
|
* Creates a conversational agent toolkit that gives an LLM control over a TomTom map.
|
|
4697
4696
|
*
|
|
4698
|
-
*
|
|
4697
|
+
* It returns a ToolLoopAgent instance (compatible with DirectChatTransport) with
|
|
4699
4698
|
* `state` and `destroy` attached. Classification runs transparently inside
|
|
4700
|
-
* `prepareStep
|
|
4699
|
+
* `prepareStep`, so you need no wrapper type.
|
|
4701
4700
|
*
|
|
4702
|
-
* @param map - The
|
|
4703
|
-
* @
|
|
4704
|
-
* @returns A ToolLoopAgent with state access and cleanup
|
|
4701
|
+
* @param map - The map to control.
|
|
4702
|
+
* @returns A ToolLoopAgent with state access and cleanup.
|
|
4705
4703
|
*
|
|
4706
4704
|
* @example Basic usage
|
|
4707
4705
|
* ```typescript
|
|
@@ -4738,11 +4736,11 @@ export declare const createMapAgent: <CS extends ToolState = ToolState>(map: Tom
|
|
|
4738
4736
|
*
|
|
4739
4737
|
* - `ToolEntry` (or builder) values add or replace tools in `defaults`.
|
|
4740
4738
|
* - `false` values remove tools from `defaults`.
|
|
4741
|
-
* -
|
|
4739
|
+
* - It returns a new object and never mutates `defaults`.
|
|
4742
4740
|
*
|
|
4743
4741
|
* Default entries may be {@link ToolEntryBuilder builders} that produce
|
|
4744
4742
|
* their {@link ToolEntry} from build-time options. Builders pass through
|
|
4745
|
-
* untouched and
|
|
4743
|
+
* untouched, and `setupTools` materializes them later.
|
|
4746
4744
|
*
|
|
4747
4745
|
* @param defaults - Base tool record (typically DEFAULT_TOOLS or empty).
|
|
4748
4746
|
* @param overrides - User-provided additions, replacements, and exclusions.
|
|
@@ -4750,7 +4748,7 @@ export declare const createMapAgent: <CS extends ToolState = ToolState>(map: Tom
|
|
|
4750
4748
|
*
|
|
4751
4749
|
* @group Agent Toolkit
|
|
4752
4750
|
*/
|
|
4753
|
-
export declare const resolveTools: <S extends ToolState>(defaults: Record<string, ToolDefinition<S>>, overrides?:
|
|
4751
|
+
export declare const resolveTools: <S extends ToolState>(defaults: Record<string, ToolDefinition<S>>, overrides?: MapAgentOptions<S>["tools"]) => Record<string, ToolDefinition<S>>;
|
|
4754
4752
|
//#endregion
|
|
4755
4753
|
//#region src/tools/utilities/clarify-user-intent.d.ts
|
|
4756
4754
|
/** A single clarification question shown to the user. Exported so a host can type its form state. */
|
|
@@ -4760,7 +4758,7 @@ export declare const questionSchema: z.ZodObject<{
|
|
|
4760
4758
|
options: z.ZodArray<z.ZodString>;
|
|
4761
4759
|
multiSelect: z.ZodDefault<z.ZodBoolean>;
|
|
4762
4760
|
}, z.core.$strip>;
|
|
4763
|
-
/** One clarification question
|
|
4761
|
+
/** One clarification question, the unit a host UI renders. */
|
|
4764
4762
|
type ClarifyIntentQuestion = z.infer<typeof questionSchema>;
|
|
4765
4763
|
/**
|
|
4766
4764
|
* Input schema for {@link executeClarifyIntent}.
|
|
@@ -4777,8 +4775,8 @@ export declare const clarifyIntentSchema: z.ZodObject<{
|
|
|
4777
4775
|
/**
|
|
4778
4776
|
* Output schema for {@link executeClarifyIntent}. The tool resolves immediately, echoing back the
|
|
4779
4777
|
* `intro` + `questions` (so a host can render the whole form) plus an `awaiting_user_response` status.
|
|
4780
|
-
* No "stop and wait" directive is echoed
|
|
4781
|
-
*
|
|
4778
|
+
* No "stop and wait" directive is echoed, because the description-level usage contract already carries
|
|
4779
|
+
* it. CLARIFY_FORM_PROMPT and CLARIFY_PROSE_PROMPT both tell the agent to STOP and wait, so repeating it
|
|
4782
4780
|
* in the result would be redundant.
|
|
4783
4781
|
*/
|
|
4784
4782
|
export declare const clarifyIntentOutputSchema: z.ZodObject<{
|
|
@@ -4793,7 +4791,7 @@ export declare const clarifyIntentOutputSchema: z.ZodObject<{
|
|
|
4793
4791
|
}, z.core.$strip>;
|
|
4794
4792
|
/** Usage contract appended to the description when the host renders the form: silent turn, questions not restated in prose. */
|
|
4795
4793
|
export declare const CLARIFY_FORM_PROMPT: string;
|
|
4796
|
-
/** Usage contract appended to the description when there is no form
|
|
4794
|
+
/** Usage contract appended to the description when there is no form. The model also writes the questions as prose so any UI shows them. */
|
|
4797
4795
|
export declare const CLARIFY_PROSE_PROMPT: string;
|
|
4798
4796
|
/** Per-call overrides accepted by {@link createClarifyIntentTool}. */
|
|
4799
4797
|
type ClarifyIntentToolOptions = {
|
|
@@ -4806,19 +4804,19 @@ type ClarifyIntentToolOptions = {
|
|
|
4806
4804
|
/** Replace the default natural-language example prompts. */
|
|
4807
4805
|
examplePrompts?: string[];
|
|
4808
4806
|
/**
|
|
4809
|
-
*
|
|
4810
|
-
* to clarify, even mid-task
|
|
4807
|
+
* Whether the tool stays active on every step regardless of the classifier, so the agent can always
|
|
4808
|
+
* ask to clarify, even mid-task. Defaults to `true`. `false` leaves activation to the classifier.
|
|
4811
4809
|
*/
|
|
4812
4810
|
alwaysActive?: boolean;
|
|
4813
4811
|
/**
|
|
4814
|
-
*
|
|
4815
|
-
* the agent narrates the questions as prose so they reach a form-less UI.
|
|
4812
|
+
* Whether your host renders the clarifyIntent form. `true` uses the silent form contract. With
|
|
4813
|
+
* `false` (default), the agent narrates the questions as prose so they reach a form-less UI.
|
|
4816
4814
|
*/
|
|
4817
4815
|
rendersForm?: boolean;
|
|
4818
4816
|
};
|
|
4819
4817
|
/**
|
|
4820
|
-
*
|
|
4821
|
-
* specific domain. The schema and `execute` are fixed
|
|
4818
|
+
* Builds a clarifyIntent {@link ToolEntry}, optionally overriding its description and examples for a
|
|
4819
|
+
* specific domain. The schema and `execute` are fixed. Only the classifier-facing metadata is
|
|
4822
4820
|
* customizable. Pass the result to `createMapAgent`'s `tools` option to replace the built-in default:
|
|
4823
4821
|
*
|
|
4824
4822
|
* ```typescript
|
|
@@ -4838,14 +4836,14 @@ export declare const createClarifyIntentTool: (options?: ClarifyIntentToolOption
|
|
|
4838
4836
|
//#region src/tools/utilities/get-current-location.d.ts
|
|
4839
4837
|
type GetCurrentLocationToolOptions = {
|
|
4840
4838
|
/**
|
|
4841
|
-
*
|
|
4842
|
-
* fresh high-accuracy fix.
|
|
4839
|
+
* Whether the model gets the exact position, the device's accuracy and the fix's timestamp, from a
|
|
4840
|
+
* fresh high-accuracy fix. By default (`false`), the position is rounded to 3 decimals (about
|
|
4843
4841
|
* 100 m) from a fix up to a minute old, with no timestamp.
|
|
4844
4842
|
*/
|
|
4845
4843
|
fullPrecision?: boolean;
|
|
4846
4844
|
};
|
|
4847
4845
|
/**
|
|
4848
|
-
*
|
|
4846
|
+
* Builds a getCurrentLocation {@link ToolEntry}. Pass the result to `createMapAgent`'s `tools` option
|
|
4849
4847
|
* to replace the built-in default, for example to send the exact position:
|
|
4850
4848
|
*
|
|
4851
4849
|
* ```typescript
|