🤯 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(heterogeneous-agent): add Devin tool inspectors, renders and apiName labels (#20553)
AmAzing-a33fb640f1cb
diff --git a/locales/en-US/plugin.json b/locales/en-US/plugin.jsonindex 7a8b1669d5e..7ad8daf3602 100644--- a/locales/en-US/plugin.json+++ b/locales/en-US/plugin.json@@ -71,6 +71,35 @@"builtins.codex.mcpTool.result": "Result","builtins.codex.mcpTool.unknownTool": "MCP tool","builtins.codex.webSearch.query": "Query",+ "builtins.devin.apiName.askUserQuestion": "Ask a question",+ "builtins.devin.apiName.edit": "Edit file",+ "builtins.devin.apiName.exec": "Run command",+ "builtins.devin.apiName.exec_output": "Read command output",+ "builtins.devin.apiName.exit_plan_mode": "Exit plan mode",+ "builtins.devin.apiName.fast_context": "Load context",+ "builtins.devin.apiName.find_file_by_name": "Find files",+ "builtins.devin.apiName.get_output": "Read command output",+ "builtins.devin.apiName.glob": "Find files",+ "builtins.devin.apiName.grep": "Search content",+ "builtins.devin.apiName.kill_shell": "Stop command",+ "builtins.devin.apiName.mcp_call_tool": "Call MCP tool",+ "builtins.devin.apiName.notebook_edit": "Edit notebook",+ "builtins.devin.apiName.notebook_read": "Read notebook",+ "builtins.devin.apiName.read": "Read file",+ "builtins.devin.apiName.request_scope": "Request access",+ "builtins.devin.apiName.run_subagent": "Run subagent",+ "builtins.devin.apiName.skill": "Use skill",+ "builtins.devin.apiName.subagent": "Run subagent",+ "builtins.devin.apiName.todo": "Update tasks",+ "builtins.devin.apiName.todo_write": "Update tasks",+ "builtins.devin.apiName.tool_search": "Search tools",+ "builtins.devin.apiName.user_question": "Ask a question",+ "builtins.devin.apiName.view_image": "View image",+ "builtins.devin.apiName.web_search": "Search the web",+ "builtins.devin.apiName.webfetch": "Fetch web page",+ "builtins.devin.apiName.write": "Write file",+ "builtins.devin.apiName.write_plan": "Write plan",+ "builtins.devin.apiName.write_to_process": "Send input","builtins.github.render.error": "Error","builtins.github.render.rawResult": "Raw result","builtins.github.render.updatedAt": "Updated {{time}}",diff --git a/locales/zh-CN/plugin.json b/locales/zh-CN/plugin.jsonindex 8224ced52ce..3acb68fb0dc 100644--- a/locales/zh-CN/plugin.json+++ b/locales/zh-CN/plugin.json@@ -71,6 +71,35 @@"builtins.codex.mcpTool.result": "结果","builtins.codex.mcpTool.unknownTool": "MCP 工具","builtins.codex.webSearch.query": "搜索词",+ "builtins.devin.apiName.askUserQuestion": "向你提问",+ "builtins.devin.apiName.edit": "编辑文件",+ "builtins.devin.apiName.exec": "执行命令",+ "builtins.devin.apiName.exec_output": "读取命令输出",+ "builtins.devin.apiName.exit_plan_mode": "退出计划模式",+ "builtins.devin.apiName.fast_context": "加载上下文",+ "builtins.devin.apiName.find_file_by_name": "查找文件",+ "builtins.devin.apiName.get_output": "读取命令输出",+ "builtins.devin.apiName.glob": "查找文件",+ "builtins.devin.apiName.grep": "搜索内容",+ "builtins.devin.apiName.kill_shell": "终止命令",+ "builtins.devin.apiName.mcp_call_tool": "调用 MCP 工具",+ "builtins.devin.apiName.notebook_edit": "编辑笔记本",+ "builtins.devin.apiName.notebook_read": "读取笔记本",+ "builtins.devin.apiName.read": "读取文件",+ "builtins.devin.apiName.request_scope": "请求访问权限",+ "builtins.devin.apiName.run_subagent": "运行子代理",+ "builtins.devin.apiName.skill": "使用技能",+ "builtins.devin.apiName.subagent": "运行子代理",+ "builtins.devin.apiName.todo": "更新任务清单",+ "builtins.devin.apiName.todo_write": "更新任务清单",+ "builtins.devin.apiName.tool_search": "搜索工具",+ "builtins.devin.apiName.user_question": "向你提问",+ "builtins.devin.apiName.view_image": "查看图片",+ "builtins.devin.apiName.web_search": "搜索网页",+ "builtins.devin.apiName.webfetch": "抓取网页",+ "builtins.devin.apiName.write": "写入文件",+ "builtins.devin.apiName.write_plan": "写入计划",+ "builtins.devin.apiName.write_to_process": "发送输入","builtins.github.render.error": "错误","builtins.github.render.rawResult": "原始结果","builtins.github.render.updatedAt": "更新于 {{time}}",diff --git a/packages/builtin-tool-local-system/src/client/Render/ReadLocalFile/buildReadFileState.test.ts b/packages/builtin-tool-local-system/src/client/Render/ReadLocalFile/buildReadFileState.test.tsindex e3af271d982..de792746fbd 100644--- a/packages/builtin-tool-local-system/src/client/Render/ReadLocalFile/buildReadFileState.test.ts+++ b/packages/builtin-tool-local-system/src/client/Render/ReadLocalFile/buildReadFileState.test.ts@@ -1,3 +1,4 @@+import type { ReadFileState } from '@lobechat/tool-runtime';import { describe, expect, it } from 'vitest';import {@@ -7,6 +8,17 @@ import {} from './buildReadFileState';describe('buildReadFileState', () => {+ it('keeps the card for an empty Devin read confirmed by the final result state', () => {+ const state = buildReadFileState({+ args: { file_path: '/repo/empty.txt' },+ identifier: 'devin',+ parsedContent: { content: '' },+ pluginState: { content: '' },+ });++ expect(state).toMatchObject({ charCount: 0, content: '', path: '/repo/empty.txt' });+ });+it('keeps the card for a successful builtin read of an empty file', () => {const state = buildReadFileState({args: { path: '/repo/empty.txt' },@@ -55,6 +67,11 @@ describe('buildReadFileState', () => {identifier: 'pi',parsedContent: { content: 'const a = 1;' },});+ const fromDevin = buildReadFileState({+ args: { file_path: '/repo/file.ts' },+ identifier: 'devin',+ parsedContent: { content: 'const a = 1;' },+ });const fromBuiltin = buildReadFileState({args: { path: '/repo/file.ts' },identifier: 'lobe-local-system',@@ -62,9 +79,26 @@ describe('buildReadFileState', () => {});expect(fromPi).toMatchObject({ content: 'const a = 1;', fileType: 'ts' });+ expect(fromDevin).toMatchObject({ content: 'const a = 1;', fileType: 'ts' });expect(fromBuiltin).toBeUndefined();});+ it('ignores non-string ACP content blocks parked on pluginState', () => {+ // Devin's tool_state carries the raw session update, whose `content` is a+ // content-block array — the read text only lives in the result content.+ const state = buildReadFileState({+ args: { file_path: '/repo/file.ts' },+ identifier: 'devin',+ parsedContent: { content: 'body' },+ pluginState: {+ content: [{ text: 'Reading…', type: 'content' }],+ sessionUpdate: 'tool_call_update',+ } as unknown as ReadFileState,+ });++ expect(state?.content).toBe('body');+ });+it('derives loc from offset and limit args', () => {const state = buildReadFileState({args: { limit: 10, offset: 5, path: '/repo/file.ts' },diff --git a/packages/builtin-tool-local-system/src/client/Render/ReadLocalFile/buildReadFileState.ts b/packages/builtin-tool-local-system/src/client/Render/ReadLocalFile/buildReadFileState.tsindex 603e235174c..adfa076f788 100644--- a/packages/builtin-tool-local-system/src/client/Render/ReadLocalFile/buildReadFileState.ts+++ b/packages/builtin-tool-local-system/src/client/Render/ReadLocalFile/buildReadFileState.ts@@ -35,8 +35,14 @@ export const buildReadFileState = ({'';if (!filePath) return;- const canUseContentFallback = identifier === 'opencode' || identifier === 'pi';- const text = pluginState?.content ?? (canUseContentFallback ? parsedContent.content : '');+ const canUseContentFallback =+ identifier === 'opencode' || identifier === 'pi' || identifier === 'devin';+ // ACP agents (Devin) park the raw session update in pluginState, whose+ // `content` is a content-block array — never the read text — so only a+ // string value counts as reported content.+ const reportedContent =+ typeof pluginState?.content === 'string' ? pluginState.content : undefined;+ const text = reportedContent ?? (canUseContentFallback ? parsedContent.content : '');const images = pluginState?.images;// An empty file is still a successful read: keep the card when the builtin// tool reported a state, or when the OpenCode envelope confirms completion.diff --git a/packages/builtin-tools/src/register.ts b/packages/builtin-tools/src/register.tsindex 0545f4e304e..796439ceea0 100644--- a/packages/builtin-tools/src/register.ts+++ b/packages/builtin-tools/src/register.ts@@ -166,6 +166,7 @@ import {WebOnboardingRenders,} from '@lobechat/builtin-tool-web-onboarding/client';import {+ createEditLocalFileInspector,createReadLocalFileInspector,createRunCommandInspector,createWriteLocalFileInspector,@@ -224,6 +225,29 @@ const heterogeneousCliStreamings: Record<string, BuiltinStreaming> = {write: LocalSystemStreamings[LocalSystemApiName.writeFile] as BuiltinStreaming,};+/**+ * Devin's ACP stream reports the CLI's inference tool names via+ * `_meta['cognition.ai/inferenceToolName']` (exec/read/write/edit/…), so the+ * shared command and local-file surfaces apply under those apiName keys.+ * `edit` gets an inspector but no render: its tool result is flattened diff+ * text, not the `diffText` patch EditLocalFile expects. `grep`/`glob` stay+ * inspector-less too — their count icons key off lobe-shaped pluginState+ * (totalMatches/totalCount) that ACP updates never carry, so a successful+ * search would render as a failure.+ */+const devinCliInspectors: Record<string, BuiltinInspector> = {+ edit: createEditLocalFileInspector('builtins.devin.apiName.edit') as BuiltinInspector,+ exec: createRunCommandInspector('builtins.devin.apiName.exec') as BuiltinInspector,+ read: createReadLocalFileInspector('builtins.devin.apiName.read') as BuiltinInspector,+ write: createWriteLocalFileInspector('builtins.devin.apiName.write') as BuiltinInspector,+};++const devinCliRenders: Record<string, BuiltinRender> = {+ exec: RunCommandRender as BuiltinRender,+ read: LocalSystemRenders[LocalSystemApiName.readFile] as BuiltinRender,+ write: LocalSystemRenders[LocalSystemApiName.writeFile] as BuiltinRender,+};+let builtinToolSurfacesRegistered = false;export const registerBuiltinToolSurfaces = (): void => {@@ -238,6 +262,7 @@ export const registerBuiltinToolSurfaces = (): void => {[ClaudeCodeApiName.AskUserQuestion]: ClaudeCodeRenders[ClaudeCodeApiName.AskUserQuestion],},[DEVIN_IDENTIFIER]: {+ ...devinCliRenders,[ClaudeCodeApiName.AskUserQuestion]: ClaudeCodeRenders[ClaudeCodeApiName.AskUserQuestion],},[QODER_IDENTIFIER]: ClaudeCodeRenders as Record<string, BuiltinRender>,@@ -296,6 +321,7 @@ export const registerBuiltinToolSurfaces = (): void => {[ClaudeCodeApiName.AskUserQuestion]: ClaudeCodeInspectors[ClaudeCodeApiName.AskUserQuestion],},[DEVIN_IDENTIFIER]: {+ ...devinCliInspectors,[ClaudeCodeApiName.AskUserQuestion]: ClaudeCodeInspectors[ClaudeCodeApiName.AskUserQuestion],},[QODER_IDENTIFIER]: ClaudeCodeInspectors as Record<string, BuiltinInspector>,diff --git a/packages/heterogeneous-agents/src/adapters/devinAcp.test.ts b/packages/heterogeneous-agents/src/adapters/devinAcp.test.tsindex c2d22a46b90..45c07fdf7d1 100644--- a/packages/heterogeneous-agents/src/adapters/devinAcp.test.ts+++ b/packages/heterogeneous-agents/src/adapters/devinAcp.test.ts@@ -7,6 +7,42 @@ const dataFor = (events: HeterogeneousAgentEvent[], type: HeterogeneousAgentEvenevents.filter((event) => event.type === type).map((event) => event.data);describe('DevinAcpAdapter', () => {+ it.each(['completed', 'failed', 'running', 'pending'])(+ 'preserves empty read content only after successful completion (%s)',+ (status) => {+ const adapter = new DevinAcpAdapter();+ adapter.adapt({+ name: 'read',+ rawInput: { file_path: '/repo/empty.txt' },+ sessionUpdate: 'tool_call',+ toolCallId: 'read-empty',+ });++ const events = adapter.adapt({+ content: [{ content: { text: '', type: 'text' }, type: 'content' }],+ sessionUpdate: 'tool_call_update',+ status,+ toolCallId: 'read-empty',+ });+ const results = dataFor(events, 'tool_result');++ if (status === 'completed') {+ expect(results).toEqual([+ {+ content: '',+ isError: false,+ pluginState: { content: '' },+ toolCallId: 'read-empty',+ },+ ]);+ } else if (status === 'failed') {+ expect(results).toEqual([{ content: '', isError: true, toolCallId: 'read-empty' }]);+ } else {+ expect(results).toEqual([]);+ }+ },+ );+it('emits step_complete with turn_metadata from session/prompt result usage', () => {const adapter = new DevinAcpAdapter();diff --git a/packages/heterogeneous-agents/src/adapters/devinAcp.ts b/packages/heterogeneous-agents/src/adapters/devinAcp.tsindex a6c4dc1bb36..51a648bbcbe 100644--- a/packages/heterogeneous-agents/src/adapters/devinAcp.ts+++ b/packages/heterogeneous-agents/src/adapters/devinAcp.ts@@ -1,6 +1,6 @@import { isRecord } from '@lobechat/utils/object';-import type { UsageData } from '../types';+import type { HeterogeneousAgentEvent, UsageData } from '../types';import { TraeAcpAdapter, type TraeAcpPayload } from './traeAcp';const toFiniteNumber = (value: unknown): number | undefined => {@@ -13,6 +13,20 @@ export class DevinAcpAdapter extends TraeAcpAdapter {super({ eventPrefix: 'devin', provider: 'devin' });}+ override adapt(value: unknown): HeterogeneousAgentEvent[] {+ return super.adapt(value).map((event) => {+ if (event.type !== 'tool_result' || event.data.isError) return event;+ const tool = this.stream.stepTools.find((tool) => tool.id === event.data.toolCallId);+ if (tool?.identifier !== 'devin' || tool.apiName !== 'read') return event;++ // A successful empty read needs state even when ACP skipped running updates.+ return {+ ...event,+ data: { ...event.data, pluginState: { content: event.data.content } },+ };+ });+ }+protected override extractUsageFromUsageUpdate(raw: TraeAcpPayload): UsageData | undefined {const meta = isRecord(raw._meta) ? raw._meta : undefined;if (!meta) return;diff --git a/packages/locales/src/default/plugin.ts b/packages/locales/src/default/plugin.tsindex 5c41c9c8b05..361fb9268f1 100644--- a/packages/locales/src/default/plugin.ts+++ b/packages/locales/src/default/plugin.ts@@ -209,6 +209,38 @@ export default {'builtins.codex.mcpTool.result': 'Result','builtins.codex.mcpTool.unknownTool': 'MCP tool','builtins.codex.webSearch.query': 'Query',+ // Devin's ACP `tool_call` names come from `_meta['cognition.ai/inferenceToolName']`,+ // the CLI's inference tool vocabulary — both the documented permission names+ // (read/edit/grep/glob/exec) and the wire names are covered.+ 'builtins.devin.apiName.askUserQuestion': 'Ask a question',+ 'builtins.devin.apiName.edit': 'Edit file',+ 'builtins.devin.apiName.exec': 'Run command',+ 'builtins.devin.apiName.exec_output': 'Read command output',+ 'builtins.devin.apiName.exit_plan_mode': 'Exit plan mode',+ 'builtins.devin.apiName.fast_context': 'Load context',+ 'builtins.devin.apiName.find_file_by_name': 'Find files',+ 'builtins.devin.apiName.get_output': 'Read command output',+ 'builtins.devin.apiName.glob': 'Find files',+ 'builtins.devin.apiName.grep': 'Search content',+ 'builtins.devin.apiName.kill_shell': 'Stop command',+ 'builtins.devin.apiName.mcp_call_tool': 'Call MCP tool',+ 'builtins.devin.apiName.notebook_edit': 'Edit notebook',+ 'builtins.devin.apiName.notebook_read': 'Read notebook',+ 'builtins.devin.apiName.read': 'Read file',+ 'builtins.devin.apiName.request_scope': 'Request access',+ 'builtins.devin.apiName.run_subagent': 'Run subagent',+ 'builtins.devin.apiName.skill': 'Use skill',+ 'builtins.devin.apiName.subagent': 'Run subagent',+ 'builtins.devin.apiName.todo': 'Update tasks',+ 'builtins.devin.apiName.todo_write': 'Update tasks',+ 'builtins.devin.apiName.tool_search': 'Search tools',+ 'builtins.devin.apiName.user_question': 'Ask a question',+ 'builtins.devin.apiName.view_image': 'View image',+ 'builtins.devin.apiName.web_search': 'Search the web',+ 'builtins.devin.apiName.webfetch': 'Fetch web page',+ 'builtins.devin.apiName.write': 'Write file',+ 'builtins.devin.apiName.write_plan': 'Write plan',+ 'builtins.devin.apiName.write_to_process': 'Send input','builtins.lobe-browser.apiName.click': 'Clicked element','builtins.lobe-browser.apiName.fill': 'Filled input','builtins.lobe-browser.apiName.navigate': 'Opened page',diff --git a/src/features/DevPanel/RenderGallery/fixtures/devin.ts b/src/features/DevPanel/RenderGallery/fixtures/devin.tsnew file mode 100644index 00000000000..13adb128e07--- /dev/null+++ b/src/features/DevPanel/RenderGallery/fixtures/devin.ts@@ -0,0 +1,83 @@+'use client';++import { defineFixtures, single } from './_helpers';++const readFileText = `import { TraeAcpAdapter } from './traeAcp';++export class DevinAcpAdapter extends TraeAcpAdapter {+ protected readonly identifier = 'devin';+}`;++// Devin parks the raw ACP `tool_call_update` in pluginState, whose `content`+// is a content-block array rather than the plain strings lobe tools report.+const acpToolState = (kind: string, text: string) => ({+ content: [{ content: { text, type: 'text' }, type: 'content' }],+ kind,+ status: 'completed',+});++export default defineFixtures({+ identifier: 'devin',+ meta: {+ description:+ 'Devin CLI tool previews. apiName comes from _meta["cognition.ai/inferenceToolName"] on ACP tool_call updates.',+ title: 'Devin',+ },+ apiList: [+ { description: 'Ask the user a question (permission prompts).', name: 'askUserQuestion' },+ { description: 'Edit a file by replacing matching content.', name: 'edit' },+ { description: 'Run a shell command.', name: 'exec' },+ { description: 'Read file content.', name: 'read' },+ { description: 'Write a new file.', name: 'write' },+ ],+ fixtures: {+ askUserQuestion: single({+ args: {+ questions: [+ {+ header: 'Permission',+ options: [+ { description: 'Run the command once.', label: 'Allow' },+ {+ description: 'Trust this command for the rest of the session.',+ label: 'Always allow',+ },+ { description: 'Skip this command.', label: 'Deny' },+ ],+ question: 'Devin wants to run `pnpm install`. Allow it?',+ },+ ],+ },+ }),+ edit: single({+ args: {+ file_path: 'packages/builtin-tools/src/register.ts',+ new_string: "const DEVIN_IDENTIFIER = 'devin';",+ old_string: "const DEVIN_IDENTIFIER = 'devin-cli';",+ },+ content: 'Applied edit to packages/builtin-tools/src/register.ts',+ pluginState: acpToolState('edit', 'Applied edit to packages/builtin-tools/src/register.ts'),+ }),+ exec: single({+ args: { command: 'bun run check packages/builtin-tools/src/register.ts' },+ content: '✓ 7 files · lint clean · tests 52 passed',+ pluginState: acpToolState('execute', '✓ 7 files · lint clean · tests 52 passed'),+ }),+ read: single({+ args: {+ file_path: 'packages/heterogeneous-agents/src/adapters/devinAcp.ts',+ limit: 4,+ },+ content: readFileText,+ pluginState: acpToolState('read', readFileText),+ }),+ write: single({+ args: {+ content: `import { defineFixtures, single } from './_helpers';\n\nexport default defineFixtures({\n identifier: 'devin',\n});\n`,+ file_path: 'src/features/DevPanel/RenderGallery/fixtures/devin.ts',+ },+ content: 'Wrote src/features/DevPanel/RenderGallery/fixtures/devin.ts',+ pluginState: acpToolState('write', 'File written'),+ }),+ },+});diff --git a/src/features/DevPanel/RenderGallery/fixtures/index.ts b/src/features/DevPanel/RenderGallery/fixtures/index.tsindex 0801e81d752..bdd0661e60d 100644--- a/src/features/DevPanel/RenderGallery/fixtures/index.ts+++ b/src/features/DevPanel/RenderGallery/fixtures/index.ts@@ -8,6 +8,7 @@ import type { ToolRenderFixture } from '../lifecycleMode';import { buildSchemaSample, humanize, single, type ToolsetFixtureModule } from './_helpers';import claudeCode from './claude-code';import codex from './codex';+import devin from './devin';import github from './github';import kimiCode from './kimi-code';import linear from './linear';@@ -85,6 +86,7 @@ export const DEVTOOLS_GROUP_DETAIL = {const toolsetModules: ToolsetFixtureModule[] = [claudeCode,codex,+ devin,github,kimiCode,linear,diff --git a/src/store/tool/builtinToolRegistry.test.ts b/src/store/tool/builtinToolRegistry.test.tsindex f1d2c7c727c..15d7255720f 100644--- a/src/store/tool/builtinToolRegistry.test.ts+++ b/src/store/tool/builtinToolRegistry.test.ts@@ -427,6 +427,21 @@ describe('builtin tool registry', () => {expect(getBuiltinIntervention('qoder', UserInteractionApiName.askUserQuestion)).toBeDefined();});+ it('registers command and local-file surfaces for Devin ACP tool names', () => {+ // Devin tool calls arrive under the CLI's inference names+ // (`_meta['cognition.ai/inferenceToolName']`), not Claude Code's.+ expect(getBuiltinInspector('devin', 'exec')).toBeDefined();+ expect(getBuiltinRender('devin', 'exec')).toBeDefined();+ expect(getBuiltinInspector('devin', 'read')).toBeDefined();+ expect(getBuiltinRender('devin', 'read')).toBeDefined();+ expect(getBuiltinInspector('devin', 'write')).toBeDefined();+ expect(getBuiltinRender('devin', 'write')).toBeDefined();+ expect(getBuiltinInspector('devin', 'edit')).toBeDefined();+ // No diffText is synthesized for ACP updates, so edit keeps the generic+ // result view instead of an empty patch card.+ expect(getBuiltinRender('devin', 'edit')).toBeUndefined();+ });+it('exposes the marketplace APIs under the web onboarding manifest', () => {const apiNames = WebOnboardingManifest.api.map((entry) => entry.name);expect(apiNames).toContain(WebOnboardingApiName.showAgentMarketplace);