chore: merge dev

This commit is contained in:
Dax Raad
2026-06-04 01:24:55 -04:00
312 changed files with 32760 additions and 4465 deletions
@@ -25,6 +25,7 @@ import { disposeAllInstances, TestInstance, tmpdirScoped } from "../fixture/fixt
import { awaitWithTimeout, testEffect } from "../lib/effect"
import { testProviderConfig } from "../lib/test-provider"
import { ProviderV2 } from "@opencode-ai/core/provider"
import { ModelV2 } from "@opencode-ai/core/model"
import { Database } from "@opencode-ai/core/database/database"
import { httpApiLayer } from "./httpapi-layer"
@@ -60,13 +61,20 @@ type TestScope = Scope.Scope | TestServices
function client(
serverPath: ServerPath,
directory?: string,
input?: { password?: string; username?: string; headers?: Record<string, string> },
input?: {
password?: string
username?: string
headers?: Record<string, string>
workspaceID?: string
onRequest?: (request: Request) => void
},
) {
return serverFetch(serverPath, input).pipe(
Effect.map((fetch) =>
createOpencodeClient({
baseUrl: "http://localhost",
directory,
experimental_workspaceID: input?.workspaceID,
headers: input?.headers,
fetch,
}),
@@ -74,7 +82,10 @@ function client(
)
}
function serverFetch(serverPath: ServerPath, input?: { password?: string; username?: string }) {
function serverFetch(
serverPath: ServerPath,
input?: { password?: string; username?: string; onRequest?: (request: Request) => void },
) {
return HttpServer.HttpServer.use((server) =>
Effect.sync(() => {
void serverPath
@@ -84,6 +95,7 @@ function serverFetch(serverPath: ServerPath, input?: { password?: string; userna
return Object.assign(
async (request: RequestInfo | URL, init?: RequestInit) => {
const source = request instanceof Request ? request : new Request(request, init)
input?.onRequest?.(source)
const url = new URL(source.url)
return globalThis.fetch(new Request(new URL(`${url.pathname}${url.search}`, baseUrl), source))
},
@@ -299,7 +311,7 @@ function seedMessage(directory: string, sessionID: string) {
role: "user",
time: { created: Date.now() },
agent: "test",
model: { providerID: ProviderV2.ID.make("test"), modelID: ProviderV2.ModelID.make("test") },
model: { providerID: ProviderV2.ID.make("test"), modelID: ModelV2.ID.make("test") },
tools: {},
} satisfies SessionV1.User)
const part = yield* svc.updatePart({
@@ -367,6 +379,31 @@ describe("HttpApi SDK", () => {
}),
)
httpapi(
"routes configured SDK directory and workspace for v2 location GETs",
withProject("raw", { setup: writeStandardFiles }, ({ directory }) =>
Effect.gen(function* () {
const workspaceID = "wrk_sdk"
let request: Request | undefined
const sdk = yield* client("raw", directory, {
workspaceID,
onRequest: (value) => (request = value),
})
const file = yield* call(() => sdk.v2.fs.read({ path: "hello.txt" }))
const url = new URL(request!.url)
expect(file.response.status).toBe(200)
expect(file.data).toMatchObject({ content: "hello" })
expect(url.searchParams.get("directory")).toBe(directory)
expect(url.searchParams.get("workspace")).toBe(workspaceID)
expect(url.searchParams.get("location[directory]")).toBe(directory)
expect(url.searchParams.get("location[workspace]")).toBe(workspaceID)
expect(request!.headers.has("x-opencode-directory")).toBe(false)
expect(request!.headers.has("x-opencode-workspace")).toBe(false)
}),
),
)
serverPathParity("matches generated SDK global and control behavior", (serverPath) =>
Effect.gen(function* () {
const sdk = yield* client(serverPath)