Commit graph

202 commits

Author SHA1 Message Date
Alishahryar1
fc3ef0b5cc Migrate legacy env config on startup
Some checks are pending
CI / checks (push) Waiting to run
2026-05-16 21:06:12 -07:00
Alishahryar1
d05446f0b2 Remove Anthropic API key from proxy child env
Some checks are pending
CI / checks (push) Waiting to run
2026-05-16 15:13:05 -07:00
Alishahryar1
e5edffa246 Pass proxy auth token to Telegram CLI sessions 2026-05-16 15:07:45 -07:00
Alishahryar1
247d17160f Revert "Improve provider error diagnostics"
This reverts commit 327b393b05.
2026-05-16 14:49:36 -07:00
Alishahryar1
327b393b05 Improve provider error diagnostics 2026-05-16 14:48:09 -07:00
Alishahryar1
ac2c37f613 Use canonical FCC server log path
Some checks are pending
CI / checks (push) Waiting to run
2026-05-16 11:51:45 -07:00
Alishahryar1
a728994e29 Update default config and workspace paths 2026-05-16 11:36:53 -07:00
Alishahryar1
f389cf415e fix: default logs to logs/ and ignore rotations (issue 427)
- Default LOG_FILE to logs/server.log in settings and admin config
- Create log parent directories in configure_logging
- Gitignore /logs/, /server.*.log; keep server.log for root override
- Add test for nested log path mkdir
2026-05-13 18:01:54 -07:00
Siarhei Krotau
972bc1661c
feat(providers): add Z.ai Coding Plan provider (#440)
Some checks are pending
CI / checks (push) Waiting to run
2026-05-13 12:02:15 -07:00
Rizki Kotet
32e2e4d755
feat(opencode): integrate OpenCode Zen provider and API key support (#426)
Some checks are pending
CI / checks (push) Waiting to run
2026-05-12 08:44:54 -07:00
Alishahryar1
89f7ed6214 fix(cli): resolve claude command before launch 2026-05-11 00:41:51 -07:00
Alishahryar1
25695077c4 fix(cli): exit fcc-server cleanly on interrupt 2026-05-10 22:47:27 -07:00
Alishahryar1
ca2cf6a6c1 fix(cli): terminate launched process trees 2026-05-10 22:44:07 -07:00
Alishahryar1
2637824a3f fix(openai): close async client with supported method 2026-05-10 22:30:23 -07:00
Alishahryar1
41f2bc71a0 feat(providers): retry all upstream 5xx like 429
Some checks are pending
CI / checks (push) Waiting to run
Generalize retryable_upstream_status to HTTP 500-599 plus 429.
Improve execute_with_retry log label with actual status.
Preserve OpenAI InternalServerError 5xx in map_error after overload check.
Unify native stream send: log via _raise_for_status then optional async aclose.
Add _maybe_await_aclose for httpx doubles in tests.
Rename openai compat retry tests to 5xx; parameterize native/limiter/mapping tests.
2026-05-10 19:56:14 -07:00
Alishahryar1
21ff2137ef feat(providers): retry upstream HTTP 503 like 429
Extend execute_with_retry with retryable_upstream_status for 429/503
shared backoff, reactive block, and TRACE provider.retry.scheduled.
Map InternalServerError(503) to APIError with preserved status.
Native transport closes-and-raises on 503 like 429 for clean retries.
Add NIM/OpenAI-compat and rate limiter tests.
2026-05-10 19:28:32 -07:00
Alishahryar1
29e7714337 feat(logging): structured TRACE events and end-to-end request correlation
Add core/trace.py with trace_event, traced_async_stream, and payload snapshots.
Merge TRACE fields into JSON logs; promote claude_session_id, http path/method.
Instrument API, messaging/CLI, and OpenAI-compat/native provider paths.
Harden log sink with enqueue and stdlib intercept re-entrancy guard.
Document behavior in .env.example and README; extend tests.
2026-05-10 18:24:48 -07:00
Nox
1e97dff214
fix: handle disallowed special tokens in tiktoken encoder (#382)
Co-authored-by: Alishahryar1 <alishahryar2@gmail.com>
2026-05-10 17:30:24 -07:00
Alishahryar1
f9fc614563 Allow unauthenticated root probes 2026-05-10 16:03:19 -07:00
Alishahryar1
e386a3c8aa Improve admin UI setup flow 2026-05-10 15:57:56 -07:00
Alishahryar1
8ee72968ed Initial admin impl 2026-05-10 01:21:16 -07:00
Alishahryar1
de8e902899 Add Claude CLI smoke matrices
Some checks are pending
CI / checks (push) Waiting to run
2026-05-09 17:27:23 -07:00
Alishahryar1
07497c7ed8 Add NVIDIA NIM CLI smoke matrix and tool schema aliasing 2026-05-09 14:25:50 -07:00
Alishahryar1
5294661aa4 feat: add Wafer provider 2026-05-08 23:43:16 -07:00
Leung Ka Chun
19e08f2da1
fix(deepseek): accept document blocks and normalize tool_result content (#358)
## What
Fixes the 422 error returned by the proxy when Claude Code v2.1.128+
sends PDF context as Anthropic `document` blocks, plus two related
DeepSeek-only issues uncovered while debugging.

Closes #357.

## Why
Claude Code now attaches PDFs/files as `document` content blocks. The
`Message.content` union didn't include that variant, so every follow-up
turn after a PDF read returned `422 Unprocessable Content` from the
proxy itself (before the request ever reached DeepSeek).

## Changes
- `api/models/anthropic.py`: new `ContentBlockDocument`, added to
`Message.content` union.
- `providers/deepseek/request.py`:
- `_strip_unsupported_attachment_blocks` — silently drops
`image`/`document` blocks for DeepSeek.
- `_serialize_tool_result_content` + `_normalize_tool_result_content` —
coerces `tool_result.content` to a string per DeepSeek's API contract.
- Hooked into `build_request_body` (strip before validation, normalize
before send).
- `tests/providers/test_deepseek.py`: +4 tests, 1 legacy test updated.

## Verification
- `uv run ruff format` 
- `uv run ruff check` 
- `uv run ty check` 
- `uv run pytest`  (1194 passed)
- Manual: `claude-deepseek` against a PDF no longer 422s.

## Scope / non-goals
- No README change (per CONTRIBUTING).
- Image/document blocks for DeepSeek are stripped, not converted to text
— Claude Code already ships the extracted text in the paired
tool_result.
- No changes to other providers.

---------

Co-authored-by: Alishahryar1 <alishahryar2@gmail.com>
2026-05-05 21:36:38 -07:00
Alishahryar1
d3a3b37e9e Filter OpenRouter model variants by thinking support
Some checks failed
CI / checks (push) Has been cancelled
2026-04-30 22:01:36 -07:00
Alishahryar1
db3c9521b1 Add no-thinking model picker variants
Some checks are pending
CI / checks (push) Waiting to run
2026-04-30 21:27:23 -07:00
Alishahryar1
72b34ad57c Added claude-code native model picker 2026-04-30 20:34:35 -07:00
Alishahryar1
847916b1d3 fixed deepseek issue 2026-04-30 15:15:36 -07:00
Alishahryar1
d9040ce901 Report startup validation failures without tracebacks 2026-04-30 00:43:43 -07:00
Alishahryar1
85232a3ccb Log startup model validation failures clearly 2026-04-30 00:37:32 -07:00
Alishahryar1
eb5516e53b Validate configured models at startup 2026-04-30 00:33:45 -07:00
Alishahryar1
abae61d85b Fix null usage in SSE for OpenAI-compatible streams (#209, #123)
- Only use provider completion_tokens when it is an int; otherwise estimate
- Coerce message_start/message_delta usage fields to safe integers in SSEBuilder
- Add regression tests for null upstream completion_tokens and builder edge cases

Claude Code could crash (e.g. undefined access on usage) when NIM/GLM or
similar sent usage with null token fields in streamed message_delta.
2026-04-27 18:20:33 -07:00
Alishahryar1
0cca5699cb fix(messaging): reuse parent CLI session for Telegram reply continuation (#233)
Pass parent_session_id into get_or_create_session so reply nodes align with
the fork/resume path instead of always allocating a fresh pending session.
Add unit coverage and update integration expectations.
2026-04-27 16:24:31 -07:00
Alishahryar1
f96f541c0a fix(smoke): accept reasoning-only streams and add text placeholder
- OpenAI-compat: emit minimal text block when only reasoning_content streams
  (e.g. NIM) so clients get a text segment.
- Provider prereq: pass if text or thinking content is non-empty after strip.
- Add unit test for reasoning-only stream placeholder text.
2026-04-26 12:55:18 -07:00
Alishahryar1
36d236b563 fix(206): defer post-tool assistant content for OpenAI chat conversion
- Make AnthropicToOpenAIConverter stateful: assistant text after tool_use is
  deferred until matching tool_result, then replayed as a follow-up assistant
  turn.
- After native streamed tool_use, emit top-level SSE error on transport
  failure instead of assistant text_delta (avoids bad transcript shape).
- Add NIM preflight, streaming, converter, and product smoke regressions.
2026-04-26 12:43:25 -07:00
Alishahryar1
6297b48f81 feat(deepseek): use native Anthropic Messages transport
- Point DeepSeek at api.deepseek.com/anthropic with x-api-key headers
- Native request builder, DeepSeek-specific thinking/block sanitization
- Drop deepseek from OpenAI-chat server-tool preflight; update tests and docs
- Default smoke model deepseek-v4-pro; re-export dump_raw_messages_request
2026-04-26 12:03:21 -07:00
Alishahryar1
2d2bf3de70 fix: replay reasoning_content for DeepSeek/NIM and expand provider smoke
Some checks are pending
CI / checks (push) Waiting to run
- Add ReasoningReplayMode and top-level reasoning replay in OpenAI conversion
- DeepSeek/NIM request bodies use reasoning_content when thinking is enabled
- NIM retries without reasoning_content on 400 from upstream
- Per-provider smoke models (FCC_SMOKE_MODEL_*) independent of MODEL mapping
- Fix smoke model override parsing for owner/model names with slashes
- Live smoke: reasoning tool continuation uses synthetic thinking+tool history
- Tests and docs updated
2026-04-26 11:02:18 -07:00
Alishahryar1
f3a7528d49 Major refactor: API, providers, messaging, and Anthropic protocol
Some checks are pending
CI / checks (push) Waiting to run
Consolidates the incremental refactor work into a single change set: modular web tools (api/web_tools), native Anthropic request building and SSE block policy, OpenAI conversion and error handling, provider transports and rate limiting, messaging handler and tree queue, safe logging, smoke tests, and broad test coverage.
2026-04-26 03:01:14 -07:00
Wang Ji
b525217633
[feat] ollama method support (#129)
Support use ollama method like LM stuio

---------

Co-authored-by: Alishahryar1 <alishahryar2@gmail.com>
Co-authored-by: u011436427 <u011436427@noreply.gitcode.com>
2026-04-25 22:06:36 -07:00
Alishahryar1
7f1e860c7f Use root env example for fcc init 2026-04-25 20:59:44 -07:00
Alishahryar1
f29e693dc5 Add per-model thinking toggles 2026-04-25 20:51:07 -07:00
Alishahryar1
40951c145a refactor: drop legacy title-generation detection copy
Some checks are pending
CI / checks (push) Waiting to run
Remove new-conversation-topic heuristic; keep sentence-case and JSON session
title patterns. Update unit and smoke E2E payloads accordingly.
2026-04-25 00:45:22 -07:00
Alishahryar1
080ebefc7b fix: detect Claude Code 2.1+ session title requests for optimization skip
Expand is_title_generation_request to match sentence-case/JSON title prompts
in addition to legacy new-conversation-topic copy. Add unit test for the
current session-title system text shape.
2026-04-25 00:44:25 -07:00
Alishahryar1
b926f60f64 feat: Anthropic web server tools, provider metadata, messaging hardening
- Add local web_search/web_fetch SSE handling and optional tool schemas
- Extend HeuristicToolParser for JSON-style WebFetch/WebSearch text
- Consolidate provider defaults, ids, and exception typing; stream contracts
- Messaging: typed options, voice config injection, platform contract cleanup
- Tests for web server tools, converters, parsers, contracts; ignore debug-*.log
2026-04-24 23:01:14 -07:00
Alishahryar1
0e3b2c24b4 refactor: remove OpenRouter rollback, shims, and redundant layers
- OpenRouter: native Anthropic only; remove chat_request and OPENROUTER_TRANSPORT
- Drop OpenAICompatibleProvider alias, api.request_utils, voice_pipeline facade
- Simplify OpenRouter SSE, generic reasoning in conversion, messaging dispatch
- Shared markdown table helpers; API optimization response helper; contract guards
- Restore PLAN.md; update docs and tests
2026-04-24 21:08:38 -07:00
Alishahryar1
26b8a29537 Architecture refactor: core anthropic, runtime, smoke tiers, remove providers.common 2026-04-24 20:03:14 -07:00
Alishahryar1
66ef23072c Refactor provider routing and smoke coverage 2026-04-24 19:34:34 -07:00
Alishahryar1
efa9f36c3a Revert "Refactor native Anthropic messages providers (#147)"
Some checks are pending
CI / checks (push) Waiting to run
This reverts commit ffa8237220.
2026-04-24 17:27:26 -07:00
Ali Khokhar
ffa8237220
Refactor native Anthropic messages providers (#147)
## Summary
- add a shared `AnthropicMessagesProvider` for native Anthropic
`/messages` providers
- migrate OpenRouter, LM Studio, and llama.cpp onto the shared
transport/streaming base
- preserve provider-specific stream chunking, request headers, thinking
filtering, and error shapes

## Verification
- `uv run ruff format`
- `uv run ruff check`
- `uv run ty check`
- `uv run pytest` (902 passed)
2026-04-24 17:25:49 -07:00