Compare commits

...
Author SHA1 Message Date
rekram1-node ad5a03895c test(sdk): check packed server status 2026-09-14 01:35:49 +00:00
rekram1-node 34afa46e23 fix(server): await plugin-backed reads 2026-09-14 01:27:01 +00:00
5 changed files with 24 additions and 4 deletions
+1 -1
View File
@@ -180,7 +180,7 @@ try {
"Packed workerd health returned " + response.status + ": " + await response.text(),
)
const body = await response.json()
if (body.healthy !== true || body.version !== "packed-workerd") {
if (body.version !== "packed-workerd" || !Array.isArray(body.urls)) {
throw new Error("Unexpected packed workerd health: " + JSON.stringify(body))
}
} finally {
+3
View File
@@ -1,4 +1,5 @@
import { Agent } from "@opencode/core/agent"
import { Plugin } from "@opencode/core/plugin"
import { Effect } from "effect"
import { HttpApiBuilder } from "effect/unstable/httpapi"
import { Api } from "../api"
@@ -9,12 +10,14 @@ export const AgentHandler = HttpApiBuilder.group(Api, "server.agent", (handlers)
handlers
.handle("agent.list", () =>
Effect.gen(function* () {
yield* Plugin.awaitActivation
return yield* response(Agent.Service.use((agent) => agent.list()))
}),
)
.handle(
"agent.get",
Effect.fn(function* (ctx) {
yield* Plugin.awaitActivation
const agent = yield* Agent.Service.use((service) => service.get(ctx.params.agentID))
if (!agent)
return yield* new AgentNotFoundError({
+8 -1
View File
@@ -1,8 +1,15 @@
import { Command } from "@opencode/core/command"
import { Plugin } from "@opencode/core/plugin"
import { Effect } from "effect"
import { HttpApiBuilder } from "effect/unstable/httpapi"
import { Api } from "../api"
import { response } from "../location"
export const CommandHandler = HttpApiBuilder.group(Api, "server.command", (handlers) =>
handlers.handle("command.list", () => response(Command.Service.use((command) => command.list()))),
handlers.handle("command.list", () =>
Effect.gen(function* () {
yield* Plugin.awaitActivation
return yield* response(Command.Service.use((command) => command.list()))
}),
),
)
+3
View File
@@ -1,4 +1,5 @@
import { Catalog } from "@opencode/core/catalog"
import { Plugin } from "@opencode/core/plugin"
import { Effect } from "effect"
import { HttpApiBuilder } from "effect/unstable/httpapi"
import { Api } from "../api"
@@ -10,6 +11,7 @@ export const ModelHandler = HttpApiBuilder.group(Api, "server.model", (handlers)
.handle(
"model.list",
Effect.fn(function* () {
yield* Plugin.awaitActivation
const catalog = yield* Catalog.Service
return yield* response(catalog.model.available())
}),
@@ -17,6 +19,7 @@ export const ModelHandler = HttpApiBuilder.group(Api, "server.model", (handlers)
.handle(
"model.default",
Effect.fn(function* () {
yield* Plugin.awaitActivation
const catalog = yield* Catalog.Service
return yield* response(catalog.model.default())
}),
+9 -2
View File
@@ -2,7 +2,7 @@ import fs from "node:fs/promises"
import path from "node:path"
import { $ } from "bun"
import { expect } from "bun:test"
import { Effect } from "effect"
import { Effect, Schedule } from "effect"
import { tmpdir } from "../../core/test/fixture/tmpdir"
import { it } from "../../core/test/lib/effect"
import { startServer } from "./fixture/server"
@@ -213,8 +213,15 @@ it.live(
})
const server = yield* startServer(path.join(tmp.path, "config"))
const api = OpenCode.make({ baseUrl: server.base, headers: server.headers })
yield* Effect.promise(() => api.location.get({ location: { directory: source } }))
yield* Effect.tryPromise({
try: async () => {
const plugins = await api.plugin.list({ location: { directory: source } })
if (!plugins.data.some((plugin) => plugin.id === "test.worktree-delegate")) throw new Error("Plugin not ready")
},
catch: (cause) => cause,
}).pipe(Effect.retry(Schedule.spaced("10 millis")), Effect.timeout("2 seconds"))
yield* Effect.promise(async () => {
await api.location.get({ location: { directory: source } })
expect(await api.worktree.list({ location: { directory: target } })).toContainEqual({
directory: path.join(destination, "delegated"),
strategy: "target-copy",