Commit Graph

9483 Commits

Author SHA1 Message Date
Arvin Xu
d3ea4a4894 ♻️ refactor: refactor agent-runtime hooks mode (#13145)
*  feat: add Agent Runtime Hooks — external lifecycle hook system

Hooks are registered once and automatically adapt to runtime mode:
- Local: handler functions called directly (in-process)
- Production: webhook configs persisted to Redis, delivered via HTTP/QStash

- HookDispatcher: register, dispatch, serialize hooks per operationId
- AgentHook type: id, type (beforeStep/afterStep/onComplete/onError),
  handler function, optional webhook config
- Integrated into AgentRuntimeService.createOperation + executeStep
- Hooks persisted in AgentState.metadata._hooks for cross-request survival
- Dispatched at both normal completion and error paths
- Non-fatal: hook errors never affect main execution flow

LOBE-6208

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

*  test: add HookDispatcher unit tests (19 tests)

Tests cover:
- register/unregister/hasHooks
- Local mode dispatch: matching types, multiple handlers, error isolation
- Production mode dispatch: webhook delivery, body merging, mode isolation
- Serialization: getSerializedHooks filters webhook-only hooks
- All hook types: beforeStep, afterStep, onComplete, onError

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

*  feat: migrate SubAgent to hooks + add afterStep dispatch + finalState

- AgentHookEvent: added finalState field (local-mode only, stripped from webhooks)
- AgentRuntimeService: dispatch afterStep hooks alongside legacy callbacks
- AiAgentService: createThreadHooks() replaces createThreadMetadataCallbacks()
  for SubAgent Thread execution — same behavior, using hooks API
- HookDispatcher: strip finalState from webhook payloads (too large)

LOBE-6208

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

* 🐛 fix: add Vercel bypass header to QStash hook webhooks

Preserves x-vercel-protection-bypass header when delivering hook
webhooks via QStash, matching existing behavior in
AgentRuntimeService.deliverWebhook and libs/qstash.

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

*  feat: migrate Eval Run to hooks + add finalState to AgentHookEvent

Eval Run now uses hooks API instead of raw completionWebhook:
- executeTrajectory: hook with local handler + webhook fallback
- executeThreadTrajectory: hook with local handler + webhook fallback
- Local mode now works for eval runs (previously production-only)

Also:
- AgentHookEvent: added finalState field (local-only, stripped from webhooks)
  for consumers that need deep state access

LOBE-6208

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

* 🐛 fix: dispatch beforeStep hooks + fix completion event payload fields

P1: Add hookDispatcher.dispatch('beforeStep') alongside legacy
onBeforeStep callback. All 4 hook types now dispatch correctly:
beforeStep, afterStep, onComplete, onError.

P2: Fix completion event payload to use actual AgentState fields
(state.cost.total, state.usage.llm.*, state.messages) instead of
non-existent state.session.* properties. Matches the field access
pattern in triggerCompletionWebhook.

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

* 🐛 fix: update eval test assertions for hooks migration + fix status type

- Test: update executeTrajectory assertion to expect hooks array
  instead of completionWebhook object
- Fix: add fallback for event.status (string | undefined) when passing
  to recordTrajectoryCompletion/recordThreadCompletion (status: string)

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

* 🐛 fix: update SubAgent test assertions for hooks migration

Update execGroupSubAgentTask tests to expect hooks array instead of
stepCallbacks object, matching the SubAgent → hooks migration.

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

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 12:05:25 +08:00
Rylan Cai
6ce9d9a814 🐛 fix: agent stream error in local dev (#13054)
* 🐛 fix: close local agent streams on terminal errors

* ♻️ refactor: revert redundant cli stream error handling

* 🧪 test: remove redundant cli stream error test

* wip: prune tests

* 🐛 fix: guard terminal agent runtime end step index
2026-03-20 11:39:54 +08:00
Neko
f51da14f07 🔧 chore(locales): use "created" for "sent" in "sent x messages" (#13140) 2026-03-20 11:08:13 +08:00
Protocol Zero
bc8debe836 🐛 fix(chat): strip forkedFromIdentifier before LLM API request (#13142)
fix(chat): strip forkedFromIdentifier before LLM API request

Fork & Chat stores forkedFromIdentifier in agent.params for DB lookup.
Spreading params into the chat payload forwarded it to Responses API,
causing strict providers (e.g. AiHubMix) to reject the request.

Remove the field in getChatCompletion alongside existing non-API keys.

Fixes lobehub/lobehub#13071

Made-with: Cursor
2026-03-20 11:07:29 +08:00
Neko
1b909a74d7 🔧 chore(locales): missing category locale for productivity (#13141) 2026-03-20 03:46:23 +08:00
Arvin Xu
04f963d1da ♻️ refactor: use incremental diff for snapshot messages to prevent OOM (#13136)
* ♻️ refactor: use incremental diff for snapshot messages to prevent OOM

Replace full messages/messagesAfter duplication per step with baseline + delta approach:
- Step 0 and compression resets store full messagesBaseline
- Other steps store only messagesDelta (new messages added)
- Strip llm_stream events from snapshot (not useful for post-analysis)
- Strip messages from done.finalState (reconstructible from delta chain)
- Strip duplicate toolResults from context.payload
- Reduce context_engine_result event size by removing messages and toolsConfig
- Add reconstructMessages() utility for rebuilding full state from delta chain
- AiAgentService constructor now accepts runtimeOptions for DI

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

* ♻️ refactor: add incremental toolset delta for snapshot

- Store operationToolSet as toolsetBaseline in step 0 only (immutable)
- Track activatedStepTools changes via per-step activatedStepToolsDelta
- Strip operationToolSet/toolManifestMap/tools/toolSourceMap from done.finalState
- Add reconstructToolsetBaseline() and reconstructActivatedStepTools() utilities

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

* 🐛 fix: correct snapshot delta recording and restore context-engine output

- P1: messagesDelta now always stores only appended messages (afterMessages.slice),
  fixing duplication when isBaseline was true (step 0 / compression reset)
- P2: Restore context_engine_result.output (processedMessages) — needed by
  inspect CLI for --env, --system-role, and -m commands
- Add P1 regression test for message deduplication

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

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 01:01:35 +08:00
YuTengjing
d6f75f3282 feat(model-runtime): add xiaomimimo to RouterRuntime base runtime map (#13137) 2026-03-20 01:01:06 +08:00
YuTengjing
563f4a25f1 💄 style: add XiaomiMiMo LobeHub-hosted model cards and fix pricing (#13133) 2026-03-19 23:51:23 +08:00
Zhijie He
e2d25be729 💄 style: add mimo-v2-pro & mimo-v2-omni support (#13123) 2026-03-19 22:14:20 +08:00
Innei
80cb6c9d11 feat(chat-input): add category-based mention menu (#13109)
*  feat(chat-input): add category-based mention menu with keyboard navigation

Replace flat mention list with a structured category menu (Agents, Members, Topics).
Supports home/category/search views, Fuse.js fuzzy search, floating-ui positioning,
and full keyboard navigation.

* 🔧 chore: update @lobehub/editor to version 4.3.0 and refactor type definition in useMentionCategories

Signed-off-by: Innei <tukon479@gmail.com>

*  feat(MentionMenu): enhance icon rendering logic in MenuItem component

Updated the MenuItem component to improve how icons are rendered. Now, it checks if the icon is a valid React element or a function, ensuring better flexibility in icon usage. This change enhances the overall user experience in the mention menu.

Signed-off-by: Innei <tukon479@gmail.com>

* 🔧 chore: update @lobehub/editor to version 4.3.1 in package.json

Signed-off-by: Innei <tukon479@gmail.com>

---------

Signed-off-by: Innei <tukon479@gmail.com>
2026-03-19 21:48:10 +08:00
YuTengjing
57ec43cd00 🐛 fix(database): add drizzle-zod and zod as peer dependencies to fix type-check errors (#13132) 2026-03-19 21:24:41 +08:00
Innei
0f67a5b8d7 💄 style(desktop): improve WelcomeStep layout centering in onboarding (#13125)
* 💄 style(desktop): improve WelcomeStep layout centering in onboarding

Made-with: Cursor

* 🐛 fix(desktop): validate remote server URL in isRemoteServerConfigured

Made-with: Cursor
2026-03-19 21:18:41 +08:00
Innei
8d387a98a0 🐛 fix(editor): correct empty editor state structure and wide screen layout (#13131)
- Fix EMPTY_EDITOR_STATE with proper Lexical node structure (root id, paragraph id)
- Add flex-grow to WideScreenContainer for proper editor canvas expansion

Made-with: Cursor
2026-03-19 21:07:18 +08:00
YuTengjing
3931aa9f76 🐛 fix(auth): add BusinessAuthProvider slot to auth layout (#13130) 2026-03-19 18:56:45 +08:00
YuTengjing
73d46bb4c4 feat(ci): add Claude PR auto-assign reviewer workflow (#13120) 2026-03-19 16:13:01 +08:00
Innei
f827b870c3 feat(version): display actual desktop app version with canary suffix (#13110)
*  feat(version): display actual desktop app version with canary suffix

Add support for fetching and displaying the desktop application's actual version number in the About section. When running on desktop, the version now displays the desktop app's version (including canary suffix if applicable), falling back to the web version if unavailable.

- Add getAppVersion IPC method in SystemController
- Create versionDisplay utility module with comprehensive tests
- Integrate desktop version fetching in Version component

* ♻️ refactor(desktop): inject about version at build time
v2.2.0-nightly.202603190626
2026-03-19 14:24:03 +08:00
Neko
efd99850df feat(agentDocuments): added agent documents impl, and tools (#13093) 2026-03-19 14:05:02 +08:00
Neko
87c770cda7 🔨 chore: use percentage value for Codecov (#13121)
build: use percentage value
2026-03-19 13:28:48 +08:00
YuTengjing
715481c471 🐛 fix(portal): preserve artifacts code scroll while streaming (#13114) v0.0.0-nightly.pr13110.6936 2026-03-19 00:35:20 +08:00
YuTengjing
25e1a64c1b 💄 style: update Grok 4.20 to 0309 and add MiniMax M2.7 models (#13112) 2026-03-19 00:05:07 +08:00
Innei
465c9699e7 feat(context-engine): inject referenced topic context into last user message (#13104)
*  feat: inject referenced topic context into last user message

When users @refer_topic in chat, inject the referenced topic's summary
or recent messages directly into the context, reducing unnecessary tool calls.

* 🐛 fix: include agentId and groupId in message retrieval for context engineering

Signed-off-by: Innei <tukon479@gmail.com>

*  feat: skip topic reference resolution for messages with existing topic_reference_context

Added logic to prevent double injection of topic references when messages already contain the topic_reference_context. Updated tests to verify the behavior for both cases: when topic references should be resolved and when they should be skipped.

Signed-off-by: Innei <tukon479@gmail.com>

---------

Signed-off-by: Innei <tukon479@gmail.com>
2026-03-18 21:58:41 +08:00
Innei
ac29897d72 ♻️ refactor(perf): user message renderer (#13108)
refactor(perf): user message renderer
2026-03-18 21:58:29 +08:00
YuTengjing
1df5ae32f1 🐛 fix: distinguish SSRF block errors from network errors (#13103) 2026-03-18 18:16:19 +08:00
Innei
8a90f79c11 ♻️ refactor(nav): remove devOnly mode from nav layout and stabilize Footer (#13101)
* ♻️ refactor(nav): remove devOnly mode from nav layout and stabilize Footer during panel transitions

- Remove devOnly filtering from useNavLayout, treat all items as non-dev mode
- Move Pages to top nav position, remove video/image/settings/memory nav items
- Extract Footer from SideBarLayout into NavPanelDraggable outside animation layer
- Show settings ActionIcon in Footer when dev mode is enabled (hidden on settings page)

* 🔧 fix(footer): update settings icon in Footer component

- Replace Settings2 icon with Settings icon in the Footer when dev mode is enabled, ensuring consistency in the user interface.

Signed-off-by: Innei <tukon479@gmail.com>

---------

Signed-off-by: Innei <tukon479@gmail.com>
2026-03-18 15:44:51 +08:00
LobeHub Bot
91ec7b412b 🌐 chore: translate non-English comments to English in ProfileEditor and related features (#13048)
Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-18 15:40:07 +08:00
YuTengjing
e9766be3f3 🐛 fix: pass userId in initModelRuntimeFromDB (#13100) 2026-03-18 15:11:29 +08:00
Rylan Cai
52652866e0 feat: support server context compression (#12976)
* ♻️ refactor: add eval-only server context compression

* ♻️ refactor: align eval compression with runtime step flow

* ♻️ refactor: trim redundant call_llm diff

*  add mid-run context compression step

* 📝 document post compression helper

* 🐛 revert unnecessary agent runtime service diff

* ♻️ refactor: clean up context compression follow-up logic

* ♻️ refactor: move compression gate before call llm

* ♻️ refactor: make call llm compression gate explicit

* ♻️ refactor: restore agent-side compression checks

* ♻️ refactor: rename agent llm continuation helper

* ♻️ refactor: inline agent compression helper

* ♻️ refactor: preserve trailing user message during compression

* 📝 docs: clarify toLLMCall refactor direction

*  test: add coverage for context compression flow

*  reset: unstash
2026-03-18 12:48:34 +08:00
YuTengjing
95ef230354 💄 style: add GPT-5.4 mini and nano models (#13094) 2026-03-18 12:34:31 +08:00
lobehubbot
b894622dfe Merge remote-tracking branch 'origin/main' into canary 2026-03-18 04:29:39 +00:00
Arvin Xu
ae77fee1b8 👷 build: add settings column to agent_bot_providers (#13081) 2026-03-18 12:28:58 +08:00
YuTengjing
7cd4b1942f 💄 style: use credit terminology in auto top-up tooltips (#13091) 2026-03-18 11:12:39 +08:00
Rylan Cai
69c24c714e 🔧 chore(eval): improve trajectory workflow controls and execution metadata (#13049)
* 🔧 chore(search): reduce Exa default result count

* 🐛 fix(eval): relax run input schema limits

*  feat(agent): persist tool execution time in message metadata

* 🔧 chore(eval): add flow control to trajectory workflows

* 🧪 test: adjust Exa numResults expectation
2026-03-18 10:29:49 +08:00
Sirui He
3a789dc612 🐛 fix: SPA HTML entry returns stale content after server upgrade (#12998)
fix: add no-cache header to SPA HTML entry point

Prevent stale SPA HTML from being served after server upgrades.
JS/CSS assets still cache normally via hashed filenames.
2026-03-18 01:27:52 +08:00
Xial
46455cb6c3 🐛 fix: load PDF.js worker from local assets via Vite ?url import (#13006) 2026-03-18 01:26:10 +08:00
YuTengjing
81becc3583 🐛 fix(model-runtime): handle Responses API tool pairing and context limit errors (#13078) 2026-03-18 00:07:10 +08:00
YuTengjing
cb0037ce1e 🐛 fix: pass userId to all embeddings API calls (#13077) 2026-03-17 23:44:34 +08:00
Innei
03f3a2438c 🐛 fix(skills): repair db-migrations frontmatter (#13073) 2026-03-17 23:32:14 +08:00
Innei
4994d19a9c 🐛 fix(desktop): remove electron-liquid-glass to fix click event blocking (#13070)
* 🐛 fix(desktop): remove electron-liquid-glass to fix click event blocking

The electron-liquid-glass native addon was blocking all click events in the
Electron desktop app window. Remove the dependency and restore vibrancy-based
transparency with semi-transparent body background via `.desktop` CSS class.

* 🔨 chore(desktop): remove electron-liquid-glass from native modules config
2026-03-17 22:56:29 +08:00
YuTengjing
f8d51bbf4f 🐛 fix(model-runtime): filter internal thinking content in openai-compatible payloads (#13067) 2026-03-17 22:28:08 +08:00
YuTengjing
189e5d5a20 🐛 fix(model-runtime): prune unsupported xAI reasoning penalties (#13066) 2026-03-17 22:27:59 +08:00
Innei
b2122a5224 ♻️ refactor: replace per-message useNewScreen with centralized useConversationSpacer (#13042)
* ♻️ refactor: replace per-message useNewScreen with centralized useConversationSpacer

Replace the old per-message min-height approach with a single spacer element appended to the virtual list, simplifying scroll-to-top UX when user sends a new message.

* 🔧 refactor: streamline handleSendButton logic and enhance editor focus behavior

Removed redundant editor null check and added double requestAnimationFrame calls to ensure the editor is focused after sending a message.

Signed-off-by: Innei <tukon479@gmail.com>

---------

Signed-off-by: Innei <tukon479@gmail.com>
2026-03-17 21:19:58 +08:00
Innei
d2d9e6034e 🐛 fix(chat): clear input immediately on send to preserve drafts during streaming (#13038)
* 🐛 fix: clear input immediately on send to preserve drafts typed during streaming

Move inputMessage reset before the async streaming lifecycle so text
entered while the assistant is responding is not overwritten on completion.

Also normalize null/undefined in operation context matching so that
cancelOperations works correctly in null-topic sessions.

Fixes LOBE-2647

* 🐛 fix: resolve TS2322 null-vs-undefined type error in useOperationState test
2026-03-17 21:14:40 +08:00
YuTengjing
97f4a370ab feat: add request trigger tracking, embeddings billing hooks, and memory extraction userId fix (#13061) 2026-03-17 20:54:28 +08:00
YuTengjing
62a6c3da1d 🌐 i18n: add pending_reward status translation for referral table (#13065) 2026-03-17 20:08:18 +08:00
YuTengjing
10b7906071 🔨 chore: add device fingerprint utility and pending_reward status (#13062) 2026-03-17 18:49:35 +08:00
YuTengjing
3207d14403 🔨 chore: add batch query methods for UserModel and MessageModel (#13060) 2026-03-17 18:20:03 +08:00
Innei
8f7527b7e2 feat(desktop): Linux window specialization (#13059)
*  feat(desktop): Linux window specialization

- Add minimize/maximize/close buttons for Linux (WinControl)
- Linux: no tray, close main window quits app
- Linux: native window shadow and opaque background
- i18n for window control tooltips

Made-with: Cursor

* 🌐 i18n: add window control translations for all locales

Made-with: Cursor

* 🐛 fix(desktop): show WinControl in SimpleTitleBar only on Linux

Made-with: Cursor

* 🐛 fix(desktop): limit custom titlebar controls to Linux

Avoid rendering duplicate window controls on Windows and keep the Linux maximize button in sync with the current window state.

Made-with: Cursor

---------

Co-authored-by: LiJian <onlyyoulove3@gmail.com>
2026-03-17 16:59:33 +08:00
LiJian
26269eacbb 🐛 fix: slove the market oidc lost the call tools error (#13025)
* fix: slove the market oidc lost the call tools error

* fix: add the beta-version & add some log

* fix: fixed the oidc error ts
2026-03-17 11:27:19 +08:00
Zhijie He
78cfb087b4 💄 style: update claude 4.6 series 1M contextWindow (#12994)
* style: update claude 4.6 series 1M contextWindow

* chore: cleanup bedrock search tag

chore: cleanup bedrock retired model

chore: cleanup bedrock retired model

chore: cleanup bedrock retired model

* fix: fix ci test
2026-03-17 10:58:20 +08:00
Zhijie He
2717f8a86c 💄 style: add Seedance 1.5 Pro support for OSS (#13035)
* style: add seedance 1.5 support for OSS

* style: update volcengine videoGen models
2026-03-17 10:43:25 +08:00