mirror of
https://github.com/sst/opencode.git
synced 2025-08-31 02:07:24 +00:00
fix mcp tools corrupting session
This commit is contained in:
parent
27f7e02f12
commit
0d50c867ff
2 changed files with 20 additions and 8 deletions
|
@ -1,5 +1,11 @@
|
|||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"mcp": {
|
||||
"weather": {
|
||||
"type": "local",
|
||||
"command": ["opencode", "x", "@h1deya/mcp-server-weather"]
|
||||
}
|
||||
},
|
||||
"experimental": {
|
||||
"hook": {
|
||||
"file_edited": {
|
||||
|
|
|
@ -496,14 +496,20 @@ export namespace Session {
|
|||
const execute = item.execute
|
||||
if (!execute) continue
|
||||
item.execute = async (args, opts) => {
|
||||
try {
|
||||
const result = await execute(args, opts)
|
||||
return result.content
|
||||
.filter((x: any) => x.type === "text")
|
||||
.map((x: any) => x.text)
|
||||
.join("\n\n")
|
||||
} catch (e: any) {
|
||||
return e.toString()
|
||||
const result = await execute(args, opts)
|
||||
const output = result.content
|
||||
.filter((x: any) => x.type === "text")
|
||||
.map((x: any) => x.text)
|
||||
.join("\n\n")
|
||||
|
||||
return {
|
||||
output,
|
||||
}
|
||||
}
|
||||
item.toModelOutput = (result) => {
|
||||
return {
|
||||
type: "text",
|
||||
value: result.output,
|
||||
}
|
||||
}
|
||||
tools[key] = item
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue