Download desktop/src/api/plugins.ts from chenbhao/codev: direct link, hf CLI and curl.
- Browser
- Download file 1.63 kB
-
https://huggingface.co/chenbhao/codev/resolve/e40073cc959cd4729bf4009662bca374c5c4e266/desktop/src/api/plugins.ts
- Command line
-
hf download hf://chenbhao/codev@e40073cc959cd4729bf4009662bca374c5c4e266/desktop/src/api/plugins.ts
-
curl -L -o plugins.ts https://huggingface.co/chenbhao/codev/resolve/e40073cc959cd4729bf4009662bca374c5c4e266/desktop/src/api/plugins.ts
1.63 kB
| import { api } from './client' | |
| import type { | |
| PluginDetail, | |
| PluginListResponse, | |
| PluginReloadSummary, | |
| PluginSessionReloadSummary, | |
| PluginScope, | |
| } from '../types/plugin' | |
| type PluginActionPayload = { | |
| id: string | |
| scope?: PluginScope | |
| keepData?: boolean | |
| } | |
| export const pluginsApi = { | |
| list: (cwd?: string) => { | |
| const query = cwd ? `?cwd=${encodeURIComponent(cwd)}` : '' | |
| return api.get<PluginListResponse>(`/api/plugins${query}`) | |
| }, | |
| detail: (id: string, cwd?: string) => { | |
| const query = new URLSearchParams({ id }) | |
| if (cwd) query.set('cwd', cwd) | |
| return api.get<{ detail: PluginDetail }>(`/api/plugins/detail?${query.toString()}`) | |
| }, | |
| enable: (payload: PluginActionPayload) => | |
| api.post<{ ok: true; message: string }>('/api/plugins/enable', payload), | |
| disable: (payload: PluginActionPayload) => | |
| api.post<{ ok: true; message: string }>('/api/plugins/disable', payload), | |
| update: (payload: PluginActionPayload) => | |
| api.post<{ ok: true; message: string }>('/api/plugins/update', payload), | |
| uninstall: (payload: PluginActionPayload) => | |
| api.post<{ ok: true; message: string }>('/api/plugins/uninstall', payload), | |
| reload: (cwd?: string, sessionId?: string) => { | |
| const query = new URLSearchParams() | |
| if (cwd) query.set('cwd', cwd) | |
| if (sessionId) query.set('sessionId', sessionId) | |
| const suffix = query.size > 0 ? `?${query.toString()}` : '' | |
| return api.post<{ | |
| ok: true | |
| summary: PluginReloadSummary | |
| session?: PluginSessionReloadSummary | |
| }>( | |
| `/api/plugins/reload${suffix}`, | |
| undefined, | |
| { timeout: 120_000 }, | |
| ) | |
| }, | |
| } | |