mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-27 07:16:19 +09:00
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import { AuthFetcher } from '..'
|
|
import { AgentAction, AgentAuthContext, BraveConfig, IdentityContext, ModelConfig } from '../types'
|
|
import { ToolSet } from 'ai'
|
|
import { getWebTools } from './web'
|
|
import { getSubagentTools } from './subagent'
|
|
import { getSkillTools } from './skill'
|
|
|
|
export interface ToolsParams {
|
|
fetch: AuthFetcher
|
|
model: ModelConfig
|
|
brave?: BraveConfig
|
|
identity: IdentityContext
|
|
auth: AgentAuthContext
|
|
enableSkill: (skill: string) => void
|
|
}
|
|
|
|
export const getTools = (
|
|
actions: AgentAction[],
|
|
{ fetch, model, brave, identity, auth, enableSkill }: ToolsParams
|
|
) => {
|
|
const tools: ToolSet = {}
|
|
if (actions.includes(AgentAction.Web) && brave) {
|
|
const webTools = getWebTools({ brave })
|
|
Object.assign(tools, webTools)
|
|
}
|
|
if (actions.includes(AgentAction.Subagent)) {
|
|
const subagentTools = getSubagentTools({ fetch, model, brave, identity, auth })
|
|
Object.assign(tools, subagentTools)
|
|
}
|
|
if (actions.includes(AgentAction.Skill)) {
|
|
const skillTools = getSkillTools({ useSkill: enableSkill })
|
|
Object.assign(tools, skillTools)
|
|
}
|
|
return tools
|
|
} |