feat(adapter): add amp adapter (selective passthrough)#493
Open
rynfar wants to merge 16 commits into
Open
Conversation
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
@sourcegraph/amp)./api/provider/anthropic/*(Claude inference via Claude Max), forward every other Amp endpoint toAMP_UPSTREAM_URL(defaulthttps://ampcode.com). Threads sync, attachments, telemetry, login, usage, code review, skills, MCP, permissions all keep working — entire Amp app remains usable.ampForwardermodule handles HTTP and SSE streaming with proper Content-Encoding handling so Bun-fetch's auto-decoded responses don't trigger client-side ZlibError./api/provider/anthropic/) or anyx-amp-*header.create_file,edit_file,bash) for file-change extraction.ampCLI (v0.0.1778130306-g2889d9): inference round-trips through Claude Max, free-tier user bypasses Sourcegraph's 402 paywall onamp -x.Setup
(
AMP_API_KEYis needed because Amp keys credentials by URL — the stored key is forhttps://ampcode.com, not the local URL.)Configuration
AMP_UPSTREAM_URLhttps://ampcode.comMERIDIAN_AMP_FORWARD_DISABLEDTest plan
src/__tests__/amp-adapter.test.ts(33 tests),src/__tests__/amp-forwarder.test.ts(10 tests)src/__tests__/adapter-detection.test.ts(7 new cases)src/__tests__/amp-integration.test.ts(9 tests)npm test— 1791 passing, 0 failingnpm run build— cleanampCLI on port 3458:Notable bug found and fixed during verification
amp threads listinitially failed withZlibError. Bun's nativefetch()transparently decodes gzipped response bodies but preserves the originalContent-Encoding: gzipheader. Forwarding that header verbatim made Amp's client try to gunzip an already-decoded body. Fix: stripContent-EncodingandContent-Lengthfrom forwarded responses (commit 510c28a). Regression test included.Spec & plan
docs/superpowers/specs/2026-05-06-amp-adapter-design.mddocs/superpowers/plans/2026-05-06-amp-adapter.md