Skip to content

Commit daea79c

Browse files
authored
feat: top level tool config (sst#2008)
1 parent 9c7fa35 commit daea79c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

packages/opencode/src/agent/agent.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export namespace Agent {
3838

3939
const state = App.state("agent", async () => {
4040
const cfg = await Config.get()
41+
const defaultTools = cfg.tools ?? {}
4142
const defaultPermission: Info["permission"] = {
4243
edit: "allow",
4344
bash: {
@@ -55,6 +56,7 @@ export namespace Agent {
5556
tools: {
5657
todoread: false,
5758
todowrite: false,
59+
...defaultTools,
5860
},
5961
options: {},
6062
permission: agentPermission,
@@ -63,7 +65,7 @@ export namespace Agent {
6365
},
6466
build: {
6567
name: "build",
66-
tools: {},
68+
tools: { ...defaultTools },
6769
options: {},
6870
permission: agentPermission,
6971
mode: "primary",
@@ -77,6 +79,7 @@ export namespace Agent {
7779
write: false,
7880
edit: false,
7981
patch: false,
82+
...defaultTools,
8083
},
8184
mode: "primary",
8285
builtIn: true,
@@ -109,6 +112,10 @@ export namespace Agent {
109112
...item.tools,
110113
...tools,
111114
}
115+
item.tools = {
116+
...defaultTools,
117+
...item.tools,
118+
}
112119
if (description) item.description = description
113120
if (temperature != undefined) item.temperature = temperature
114121
if (top_p != undefined) item.topP = top_p

packages/opencode/src/config/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ export namespace Config {
384384
webfetch: Permission.optional(),
385385
})
386386
.optional(),
387+
tools: z.record(z.string(), z.boolean()).optional(),
387388
experimental: z
388389
.object({
389390
hook: z

0 commit comments

Comments
 (0)