MCPcopy Create free account
hub / github.com/astercloud/aster / NewCodeExecuteTool

Function NewCodeExecuteTool

pkg/tools/builtin/codeexecute.go:28–42  ·  view source on GitHub ↗

NewCodeExecuteTool 创建代码执行工具

(config map[string]any)

Source from the content-addressed store, hash-verified

26
27// NewCodeExecuteTool 创建代码执行工具
28func NewCodeExecuteTool(config map[string]any) (tools.Tool, error) {
29 runtimeConfig := bridge.DefaultRuntimeConfig()
30
31 // 解析配置
32 if timeout, ok := config["timeout"].(float64); ok {
33 runtimeConfig.Timeout = time.Duration(timeout) * time.Second
34 }
35 if workDir, ok := config["work_dir"].(string); ok {
36 runtimeConfig.WorkDir = workDir
37 }
38
39 return &CodeExecuteTool{
40 runtimeManager: bridge.NewRuntimeManager(runtimeConfig),
41 }, nil
42}
43
44// NewCodeExecuteToolWithBridge 创建带桥接器的代码执行工具
45func NewCodeExecuteToolWithBridge(toolBridge *bridge.ToolBridge) *CodeExecuteTool {

Callers

nothing calls this directly

Calls 3

DefaultRuntimeConfigFunction · 0.92
NewRuntimeManagerFunction · 0.92
DurationMethod · 0.45

Tested by

no test coverage detected