mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
Refactor schedule service and add cron support
This commit is contained in:
1 parent
dbf48d4691
commit
47524876aa
24 files changed
+652
-139
No files matched your search
@@ -1,7 +1,5 @@
|
||||
import type { paths } from './opencode-types'
|
||||
import { fetchWrapper } from './fetchWrapper'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { OPENCODE_API_ENDPOINT } from '@/config'
|
||||
|
||||
type SessionListResponse = paths['/session']['get']['responses']['200']['content']['application/json']
|
||||
type SessionResponse = paths['/session/{sessionID}']['get']['responses']['200']['content']['application/json']
|
||||
@@ -251,13 +249,3 @@ export const createOpenCodeClient = (baseURL: string, directory?: string) => {
|
||||
return new OpenCodeClient(baseURL, directory)
|
||||
}
|
||||
|
||||
export const useAgents = () => {
|
||||
return useQuery({
|
||||
queryKey: ['opencode-agents'],
|
||||
queryFn: async () => {
|
||||
const client = createOpenCodeClient(OPENCODE_API_ENDPOINT)
|
||||
return await client.listAgents()
|
||||
},
|
||||
staleTime: 5 * 60 * 1000,
|
||||
})
|
||||
}
|
||||
@@ -4,7 +4,11 @@ import type {
|
||||
OpenCodeConfig,
|
||||
OpenCodeConfigResponse,
|
||||
CreateOpenCodeConfigRequest,
|
||||
UpdateOpenCodeConfigRequest
|
||||
UpdateOpenCodeConfigRequest,
|
||||
SkillFileInfo,
|
||||
CreateSkillRequest,
|
||||
UpdateSkillRequest,
|
||||
SkillScope,
|
||||
} from './types/settings'
|
||||
import { API_BASE_URL } from '@/config'
|
||||
import { fetchWrapper, FetchError } from './fetchWrapper'
|
||||
@@ -214,6 +218,43 @@ export const settingsApi = {
|
||||
getMemoryPluginStatus: async (): Promise<{ memoryPluginEnabled: boolean }> => {
|
||||
return fetchWrapper(`${API_BASE_URL}/api/settings/memory-plugin-status`)
|
||||
},
|
||||
|
||||
listManagedSkills: async (repoId?: number): Promise<SkillFileInfo[]> => {
|
||||
const params = repoId ? `?repoId=${repoId}` : ''
|
||||
return fetchWrapper(`${API_BASE_URL}/api/settings/skills${params}`)
|
||||
},
|
||||
|
||||
getSkill: async (name: string, scope: SkillScope, repoId?: number): Promise<SkillFileInfo> => {
|
||||
const params = new URLSearchParams({ scope })
|
||||
if (repoId) params.set('repoId', String(repoId))
|
||||
return fetchWrapper(`${API_BASE_URL}/api/settings/skills/${name}?${params}`)
|
||||
},
|
||||
|
||||
createSkill: async (data: CreateSkillRequest): Promise<SkillFileInfo> => {
|
||||
return fetchWrapper(`${API_BASE_URL}/api/settings/skills`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data),
|
||||
})
|
||||
},
|
||||
|
||||
updateSkill: async (name: string, scope: SkillScope, data: UpdateSkillRequest, repoId?: number): Promise<SkillFileInfo> => {
|
||||
const params = new URLSearchParams({ scope })
|
||||
if (repoId) params.set('repoId', String(repoId))
|
||||
return fetchWrapper(`${API_BASE_URL}/api/settings/skills/${name}?${params}`, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data),
|
||||
})
|
||||
},
|
||||
|
||||
deleteSkill: async (name: string, scope: SkillScope, repoId?: number): Promise<{ success: boolean }> => {
|
||||
const params = new URLSearchParams({ scope })
|
||||
if (repoId) params.set('repoId', String(repoId))
|
||||
return fetchWrapper(`${API_BASE_URL}/api/settings/skills/${name}?${params}`, {
|
||||
method: 'DELETE',
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
export interface VersionInfo {
|
||||
|
||||
@@ -7,10 +7,14 @@ import {
|
||||
type TTSConfig,
|
||||
type STTConfig,
|
||||
type OpenCodeConfigContent,
|
||||
type SkillFileInfo,
|
||||
type CreateSkillRequest,
|
||||
type UpdateSkillRequest,
|
||||
type SkillScope,
|
||||
} from '@opencode-manager/shared'
|
||||
import type { NotificationPreferences } from '@opencode-manager/shared/types'
|
||||
|
||||
export type { TTSConfig, STTConfig, OpenCodeConfigContent, NotificationPreferences }
|
||||
export type { TTSConfig, STTConfig, OpenCodeConfigContent, NotificationPreferences, SkillFileInfo, CreateSkillRequest, UpdateSkillRequest, SkillScope }
|
||||
export { DEFAULT_TTS_CONFIG, DEFAULT_STT_CONFIG, DEFAULT_KEYBOARD_SHORTCUTS, DEFAULT_USER_PREFERENCES, DEFAULT_LEADER_KEY }
|
||||
|
||||
export interface CustomCommand {
|
||||
|
||||
Reference in new issue
Block a user