feat(19-01): add getAgentQuestions and listWaitingAgents tRPC procedures

- getAgentQuestions returns structured PendingQuestions from AgentManager
- listWaitingAgents filters agents to waiting_for_input status
- Updated JSDoc procedure list with both new procedures
This commit is contained in:
Lukas May
2026-02-04 21:51:25 +01:00
parent 6450e4072a
commit 004140ea83

View File

@@ -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<PendingQuestions | null> => {
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
// ===========================================================================