opencode icon indicating copy to clipboard operation
opencode copied to clipboard

feat(core): expose `Question.ask` via API/SDK

Open eXamadeus opened this issue 4 days ago • 3 comments

What does this PR do?

Fixes: #8384

Exposes a new POST /question/ask server endpoint that allows clients and the SDK to programmatically ask questions to users without blocking. Key changes:

  • Refactored Question.ask() function to support an optional options parameter with an awaitAnswers key:
    • When awaitAnswers: true (default): blocks and returns the answers (existing behavior)
    • When awaitAnswers: false: returns the question request ID immediately without waiting for answers
  • Added new /question/ask API endpoint that creates a question request and returns its ID, enabling async question flows from external clients
    • /question/ask endpoint performs session existence validation and returns 404 when the session doesn't exist
  • Extracted Question.AskInput schema from Question.Request to provide a clean input type for the new endpoint (without the server-generated id field)
  • Regenerated SDK with the new Question.ask() method and types (QuestionAskInput, QuestionAskResponses, etc.)

How did you verify your code works?

  • Called endpoint locally and tested with my plugin
  • Added a test for the Question.ask refactor in test/question/question.test.ts
  • Added server endpoint tests in test/server/question.test.ts:
    • Happy path: returns question ID and adds to pending list
    • Returns 404 when session does not exist
    • Returns 400 when session ID format is invalid
    • Returns 400 when header exceeds max length (12 chars)

eXamadeus avatar Jan 14 '26 08:01 eXamadeus