Refactor SSE event handling and consolidate notification contexts

This commit is contained in:
Chris Scott committed 2026-01-12 23:56:50 -05:00
1 parent 9851ec06e0
commit f7fd3176d4
30 files changed
+2226 -988

No files matched your search

+16
View File
@@ -11,6 +11,7 @@ type CommandListResponse = paths['/command']['get']['responses']['200']['content
type CommandRequest = NonNullable<paths['/session/{sessionID}/command']['post']['requestBody']>['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 QuestionListResponse = paths['/question']['get']['responses']['200']['content']['application/json']
export class OpenCodeClient {
private client: AxiosInstance
@@ -130,6 +131,21 @@ export class OpenCodeClient {
return result.data
}
async replyToQuestion(requestID: string, answers: string[][]) {
const result = await this.client.post(`/question/${requestID}/reply`, { answers })
return result.data
}
async rejectQuestion(requestID: string) {
const result = await this.client.post(`/question/${requestID}/reject`)
return result.data
}
async listPendingQuestions() {
const response = await this.client.get<QuestionListResponse>('/question')
return response.data
}
async listAgents() {
const response = await this.client.get<AgentListResponse>('/agent')
return response.data
+30
View File
@@ -21,6 +21,11 @@ export type Session = components['schemas']['Session']
export type PermissionRequest = components['schemas']['PermissionRequest']
export type PermissionResponse = 'once' | 'always' | 'reject'
export type QuestionOption = components['schemas']['QuestionOption']
export type QuestionInfo = components['schemas']['QuestionInfo']
export type QuestionRequest = components['schemas']['QuestionRequest']
export type QuestionAnswer = components['schemas']['QuestionAnswer']
export type MessageWithParts = {
info: Message
parts: Part[]
@@ -102,6 +107,28 @@ export interface SSEPermissionRepliedEvent {
}
}
export interface SSEQuestionAskedEvent {
type: 'question.asked'
properties: QuestionRequest
}
export interface SSEQuestionRepliedEvent {
type: 'question.replied'
properties: {
sessionID: string
requestID: string
answers: QuestionAnswer[]
}
}
export interface SSEQuestionRejectedEvent {
type: 'question.rejected'
properties: {
sessionID: string
requestID: string
}
}
export interface SSEInstallationUpdatedEvent {
type: 'installation.updated'
properties: {
@@ -153,6 +180,9 @@ export type SSEEvent =
| SSETodoUpdatedEvent
| SSEPermissionAskedEvent
| SSEPermissionRepliedEvent
| SSEQuestionAskedEvent
| SSEQuestionRepliedEvent
| SSEQuestionRejectedEvent
| SSEInstallationUpdatedEvent
| SSEInstallationUpdateAvailableEvent