feat: add responses passthrough#1
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an OpenAI-style responses passthrough to the Copilot proxy so clients can call /responses (and /v1/responses) and receive the upstream Copilot response (including streaming metadata) largely unchanged.
Changes:
- Introduces a new Copilot service (
createResponses) that POSTs to Copilot’s/responsesendpoint and returns the upstreamResponse. - Adds Hono routing for
/responsesand registers it under both/responsesand/v1/responses. - Adds tests covering basic POST behavior and preservation of streaming headers/body; updates README endpoint documentation.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/create-responses.test.ts | Adds unit tests for the new responses passthrough behavior (JSON + streaming). |
| src/services/copilot/create-responses.ts | Implements the Copilot /responses service call and error handling. |
| src/routes/responses/route.ts | Adds a new route that forwards request JSON to Copilot and streams back status/headers/body. |
| src/server.ts | Registers the new responses routes under both unversioned and /v1 paths. |
| README.md | Documents the new endpoints and simplifies the README structure. |
| bun.lock | Lockfile metadata update (configVersion). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /// <reference lib="dom" /> | ||
|
|
There was a problem hiding this comment.
/// <reference lib="dom" /> is the only triple-slash lib reference in the repo. Since the project’s TypeScript configuration controls global libs, it’s better to avoid per-file lib references here (they can create inconsistent typing/duplicate lib definitions across files). Consider removing this and, if DOM types are actually needed project-wide, add them in tsconfig.json (or rely on @types/bun) instead.
| /// <reference lib="dom" /> |
| body: JSON.stringify(payload), | ||
| }) | ||
|
|
||
| if (!response.ok) throw new HTTPError("Failed to create response", response) |
There was a problem hiding this comment.
The error message "Failed to create response" is a bit ambiguous/inconsistent with the endpoint name (/responses) and other service errors in this repo (e.g., "Failed to create embeddings", "Failed to create chat completions"). Consider renaming it to clearly identify the failing operation (e.g., "Failed to create responses") so logs and client errors are easier to interpret.
| if (!response.ok) throw new HTTPError("Failed to create response", response) | |
| if (!response.ok) throw new HTTPError("Failed to create responses", response) |
| | Endpoint | Method | Notes | | ||
| | --- | --- | --- | | ||
| | `/chat/completions` | `POST` | Chat completions passthrough | | ||
| | `/v1/chat/completions` | `POST` | Chat completions passthrough | | ||
| | `/embeddings` | `POST` | Embeddings passthrough | | ||
| | `/v1/embeddings` | `POST` | Embeddings passthrough | | ||
| | `/models` | `GET` | Model list | | ||
| | `/v1/models` | `GET` | Model list | | ||
| | `/responses` | `POST` | Responses passthrough | | ||
| | `/v1/responses` | `POST` | Responses passthrough | |
There was a problem hiding this comment.
The new Markdown tables in this section start with a double pipe (|| ...). In standard Markdown this creates an extra empty first column, which makes the table render with a blank leading column. Use a single leading pipe (| ...) for the header and separator rows to avoid the extra column.
| | Endpoint | Method | Notes | | ||
| | --- | --- | --- | | ||
| | `/v1/messages` | `POST` | Anthropic messages compatibility | | ||
| | `/v1/messages/count_tokens` | `POST` | Token counting | |
There was a problem hiding this comment.
This table also starts with ||, which renders an extra blank first column in Markdown. Use a single leading | on the header/separator rows instead.
| | Endpoint | Method | Notes | | ||
| | --- | --- | --- | | ||
| | `/usage` | `GET` | Usage information | | ||
| | `/token` | `GET` | Current Copilot token | |
There was a problem hiding this comment.
Same Markdown table formatting issue here: the rows start with ||, which adds an unintended empty first column when rendered. Prefer a single leading | for these rows.
No description provided.