@neeter/react
Advanced tools
+2
-0
@@ -13,2 +13,3 @@ import type { ChatMessage, McpServerStatus, PermissionRequest, SSEEvent } from "@neeter/types"; | ||
| mcpServers: McpServerStatus[]; | ||
| checkpoints: string[]; | ||
| totalCost: number; | ||
@@ -36,2 +37,3 @@ totalTurns: number; | ||
| setMcpServers: (servers: McpServerStatus[]) => void; | ||
| addCheckpoint: (uuid: string) => void; | ||
| addCost: (cost: number, turns: number) => void; | ||
@@ -38,0 +40,0 @@ cancelInflightToolCalls: () => void; |
+8
-0
@@ -30,2 +30,3 @@ import { immer } from "zustand/middleware/immer"; | ||
| mcpServers: [], | ||
| checkpoints: [], | ||
| totalCost: 0, | ||
@@ -146,2 +147,5 @@ totalTurns: 0, | ||
| }), | ||
| addCheckpoint: (uuid) => set((s) => { | ||
| s.checkpoints.push(uuid); | ||
| }), | ||
| addCost: (cost, turns) => set((s) => { | ||
@@ -175,2 +179,3 @@ s.totalCost += cost; | ||
| s.mcpServers = []; | ||
| s.checkpoints = []; | ||
| s.totalCost = 0; | ||
@@ -223,2 +228,5 @@ s.totalTurns = 0; | ||
| break; | ||
| case "checkpoint": | ||
| s.addCheckpoint(data.userMessageUuid); | ||
| break; | ||
| case "turn_complete": | ||
@@ -225,0 +233,0 @@ s.flushStreamingThinking(); |
@@ -1,2 +0,2 @@ | ||
| import type { CustomEvent, PermissionResponse, SessionHistoryEntry } from "@neeter/types"; | ||
| import type { CustomEvent, PermissionResponse, RewindFilesResult, SessionHistoryEntry } from "@neeter/types"; | ||
| import { type ChatStore } from "./store.js"; | ||
@@ -19,2 +19,5 @@ export interface UseAgentConfig { | ||
| }) => Promise<void>; | ||
| rewindSession: (checkpointId: string, options?: { | ||
| dryRun?: boolean; | ||
| }) => Promise<RewindFilesResult>; | ||
| newSession: () => Promise<void>; | ||
@@ -21,0 +24,0 @@ refreshHistory: () => Promise<void>; |
+15
-0
@@ -153,2 +153,6 @@ import { useCallback, useEffect, useRef, useState, useSyncExternalStore } from "react"; | ||
| }); | ||
| es.addEventListener("checkpoint", (e) => { | ||
| const { userMessageUuid } = JSON.parse(e.data); | ||
| store.getState().addCheckpoint(userMessageUuid); | ||
| }); | ||
| if (onCustomEvent) { | ||
@@ -234,2 +238,12 @@ es.addEventListener("custom", (e) => { | ||
| }, [endpoint]); | ||
| const rewindSession = useCallback(async (checkpointId, options) => { | ||
| if (!sessionId) | ||
| return { canRewind: false, error: "No active session" }; | ||
| const res = await fetch(`${endpoint}/sessions/${sessionId}/rewind`, { | ||
| method: "POST", | ||
| headers: { "Content-Type": "application/json" }, | ||
| body: JSON.stringify({ userMessageId: checkpointId, dryRun: options?.dryRun }), | ||
| }); | ||
| return res.json(); | ||
| }, [sessionId, endpoint]); | ||
| const newSession = useCallback(async () => { | ||
@@ -253,2 +267,3 @@ if (eventSourceRef.current) { | ||
| resumeSession, | ||
| rewindSession, | ||
| newSession, | ||
@@ -255,0 +270,0 @@ refreshHistory, |
+2
-2
| { | ||
| "name": "@neeter/react", | ||
| "version": "0.10.11", | ||
| "version": "0.11.0", | ||
| "description": "React components and hooks for building chat UIs on top of the Claude Agent SDK", | ||
@@ -29,3 +29,3 @@ "license": "MIT", | ||
| "tailwind-merge": "^3.5.0", | ||
| "@neeter/types": "0.10.11" | ||
| "@neeter/types": "0.11.0" | ||
| }, | ||
@@ -32,0 +32,0 @@ "peerDependencies": { |
103823
1.14%1996
1.42%11
10%+ Added
- Removed
Updated