Commit Graph
8 Commits
Author SHA1 Message Date
asepharyana 3de32a10f3 fix(translator): shape Anthropic non-stream responses from forced-streaming providers
The non-streaming Anthropic path leaked OpenAI chat.completion bodies to
Claude clients when the upstream provider forces streaming (forced
SSE->JSON path): parseSSEToOpenAIResponse yields choices[] which Claude
Code cannot parse. Convert to Claude Messages shape for sourceFormat
CLAUDE in sseToJsonHandler.

Shared toClaudeMessageShape/openAICompletionToClaudeMessage moved to
translator/concerns/claudeShape.js to avoid circular import between
nonStreamingHandler and sseToJsonHandler. 5 new tests: sse-to-json
reassembly + Claude guard, plus existing anthropic-nonstream-shape
updated to import from the concern.
2026-09-23 15:36:24 +07:00
asepharyana b239b2a8a9 chore: add .planning/ to .gitignore 2026-09-23 15:24:53 +07:00
asepharyana 9fd0fb0181 fix(anthropic): non-stream /v1/messages returned OpenAI shape; strip EOS sentinel from text deltas
BUG: Anthropic client (sourceFormat=CLAUDE) hitting a claude-target provider
got a raw OpenAI chat.completion body on non-streaming requests. The
needsTranslation(CLAUDE,CLAUDE) gate is false when target===source, so the
translator never ran; a claude-transport executor replying OpenAI JSON
(opencode/big-pickle) leaked choices[]/prompt_tokens to the client, which
Anthropic SDKs cannot parse (no content[] blocks, no type:"message").

FIX: shape-aware guard toClaudeMessageShape() in nonStreamingHandler — when
sourceFormat is CLAUDE, convert any OpenAI-shape body to a proper Claude
message (type, content blocks with thinking/text/tool_use, stop_reason via
finish mapping, usage input/output tokens). Claude-shaped bodies pass through.

Also: strip <|im_end|>/<|endoftext|>/<|eot_id|> EOS sentinels from Claude
text deltas in openai-to-claude and kiro-to-claude translators — the upstream
EOS token leaks into the final text_delta (observed 'OK<|im_end|>').

Tests: anthropic-nonstream-shape.test.js (6: eos strip + shape guard incl
tool_calls→tool_use, pass-through, finish mapping). 28/28 related tests green.
2026-09-23 15:24:15 +07:00
asepharyana e0eef05b6b feat(dashboard): show build git SHA in header + profile page
The version label now renders 'v0.5.86 (<shortsha>)' when the flake build
injects NEXT_PUBLIC_GIT_SHA (git commit identity of the deployed artifact),
so any running dashboard traces to its exact source commit. Falls back to
semver-only when the env var is absent (local dev). Also fixes the profile
page repo link back to asepharyana/9router (MIBP merge target), replacing
the mhiqrambg fork label left over from the merge.
2026-09-23 14:45:08 +07:00
asepharyana 3f0d904d1d chore(nix): version the build by git short SHA instead of package.json semver
flake.nix now uses self.shortRev (git HEAD short hash) as the derivation
version, so the store path is /nix/store/<hash>-9router-<shortsha> and any
deployed build traces to its exact source commit. Removes the package.json
version bump churn; the updater's deployed/current comparison switches to
git SHA.
2026-09-23 14:03:08 +07:00
asepharyana 8ae771b561 chore: ignore nix build result symlink 2026-09-23 11:56:19 +07:00
asepharyana 7001bd17ea chore(nix): add flake.nix + bun.lock so 9router builds/deploys from this repo
Migrate the Nix build + deploy source from /home/code/9router-repo (a pure
upstream mirror, now deleted) to this repo, which carries the MIBP fork
merge (freebuff, cline free models, proxy-pool fitness). flake.lock and
flake.nix copied verbatim from 9router-repo; bun.lock generated from the
merged dependency set. The cron updater (9router-update.sh) now points at
/home/code/9router with a keep-ours conflict policy.
2026-09-23 11:51:11 +07:00
asepharyana 2bc9d67d26 merge: pull mhiqrambg/9router-mibp-version into master
Merge the MIBP fork (v1.0.14, synced to decolua v0.5.81) into our master
(0.5.86) at merge-base a8c9d380. Keep HEAD's infra policy (untracked
lockfile, mirror-configurable Dockerfile, decolua GHCR/DockerHub, README)
while absorbing the fork's engine features:

- feat(providers): freebuff provider + executor + OAuth + usage tracking
- feat(providers): cline free-tier models, Freebuff catalog sync
- feat(proxy-pools): pool egress geo probe, proxy-pool fitness + retry
- fix(usage): hide noAuth providers (devin-cli, mimo-free) from usage list
- test(harness): DATA_DIR isolation so tests never write the real DB
- fix(codebuddy-intl): probe token in connection test, OAuth by identity
- chore(guards): durable markers so fixes aren't silently dropped

Resolutions:
- registry/index.js regenerated deterministically (122 providers, alpha
  order). trae/windsurf/devin-cli stay hidden per HEAD security posture
  (no tool-calling / local-agent shell access) — not re-enabled.
- nonStreamingHandler: drop the generic unconditional unwrapDataEnvelope
  call; envelope unwrap stays scoped to clineEnvelope-quirk providers
  (unwrapClineEnvelope), fixing a latent mibp bug where non-opted-in
  providers ({success,data} bodies) were stripped.
- Drop fork-local Docker lockfile policy (package-lock.json, AGENTS.md,
  .npmrc verify scripts): this repo keeps package-lock untracked (nix
  build deploy). .npmrc (audit=false/fund=false) kept.
- Keep gitbook-pages workflow enabled (ours); mibp disabled it.
- Restore 13 upstream tests mibp deleted (they cover features we keep).

Verified: 2841 tests, 2687 pass, fail set byte-identical to HEAD (zero
new regressions); providers/alias/oauth baselines regenerated to merged
code and all green.
2026-09-23 11:44:58 +07:00