Commit Graph

31 Commits

Author SHA1 Message Date
Arvin Xu 119c09ab39 ♻️ refactor(mecha): decide the model parameters of an LLM call in the shared core (#19586)
* ♻️ refactor(mecha): decide the model parameters of an LLM call in the shared core

Move the model-parameter rules out of the server's per-attempt hints into
`@lobechat/mecha` as `resolveModelParams(request, providers)`: which extend
params the model consumes (user row → provider card → canonical card),
where the reasoning effort comes from (topic pin, only for the pinned
model and, in a group topic, the answering agent → model-instance config →
sub-agent override), when assistant reasoning must be replayed (Kimi,
DeepSeek thinking, Meta, card support, provider fallback), the capability
defaults the context may assume, the history window, and the stream flag.

The server adapter now only supplies lookups (`createServerModelParamsProviders`)
and the run's frozen snapshots. `stream` falls back to the agent's
`chatConfig.enableStreaming` when the operation did not pin one; the
DeepSeek model-id predicates move to a dependency-free module so the shared
package can import them without the model bank.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* 🐛 fix(server): trace the streaming mode the request really uses

The chat span recorded `ctx.stream ?? true` while the payload now honours
the agent's chat config, so a newly non-streaming request was labelled as
streaming in telemetry. The built context rides along on the LLM trace
input and both the payload and the span read the same resolved value.
Also point the add-model-provider integration map at the shared
resolver as the policy owner.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-15 21:39:34 +08:00
Innei f6ba7c15c6 ⚡️ perf(model-bank): keep the aiModels catalog off the boot path (#19291)
* ⚡️ perf(model-bank): keep the aiModels catalog off the boot path

The model-bank root barrel re-exports the whole aiModels catalog (1.4 MB
raw), and a handful of value imports on the boot path (search config,
reasoning params, image/video defaults, provider enum) dragged it into the
first screen. Boot-path and route code now import the subpaths, the package
declares sideEffects: false and exposes ./utils and ./knowledgeCutoff, and an
eslint rule forbids value imports of the root barrel across src.

Also reach @lobechat/model-runtime/errors/specs and
@lobechat/utils/client/apiKeyManager directly so services/chat stops pulling
the error pattern tables and dompurify.

Web production build: first-screen gzip 2299 KB -> 2154 KB.

Claude-Session: https://claude.ai/code/session_01QKr8CsFLYmrgqbRTSipTNH

* 🐛 fix(lint): carry the model-bank ban through every scoped override

Flat config replaces no-restricted-imports per file instead of merging, so a
separate src/** block was dropped by the boot-path and feature overrides.
The ban now lives in performanceRestrictedImportPaths, which every
createRestrictedImportRule call includes; tests keep the base restrictions
only.

Claude-Session: https://claude.ai/code/session_01QKr8CsFLYmrgqbRTSipTNH

* ✅ test(upload): assert rejected store actions without act()

Wrapping a rejecting store action in act() and asserting with rejects let
the callback run again after the spies were restored, which sent a real
checkFileHash request and surfaced as an unhandled rejection in the shard.
Store actions do not render, so the assertion awaits them directly.

Claude-Session: https://claude.ai/code/session_01QKr8CsFLYmrgqbRTSipTNH
2026-09-09 02:33:59 +08:00
YuTengjing b6a8fcf0dc 🐛 fix: filter failed assistant placeholders and harden Claude prefill guard (#17737) 2026-07-30 21:31:10 +08:00
Innei 93213a51fb ⚡️ perf: make SPA startup demand-aware (#17577)
* ⚡️ perf(vite): make route chunk warmup demand-aware

* ⚡️ perf(spa): preload routes through shared lazy loaders

* ⬆️ chore(deps): align UI editor and Shiki versions

* ⚡️ perf(pwa): cache lazy code on demand

* ⚡️ perf(spa): reduce initial JavaScript dependency closure

* ⚡️ perf(desktop): simplify renderer startup

* ⚡️ perf: refine imperative modal loading boundaries

* 🐛 fix(ci): restore production SPA startup

* ♻️ refactor: share deferred PWA cache rules

* 🐛 fix(ci): execute SPA copy entry with Node
2026-07-29 15:00:26 +08:00
Arvin Xu 20238b7b02 ⬆️ refactor: upgrade Zod to v4 (#16998)
* ⬆️ chore: upgrade Zod to v4

* ⬆️ chore: align drizzle-zod with Zod 4

* 🧰 chore(agent-testing): make verify runs lifecycle-safe

* ✅ test: align Zod 4 validation expectations

* ✅ test: use a valid tracing UUID
2026-07-11 15:09:20 +08:00
YuTengjing be0255b746 🔨 chore: update dependency baseline (#16465)
* 🔨 chore: update dependency baseline

* 🔨 chore(cli): update dependency baseline

* 🔨 chore(desktop): update dependency baseline

* 🔨 chore: fix dependency baseline blockers

* 🔨 chore: update TypeScript and Next baseline
2026-06-30 23:18:08 +08:00
Arvin Xu 88a7e82ab8 ⬆️ fix(model-runtime): upgrade openai SDK to v6 to drop node-fetch@2 (#16090)
OpenAI SDK v4 bundles node-fetch@2, whose gzip response-stream handling
breaks under the Node.js June 2026 security release and throws
ERR_STREAM_PREMATURE_CLOSE (surfaced as "LLM stream error: Premature
close" across all providers). SDK v6 uses native fetch, removing the
node-fetch@2 dependency from the LLM call path.

Migration touch-ups for v6's type changes:
- narrow `apiKey` back to `string` (v6 widened it to `string | ApiKeySetter`)
- access `.function` via the function-tool variant (`ChatCompletionTool` /
  `ChatCompletionMessageToolCall` are now function|custom unions)
- pass real `Headers` instead of plain objects to `APIError` in tests
  (v6 calls `headers.get()`)

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-20 15:57:56 +08:00
sxjeru 77dbe4b7b3 🔨 chore(google): Support External URL file input with SSRF validation to optimize transmission (#12657)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: yutengjing <ytj2713151713@gmail.com>
2026-06-09 16:13:54 +08:00
YuTengjing 0911c2a94c ♻️ refactor: load models through model bank slot (#14877)
* ♻️ refactor: load models through model bank slot

* ♻️ refactor: remove static LobeHub model cards

* ♻️ refactor: share OpenAI image parameters

* 🐛 fix: load async LobeHub model config in server paths

* 🐛 fix: repair model bank CI follow-ups

* 🐛 fix: avoid repeated model bank fallback loads

* 🐛 fix: resolve business model config import in browser

* 🐛 fix: align Nano Banana 2 resolution default

* ♻️ refactor: move model loader slot under client

* ✅ test: move model bank aiModels spec out of build entries

* 🐛 fix: use business model config for mixed provider parsing

* ♻️ refactor: consolidate model bank provider utilities

* 🐛 fix: preserve Nano Banana 2 raw resolution

* 🐛 fix: avoid generated locale sync for raw resolution

* 🌐 style: add Nano Banana 2 resolution locales

* 🌐 style: add online LobeHub model locales

* 🐛 fix: guard optional model provider loaders

* 🐛 fix: prevent sitemap build from hanging

* 🐛 fix: clear sitemap timeout after model load
2026-05-21 10:35:14 +08:00
Arvin Xu ba6980ffe9 🐛 fix(minimax): derive max_tokens from context window to avoid ExceededContextWindow (#14814)
* 🐛 fix(minimax): derive max_tokens from context window to avoid ExceededContextWindow

MiniMax API enforces `input_tokens + max_tokens <= context_window`. The
provider was passing the model's full `maxOutput` as `max_tokens`, which
overflowed the context window as soon as a few large tool definitions or
system prompts were attached and made the very first user message fail
with "context window exceeds limit".

Add `resolveSafeMaxTokens` utility that estimates input tokens from the
payload (messages + tools), caps `max_tokens` at
`min(maxOutput, contextWindow - estimatedInput - buffer)`, and throws a
typed `MaxTokensExceededError` when no headroom remains. The MiniMax
provider now wires this into `handlePayload` and surfaces the error as
`ExceededContextWindow` via a `handleError` callback so it short-circuits
before the doomed upstream call.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* 🐛 fix(minimax): estimate max_tokens against sanitized messages

handlePayload strips signed reasoning (and reasoning-without-content)
from assistant messages before sending to MiniMax, but the previous
resolveSafeMaxTokens call was still measuring the original payload.
For chats with long historical reasoning traces this overcounted the
input — capping max_tokens unnecessarily, or even raising
MaxTokensExceededError when the request would actually fit.

Pass the same processedMessages we send so the estimate matches the
wire payload.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-15 14:47:30 +08:00
sxjeru 1c1af17716 ✨ feat: add auto aspect ratio and image search support for Nano Banana 2 (#12537)
* Update sync.yml

* ✨ feat: update aspect ratio defaults to 'auto' for image generation models

* ✨ feat: enhance grounding metadata handling with image search results support

* ✨ feat: filter empty strings from searchQueries in groundingMetadata and update favicon handling in SearchGrounding component

* ✨ feat: add inputToolTokens tracking and update related components for tool usage

* ✨ feat: enhance search grounding with image results and update related components

* ✨ feat: add ImageSearchRef component and related tests for image reference handling

* fix test: rename VertexAIStream to GoogleGenerativeAIStream for consistency in test cases

* Update sync.yml
2026-03-03 19:31:29 +08:00
sxjeru b0a8e0f51c ✨style: add adaptive thinking and effort configuration for Claude Opus 4.6 (#12139)
* feat: add adaptive thinking and effort configuration for Claude Opus 4.6

* fix: update @anthropic-ai/sdk dependency and refine thinking type handling in payload

* fix: enhance payload handling for Claude Opus 4.6

* i18n
2026-02-06 15:54:31 +08:00
YuTengjing 9f1c79e9a7 Tj/refactor/businessify-3 (#10961) 2025-12-25 16:31:56 +08:00
CanisMinor c5fe456aec 🔨 chore: update compoents version (#10957)
chore: update deps
2025-12-25 12:52:31 +08:00
Rdmclin2 8c42a934b3 ✨ feat: mobile native better auth support (#10871)
* feat: mobile native better auth support

* chore: add android assetlinks

* chore: add android assetlinks

* chore: add expo fingerpoint

* chore: add relation

* chore: add android origin hash

* chore: update passkey table

* chore: optimize version

* chore: remove as any

* fix: sql not exits problem

* fix: passkey statement

* fix:  passkey origin null

* chore: remove strict peer dependencies

* fix: test case

* chore: remove local passkey origin
2025-12-23 15:19:42 +08:00
Oriol Rius 542f4d97dd ✨ feat: Add Replicate image provider
Co-authored-by: Claude <noreply@anthropic.com>
2025-12-11 15:43:00 +08:00
Arvin Xu 95f31bc57c ♻️ refactor: unify retry logic to async-retry (#10579)
* ♻️ refactor: unify retry logic to async-retry

- Refactor MCPService.listTools() to use async-retry with exponential backoff
- Refactor asyncifyPolling() to use async-retry internally while maintaining the same API
- Add async-retry as dependency to root package and model-runtime package

🔗 Related: LOBE-1370

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* ✅ test: update MCPService.listTools tests for async-retry

- Update test expectation: throw original error when retries exceeded
- Remove skipCache parameter test (now handled internally by async-retry)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-03 19:14:40 +08:00
renovate[bot] 8da7cc4418 Update all non-major dependencies (#10372)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-11-30 19:39:26 +08:00
renovate[bot] b76e3c85b9 Update all non-major dependencies (#10177)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-11-17 09:56:56 +08:00
jjangga0214 7571b66284 👷 build(deps): missing deps for model-runtime (#9782) 2025-10-21 00:26:23 +08:00
YuTengjing 49ea508cc4 🔨 chore: support chat api and create image cost caculate (#9492) 2025-09-30 21:09:56 +08:00
Arvin Xu d9a4361994 ♻️ refactor: move the ModelProvider to model-bank (#9374)
* move the ModelProvider to model-bank

* fix tests

* fix deps

* clean deps
2025-09-22 19:23:26 +08:00
YuTengjing 1762dc9148 ♻️ chore: refactor router runtime (#9306) 2025-09-17 23:30:04 +08:00
Arvin Xu 58f1a52eb9 🔨 chore(model-runtime): improve export type (#9213)
* improve exports

* improve provider
2025-09-11 13:13:04 +08:00
Arvin Xu 7fe17e4028 ♻️ refactor: refactor model runtime folder structure and add more tests (#9210)
* add test

* fix tests

* fix tests

* revert tests

* refactor model runtime folder

* refactor model runtime folder and remove @/libs/model-runtime

* fix lint

* move

* fix tests
2025-09-11 11:22:05 +08:00
Arvin Xu f813d0c429 ✅ test: add model runtime tests (#9128)
* fix

* refactor to remove model runtime alias in tests
2025-09-06 14:57:14 +08:00
Arvin Xu 9f7677d560 ♻️ refactor(model-runtime): refactor model-runtime dependencies and clean code (#8997)
* refactor and clean code

* refactor to remove circular deps

* refactor to clean code

* refactor to clean code

* refactor model-runtime

* refactor image const

* refactor model-runtime import

* fix lint circular

* refactor the @/lib/model-runtime

* fix tests

* refactor to clean code
2025-08-30 23:52:42 +08:00
Arvin Xu c65eb095ba ♻️ refactor: refactor the model-bank package from src/config/aiModels (#8983)
* move

* refactor with model banks

* refactor with model banks

* refactor @/config/aiModels to model-bank

* refactor @/config/aiModels to model-bank

* fix model bank exports

* clean

* add test workflow

* try again

* fix

* add exports tests

* fix model bank alias

* Update tsconfig.json

* fix import issue

* clean unused code

* fix tests
2025-08-30 01:28:16 +08:00
Arvin Xu 8dedc2d3e1 ♻️ refactor: move utils to separate package (#8889)
* move utils

* move utils

* move utils

* update

* update

* update

* update

* update

* refactor to clean the tests

* fix release workflow

* fix tests

* fix tests

* fix tests

* fix tests

* fix tests

* fix tests

* try to fix client db migration issue

* fix tests
2025-08-22 14:05:01 +08:00
Arvin Xu d07e2acae8 🔨 chore: improve test workflow (#8876)
* test workflow

* test workflow

* add test workflow

* add test workflow

* add test config

* add test config

* add test config

* add test config

* add test config

* update

* refactor tests

* fix tests

* fix tests

* exclude packages

* improve test

* fix test

* add a new package
2025-08-21 20:39:29 +08:00
Arvin Xu e5eb7a280d ♻️ refactor: refactor model-runtime to a seperated package (#8763)
* move model-runtime

* refactor import from @/libs/model-runtime to @lobechat/model-runtime

* move deps

* refactor types
2025-08-12 00:08:52 +08:00