β¨ feat(page-agent): execute tools server-side via HeadlessEditor#15023
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codecov Reportβ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## canary #15023 +/- ##
==========================================
- Coverage 70.69% 70.63% -0.07%
==========================================
Files 3277 3278 +1
Lines 323408 323716 +308
Branches 29521 29521
==========================================
+ Hits 228641 228660 +19
- Misses 94584 94873 +289
Partials 183 183
Flags with carried forward coverage won't be shown. Click here to find out more.
π New features to boost your workflow:
|
bdf2b77 to
7a430f9
Compare
7a430f9 to
3b25e50
Compare
3b25e50 to
54fbafb
Compare
Page-agent tools (initPage / editTitle / getPageContent / modifyNodes / replaceText) now run on the server against a `@lobehub/editor/headless` instance and persist through `DocumentService.updateDocument`, instead of executing inside the renderer's Lexical instance. The renderer applies the resulting snapshot via the builtin-tool `onAfterCall` hook, so the document store stays in sync without an extra fetch. This makes page-agent execution independent of the client lifecycle (editor unmount, tab switch, network blip), gives us full server-side tracing for free (OTel gen-ai + agent-signal + documentHistories), and exposes a `silent-no-op` / `unexpected-mutation` invariant when the exported editorData hash diverges from what the handler reported. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
β¦ffecting bundle EditorRuntime statically imported LITEXML_*_COMMAND from @lobehub/editor, which pulls ReactSlashPlugin and crashes Node (`document is not defined`) in any server-side test that transitively touched the runtime. The same import also dispatched the wrong command identity on HeadlessEditor's kernel β pnpm resolves @lobehub/editor to a different module copy than the headless bundle, so dispatchCommand would silently no-op server-side. Introduce a LiteXMLAdapter strategy: renderer wires command dispatch against the live editor; server wires HeadlessEditor.applyLiteXMLBatch / applyLiteXML so the correct headless-bundle symbols are used. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
β¦mount The main commit dropped `setBeforeMutateHandler`/`setAfterMutateHandler` under the assumption that page-agent tools always execute server-side. But the chat-store path (`invokeBuiltinTool` β `PageAgentExecutor.modifyNodes` β `EditorRuntime.modifyNodes`) still routes through the client-bound runtime whenever the LLM dispatcher is the chat slice β it does not consult `manifest.executors`. Without the handlers, that path mutates the live editor but skips both `documentHistoryQueueService.enqueueEditorSnapshot` (loses undo baseline) and `commitEditorMutation(saveSource: 'llm_call')` (row never persists). Re-wire both handlers. Server-runtime path is unaffected: it instantiates its own `EditorRuntime` against `HeadlessEditor` and never sees the client's StoreUpdater wiring, so the two paths can coexist without double-writing. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
β¦r gets adapter for free Renderer call sites shouldn't have to opt in to the obvious default (dispatch LITEXML_*_COMMAND on the live editor). Split the package into two entries: - `@lobechat/editor-runtime` β renderer entry; constructor auto-wires the LiteXML adapter from `@lobehub/editor`. Static-importing this from Node still crashes (ReactSlashPlugin), so it's the right shape for the browser only. - `@lobechat/editor-runtime/server` β server-safe entry; exports the bare class without touching `@lobehub/editor`. Callers (currently only the page-agent server runtime) supply their own HeadlessEditor- backed adapter. Drops the renderer-side setLiteXMLAdapter patch and a stale comment block in StoreUpdater. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1312fcc to
cb25155
Compare
`@lobehub/editor` 4.16.1 ships the LiteXML command identities through the side-effect-free `@lobehub/editor/litexml-commands` subpath, so a single command object is shared across the browser and node bundles and can be imported in Node without pulling the DOM-dependent editor bundle. `EditorRuntime` now imports `LITEXML_MODIFY_COMMAND` / `LITEXML_APPLY_COMMAND` from that subpath and dispatches them straight onto the editor kernel. This removes the `LiteXMLAdapter` strategy object (`setLiteXMLAdapter` / `getLiteXMLAdapter`) β a leaky abstraction whose only purpose was to keep the crash-on-Node command import out of the shared base. - editor-runtime: dispatch `LITEXML_*_COMMAND` directly; delete the adapter interface, field, setter and runtime-throw guard. - Collapse the client/server entry split (its sole reason β isolating the DOM-crashing import β is gone); both entries now re-export the isomorphic base. - pageAgent server runtime: drop the HeadlessEditor-backed adapter wiring. - Bump `@lobehub/editor` to ^4.16.1. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Now that `EditorRuntime` is isomorphic (LiteXML commands come from the DOM-free `@lobehub/editor/litexml-commands` subpath), the `./server` entry is byte-for-byte identical to the root `.` entry. Remove it and point the only consumer (pageAgent server runtime) at the root entry. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This was referenced Jun 9, 2026
This was referenced Jun 10, 2026
arvinxx
added a commit
that referenced
this pull request
Jun 10, 2026
# π LobeHub Release (20260610) **Release Date:** June 10, 2026 **Since v2.2.2:** 131 merged PRs Β· 13 contributors > This weekly release strengthens agent collaboration across cloud, desktop, CLI, and workspace flows, with steadier runtime behavior and a broader foundation for workspace-scoped data. --- ## β¨ Highlights - **Agent execution across devices** β Unifies per-device working directories, project skill discovery, and sub-agent suspend/resume behavior across server, QStash, and device RPC flows. (#15543, #15566, #15481, #15620, #15591) - **Connector and sandbox platform** β Expands connector permissions, custom OAuth MCP connector onboarding, sandbox provider support, and user-uploaded file sync into cloud sandbox runs. (#15463, #15546, #15184, #15550) - **Desktop and CLI reliability** β Fixes desktop cold-start, auto-update, Windows build, CLI skill discovery, and `lh connect` agent dispatch paths. (#15547, #15525, #15527, #15562, #15632, #15634) - **Pages and sharing** β Refreshes topic sharing, improves Page Editor layout behavior, and routes Page Agent tool execution through the server-side editor path. (#15581, #15556, #15588, #15023, #15610) - **Model availability and provider updates** β Adds user-scoped LobeHub model availability, Claude Fable 5, Qwen thinking preservation, and MiniMax M3 updates. (#15590, #15639, #13494, #15376) --- ## ποΈ Core Product & Architecture ### Agent Runtime & Heterogeneous Agents - Improves sub-agent lifecycle handling, including async suspend/resume, queue-mode QStash resume delivery, and blocking nested sub-agent calls. (#15481, #15620, #15575) - Stabilizes heterogeneous agent ingestion and streaming with raw stream dumps, per-turn usage, image forwarding on regenerate, and duplicate-text fixes. (#15602, #15577, #15592, #15585) - Adds execution-device and working-directory controls across device RPC, legacy defaults, and remote-spawned Claude Code sessions. (#15543, #15566, #15591, #15572) - Improves runtime diagnostics and compatibility, including Gemini multimodal output capture, abort stream semantics, and trace quality analysis. (#15535, #13677, #15508) --- ## π± Platforms, Integrations & UX ### Connectors, Sandbox & Tools - Ships API-level connector tool permissions, custom OAuth MCP connector onboarding, and connector-first runtime execution. (#15463, #15546) - Adds sandbox provider support, cloud sandbox file sync, and safer external URL file input handling with SSRF validation. (#15184, #15550, #12657) - Improves tool visibility and execution with pinned app-fixed tools, ANSI output rendering, gateway-tunneled MCP calls, and automatic headless tool runs. (#15509, #15516, #15469, #15492) ### Desktop, CLI & Web UX - Restores desktop startup and reload behavior, preserves IPC error causes, and keeps the tab bar new-tab action visible across routes. (#15547, #15597, #15638) - Fixes desktop update and build stability for browser quit guards, macOS update signing, and Windows Visual Studio detection. (#15525, #15527, #15562) - Shows the plan-limit upgrade UI on desktop builds. (#15628) - Adds the Agent Run delivery checker and fixes CLI device dispatch plus skill list/search output. (#15489, #15634, #15632) - Refreshes onboarding, auth source preservation, topic UI states, referral/Fable campaign copy, and chat-input control bar behavior. (#15629, #15544, #15573, #15614, #15616, #15617, #15622, #15643) --- ## π Security, Reliability & Rollout Notes - External URL file input now includes SSRF validation for safer Google file handling. (#12657) - Database workspace-scope migrations are part of this release; self-hosted operators should run the normal migration path before serving the updated app. (#15446, #15465, #15468, #15472) - The release branch was re-cut from `canary` and includes the latest `main` release-version commit so `v2.2.2` is the verified compare base. --- ## π₯ Contributors @ONLY-yours, @sxjeru, @hardy-one, @xujingli, @hezhijie0327, @Coooolfan, @arvinxx, @tjx666, @Innei, @rivertwilight, @rdmclin2, @cy948, @AmAzing129 **Full Changelog**: v2.2.2...release/weekly-20260610-recut-3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
π» Change Type
π Description of Change
Page-agent tools (
initPage/editTitle/getPageContent/modifyNodes/replaceText) used to run inside the renderer's mounted Lexical instance viaEditorRuntime. This PR moves the execution path to the server, against a@lobehub/editor/headlessinstance, with the renderer reduced to a sync target.Why
gen-ai+agent-signal+documentHistoriesaudit trail. Page-agent was the only blind spot.How it works now
Layout (follows
agent-documents/self-iterationconvention)packages/builtin-tool-page-agent/src/ExecutionRuntime/index.tsβ runtime shell +PageAgentRuntimeServicecontract; package stays free of@lobehub/editor/@lobechat/editor-runtimestatic importspackages/builtin-tool-page-agent/src/client/executor/index.tsβgit mvfromsrc/executor/index.ts; gainsonAfterCallto sync renderer statesrc/server/services/toolExecution/serverRuntimes/pageAgent.tsβ registration site; directly importsEditorRuntime+createHeadlessEditor, implements the 5 service callbacks, computes editorData hash before/after for silent-failure detectionpackages/editor-runtime/src/EditorRuntime.tsβ newapplyServerSnapshot()that pushes a server-produced snapshot into the live editor without triggering the auto-save loopsrc/store/document/slices/editor/action.tsβ matching store action that marks the row clean after a server writesrc/features/PageEditor/StoreUpdater.tsxβ removes the now-dead LLMafterMutateHandlerwiring (human-edit path untouched)Package exports dropped
./executor(the slot used to be a renderer-only executor), gained./executionRuntime. Existing consumer (src/store/tool/slices/builtin/executors/lobe-page-agent.ts) updated to import from./client.π§ͺ How to Test
Automated:
packages/builtin-tool-page-agent: 24/25 tests pass (1 pre-existing baseline failure unrelated to this PR; see commit history onclient/executor/index.test.ts).src/server/services/toolExecution/**+src/store/document/slices/editor/**: 230/230 pass.drizzle-ormdual-copy noise unaffected).Manual:
page).π Additional Information
Invariant violation is surfaced as a
console.warnplus astate.invariantViolation = { apiName, kind, detail }field on the tool result. `kind` is one of:silent-no-opβ handler reported a successful mutation but the editorData hash did not change (e.g. `modifyNodes` operations all pointed at non-existent node IDs).unexpected-mutationβ editor state changed even though the handler reported no successful change.Stability boundary: `editorChanged` is computed by hashing the exported `editorData` before and after the handler runs; `editTitle` is exempt because the title lives outside `editorData`.
Not in this PR: surfacing invariant violations in the UI, agent-signal source events on violation, and richer trace headers (these belong to the broader tracing-foundation work this PR unblocks).
π€ Generated with Claude Code