Skip to content

Feature: Support PreToolUse hook updatedInput for headless question answering #336

@OneStepAt4time

Description

@OneStepAt4time

Background

Claude Code v2.1.85 added support for PreToolUse hooks to return updatedInput alongside permissionDecision: "allow", enabling headless integrations that collect answers via their own UI.

Feature

When CC asks a question via AskUserQuestion tool, Aegis should be able to intercept it via the PreToolUse hook and provide an answer programmatically.

API

POST /v1/sessions/:id/answer
{
  "questionId": "<tool_use_id>",
  "answer": "<user answer text>"
}

Flow

  1. CC invokes AskUserQuestion tool
  2. Aegis PreToolUse hook fires with the question
  3. Aegis stores the pending question and emits a ask_question status event (already done)
  4. External client calls POST /v1/sessions/:id/answer
  5. Aegis returns { permissionDecision: "allow", updatedInput: { answer: "..." } } from the hook
  6. CC receives the answer and continues

Priority

P1 — This is a key differentiator for headless CC orchestration.

Files

  • src/hooks.ts — hook handler for PreToolUse with updatedInput
  • src/server.ts — new endpoint POST /v1/sessions/:id/answer
  • src/session.ts — pending question tracking
  • src/events.ts — question event with ID for correlation

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions