Commit Graph

14 Commits

Author SHA1 Message Date
huangzhenpc
a6e11c6d22 fix: drop --- SYSTEM PROMPT --- wrapper in Claude path to avoid Kiro injection detection
Some checks failed
Build Docker Image / build (push) Has been cancelled
Kiro's upstream model is trained to identify and resist
--- SYSTEM PROMPT --- marker blocks as injection attempts, causing it
to actively reject the user's system prompt and self-correct its
identity. Switch the Claude path to the same plain-prepend approach
already used by the OpenAI path: system content is joined directly
before the user message without any marker, matching natural context.

The sanitizer (reSysPromptBlock) still strips the old marker format
from conversation history until existing contamination clears out.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-12 11:41:44 +08:00
huangzhenpc
c87517c0bf feat: sanitize injection blocks from conversation history before forwarding upstream
Some checks failed
Build Docker Image / build (push) Has been cancelled
When the proxy's own --- SYSTEM PROMPT --- wrapper or Claude Code's
<system-reminder> blocks appear in conversation history (e.g. echoed
back by Kiro and included in the next request), strip them from user
and assistant message content before building the Kiro payload.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-12 10:58:19 +08:00
huangzhenpc
de4524ad19 Merge upstream Quorinex/Kiro-Go v1.0.6 with local features preserved
Some checks failed
Build Docker Image / build (push) Has been cancelled
Brought in 9 upstream commits:
- 221348b thinking routing: ClaudeRequest.Thinking + Signature + includeEmptyThinkingBlock
- 0203357 + 31aa6aa accurate input_tokens via contextUsageEvent
- 404e242 + 50f1a7e outbound proxy (socks5/http) + UI
- 940dc78 version bump to 1.0.6
- 3 CI workflow changes

Strategy: took upstream base for the 4 conflicting files, then re-applied
our local changes on top:
- config.go: InvalidModelRetries field + GetInvalidModelRetries/UpdateInvalidModelRetries
- kiro.go: AmazonQ origin CLI->AI_EDITOR, attempt-level retry loop for
  INVALID_MODEL_ID, detailed log.Printf (account/model/attempt/elapsed),
  log import; adopted upstream's kiroHttpStore atomic pointer for Do()
- handler.go: /admin/api/general GET/POST + apiGetGeneralConfig +
  apiUpdateGeneralConfig
- web/index.html: General Settings card (invalid-model-retries),
  CN/EN i18n, loadGeneralConfig/saveGeneralConfig, call from initSettings

Build + full test suite green on Go 1.24.3.
2026-05-12 00:09:33 +08:00
Henry Yang
221348b975 fix: support Claude thinking config routing (#40) 2026-05-11 21:01:54 +08:00
huangzhenpc
6d1d1c68a9 fix(translator): prevent silent model downgrade with boundary-aware matching
- Add missing claude-sonnet-4-7/4.7 and claude-haiku-4-7/4.7 mappings;
  previously claude-sonnet-4.7 was substring-matched by the bare
  "claude-sonnet-4" key and silently downgraded to claude-sonnet-4.
- Introduce modelMapping.boundary flag and modelKeyMatches() helper.
  Bare digit-ending keys (like claude-sonnet-4) now require the next
  character to NOT be a digit, dot, or dash-digit, so future versions
  (4.8, 5.x) also pass through without silent downgrade.
- Add 8 regression tests in TestParseModelAndThinkingNoSilentDowngrade
  covering the 4.7 family, hypothetical 4.8, Bedrock-style names, and
  thinking-suffix variants.
2026-05-11 19:16:05 +08:00
Quorinex
f853d0544b Merge branch 'dev' (#32)
* chore: optimize model handling

* chore: update version metadata

---------

Co-authored-by: Quorinex <quorinex@users.noreply.github.com>
2026-05-10 21:16:36 +08:00
Quorinex
a24529d783 chore: sync dev branch proxy and workflow updates 2026-05-10 18:57:40 +08:00
luka7620
a063efd494 v1.1 适配opus4.7调用 2026-05-10 12:53:00 +08:00
Quorinex
d71bf09dde chore: bump version to 1.0.3 and refactor model mapping 2026-02-23 21:46:42 +08:00
edxeth
6151888df5 fix: stabilize thinking streams, multimodal parsing, and token accounting (#20)
* fix: stabilize multimodal image compatibility across OpenCode flows

Advertise vision-capable metadata in /v1/models and make model matching deterministic so OpenCode does not downgrade image support or route 4.6 models incorrectly. Expand request translation to accept OpenCode/OpenAI attachment shapes, sanitize [Image N] placeholders safely, keep image-only follow-up turns non-empty, and improve token accounting so base64 image bytes no longer inflate prompt token usage and trigger premature compaction.

* fix: deduplicate thinking streams and trim injected prompt noise

* fix: align /v1/messages thinking blocks and message_start usage

* fix: reduce repetitive thinking across tool turns

Select a single reasoning stream source, prevent chunk replay, and preserve structured tool-loop context so the model keeps continuity instead of re-planning each turn.

* fix: unify token counting on existing API endpoints

Compute usage deterministically on /v1/messages and /v1/chat/completions even when upstream omits tokenUsage.

- remove roo-only token path and keep behavior on existing endpoints
- add proxy/token_estimator.go with shared Claude/OpenAI estimators (input/system/messages/tools + output/thinking/tool calls)
- wire stream/non-stream handlers to use estimator-derived input/output usage
- update /v1/messages/count_tokens to reuse the same estimator
- keep robust upstream usage parsing/normalization in proxy/kiro.go while dropping parser-level estimate fallback

Why: direct upstream tests show metering/context events frequently arrive without tokenUsage in this environment; this made usage zero or inconsistent. Local deterministic accounting keeps reported usage stable and explicit.
2026-02-23 20:33:53 +08:00
edxeth
f4049948f1 feat: add Claude Sonnet 4.6 and Opus 4.6 to model list and mapping (#18)
- Add claude-sonnet-4.6 (dot and dash variants) to modelMap in translator.go
- Add claude-sonnet-4.6 and claude-opus-4.6 (plus -thinking variants) to the
  static fallback model list in handler.go
- Realign existing opus-4.6 entries for consistency
2026-02-21 14:33:41 +08:00
Quorinex
306f49f9ac fix: add usage field to OpenAI streaming response final chunk (#10) 2026-02-10 09:42:31 +08:00
Quorinex
01e9d0577c feat: add thinking mode support with configurable output formats 2026-02-04 17:42:30 +08:00
Quorinex
c5e6d42163 feat: Kiro API Proxy - OpenAI/Anthropic compatible API service
- Multi-account pool with round-robin load balancing
- Auto token refresh for IAM IdC and Social auth
- Streaming support (SSE)
- Web admin panel with account management
- Docker support with GitHub Actions CI/CD
- Machine ID management per account
- Usage tracking (requests, tokens, credits)
2026-02-04 00:37:05 +08:00