feat: enrich listWaitingAgents with task/phase/initiative context via DB joins
Replaces the in-memory filter (agentManager.list() + filter) with a direct repository query that LEFT JOINs tasks, phases, and initiatives to return taskName, phaseName, initiativeName, and taskDescription alongside agent fields. - Adds AgentWithContext interface and findWaitingWithContext() to AgentRepository port - Implements findWaitingWithContext() in DrizzleAgentRepository using getTableColumns - Wires agentRepository into TRPCContext, CreateContextOptions, and TrpcAdapterOptions - Adds requireAgentRepository() helper following existing pattern - Updates listWaitingAgents to use repository query instead of agentManager - Adds 5 unit tests for findWaitingWithContext() covering all FK join edge cases - Updates existing AgentRepository mocks to satisfy updated interface Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,14 @@
|
||||
import type { Agent } from '../schema.js';
|
||||
import type { AgentMode } from '../../agent/types.js';
|
||||
|
||||
/** Agent row enriched with joined task/phase/initiative context fields. */
|
||||
export interface AgentWithContext extends Agent {
|
||||
taskName: string | null;
|
||||
phaseName: string | null;
|
||||
initiativeName: string | null;
|
||||
taskDescription: string | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Agent status values.
|
||||
*/
|
||||
@@ -117,4 +125,10 @@ export interface AgentRepository {
|
||||
* Throws if agent not found.
|
||||
*/
|
||||
delete(id: string): Promise<void>;
|
||||
|
||||
/**
|
||||
* Find all agents with status 'waiting_for_input', enriched with
|
||||
* task, phase, and initiative names via LEFT JOINs.
|
||||
*/
|
||||
findWaitingWithContext(): Promise<AgentWithContext[]>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user