@polpo-ai/react package wraps the TypeScript SDK with React hooks and a context Provider. It connects to the SSE event stream for live updates — no polling needed.
Install
Provider setup
Wrap your app withPolpoProvider:
| Prop | Type | Default | Description |
|---|---|---|---|
baseUrl | string | required | API base URL |
apiKey | string | — | Project API key |
autoConnect | boolean | true | Auto-connect to SSE stream |
eventFilter | string[] | — | Filter SSE events (e.g. ["task:*"]) |
Hooks
useTasks(filter?)
useTask(taskId)
useMissions()
useMission(missionId)
useAgents()
useProcesses()
useMemory() / useAgentMemory(name)
useChat(options?)
Full-featured chat hook with automatic session management, streaming, tool call tracking, and abort support.
Options
| Option | Type | Description |
|---|---|---|
agent | string | Target agent name |
sessionId | string | Resume an existing session |
onChunk | (chunk) => void | Called on each streaming chunk |
onFinish | (result) => void | Called when streaming completes |
onError | (error) => void | Called on error |
onAskUser | (payload) => void | Called when finish_reason is "ask_user" |
onMissionPreview | (preview) => void | Called when finish_reason is "mission_preview" |
onToolCall | (toolCall) => void | Called when the agent invokes a tool |
Return value
| Property | Type | Description |
|---|---|---|
messages | ChatMessage[] | Full message history |
sendMessage | (content: string | ContentPart[]) => Promise<void> | Send a user message (plain text or content parts) |
sessionId | string | null | Current session ID |
setSessionId | (id: string) => void | Switch to an existing session |
newSession | () => void | Start a new conversation |
status | string | "idle" | "loading" | "streaming" | "error" |
error | Error | null | Last error, if any |
isStreaming | boolean | Whether a response is currently streaming |
pendingToolCall | PendingToolCall | null | Client-side tool call waiting for a response |
abort | () => void | Abort the current stream |
useSessions()
File attachments
To attach files to a chat message, useuseFiles to upload and reference the path in your message:
Client-side tools (pendingToolCall + sendToolResult)
Some agent tools are client-side — the agent calls them, but your app handles the interaction. The built-in client-side tool is ask_user_question: the agent asks clarifying questions and your UI collects the answers.
pendingToolCall is set → your UI renders → user responds → sendToolResult() sends the answer and resumes the agent stream.
useFiles(path?)
Browse and manage the agent workspace filesystem. Pass an optional path to auto-load entries for that directory.
uploadFile, createDirectory, renameFile, deleteFile) include loading states and automatically refresh the file listing on success.