Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions app/actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import { Spinner } from '@/components/ui/spinner';
import { Section } from '@/components/section';
import { FollowupPanel } from '@/components/followup-panel';
import { inquire, researcher, taskManager, querySuggestor } from '@/lib/agents';
import { useGeospatialToolMcp } from '@/lib/agents/tools/geospatial'; // Added import for the hook
// Removed import of useGeospatialToolMcp as it no longer exists and was incorrectly used here.
// The geospatialTool (if used by agents like researcher) now manages its own MCP client.
import { writer } from '@/lib/agents/writer';
import { saveChat, getSystemPrompt } from '@/lib/actions/chat'; // Added getSystemPrompt
import { Chat, AIMessage } from '@/lib/types';
Expand All @@ -30,7 +31,8 @@ type RelatedQueries = {
items: { query: string }[];
};

async function submit(formData?: FormData, skip?: boolean, mcp?: any) { // Added mcp as a parameter
// Removed mcp parameter from submit, as geospatialTool now handles its client.
async function submit(formData?: FormData, skip?: boolean) {
'use server';

// TODO: Update agent function signatures in lib/agents/researcher.tsx and lib/agents/writer.tsx
Expand Down Expand Up @@ -141,12 +143,13 @@ async function submit(formData?: FormData, skip?: boolean, mcp?: any) { // Added
: answer.length === 0 && !errorOccurred
) {
// Search the web and generate the answer
// Removed mcp argument from researcher call
const { fullResponse, hasError, toolResponses } = await researcher(
currentSystemPrompt,
uiStream,
streamText,
messages,
mcp, // Pass mcp to researcher
// mcp, // mcp instance is no longer passed down
useSpecificAPI
);
answer = fullResponse;
Expand Down
Binary file modified bun.lockb
Binary file not shown.
7 changes: 4 additions & 3 deletions components/chat-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useEffect, useState, useRef } from 'react'
import { useRouter } from 'next/navigation'
import type { AI, UIState } from '@/app/actions'
import { useUIState, useActions } from 'ai/rsc'
import { useGeospatialToolMcp } from '@/lib/agents/tools/geospatial' // Added import
// Removed import of useGeospatialToolMcp as it's no longer used/available
import { cn } from '@/lib/utils'
import { UserMessage } from './user-message'
import { Button } from './ui/button'
Expand All @@ -21,7 +21,7 @@ interface ChatPanelProps {
export function ChatPanel({ messages, input, setInput }: ChatPanelProps) {
const [, setMessages] = useUIState<typeof AI>()
const { submit } = useActions()
const mcp = useGeospatialToolMcp() // Call the hook
// Removed mcp instance as it's no longer passed to submit
const [isButtonPressed, setIsButtonPressed] = useState(false)
const [isMobile, setIsMobile] = useState(false)
const inputRef = useRef<HTMLTextAreaElement>(null)
Expand Down Expand Up @@ -58,7 +58,8 @@ export function ChatPanel({ messages, input, setInput }: ChatPanelProps) {
}
])
const formData = new FormData(e.currentTarget)
const responseMessage = await submit(formData, undefined, mcp) // Pass mcp
// Removed mcp argument from submit call
const responseMessage = await submit(formData)
setMessages(currentMessages => [...currentMessages, responseMessage as any])
}

Expand Down
7 changes: 4 additions & 3 deletions components/copilot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Button } from './ui/button'
import { Card } from './ui/card'
import { ArrowRight, Check, FastForward, Sparkles } from 'lucide-react'
import { useActions, useStreamableValue, useUIState } from 'ai/rsc'
import { useGeospatialToolMcp } from '@/lib/agents/tools/geospatial' // Added import
// Removed import of useGeospatialToolMcp as it's no longer used/available
import type { AI } from '@/app/actions'
import {

Expand All @@ -32,7 +32,7 @@ export const Copilot: React.FC<CopilotProps> = ({ inquiry }: CopilotProps) => {
const [isButtonDisabled, setIsButtonDisabled] = useState(true)
const [, setMessages] = useUIState<typeof AI>()
const { submit } = useActions()
const mcp = useGeospatialToolMcp() // Call the hook
// Removed mcp instance as it's no longer passed to submit

const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
setQuery(event.target.value)
Expand Down Expand Up @@ -79,7 +79,8 @@ export const Copilot: React.FC<CopilotProps> = ({ inquiry }: CopilotProps) => {
? undefined
: new FormData(e.target as HTMLFormElement)

const response = await submit(formData, skip, mcp) // Pass mcp
// Removed mcp argument from submit call
const response = await submit(formData, skip)
setMessages(currentMessages => [...currentMessages, response])
}

Expand Down
7 changes: 4 additions & 3 deletions components/followup-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { useState } from 'react'
import { Button } from './ui/button'
import { Input } from './ui/input'
import { useActions, useUIState } from 'ai/rsc'
import { useGeospatialToolMcp } from '@/lib/agents/tools/geospatial' // Added import
// Removed import of useGeospatialToolMcp as it's no longer used/available
import type { AI } from '@/app/actions'
import { UserMessage } from './user-message'
import { ArrowRight } from 'lucide-react'

export function FollowupPanel() {
const [input, setInput] = useState('')
const { submit } = useActions()
const mcp = useGeospatialToolMcp() // Call the hook
// Removed mcp instance as it's no longer passed to submit
const [, setMessages] = useUIState<typeof AI>()

const handleSubmit = async (event: React.FormEvent<HTMLFormElement>) => {
Expand All @@ -25,7 +25,8 @@ export function FollowupPanel() {
component: <UserMessage message={input} />
}

const responseMessage = await submit(formData, undefined, mcp) // Pass mcp
// Removed mcp argument from submit call
const responseMessage = await submit(formData)
setMessages(currentMessages => [
...currentMessages,
userMessage,
Expand Down
7 changes: 4 additions & 3 deletions components/search-related.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
StreamableValue
} from 'ai/rsc'
import { AI } from '@/app/actions'
import { useGeospatialToolMcp } from '@/lib/agents/tools/geospatial' // Added import
// Removed import of useGeospatialToolMcp as it's no longer used/available
import { UserMessage } from './user-message'
import { PartialRelated } from '@/lib/schema/related'

Expand All @@ -23,7 +23,7 @@ export const SearchRelated: React.FC<SearchRelatedProps> = ({
relatedQueries
}) => {
const { submit } = useActions()
const mcp = useGeospatialToolMcp() // Call the hook
// Removed mcp instance as it's no longer passed to submit
const [, setMessages] = useUIState<typeof AI>()
const [data, error, pending] =
useStreamableValue<PartialRelated>(relatedQueries)
Expand All @@ -46,7 +46,8 @@ export const SearchRelated: React.FC<SearchRelatedProps> = ({
component: <UserMessage message={query} />
}

const responseMessage = await submit(formData, undefined, mcp) // Pass mcp
// Removed mcp argument from submit call
const responseMessage = await submit(formData)
setMessages(currentMessages => [
...currentMessages,
userMessage,
Expand Down
4 changes: 2 additions & 2 deletions lib/agents/researcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export async function researcher(
uiStream: ReturnType<typeof createStreamableUI>,
streamText: ReturnType<typeof createStreamableValue<string>>,
messages: CoreMessage[],
mcp: any, // Moved mcp before optional parameter
// mcp: any, // Removed mcp parameter
useSpecificModel?: boolean
) {
let fullResponse = ''
Expand Down Expand Up @@ -56,7 +56,7 @@ Match the language of your response to the user's language.`;
tools: getTools({
uiStream,
fullResponse,
mcp // Pass the mcp parameter to getTools
// mcp // mcp parameter is no longer passed to getTools
})
})

Expand Down
Loading