Download apps/vscode/webview-ui/src/stores/approval.store.ts from SaylorTwift/kimi-code: direct link, hf CLI and curl.
- Browser
- Download file 1.03 kB
-
https://huggingface.co/SaylorTwift/kimi-code/resolve/main/apps/vscode/webview-ui/src/stores/approval.store.ts
- Command line
-
hf download hf://SaylorTwift/kimi-code/apps/vscode/webview-ui/src/stores/approval.store.ts
-
curl -L -o approval.store.ts https://huggingface.co/SaylorTwift/kimi-code/resolve/main/apps/vscode/webview-ui/src/stores/approval.store.ts
1.03 kB
| import { create } from "zustand"; | |
| import type { DisplayBlock, ApprovalResponse } from "shared/legacy-sdk"; | |
| import { bridge } from "@/services"; | |
| export interface ApprovalRequest { | |
| id: string; | |
| tool_call_id: string; | |
| sender: string; | |
| action: string; | |
| description: string; | |
| display: DisplayBlock[]; | |
| } | |
| interface ApprovalState { | |
| pending: ApprovalRequest[]; | |
| addRequest: (request: ApprovalRequest) => void; | |
| removeRequest: (id: string) => void; | |
| respondToRequest: (id: string, response: ApprovalResponse) => Promise<void>; | |
| clearRequests: () => void; | |
| } | |
| export const useApprovalStore = create<ApprovalState>((set, get) => ({ | |
| pending: [], | |
| addRequest: (request) => { | |
| set((s) => ({ pending: [...s.pending, request] })); | |
| }, | |
| removeRequest: (id) => { | |
| set((s) => ({ pending: s.pending.filter((r) => r.id !== id) })); | |
| }, | |
| respondToRequest: async (id, response) => { | |
| await bridge.respondApproval(id, response); | |
| get().removeRequest(id); | |
| }, | |
| clearRequests: () => { | |
| set({ pending: [] }); | |
| }, | |
| })); | |