Skip to content

Commit 76636ea

Browse files
author
Thorsten.Tegetmeyer-Kleine
committed
fix(tool): port bash-output and kill-shell params from zod to Effect Schema
Matches the Tool.define schema migration in upstream anomalyco#23244. Without this the tool registry can't construct these tools and runtime errors out with "undefined is not an object (evaluating 'X.context')" on every prompt.
1 parent 1dd87bd commit 76636ea

3 files changed

Lines changed: 13 additions & 13 deletions

File tree

bun.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/opencode/src/tool/bash-output.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import z from "zod"
2-
import { Effect } from "effect"
1+
import { Effect, Schema } from "effect"
32
import * as Tool from "./tool"
43
import { BackgroundShell, ShellNotFound } from "../shell/background"
54

6-
const parameters = z.object({
7-
shell_id: z.string().describe("The id of a background shell previously started via bash with run_in_background"),
5+
const parameters = Schema.Struct({
6+
shell_id: Schema.String.annotate({
7+
description: "The id of a background shell previously started via bash with run_in_background",
8+
}),
89
})
910

1011
const DESCRIPTION = `Read new output from a background shell started by the bash tool with \`run_in_background: true\`.
@@ -20,7 +21,7 @@ export const BashOutputTool = Tool.define(
2021
return {
2122
description: DESCRIPTION,
2223
parameters,
23-
execute: (params: z.infer<typeof parameters>, _ctx: Tool.Context) =>
24+
execute: (params: Schema.Schema.Type<typeof parameters>, _ctx: Tool.Context) =>
2425
bg
2526
.output({ shellID: params.shell_id })
2627
.pipe(

packages/opencode/src/tool/kill-shell.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import z from "zod"
2-
import { Effect } from "effect"
1+
import { Effect, Schema } from "effect"
32
import * as Tool from "./tool"
43
import { BackgroundShell, ShellNotFound } from "../shell/background"
54

6-
const parameters = z.object({
7-
shell_id: z.string().describe("The id of the background shell to terminate"),
5+
const parameters = Schema.Struct({
6+
shell_id: Schema.String.annotate({ description: "The id of the background shell to terminate" }),
87
})
98

109
const DESCRIPTION = `Terminate a background shell previously started by the bash tool with \`run_in_background: true\`.
@@ -18,7 +17,7 @@ export const KillShellTool = Tool.define(
1817
return {
1918
description: DESCRIPTION,
2019
parameters,
21-
execute: (params: z.infer<typeof parameters>, _ctx: Tool.Context) =>
20+
execute: (params: Schema.Schema.Type<typeof parameters>, _ctx: Tool.Context) =>
2221
bg
2322
.kill({ shellID: params.shell_id })
2423
.pipe(

0 commit comments

Comments
 (0)