refactor(tools): extract shared logic for internal channels and tool definitions
- Add constants package with IsInternalChannel helper to centralize internal channel checks across agent, channels, and heartbeat services - Add ToProviderDefs method to ToolRegistry to consolidate tool definition conversion logic used in agent loop and tool loop - Refactor SubagentTool.Execute to use RunToolLoop for consistent tool execution with iteration tracking - Remove duplicate inline map definitions and type assertion code throughout codebase
This commit is contained in:
15
pkg/constants/channels.go
Normal file
15
pkg/constants/channels.go
Normal file
@@ -0,0 +1,15 @@
|
||||
// Package constants provides shared constants across the codebase.
|
||||
package constants
|
||||
|
||||
// InternalChannels defines channels that are used for internal communication
|
||||
// and should not be exposed to external users or recorded as last active channel.
|
||||
var InternalChannels = map[string]bool{
|
||||
"cli": true,
|
||||
"system": true,
|
||||
"subagent": true,
|
||||
}
|
||||
|
||||
// IsInternalChannel returns true if the channel is an internal channel.
|
||||
func IsInternalChannel(channel string) bool {
|
||||
return InternalChannels[channel]
|
||||
}
|
||||
Reference in New Issue
Block a user