fix(server): apply plugin pty environment (#32296)
This commit is contained in:
@@ -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]),
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user