@tomtom-org/maps-sdk-plugin-agent-toolkit 0.16.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -13
- package/THIRD_PARTY.txt +3 -3
- package/dist/THIRD_PARTY.txt +3 -3
- package/dist/index.d.ts +104 -32
- package/dist/index.es.js +2 -2
- package/dist/third-party.json +3 -3
- package/dist/{worker-libs-tTFEqlXk.js → worker-libs-B6xqxvae.js} +1 -1
- package/package.json +15 -15
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# Agent Toolkit Plugin
|
|
2
2
|
|
|
3
|
-
This plugin is a headless conversational agent that gives large language models tool-based control over a [TomTom Map](https://docs.tomtom.com/maps-sdk-js/guides/map/tomtom-map) and TomTom location services. It's built on [Vercel AI SDK
|
|
3
|
+
This plugin is a headless conversational agent that gives large language models tool-based control over a [TomTom Map](https://docs.tomtom.com/maps-sdk-js/guides/map/tomtom-map) and TomTom location services. It's built on [Vercel AI SDK v7](https://ai-sdk.dev/).
|
|
4
|
+
|
|
5
|
+
> **Public preview.** This plugin is in [Public Preview](https://docs.tomtom.com/legal/public-preview) until its 1.0.0 release.
|
|
4
6
|
|
|
5
7
|
The plugin has no UI, so you bring your own chat interface. It bundles no LLM provider, so you supply any AI SDK-compatible model.
|
|
6
8
|
|
|
@@ -85,7 +87,7 @@ For a full working app, see the [traffic agent example](https://docs.tomtom.com/
|
|
|
85
87
|
|
|
86
88
|
## Tools reference
|
|
87
89
|
|
|
88
|
-
The plugin ships a `DEFAULT_TOOLS` registry that covers search, routing, traffic, reachable areas, BYOD GeoJSON, base-map control, MapLibre access and code-generated analysis. The agent gets every tool by default, and you can remove or replace each one through the [`tools` option](#composing-tool-sets). The [Agent Toolkit guide](https://docs.tomtom.com/maps-sdk-js/guides/plugins/agent-toolkit/tools) has the full per-tool reference.
|
|
90
|
+
The plugin ships a `DEFAULT_TOOLS` registry that covers search, routing, traffic, reachable areas, BYOD GeoJSON, base-map control, MapLibre access and code-generated analysis. The agent gets every tool in it by default, and you can remove or replace each one through the [`tools` option](#composing-tool-sets). The [Agent Toolkit guide](https://docs.tomtom.com/maps-sdk-js/guides/plugins/agent-toolkit/tools) has the full per-tool reference.
|
|
89
91
|
|
|
90
92
|
### Location & search
|
|
91
93
|
|
|
@@ -147,11 +149,12 @@ The plugin ships a `DEFAULT_TOOLS` registry that covers search, routing, traffic
|
|
|
147
149
|
| `analyseData` | Aggregate or chart entries (`places`, `routes`, `incidents`, `geometries`, `trafficAreaAnalytics`, `byod`) with dynamic JS. The scope the classifier emits narrows the schema each turn |
|
|
148
150
|
| `processData` | Transform entries, with dynamic JS, into new `places`, `placeConnections`, `geometries`, `byod` or a `fitOnMap` camera move |
|
|
149
151
|
| `monitorAnalysis` | Start or stop recomputing an `analyseData` analysis whenever its source entries change |
|
|
150
|
-
|
|
152
|
+
|
|
153
|
+
`executeMaplibreCode` runs arbitrary MapLibre JS against the live `Map` instance, an escape hatch for custom layers, animations and raster overlays. Its code runs in your page with no sandbox, so it's not in `DEFAULT_TOOLS`. Add it with `tools: { executeMaplibreCode: createExecuteMaplibreCodeTool() }` only where you trust the model.
|
|
151
154
|
|
|
152
155
|
> See [Code generation](https://docs.tomtom.com/maps-sdk-js/guides/plugins/agent-toolkit/code-generation) for the injected identifiers, output contracts and threat model, and [Scope-aware data tools](https://docs.tomtom.com/maps-sdk-js/guides/plugins/agent-toolkit/scope-aware-data-tools) for how the per-turn classifier scope keeps the prompt small.
|
|
153
156
|
|
|
154
|
-
`analyseData`, `processData`, `createTracker` and `clusterIncidents` code is **
|
|
157
|
+
`analyseData`, `processData`, `createTracker` and `clusterIncidents` code is **isolated in the browser, or not run**, unless you opt into `codeExecution.allowMainThreadFallback`. It runs in a Web Worker inside a sandboxed, opaque-origin iframe with no DOM or network access, terminable on timeout. The SDK lazily loads its own bundled turf and h3 for the worker, so a page without a Content Security Policy needs no configuration. A page with one must allow what the sandbox needs, which the code-generation guide lists. The environment decides where the code runs. The browser isolates it, while Node and SSR always run it on the main thread. That boundary has no equivalent there, so the protection is defense-in-depth only. The optional `codeExecution` tunes the browser run:
|
|
155
158
|
|
|
156
159
|
```typescript
|
|
157
160
|
const agent = createMapAgent(map, {
|
|
@@ -160,7 +163,7 @@ const agent = createMapAgent(map, {
|
|
|
160
163
|
});
|
|
161
164
|
```
|
|
162
165
|
|
|
163
|
-
> **Experimental.** The `e2e-tests/` suite verifies the isolation boundary (CSP egress-block, worker termination, opaque-origin isolation) and runs in CI as a dedicated job. If the iframe can't
|
|
166
|
+
> **Experimental.** The `e2e-tests/` suite verifies the isolation boundary (CSP egress-block, worker termination, opaque-origin isolation) and runs in CI as a dedicated job. If the iframe can't start, the code doesn't run. The tool returns an error to the model, and a call 30 seconds or more later tries again. `agent.getCodeExecutionMode()` reports where the code runs, and `codeExecution.allowMainThreadFallback: true` runs it in the page, not isolated, and does not retry the iframe. The worker bundles `turf`, `h3` and `routeUtils`, so that code, route slicing included, runs fully in the browser. See the [code-generation guide](https://docs.tomtom.com/maps-sdk-js/guides/plugins/agent-toolkit/code-generation#data-tool-execution-isolation-experimental).
|
|
164
167
|
|
|
165
168
|
### Map display
|
|
166
169
|
|
|
@@ -533,13 +536,14 @@ const agent = createMapAgent(map, {
|
|
|
533
536
|
|
|
534
537
|
### The `MapAgentInstance`
|
|
535
538
|
|
|
536
|
-
`createMapAgent` returns a `ToolLoopAgent` (usable directly with `DirectChatTransport`) with
|
|
539
|
+
`createMapAgent` returns a `ToolLoopAgent` (usable directly with `DirectChatTransport`) with three extra properties:
|
|
537
540
|
|
|
538
541
|
```typescript
|
|
539
542
|
const agent = createMapAgent(map, { model });
|
|
540
543
|
|
|
541
|
-
agent.state;
|
|
542
|
-
agent.
|
|
544
|
+
agent.state; // Live state — typed as CS when custom state is provided, ToolState otherwise
|
|
545
|
+
agent.getCodeExecutionMode(); // Where the code-generation tools run: not-started, iframe-worker, unavailable or main-thread
|
|
546
|
+
agent.destroy(); // Reset all state slices (call on unmount)
|
|
543
547
|
```
|
|
544
548
|
|
|
545
549
|
## Public API exports
|
|
@@ -552,11 +556,11 @@ For the complete, always-current list of exports, including factories, tool-regi
|
|
|
552
556
|
|
|
553
557
|
| Type | Package | Purpose |
|
|
554
558
|
|---|---|---|
|
|
555
|
-
| Peer | `@tomtom-org/maps-sdk
|
|
559
|
+
| Peer | `@tomtom-org/maps-sdk@^1.0.0-rc.4` | TomTom Maps SDK (types, services, map modules), from 1.0.0-rc.4 through every 1.x release |
|
|
556
560
|
| Peer | `@tomtom-org/maps-sdk-plugin-map-theme@>=0.3.0` | Theming the map from a few colours or an image in `setMapStyling` |
|
|
557
|
-
| Peer | `ai@^
|
|
558
|
-
| Peer | `zod@^4` | Schema validation |
|
|
559
|
-
| Peer | `maplibre-gl@^6` | Map rendering engine |
|
|
561
|
+
| Peer | `ai@^7.0.143` | Vercel AI SDK (ToolLoopAgent, tool types) |
|
|
562
|
+
| Peer | `zod@^4.6.7` | Schema validation |
|
|
563
|
+
| Peer | `maplibre-gl@^6.15.0` | Map rendering engine |
|
|
560
564
|
| Peer | `@turf/turf@^7` | Geospatial math (distance, bbox, bearing) used by the data tools |
|
|
561
565
|
| Peer | `chart.js@^4` | Chart rendering for `analyseData` outputs |
|
|
562
566
|
| Peer | `h3-js@^4` | H3 hexagonal grid for `processData` coverage / hexgrid visualizations |
|
|
@@ -571,10 +575,14 @@ For the complete, always-current list of exports, including factories, tool-regi
|
|
|
571
575
|
- [Code generation](https://docs.tomtom.com/maps-sdk-js/guides/plugins/agent-toolkit/code-generation) — `analyseData` / `processData` / `createTracker` / `clusterIncidents` / `executeMaplibreCode` (threat model included)
|
|
572
576
|
- [Scope-aware data tools](https://docs.tomtom.com/maps-sdk-js/guides/plugins/agent-toolkit/scope-aware-data-tools) — per-turn scope mechanism
|
|
573
577
|
- [Bring your own data](https://docs.tomtom.com/maps-sdk-js/guides/plugins/agent-toolkit/byod) — ingest customer GeoJSON layers
|
|
574
|
-
- [AI SDK
|
|
578
|
+
- [AI SDK v7 documentation](https://ai-sdk.dev/)
|
|
575
579
|
- [TomTom Maps SDK documentation](https://docs.tomtom.com/maps-sdk-js)
|
|
576
580
|
- [Example application](https://docs.tomtom.com/maps-sdk-js/examples/map-traffic-agent-react) — full chat interface implementation
|
|
577
581
|
|
|
578
582
|
## License
|
|
579
583
|
|
|
580
584
|
See `LICENSE.txt`.
|
|
585
|
+
|
|
586
|
+
## Security
|
|
587
|
+
|
|
588
|
+
To report a security vulnerability, follow [SECURITY.md](https://github.com/tomtom-international/maps-sdk-js/blob/main/SECURITY.md), which keeps it private.
|
package/THIRD_PARTY.txt
CHANGED
|
@@ -49,7 +49,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
49
49
|
---
|
|
50
50
|
|
|
51
51
|
Name: ai
|
|
52
|
-
Version:
|
|
52
|
+
Version: 7.0.143
|
|
53
53
|
License: Apache-2.0
|
|
54
54
|
Bundled: false (peer dependency)
|
|
55
55
|
Description: AI SDK by Vercel - build apps like ChatGPT, Claude, Gemini, and more with a single interface for any model using the Vercel AI Gateway or go direct to OpenAI, Anthropic, Google, or any other model provider.
|
|
@@ -334,7 +334,7 @@ limitations under the License.
|
|
|
334
334
|
---
|
|
335
335
|
|
|
336
336
|
Name: maplibre-gl
|
|
337
|
-
Version: 6.
|
|
337
|
+
Version: 6.15.0
|
|
338
338
|
License: BSD-3-Clause
|
|
339
339
|
Bundled: false (peer dependency)
|
|
340
340
|
Description: BSD licensed community fork of mapbox-gl, a WebGL interactive maps library
|
|
@@ -464,7 +464,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
464
464
|
---
|
|
465
465
|
|
|
466
466
|
Name: zod
|
|
467
|
-
Version: 4.6.
|
|
467
|
+
Version: 4.6.7
|
|
468
468
|
License: MIT
|
|
469
469
|
Bundled: false (peer dependency)
|
|
470
470
|
Description: TypeScript-first schema declaration and validation library with static type inference
|
package/dist/THIRD_PARTY.txt
CHANGED
|
@@ -39,7 +39,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
39
39
|
---
|
|
40
40
|
|
|
41
41
|
Name: ai
|
|
42
|
-
Version:
|
|
42
|
+
Version: 7.0.143
|
|
43
43
|
License: Apache-2.0
|
|
44
44
|
Bundled: false (peer dependency)
|
|
45
45
|
Description: AI SDK by Vercel - build apps like ChatGPT, Claude, Gemini, and more with a single interface for any model using the Vercel AI Gateway or go direct to OpenAI, Anthropic, Google, or any other model provider.
|
|
@@ -324,7 +324,7 @@ limitations under the License.
|
|
|
324
324
|
---
|
|
325
325
|
|
|
326
326
|
Name: maplibre-gl
|
|
327
|
-
Version: 6.
|
|
327
|
+
Version: 6.15.0
|
|
328
328
|
License: BSD-3-Clause
|
|
329
329
|
Bundled: false (peer dependency)
|
|
330
330
|
Description: BSD licensed community fork of mapbox-gl, a WebGL interactive maps library
|
|
@@ -454,7 +454,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
454
454
|
---
|
|
455
455
|
|
|
456
456
|
Name: zod
|
|
457
|
-
Version: 4.6.
|
|
457
|
+
Version: 4.6.7
|
|
458
458
|
License: MIT
|
|
459
459
|
Bundled: false (peer dependency)
|
|
460
460
|
Description: TypeScript-first schema declaration and validation library with static type inference
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { ChartConfiguration } from "chart.js";
|
|
|
4
4
|
import { Map as Map$1 } from "maplibre-gl";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
import { GeoBias, TrafficIncidentDetailsByBBoxParams } from "@tomtom-org/maps-sdk/services";
|
|
7
|
-
import { LanguageModel, ModelMessage, PrepareStepFunction, ToolLoopAgent } from "ai";
|
|
7
|
+
import { LanguageModel, ModelMessage, PrepareStepFunction, ToolLoopAgent, ToolSet } from "ai";
|
|
8
8
|
//#region src/engine/engine.d.ts
|
|
9
9
|
/** What {@link JobEngine.register} needs to mint a {@link Job}. `run` and `onOrphaned` are owner closures. */
|
|
10
10
|
type JobSpec = {
|
|
@@ -156,7 +156,7 @@ export type SandboxExecutor = {
|
|
|
156
156
|
destroy?(): void;
|
|
157
157
|
};
|
|
158
158
|
/**
|
|
159
|
-
* Default executor for Node/SSR (and the
|
|
159
|
+
* Default executor for Node/SSR (and the browser's opt-in `allowMainThreadFallback`): compiles + runs the
|
|
160
160
|
* code synchronously in the host realm. Deep-copies data inputs (see
|
|
161
161
|
* {@link cloneDataArg}) so the body can't mutate live state, but provides no isolation
|
|
162
162
|
* beyond the global shadowing — see {@link SHADOWED_GLOBALS}.
|
|
@@ -802,10 +802,10 @@ export declare const buildEntryKindScopeSchema: (enabled: readonly EntryDataKind
|
|
|
802
802
|
kinds: z.ZodArray<z.ZodEnum<{
|
|
803
803
|
places: "places";
|
|
804
804
|
routes: "routes";
|
|
805
|
-
incidents: "incidents";
|
|
806
|
-
customGeometries: "customGeometries";
|
|
807
805
|
trafficAreaAnalytics: "trafficAreaAnalytics";
|
|
806
|
+
customGeometries: "customGeometries";
|
|
808
807
|
byod: "byod";
|
|
808
|
+
incidents: "incidents";
|
|
809
809
|
}>>;
|
|
810
810
|
}, z.core.$strip>;
|
|
811
811
|
/**
|
|
@@ -1670,6 +1670,10 @@ type RoutesEntry = BaseEntry<Routes> & {
|
|
|
1670
1670
|
_module?: RoutingModule;
|
|
1671
1671
|
/** True while this entry's `_module` is rendering routes/waypoints on the map. */
|
|
1672
1672
|
_shown?: boolean;
|
|
1673
|
+
/** False once its waypoint pins are hidden, which every later show keeps until they are shown again. */
|
|
1674
|
+
_waypointsShown?: boolean;
|
|
1675
|
+
/** Finds the ids of the sections to ring on a route, so a monitor tick rings them on the recalculated one. */
|
|
1676
|
+
_sectionFocus?: (route: Route) => readonly string[];
|
|
1673
1677
|
/**
|
|
1674
1678
|
* Per-entry route monitor. Lazy-created on first {@link RoutingState.startMonitoring}; reused
|
|
1675
1679
|
* across stop/start cycles. Recalculates this route (same waypoints + params) on its interval so
|
|
@@ -1784,14 +1788,21 @@ declare class RoutingState implements ShownEntriesSlice {
|
|
|
1784
1788
|
* layers don't pile up. With `entryMode === 'multiple'`, previously-shown entries stay
|
|
1785
1789
|
* rendered, so the caller can overlay several routes at once.
|
|
1786
1790
|
*
|
|
1787
|
-
* Emits `shown-change` once the new entry is up. Pass `showWaypoints
|
|
1788
|
-
*
|
|
1789
|
-
* per-route ETA bubbles (e.g. a monitored
|
|
1791
|
+
* Emits `shown-change` once the new entry is up. Pass `showWaypoints` to show or hide the
|
|
1792
|
+
* origin/stop/destination pins for this show only, over the entry's {@link setWaypointsShown}
|
|
1793
|
+
* choice, and `showSummaryBubbles: false` to drop the per-route ETA bubbles (e.g. a monitored
|
|
1794
|
+
* corridor backdrop).
|
|
1790
1795
|
*/
|
|
1791
1796
|
showEntry(entryId: string, opts?: {
|
|
1792
1797
|
showWaypoints?: boolean;
|
|
1793
1798
|
showSummaryBubbles?: boolean;
|
|
1794
1799
|
}): Promise<void>;
|
|
1800
|
+
/**
|
|
1801
|
+
* Shows or hides the origin/stop/destination pins of an entry's routes, and keeps that choice
|
|
1802
|
+
* for every later {@link showEntry}. An entry not on the map only records it.
|
|
1803
|
+
*/
|
|
1804
|
+
setWaypointsShown(entryId: string, shown: boolean): Promise<void>;
|
|
1805
|
+
private _renderWaypoints;
|
|
1795
1806
|
/**
|
|
1796
1807
|
* Hides the entry's routes and waypoints by clearing its module, which stays cached.
|
|
1797
1808
|
* Does nothing if the entry is unknown or already hidden.
|
|
@@ -3330,11 +3341,15 @@ export declare const isResolveError: (r: unknown) => r is ResolveError;
|
|
|
3330
3341
|
*/
|
|
3331
3342
|
export declare const routeUtils: {
|
|
3332
3343
|
readonly calculateProgressAtRoutePoint: (route: import("@tomtom-org/maps-sdk/core").Route, pathIndex: number) => import("@tomtom-org/maps-sdk/core").RouteProgressAtPoint | undefined;
|
|
3344
|
+
readonly compareRoutes: (route: import("@tomtom-org/maps-sdk/core").Route, reference: import("@tomtom-org/maps-sdk/core").Route, { types }?: import("@tomtom-org/maps-sdk/core").CompareRoutesOptions) => import("@tomtom-org/maps-sdk/core").RouteComparison;
|
|
3333
3345
|
readonly getCoordinateAtRouteProgress: (route: import("@tomtom-org/maps-sdk/core").Route, query: import("@tomtom-org/maps-sdk/core").RouteProgressQuery) => import("@tomtom-org/maps-sdk/core").RouteCoordinateAtProgress | undefined;
|
|
3346
|
+
readonly getImportantRoads: (route: import("@tomtom-org/maps-sdk/core").Route, { within, minLengthInMeters }?: import("@tomtom-org/maps-sdk/core").ImportantRoadsOptions) => import("@tomtom-org/maps-sdk/core").ImportantRoad[];
|
|
3334
3347
|
readonly getProgressAtNearestRoutePoint: (route: import("@tomtom-org/maps-sdk/core").Route, point: import("@tomtom-org/maps-sdk/core").HasLngLat) => import("@tomtom-org/maps-sdk/core").RouteCoordinateAtProgress | undefined;
|
|
3335
3348
|
readonly getRouteProgressBetween: (route: import("@tomtom-org/maps-sdk/core").Route, startPathIndex: number, endPathIndex: number) => import("@tomtom-org/maps-sdk/core").RouteSegmentProgress | undefined;
|
|
3336
3349
|
readonly getRouteProgressForSection: (route: import("@tomtom-org/maps-sdk/core").Route, section: import("@tomtom-org/maps-sdk/core").RouteSpan) => import("@tomtom-org/maps-sdk/core").RouteSegmentProgress | undefined;
|
|
3337
3350
|
readonly getSectionBBox: (route: import("@tomtom-org/maps-sdk/core").Route, section: import("@tomtom-org/maps-sdk/core").RouteSpan) => import("@tomtom-org/maps-sdk/core").OptionalBBox;
|
|
3351
|
+
readonly getSectionsWithin: (route: import("@tomtom-org/maps-sdk/core").Route, { within, types }?: import("@tomtom-org/maps-sdk/core").SectionsWithinOptions) => import("@tomtom-org/maps-sdk/core").SectionsWithin;
|
|
3352
|
+
readonly isHairpin: (curve: Pick<import("@tomtom-org/maps-sdk/core").CurveSectionProps, "headingChangeInDegrees" | "radiusInMeters" | "maneuver">) => boolean;
|
|
3338
3353
|
};
|
|
3339
3354
|
//#endregion
|
|
3340
3355
|
//#region src/tools/shared/routes-schema-doc.d.ts
|
|
@@ -3702,16 +3717,15 @@ type ByodSourceUrlValidation = {
|
|
|
3702
3717
|
reason: string;
|
|
3703
3718
|
};
|
|
3704
3719
|
/**
|
|
3705
|
-
* An app-supplied authorization hook for BYOD source URLs. `addByodSource` runs it
|
|
3706
|
-
*
|
|
3707
|
-
*
|
|
3708
|
-
*
|
|
3709
|
-
* an allowlist lookup.
|
|
3720
|
+
* An app-supplied authorization hook for BYOD source URLs. `addByodSource` runs it on
|
|
3721
|
+
* every `http:` or `https:` URL, before the network fetch. Return `{ valid: true }` to
|
|
3722
|
+
* allow the fetch or `{ valid: false, reason }` to block it (see
|
|
3723
|
+
* {@link ByodSourceUrlValidation}). It may be sync or async, such as an allowlist lookup.
|
|
3710
3724
|
*
|
|
3711
|
-
*
|
|
3712
|
-
*
|
|
3713
|
-
*
|
|
3714
|
-
*
|
|
3725
|
+
* It **replaces** the built-in policy, which allows only public `https:` URLs: no
|
|
3726
|
+
* `http:`, no page origin, no `localhost`-style hostname and no loopback, private,
|
|
3727
|
+
* link-local or other non-public IP address. The size cap, the timeout, the omitted
|
|
3728
|
+
* credentials and the refused redirects apply either way. Set it via the
|
|
3715
3729
|
* `byod.validateSourceUrl` option on `createMapAgent`, or assign
|
|
3716
3730
|
* `state.byod.sourceUrlValidator` directly.
|
|
3717
3731
|
*
|
|
@@ -3737,8 +3751,8 @@ declare class BYODState implements ShownEntriesSlice, StateSlice {
|
|
|
3737
3751
|
readonly events: StateEvents<BYODStateEvents>;
|
|
3738
3752
|
/**
|
|
3739
3753
|
* The optional authorization hook for `addByodSource` URL fetches (see
|
|
3740
|
-
* {@link ByodSourceUrlValidator}). If unset,
|
|
3741
|
-
*
|
|
3754
|
+
* {@link ByodSourceUrlValidator}). If unset, the built-in policy allows only
|
|
3755
|
+
* public `https:` URLs.
|
|
3742
3756
|
*/
|
|
3743
3757
|
sourceUrlValidator?: ByodSourceUrlValidator;
|
|
3744
3758
|
constructor(_ttMap: TomTomMap);
|
|
@@ -3958,6 +3972,8 @@ export declare const buildSystemPrompt: ({ customPrompt, prefix, suffix }?: Buil
|
|
|
3958
3972
|
*
|
|
3959
3973
|
* createMapAgent includes it automatically unless includeDefaultTools is false.
|
|
3960
3974
|
* For manual composition outside createMapAgent, use resolveTools().
|
|
3975
|
+
* It leaves out executeMaplibreCode, which runs model-written code in your page.
|
|
3976
|
+
* createExecuteMaplibreCodeTool() adds it.
|
|
3961
3977
|
*
|
|
3962
3978
|
* @group Agent Toolkit
|
|
3963
3979
|
*/
|
|
@@ -4004,7 +4020,6 @@ export declare const DEFAULT_TOOLS: {
|
|
|
4004
4020
|
setLayerProperties: ToolDefinition;
|
|
4005
4021
|
setPitchBearing: ToolDefinition;
|
|
4006
4022
|
zoomInOrOut: ToolDefinition;
|
|
4007
|
-
executeMaplibreCode: ToolDefinition;
|
|
4008
4023
|
calculateBBox: ToolDefinition;
|
|
4009
4024
|
getCurrentLocation: ToolDefinition;
|
|
4010
4025
|
clarifyIntent: ToolDefinition;
|
|
@@ -4050,6 +4065,17 @@ export declare const TOOLS_BY_DATA_ENTRY_KIND: Record<DataEntryKind, readonly To
|
|
|
4050
4065
|
*/
|
|
4051
4066
|
export declare const getDefaultToolPrompts: () => Record<ToolName, readonly string[]>;
|
|
4052
4067
|
//#endregion
|
|
4068
|
+
//#region src/tools/shared/sandbox/iframe-worker-executor.d.ts
|
|
4069
|
+
/**
|
|
4070
|
+
* A {@link SandboxExecutor} that reports where its code currently runs, for
|
|
4071
|
+
* `MapAgentInstance.getCodeExecutionMode`.
|
|
4072
|
+
*
|
|
4073
|
+
* @ignore
|
|
4074
|
+
*/
|
|
4075
|
+
type ResolvedSandboxExecutor = SandboxExecutor & {
|
|
4076
|
+
getMode(): CodeExecutionMode;
|
|
4077
|
+
};
|
|
4078
|
+
//#endregion
|
|
4053
4079
|
//#region src/utils/types/intent-classifier.d.ts
|
|
4054
4080
|
/**
|
|
4055
4081
|
* Result returned by {@link classifyUserIntent}.
|
|
@@ -4219,7 +4245,7 @@ export type ToolState = {
|
|
|
4219
4245
|
* `createMapAgent` re-resolves it with {@link MapAgentOptions.codeExecution}. Tools read this
|
|
4220
4246
|
* to select where sandbox code runs.
|
|
4221
4247
|
*/
|
|
4222
|
-
codeExecution:
|
|
4248
|
+
codeExecution: ResolvedSandboxExecutor;
|
|
4223
4249
|
/**
|
|
4224
4250
|
* The single recurrence engine. Owners (`analyses`, `trackers`) register entry-anchored jobs and keep
|
|
4225
4251
|
* the returned handles. The engine re-runs each active job when its source entries change. It is generic
|
|
@@ -4242,11 +4268,10 @@ export type ToolState = {
|
|
|
4242
4268
|
};
|
|
4243
4269
|
/**
|
|
4244
4270
|
* Tunes the sandbox execution of `analyseData`, `processData`, `createTracker` and
|
|
4245
|
-
* `clusterIncidents` code.
|
|
4246
|
-
*
|
|
4247
|
-
* sandboxed, opaque-origin iframe + Web Worker (no DOM/storage access, no network
|
|
4271
|
+
* `clusterIncidents` code. The environment decides where the code runs. In the browser,
|
|
4272
|
+
* it is a sandboxed, opaque-origin iframe + Web Worker (no DOM/storage access, no network
|
|
4248
4273
|
* via CSP, terminable on timeout). In Node / SSR, where that boundary has no
|
|
4249
|
-
* equivalent, it is the main thread. The options below only
|
|
4274
|
+
* equivalent, it is the main thread. The options below only apply in the browser.
|
|
4250
4275
|
*
|
|
4251
4276
|
* @group Agent Toolkit
|
|
4252
4277
|
*/
|
|
@@ -4260,7 +4285,26 @@ export type CodeExecutionConfig = {
|
|
|
4260
4285
|
* `self.turf` and `self.h3` (string or Promise of one).
|
|
4261
4286
|
*/
|
|
4262
4287
|
loadWorkerLibrarySource?: () => string | Promise<string>;
|
|
4288
|
+
/**
|
|
4289
|
+
* Whether code runs on the page's main thread, NOT isolated, when the iframe can't start.
|
|
4290
|
+
* Defaults to `false`: the code-running tools then return an error to the model, and a
|
|
4291
|
+
* call 30 seconds or more later tries the iframe again. When `true`, the failure is final
|
|
4292
|
+
* and later runs stay on the main thread. {@link MapAgentInstance.getCodeExecutionMode} reports which happened.
|
|
4293
|
+
*/
|
|
4294
|
+
allowMainThreadFallback?: boolean;
|
|
4263
4295
|
};
|
|
4296
|
+
/**
|
|
4297
|
+
* Where `analyseData`, `processData`, `createTracker` and `clusterIncidents` code runs now:
|
|
4298
|
+
* - `not-started` - Browser. The iframe starts on the first code run.
|
|
4299
|
+
* - `iframe-worker` - Browser, isolated in the iframe's Web Worker.
|
|
4300
|
+
* - `unavailable` - Browser. The last start failed, so code-running tools return an error.
|
|
4301
|
+
* A call 30 seconds or more later tries again.
|
|
4302
|
+
* - `main-thread` - In the page, NOT isolated: Node / SSR, or a browser where the start failed with
|
|
4303
|
+
* {@link CodeExecutionConfig.allowMainThreadFallback} set. That failure does not retry the iframe.
|
|
4304
|
+
*
|
|
4305
|
+
* @group Agent Toolkit
|
|
4306
|
+
*/
|
|
4307
|
+
export type CodeExecutionMode = 'not-started' | 'iframe-worker' | 'unavailable' | 'main-thread';
|
|
4264
4308
|
/**
|
|
4265
4309
|
* Per-call options handed to a tool's `execute`, separate from its parsed input.
|
|
4266
4310
|
*
|
|
@@ -4614,9 +4658,9 @@ export type MapAgentOptions<CS extends ToolState = ToolState> = {
|
|
|
4614
4658
|
* createMapAgent(map, {
|
|
4615
4659
|
* model: openai('gpt-4o'),
|
|
4616
4660
|
* byod: {
|
|
4617
|
-
* //
|
|
4661
|
+
* // Allow only known hosts.
|
|
4618
4662
|
* validateSourceUrl: (url) =>
|
|
4619
|
-
* url.hostname === 'data.example.com'
|
|
4663
|
+
* url.protocol === 'https:' && url.hostname === 'data.example.com'
|
|
4620
4664
|
* ? { valid: true }
|
|
4621
4665
|
* : { valid: false, reason: `Host "${url.hostname}" is not allowed.` },
|
|
4622
4666
|
* },
|
|
@@ -4627,16 +4671,16 @@ export type MapAgentOptions<CS extends ToolState = ToolState> = {
|
|
|
4627
4671
|
/**
|
|
4628
4672
|
* Authorises each `addByodSource` URL before it is fetched (see
|
|
4629
4673
|
* {@link ByodSourceUrlValidator}). Return `{ valid: true }` to allow or
|
|
4630
|
-
* `{ valid: false, reason }` to block (sync or async). It
|
|
4631
|
-
*
|
|
4674
|
+
* `{ valid: false, reason }` to block (sync or async). It replaces the
|
|
4675
|
+
* built-in policy, which allows only public `https:` URLs.
|
|
4632
4676
|
*/
|
|
4633
4677
|
validateSourceUrl?: ByodSourceUrlValidator;
|
|
4634
4678
|
};
|
|
4635
4679
|
/**
|
|
4636
4680
|
* Tunes the data tools' sandbox execution (see {@link CodeExecutionConfig}).
|
|
4637
|
-
* The environment
|
|
4638
|
-
*
|
|
4639
|
-
*
|
|
4681
|
+
* The environment chooses where the code runs (off-thread iframe-worker in the browser,
|
|
4682
|
+
* main thread in Node/SSR). These options adjust the browser run (`timeoutMs`,
|
|
4683
|
+
* `loadWorkerLibrarySource`, `allowMainThreadFallback`).
|
|
4640
4684
|
*
|
|
4641
4685
|
* @experimental
|
|
4642
4686
|
*/
|
|
@@ -4662,8 +4706,11 @@ export type MapAgentOptions<CS extends ToolState = ToolState> = {
|
|
|
4662
4706
|
/**
|
|
4663
4707
|
* Custom prepareStep hook, composed with internal classification step.
|
|
4664
4708
|
* Your `activeTools` are intersected with the classifier's selection.
|
|
4709
|
+
* An `instructions` or `messages` override carries over to the later steps of the turn: build
|
|
4710
|
+
* `instructions` from `initialInstructions`, and `messages` from
|
|
4711
|
+
* `[...initialMessages, ...responseMessages]`, so the earlier steps' tool calls and results stay in.
|
|
4665
4712
|
*/
|
|
4666
|
-
prepareStep?: PrepareStepFunction
|
|
4713
|
+
prepareStep?: PrepareStepFunction<ToolSet>;
|
|
4667
4714
|
/**
|
|
4668
4715
|
* Whether to include output schemas on tools.
|
|
4669
4716
|
* Defaults to `true`. Set to `false` for providers that don't support structured tool outputs.
|
|
@@ -4725,6 +4772,11 @@ export type MapAgentOptions<CS extends ToolState = ToolState> = {
|
|
|
4725
4772
|
export type MapAgentInstance<CS extends ToolState = ToolState> = ToolLoopAgent & {
|
|
4726
4773
|
/** Live agent state (built-in + custom slices). */
|
|
4727
4774
|
readonly state: CS;
|
|
4775
|
+
/**
|
|
4776
|
+
* Where the data tools' generated code runs now. In a browser, `unavailable` (code fails) and
|
|
4777
|
+
* `main-thread` (code runs unisolated) both mean the iframe sandbox couldn't start.
|
|
4778
|
+
*/
|
|
4779
|
+
getCodeExecutionMode(): CodeExecutionMode;
|
|
4728
4780
|
/** Tears down by resetting all state slices that have a reset() method. */
|
|
4729
4781
|
destroy(): void;
|
|
4730
4782
|
};
|
|
@@ -4737,6 +4789,9 @@ export type MapAgentInstance<CS extends ToolState = ToolState> = ToolLoopAgent &
|
|
|
4737
4789
|
* `state` and `destroy` attached. Classification runs transparently inside
|
|
4738
4790
|
* `prepareStep`, so you need no wrapper type.
|
|
4739
4791
|
*
|
|
4792
|
+
* @remarks
|
|
4793
|
+
* **[Public Preview](https://docs.tomtom.com/legal/public-preview)** until the plugin's 1.0.0 release.
|
|
4794
|
+
*
|
|
4740
4795
|
* @param map - The map to control.
|
|
4741
4796
|
* @returns A ToolLoopAgent with state access and cleanup.
|
|
4742
4797
|
*
|
|
@@ -4789,6 +4844,23 @@ export declare const createMapAgent: <CS extends ToolState = ToolState>(map: Tom
|
|
|
4789
4844
|
*/
|
|
4790
4845
|
export declare const resolveTools: <S extends ToolState>(defaults: Record<string, ToolDefinition<S>>, overrides?: MapAgentOptions<S>["tools"]) => Record<string, ToolDefinition<S>>;
|
|
4791
4846
|
//#endregion
|
|
4847
|
+
//#region src/tools/maplibre/execute-maplibre-code.d.ts
|
|
4848
|
+
/**
|
|
4849
|
+
* Builds the executeMaplibreCode {@link ToolEntry}, which runs model-written JavaScript in your page
|
|
4850
|
+
* against the live MapLibre map, with no sandbox. It is not in `DEFAULT_TOOLS`: add it through
|
|
4851
|
+
* `createMapAgent`'s `tools` option only where you trust the model and every prompt and tool result it reads.
|
|
4852
|
+
*
|
|
4853
|
+
* ```typescript
|
|
4854
|
+
* createMapAgent(map, {
|
|
4855
|
+
* model,
|
|
4856
|
+
* tools: { executeMaplibreCode: createExecuteMaplibreCodeTool() },
|
|
4857
|
+
* });
|
|
4858
|
+
* ```
|
|
4859
|
+
*
|
|
4860
|
+
* @group Agent Toolkit
|
|
4861
|
+
*/
|
|
4862
|
+
export declare const createExecuteMaplibreCodeTool: () => ToolEntry;
|
|
4863
|
+
//#endregion
|
|
4792
4864
|
//#region src/tools/utilities/clarify-user-intent.d.ts
|
|
4793
4865
|
/** A single clarification question shown to the user. Exported so a host can type its form state. */
|
|
4794
4866
|
export declare const questionSchema: z.ZodObject<{
|