fix(server): apply plugin pty environment (#32296)

This commit is contained in:
Shoubhit Dash
2026-06-14 16:47:48 +05:30
committed by GitHub
parent 8cc2276dba
commit 7ad68f8150
8 changed files with 135 additions and 3 deletions
@@ -0,0 +1,24 @@
export * as PluginPtyEnvironment from "./pty-environment"
import { PtyEnvironment } from "@opencode-ai/server/pty-environment"
import { Effect, Layer } from "effect"
import { InstanceStore } from "@/project/instance-store"
import { Plugin } from "."
export const layer = Layer.effect(
PtyEnvironment.Service,
Effect.gen(function* () {
const plugin = yield* Plugin.Service
const instances = yield* InstanceStore.Service
return PtyEnvironment.Service.of({
get: Effect.fn("PtyEnvironment.get")(function* (input) {
return yield* instances.provide(
{ directory: input.directory },
plugin
.trigger("shell.env", { cwd: input.cwd }, { env: {} as Record<string, string> })
.pipe(Effect.map((result) => result.env)),
)
}),
})
}),
)
@@ -21,6 +21,7 @@ import { MCP } from "@/mcp"
import { McpAuth } from "@/mcp/auth"
import { Permission } from "@/permission"
import { Plugin } from "@/plugin"
import { PluginPtyEnvironment } from "@/plugin/pty-environment"
import { InstanceStore } from "@/project/instance-store"
import { Project } from "@/project/project"
import { Vcs } from "@/project/vcs"
@@ -166,6 +167,7 @@ const instanceRoutes = instanceApiRoutes.pipe(
)
const serverRoutes = HttpApiBuilder.layer(Api).pipe(
Layer.provide(handlers),
Layer.provide(PluginPtyEnvironment.layer),
Layer.provide([serverHttpApiAuthLayer, v2SchemaErrorLayer]),
)