MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / execute

Method execute

src/core/tools/SkillTool.ts:19–81  ·  view source on GitHub ↗
(params: SkillParams, task: Task, callbacks: ToolCallbacks)

Source from the content-addressed store, hash-verified

17 readonly name = "skill" as const
18
19 async execute(params: SkillParams, task: Task, callbacks: ToolCallbacks): Promise<void> {
20 const { skill: skillName, args } = params
21 const { askApproval, handleError, pushToolResult } = callbacks
22
23 try {
24 // Validate skill name parameter
25 if (!skillName) {
26 task.consecutiveMistakeCount++
27 task.recordToolError("skill")
28 task.didToolFailInCurrentTurn = true
29 pushToolResult(await task.sayAndCreateMissingParamError("skill", "skill"))
30 return
31 }
32
33 task.consecutiveMistakeCount = 0
34
35 // Get SkillsManager from provider
36 const provider = task.providerRef.deref()
37 const skillsManager = provider?.getSkillsManager()
38
39 if (!skillsManager) {
40 task.recordToolError("skill")
41 task.didToolFailInCurrentTurn = true
42 pushToolResult(formatResponse.toolError("Skills Manager not available"))
43 return
44 }
45
46 // Get current mode for skill resolution
47 const state = await provider?.getState()
48 const currentMode = state?.mode ?? "code"
49
50 // Fetch skill content
51 const skillContent = await resolveSkillContentForMode(skillsManager, skillName, currentMode)
52
53 if (!skillContent) {
54 // Get available skills for error message
55 const availableSkills = skillsManager.getSkillsForMode(currentMode)
56 const skillNames = availableSkills.map((s) => s.name)
57
58 task.recordToolError("skill")
59 task.didToolFailInCurrentTurn = true
60 pushToolResult(
61 formatResponse.toolError(
62 `Skill '${skillName}' not found. Available skills: ${skillNames.join(", ") || "(none)"}`,
63 ),
64 )
65 return
66 }
67
68 // Build approval message
69 const toolMessage = buildSkillApprovalMessage(skillName, args, skillContent)
70
71 const didApprove = await askApproval("tool", toolMessage)
72
73 if (!didApprove) {
74 return
75 }
76

Callers

nothing calls this directly

Calls 11

buildSkillResultFunction · 0.90
pushToolResultFunction · 0.85
askApprovalFunction · 0.85
handleErrorFunction · 0.85
recordToolErrorMethod · 0.80
getSkillsManagerMethod · 0.80
getSkillsForModeMethod · 0.80
getStateMethod · 0.65

Tested by

no test coverage detected