A signed-in Claude Code is now offered as a provider (claude/…) like Codex and Copilot. Anthropic classifies another agent's system prompt as third-party traffic even over Claude Code's OAuth, so magpie drives the real local claude binary for every generation: the caller's tools are bridged in over MCP (magpie claude-mcp-helper), and tool results resume the same Claude Code turn. Token counting is estimated locally so the OAuth token takes no side path. No model list is compiled in any more. The built-in catalog, preset defaults and Claude Code's alias list are gone; the picker shows the models.dev catalog (refreshed in the background when stale) layered with each vendor's own /models answer, and signed-in accounts fetch theirs at start-up. Whether a model rejects temperature/top_p now comes from models.dev rather than a name prefix. The gateway retries a Chat request on the Responses endpoint when the model is Responses-only, and remembers that. Recent calls keep the first 256 KB of request and response bodies, viewable in the call list. The Usage tab shows subscription allowances (Claude, Codex, Copilot) as the vendors report them.
28 lines
692 B
Go
28 lines
692 B
Go
package gateway
|
|
|
|
import (
|
|
"net/http/httptest"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestCaptureRequestBodyLimit(t *testing.T) {
|
|
body := []byte(strings.Repeat("x", callBodyLimit+17))
|
|
got, truncated := captureRequestBody(body)
|
|
if len(got) != callBodyLimit || !truncated {
|
|
t.Fatalf("captured %d bytes, truncated=%v", len(got), truncated)
|
|
}
|
|
}
|
|
|
|
func TestCaptureResponseWriterPreservesResponse(t *testing.T) {
|
|
r := httptest.NewRecorder()
|
|
w := &captureResponseWriter{ResponseWriter: r}
|
|
_, _ = w.Write([]byte(`{"ok":true}`))
|
|
if got := w.body.text(); got != `{"ok":true}` {
|
|
t.Fatalf("capture = %q", got)
|
|
}
|
|
if got := r.Body.String(); got != `{"ok":true}` {
|
|
t.Fatalf("response = %q", got)
|
|
}
|
|
}
|