diff --git a/src/trpc/router.ts b/src/trpc/router.ts index ecfb30e..699cfd0 100644 --- a/src/trpc/router.ts +++ b/src/trpc/router.ts @@ -8,7 +8,7 @@ import { initTRPC, TRPCError } from '@trpc/server'; import { z } from 'zod'; import type { TRPCContext } from './context.js'; -import type { AgentInfo, AgentResult } from '../agent/types.js'; +import type { AgentInfo, AgentResult, PendingQuestions } from '../agent/types.js'; import type { TaskRepository } from '../db/repositories/task-repository.js'; import type { MessageRepository } from '../db/repositories/message-repository.js'; import type { InitiativeRepository } from '../db/repositories/initiative-repository.js'; @@ -308,6 +308,8 @@ function requirePhaseDispatchManager(ctx: TRPCContext): PhaseDispatchManager { * - getAgentByName: Get agent by name * - resumeAgent: Resume an agent waiting for input * - getAgentResult: Get result of agent's work + * - getAgentQuestions: Get pending questions for an agent waiting for input + * - listWaitingAgents: List agents currently waiting for user input * - listTasks: List tasks for a plan * - getTask: Get task by ID * - updateTaskStatus: Update task status @@ -454,6 +456,29 @@ export const appRouter = router({ return agentManager.getResult(agent.id); }), + /** + * Get pending questions for an agent waiting for input. + * Returns structured question data (options, multiSelect) from AgentManager. + */ + getAgentQuestions: publicProcedure + .input(agentIdentifierSchema) + .query(async ({ ctx, input }): Promise => { + const agentManager = requireAgentManager(ctx); + const agent = await resolveAgent(ctx, input); + return agentManager.getPendingQuestions(agent.id); + }), + + /** + * List agents currently waiting for user input. + * Filters to only agents with status 'waiting_for_input'. + */ + listWaitingAgents: publicProcedure + .query(async ({ ctx }) => { + const agentManager = requireAgentManager(ctx); + const allAgents = await agentManager.list(); + return allAgents.filter(agent => agent.status === 'waiting_for_input'); + }), + // =========================================================================== // Task Procedures // ===========================================================================