Migrate UI to v2 SDK client
Use v2 OpencodeClient with normalized request handling and rehydrate pending permissions via GET /permission on instance hydration.
This commit is contained in:
@@ -1,18 +1,20 @@
|
||||
import { createOpencodeClient, type OpencodeClient } from "@opencode-ai/sdk/client"
|
||||
import { createOpencodeClient, type OpencodeClient } from "@opencode-ai/sdk/v2/client"
|
||||
import { CODENOMAD_API_BASE } from "./api-client"
|
||||
|
||||
class SDKManager {
|
||||
private clients = new Map<string, OpencodeClient>()
|
||||
|
||||
createClient(instanceId: string, proxyPath: string): OpencodeClient {
|
||||
if (this.clients.has(instanceId)) {
|
||||
return this.clients.get(instanceId)!
|
||||
const existing = this.clients.get(instanceId)
|
||||
if (existing) {
|
||||
return existing
|
||||
}
|
||||
|
||||
const baseUrl = buildInstanceBaseUrl(proxyPath)
|
||||
const client = createOpencodeClient({ baseUrl })
|
||||
|
||||
this.clients.set(instanceId, client)
|
||||
|
||||
return client
|
||||
}
|
||||
|
||||
@@ -29,6 +31,8 @@ class SDKManager {
|
||||
}
|
||||
}
|
||||
|
||||
export type { OpencodeClient }
|
||||
|
||||
function buildInstanceBaseUrl(proxyPath: string): string {
|
||||
const normalized = normalizeProxyPath(proxyPath)
|
||||
const base = stripTrailingSlashes(CODENOMAD_API_BASE)
|
||||
|
||||
Reference in New Issue
Block a user