Skip to content

[codex] Convert webhook adapter to TypeScript#5

Merged
BunsDev merged 1 commit into
mainfrom
codex/typescript-webhook
Jul 6, 2026
Merged

[codex] Convert webhook adapter to TypeScript#5
BunsDev merged 1 commit into
mainfrom
codex/typescript-webhook

Conversation

@BunsDev

@BunsDev BunsDev commented Jul 6, 2026

Copy link
Copy Markdown
Member

Summary

  • Replace the Python WSGI webhook adapter with a TypeScript/Node service.
  • Preserve the existing webhook contract, policy routing, state layout, GitHub App auth flow, PR review context capture, coven-code runtime invocation, publication comments, and review-fix loop behavior.
  • Add Node CI, TypeScript parity tests, and updated runtime docs.

Verification

  • python3 -m unittest tests/test_webhook_adapter.py before rewrite: 10/10
  • npm test: 11/11
  • npm run build
  • ruby -e 'require "yaml"; YAML.load_file(".github/workflows/ci.yml"); puts "workflow yaml ok"'
  • git diff --check
  • WEBHOOK_SECRET=local-smoke-secret scripts/smoke-webhook.sh http://localhost:3107/webhook against built npm start server

Signed-off-by: Val Alexander <bunsthedev@gmail.com>
Copilot AI review requested due to automatic review settings July 6, 2026 13:29
@BunsDev BunsDev merged commit d78d5b4 into main Jul 6, 2026
1 check passed
@BunsDev BunsDev deleted the codex/typescript-webhook branch July 6, 2026 13:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 unittest to 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 thread src/server.ts
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 thread src/server.ts
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 thread src/adapter.ts
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)}`);
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.

2 participants