Skip to content

feat(api): multi-key auth, free-limit proxy fallback, web_search grounding, Interactions API - #12

Merged
samson910022 merged 3 commits into
mainfrom
feat/phased-multikey-websearch-fallback-interactions
Sep 9, 2026
Merged

samson910022 merged 3 commits into
mainfrom
feat/phased-multikey-websearch-fallback-interactions

Conversation

@samson910022

Copy link
Copy Markdown
Owner

Summary

Phased implementation (P1–P5), each phase reviewed by subagents with fix→review loops until PASS, plus a final 3-agent comprehensive review (GO).

  • P1: external multi-client keys (API_KEYS/OPENCODE_API_KEYS merge, timingSafeEqual, Bearer/x-api-key OR, empty falls back to no-auth)
  • P2: websearch allowlist alias normalization (web_fetch↔webfetch), messages request-level narrowing parity
  • P3: lazy fallback proxy pool (socks5-first, failover-rr, cooldown, loopback bypass) engaged only on 429 FreeUsageLimitError/GoUsageLimitError; stream paths degrade to poll; details/metrics exposure
  • P4: /v1/responses tools:[{type:web_search}] drives opencode websearch, returns web_search_call + url_citation (honest indices only)
  • P5: POST /v1beta|/v1/interactions thin layer (text + google_search grounding, previous_interaction_id, store flag, SSE contract)
  • chat/messages reject hosted web_search with 400 + pointer to responses/interactions
  • engines: node >=22.19 (undici 8 floor)

Verification

  • npm run typecheck clean
  • npm run build clean
  • npm test -- --runInBand: 13 suites / 244 tests green (was 7/191)
  • six-way config matrix updated (index.ts, proxy-config.ts, .env.example, config.json.example, Dockerfile, compose, docs + AGENTS table)
  • no secrets in diff; wire shapes preserved; AGENTS §9 no-touch list respected

Docs

  • docs/api-reference.md: web_search grounding + Interactions sections
  • docs/configuration.md: API_KEYS row, fallback-proxy section (two-hop model), allowlist guidance

…nding, Interactions API

- P1: external multi-client keys (API_KEYS/OPENCODE_API_KEYS merge,
  timingSafeEqual, Bearer/x-api-key OR, empty falls back to no-auth)
- P2: websearch allowlist alias normalization (web_fetch<->webfetch),
  messages request-level narrowing parity
- P3: lazy fallback proxy pool (socks5-first, failover-rr, cooldown,
  loopback bypass) engaged only on 429 FreeUsageLimitError/GoUsageLimitError;
  stream paths degrade to poll; details/metrics exposure
- P4: /v1/responses tools:[{type:web_search}] drives opencode websearch,
  returns web_search_call + url_citation (honest indices only)
- P5: POST /v1beta|/v1/interactions thin layer (text + google_search
  grounding, previous_interaction_id, store flag, SSE contract)
- chat/messages reject hosted web_search with 400 + pointer
- engines: node >=22.19 (undici 8 floor)

typecheck + build clean; 13 suites / 244 tests green
- remove unread apiKeyId dead code, use isAuthorized verifier
- shared isHostedSearchType (exact + versioned prefix), messages guard
  reuses it (covers google_search on /v1/messages)
- normalize strategy/cooldown at config build time (truthful config+log)
- document failover-rr/round-robin alias + store:false non-ephemerality
- responses mixed-request toolMode metadata includes websearch
- chat stream catch assigns collected unconditionally
- tests: normalizers, versioned types, google_search 400
CI pinned Node 20 but undici 8 requires >=22.19, crashing every suite
at import time (webidl.util.markAsUncloneable). Bump CI to Node 24
and load undici lazily so direct-only deployments never pay for or
depend on the proxy runtime: load failure fails open to direct.
@samson910022
samson910022 merged commit 4391e16 into main Sep 9, 2026
3 checks passed
@samson910022
samson910022 deleted the feat/phased-multikey-websearch-fallback-interactions branch September 10, 2026 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant