---
phase: 19-agent-inbox
plan: 01
type: execute
wave: 1
depends_on: []
files_modified: [src/trpc/router.ts]
autonomous: true
---

<objective>
Add tRPC procedures to expose structured agent question data to the frontend.

Purpose: The agent inbox UI needs structured question data (options, multiSelect) to render form controls. Questions are stored in-memory on AgentManager via `getPendingQuestions(agentId)`, but no tRPC procedure exposes this. The message table `content` is a plain string and does NOT contain the structured question data. This plan bridges that gap.

Output: Two new tRPC procedures: `getAgentQuestions` and `listWaitingAgents`.
</objective>

<execution_context>
@~/.claude/get-shit-done/workflows/execute-plan.md
@~/.claude/get-shit-done/templates/summary.md
</execution_context>

<context>
@.planning/PROJECT.md
@.planning/ROADMAP.md
@.planning/STATE.md

@src/trpc/router.ts
@src/agent/types.ts
@src/agent/schema.ts
</context>

<tasks>

<task type="auto">
  <name>Task 1: Add getAgentQuestions tRPC procedure</name>
  <files>src/trpc/router.ts</files>
  <action>
Add a `getAgentQuestions` query procedure to the appRouter. It should:
1. Accept `agentIdentifierSchema` input (same as getAgent — name or id)
2. Resolve the agent via `resolveAgent(ctx, input)`
3. Call `agentManager.getPendingQuestions(agent.id)`
4. Return the `PendingQuestions` object (or null if no pending questions)

Place it near the existing `getAgentResult` procedure since it follows the same pattern.

Also add a `listWaitingAgents` query that filters `agentManager.list()` to only agents with `status === 'waiting_for_input'`. This lets the inbox efficiently fetch only agents that have questions without filtering client-side.

Update the JSDoc procedure list comment at the top of appRouter to include both new procedures.
  </action>
  <verify>npx tsc --noEmit (TypeScript compiles without errors)</verify>
  <done>
    - `getAgentQuestions` procedure exists and returns PendingQuestions | null
    - `listWaitingAgents` procedure exists and returns AgentInfo[] filtered to waiting_for_input
    - TypeScript compiles clean
  </done>
</task>

<task type="auto">
  <name>Task 2: Export PendingQuestions and QuestionItem types from shared package</name>
  <files>packages/shared/src/types.ts</files>
  <action>
The frontend needs `PendingQuestions` and `QuestionItem` types to properly type the question form props. Export these types from the shared package:

1. In `packages/shared/src/types.ts`, add re-exports for `PendingQuestions` and `QuestionItem` from `../../src/agent/types.js`
2. If the import path doesn't work with the shared package's rootDir config, define matching interfaces directly in the shared types file (same shapes as in src/agent/types.ts)

The key types needed by the frontend are:
- `QuestionItem`: `{ id: string; question: string; options?: { label: string; description?: string }[]; multiSelect?: boolean }`
- `PendingQuestions`: `{ questions: QuestionItem[] }`
  </action>
  <verify>npx tsc --noEmit -p packages/shared/tsconfig.json && npx tsc --noEmit -p packages/web/tsconfig.app.json</verify>
  <done>
    - PendingQuestions and QuestionItem available to import from @codewalk-district/shared
    - Both frontend and backend packages compile
  </done>
</task>

</tasks>

<verification>
Before declaring plan complete:
- [ ] `npx tsc --noEmit` passes in root
- [ ] `npm run build` succeeds
- [ ] New procedures visible in router type
</verification>

<success_criteria>

- getAgentQuestions procedure returns structured question data from AgentManager
- listWaitingAgents returns only agents in waiting_for_input status
- PendingQuestions/QuestionItem types available in shared package
- All builds pass
  </success_criteria>

<output>
After completion, create `.planning/phases/19-agent-inbox/19-01-SUMMARY.md`
</output>
