Skip to content

feat(webhook-server): raw-route registry — non-Chat-SDK webhooks become an append - #2739

Merged
gavrielc merged 2 commits into
mainfrom
feat/raw-webhook-registry
Jun 11, 2026
Merged

feat(webhook-server): raw-route registry — non-Chat-SDK webhooks become an append#2739
gavrielc merged 2 commits into
mainfrom
feat/raw-webhook-registry

Conversation

@gavrielc

Copy link
Copy Markdown
Collaborator

Type of Change

  • Feature skill - adds a channel or integration (source code changes + SKILL.md)
  • Utility skill - adds a standalone tool (code files in .claude/skills/<name>/, no source changes)
  • Operational/container skill - adds a workflow or agent skill (SKILL.md only, no source changes)
  • Fix - bug fix or security fix to source code
  • Simplification - reduces or simplifies source code
  • Documentation - docs, README, or CONTRIBUTING changes only

None of the boxes fit — this is a small core extensibility seam (same category as #2733's routingPath).

Description

What — a raw-route registry on the shared webhook server. registerWebhookHandler(path, handler) mounts a plain Node (req, res) handler at /webhook/{path}, alongside the existing Chat SDK adapter routes. Adds the exported RawWebhookHandler type, a second rawRoutes map (the WebhookEntry shape is untouched), priority dispatch for raw routes, throw→500 conversion, and rawRoutes.clear() on stopWebhookServer().

Why — today every non-Chat-SDK webhook (GitHub PR events, payment providers, health checks) requires either editing webhook-server.ts or standing up a second HTTP server on another port. With the registry, a module self-registers its endpoint as an append — the same make-it-an-append rationale as #2733's routingPath for second adapter instances.

How it worksregisterWebhookHandler stores the handler keyed by path segment and lazily starts the shared server, mirroring registerWebhookAdapter. The dispatch loop checks rawRoutes first (the handler owns the response directly), then falls through to the Chat SDK lookup unchanged. The existing try/catch covers both paths; a headersSent guard prevents a double writeHead when a handler throws after writing.

How it was tested — new guard test src/webhook-server.test.ts drives the real server over HTTP on an ephemeral WEBHOOK_PORT: registered raw route dispatches, unregistered path 404s, throwing handler yields 500, raw routes coexist with a Chat SDK adapter route on the same server, and stopWebhookServer clears the registry. Full suites green: 354 host vitest, container bun tests unaffected (no container changes); build, typecheck, and lint at baseline.

🤖 Generated with Claude Code

…me an append

Add a RawWebhookHandler registry alongside the Chat SDK adapter routes
so modules can mount plain Node handlers at /webhook/{path} on the
shared server instead of editing webhook-server.ts or standing up a
second HTTP server on another port. Raw routes dispatch ahead of
adapter routes, handler throws surface as a 500, and stopWebhookServer
clears the registry.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@gavrielc
gavrielc requested a review from gabi-simons as a code owner June 11, 2026 10:59
@github-actions github-actions Bot added the follows-guidelines PR was created using the current contributing template label Jun 11, 2026
…files

The instance route-split suite (from #2733) keeps src/webhook-server.test.ts;
this branch's raw-route suite moves to src/webhook-server-raw.test.ts —
incompatible lifecycle setups (fixed port + afterEach vs random port +
afterAll) make a single merged file wrong. webhook-server.ts auto-merge
verified: raw routes take dispatch priority, stop clears both maps.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@gavrielc
gavrielc merged commit 4459ab2 into main Jun 11, 2026
1 check passed
technicalpickles pushed a commit to technicalpickles/nanoclaw that referenced this pull request Jul 12, 2026
feat(webhook-server): raw-route registry — non-Chat-SDK webhooks become an append
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

follows-guidelines PR was created using the current contributing template

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant