index.ts 632 B

12345678910111213141516171819202122232425
  1. import { tool } from "@opencode-ai/plugin/tool"
  2. // Example tool implementation
  3. export async function exampleFunction(input: string): Promise<string> {
  4. // Your tool logic here
  5. return `Processed: ${input}`
  6. }
  7. // Tool definition for OpenCode agent system
  8. export const exampleTool = tool({
  9. description: "Example tool description",
  10. args: {
  11. input: tool.schema.string().describe("Input parameter description"),
  12. },
  13. async execute(args, context) {
  14. try {
  15. return await exampleFunction(args.input)
  16. } catch (error) {
  17. return `Error: ${error.message}`
  18. }
  19. },
  20. })
  21. // Default export
  22. export default exampleTool