Files
Memoh/packages/agent/src/tools/skill.ts
T
Acbox Liu e6d70b523e refactor: divide agent logic and gateway into different package (#90)
* feat: add @memoh/agent

* chore: use @memoh/agent in @memoh-gateway
2026-02-22 02:06:47 +08:00

28 lines
721 B
TypeScript

import { tool } from 'ai'
import { z } from 'zod'
interface SkillToolParams {
useSkill: (skill: string) => void
}
export const getSkillTools = ({ useSkill }: SkillToolParams) => {
const useSkillTool = tool({
description: 'Use a skill if you think it is relevant to the current task',
inputSchema: z.object({
skillName: z.string().describe('The name of the skill to use'),
reason: z.string().describe('The reason why you think this skill is relevant to the current task'),
}),
execute: async ({ skillName, reason }) => {
useSkill(skillName)
return {
success: true,
skillName,
reason,
}
},
})
return {
'use_skill': useSkillTool,
}
}