fix(core): restore agent environment markers

Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
This commit is contained in:
Aiden Cline 2026-07-08 15:02:06 +00:00
commit cdc8118373
4 changed files with 28 additions and 1 deletions

View file

@ -158,6 +158,8 @@ const layer = Layer.effectDiscard(
const command = ChildProcess.make(input.command, [], {
cwd: target.canonical,
shell,
env: { OPENCODE: "1", AGENT: "1" },
extendEnv: true,
stdin: "ignore",
detached: process.platform !== "win32",
forceKillAfter: Duration.seconds(3),

View file

@ -28,6 +28,8 @@ const runs: Array<{
readonly command: string
readonly cwd?: string
readonly shell?: string | boolean
readonly env?: Record<string, string | undefined>
readonly extendEnv?: boolean
readonly options?: AppProcess.RunOptions
}> = []
let denyAction: string | undefined
@ -67,7 +69,14 @@ const appProcess = Layer.succeed(
run: (command: ChildProcess.Command, options?: AppProcess.RunOptions) =>
Effect.suspend(() => {
if (command._tag !== "StandardCommand") throw new Error("expected standard command")
runs.push({ command: command.command, cwd: command.options.cwd, shell: command.options.shell, options })
runs.push({
command: command.command,
cwd: command.options.cwd,
shell: command.options.shell,
env: command.options.env,
extendEnv: command.options.extendEnv,
options,
})
return runFailure ? Effect.fail(runFailure) : Effect.succeed(result)
}),
} as unknown as AppProcess.Interface),
@ -168,6 +177,7 @@ describe("BashTool", () => {
},
})
expect(runs).toMatchObject([{ command: "pwd", cwd: realpathSync(tmp.path) }])
expect(runs[0]).toMatchObject({ env: { OPENCODE: "1", AGENT: "1" }, extendEnv: true })
expect(runs[0]?.options).toMatchObject({
combineOutput: true,
maxOutputBytes: BashTool.MAX_CAPTURE_BYTES,