()
| 80 | } |
| 81 | |
| 82 | func createDependencies() *agent.Dependencies { |
| 83 | // 创建工具注册表并注册内置工具 |
| 84 | toolRegistry := tools.NewRegistry() |
| 85 | builtin.RegisterAll(toolRegistry) |
| 86 | |
| 87 | // 创建模板注册表 |
| 88 | templateRegistry := agent.NewTemplateRegistry() |
| 89 | |
| 90 | // 注册代码助手模板 |
| 91 | templateRegistry.Register(&types.AgentTemplateDefinition{ |
| 92 | ID: "code-assistant", |
| 93 | SystemPrompt: "You are a professional code assistant. Help users with software development tasks.", |
| 94 | Tools: []any{"Read", "Write"}, |
| 95 | }) |
| 96 | |
| 97 | // 注册研究助手模板 |
| 98 | templateRegistry.Register(&types.AgentTemplateDefinition{ |
| 99 | ID: "research-assistant", |
| 100 | SystemPrompt: "You are a research assistant. Help users gather and analyze information.", |
| 101 | Tools: []any{"Read"}, |
| 102 | }) |
| 103 | |
| 104 | // 注册带 Todo 提醒的模板 |
| 105 | templateRegistry.Register(&types.AgentTemplateDefinition{ |
| 106 | ID: "todo-assistant", |
| 107 | SystemPrompt: "You are a task management assistant.", |
| 108 | Tools: []any{"Read", "Write"}, |
| 109 | Runtime: &types.AgentTemplateRuntime{ |
| 110 | Todo: &types.TodoConfig{ |
| 111 | Enabled: true, |
| 112 | ReminderOnStart: true, |
| 113 | }, |
| 114 | }, |
| 115 | }) |
| 116 | |
| 117 | // 创建 Provider Factory |
| 118 | providerFactory := provider.NewMultiProviderFactory() |
| 119 | |
| 120 | // 创建 Sandbox Factory |
| 121 | sandboxFactory := sandbox.NewFactory() |
| 122 | |
| 123 | // 创建 Store |
| 124 | jsonStore, err := store.NewJSONStore(".aster-prompt-builder") |
| 125 | if err != nil { |
| 126 | log.Fatalf("Failed to create store: %v", err) |
| 127 | } |
| 128 | |
| 129 | return &agent.Dependencies{ |
| 130 | ToolRegistry: toolRegistry, |
| 131 | TemplateRegistry: templateRegistry, |
| 132 | ProviderFactory: providerFactory, |
| 133 | SandboxFactory: sandboxFactory, |
| 134 | Store: jsonStore, |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | // getSystemPrompt 获取 Agent 的 System Prompt |
| 139 | func getSystemPrompt(ag *agent.Agent) string { |
no test coverage detected