opencode_offline/packages/plugin/src/example.ts

23 lines
478 B
TypeScript
Raw Normal View History

2025-08-03 06:50:19 +08:00
import { Plugin } from "./index"
2025-09-18 15:58:21 +08:00
import { tool } from "./tool"
2025-08-03 06:50:19 +08:00
2025-09-18 15:58:21 +08:00
export const ExamplePlugin: Plugin = async (ctx) => {
2025-08-03 06:50:19 +08:00
return {
permission: {},
2025-09-18 15:58:21 +08:00
tool: {
mytool: tool((zod) => ({
description: "This is a custom tool tool",
args: {
foo: zod.string(),
},
async execute(args, ctx) {
return `Hello ${args.foo}!`
},
})),
},
2025-09-02 05:35:48 +08:00
async "chat.params"(_input, output) {
2025-08-04 09:42:45 +08:00
output.topP = 1
2025-08-04 09:19:03 +08:00
},
2025-08-03 06:50:19 +08:00
}
}