diff --git a/bun.lockb b/bun.lockb index d24d91ca..aef3c50b 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/components/map/map-data-context.tsx b/components/map/map-data-context.tsx index 149cb36b..07a16eb8 100644 --- a/components/map/map-data-context.tsx +++ b/components/map/map-data-context.tsx @@ -1,19 +1,15 @@ 'use client'; import React, { createContext, useContext, useState, ReactNode } from 'react'; -import { LngLatLike } from 'mapbox-gl'; // Import LngLatLike +import { LngLatLike } from 'mapbox-gl'; // Import LngLatLike\nimport type * as GeoJSON from 'geojson'; // Define the shape of the map data you want to share export interface MapData { - targetPosition?: LngLatLike | null; // For flying to a location - // TODO: Add other relevant map data types later (e.g., routeGeoJSON, poiList) - mapFeature?: any | null; // Generic feature from MCP hook's processLocationQuery - drawnFeatures?: Array<{ // Added to store drawn features and their measurements - id: string; - type: 'Polygon' | 'LineString'; - measurement: string; - geometry: any; - }>; + targetPosition?: LngLatLike | null; + routeGeoJSON?: GeoJSON.Feature | null; + markers?: Array<{ lat: number; lng: number; name?: string; address?: string }>; + polygons?: Array>; + drawnFeatures?: Array<{ id: string; type: 'Polygon' | 'LineString'; measurement: string; geometry: any }>; } interface MapDataContextType { diff --git a/components/map/map-query-handler.tsx b/components/map/map-query-handler.tsx index f3e36bbb..08f9fdea 100644 --- a/components/map/map-query-handler.tsx +++ b/components/map/map-query-handler.tsx @@ -2,24 +2,18 @@ import { useEffect } from 'react'; // Removed useMCPMapClient as we'll use data passed via props -import { useMapData } from './map-data-context'; +import { useMapData, MapData } from './map-data-context'; // Define the expected structure of the mcp_response from geospatialTool -interface McpResponseData { - location: { - latitude?: number; - longitude?: number; - place_name?: string; - address?: string; - }; - mapUrl?: string; -} +type McpResponseData = any; interface GeospatialToolOutput { - type: string; // e.g., "MAP_QUERY_TRIGGER" + type: string; originalUserInput: string; timestamp: string; + queryType: string; mcp_response: McpResponseData | null; + error?: string; } interface MapQueryHandlerProps { diff --git a/lib/agents/tools/geospatial.tsx b/lib/agents/tools/geospatial.tsx index cb1ff07c..525ab495 100644 --- a/lib/agents/tools/geospatial.tsx +++ b/lib/agents/tools/geospatial.tsx @@ -239,19 +239,8 @@ export const geospatialTool = ({ uiStream }: { uiStream: ReturnType 0) { - const firstResult = parsedData.results[0]; - mcpData = { location: { latitude: firstResult.coordinates?.latitude, longitude: firstResult.coordinates?.longitude, place_name: firstResult.name || firstResult.place_name, address: firstResult.full_address || firstResult.address }, mapUrl: parsedData.mapUrl }; - } else if (parsedData.location) { - mcpData = { location: { latitude: parsedData.location.latitude, longitude: parsedData.location.longitude, place_name: parsedData.location.place_name || parsedData.location.name, address: parsedData.location.address || parsedData.location.formatted_address }, mapUrl: parsedData.mapUrl || parsedData.map_url }; - } else { - throw new Error("Response missing required 'location' or 'results' field"); - } - } else throw new Error('Unexpected response format from mapping service'); - - feedbackMessage = `Successfully processed ${queryType} query for: ${mcpData.location.place_name || JSON.stringify(params)}`; + mcpData = content; + feedbackMessage = `Successfully processed ${queryType} query`; uiFeedbackStream.update(feedbackMessage); } catch (error: any) {