Files
goclaw/migrations/000019_team_id_columns.down.sql
T
Viet Tran 9a9744077e refactor(teams): v2 system cleanup — remove legacy tools, fix followup, add events API (#210)
Major refactoring of the team system with multiple improvements:

## Removed legacy delegation tools
- Delete `delegate.go`, `delegate_async.go`, `delegate_sync.go`, `delegate_events.go`,
  `delegate_policy.go`, `delegate_prep.go`, `delegate_state.go`, `delegate_search_tool.go`
- Delete `evaluate_loop_tool.go`, `handoff_tool.go`
- Remove all references and registrations from tool manager and policy
- Clean up TEAM_PLAYBOOK_IDEAS.md and TEAM_SYSTEM.md (moved to docs)

## Rename await_reply → ask_user
- Rename action `await_reply` → `ask_user`, `clear_followup` → `clear_ask_user`
- Rename functions `executeAwaitReply` → `executeAskUser`, `executeClearFollowup` → `executeClearAskUser`
- Update system prompt with stronger wording to prevent model misuse
- Model was confusing "await_reply" with general waiting; "ask_user" is unambiguous

## Fix auto-followup false positives
- Add `HasActiveMemberTasks(ctx, teamID, excludeAgentID)` store method
- Guard `autoSetFollowup()` in consumer: skip when lead has active member tasks
- Prevents auto-followup when lead is orchestrating teammates (not waiting for user)

## Task identifier zero-padding
- Change format from `T-1-xxxx` → `T-001-xxxx` (3-digit minimum)

## Refactor workspace WS handlers to filesystem-only
- Rewrite `teams.workspace.list/read/delete` to use pure filesystem (os.ReadDir/ReadFile/Remove)
- Remove DB dependency from workspace WS handlers
- Consistent with storage handler and workspace tools
- Simplify TeamWorkspaceFile type and frontend hook

## Add team events listing API
- New WS method `teams.events.list` with team_id, limit, offset params
- New HTTP endpoint `GET /v1/teams/{id}/events` with bearer auth
- New `ListTeamEvents(ctx, teamID, limit, offset)` store method
- JOIN with team_tasks for team-wide event filtering

## Extract team access policy
- New `team_access_policy.go` — centralized team tool access control

## Migration 000019: team_id columns
- Add team_id foreign key columns to relevant tables

## Other improvements
- Add team_id propagation through agent loop, tracing, sessions
- Update i18n locale files (en/vi/zh) for new tool labels
- Update frontend builtin-tools page and require-setup component
- Bump RequiredSchemaVersion for migration 000019
2026-03-15 14:53:19 +07:00

42 lines
1.2 KiB
SQL

-- Drop performance indexes for team_tasks
DROP INDEX IF EXISTS idx_tt_owner_status;
DROP INDEX IF EXISTS idx_tt_blocked_by;
-- Revert: remove team_id from memory, KG, traces, spans, cron, and sessions tables.
-- Sessions
DROP INDEX IF EXISTS idx_sessions_team;
ALTER TABLE sessions DROP COLUMN IF EXISTS team_id;
-- Cron run logs
DROP INDEX IF EXISTS idx_cron_run_logs_team;
ALTER TABLE cron_run_logs DROP COLUMN IF EXISTS team_id;
-- Cron jobs
DROP INDEX IF EXISTS idx_cron_jobs_team;
ALTER TABLE cron_jobs DROP COLUMN IF EXISTS team_id;
-- Spans
DROP INDEX IF EXISTS idx_spans_team;
ALTER TABLE spans DROP COLUMN IF EXISTS team_id;
-- Traces
DROP INDEX IF EXISTS idx_traces_team;
ALTER TABLE traces DROP COLUMN IF EXISTS team_id;
-- KG relations
DROP INDEX IF EXISTS idx_kg_relations_team;
ALTER TABLE kg_relations DROP COLUMN IF EXISTS team_id;
-- KG entities
DROP INDEX IF EXISTS idx_kg_entities_team;
ALTER TABLE kg_entities DROP COLUMN IF EXISTS team_id;
-- Memory chunks
DROP INDEX IF EXISTS idx_memchunk_team;
ALTER TABLE memory_chunks DROP COLUMN IF EXISTS team_id;
-- Memory documents
DROP INDEX IF EXISTS idx_memdoc_team;
ALTER TABLE memory_documents DROP COLUMN IF EXISTS team_id;