Minor fix
This commit is contained in:
parent
70dfe7e589
commit
3be030b149
2 changed files with 44 additions and 34 deletions
|
|
@ -485,7 +485,7 @@ func interactiveMode(agentLoop *agent.AgentLoop, sessionKey string) {
|
||||||
func simpleInteractiveMode(agentLoop *agent.AgentLoop, sessionKey string) {
|
func simpleInteractiveMode(agentLoop *agent.AgentLoop, sessionKey string) {
|
||||||
reader := bufio.NewReader(os.Stdin)
|
reader := bufio.NewReader(os.Stdin)
|
||||||
for {
|
for {
|
||||||
fmt.Print(fmt.Sprintf("%s You: ", logo))
|
fmt.Printf("%s You: ", logo)
|
||||||
line, err := reader.ReadString('\n')
|
line, err := reader.ReadString('\n')
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
|
|
|
||||||
|
|
@ -54,43 +54,35 @@ type processOptions struct {
|
||||||
func NewAgentLoop(cfg *config.Config, msgBus *bus.MessageBus, provider providers.LLMProvider) *AgentLoop {
|
func NewAgentLoop(cfg *config.Config, msgBus *bus.MessageBus, provider providers.LLMProvider) *AgentLoop {
|
||||||
registry := NewAgentRegistry(cfg, provider)
|
registry := NewAgentRegistry(cfg, provider)
|
||||||
|
|
||||||
// File system tools
|
for _, agentID := range registry.ListAgentIDs() {
|
||||||
registry.Register(tools.NewReadFileTool(workspace, restrict))
|
agent, ok := registry.GetAgent(agentID)
|
||||||
registry.Register(tools.NewWriteFileTool(workspace, restrict))
|
if !ok {
|
||||||
registry.Register(tools.NewListDirTool(workspace, restrict))
|
continue
|
||||||
registry.Register(tools.NewEditFileTool(workspace, restrict))
|
}
|
||||||
registry.Register(tools.NewAppendFileTool(workspace, restrict))
|
|
||||||
|
|
||||||
// Shell execution
|
searchOpts := []tools.WebSearchToolOptions{
|
||||||
registry.Register(tools.NewExecTool(workspace, restrict))
|
{
|
||||||
|
Provider: cfg.Tools.Web.Search.Provider,
|
||||||
// Build web search tool from config - single provider with fallback to DuckDuckGo
|
APIKey: cfg.Tools.Web.Search.APIKey,
|
||||||
searchOpts := []tools.WebSearchToolOptions{
|
BaseURL: cfg.Tools.Web.Search.Endpoint,
|
||||||
{
|
MaxResults: cfg.Tools.Web.Search.MaxResults,
|
||||||
Provider: cfg.Tools.Web.Search.Provider,
|
Mode: cfg.Tools.Web.Search.RestType,
|
||||||
APIKey: cfg.Tools.Web.Search.APIKey,
|
Param: cfg.Tools.Web.Search.QueryParam,
|
||||||
BaseURL: cfg.Tools.Web.Search.Endpoint,
|
},
|
||||||
MaxResults: cfg.Tools.Web.Search.MaxResults,
|
{
|
||||||
Mode: cfg.Tools.Web.Search.RestType,
|
Provider: "duckduckgo",
|
||||||
Param: cfg.Tools.Web.Search.QueryParam,
|
MaxResults: 5,
|
||||||
},
|
},
|
||||||
// Always add DuckDuckGo as fallback
|
}
|
||||||
{
|
if searchTool := tools.NewWebSearchTool(searchOpts...); searchTool != nil {
|
||||||
Provider: "duckduckgo",
|
agent.Tools.Register(searchTool)
|
||||||
MaxResults: 5,
|
}
|
||||||
},
|
agent.Tools.Register(tools.NewWebFetchTool(50000))
|
||||||
}
|
|
||||||
|
|
||||||
if searchTool := tools.NewWebSearchTool(searchOpts...); searchTool != nil {
|
|
||||||
registry.Register(searchTool)
|
|
||||||
}
|
|
||||||
registry.Register(tools.NewWebFetchTool(50000))
|
|
||||||
|
|
||||||
// Hardware tools (I2C, SPI) - Linux only, returns error on other platforms
|
// Hardware tools (I2C, SPI) - Linux only, returns error on other platforms
|
||||||
agent.Tools.Register(tools.NewI2CTool())
|
agent.Tools.Register(tools.NewI2CTool())
|
||||||
agent.Tools.Register(tools.NewSPITool())
|
agent.Tools.Register(tools.NewSPITool())
|
||||||
|
|
||||||
// Message tool
|
|
||||||
messageTool := tools.NewMessageTool()
|
messageTool := tools.NewMessageTool()
|
||||||
messageTool.SetSendCallback(func(channel, chatID, content string) error {
|
messageTool.SetSendCallback(func(channel, chatID, content string) error {
|
||||||
msgBus.PublishOutbound(bus.OutboundMessage{
|
msgBus.PublishOutbound(bus.OutboundMessage{
|
||||||
|
|
@ -102,8 +94,15 @@ func NewAgentLoop(cfg *config.Config, msgBus *bus.MessageBus, provider providers
|
||||||
})
|
})
|
||||||
agent.Tools.Register(messageTool)
|
agent.Tools.Register(messageTool)
|
||||||
|
|
||||||
// Spawn tool with allowlist checker
|
|
||||||
subagentManager := tools.NewSubagentManager(provider, agent.Model, agent.Workspace, msgBus)
|
subagentManager := tools.NewSubagentManager(provider, agent.Model, agent.Workspace, msgBus)
|
||||||
|
subagentTools := tools.NewToolRegistry()
|
||||||
|
for _, toolName := range agent.Tools.List() {
|
||||||
|
if tool, exists := agent.Tools.Get(toolName); exists {
|
||||||
|
subagentTools.Register(tool)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
subagentManager.SetTools(subagentTools)
|
||||||
|
|
||||||
spawnTool := tools.NewSpawnTool(subagentManager)
|
spawnTool := tools.NewSpawnTool(subagentManager)
|
||||||
currentAgentID := agentID
|
currentAgentID := agentID
|
||||||
spawnTool.SetAllowlistChecker(func(targetAgentID string) bool {
|
spawnTool.SetAllowlistChecker(func(targetAgentID string) bool {
|
||||||
|
|
@ -111,9 +110,20 @@ func NewAgentLoop(cfg *config.Config, msgBus *bus.MessageBus, provider providers
|
||||||
})
|
})
|
||||||
agent.Tools.Register(spawnTool)
|
agent.Tools.Register(spawnTool)
|
||||||
|
|
||||||
// Update context builder with the complete tools registry
|
subagentTool := tools.NewSubagentTool(subagentManager)
|
||||||
|
agent.Tools.Register(subagentTool)
|
||||||
|
|
||||||
agent.ContextBuilder.SetToolsRegistry(agent.Tools)
|
agent.ContextBuilder.SetToolsRegistry(agent.Tools)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return &AgentLoop{
|
||||||
|
bus: msgBus,
|
||||||
|
cfg: cfg,
|
||||||
|
registry: registry,
|
||||||
|
state: state.NewManager(cfg.WorkspacePath()),
|
||||||
|
fallback: providers.NewFallbackChain(providers.NewCooldownTracker()),
|
||||||
|
summarizing: sync.Map{},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (al *AgentLoop) Run(ctx context.Context) error {
|
func (al *AgentLoop) Run(ctx context.Context) error {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue