π€― 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
β¨ feat: implement builtin agents packages
arvinxx2255a7cc516f
diff --git a/packages/builtin-agents/package.json b/packages/builtin-agents/package.jsonnew file mode 100644index 00000000000..eb78384c0f2--- /dev/null+++ b/packages/builtin-agents/package.json@@ -0,0 +1,13 @@+{+ "name": "@lobechat/builtin-agents",+ "version": "1.0.0",+ "private": true,+ "main": "./src/index.ts",+ "dependencies": {+ "@lobechat/builtin-tool-agent-builder": "workspace:*",+ "@lobechat/builtin-tool-group-agent-builder": "workspace:*",+ "@lobechat/builtin-tool-group-management": "workspace:*",+ "@lobechat/builtin-tool-gtd": "workspace:*",+ "@lobechat/types": "workspace:*"+ }+}diff --git a/packages/builtin-agents/src/agents/group-supervisor/index.ts b/packages/builtin-agents/src/agents/group-supervisor/index.tsnew file mode 100644index 00000000000..d969f72ad20--- /dev/null+++ b/packages/builtin-agents/src/agents/group-supervisor/index.ts@@ -0,0 +1,42 @@+import { GroupManagementIdentifier } from '@lobechat/builtin-tool-group-management';+import { GTDIdentifier } from '@lobechat/builtin-tool-gtd';++import type { BuiltinAgentDefinition } from '../../types';+import { BUILTIN_AGENT_SLUGS } from '../../types';+import { supervisorSystemRole } from './systemRole';+import type { GroupSupervisorContext } from './type';++/**+ * Replace template variables in system role+ */+const resolveSystemRole = (ctx: GroupSupervisorContext): string => {+ return supervisorSystemRole.replace('{{GROUP_TITLE}}', ctx.groupTitle);+};++/**+ * Group Supervisor - orchestrates multi-agent group conversations+ *+ * The supervisor agent is responsible for:+ * - Strategically coordinating agent participation+ * - Ensuring natural conversation flow+ * - Matching user queries to appropriate agent expertise+ */+export const GROUP_SUPERVISOR: BuiltinAgentDefinition = {+ runtime: (ctx) => {+ const { groupSupervisorContext } = ctx;++ if (!groupSupervisorContext) {+ return { systemRole: '' };+ }++ return {+ chatConfig: {+ enableHistoryCount: false,+ },+ plugins: [GroupManagementIdentifier, GTDIdentifier, ...(ctx.plugins || [])],+ systemRole: resolveSystemRole(groupSupervisorContext),+ };+ },++ slug: BUILTIN_AGENT_SLUGS.groupSupervisor,+};diff --git a/packages/builtin-agents/src/agents/group-supervisor/systemRole.ts b/packages/builtin-agents/src/agents/group-supervisor/systemRole.tsnew file mode 100644index 00000000000..a47fa71c4d1--- /dev/null+++ b/packages/builtin-agents/src/agents/group-supervisor/systemRole.ts@@ -0,0 +1,63 @@+/**+ * System role template for Group Supervisor agent+ *+ * Variables (replaced by resolveSystemRole):+ * - {{GROUP_TITLE}} - The name/title of the group+ *+ * Variables (auto-injected by context-engine):+ * - {{date}} - Current date (e.g., "12/25/2023")+ * - {{model}} - Current model ID (requires LOBE-1803)+ * - {{provider}} - Current provider (requires LOBE-1803)+ */+export const supervisorSystemRole = `You are LobeAI, an intelligent team coordinator developed by LobeHub, powered by {{model}}. You are orchestrating the multi-agent group "{{GROUP_TITLE}}". Your primary responsibility is to facilitate productive, natural conversations by strategically coordinating when and how AI agents participate.++<system_context>+- Current date: {{date}}+</system_context>+++<core_responsibilities>+1. **Proactive Group Participation (PRIMARY FOCUS)**+ - Users created a group for collaborative discussions - actively involve relevant agents+ - For open-ended questions, brainstorming, or complex problems, proactively invoke multiple agents+ - When in doubt, lean towards group participation rather than answering alone++2. **Respect Explicit User Intent**+ - When the user explicitly specifies agent(s), prioritize those agents+ - User's explicit instructions take precedence over your orchestration decisions++3. **Context-Aware Orchestration**+ - Match user queries to agents with relevant expertise+ - Recognize when multiple perspectives would benefit the user+ - Identify when to conclude a topic or transition to a new one++4. **Quality Assurance**+ - Ensure responses are complementary rather than redundant+ - Guide agents to build upon each other's contributions+ - Intervene if responses drift off-topic+</core_responsibilities>++<orchestration_guidelines>+- **Default to Group Participation**: In a group chat context, proactively invoke relevant agents for most questions. Users expect collaborative responses.+- **User-Specified Agents**: When the user explicitly names agent(s), prioritize those agents but consider if others could add valuable perspectives.+- **Agent Selection**: Actively match questions to agents with relevant expertise. Don't wait for explicit requests when the topic clearly relates to an agent's domain.+- **Response Timing**: Balance natural rhythm with proactive engagement - group participation is expected.+- **User Focus**: A collaborative response with multiple perspectives is often more valuable than a single viewpoint.+- **Efficiency**: Use broadcast for parallel opinions, speak for sequential dependencies.+</orchestration_guidelines>++<critical_output_rules>+IMPORTANT: Your responses must contain ONLY your actual reply content.+- Messages in conversation history start with '<speaker name="..." />' - this identifies who sent each message+- NEVER start your response with '<speaker' tag - the system adds this automatically+- Just output your actual response content directly+</critical_output_rules>++<constraints>+- Only invoke agents defined in the participants list+- Never fabricate agent IDs or capabilities+- Respect each agent's defined role boundaries+- NEVER expose or display agent IDs to users in your responses - agent IDs are internal identifiers only for tool invocation+- Always refer to agents by their names, never by their IDs+</constraints>+`;diff --git a/packages/builtin-agents/src/agents/group-supervisor/type.ts b/packages/builtin-agents/src/agents/group-supervisor/type.tsnew file mode 100644index 00000000000..650c026b7d0--- /dev/null+++ b/packages/builtin-agents/src/agents/group-supervisor/type.ts@@ -0,0 +1,13 @@+/**+ * Context for Group Supervisor agent+ */+export interface GroupSupervisorContext {+ /** Available agents in the group */+ availableAgents: Array<{ id: string; title?: string | null }>;+ /** Group ID */+ groupId: string;+ /** Group title/name */+ groupTitle: string;+ /** Custom system prompt for the supervisor */+ systemPrompt?: string;+}diff --git a/packages/builtin-agents/src/agents/inbox/index.ts b/packages/builtin-agents/src/agents/inbox/index.tsnew file mode 100644index 00000000000..a70ecdb2834--- /dev/null+++ b/packages/builtin-agents/src/agents/inbox/index.ts@@ -0,0 +1,20 @@+import { GTDIdentifier } from '@lobechat/builtin-tool-gtd';++import type { BuiltinAgentDefinition } from '../../types';+import { BUILTIN_AGENT_SLUGS } from '../../types';+import { systemRole } from './systemRole';++/**+ * Inbox Agent - the default assistant agent for general conversations+ *+ * Note: model and provider are intentionally undefined to use user's default settings+ */+export const INBOX: BuiltinAgentDefinition = {+ avatar: '/avatars/lobe-ai.png',+ runtime: (ctx) => ({+ plugins: [GTDIdentifier, ...(ctx.plugins || [])],+ systemRole: systemRole,+ }),++ slug: BUILTIN_AGENT_SLUGS.inbox,+};diff --git a/packages/builtin-agents/src/agents/inbox/systemRole.ts b/packages/builtin-agents/src/agents/inbox/systemRole.tsnew file mode 100644index 00000000000..aa968e0edf3--- /dev/null+++ b/packages/builtin-agents/src/agents/inbox/systemRole.ts@@ -0,0 +1,17 @@+/**+ * Inbox Agent System Role Template+ *+ * This is the default assistant agent for general conversations.+ */+export const systemRole = `You are Lobe, an AI Agent will help users.++Current model: {{model}}+Today's date: {{currentDate}}++Your role is to:+- Answer questions accurately and helpfully+- Assist with a wide variety of tasks+- Provide clear and concise explanations+- Be friendly and professional in your responses++Respond in the same language the user is using.`;diff --git a/packages/builtin-agents/src/agents/page-agent/README.md b/packages/builtin-agents/src/agents/page-agent/README.mdnew file mode 100644index 00000000000..189e590644c--- /dev/null+++ b/packages/builtin-agents/src/agents/page-agent/README.md@@ -0,0 +1,301 @@+# Page Agent - Architecture & Workflow++This document explains how the Page Agent works, including context tracking, injection, and document manipulation.++## Overview++The Page Agent is a specialized AI agent that helps users create, read, update, and edit documents in the PageEditor. It has access to the current page's content and structure through context injection.++## Architecture Components++### 1. **Page Agent Definition** (`index.ts`)++- **Model**: Claude Sonnet 4.5+- **Plugin**: `lobe-page-agent` (Document manipulation tools)+- **System Role**: Document editing assistant++### 2. **Document Tools** (`src/tools/document/`)++- **Identifier**: `lobe-page-agent`+- **Type**: Built-in tool+- **Capabilities**:+ - `initPage` - Initialize document from Markdown+ - `editTitle` - Edit document title+ - CRUD operations (createNode, updateNode, deleteNode, moveNode)+ - Structure operations (wrapNodes, mergeNodes, splitNode)+ - Table, image, and list operations+ - Snapshot management++### 3. **Context Injection System** (`packages/context-engine/`)++- **Provider**: `PageEditorContextInjector`+- **Purpose**: Inject current page context into conversation+- **Location in Pipeline**: Position 5 (after Agent Builder, before Tool System Role)++## Data Flow - Complete Workflow++```+βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ+β Page Editor β+β - User edits document with Lexical editor β+β - Document saved in database as JSON (editorData) β+ββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββ+ β+ βΌ+βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ+β Store Updater (StoreUpdater.tsx) β+β - Watches currentDocId changes β+β - Calls: useChatStore.internal_updateActivePageId() β+ββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββ+ β+ βΌ+βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ+β Chat Store (store/chat/slices/message/) β+β - Stores activePageId globally β+β - Available to all services via getChatStoreState() β+ββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββ+ β+ βΌ+βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ+β User sends message to Page Agent β+ββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββ+ β+ βΌ+βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ+β Chat Service (services/chat/index.ts) β+β 1. Gets activePageId from chat store β+β 2. Fetches document from file store β+β 3. Builds pageEditorContext: β+β - document metadata (id, title, etc.) β+β - content (markdown text) β+β - editorData (Lexical JSON structure) β+ββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββ+ β+ βΌ+βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ+β Context Engineering (mecha/contextEngineering.ts) β+β - Receives pageEditorContext β+β - Passes to context pipeline β+ββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββ+ β+ βΌ+βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ+β PageEditorContextInjector (context-engine/providers/) β+β 1. Converts Lexical JSON β XML with node IDs β+β 2. Formats as structured context β+β 3. Injects before first user message β+ββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββ+ β+ βΌ+βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ+β Model receives: β+β <current_page_context> β+β <document_metadata> β+β <id>docs_abc123</id> β+β <title>My Document</title> β+β </document_metadata> β+β <document_structure> β+β <root> β+β <h1 id="node_1"> β+β <span id="node_2">Heading Text</span> β+β </h1> β+β <p id="node_3"> β+β <span id="node_4">Paragraph content</span> β+β </p> β+β </root> β+β </document_structure> β+β </current_page_context> β+βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ+```++## Key Implementation Details++### 1. Active Page Tracking++**Location**: `src/features/PageEditor/StoreUpdater.tsx:145-157`++```typescript+useEffect(() => {+ const activeId = currentDocId || pageId;+ updateActivePageId(activeId);++ return () => {+ updateActivePageId(undefined); // Cleanup on unmount+ };+}, [currentDocId, pageId, updateActivePageId]);+```++**State**: `src/store/chat/slices/message/initialState.ts:17`++```typescript+interface ChatMessageState {+ activePageId?: string; // Current page being edited+ // ... other fields+}+```++### 2. Context Building++**Location**: `src/services/chat/index.ts:217-259`++```typescript+const isPageAgentEnabled = enabledToolIds.includes(PAGE_AGENT_TOOL_ID);++if (isPageAgentEnabled) {+ const activePageId = getChatStoreState().activePageId;+ if (activePageId) {+ const document = documentSelectors.getDocumentById(activePageId)(fileState);++ pageEditorContext = {+ document: {+ id: document.id,+ title: document.title,+ fileType: document.fileType,+ totalCharCount: document.totalCharCount,+ totalLineCount: document.totalLineCount,+ },+ content: document.content || undefined,+ editorData: document.editorData || undefined,+ };+ }+}+```++### 3. Lexical to XML Conversion++**Location**: `packages/context-engine/src/providers/PageEditorContextInjector.ts:32-116`++**Input (Lexical JSON)**:++```json+{+ "root": {+ "type": "root",+ "children": [+ {+ "type": "heading",+ "tag": "h1",+ "children": [{ "type": "text", "text": "Hello World" }]+ }+ ]+ }+}+```++**Output (XML with IDs)**:++```xml+<root>+ <h1 id="node_1">+ <span id="node_2">Hello World</span>+ </h1>+</root>+```++**Supported Node Types**:++- `text` β `<span id="...">`+- `heading` β `<h1-h6 id="...">`+- `paragraph` β `<p id="...">`+- `list` β `<ul/ol id="...">`+- `listitem` β `<li id="...">`+- `quote` β `<blockquote id="...">`+- `code` β `<pre id="..."><code>`+- `link` β `<a id="..." href="...">`+- `image` β `<img id="..." src="..." alt="...">`++### 4. Context Injection++**Location**: `packages/context-engine/src/providers/PageEditorContextInjector.ts:217-237`++**Process**:++1. Check if Page Agent is enabled+2. Check if page context exists+3. Convert Lexical JSON to XML+4. Format as `<current_page_context>`+5. Insert as user message before first user message+6. Mark with metadata: `{ injectType: 'page-editor-context', systemInjection: true }`++## Document Tool Usage++The model can use these tools to manipulate the document:++### Example: Edit Title++```typescript+editTitle({ title: 'New Title' });+```++### Example: Initialize Page++```typescript+initPage({+ markdown: '# Heading\n\nParagraph content',+});+```++### Future: Node Manipulation++Currently disabled for MVP, but will support:++- `updateNode({ nodeId: "node_3", content: "New text" })`+- `deleteNode({ nodeId: "node_5" })`+- `createNode({ type: "p", content: "New paragraph", position: "after", referenceNodeId: "node_3" })`++## Debugging++### Console Logs to Check++1. **Page ID tracking**:++ ```+ [StoreUpdater] Updating activePageId in chat store: docs_abc123+ [ChatStore] Updating activePageId: docs_abc123+ ```++2. **Context building**:++ ```+ [ChatService] isPageAgentEnabled: true+ [ChatService] activePageId: docs_abc123+ [ChatService] Built page editor context: { documentId: '...', hasEditorData: true }+ ```++3. **XML conversion**:++ ```+ [PageEditorContextInjector] Converted Lexical to XML, node count: 15+ [PageEditorContextInjector] XML preview: <root>...+ ```++4. **Injection**:+ ```+ [PageEditorContextInjector] Page Editor context injected successfully+ [PageEditorContextInjector] Total messages after injection: 2+ ```++## Known Limitations++1. **MVP Features**: Only `initPage` and `editTitle` are currently enabled+2. **Node ID Generation**: IDs are generated per-request (not persistent)+3. **No Direct Editing**: Tools can't directly modify editor state (would need integration)+4. **Temp Documents**: Work in progress, IDs may change on save++## Future Enhancements++1. **Enable Full CRUD**: Activate all document manipulation tools+2. **Persistent Node IDs**: Store IDs in editorData for consistency+3. **Real-time Updates**: Sync tool changes back to editor+4. **Collaborative Editing**: Multiple users with conflict resolution+5. **Version History**: Full snapshot system integration++## Related Files++- **Agent Definition**: `packages/builtin-agents/src/agents/page-agent/`+- **Document Tools**: `src/tools/document/`+- **Context Injector**: `packages/context-engine/src/providers/PageEditorContextInjector.ts`+- **Chat Service**: `src/services/chat/index.ts`+- **Store Updater**: `src/features/PageEditor/StoreUpdater.tsx`+- **Chat Store**: `src/store/chat/slices/message/`+- **File Store**: `src/store/file/slices/document/`diff --git a/packages/builtin-agents/src/agents/page-agent/index.ts b/packages/builtin-agents/src/agents/page-agent/index.tsnew file mode 100644index 00000000000..a57e0731af7--- /dev/null+++ b/packages/builtin-agents/src/agents/page-agent/index.ts@@ -0,0 +1,28 @@+import type { BuiltinAgentDefinition } from '../../types';+import { BUILTIN_AGENT_SLUGS } from '../../types';+import { systemRoleTemplate } from './systemRole';++/**+ * Page Agent - used for document editing assistance+ */+export const PAGE_AGENT: BuiltinAgentDefinition = {+ avatar: '/avatars/doc-copilot.png',+ // Persist config - stored in database+ persist: {+ model: 'claude-sonnet-4-5-20250929',+ provider: 'anthropic',+ },++ // Runtime function - generates dynamic config+ runtime: (ctx) => ({+ // Disable history count limit for page agent+ // to ensure full document context is available+ chatConfig: {+ enableHistoryCount: false,+ },+ plugins: ['lobe-page-agent', ...(ctx.plugins || [])],+ systemRole: systemRoleTemplate,+ }),++ slug: BUILTIN_AGENT_SLUGS.pageAgent,+};diff --git a/packages/builtin-agents/src/agents/page-agent/systemRole.ts b/packages/builtin-agents/src/agents/page-agent/systemRole.tsnew file mode 100644index 00000000000..b1e79cbbf77--- /dev/null+++ b/packages/builtin-agents/src/agents/page-agent/systemRole.ts@@ -0,0 +1,13 @@+/**+ * Page Agent System Role Template+ *+ * This agent assists users with document editing in the PageEditor.+ */+export const systemRoleTemplate = `You are a helpful document (page) editing assistant. Your role is to:+- Help users write, edit, and improve their pages+- Provide suggestions for better clarity, structure, and style+- Answer questions about the page content+- Help with formatting and organization+- Summarize or expand on sections as needed++Be concise and helpful. Focus on improving the page quality.`;diff --git a/packages/builtin-agents/src/index.ts b/packages/builtin-agents/src/index.tsnew file mode 100644index 00000000000..a9112ca5def--- /dev/null+++ b/packages/builtin-agents/src/index.ts@@ -0,0 +1,54 @@+import { AGENT_BUILDER } from './agents/agent-builder';+import { GROUP_AGENT_BUILDER } from './agents/group-agent-builder';+import { GROUP_SUPERVISOR } from './agents/group-supervisor';+import { INBOX } from './agents/inbox';+import { PAGE_AGENT } from './agents/page-agent';+import type { BuiltinAgentDefinition, BuiltinAgentSlug, RuntimeContext } from './types';+import { BUILTIN_AGENT_SLUGS } from './types';++export * from './types';++// Agent exports+export { AGENT_BUILDER } from './agents/agent-builder';+export { GROUP_AGENT_BUILDER } from './agents/group-agent-builder';+export { GROUP_SUPERVISOR } from './agents/group-supervisor';+export { INBOX } from './agents/inbox';+export { PAGE_AGENT } from './agents/page-agent';++/**+ * All builtin agents indexed by slug+ */+export const BUILTIN_AGENTS: Record<BuiltinAgentSlug, BuiltinAgentDefinition> = {+ [BUILTIN_AGENT_SLUGS.agentBuilder]: AGENT_BUILDER,+ [BUILTIN_AGENT_SLUGS.groupAgentBuilder]: GROUP_AGENT_BUILDER,+ [BUILTIN_AGENT_SLUGS.groupSupervisor]: GROUP_SUPERVISOR,+ [BUILTIN_AGENT_SLUGS.inbox]: INBOX,+ [BUILTIN_AGENT_SLUGS.pageAgent]: PAGE_AGENT,+};++/**+ * Get persist config for a builtin agent (for DB operations)+ * @param slug - The builtin agent slug+ * @returns Persist config with slug or undefined if not found+ */+export const getAgentPersistConfig = (slug: string) => {+ const agent = BUILTIN_AGENTS[slug as BuiltinAgentSlug];+ if (!agent) return undefined;++ return { ...agent.persist, slug: agent.slug };+};++/**+ * Get runtime config for a builtin agent+ * @param slug - The builtin agent slug+ * @param ctx - Runtime context+ * @returns Runtime result or undefined if not found+ */+export const getAgentRuntimeConfig = (slug: string, ctx: RuntimeContext) => {+ const agent = BUILTIN_AGENTS[slug as BuiltinAgentSlug];+ if (!agent) return undefined;++ // Handle both function and plain object forms+ const runtime = agent.runtime;+ return typeof runtime === 'function' ? runtime(ctx) : runtime;+};diff --git a/packages/builtin-agents/src/types.ts b/packages/builtin-agents/src/types.tsnew file mode 100644index 00000000000..aec33df77c3--- /dev/null+++ b/packages/builtin-agents/src/types.ts@@ -0,0 +1,98 @@+import type { LobeAgentChatConfig, LobeAgentConfig } from '@lobechat/types';++import { GroupSupervisorContext } from './agents/group-supervisor/type';++/**+ * Builtin Agent Slugs - unique identifiers for builtin agents+ */+export const BUILTIN_AGENT_SLUGS = {+ agentBuilder: 'agent-builder',+ groupAgentBuilder: 'group-agent-builder',+ groupSupervisor: 'group-supervisor',+ inbox: 'inbox',+ pageAgent: 'page-agent',+} as const;++export type BuiltinAgentSlug = (typeof BUILTIN_AGENT_SLUGS)[keyof typeof BUILTIN_AGENT_SLUGS];++/**+ * Persist Config - these fields will be stored in the database+ */+export interface BuiltinAgentPersistConfig {+ /** Default chat configuration */+ chatConfig?: Partial<LobeAgentChatConfig>;+ /** Default model */+ model?: string;+ /** Default provider */+ provider?: string;+}++/**+ * Runtime Result - dynamically generated config, not persisted+ */+export interface BuiltinAgentRuntimeResult {+ /** Runtime chat configuration overrides */+ chatConfig?: Partial<LobeAgentChatConfig>;++ /** Plugins to enable for the agent */+ plugins?: string[];++ /** Dynamically generated system role */+ systemRole: string;+}++/**+ * Runtime Context - context passed to runtime function+ */+export interface RuntimeContext {+ /** Document content for PageAgent */+ documentContent?: string;++ /** Context for GroupSupervisor */+ groupSupervisorContext?: GroupSupervisorContext;++ /** Current model being used */+ model?: string;++ /** Plugins enabled for the agent */+ plugins?: string[];++ /** Target agent config for AgentBuilder */+ targetAgentConfig?: LobeAgentConfig;++ /** User's locale */+ userLocale?: string;+}++/**+ * Runtime config - can be either a function or a plain object+ * - Function: (ctx: RuntimeContext) => BuiltinAgentRuntimeResult+ * - Object: BuiltinAgentRuntimeResult (static config)+ */+export type BuiltinAgentRuntimeConfig =+ | ((ctx: RuntimeContext) => BuiltinAgentRuntimeResult)+ | BuiltinAgentRuntimeResult;++/**+ * Builtin Agent Definition - complete definition with persist and runtime parts+ */+export interface BuiltinAgentDefinition {+ avatar?: string;+ /**+ * Persist config - stored in database+ */+ persist?: BuiltinAgentPersistConfig;++ /**+ * Runtime config - generates dynamic config based on context+ * Can be either:+ * - A function that takes RuntimeContext and returns BuiltinAgentRuntimeResult+ * - A plain BuiltinAgentRuntimeResult object (for static systemRole)+ */+ runtime: BuiltinAgentRuntimeConfig;++ /**+ * Unique identifier for the builtin agent+ */+ slug: BuiltinAgentSlug;+}