mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-06-10 10:10:49 +00:00
e138ac7676
- Add terminal-state check in executeCreate(): reject blocked_by referencing completed/cancelled/failed tasks with actionable error - Add full validation in executeUpdate(): batch query via GetTasksByIDs, check existence + team membership + terminal state - Add GetTasksByIDs batch query to TeamStore interface + pg implementation - Refactor: modularize gateway, skills store, and team tools into focused files - Update TEAM.md leader prompt: prefer delegation, plan full task graph upfront, create tasks in order with blocked_by UUIDs
43 lines
1.5 KiB
Go
43 lines
1.5 KiB
Go
package tools
|
|
|
|
import (
|
|
"sync"
|
|
"time"
|
|
|
|
"github.com/nextlevelbuilder/goclaw/internal/bus"
|
|
"github.com/nextlevelbuilder/goclaw/internal/store"
|
|
)
|
|
|
|
const teamCacheTTL = 5 * time.Minute
|
|
|
|
// teamCacheEntry wraps cached team data + members with a timestamp for TTL expiration.
|
|
type teamCacheEntry struct {
|
|
team *store.TeamData
|
|
members []store.TeamMemberData // loaded together with team to avoid separate DB call
|
|
cachedAt time.Time
|
|
}
|
|
|
|
// agentCacheEntry wraps cached agent data with a timestamp for TTL expiration.
|
|
type agentCacheEntry struct {
|
|
agent *store.AgentData
|
|
cachedAt time.Time
|
|
}
|
|
|
|
// TeamToolManager is the shared backend for team_tasks and team_message tools.
|
|
// It resolves the calling agent's team from context and provides access to
|
|
// the team store, agent store, and message bus.
|
|
// Includes a TTL cache for team data to avoid DB queries on every tool call.
|
|
type TeamToolManager struct {
|
|
teamStore store.TeamStore
|
|
agentStore store.AgentStore
|
|
msgBus *bus.MessageBus
|
|
dataDir string // base data directory for workspace path resolution
|
|
teamCache sync.Map // agentID (uuid.UUID) → *teamCacheEntry
|
|
agentCache sync.Map // agentID (uuid.UUID) → *agentCacheEntry
|
|
agentKeyCache sync.Map // agentKey (string) → *agentCacheEntry
|
|
}
|
|
|
|
func NewTeamToolManager(teamStore store.TeamStore, agentStore store.AgentStore, msgBus *bus.MessageBus, dataDir string) *TeamToolManager {
|
|
return &TeamToolManager{teamStore: teamStore, agentStore: agentStore, msgBus: msgBus, dataDir: dataDir}
|
|
}
|