π€― LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
π fix: consolidate agent-documents tools and fix empty readDocument (#14288)
Arvin Xua2b8f4c81a40
diff --git a/packages/builtin-tool-agent-documents/src/ExecutionRuntime/index.ts b/packages/builtin-tool-agent-documents/src/ExecutionRuntime/index.tsindex 2e49907a831..6dd5d7e9656 100644--- a/packages/builtin-tool-agent-documents/src/ExecutionRuntime/index.ts+++ b/packages/builtin-tool-agent-documents/src/ExecutionRuntime/index.ts@@ -3,15 +3,13 @@ import type { BuiltinServerRuntimeOutput } from '@lobechat/types';import type {CopyDocumentArgs,CreateDocumentArgs,- EditDocumentArgs,ListDocumentsArgs,ModifyDocumentNodesArgs,ReadDocumentArgs,- ReadDocumentByFilenameArgs,RemoveDocumentArgs,RenameDocumentArgs,+ ReplaceDocumentContentArgs,UpdateLoadRuleArgs,- UpsertDocumentByFilenameArgs,} from '../types';interface AgentDocumentRecord {@@ -60,11 +58,6 @@ export interface AgentDocumentsRuntimeService {topicId: string;},) => Promise<AgentDocumentRecord | undefined>;- editDocument: (- params: EditDocumentArgs & {- agentId: string;- },- ) => Promise<AgentDocumentRecord | undefined>;listDocuments: (params: ListDocumentsArgs & {agentId: string;@@ -86,11 +79,6 @@ export interface AgentDocumentsRuntimeService {agentId: string;},) => Promise<AgentDocumentRecord | undefined>;- readDocumentByFilename: (- params: ReadDocumentByFilenameArgs & {- agentId: string;- },- ) => Promise<AgentDocumentRecord | undefined>;removeDocument: (params: RemoveDocumentArgs & {agentId: string;@@ -101,13 +89,13 @@ export interface AgentDocumentsRuntimeService {agentId: string;},) => Promise<AgentDocumentRecord | undefined>;- updateLoadRule: (- params: UpdateLoadRuleArgs & {+ replaceDocumentContent: (+ params: ReplaceDocumentContentArgs & {agentId: string;},) => Promise<AgentDocumentRecord | undefined>;- upsertDocumentByFilename: (- params: UpsertDocumentByFilenameArgs & {+ updateLoadRule: (+ params: UpdateLoadRuleArgs & {agentId: string;},) => Promise<AgentDocumentRecord | undefined>;@@ -159,19 +147,6 @@ export class AgentDocumentsExecutionRuntime {return doc.documentId === currentDocumentId;}- private async shouldBlockUpsertForCurrentPageDocument(- agentId: string,- filename: string,- context?: AgentDocumentOperationContext,- ) {- const currentDocumentId = this.getCurrentDocumentId(context);- if (!currentDocumentId) return false;-- const docs = await this.service.listDocuments({ agentId });-- return docs.some((doc) => doc.documentId === currentDocumentId && doc.filename === filename);- }-private formatDocumentReadContent(doc: AgentDocumentRecord,format: 'xml' | 'markdown' | 'both' = 'xml',@@ -224,62 +199,6 @@ export class AgentDocumentsExecutionRuntime {};}- async readDocumentByFilename(- args: ReadDocumentByFilenameArgs,- context?: AgentDocumentOperationContext,- ): Promise<BuiltinServerRuntimeOutput> {- const agentId = this.resolveAgentId(context);- if (!agentId) {- return {- content: 'Cannot read agent document without agentId context.',- success: false,- };- }-- const doc = await this.service.readDocumentByFilename({ ...args, agentId });- if (!doc) return { content: `Document not found: ${args.filename}`, success: false };-- const format = args.format ?? 'xml';-- return {- content: this.formatDocumentReadContent(doc, format),- state: {- content: doc.content,- filename: args.filename,- id: doc.id,- title: doc.title,- xml: doc.litexml,- },- success: true,- };- }-- async upsertDocumentByFilename(- args: UpsertDocumentByFilenameArgs,- context?: AgentDocumentOperationContext,- ): Promise<BuiltinServerRuntimeOutput> {- const agentId = this.resolveAgentId(context);- if (!agentId) {- return {- content: 'Cannot upsert agent document without agentId context.',- success: false,- };- }-- if (await this.shouldBlockUpsertForCurrentPageDocument(agentId, args.filename, context)) {- return this.buildCurrentPageDocumentWriteBlockedResult('upsertDocumentByFilename');- }-- const doc = await this.service.upsertDocumentByFilename({ ...args, agentId });- if (!doc) return { content: `Failed to upsert document: ${args.filename}`, success: false };-- return {- content: `Upserted document "${args.filename}" (${doc.id}).`,- state: { filename: args.filename, id: doc.id },- success: true,- };- }-async createDocument(args: CreateDocumentArgs,context?: AgentDocumentOperationContext,@@ -338,14 +257,14 @@ export class AgentDocumentsExecutionRuntime {};}- async editDocument(- args: EditDocumentArgs,+ async replaceDocumentContent(+ args: ReplaceDocumentContentArgs,context?: AgentDocumentOperationContext,): Promise<BuiltinServerRuntimeOutput> {const agentId = this.resolveAgentId(context);if (!agentId) {return {- content: 'Cannot edit agent document without agentId context.',+ content: 'Cannot replace agent document content without agentId context.',success: false,};}@@ -354,10 +273,10 @@ export class AgentDocumentsExecutionRuntime {if (!existing) return { content: `Document not found: ${args.id}`, success: false };if (this.isCurrentPageDocument(existing, context)) {- return this.buildCurrentPageDocumentWriteBlockedResult('editDocument');+ return this.buildCurrentPageDocumentWriteBlockedResult('replaceDocumentContent');}- const doc = await this.service.editDocument({ ...args, agentId });+ const doc = await this.service.replaceDocumentContent({ ...args, agentId });if (!doc) return { content: `Failed to update document ${args.id}.`, success: false };return {diff --git a/packages/builtin-tool-agent-documents/src/client/Inspector/ReadDocumentByFilename/index.tsx b/packages/builtin-tool-agent-documents/src/client/Inspector/ReadDocumentByFilename/index.tsxdeleted file mode 100644index bf4ed858ae3..00000000000--- a/packages/builtin-tool-agent-documents/src/client/Inspector/ReadDocumentByFilename/index.tsx+++ /dev/null@@ -1,41 +0,0 @@-'use client';--import type { BuiltinInspectorProps } from '@lobechat/types';-import { cx } from 'antd-style';-import { memo } from 'react';-import { useTranslation } from 'react-i18next';--import { highlightTextStyles, inspectorTextStyles, shinyTextStyles } from '@/styles';--import type { ReadDocumentByFilenameArgs, ReadDocumentByFilenameState } from '../../../types';--export const ReadDocumentByFilenameInspector = memo<- BuiltinInspectorProps<ReadDocumentByFilenameArgs, ReadDocumentByFilenameState>->(({ args, partialArgs, isArgumentsStreaming, isLoading }) => {- const { t } = useTranslation('plugin');- const filename = args?.filename || partialArgs?.filename;-- if (isArgumentsStreaming && !filename) {- return (- <div className={cx(inspectorTextStyles.root, shinyTextStyles.shinyText)}>- <span>{t('builtins.lobe-agent-documents.apiName.readDocumentByFilename')}</span>- </div>- );- }-- return (- <div- className={cx(- inspectorTextStyles.root,- (isArgumentsStreaming || isLoading) && shinyTextStyles.shinyText,- )}- >- <span>{t('builtins.lobe-agent-documents.apiName.readDocumentByFilename')}: </span>- {filename && <span className={highlightTextStyles.primary}>{filename}</span>}- </div>- );-});--ReadDocumentByFilenameInspector.displayName = 'ReadDocumentByFilenameInspector';--export default ReadDocumentByFilenameInspector;diff --git a/packages/builtin-tool-agent-documents/src/client/Inspector/EditDocument/index.tsx b/packages/builtin-tool-agent-documents/src/client/Inspector/ReplaceDocumentContent/index.tsxsimilarity index 61%rename from packages/builtin-tool-agent-documents/src/client/Inspector/EditDocument/index.tsxrename to packages/builtin-tool-agent-documents/src/client/Inspector/ReplaceDocumentContent/index.tsxindex 874dd1c65df..0ed0dde67b1 100644--- a/packages/builtin-tool-agent-documents/src/client/Inspector/EditDocument/index.tsx+++ b/packages/builtin-tool-agent-documents/src/client/Inspector/ReplaceDocumentContent/index.tsx@@ -7,10 +7,10 @@ import { useTranslation } from 'react-i18next';import { highlightTextStyles, inspectorTextStyles, shinyTextStyles } from '@/styles';-import type { EditDocumentArgs, EditDocumentState } from '../../../types';+import type { ReplaceDocumentContentArgs, ReplaceDocumentContentState } from '../../../types';-export const EditDocumentInspector = memo<- BuiltinInspectorProps<EditDocumentArgs, EditDocumentState>+export const ReplaceDocumentContentInspector = memo<+ BuiltinInspectorProps<ReplaceDocumentContentArgs, ReplaceDocumentContentState>>(({ args, partialArgs, isArgumentsStreaming, isLoading }) => {const { t } = useTranslation('plugin');const id = args?.id || partialArgs?.id;@@ -18,7 +18,7 @@ export const EditDocumentInspector = memo<if (isArgumentsStreaming && !id) {return (<div className={cx(inspectorTextStyles.root, shinyTextStyles.shinyText)}>- <span>{t('builtins.lobe-agent-documents.apiName.editDocument')}</span>+ <span>{t('builtins.lobe-agent-documents.apiName.replaceDocumentContent')}</span></div>);}@@ -30,12 +30,12 @@ export const EditDocumentInspector = memo<(isArgumentsStreaming || isLoading) && shinyTextStyles.shinyText,)}>- <span>{t('builtins.lobe-agent-documents.apiName.editDocument')}: </span>+ <span>{t('builtins.lobe-agent-documents.apiName.replaceDocumentContent')}: </span>{id && <span className={highlightTextStyles.primary}>{id}</span>}</div>);});-EditDocumentInspector.displayName = 'EditDocumentInspector';+ReplaceDocumentContentInspector.displayName = 'ReplaceDocumentContentInspector';-export default EditDocumentInspector;+export default ReplaceDocumentContentInspector;diff --git a/packages/builtin-tool-agent-documents/src/client/Inspector/UpsertDocumentByFilename/index.tsx b/packages/builtin-tool-agent-documents/src/client/Inspector/UpsertDocumentByFilename/index.tsxdeleted file mode 100644index 7c629ee500c..00000000000--- a/packages/builtin-tool-agent-documents/src/client/Inspector/UpsertDocumentByFilename/index.tsx+++ /dev/null@@ -1,41 +0,0 @@-'use client';--import type { BuiltinInspectorProps } from '@lobechat/types';-import { cx } from 'antd-style';-import { memo } from 'react';-import { useTranslation } from 'react-i18next';--import { highlightTextStyles, inspectorTextStyles, shinyTextStyles } from '@/styles';--import type { UpsertDocumentByFilenameArgs, UpsertDocumentByFilenameState } from '../../../types';--export const UpsertDocumentByFilenameInspector = memo<- BuiltinInspectorProps<UpsertDocumentByFilenameArgs, UpsertDocumentByFilenameState>->(({ args, partialArgs, isArgumentsStreaming, isLoading }) => {- const { t } = useTranslation('plugin');- const filename = args?.filename || partialArgs?.filename;-- if (isArgumentsStreaming && !filename) {- return (- <div className={cx(inspectorTextStyles.root, shinyTextStyles.shinyText)}>- <span>{t('builtins.lobe-agent-documents.apiName.upsertDocumentByFilename')}</span>- </div>- );- }-- return (- <div- className={cx(- inspectorTextStyles.root,- (isArgumentsStreaming || isLoading) && shinyTextStyles.shinyText,- )}- >- <span>{t('builtins.lobe-agent-documents.apiName.upsertDocumentByFilename')}: </span>- {filename && <span className={highlightTextStyles.primary}>{filename}</span>}- </div>- );-});--UpsertDocumentByFilenameInspector.displayName = 'UpsertDocumentByFilenameInspector';--export default UpsertDocumentByFilenameInspector;diff --git a/packages/builtin-tool-agent-documents/src/client/Inspector/index.ts b/packages/builtin-tool-agent-documents/src/client/Inspector/index.tsindex 8d1aefcdc40..5cb31b4a8be 100644--- a/packages/builtin-tool-agent-documents/src/client/Inspector/index.ts+++ b/packages/builtin-tool-agent-documents/src/client/Inspector/index.ts@@ -3,28 +3,23 @@ import type { BuiltinInspector } from '@lobechat/types';import { AgentDocumentsApiName } from '../../types';import { CopyDocumentInspector } from './CopyDocument';import { CreateDocumentInspector } from './CreateDocument';-import { EditDocumentInspector } from './EditDocument';import { ListDocumentsInspector } from './ListDocuments';import { ModifyNodesInspector } from './ModifyNodes';import { ReadDocumentInspector } from './ReadDocument';-import { ReadDocumentByFilenameInspector } from './ReadDocumentByFilename';import { RemoveDocumentInspector } from './RemoveDocument';import { RenameDocumentInspector } from './RenameDocument';+import { ReplaceDocumentContentInspector } from './ReplaceDocumentContent';import { UpdateLoadRuleInspector } from './UpdateLoadRule';-import { UpsertDocumentByFilenameInspector } from './UpsertDocumentByFilename';export const AgentDocumentsInspectors: Record<string, BuiltinInspector> = {[AgentDocumentsApiName.copyDocument]: CopyDocumentInspector as BuiltinInspector,[AgentDocumentsApiName.createDocument]: CreateDocumentInspector as BuiltinInspector,- [AgentDocumentsApiName.editDocument]: EditDocumentInspector as BuiltinInspector,[AgentDocumentsApiName.listDocuments]: ListDocumentsInspector as BuiltinInspector,[AgentDocumentsApiName.modifyNodes]: ModifyNodesInspector as BuiltinInspector,[AgentDocumentsApiName.readDocument]: ReadDocumentInspector as BuiltinInspector,- [AgentDocumentsApiName.readDocumentByFilename]:- ReadDocumentByFilenameInspector as BuiltinInspector,[AgentDocumentsApiName.removeDocument]: RemoveDocumentInspector as BuiltinInspector,[AgentDocumentsApiName.renameDocument]: RenameDocumentInspector as BuiltinInspector,+ [AgentDocumentsApiName.replaceDocumentContent]:+ ReplaceDocumentContentInspector as BuiltinInspector,[AgentDocumentsApiName.updateLoadRule]: UpdateLoadRuleInspector as BuiltinInspector,- [AgentDocumentsApiName.upsertDocumentByFilename]:- UpsertDocumentByFilenameInspector as BuiltinInspector,};diff --git a/packages/builtin-tool-agent-documents/src/executor/index.ts b/packages/builtin-tool-agent-documents/src/executor/index.tsindex b110b391d5a..147f6689f35 100644--- a/packages/builtin-tool-agent-documents/src/executor/index.ts+++ b/packages/builtin-tool-agent-documents/src/executor/index.ts@@ -6,15 +6,13 @@ import {AgentDocumentsIdentifier,type CopyDocumentArgs,type CreateDocumentArgs,- type EditDocumentArgs,type ListDocumentsArgs,type ModifyDocumentNodesArgs,type ReadDocumentArgs,- type ReadDocumentByFilenameArgs,type RemoveDocumentArgs,type RenameDocumentArgs,+ type ReplaceDocumentContentArgs,type UpdateLoadRuleArgs,- type UpsertDocumentByFilenameArgs,} from '../types';export class AgentDocumentsExecutor extends BaseExecutor<typeof AgentDocumentsApiName> {@@ -40,28 +38,6 @@ export class AgentDocumentsExecutor extends BaseExecutor<typeof AgentDocumentsAp});};- readDocumentByFilename = async (- params: ReadDocumentByFilenameArgs,- ctx: BuiltinToolContext,- ): Promise<BuiltinToolResult> => {- return this.runtime.readDocumentByFilename(params, {- agentId: ctx.agentId,- currentDocumentId: ctx.documentId,- scope: ctx.scope,- });- };-- upsertDocumentByFilename = async (- params: UpsertDocumentByFilenameArgs,- ctx: BuiltinToolContext,- ): Promise<BuiltinToolResult> => {- return this.runtime.upsertDocumentByFilename(params, {- agentId: ctx.agentId,- currentDocumentId: ctx.documentId,- scope: ctx.scope,- });- };-createDocument = async (params: CreateDocumentArgs,ctx: BuiltinToolContext,@@ -85,11 +61,11 @@ export class AgentDocumentsExecutor extends BaseExecutor<typeof AgentDocumentsAp});};- editDocument = async (- params: EditDocumentArgs,+ replaceDocumentContent = async (+ params: ReplaceDocumentContentArgs,ctx: BuiltinToolContext,): Promise<BuiltinToolResult> => {- return this.runtime.editDocument(params, {+ return this.runtime.replaceDocumentContent(params, {agentId: ctx.agentId,currentDocumentId: ctx.documentId,scope: ctx.scope,@@ -156,16 +132,14 @@ const fallbackRuntime = new AgentDocumentsExecutionRuntime({copyDocument: async ({ agentId: _agentId }) => undefined,createDocument: async () => undefined,createTopicDocument: async () => undefined,- editDocument: async ({ agentId: _agentId }) => undefined,listDocuments: async () => [],listTopicDocuments: async () => [],modifyNodes: async ({ agentId: _agentId }) => undefined,readDocument: async ({ agentId: _agentId }) => undefined,- readDocumentByFilename: async () => undefined,removeDocument: async ({ agentId: _agentId }) => false,renameDocument: async ({ agentId: _agentId }) => undefined,+ replaceDocumentContent: async ({ agentId: _agentId }) => undefined,updateLoadRule: async ({ agentId: _agentId }) => undefined,- upsertDocumentByFilename: async () => undefined,});export const agentDocumentsExecutor = new AgentDocumentsExecutor(fallbackRuntime);diff --git a/packages/builtin-tool-agent-documents/src/index.ts b/packages/builtin-tool-agent-documents/src/index.tsindex c762059986a..c0bb22ad407 100644--- a/packages/builtin-tool-agent-documents/src/index.ts+++ b/packages/builtin-tool-agent-documents/src/index.ts@@ -8,23 +8,19 @@ export {type CopyDocumentState,type CreateDocumentArgs,type CreateDocumentState,- type EditDocumentArgs,- type EditDocumentState,type ListDocumentsArgs,type ListDocumentsState,type ModifyDocumentNodesArgs,type ModifyDocumentNodesState,type ModifyDocumentOperation,type ReadDocumentArgs,- type ReadDocumentByFilenameArgs,- type ReadDocumentByFilenameState,type ReadDocumentState,type RemoveDocumentArgs,type RemoveDocumentState,type RenameDocumentArgs,type RenameDocumentState,+ type ReplaceDocumentContentArgs,+ type ReplaceDocumentContentState,type UpdateLoadRuleArgs,type UpdateLoadRuleState,- type UpsertDocumentByFilenameArgs,- type UpsertDocumentByFilenameState,} from './types';diff --git a/packages/builtin-tool-agent-documents/src/manifest.ts b/packages/builtin-tool-agent-documents/src/manifest.tsindex c5eab6a25c0..7abc25a1ef8 100644--- a/packages/builtin-tool-agent-documents/src/manifest.ts+++ b/packages/builtin-tool-agent-documents/src/manifest.ts@@ -55,12 +55,12 @@ export const AgentDocumentsManifest: BuiltinToolManifest = {},{description:- 'Edit an existing agent document content by ID. Use this for full-content replacement, not title rename. Prefer modifyNodes for targeted content edits.',- name: AgentDocumentsApiName.editDocument,+ 'Replace the entire content of an existing agent document by ID. Use this only when overwriting most or all of the document. Prefer modifyNodes for targeted edits.',+ name: AgentDocumentsApiName.replaceDocumentContent,parameters: {properties: {content: {- description: 'Updated full document content.',+ description: 'New full document content.',type: 'string',},id: {@@ -204,47 +204,6 @@ export const AgentDocumentsManifest: BuiltinToolManifest = {type: 'object',},},- {- description:- 'Read an existing agent document by its filename. Prefer XML format before node-level edits because XML includes stable node IDs.',- name: AgentDocumentsApiName.readDocumentByFilename,- parameters: {- properties: {- format: {- default: 'xml',- description:- 'The format to return. Use "xml" for node-level edits, "markdown" for plain text, or "both". Defaults to "xml".',- enum: ['xml', 'markdown', 'both'],- type: 'string',- },- filename: {- description: 'Target document filename.',- type: 'string',- },- },- required: ['filename'],- type: 'object',- },- },- {- description:- 'Create or update an agent document by filename. If a document with the given filename exists, its content is updated; otherwise a new document is created.',- name: AgentDocumentsApiName.upsertDocumentByFilename,- parameters: {- properties: {- content: {- description: 'Document content in markdown or plain text.',- type: 'string',- },- filename: {- description: 'Target document filename.',- type: 'string',- },- },- required: ['filename', 'content'],- type: 'object',- },- },{description:'Update agent-document load rules. Use this to control how documents are loaded into runtime context.',diff --git a/packages/builtin-tool-agent-documents/src/systemRole.ts b/packages/builtin-tool-agent-documents/src/systemRole.tsindex 43f65e9d49f..eb3f192b339 100644--- a/packages/builtin-tool-agent-documents/src/systemRole.ts+++ b/packages/builtin-tool-agent-documents/src/systemRole.ts@@ -2,8 +2,8 @@ export const systemPrompt = `You have access to an Agent Documents tool for crea<core_capabilities>1. Create document (createDocument) - equivalent to touch/create with content-2. Read document (readDocument) - equivalent to cat/read-3. Edit document (editDocument) - full-content overwrite+2. Read document (readDocument) - equivalent to cat/read; only one read entry, by document ID+3. Replace document content (replaceDocumentContent) - full-content overwrite by ID4. Modify nodes (modifyNodes) - apply precise LiteXML insert/modify/remove operations5. Remove document (removeDocument) - equivalent to rm/delete6. Rename document (renameDocument) - equivalent to mv/rename@@ -14,7 +14,7 @@ export const systemPrompt = `You have access to an Agent Documents tool for crea<workflow>1. Understand the exact document operation intent.2. Select the correct API based on the requested action.-3. Use explicit IDs/titles/content in arguments.+3. Use explicit IDs and content in arguments. Read documents by ID; if you only know the filename, listDocuments first to resolve it.4. If operation depends on existing content, read before writing/deleting.5. Confirm what changed after each operation.</workflow>@@ -22,10 +22,10 @@ export const systemPrompt = `You have access to an Agent Documents tool for crea<tool_selection_guidelines>- By default, if the user does not explicitly specify otherwise, and the relevant Agent Documents tool is available for the task, prefer Agent Documents over Cloud Sandbox because it is easier for collaboration and multi-agent coordination.- **createDocument**: create a new document with title + content. Use target="currentTopic" only when the user asks to create a document in the current topic; otherwise omit target for an agent-scoped document.-- **listDocuments**: list agent documents. Use target="currentTopic" when the user asks about documents in the current topic.-- **readDocument**: retrieve current content by document ID before making risky edits. Prefer format="xml" when you may edit content, because XML includes stable node IDs.+- **listDocuments**: list agent documents. Use target="currentTopic" when the user asks about documents in the current topic. Use this to resolve a filename to a document ID before reading.+- **readDocument**: retrieve current content by document ID. This is the only way to read an agent document β there is no read-by-filename variant. Prefer format="xml" when you may edit content, because XML includes stable node IDs. If the response contains empty content, the document is genuinely empty; do not retry with a different format or filename.- **modifyNodes**: preferred content-edit API. Use LiteXML insert/modify/remove operations after reading XML. For modify operations, include the existing node ID in the LiteXML.-- **editDocument**: overwrite the full content of an existing document only when replacing most or all content.+- **replaceDocumentContent**: overwrite the full content of an existing document only when replacing most or all content.- **removeDocument**: permanently remove a document by ID.- **renameDocument**: change document title only.- **copyDocument**: duplicate a document, optionally with a new title.diff --git a/packages/builtin-tool-agent-documents/src/types.ts b/packages/builtin-tool-agent-documents/src/types.tsindex fa1a4ad0759..9e0da524ff8 100644--- a/packages/builtin-tool-agent-documents/src/types.ts+++ b/packages/builtin-tool-agent-documents/src/types.ts@@ -3,15 +3,13 @@ export const AgentDocumentsIdentifier = 'lobe-agent-documents';export const AgentDocumentsApiName = {createDocument: 'createDocument',copyDocument: 'copyDocument',- editDocument: 'editDocument',listDocuments: 'listDocuments',modifyNodes: 'modifyNodes',readDocument: 'readDocument',- readDocumentByFilename: 'readDocumentByFilename',removeDocument: 'removeDocument',renameDocument: 'renameDocument',+ replaceDocumentContent: 'replaceDocumentContent',updateLoadRule: 'updateLoadRule',- upsertDocumentByFilename: 'upsertDocumentByFilename',} as const;export interface CreateDocumentArgs {@@ -36,12 +34,12 @@ export interface ReadDocumentState {xml?: string;}-export interface EditDocumentArgs {+export interface ReplaceDocumentContentArgs {content: string;id: string;}-export interface EditDocumentState {+export interface ReplaceDocumentContentState {id: string;updated: boolean;}@@ -160,27 +158,3 @@ export interface ListDocumentsArgs {export interface ListDocumentsState {documents: { documentId?: string; filename: string; id: string; title?: string }[];}--export interface ReadDocumentByFilenameArgs {- filename: string;- format?: 'xml' | 'markdown' | 'both';-}--export interface ReadDocumentByFilenameState {- content?: string;- filename: string;- id: string;- title?: string;- xml?: string;-}--export interface UpsertDocumentByFilenameArgs {- content: string;- filename: string;-}--export interface UpsertDocumentByFilenameState {- created: boolean;- filename: string;- id: string;-}diff --git a/packages/builtin-tool-page-agent/src/executor/index.ts b/packages/builtin-tool-page-agent/src/executor/index.tsindex a6aa7f9f96b..8acb2d9d832 100644--- a/packages/builtin-tool-page-agent/src/executor/index.ts+++ b/packages/builtin-tool-page-agent/src/executor/index.ts@@ -65,7 +65,7 @@ const getRuntimeDebugSnapshot = (runtime: EditorRuntime) => {const PAGE_EDITOR_NOT_MOUNTED_MESSAGE ='Page editor is not currently mounted. This topic was started in the page editor, but the editor is not active in the current view. ' +'Do not retry initPage / editTitle / modifyNodes / replaceText / getPageContent here β they require a mounted editor. ' +- 'To read or modify the topic document, use lobe-agent-documents (readDocument / editDocument / modifyNodes / upsertDocumentByFilename).';+ 'To read or modify the topic document, use lobe-agent-documents (readDocument / replaceDocumentContent / modifyNodes).';const buildEditorNotMountedResult = (runtime: EditorRuntime,diff --git a/src/features/Conversation/Messages/AssistantGroup/constants.ts b/src/features/Conversation/Messages/AssistantGroup/constants.tsindex a6e8788695f..ffb73a2fced 100644--- a/src/features/Conversation/Messages/AssistantGroup/constants.ts+++ b/src/features/Conversation/Messages/AssistantGroup/constants.ts@@ -123,13 +123,11 @@ export const TOOL_API_DISPLAY_NAMES: Record<string, string> = {// Agent documentscopyDocument: 'workflow.toolDisplayName.copyDocument',- editDocument: 'workflow.toolDisplayName.editDocument',listDocuments: 'workflow.toolDisplayName.listDocuments',readDocument: 'workflow.toolDisplayName.readDocument',- readDocumentByFilename: 'workflow.toolDisplayName.readDocumentByFilename',removeDocument: 'workflow.toolDisplayName.removeDocument',renameDocument: 'workflow.toolDisplayName.renameDocument',- upsertDocumentByFilename: 'workflow.toolDisplayName.upsertDocumentByFilename',+ replaceDocumentContent: 'workflow.toolDisplayName.replaceDocumentContent',updateLoadRule: 'workflow.toolDisplayName.updateLoadRule',// Calculatordiff --git a/src/locales/default/chat.ts b/src/locales/default/chat.tsindex 823f539313f..d47030c7864 100644--- a/src/locales/default/chat.ts+++ b/src/locales/default/chat.ts@@ -802,7 +802,7 @@ export default {'workflow.toolDisplayName.createTodos': 'Created todos','workflow.toolDisplayName.deleteAgent': 'Deleted an agent','workflow.toolDisplayName.deleteDocument': 'Deleted a document',- 'workflow.toolDisplayName.editDocument': 'Edited a document',+ 'workflow.toolDisplayName.replaceDocumentContent': 'Replaced document content','workflow.toolDisplayName.editLocalFile': 'Edited a file','workflow.toolDisplayName.editTitle': 'Edited title','workflow.toolDisplayName.evaluate': 'Evaluated expression',@@ -829,7 +829,6 @@ export default {'workflow.toolDisplayName.modifyNodes': 'Modified Page','workflow.toolDisplayName.moveLocalFiles': 'Moved files','workflow.toolDisplayName.readDocument': 'Read a document',- 'workflow.toolDisplayName.readDocumentByFilename': 'Read a document','workflow.toolDisplayName.readKnowledge': 'Read knowledge','workflow.toolDisplayName.readLocalFile': 'Read a file','workflow.toolDisplayName.removeDocument': 'Removed a document',@@ -851,7 +850,6 @@ export default {'workflow.toolDisplayName.updateLoadRule': 'Updated load rule','workflow.toolDisplayName.updatePlan': 'Updated plan','workflow.toolDisplayName.updateTodos': 'Updated todos',- 'workflow.toolDisplayName.upsertDocumentByFilename': 'Updated a document','workflow.toolDisplayName.writeLocalFile': 'Wrote a file','workflow.awaitingConfirmation': 'Awaiting your confirmation','workflow.collapse': 'Collapse',diff --git a/src/locales/default/plugin.ts b/src/locales/default/plugin.tsindex f513408adad..9dbe9a89fd2 100644--- a/src/locales/default/plugin.ts+++ b/src/locales/default/plugin.ts@@ -152,15 +152,13 @@ export default {'builtins.lobe-local-system.title': 'Local System','builtins.lobe-agent-documents.apiName.copyDocument': 'Copy document','builtins.lobe-agent-documents.apiName.createDocument': 'Create document',- 'builtins.lobe-agent-documents.apiName.editDocument': 'Edit document','builtins.lobe-agent-documents.apiName.listDocuments': 'List documents','builtins.lobe-agent-documents.apiName.modifyNodes': 'Modify document','builtins.lobe-agent-documents.apiName.readDocument': 'Read document',- 'builtins.lobe-agent-documents.apiName.readDocumentByFilename': 'Read document by filename','builtins.lobe-agent-documents.apiName.removeDocument': 'Remove document','builtins.lobe-agent-documents.apiName.renameDocument': 'Rename document',+ 'builtins.lobe-agent-documents.apiName.replaceDocumentContent': 'Replace document content','builtins.lobe-agent-documents.apiName.updateLoadRule': 'Update load rule',- 'builtins.lobe-agent-documents.apiName.upsertDocumentByFilename': 'Upsert document by filename','builtins.lobe-agent-documents.title': 'Agent Documents','builtins.lobe-notebook.actions.collapse': 'Collapse','builtins.lobe-notebook.actions.copy': 'Copy',diff --git a/src/server/routers/lambda/agentDocument.ts b/src/server/routers/lambda/agentDocument.tsindex 8539e6f7370..a69a57b6d52 100644--- a/src/server/routers/lambda/agentDocument.ts+++ b/src/server/routers/lambda/agentDocument.ts@@ -331,23 +331,6 @@ export const agentDocumentRouter = router({}}),- /**- * Tool-oriented: read document by filename- */- readDocumentByFilename: agentDocumentProcedure- .input(- z.object({- agentId: z.string(),- format: readFormatSchema,- filename: z.string(),- }),- )- .query(async ({ ctx, input }) => {- return input.format- ? ctx.agentDocumentService.getDocumentSnapshotByFilename(input.agentId, input.filename)- : ctx.agentDocumentService.getDocumentByFilename(input.agentId, input.filename);- }),-/*** Tool-oriented: stat document by VFS path*/@@ -653,25 +636,6 @@ export const agentDocumentRouter = router({}}),- /**- * Tool-oriented: upsert document by filename- */- upsertDocumentByFilename: agentDocumentProcedure- .input(- z.object({- agentId: z.string(),- content: z.string(),- filename: z.string(),- }),- )- .mutation(async ({ ctx, input }) => {- return ctx.agentDocumentService.upsertDocumentByFilename({- agentId: input.agentId,- content: input.content,- filename: input.filename,- });- }),-/*** Tool-oriented: associate an existing document with an agent*/@@ -764,9 +728,9 @@ export const agentDocumentRouter = router({}),/**- * Tool-oriented: edit document content by id+ * Tool-oriented: replace document content by id*/- editDocument: agentDocumentProcedure+ replaceDocumentContent: agentDocumentProcedure.input(z.object({agentId: z.string(),@@ -775,7 +739,11 @@ export const agentDocumentRouter = router({}),).mutation(async ({ ctx, input }) => {- return ctx.agentDocumentService.editDocumentById(input.id, input.content, input.agentId);+ return ctx.agentDocumentService.replaceDocumentContentById(+ input.id,+ input.content,+ input.agentId,+ );}),/**diff --git a/src/server/services/agentDocuments/index.test.ts b/src/server/services/agentDocuments/index.test.tsindex 81f9e372e42..9eb9229e6ac 100644--- a/src/server/services/agentDocuments/index.test.ts+++ b/src/server/services/agentDocuments/index.test.ts@@ -421,7 +421,7 @@ describe('AgentDocumentsService', () => {});});- describe('editDocumentById', () => {+ describe('replaceDocumentContentById', () => {it('should save history before editing document content', async () => {mockModel.findById.mockResolvedValueOnce({@@ -440,7 +440,7 @@ describe('AgentDocumentsService', () => {});const service = new AgentDocumentsService(db, userId);- const result = await service.editDocumentById('agent-doc-1', 'new', 'agent-1');+ const result = await service.replaceDocumentContentById('agent-doc-1', 'new', 'agent-1');expect(mockDocumentService.trySaveCurrentDocumentHistory).toHaveBeenCalledWith('documents-1',@@ -480,7 +480,7 @@ describe('AgentDocumentsService', () => {});const service = new AgentDocumentsService(db, userId);- await service.editDocumentById('agent-doc-1', 'same', 'agent-1');+ await service.replaceDocumentContentById('agent-doc-1', 'same', 'agent-1');expect(mockDocumentService.trySaveCurrentDocumentHistory).not.toHaveBeenCalled();expect(mockModel.update).toHaveBeenCalledWith('agent-doc-1', {diff --git a/src/server/services/agentDocuments/index.ts b/src/server/services/agentDocuments/index.tsindex cb835876e75..5f83451d2a8 100644--- a/src/server/services/agentDocuments/index.ts+++ b/src/server/services/agentDocuments/index.ts@@ -108,6 +108,20 @@ export class AgentDocumentsService {litexml: true,});+ // Hydration of stale editorData (older Lexical schemas) can silently fail+ // and leave the editor empty. When that happens, hydrate from the markdown+ // column directly so readDocument never returns an empty doc for a row that+ // actually has content.+ if (snapshot.content.trim().length === 0 && doc.content.trim().length > 0) {+ const fromMarkdown = await exportEditorDataSnapshot({+ editorData: undefined,+ fallbackContent: doc.content,+ litexml: true,+ });+ const content = fromMarkdown.content.trim().length > 0 ? fromMarkdown.content : doc.content;+ return { ...doc, content, litexml: fromMarkdown.litexml };+ }+return { ...doc, content: snapshot.content, litexml: snapshot.litexml };}@@ -483,7 +497,7 @@ export class AgentDocumentsService {});}- async editDocumentById(documentId: string, content: string, expectedAgentId?: string) {+ async replaceDocumentContentById(documentId: string, content: string, expectedAgentId?: string) {const doc = await this.getDocumentByIdInAgent(documentId, expectedAgentId);if (!doc) return undefined;const snapshot = await createMarkdownEditorSnapshot(content);diff --git a/src/server/services/toolExecution/serverRuntimes/__tests__/agentDocuments.test.ts b/src/server/services/toolExecution/serverRuntimes/__tests__/agentDocuments.test.tsindex 11bbf658156..a86bc5ead0c 100644--- a/src/server/services/toolExecution/serverRuntimes/__tests__/agentDocuments.test.ts+++ b/src/server/services/toolExecution/serverRuntimes/__tests__/agentDocuments.test.ts@@ -39,7 +39,6 @@ describe('agentDocumentsRuntime auto-pin to task', () => {copyDocumentById: ReturnType<typeof vi.fn>;createDocument: ReturnType<typeof vi.fn>;createForTopic: ReturnType<typeof vi.fn>;- upsertDocumentByFilename: ReturnType<typeof vi.fn>;};let pinDocument: ReturnType<typeof vi.fn>;@@ -48,7 +47,6 @@ describe('agentDocumentsRuntime auto-pin to task', () => {copyDocumentById: vi.fn().mockResolvedValue(newDoc),createDocument: vi.fn().mockResolvedValue(newDoc),createForTopic: vi.fn().mockResolvedValue(newDoc),- upsertDocumentByFilename: vi.fn().mockResolvedValue(newDoc),};pinDocument = vi.fn().mockResolvedValue(undefined);@@ -101,17 +99,6 @@ describe('agentDocumentsRuntime auto-pin to task', () => {expect(pinDocument).toHaveBeenCalledWith('task-1', 'documents-row-id', 'agent');});- it('pins documents produced by upsertDocumentByFilename', async () => {- const runtime = agentDocumentsRuntime.factory(buildContext('task-1'));-- await runtime.upsertDocumentByFilename(- { content: 'body', filename: 'daily-brief.md' },- { agentId: 'agent-1' },- );-- expect(pinDocument).toHaveBeenCalledWith('task-1', 'documents-row-id', 'agent');- });-it('does not pin when service returns undefined (e.g. copy of missing doc)', async () => {serviceImpl.copyDocumentById.mockResolvedValue(undefined);const runtime = agentDocumentsRuntime.factory(buildContext('task-1'));@@ -127,16 +114,14 @@ describe('AgentDocumentsExecutionRuntime.createDocument', () => {copyDocument: vi.fn(),createDocument: vi.fn(),createTopicDocument: vi.fn(),- editDocument: vi.fn(),listDocuments: vi.fn(),listTopicDocuments: vi.fn(),modifyNodes: vi.fn(),readDocument: vi.fn(),- readDocumentByFilename: vi.fn(),removeDocument: vi.fn(),renameDocument: vi.fn(),+ replaceDocumentContent: vi.fn(),updateLoadRule: vi.fn(),- upsertDocumentByFilename: vi.fn(),});it('returns documents.id (not agentDocuments.id) for state.documentId', async () => {@@ -211,7 +196,7 @@ describe('AgentDocumentsExecutionRuntime.createDocument', () => {expect(stub.createTopicDocument).not.toHaveBeenCalled();});- it('blocks editDocument for the current page document', async () => {+ it('blocks replaceDocumentContent for the current page document', async () => {const stub = makeStub();stub.readDocument.mockResolvedValue({content: 'body',@@ -221,7 +206,7 @@ describe('AgentDocumentsExecutionRuntime.createDocument', () => {});const runtime = new AgentDocumentsExecutionRuntime(stub);- const result = await runtime.editDocument(+ const result = await runtime.replaceDocumentContent({ content: 'updated', id: 'agent-doc-assoc-id' },{agentId: 'agent-1',@@ -235,39 +220,10 @@ describe('AgentDocumentsExecutionRuntime.createDocument', () => {code: 'CURRENT_PAGE_DOCUMENT_WRITE_FORBIDDEN',kind: 'replan',});- expect(stub.editDocument).not.toHaveBeenCalled();- });-- it('blocks upsertDocumentByFilename when the filename resolves to the current page document', async () => {- const stub = makeStub();- stub.listDocuments.mockResolvedValue([- {- documentId: 'documents-row-id',- filename: 'current-doc.md',- id: 'agent-doc-assoc-id',- title: 'Current Doc',- },- ]);-- const runtime = new AgentDocumentsExecutionRuntime(stub);- const result = await runtime.upsertDocumentByFilename(- { content: 'updated', filename: 'current-doc.md' },- {- agentId: 'agent-1',- currentDocumentId: 'documents-row-id',- scope: 'page',- },- );-- expect(result.success).toBe(false);- expect(result.error).toMatchObject({- code: 'CURRENT_PAGE_DOCUMENT_WRITE_FORBIDDEN',- kind: 'replan',- });- expect(stub.upsertDocumentByFilename).not.toHaveBeenCalled();+ expect(stub.replaceDocumentContent).not.toHaveBeenCalled();});- it('still allows editing a different agent document in page scope', async () => {+ it('still allows replacing a different agent document in page scope', async () => {const stub = makeStub();stub.readDocument.mockResolvedValue({content: 'body',@@ -275,7 +231,7 @@ describe('AgentDocumentsExecutionRuntime.createDocument', () => {id: 'agent-doc-assoc-id-2',title: 'Other Doc',});- stub.editDocument.mockResolvedValue({+ stub.replaceDocumentContent.mockResolvedValue({content: 'updated',documentId: 'documents-row-id-2',id: 'agent-doc-assoc-id-2',@@ -283,7 +239,7 @@ describe('AgentDocumentsExecutionRuntime.createDocument', () => {});const runtime = new AgentDocumentsExecutionRuntime(stub);- const result = await runtime.editDocument(+ const result = await runtime.replaceDocumentContent({ content: 'updated', id: 'agent-doc-assoc-id-2' },{agentId: 'agent-1',@@ -293,7 +249,7 @@ describe('AgentDocumentsExecutionRuntime.createDocument', () => {);expect(result.success).toBe(true);- expect(stub.editDocument).toHaveBeenCalledWith({+ expect(stub.replaceDocumentContent).toHaveBeenCalledWith({agentId: 'agent-1',content: 'updated',id: 'agent-doc-assoc-id-2',@@ -306,16 +262,14 @@ describe('AgentDocumentsExecutionRuntime.listDocuments', () => {copyDocument: vi.fn(),createDocument: vi.fn(),createTopicDocument: vi.fn(),- editDocument: vi.fn(),listDocuments: vi.fn(),listTopicDocuments: vi.fn(),modifyNodes: vi.fn(),readDocument: vi.fn(),- readDocumentByFilename: vi.fn(),removeDocument: vi.fn(),renameDocument: vi.fn(),+ replaceDocumentContent: vi.fn(),updateLoadRule: vi.fn(),- upsertDocumentByFilename: vi.fn(),});it('lists current topic documents while preserving agent document ids', async () => {diff --git a/src/server/services/toolExecution/serverRuntimes/agentDocuments.ts b/src/server/services/toolExecution/serverRuntimes/agentDocuments.tsindex d55b3b8372f..2f77256746d 100644--- a/src/server/services/toolExecution/serverRuntimes/agentDocuments.ts+++ b/src/server/services/toolExecution/serverRuntimes/agentDocuments.ts@@ -31,7 +31,6 @@ export const agentDocumentsRuntime: ServerRuntimeRegistration = {pinToTask(await service.createDocument(agentId, title, content)),createTopicDocument: async ({ agentId, content, title, topicId }) =>pinToTask(await service.createForTopic(agentId, title, content, topicId)),- editDocument: ({ agentId, content, id }) => service.editDocumentById(id, content, agentId),listDocuments: async ({ agentId }) => {const docs = await service.listDocuments(agentId);return docs.map((d) => ({@@ -53,19 +52,17 @@ export const agentDocumentsRuntime: ServerRuntimeRegistration = {modifyNodes: ({ agentId, id, operations }) =>service.modifyDocumentNodesById(id, operations, agentId),readDocument: ({ agentId, id }) => service.getDocumentSnapshotById(id, agentId),- readDocumentByFilename: ({ agentId, filename }) =>- service.getDocumentSnapshotByFilename(agentId, filename),removeDocument: ({ agentId, id }) => service.removeDocumentById(id, agentId),renameDocument: ({ agentId, id, newTitle }) =>service.renameDocumentById(id, newTitle, agentId),+ replaceDocumentContent: ({ agentId, content, id }) =>+ service.replaceDocumentContentById(id, content, agentId),updateLoadRule: ({ agentId, id, rule }) =>service.updateLoadRuleById(id,{ ...rule, rule: rule.rule as DocumentLoadRule | undefined },agentId,),- upsertDocumentByFilename: async ({ agentId, content, filename }) =>- pinToTask(await service.upsertDocumentByFilename({ agentId, content, filename })),});},identifier: AgentDocumentsIdentifier,diff --git a/src/services/agentDocument.test.ts b/src/services/agentDocument.test.tsindex 00d1d0fd519..212ce2bffaa 100644--- a/src/services/agentDocument.test.ts+++ b/src/services/agentDocument.test.ts@@ -21,17 +21,15 @@ vi.mock('@/libs/trpc/client', () => ({agentDocument: {copyDocument: { mutate: queryMock },createDocument: { mutate: queryMock },- editDocument: { mutate: queryMock },getDocuments: { query: queryMock },getTemplates: { query: queryMock },initializeFromTemplate: { mutate: queryMock },listDocuments: { query: queryMock },readDocument: { query: queryMock },- readDocumentByFilename: { query: queryMock },removeDocument: { mutate: queryMock },renameDocument: { mutate: queryMock },+ replaceDocumentContent: { mutate: queryMock },updateLoadRule: { mutate: queryMock },- upsertDocumentByFilename: { mutate: queryMock },},},}));diff --git a/src/services/agentDocument.ts b/src/services/agentDocument.tsindex b3e7228279b..19bad82c140 100644--- a/src/services/agentDocument.ts+++ b/src/services/agentDocument.ts@@ -63,30 +63,6 @@ class AgentDocumentService {return lambdaClient.agentDocument.listDocuments.query(params);};- readDocumentByFilename = async (params: {- agentId: string;- filename: string;- format?: 'xml' | 'markdown' | 'both';- }) => {- return lambdaClient.agentDocument.readDocumentByFilename.query(params);- };-- upsertDocumentByFilename = async (params: {- agentId: string;- content: string;- filename: string;- }) => {- const result = await lambdaClient.agentDocument.upsertDocumentByFilename.mutate(params);- await invalidateDocumentMutation({- agentDocumentId: getAgentDocumentId(result),- agentId: params.agentId,- cause: 'agent-document',- documentId: getDocumentId(result),- });-- return result;- };-associateDocument = async (params: { agentId: string; documentId: string }) => {const result = await lambdaClient.agentDocument.associateDocument.mutate(params);await invalidateDocumentMutation({@@ -137,8 +113,8 @@ class AgentDocumentService {return lambdaClient.agentDocument.readDocument.query(params);};- editDocument = async (params: { agentId: string; content: string; id: string }) => {- const result = await lambdaClient.agentDocument.editDocument.mutate(params);+ replaceDocumentContent = async (params: { agentId: string; content: string; id: string }) => {+ const result = await lambdaClient.agentDocument.replaceDocumentContent.mutate(params);await invalidateDocumentMutation({agentDocumentId: params.id,agentId: params.agentId,diff --git a/src/services/chat/mecha/toolSetComposer.test.ts b/src/services/chat/mecha/toolSetComposer.test.tsindex be336307d18..e06122f3027 100644--- a/src/services/chat/mecha/toolSetComposer.test.ts+++ b/src/services/chat/mecha/toolSetComposer.test.ts@@ -45,7 +45,7 @@ describe('composeEnabledTools', () => {});it('dedupes injected manifests by identifier', () => {- const duplicate = makeManifest('lobe-agent-documents', 'editDocument');+ const duplicate = makeManifest('lobe-agent-documents', 'replaceDocumentContent');const result = composeEnabledTools({context: {},@@ -55,7 +55,9 @@ describe('composeEnabledTools', () => {expect(result.enabledToolIds).toEqual(['lobe-agent-documents']);expect(result.enabledManifests).toEqual([OTHER_MANIFEST]);- expect(result.tools?.some((t) => t.function?.name?.includes('editDocument'))).toBe(false);+ expect(result.tools?.some((t) => t.function?.name?.includes('replaceDocumentContent'))).toBe(+ false,+ );});it('appends new injected manifest and adds its tools', () => {diff --git a/src/store/chat/slices/plugin/action.test.ts b/src/store/chat/slices/plugin/action.test.tsindex da3c0c9015b..d22e3a2fdc3 100644--- a/src/store/chat/slices/plugin/action.test.ts+++ b/src/store/chat/slices/plugin/action.test.ts@@ -429,7 +429,7 @@ describe('ChatPluginAction', () => {const payload = {identifier: 'lobe-agent-documents',- apiName: 'editDocument',+ apiName: 'replaceDocumentContent',arguments: JSON.stringify({ content: 'test', id: 'agent-document-id' }),type: 'builtin',} as ChatToolPayload;diff --git a/src/store/tool/slices/builtin/executors/lobe-agent-documents.ts b/src/store/tool/slices/builtin/executors/lobe-agent-documents.tsindex e2dad4ab4c5..4c83555b538 100644--- a/src/store/tool/slices/builtin/executors/lobe-agent-documents.ts+++ b/src/store/tool/slices/builtin/executors/lobe-agent-documents.ts@@ -11,8 +11,6 @@ const runtime = new AgentDocumentsExecutionRuntime({agentDocumentService.createDocument({ agentId, content, title }),createTopicDocument: ({ agentId, content, title, topicId }) =>agentDocumentService.createForTopic({ agentId, content, title, topicId }),- editDocument: ({ agentId, content, id }) =>- agentDocumentService.editDocument({ agentId, content, id }),listDocuments: async ({ agentId }) => {const docs = await agentDocumentService.listDocuments({ agentId });return docs.map((d) => ({@@ -39,12 +37,12 @@ const runtime = new AgentDocumentsExecutionRuntime({agentDocumentService.modifyNodes({ agentId, id, operations }),readDocument: ({ agentId, format, id }) =>agentDocumentService.readDocument({ agentId, format: format ?? 'xml', id }),- readDocumentByFilename: ({ agentId, filename, format }) =>- agentDocumentService.readDocumentByFilename({ agentId, filename, format: format ?? 'xml' }),removeDocument: async ({ agentId, id }) =>(await agentDocumentService.removeDocument({ agentId, id })).deleted,renameDocument: ({ agentId, id, newTitle }) =>agentDocumentService.renameDocument({ agentId, id, newTitle }),+ replaceDocumentContent: ({ agentId, content, id }) =>+ agentDocumentService.replaceDocumentContent({ agentId, content, id }),updateLoadRule: ({ agentId, id, rule }) =>agentDocumentService.updateLoadRule({agentId,@@ -55,8 +53,6 @@ const runtime = new AgentDocumentsExecutionRuntime({rule: rule.rule as DocumentLoadRule | undefined,},}),- upsertDocumentByFilename: ({ agentId, content, filename }) =>- agentDocumentService.upsertDocumentByFilename({ agentId, content, filename }),});export const agentDocumentsExecutor = new AgentDocumentsExecutor(runtime);