π€― 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
import { INTEREST_AREA_KEYS } from '@lobechat/const';
import type { BuiltinToolManifest, HumanInterventionRule } from '@lobechat/types';
import { MARKETPLACE_CATEGORY_VALUES } from './agentMarketplace/types';
import { toolSystemPrompt } from './toolSystemRole';
import { WebOnboardingApiName, WebOnboardingIdentifier } from './types';
// Agent identity (name/emoji) surface a confirmation card;
// user profile fields (fullName) and interest saves bypass intervention.
const saveUserQuestionConfirmationRules: HumanInterventionRule[] = [
{
match: {
agentName: { pattern: '\\S', type: 'regex' },
},
policy: 'always',
},
{
match: {
agentEmoji: { pattern: '\\S', type: 'regex' },
},
policy: 'always',
},
{ policy: 'never' },
] satisfies HumanInterventionRule[];
export const WebOnboardingManifest: BuiltinToolManifest = {
api: [
{
description:
'Persist structured onboarding fields. agentName and agentEmoji (updates inbox agent title/avatar) require user confirmation; interests/customInterests saves run without confirmation.',
humanIntervention: saveUserQuestionConfirmationRules,
name: WebOnboardingApiName.saveUserQuestion,
parameters: {
additionalProperties: false,
properties: {
agentEmoji: {
description: 'Emoji avatar for the agent (updates inbox agent avatar).',
type: 'string',
},
agentName: {
description: 'Name for the agent (updates inbox agent title).',
type: 'string',
},
fullName: {
type: 'string',
},
customInterests: {
description:
'Specific freeform user interests that do not fit the predefined interest keys.',
items: {
type: 'string',
},
type: 'array',
},
interests: {
description: 'Predefined interest keys selected from the supported enum values.',
items: {
enum: [...INTEREST_AREA_KEYS],
type: 'string',
},
type: 'array',
},
},
type: 'object',
},
},
{
description:
'Finish onboarding once the summary is confirmed and the user is ready to proceed.',
name: WebOnboardingApiName.finishOnboarding,
parameters: {
properties: {},
type: 'object',
},
},
{
description:
'Read a document by type. Note: document contents are automatically injected into your system context (in <current_soul_document> and <current_user_persona> tags), so this tool is only needed as a fallback. Use "soul" for SOUL.md or "persona" for the user persona document.',
name: WebOnboardingApiName.readDocument,
parameters: {
properties: {
type: {
description: 'Document type to read.',
enum: ['soul', 'persona'],
type: 'string',
},
},
required: ['type'],
type: 'object',
},
},
{
description:
'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 document content in markdown format.',
type: 'string',
},
type: {
description: 'Document type to write.',
enum: ['soul', 'persona'],
type: 'string',
},
},
required: ['type', 'content'],
type: 'object',
},
},
{
description:
'Update an existing document by applying structured hunks **in a single call**. Preferred over writeDocument for every incremental edit β cheaper, safer, less error-prone.\n\n' +
'**BATCH RULE (mandatory):** put EVERY change you want to make this turn into the `hunks` array of ONE call. Do NOT call updateDocument multiple times in a row for the same document β sequential calls waste a full LLM round-trip each and are forbidden. If you have 4 things to record, send 1 call with 4 hunks, not 4 calls with 1 hunk.\n\n' +
'Each hunk picks ONE mode:\n' +
'- `replace` (default): byte-exact SEARCH β REPLACE. For small textual tweaks.\n' +
'- `delete`: remove the byte-exact SEARCH region.\n' +
'- `deleteLines`: drop lines [startLine, endLine] (1-based, inclusive). Use the line numbers shown in <current_*_document>.\n' +
'- `insertAt`: insert `content` before `line`. Use `line = totalLines + 1` to append to the end; `line = 1` to prepend.\n' +
'- `replaceLines`: replace lines [startLine, endLine] with `content`.\n' +
'Line-based hunks REQUIRE the line numbers from the injected <current_soul_document> / <current_user_persona> view. On failure (HUNK_NOT_FOUND / HUNK_AMBIGUOUS / LINE_OUT_OF_RANGE / LINE_OVERLAP), re-check the injected document and retry with corrected hunks; do NOT fall back to writeDocument unless most of the document must change.',
name: WebOnboardingApiName.updateDocument,
parameters: {
properties: {
hunks: {
description:
'Ordered list of hunks β pack ALL changes for this turn into this single array. Content-based hunks (replace/delete) run first in order; line-based hunks (deleteLines/insertAt/replaceLines) run afterward, highest line first. Calling updateDocument again in the next turn for changes you could have included here is forbidden.',
items: {
oneOf: [
{
additionalProperties: false,
properties: {
mode: { const: 'replace', type: 'string' },
replace: {
description: 'Replacement text; may be empty to delete the matched region.',
type: 'string',
},
replaceAll: {
description: 'Replace every occurrence of search. Defaults to false.',
type: 'boolean',
},
search: {
description: 'Byte-exact substring to locate in the current document.',
type: 'string',
},
},
required: ['search', 'replace'],
type: 'object',
},
{
additionalProperties: false,
properties: {
mode: { const: 'delete', type: 'string' },
replaceAll: { type: 'boolean' },
search: {
description: 'Byte-exact substring to remove.',
type: 'string',
},
},
required: ['mode', 'search'],
type: 'object',
},
{
additionalProperties: false,
properties: {
endLine: {
description: 'Inclusive 1-based end line.',
type: 'integer',
},
mode: { const: 'deleteLines', type: 'string' },
startLine: {
description: 'Inclusive 1-based start line.',
type: 'integer',
},
},
required: ['mode', 'startLine', 'endLine'],
type: 'object',
},
{
additionalProperties: false,
properties: {
content: {
description: 'Text to insert; may span multiple lines (use \\n).',
type: 'string',
},
line: {
description:
'1-based line to insert before. Use `totalLines + 1` to append to the end.',
type: 'integer',
},
mode: { const: 'insertAt', type: 'string' },
},
required: ['mode', 'line', 'content'],
type: 'object',
},
{
additionalProperties: false,
properties: {
content: {
description: 'Replacement text; may be empty to delete the range.',
type: 'string',
},
endLine: { type: 'integer' },
mode: { const: 'replaceLines', type: 'string' },
startLine: { type: 'integer' },
},
required: ['mode', 'startLine', 'endLine', 'content'],
type: 'object',
},
],
},
minItems: 1,
type: 'array',
},
type: {
description: 'Document type to patch.',
enum: ['soul', 'persona'],
type: 'string',
},
},
required: ['type', 'hunks'],
type: 'object',
},
},
{
description:
'Open an Agent Marketplace picker card in the UI, prioritizing tabs by the provided category hints. Returns the request in pending state.',
humanIntervention: 'always',
name: WebOnboardingApiName.showAgentMarketplace,
parameters: {
properties: {
categoryHints: {
description:
'One or more fixed MarketplaceCategory slugs used to move matching picker tabs to the front.',
items: {
enum: [...MARKETPLACE_CATEGORY_VALUES],
type: 'string',
},
minItems: 1,
type: 'array',
},
description: {
description: 'Optional secondary line shown below the prompt.',
type: 'string',
},
prompt: {
description:
'Short, natural sentence shown to the user explaining what the marketplace is for.',
type: 'string',
},
requestId: {
description: 'Unique identifier for this pick request.',
type: 'string',
},
},
required: ['categoryHints', 'prompt', 'requestId'],
type: 'object',
},
renderDisplayControl: 'collapsed',
},
{
description:
"Record the user's template selection for a pending pick request. Normally client-handled after the user submits in the UI.",
name: WebOnboardingApiName.submitAgentPick,
parameters: {
properties: {
requestId: { description: 'The pick request ID to submit.', type: 'string' },
selectedTemplateIds: {
description: 'Template IDs the user selected from the marketplace.',
items: { type: 'string' },
minItems: 1,
type: 'array',
},
},
required: ['requestId', 'selectedTemplateIds'],
type: 'object',
},
},
],
identifier: WebOnboardingIdentifier,
meta: {
avatar: 'π§',
description: 'Drive the web onboarding flow with a controlled agent runtime',
title: 'Web Onboarding',
},
systemRole: toolSystemPrompt,
type: 'builtin',
};