[codex] Convert webhook adapter to TypeScript#5
Merged
Conversation
Signed-off-by: Val Alexander <bunsthedev@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR replaces the repo’s Python WSGI-based GitHub webhook adapter with a TypeScript/Node service while keeping the same core webhook contract (signature verification, policy-based routing/state layout, GitHub App auth, coven-code invocation, and optional publication back to GitHub).
Changes:
- Add a TypeScript implementation of the adapter/task runner and a Node HTTP server entrypoint.
- Port webhook adapter parity tests from Python
unittestto Node’s test runner. - Add Node/TypeScript build + CI wiring and update docs/ignores accordingly.
Reviewed changes
Copilot reviewed 9 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/adapter.ts |
New TS implementation for signature verification, routing, task execution, PR evidence capture, and publication. |
src/server.ts |
New Node http server entrypoint exposing /, /healthz, and /webhook. |
tests/webhook-adapter.test.ts |
Parity tests for signature/body edge cases and routing guard behavior. |
tests/test_webhook_adapter.py |
Removes Python parity tests now replaced by TS tests. |
coven_github_adapter.py |
Removes the Python WSGI adapter that previously implemented the webhook service. |
package.json |
Adds Node/TS toolchain, scripts (test, build, start, dev), and Node engine constraint. |
package-lock.json |
Locks dev toolchain dependencies (typescript, tsx, @types/node). |
tsconfig.json |
Adds TS compiler configuration and compilation targets. |
.github/workflows/ci.yml |
Adds CI job to npm ci, npm test, and npm run build on Node 24. |
README.md |
Updates documentation from Python/WSGI to the new Node/TypeScript runtime and workflows. |
AGENTS.md |
Updates contributor guidance from Python-focused to TypeScript/Node-focused runtime constraints. |
.gitignore |
Ignores Node build artifacts (node_modules/, dist/). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+18
to
+30
| async function readBody(req: NodeJS.ReadableStream, limit: number): Promise<Buffer> { | ||
| const chunks: Buffer[] = []; | ||
| let total = 0; | ||
| for await (const chunk of req) { | ||
| const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk); | ||
| total += buffer.length; | ||
| if (total > limit) { | ||
| return Buffer.concat([...chunks, buffer], total); | ||
| } | ||
| chunks.push(buffer); | ||
| } | ||
| return Buffer.concat(chunks, total); | ||
| } |
Comment on lines
+32
to
+47
| export function createWebhookServer(config: AdapterConfig = createConfig()) { | ||
| return createServer(async (req, res) => { | ||
| const rawBody = await readBody(req, config.maxWebhookBodyBytes + 1); | ||
| const response = await handleRequest(config, { | ||
| method: req.method || "GET", | ||
| path: req.url?.split("?")[0] || "/", | ||
| headers: headersToMap(req.headers), | ||
| rawBody, | ||
| }); | ||
| const body = Buffer.from(JSON.stringify(response.body)); | ||
| res.statusCode = response.status; | ||
| res.setHeader("Content-Type", "application/json"); | ||
| res.setHeader("Content-Length", String(body.length)); | ||
| res.end(body); | ||
| }); | ||
| } |
Comment on lines
+602
to
+606
| if (task.state === "queued") { | ||
| try { | ||
| await runTask(config, String(task.task_id)); | ||
| } catch (error) { | ||
| debug(`COVEN GITHUB TASK RUN FAIL task_id=${task.task_id} ${String((error as Error).stack || error)}`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
coven-coderuntime invocation, publication comments, and review-fix loop behavior.Verification
python3 -m unittest tests/test_webhook_adapter.pybefore rewrite: 10/10npm test: 11/11npm run buildruby -e 'require "yaml"; YAML.load_file(".github/workflows/ci.yml"); puts "workflow yaml ok"'git diff --checkWEBHOOK_SECRET=local-smoke-secret scripts/smoke-webhook.sh http://localhost:3107/webhookagainst builtnpm startserver