Add local repository support and permission request handling

This commit is contained in:
Chris Scott committed 2025-11-28 10:26:03 -05:00
1 parent 9a2ebc9652
commit 83834e7ed7
22 files changed
+685 -120

No files matched your search

+5
View File
@@ -111,6 +111,11 @@ export class OpenCodeClient {
return response.data
}
async respondToPermission(sessionID: string, permissionID: string, response: 'once' | 'always' | 'reject') {
const result = await this.client.post(`/session/${sessionID}/permissions/${permissionID}`, { response })
return result.data
}
getEventSourceURL() {
const base = this.baseURL.startsWith('http')
? this.baseURL
+3 -2
View File
@@ -2,7 +2,8 @@ import type { Repo } from './types'
import { API_BASE_URL } from '@/config'
export async function createRepo(
repoUrl: string,
repoUrl?: string,
localPath?: string,
branch?: string,
openCodeConfigName?: string,
useWorktree?: boolean
@@ -10,7 +11,7 @@ export async function createRepo(
const response = await fetch(`${API_BASE_URL}/api/repos`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ repoUrl, branch, openCodeConfigName, useWorktree }),
body: JSON.stringify({ repoUrl, localPath, branch, openCodeConfigName, useWorktree }),
})
if (!response.ok) {
+18 -2
View File
@@ -18,6 +18,8 @@ import type { components } from './opencode-types'
export type Message = components['schemas']['Message']
export type Part = components['schemas']['Part']
export type Session = components['schemas']['Session']
export type Permission = components['schemas']['Permission']
export type PermissionResponse = 'once' | 'always' | 'reject'
export type MessageWithParts = {
info: Message
@@ -86,6 +88,20 @@ export interface SSETodoUpdatedEvent {
}
}
export interface SSEPermissionUpdatedEvent {
type: 'permission.updated'
properties: Permission
}
export interface SSEPermissionRepliedEvent {
type: 'permission.replied'
properties: {
sessionID: string
permissionID: string
response: string
}
}
export type SSEEvent =
| SSEMessagePartUpdatedEvent
| SSEMessageUpdatedEvent
@@ -95,8 +111,8 @@ export type SSEEvent =
| SSESessionDeletedEvent
| SSESessionCompactedEvent
| SSETodoUpdatedEvent
| { type: 'permission.updated'; properties: Record<string, unknown> }
| { type: 'permission.replied'; properties: Record<string, unknown> }
| SSEPermissionUpdatedEvent
| SSEPermissionRepliedEvent
export type ContentPart =
| { type: 'text', content: string }