feat(webhook-server): raw-route registry — non-Chat-SDK webhooks become an append - #2739
Merged
Conversation
…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>
…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>
This was referenced Jun 12, 2026
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
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.
Type of Change
.claude/skills/<name>/, no source changes)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 exportedRawWebhookHandlertype, a secondrawRoutesmap (theWebhookEntryshape is untouched), priority dispatch for raw routes, throw→500 conversion, andrawRoutes.clear()onstopWebhookServer().Why — today every non-Chat-SDK webhook (GitHub PR events, payment providers, health checks) requires either editing
webhook-server.tsor 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'sroutingPathfor second adapter instances.How it works —
registerWebhookHandlerstores the handler keyed by path segment and lazily starts the shared server, mirroringregisterWebhookAdapter. The dispatch loop checksrawRoutesfirst (the handler owns the response directly), then falls through to the Chat SDK lookup unchanged. The existing try/catch covers both paths; aheadersSentguard prevents a doublewriteHeadwhen a handler throws after writing.How it was tested — new guard test
src/webhook-server.test.tsdrives the real server over HTTP on an ephemeralWEBHOOK_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, andstopWebhookServerclears 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