Add automatic session migration when switching from SDK to Native mode
Some checks failed
Release Binaries / release (push) Has been cancelled

This commit is contained in:
Gemini AI
2025-12-27 11:13:43 +04:00
Unverified
parent eaf93e2924
commit 64c7fb8d47
6 changed files with 311 additions and 0 deletions

View File

@@ -165,6 +165,34 @@ export const nativeSessionApi = {
return data.messages
},
/**
* Import sessions from SDK mode to Native mode
*/
async importSessions(workspaceId: string, sessions: Array<{
id: string
title?: string
parentId?: string | null
createdAt?: number
updatedAt?: number
model?: { providerId: string; modelId: string }
agent?: string
messages?: Array<{
id: string
role: "user" | "assistant" | "system" | "tool"
content?: string
createdAt?: number
}>
}>): Promise<{ success: boolean; imported: number; skipped: number }> {
const response = await fetch(`${CODENOMAD_API_BASE}/api/native/workspaces/${encodeURIComponent(workspaceId)}/sessions/import`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ sessions })
})
if (!response.ok) throw new Error("Failed to import sessions")
return response.json()
},
/**
* Send a prompt to the session and get a streaming response
*/