Download src/stores/goal-store.ts from SaylorTwift/openhands: direct link, hf CLI and curl.
- Browser
- Download file 933 Bytes
-
https://huggingface.co/SaylorTwift/openhands/resolve/main/src/stores/goal-store.ts
- Command line
-
hf download hf://SaylorTwift/openhands/src/stores/goal-store.ts
-
curl -L -o goal-store.ts https://huggingface.co/SaylorTwift/openhands/resolve/main/src/stores/goal-store.ts
933 Bytes
| import { create } from "zustand"; | |
| import { devtools } from "zustand/middleware"; | |
| import { GoalStatus } from "#/types/agent-server/core/events/conversation-state-event"; | |
| interface GoalState { | |
| /** Latest goal status per conversation, fed by goal state-update events. */ | |
| statusByConversation: Record<string, GoalStatus>; | |
| } | |
| interface GoalActions { | |
| /** Replace the latest goal status for a conversation. */ | |
| setStatus: (conversationId: string, status: GoalStatus) => void; | |
| } | |
| type GoalStore = GoalState & GoalActions; | |
| const initialState: GoalState = { statusByConversation: {} }; | |
| export const useGoalStore = create<GoalStore>()( | |
| devtools( | |
| (set) => ({ | |
| ...initialState, | |
| setStatus: (conversationId, status) => | |
| set((s) => ({ | |
| statusByConversation: { | |
| ...s.statusByConversation, | |
| [conversationId]: status, | |
| }, | |
| })), | |
| }), | |
| { name: "GoalStore" }, | |
| ), | |
| ); | |