Add auto-sync of SDK sessions: directly read from OpenCode storage and import to Native mode
Some checks failed
Release Binaries / release (push) Has been cancelled

This commit is contained in:
Gemini AI
2025-12-27 11:46:42 +04:00
Unverified
parent eca090d360
commit 251fad85b1
4 changed files with 268 additions and 5 deletions

View File

@@ -192,6 +192,43 @@ export const nativeSessionApi = {
return response.json()
},
/**
* Sync sessions from SDK (OpenCode) to Native mode
* This reads sessions directly from OpenCode's storage
*/
async syncFromSdk(workspaceId: string, folderPath: string): Promise<{
success: boolean
imported: number
skipped: number
total?: number
message?: string
}> {
const response = await fetch(`${CODENOMAD_API_BASE}/api/native/workspaces/${encodeURIComponent(workspaceId)}/sync-sdk`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ folderPath })
})
if (!response.ok) throw new Error("Failed to sync SDK sessions")
return response.json()
},
/**
* Check if SDK sessions exist for a folder
*/
async checkSdkSessions(folderPath: string): Promise<{
found: boolean
count: number
sessions: Array<{ id: string; title: string; created: number }>
}> {
const response = await fetch(`${CODENOMAD_API_BASE}/api/native/check-sdk-sessions`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ folderPath })
})
if (!response.ok) throw new Error("Failed to check SDK sessions")
return response.json()
},
/**
* Send a prompt to the session and get a streaming response