Skip to content

Conversation

@eXamadeus
Copy link

@eXamadeus eXamadeus commented Jan 14, 2026

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)

@github-actions
Copy link
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

Bus.publish(Event.Asked, info)
})

return (awaitAnswers ? answerPromise : id) as T extends true ? typeof answerPromise : typeof id
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This conditional type makes it very safe to use:

Image

@eXamadeus
Copy link
Author

eXamadeus commented Jan 14, 2026

/review

EDIT: 😢 I was hoping I could summon a review bot to give me some early feedback, heh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Expose Question.ask for API/SDK to use

1 participant