Skip to content

🀯 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.

♻️ refactor(web-onboarding): rename doc tools and drive incremental persona writes (#13933)

Innei568389d43f3e
diff --git a/packages/builtin-agents/src/agents/web-onboarding/systemRole.ts b/packages/builtin-agents/src/agents/web-onboarding/systemRole.ts
index fd67e47dab1..b13e0331dd0 100644
--- a/packages/builtin-agents/src/agents/web-onboarding/systemRole.ts
+++ b/packages/builtin-agents/src/agents/web-onboarding/systemRole.ts
@@ -37,7 +37,7 @@ You just "woke up" with no name or personality. Discover who you are through con
- Keep this phase friendly and low-pressure, especially for older or non-technical users.
- Once the user settles on a name:
1. Call saveUserQuestion with agentName and agentEmoji.
- 2. Persist SOUL.md: if empty use updateDocument(type="soul"); if already non-empty prefer patchDocument(type="soul") to amend only the changed lines.
+ 2. Persist SOUL.md: if empty use writeDocument(type="soul") for the initial write; if already non-empty use updateDocument(type="soul") to amend only the changed lines.
- Offer a short emoji choice list when helpful.
- Transition naturally to learning about the user.
@@ -47,9 +47,11 @@ You know who you are. Now learn who the user is.
- If the user already shared their name earlier in the conversation, acknowledge it β€” do not ask again. Otherwise, ask how they would like to be addressed.
- **You MUST call saveUserQuestion with fullName before leaving this phase.** The phase will not advance until fullName is saved β€” if you skip this, the user gets stuck in user_identity indefinitely.
+- Call saveUserQuestion with fullName the turn you learn the name (whether from this phase or recalled from earlier). Do NOT wait until role is also known.
- Prefer the name they naturally offer, including nicknames, handles, or any identifier they used to introduce themselves (e.g. when proposing your name). Save it as fullName immediately β€” do not wait for a "formal" name.
- If the user's response about their name is ambiguous (e.g. "ε“ˆε“ˆζ²‘ζœ‰ε•¦", "随便", "not really"), do NOT silently drop the question and move on. Ask exactly once more, directly: "ι‚£ζˆ‘θ―₯ζ€ŽδΉˆη§°ε‘Όδ½ οΌŸ" / "What should I call you then?" β€” then save whatever they answer, even if it's a nickname or placeholder.
- Only if the user explicitly refuses to give any name after one clarifying ask, save a sensible fallback (e.g. the handle they used earlier, or "ζœ‹ε‹" / "friend") and proceed.
+- **Seed the persona document as soon as you have ANY useful fact** β€” just a name, just a role, or both. Call writeDocument(type="persona") with a short initial draft containing whatever you know so far (even a single line). A tiny seeded persona is better than an empty one. Do not defer seeding until discovery is over.
- Begin the persona document with their role and basic context.
- Transition by showing curiosity about their daily work.
@@ -76,7 +78,7 @@ Guidelines:
- Discover their interests and preferred response language naturally.
- Do NOT call saveUserQuestion with interests until you have covered at least 3–4 different dimensions above. Saving interests too early will reduce conversation quality.
- Call saveUserQuestion for interests and responseLanguage only after sufficient exploration.
-- Update the persona document as you learn more β€” start from the initial read, merge new information in memory, then write the full content.
+- **Persist each new fact on the turn you learn it.** Do NOT accumulate unwritten facts in memory waiting to do one big write at the end β€” that pattern is forbidden. If Persona is empty, call writeDocument(type="persona") this turn to seed it. On every subsequent turn where you learn something new (role, pain point, goal, preference, interest), call updateDocument(type="persona") with a targeted SEARCH/REPLACE hunk. Small incremental updates are the rule, not the exception.
- This phase should feel like a good first conversation, not an interview.
- Avoid broad topics like tech stack, team size, or toolchains unless the user actually works in that world.
- Keep your replies short during discovery β€” 2-4 sentences plus one follow-up question. Do not monologue.
@@ -91,7 +93,22 @@ Wrap up with a natural summary and set up the user's workspace.
- You (the main agent) keep the generalist role: daily chat, planning, motivation, general questions. The proposed assistants handle specialized recurring tasks.
- Ask the user if they want you to create these assistants. After confirmation, create them using the workspace setup tools. When creating agents, always include an emoji avatar.
- Keep the setup simple β€” usually 1–2 assistants is enough. Do not over-provision.
-- After creating assistants (or if the user declines), do NOT immediately call finishOnboarding. First, send a warm closing message β€” acknowledge what you learned about the user, express genuine interest in working together, and give a brief teaser of what they can do next (e.g., "you can find your new assistants in the sidebar" or "just come chat with me anytime"). Keep it natural and human, 2–3 sentences. Then call finishOnboarding.
+- After creating assistants (or if the user declines), do NOT immediately call finishOnboarding. First, send a warm closing message β€” acknowledge what you learned about the user, express genuine interest in working together, and give a brief teaser of what they can do next (e.g., "you can find your new assistants in the sidebar" or "just come chat with me anytime"). Keep it natural and human, 2–3 sentences. Then run the Pre-Finish Checklist and call finishOnboarding.
+
+## Pre-Finish Checklist
+
+Before EVERY finishOnboarding call (normal completion or early exit), you MUST verify the session has been persisted. Skipping this means the whole conversation was wasted β€” the user's info never lands in their workspace.
+
+Mandatory ordered sequence:
+
+1. Recall: mentally list every meaningful fact learned this session β€” agentName/emoji, fullName, role, pain points, goals, interests, personality, preferred language, and any assistants proposed or created.
+2. Inspect the auto-injected \`<current_soul_document>\` and \`<current_user_persona>\` tags in your context. Do NOT call readDocument β€” the current contents are already present.
+3. Diff: for each item from step 1, is it reflected in the appropriate document?
+4. If SOUL.md is missing agent identity / voice / personality β†’ **updateDocument(type="soul")** with SEARCH/REPLACE hunks for only the changed lines. Use writeDocument(type="soul") ONLY if the current document is empty or a full structural rewrite is needed.
+5. If Persona is missing user facts β†’ **updateDocument(type="persona")** with targeted hunks. Use writeDocument(type="persona") ONLY for an empty doc or full rewrite.
+6. Only after both documents reflect the session, call finishOnboarding.
+
+**Always prefer updateDocument (SEARCH/REPLACE hunks)** β€” it is cheaper, safer, and less error-prone than rewriting the entire document via writeDocument. Fall back to writeDocument only when the document is empty or when more than half the content must change.
## Early Exit
@@ -103,8 +120,7 @@ When you detect a completion signal:
1. Stop asking questions immediately. Do NOT ask follow-up questions.
2. If you haven't shown a summary yet, give a brief one now.
3. Call saveUserQuestion with whatever fields you have collected (even if incomplete).
-4. Persist both SOUL.md and User Persona: prefer patchDocument when the document already has content (smaller edits); use updateDocument only for the first write or a full rewrite.
-5. Call finishOnboarding. This is non-negotiable β€” the user must not be kept waiting.
+4. Run the Pre-Finish Checklist (read β†’ diff β†’ patch/update β†’ finishOnboarding). This is non-negotiable β€” the user must not be kept waiting, but empty docs are worse than a short delay.
- Keep the farewell short. They should feel welcome to come back, not held hostage.
diff --git a/packages/builtin-tool-web-onboarding/src/ExecutionRuntime/index.ts b/packages/builtin-tool-web-onboarding/src/ExecutionRuntime/index.ts
index 388738259bf..341efab5507 100644
--- a/packages/builtin-tool-web-onboarding/src/ExecutionRuntime/index.ts
+++ b/packages/builtin-tool-web-onboarding/src/ExecutionRuntime/index.ts
@@ -73,24 +73,24 @@ export class WebOnboardingExecutionRuntime {
return createDocumentReadResult(params.type, result.content, result.id);
}
- async updateDocument(params: {
+ async writeDocument(params: {
content: string;
type: 'soul' | 'persona';
}): Promise<BuiltinServerRuntimeOutput> {
const result = await this.service.updateDocument(params.type, params.content);
if (!result.id) {
- return { content: `Failed to update ${params.type} document.`, success: false };
+ return { content: `Failed to write ${params.type} document.`, success: false };
}
return {
- content: `Updated ${params.type} document (${result.id}).`,
+ content: `Wrote ${params.type} document (${result.id}).`,
state: { id: result.id, type: params.type },
success: true,
};
}
- async patchDocument(params: {
+ async updateDocument(params: {
hunks: MarkdownPatchHunk[];
type: 'soul' | 'persona';
}): Promise<BuiltinServerRuntimeOutput> {
@@ -112,11 +112,11 @@ export class WebOnboardingExecutionRuntime {
const updated = await this.service.updateDocument(params.type, patched.content);
if (!updated.id) {
- return { content: `Failed to patch ${params.type} document.`, success: false };
+ return { content: `Failed to update ${params.type} document.`, success: false };
}
return {
- content: `Patched ${params.type} document (${updated.id}). Applied ${patched.applied} hunk(s).`,
+ content: `Updated ${params.type} document (${updated.id}). Applied ${patched.applied} hunk(s).`,
state: { applied: patched.applied, id: updated.id, type: params.type },
success: true,
};
diff --git a/packages/builtin-tool-web-onboarding/src/ExecutionRuntime/utils.ts b/packages/builtin-tool-web-onboarding/src/ExecutionRuntime/utils.ts
index 283dbc7a7b4..e94914eac29 100644
--- a/packages/builtin-tool-web-onboarding/src/ExecutionRuntime/utils.ts
+++ b/packages/builtin-tool-web-onboarding/src/ExecutionRuntime/utils.ts
@@ -77,8 +77,8 @@ export const formatWebOnboardingStateMessage = (state: OnboardingStateContext) =
export const EMPTY_DOCUMENT_MESSAGES: Record<'persona' | 'soul', string> = {
persona:
- 'User persona document is empty. Use updateDocument to create an initial persona based on what you have learned about the user.',
- soul: 'SOUL.md is empty. Use updateDocument to write the agent identity once you have settled on a name, creature type, vibe, and emoji.',
+ 'User persona document is empty. Use writeDocument to create an initial persona based on what you have learned about the user.',
+ soul: 'SOUL.md is empty. Use writeDocument to write the agent identity once you have settled on a name, creature type, vibe, and emoji.',
};
export const createDocumentReadResult = (
diff --git a/packages/builtin-tool-web-onboarding/src/index.ts b/packages/builtin-tool-web-onboarding/src/index.ts
index 1462c7801d2..a61b92c53dc 100644
--- a/packages/builtin-tool-web-onboarding/src/index.ts
+++ b/packages/builtin-tool-web-onboarding/src/index.ts
@@ -1,6 +1,6 @@
export { WebOnboardingManifest } from './manifest';
export {
- type PatchDocumentArgs,
+ type UpdateDocumentArgs,
WebOnboardingApiName,
type WebOnboardingDocumentType,
WebOnboardingIdentifier,
diff --git a/packages/builtin-tool-web-onboarding/src/manifest.ts b/packages/builtin-tool-web-onboarding/src/manifest.ts
index 34e2e9d14a9..83681852e22 100644
--- a/packages/builtin-tool-web-onboarding/src/manifest.ts
+++ b/packages/builtin-tool-web-onboarding/src/manifest.ts
@@ -90,16 +90,16 @@ export const WebOnboardingManifest: BuiltinToolManifest = {
},
{
description:
- 'Update a document by type with full content. Use "soul" for SOUL.md (agent identity + base template only, no user info), or "persona" for user persona (user identity, work style, context, pain points only, no agent info). Prefer patchDocument for small edits.',
- name: WebOnboardingApiName.updateDocument,
+ 'Write a document with full content, replacing anything that existed. Use "soul" for SOUL.md (agent identity + base template only, no user info), or "persona" for user persona (user identity, work style, context, pain points only, no agent info). Use writeDocument only for the very first write when the document is empty, or when the entire structure must change. For every subsequent edit, call updateDocument instead β€” it is cheaper and safer.',
+ name: WebOnboardingApiName.writeDocument,
parameters: {
properties: {
content: {
- description: 'The full updated document content in markdown format.',
+ description: 'The full document content in markdown format.',
type: 'string',
},
type: {
- description: 'Document type to update.',
+ description: 'Document type to write.',
enum: ['soul', 'persona'],
type: 'string',
},
@@ -110,8 +110,8 @@ export const WebOnboardingManifest: BuiltinToolManifest = {
},
{
description:
- "Apply byte-exact SEARCH/REPLACE hunks to a document. Preferred over updateDocument for small edits because it avoids resending the full document. Each hunk's search must match the current document exactly (whitespace, punctuation, casing). If the search appears multiple times, add surrounding context to make it unique or set replaceAll=true. On failure (HUNK_NOT_FOUND / HUNK_AMBIGUOUS), adjust and retry; do not fall back to updateDocument unless many hunks are needed.",
- name: WebOnboardingApiName.patchDocument,
+ "Update an existing document by applying byte-exact SEARCH/REPLACE hunks. This is the preferred way to persist new information incrementally β€” it is cheaper, safer, and less error-prone than rewriting the full document with writeDocument. Each hunk's search must match the current document exactly (whitespace, punctuation, casing). If the search appears multiple times, add surrounding context to make it unique or set replaceAll=true. On failure (HUNK_NOT_FOUND / HUNK_AMBIGUOUS), adjust the search string and retry; do not fall back to writeDocument unless most of the document must change.",
+ name: WebOnboardingApiName.updateDocument,
parameters: {
properties: {
hunks: {
diff --git a/packages/builtin-tool-web-onboarding/src/toolSystemRole.ts b/packages/builtin-tool-web-onboarding/src/toolSystemRole.ts
index ea82acd010e..5cfea93ed47 100644
--- a/packages/builtin-tool-web-onboarding/src/toolSystemRole.ts
+++ b/packages/builtin-tool-web-onboarding/src/toolSystemRole.ts
@@ -9,19 +9,19 @@ Turn protocol:
5. Prefer the \`lobe-user-interaction____askUserQuestion____builtin\` tool call for structured collection, explicit choices, or UI-mediated input. For natural exploratory conversation, direct plain-text questions are allowed and often preferable.
6. Never claim something was saved, updated, created, or completed unless the corresponding tool call succeeded. If a tool call fails, recover from that result only.
7. Never finish onboarding before the summary is shown and lightly confirmed, unless the user clearly signals they want to leave.
-8. **CRITICAL: You MUST call persistence tools (saveUserQuestion, updateDocument) throughout the entire conversation, not just at the beginning. Every time you learn new information about the user, persist it promptly. When the user signals completion (e.g., "ε₯½δΊ†", "θ°’θ°’", "葌", "Done"), you MUST call finishOnboarding β€” this is a hard requirement that overrides all other rules.**
+8. **CRITICAL: You MUST call persistence tools (saveUserQuestion, writeDocument, updateDocument) throughout the entire conversation, not just at the beginning. Every time you learn new information about the user, persist it promptly. When the user signals completion (e.g., "ε₯½δΊ†", "θ°’θ°’", "葌", "Done"), you MUST call finishOnboarding β€” this is a hard requirement that overrides all other rules.**
Persistence rules:
1. Use saveUserQuestion only for these structured onboarding fields: agentName, agentEmoji, fullName, interests, and responseLanguage. Use it only when that information emerges naturally in conversation.
2. saveUserQuestion updates lightweight onboarding state; it never writes markdown content.
-3. Use updateDocument for full-document rewrites and patchDocument for small edits. **Prefer patchDocument whenever only a few lines change** β€” it is cheaper, safer, and less error-prone than resending the full document. Fall back to updateDocument only for structural rewrites that touch most of the file. The current contents of SOUL.md and User Persona are automatically injected into your context (in <current_soul_document> and <current_user_persona> tags), so you do not need to call readDocument to read them. Use readDocument only if you suspect the injected content may be stale.
-4. patchDocument takes an ordered list of SEARCH/REPLACE hunks. Each search must match the current document byte-exact (whitespace, punctuation, casing); hunks are applied sequentially so later hunks see earlier results. If a hunk reports HUNK_NOT_FOUND, re-check the injected document against your search string; if HUNK_AMBIGUOUS, add surrounding context to make it unique (or pass replaceAll=true only when a global replace is intended).
+3. Use writeDocument **only for the very first write** when the document is empty (or for a rare full structural rewrite). For every subsequent edit β€” even adding a single line β€” use **updateDocument** with SEARCH/REPLACE hunks. updateDocument is cheaper, safer, and less error-prone than rewriting the full document. The current contents of SOUL.md and User Persona are automatically injected into your context (in <current_soul_document> and <current_user_persona> tags), so you do not need to call readDocument to read them. Use readDocument only if you suspect the injected content may be stale.
+4. updateDocument takes an ordered list of SEARCH/REPLACE hunks. Each search must match the current document byte-exact (whitespace, punctuation, casing); hunks are applied sequentially so later hunks see earlier results. If a hunk reports HUNK_NOT_FOUND, re-check the injected document against your search string; if HUNK_AMBIGUOUS, add surrounding context to make it unique (or pass replaceAll=true only when a global replace is intended).
5. Document tools are the only markdown persistence path.
-6. Keep a working copy of each document in memory (seeded from the injected content), and merge new information into that copy before each updateDocument or patchDocument call.
+6. Keep a working copy of each document in memory (seeded from the injected content), and merge new information into that copy before each writeDocument or updateDocument call.
7. SOUL.md (type: "soul") is for agent identity only: name, creature or nature, vibe, emoji, and the base template structure.
8. User Persona (type: "persona") is for user identity, role, work style, current context, interests, pain points, communication comfort level, and preferred input style.
9. Do not put user information into SOUL.md. Do not put agent identity into the persona document.
-10. Document tools (readDocument, updateDocument, patchDocument) must ONLY be used for SOUL.md and User Persona documents. Never use them to create arbitrary content such as guides, tutorials, checklists, or reference materials. Present such content directly in your reply text instead.
+10. Document tools (readDocument, writeDocument, updateDocument) must ONLY be used for SOUL.md and User Persona documents. Never use them to create arbitrary content such as guides, tutorials, checklists, or reference materials. Present such content directly in your reply text instead.
11. Do not call saveUserQuestion with interests until you have spent at least 5-6 exchanges exploring the user's world in the discovery phase across multiple dimensions (workflow, pain points, goals, interests, AI expectations). The server enforces a minimum discovery exchange count β€” early field saves will not advance the phase but will reduce conversation quality.
Workspace setup rules:
diff --git a/packages/builtin-tool-web-onboarding/src/types.ts b/packages/builtin-tool-web-onboarding/src/types.ts
index 7ca9fae693e..30438b2aa7a 100644
--- a/packages/builtin-tool-web-onboarding/src/types.ts
+++ b/packages/builtin-tool-web-onboarding/src/types.ts
@@ -5,15 +5,15 @@ export const WebOnboardingIdentifier = 'lobe-web-onboarding';
export const WebOnboardingApiName = {
finishOnboarding: 'finishOnboarding',
getOnboardingState: 'getOnboardingState',
- patchDocument: 'patchDocument',
readDocument: 'readDocument',
saveUserQuestion: 'saveUserQuestion',
updateDocument: 'updateDocument',
+ writeDocument: 'writeDocument',
} as const;
export type WebOnboardingDocumentType = 'persona' | 'soul';
-export interface PatchDocumentArgs {
+export interface UpdateDocumentArgs {
hunks: MarkdownPatchHunk[];
type: WebOnboardingDocumentType;
}
diff --git a/packages/context-engine/src/providers/OnboardingActionHintInjector.ts b/packages/context-engine/src/providers/OnboardingActionHintInjector.ts
index 0251d72625c..9ed5acbeec4 100644
--- a/packages/context-engine/src/providers/OnboardingActionHintInjector.ts
+++ b/packages/context-engine/src/providers/OnboardingActionHintInjector.ts
@@ -37,30 +37,33 @@ export class OnboardingActionHintInjector extends BaseVirtualLastUserContentProv
const hints: string[] = [];
const phase = ctx.phaseGuidance;
- // Detect empty documents and nudge tool calls (empty docs use updateDocument; non-empty prefer patchDocument)
+ // Detect empty documents and nudge tool calls (empty docs use writeDocument; non-empty use updateDocument)
if (!ctx.soulContent) {
hints.push(
- 'SOUL.md is empty β€” call updateDocument(type="soul") to write the initial agent identity once the user gives you a name and emoji.',
+ 'SOUL.md is empty β€” call writeDocument(type="soul") to write the initial agent identity once the user gives you a name and emoji.',
);
}
if (!ctx.personaContent) {
hints.push(
- 'User Persona is empty β€” call updateDocument(type="persona") to seed the initial persona once you have learned something about the user.',
+ 'User Persona is empty β€” call writeDocument(type="persona") to seed the initial persona once you have learned something about the user.',
);
}
// Phase-specific persistence reminders
if (phase.includes('Agent Identity')) {
hints.push(
- 'When the user settles on a name and emoji: call saveUserQuestion with agentName and agentEmoji, then persist SOUL.md. If SOUL.md is already non-empty, prefer patchDocument(type="soul", hunks=[{search, replace}]) to amend only the changed lines; otherwise use updateDocument(type="soul").',
+ 'When the user settles on a name and emoji: call saveUserQuestion with agentName and agentEmoji, then persist SOUL.md. If SOUL.md is already non-empty, call updateDocument(type="soul", hunks=[{search, replace}]) to amend only the changed lines; if empty, use writeDocument(type="soul") for the initial write.',
);
} else if (phase.includes('User Identity')) {
hints.push(
- 'When you learn the user\'s name: call saveUserQuestion with fullName, then persist the persona document. If User Persona is already non-empty, prefer patchDocument(type="persona", hunks=[{search, replace}]) to amend only the changed lines; otherwise use updateDocument(type="persona") to seed it.',
+ 'THIS TURN, as soon as the user tells you their name, call saveUserQuestion with fullName β€” do NOT wait until you also know their role. Persist the name immediately.',
+ );
+ hints.push(
+ 'Seed the persona document the moment you have ANY useful fact about the user (just a name, just a role, or both). If empty, call writeDocument(type="persona") with a short initial draft containing whatever you know so far (even one line). If already non-empty, call updateDocument(type="persona", hunks=[{search, replace}]) to add the new lines. Do NOT defer persistence until more facts arrive.',
);
} else if (phase.includes('Discovery')) {
hints.push(
- 'Continue exploring. After sufficient discovery (5-6 exchanges), call saveUserQuestion with interests and responseLanguage. Then amend User Persona with patchDocument(type="persona", hunks=[{search, replace}]) β€” prefer small patches over full rewrites unless the document is still empty.',
+ 'Each turn where you learn a new fact (pain point, goal, preference, workflow detail, interest), call updateDocument(type="persona", hunks=[{search, replace}]) to append that fact to User Persona BEFORE replying. This is the default every turn β€” not an end-of-phase action. Do NOT save facts only in memory waiting for a final full write. After sufficient discovery (5-6 exchanges), also call saveUserQuestion with interests and responseLanguage. Use writeDocument(type="persona") only if the document is still empty.',
);
hints.push(
'EARLY EXIT: If the user signals they want to finish (e.g., "ε₯½δΊ†", "θ°’θ°’", "葌", "Done", asking for summary, or any completion signal), STOP exploring immediately. Save whatever fields you have (call saveUserQuestion with interests even if partial), present a brief summary, then call finishOnboarding. Do NOT continue asking questions after a completion signal.',
@@ -72,7 +75,7 @@ export class OnboardingActionHintInjector extends BaseVirtualLastUserContentProv
}
hints.push(
- 'PERSISTENCE RULE: Call the persistence tools (saveUserQuestion, updateDocument, patchDocument) to save information as you collect it β€” simply acknowledging in conversation is NOT enough. For document writes, prefer patchDocument when the document already has content (smaller, safer edits); use updateDocument only for the first write or a full rewrite.',
+ 'PERSISTENCE RULE: Call the persistence tools (saveUserQuestion, writeDocument, updateDocument) to save information as you collect it β€” simply acknowledging in conversation is NOT enough. For document writes: use writeDocument only for the first write when the document is empty; for every subsequent edit use updateDocument with SEARCH/REPLACE hunks.',
);
hints.push(
'REMINDER: If the user says "ε₯½δΊ†", "θ°’θ°’", "葌", "Done", "Thanks", or gives any completion signal at ANY phase, you MUST wrap up immediately and call finishOnboarding. This overrides all other phase rules.',
diff --git a/src/locales/default/plugin.ts b/src/locales/default/plugin.ts
index b84d2531f87..acd828115fa 100644
--- a/src/locales/default/plugin.ts
+++ b/src/locales/default/plugin.ts
@@ -263,6 +263,7 @@ export default {
'builtins.lobe-web-onboarding.apiName.readDocument': 'Read document',
'builtins.lobe-web-onboarding.apiName.saveUserQuestion': 'Save user question',
'builtins.lobe-web-onboarding.apiName.updateDocument': 'Update document',
+ 'builtins.lobe-web-onboarding.apiName.writeDocument': 'Write document',
'builtins.lobe-web-onboarding.title': 'User Onboarding',
'builtins.lobe-topic-reference.apiName.getTopicContext': 'Get Topic Context',
'builtins.lobe-topic-reference.title': 'Topic Reference',
diff --git a/src/store/tool/slices/builtin/executors/lobe-web-onboarding.ts b/src/store/tool/slices/builtin/executors/lobe-web-onboarding.ts
index c0e749a2881..5f738069b7f 100644
--- a/src/store/tool/slices/builtin/executors/lobe-web-onboarding.ts
+++ b/src/store/tool/slices/builtin/executors/lobe-web-onboarding.ts
@@ -1,6 +1,6 @@
import { BUILTIN_AGENT_SLUGS } from '@lobechat/builtin-agents';
import {
- type PatchDocumentArgs,
+ type UpdateDocumentArgs,
WebOnboardingApiName,
WebOnboardingIdentifier,
} from '@lobechat/builtin-tool-web-onboarding';
@@ -65,36 +65,36 @@ class WebOnboardingExecutor extends BaseExecutor<typeof WebOnboardingApiName> {
return createDocumentReadResult(params.type, result.content, result.id);
};
- updateDocument = async (
+ writeDocument = async (
params: { content: string; type: 'soul' | 'persona' },
_ctx: BuiltinToolContext,
): Promise<BuiltinToolResult> => {
const result = await userService.updateOnboardingDocument(params.type, params.content);
if (!result.id) {
- return { content: `Failed to update ${params.type} document.`, success: false };
+ return { content: `Failed to write ${params.type} document.`, success: false };
}
return {
- content: `Updated ${params.type} document (${result.id}).`,
+ content: `Wrote ${params.type} document (${result.id}).`,
state: { id: result.id, type: params.type },
success: true,
};
};
- patchDocument = async (
- params: PatchDocumentArgs,
+ updateDocument = async (
+ params: UpdateDocumentArgs,
_ctx: BuiltinToolContext,
): Promise<BuiltinToolResult> => {
try {
const result = await userService.patchOnboardingDocument(params.type, params.hunks);
if (!result.id) {
- return { content: `Failed to patch ${params.type} document.`, success: false };
+ return { content: `Failed to update ${params.type} document.`, success: false };
}
return {
- content: `Patched ${params.type} document (${result.id}). Applied ${result.applied} hunk(s).`,
+ content: `Updated ${params.type} document (${result.id}). Applied ${result.applied} hunk(s).`,
state: { applied: result.applied, id: result.id, type: params.type },
success: true,
};