Download desktop/src/stores/agentStore.ts from chenbhao/codev: direct link, hf CLI and curl.
- Browser
- Download file 1.25 kB
-
https://huggingface.co/chenbhao/codev/resolve/e40073cc959cd4729bf4009662bca374c5c4e266/desktop/src/stores/agentStore.ts
- Command line
-
hf download hf://chenbhao/codev@e40073cc959cd4729bf4009662bca374c5c4e266/desktop/src/stores/agentStore.ts
-
curl -L -o agentStore.ts https://huggingface.co/chenbhao/codev/resolve/e40073cc959cd4729bf4009662bca374c5c4e266/desktop/src/stores/agentStore.ts
1.25 kB
| import { create } from 'zustand' | |
| import { agentsApi, type AgentDefinition } from '../api/agents' | |
| export type AgentDetailReturnTab = 'agents' | 'plugins' | |
| type AgentStore = { | |
| activeAgents: AgentDefinition[] | |
| allAgents: AgentDefinition[] | |
| isLoading: boolean | |
| error: string | null | |
| selectedAgent: AgentDefinition | null | |
| selectedAgentReturnTab: AgentDetailReturnTab | |
| fetchAgents: (cwd?: string) => Promise<void> | |
| selectAgent: ( | |
| agent: AgentDefinition | null, | |
| returnTab?: AgentDetailReturnTab, | |
| ) => void | |
| } | |
| export const useAgentStore = create<AgentStore>((set) => ({ | |
| activeAgents: [], | |
| allAgents: [], | |
| isLoading: false, | |
| error: null, | |
| selectedAgent: null, | |
| selectedAgentReturnTab: 'agents', | |
| fetchAgents: async (cwd) => { | |
| set({ isLoading: true, error: null }) | |
| try { | |
| const { activeAgents, allAgents } = await agentsApi.list(cwd) | |
| set({ activeAgents, allAgents, isLoading: false }) | |
| } catch (error) { | |
| const message = error instanceof Error ? error.message : 'Failed to load agents' | |
| set({ isLoading: false, error: message }) | |
| } | |
| }, | |
| selectAgent: (agent, returnTab = 'agents') => | |
| set({ | |
| selectedAgent: agent, | |
| selectedAgentReturnTab: agent ? returnTab : 'agents', | |
| }), | |
| })) | |