mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
feat: add assistant mode, SSE streaming, and OpenCode server integration (#214)
This commit is contained in:
1 parent
3cc24288a6
commit
c3d6549f01
133 files changed
+7284
-6293
No files matched your search
@@ -1,14 +1,16 @@
|
||||
import type { paths } from './opencode-types'
|
||||
import { fetchWrapper } from './fetchWrapper'
|
||||
import { fetchWrapper, fetchWrapperVoid } from './fetchWrapper'
|
||||
|
||||
type SessionListResponse = paths['/session']['get']['responses']['200']['content']['application/json']
|
||||
type SessionResponse = paths['/session/{sessionID}']['get']['responses']['200']['content']['application/json']
|
||||
type CreateSessionRequest = NonNullable<paths['/session']['post']['requestBody']>['content']['application/json']
|
||||
type MessageListResponse = paths['/session/{sessionID}/message']['get']['responses']['200']['content']['application/json']
|
||||
type SendPromptRequest = NonNullable<paths['/session/{sessionID}/message']['post']['requestBody']>['content']['application/json']
|
||||
type SendPromptAsyncRequest = NonNullable<paths['/session/{sessionID}/prompt_async']['post']['requestBody']>['content']['application/json']
|
||||
type ConfigResponse = paths['/config']['get']['responses']['200']['content']['application/json']
|
||||
type CommandListResponse = paths['/command']['get']['responses']['200']['content']['application/json']
|
||||
type CommandRequest = NonNullable<paths['/session/{sessionID}/command']['post']['requestBody']>['content']['application/json']
|
||||
type SendCommandResponse = paths['/session/{sessionID}/command']['post']['responses']['200']['content']['application/json']
|
||||
type ShellRequest = NonNullable<paths['/session/{sessionID}/shell']['post']['requestBody']>['content']['application/json']
|
||||
type AgentListResponse = paths['/agent']['get']['responses']['200']['content']['application/json']
|
||||
type PermissionListResponse = paths['/permission']['get']['responses']['200']['content']['application/json']
|
||||
@@ -17,7 +19,7 @@ type SendPromptResponse = paths['/session/{sessionID}/message']['post']['respons
|
||||
type LspStatusResponse = paths['/lsp']['get']['responses']['200']['content']['application/json']
|
||||
type LspStatus = LspStatusResponse[number]
|
||||
|
||||
export type { SendPromptResponse, LspStatus }
|
||||
export type { SendPromptResponse, SendCommandResponse, LspStatus }
|
||||
|
||||
export class OpenCodeClient {
|
||||
private baseURL: string
|
||||
@@ -109,6 +111,19 @@ export class OpenCodeClient {
|
||||
)
|
||||
}
|
||||
|
||||
async sendPromptAsync(sessionID: string, data: SendPromptAsyncRequest): Promise<void> {
|
||||
return fetchWrapperVoid(
|
||||
`${this.baseURL}/session/${sessionID}/prompt_async`,
|
||||
{
|
||||
method: 'POST',
|
||||
params: this.getParams(),
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data),
|
||||
timeout: 0,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async summarizeSession(sessionID: string, providerID: string, modelID: string) {
|
||||
return fetchWrapper(`${this.baseURL}/session/${sessionID}/summarize`, {
|
||||
method: 'POST',
|
||||
@@ -157,12 +172,13 @@ export class OpenCodeClient {
|
||||
})
|
||||
}
|
||||
|
||||
async sendCommand(sessionID: string, data: CommandRequest) {
|
||||
return fetchWrapper(`${this.baseURL}/session/${sessionID}/command`, {
|
||||
async sendCommand(sessionID: string, data: CommandRequest): Promise<SendCommandResponse> {
|
||||
return fetchWrapper<SendCommandResponse>(`${this.baseURL}/session/${sessionID}/command`, {
|
||||
method: 'POST',
|
||||
params: this.getParams(),
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data),
|
||||
timeout: 0,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user