An Anthropic OAuth token (sk-ant-oat01…, e.g. CLAUDE_CODE_OAUTH_TOKEN) is not an API key. Sent with an ordinary body, a current model answers 429 rate_limit_error "Error" — the same status and shape as an exhausted quota, so the endpoint looks broken at random instead of misconfigured. `oauth on` per endpoint puts Claude Code's system prompt in place, and only for endpoints that ask for it. The client's own system prompt is kept: on /v1/messages as further blocks after the marker (cache_control intact), on /v1/chat/completions as its own user message before the first turn — there the system content must be the marker alone. Measured against api.anthropic.com, each case repeated: body /v1/messages /v1/chat/completions no system 429 429 system = <marker> 200 200 system = [<marker>, <text>] 200 429 system = [<text>, <marker>] 429 429 The gating is model-dependent: retired names such as claude-haiku-4-5-20251001 answer without the marker and prove nothing. claude-sonnet-5-5, claude-haiku-5-5, claude-opus-5 and claude-opus-4-8 are gated. The marker matches byte for byte — a missing final period or a trailing newline is worth the same as no marker at all. Verified: full suite PASS, 574 OK, 0 failures. Against the live API through junction with a real subscription token: 200 on claude-sonnet-5-5 for /v1/messages (client system prompt applied, answer "Paris") and for /v1/chat/completions; streaming with a tool call works; the same request with `oauth off` still gets 429 upstream, which is the counter-proof that the option is what changes the outcome. Token B in ~/toktok is dead independently of this (403 oauth_not_allowed_for_organization). The stub's new STUB_BODY_FILE writes request bodies verbatim; a structural check (is the marker the first block) cannot be done from a header.
60 lines
2.1 KiB
Makefile
60 lines
2.1 KiB
Makefile
# junction — C99 + POSIX. TLS is optional: an OpenSSL build adds https:// upstreams
|
|
# and a TLS listener; J_WITH_TLS=0 gives a dependency-free binary.
|
|
CC ?= cc
|
|
CFLAGS ?= -std=c99 -O2 -Wall -Wextra -Wpedantic -Wshadow -Wconversion
|
|
# _DEFAULT_SOURCE next to strict POSIX: without it glibc hides SO_REUSEPORT, and an
|
|
# #ifdef around a hidden constant compiles to nothing without a word — the symptom is
|
|
# "Address already in use" instead of two instances on one port.
|
|
CPPFLAGS += -D_POSIX_C_SOURCE=200809L -D_DEFAULT_SOURCE
|
|
CFLAGS += -pthread
|
|
LDFLAGS += -pthread
|
|
LDFLAGS ?=
|
|
PREFIX ?= /usr/local
|
|
J_WITH_TLS ?= auto
|
|
|
|
SRC = src/oauth.c src/mesh.c src/mcp.c src/control.c src/control_ops.c src/compress.c src/price.c src/models.c src/config.c src/conn.c src/http.c src/cache.c src/opencode.c src/effort.c src/judge.c src/review.c src/junction.c
|
|
OBJ = $(SRC:.c=.o)
|
|
TOOLS = tools/junction-wol
|
|
|
|
ifeq ($(J_WITH_TLS),0)
|
|
TLS_LIBS =
|
|
else
|
|
ifeq ($(wildcard /usr/include/openssl/ssl.h),)
|
|
TLS_LIBS =
|
|
else
|
|
CPPFLAGS += -DJ_HAVE_TLS
|
|
TLS_LIBS = -lssl -lcrypto
|
|
endif
|
|
endif
|
|
|
|
all: junction $(TOOLS)
|
|
|
|
tools/junction-wol: tools/junction-wol.c
|
|
$(CC) -std=c99 -O2 -Wall -Wextra -Wpedantic $< -o $@
|
|
|
|
junction: $(OBJ)
|
|
$(CC) $(CFLAGS) $(OBJ) -o $@ $(LDFLAGS) $(TLS_LIBS)
|
|
|
|
src/%.o: src/%.c src/config.h src/conn.h src/http.h src/cache.h src/mcp.h src/control.h
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
|
|
|
|
test: junction
|
|
tests/run.sh
|
|
|
|
install: junction $(TOOLS)
|
|
install -d $(DESTDIR)$(PREFIX)/bin $(DESTDIR)$(PREFIX)/share/junction/hooks
|
|
install -m 0755 junction $(DESTDIR)$(PREFIX)/bin/junction
|
|
install -m 0755 $(TOOLS) $(DESTDIR)$(PREFIX)/bin/junction-wol
|
|
install -m 0755 hooks/*.sh $(DESTDIR)$(PREFIX)/share/junction/hooks/
|
|
install -m 0755 $(TOOLS) $(DESTDIR)$(PREFIX)/share/junction/hooks/
|
|
install -m 0644 config.example $(DESTDIR)$(PREFIX)/share/junction/junction.conf
|
|
install -d $(DESTDIR)$(PREFIX)/share/junction/examples
|
|
install -m 0644 examples/*.conf $(DESTDIR)$(PREFIX)/share/junction/examples/
|
|
install -d $(DESTDIR)$(PREFIX)/share/junction/www
|
|
install -m 0644 src/www/*.html $(DESTDIR)$(PREFIX)/share/junction/www/
|
|
|
|
clean:
|
|
rm -f $(OBJ) junction $(TOOLS)
|
|
|
|
.PHONY: all test install clean
|