🤯 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(codex): dedicated inspector labels and icons for node/git/python commands (#16662)
Arvin Xua5dcebfb87e2
diff --git a/locales/en-US/plugin.json b/locales/en-US/plugin.jsonindex 7031af8e2d7..25c4303c9b3 100644--- a/locales/en-US/plugin.json+++ b/locales/en-US/plugin.json@@ -16,9 +16,12 @@"builtins.codex.collabTool.sendInput": "Message subagent","builtins.codex.collabTool.spawnAgent": "Spawn subagent","builtins.codex.collabTool.wait": "Wait for subagents",+ "builtins.codex.commandExecution.gitOperation": "Git operation","builtins.codex.commandExecution.grep": "Search","builtins.codex.commandExecution.noResults": "No results","builtins.codex.commandExecution.readFile": "Read file",+ "builtins.codex.commandExecution.runNode": "Run node script",+ "builtins.codex.commandExecution.runPython": "Run python script","builtins.codex.fileChange.editedFiles_one": "Edited {{count}} file","builtins.codex.fileChange.editedFiles_other": "Edited {{count}} files","builtins.codex.fileChange.editing": "Editing files",diff --git a/locales/zh-CN/plugin.json b/locales/zh-CN/plugin.jsonindex 8d02b353ebd..ab2dbe4e525 100644--- a/locales/zh-CN/plugin.json+++ b/locales/zh-CN/plugin.json@@ -16,9 +16,12 @@"builtins.codex.collabTool.sendInput": "发送消息给子代理","builtins.codex.collabTool.spawnAgent": "启动子代理","builtins.codex.collabTool.wait": "等待子代理",+ "builtins.codex.commandExecution.gitOperation": "git 操作","builtins.codex.commandExecution.grep": "搜索","builtins.codex.commandExecution.noResults": "没有结果","builtins.codex.commandExecution.readFile": "读取文件",+ "builtins.codex.commandExecution.runNode": "运行 node 脚本",+ "builtins.codex.commandExecution.runPython": "运行 python 脚本","builtins.codex.fileChange.editedFiles_one": "已编辑 {{count}} 个文件","builtins.codex.fileChange.editedFiles_other": "已编辑 {{count}} 个文件","builtins.codex.fileChange.editing": "编辑文件中",diff --git a/packages/builtin-tools/package.json b/packages/builtin-tools/package.jsonindex 774311c2e5e..1ccb991b28f 100644--- a/packages/builtin-tools/package.json+++ b/packages/builtin-tools/package.json@@ -18,6 +18,7 @@},"main": "./src/index.ts","dependencies": {+ "@icons-pack/react-simple-icons": "^13.13.0","@lobechat/builtin-tool-activator": "workspace:*","@lobechat/builtin-tool-agent-builder": "workspace:*","@lobechat/builtin-tool-agent-documents": "workspace:*",diff --git a/packages/builtin-tools/src/codex/CommandExecutionInspector.tsx b/packages/builtin-tools/src/codex/CommandExecutionInspector.tsxindex af3e3639cc2..58881deac65 100644--- a/packages/builtin-tools/src/codex/CommandExecutionInspector.tsx+++ b/packages/builtin-tools/src/codex/CommandExecutionInspector.tsx@@ -1,5 +1,6 @@'use client';+import { SiGit, SiNodedotjs, SiPython } from '@icons-pack/react-simple-icons';import {createGrepContentInspector,createReadLocalFileInspector,@@ -7,9 +8,12 @@ import {} from '@lobechat/shared-tool-ui/inspectors';import type { RunCommandState } from '@lobechat/tool-runtime';import type { BuiltinInspectorProps } from '@lobechat/types';+import type { ComponentType } from 'react';import { memo } from 'react';import {+ type CodexCommandProgram,+ getCodexCommandProgram,getCodexGrepCommandDisplay,getCodexReadFileCommandDisplay,} from './commandExecutionUtils';@@ -18,6 +22,16 @@ const COMMAND_EXECUTION_KEY = 'builtins.codex.apiName.command_execution';const GREP_KEY = 'builtins.codex.commandExecution.grep';const GREP_NO_RESULTS_KEY = 'builtins.codex.commandExecution.noResults';const READ_FILE_KEY = 'builtins.codex.commandExecution.readFile';++/** Dedicated label + brand icon per program family. */+const PROGRAM_DISPLAY: Record<+ CodexCommandProgram,+ { icon: ComponentType<{ className?: string; size?: number }>; translationKey: string }+> = {+ git: { icon: SiGit, translationKey: 'builtins.codex.commandExecution.gitOperation' },+ node: { icon: SiNodedotjs, translationKey: 'builtins.codex.commandExecution.runNode' },+ python: { icon: SiPython, translationKey: 'builtins.codex.commandExecution.runPython' },+};const SharedGrepInspector = createGrepContentInspector({noResultsKey: GREP_NO_RESULTS_KEY,translationKey: GREP_KEY,@@ -107,6 +121,13 @@ const CommandExecutionInspector = memo<);}+ const program =+ getCodexCommandProgram(args?.command) ?? getCodexCommandProgram(partialArgs?.command);+ if (program) {+ const { icon, translationKey } = PROGRAM_DISPLAY[program];+ return <RunCommandInspector {...props} icon={icon} translationKey={translationKey} />;+ }+return <RunCommandInspector {...props} translationKey={COMMAND_EXECUTION_KEY} />;});diff --git a/packages/builtin-tools/src/codex/commandExecutionUtils.test.ts b/packages/builtin-tools/src/codex/commandExecutionUtils.test.tsindex e2704223699..bc7f0389b6e 100644--- a/packages/builtin-tools/src/codex/commandExecutionUtils.test.ts+++ b/packages/builtin-tools/src/codex/commandExecutionUtils.test.ts@@ -1,6 +1,7 @@import { describe, expect, it } from 'vitest';import {+ getCodexCommandProgram,getCodexGrepCommandDisplay,getCodexReadFileCommandDisplay,} from './commandExecutionUtils';@@ -98,3 +99,36 @@ describe('getCodexGrepCommandDisplay', () => {expect(getCodexGrepCommandDisplay('rg --files src')).toBeUndefined();});});++describe('getCodexCommandProgram', () => {+ it('classifies node commands', () => {+ expect(getCodexCommandProgram('node packages/cli/dist/index.js message-gateway stats')).toBe(+ 'node',+ );+ expect(getCodexCommandProgram('node -e "const fs=require(\'fs\')"')).toBe('node');+ });++ it('classifies git commands', () => {+ expect(getCodexCommandProgram('git diff -- package.json')).toBe('git');+ expect(getCodexCommandProgram('git status --short')).toBe('git');+ });++ it('classifies python commands, including python3 and absolute paths', () => {+ expect(getCodexCommandProgram('python analyze.py')).toBe('python');+ expect(getCodexCommandProgram('python3 -m http.server')).toBe('python');+ expect(getCodexCommandProgram('/usr/bin/python3 script.py')).toBe('python');+ });++ it('unwraps shell wrappers and skips env assignments', () => {+ expect(getCodexCommandProgram('bash -lc "git log --oneline"')).toBe('git');+ expect(getCodexCommandProgram('NODE_ENV=production node app.js')).toBe('node');+ });++ it('returns undefined for unknown or empty programs', () => {+ expect(getCodexCommandProgram('pnpm install')).toBeUndefined();+ expect(getCodexCommandProgram('ls -la')).toBeUndefined();+ expect(getCodexCommandProgram('cat foo | node bar.js')).toBeUndefined();+ expect(getCodexCommandProgram('')).toBeUndefined();+ expect(getCodexCommandProgram(undefined)).toBeUndefined();+ });+});diff --git a/packages/builtin-tools/src/codex/commandExecutionUtils.ts b/packages/builtin-tools/src/codex/commandExecutionUtils.tsindex d3432c959d1..3f09d8e0bb3 100644--- a/packages/builtin-tools/src/codex/commandExecutionUtils.ts+++ b/packages/builtin-tools/src/codex/commandExecutionUtils.ts@@ -279,3 +279,38 @@ export const getCodexGrepCommandDisplay = (return { pattern };};++/** Program families we give a dedicated label + brand icon instead of the generic terminal chip. */+export type CodexCommandProgram = 'git' | 'node' | 'python';++const PROGRAM_BY_BASENAME: Record<string, CodexCommandProgram> = {+ git: 'git',+ node: 'node',+ python: 'python',+ python3: 'python',+};++const ENV_ASSIGNMENT_PATTERN = /^[A-Z_]\w*=/i;++/**+ * Classify the leading executable of a codex command (e.g. `node app.js` → `node`).+ * Unwraps `bash -lc "..."`, skips leading `KEY=value` env assignments, and normalizes an+ * absolute path to its basename (`/usr/bin/python3` → `python3`). Returns undefined for+ * anything not in {@link PROGRAM_BY_BASENAME}.+ */+export const getCodexCommandProgram = (command?: string): CodexCommandProgram | undefined => {+ const displayCommand = stripShellWrapper(command);+ if (!displayCommand) return;++ const tokens = tokenizeShellLike(displayCommand);+ if (!tokens) return;++ let index = 0;+ while (index < tokens.length && ENV_ASSIGNMENT_PATTERN.test(tokens[index] || '')) index += 1;++ const head = tokens[index];+ if (!head) return;++ const basename = head.split('/').at(-1) || head;+ return PROGRAM_BY_BASENAME[basename];+};diff --git a/packages/locales/src/default/plugin.ts b/packages/locales/src/default/plugin.tsindex 4d35c6cfd77..e058fde18a3 100644--- a/packages/locales/src/default/plugin.ts+++ b/packages/locales/src/default/plugin.ts@@ -99,9 +99,12 @@ export default {'builtins.codex.collabTool.sendInput': 'Message subagent','builtins.codex.collabTool.spawnAgent': 'Spawn subagent','builtins.codex.collabTool.wait': 'Wait for subagents',+ 'builtins.codex.commandExecution.gitOperation': 'Git operation','builtins.codex.commandExecution.grep': 'Search','builtins.codex.commandExecution.noResults': 'No results','builtins.codex.commandExecution.readFile': 'Read file',+ 'builtins.codex.commandExecution.runNode': 'Run node script',+ 'builtins.codex.commandExecution.runPython': 'Run python script','builtins.codex.fileChange.editedFiles_one': 'Edited {{count}} file','builtins.codex.fileChange.editedFiles_other': 'Edited {{count}} files','builtins.codex.fileChange.editing': 'Editing files',diff --git a/packages/shared-tool-ui/src/Inspector/RunCommand/index.tsx b/packages/shared-tool-ui/src/Inspector/RunCommand/index.tsxindex 04d6aea8557..d2b2a0319f6 100644--- a/packages/shared-tool-ui/src/Inspector/RunCommand/index.tsx+++ b/packages/shared-tool-ui/src/Inspector/RunCommand/index.tsx@@ -4,7 +4,7 @@ import type { RunCommandState } from '@lobechat/tool-runtime';import type { BuiltinInspectorProps } from '@lobechat/types';import { createStaticStyles, cssVar, cx } from 'antd-style';import { Check, SquareChevronRight, X } from 'lucide-react';-import { memo } from 'react';+import { type ComponentType, memo } from 'react';import { useTranslation } from 'react-i18next';import { inspectorTextStyles, shinyTextStyles } from '../../styles';@@ -37,6 +37,11 @@ const styles = createStaticStyles(({ css, cssVar }) => ({text-overflow: ellipsis;white-space: nowrap;`,+ leadingIcon: css`+ flex-shrink: 0;+ margin-inline-end: 6px;+ color: ${cssVar.colorTextDescription};+ `,statusIcon: css`margin-inline-start: 4px;`,@@ -57,30 +62,52 @@ export interface RunCommandInspectorProps extends BuiltinInspectorProps<RunCommandArgs,RunCommandState> {+ /**+ * Program brand icon (e.g. Node.js / Git / Python). When provided it leads the whole row —+ * placed before the label — and the command chip drops its terminal glyph. When omitted, the+ * default terminal glyph stays inside the command chip.+ */+ icon?: ComponentType<{ className?: string; size?: number }>;/** i18n key for the API name label, e.g. 'builtins.lobe-local-system.apiName.runCommand' */translationKey: string;}export const RunCommandInspector = memo<RunCommandInspectorProps>(- ({ args, partialArgs, isArgumentsStreaming, pluginState, isLoading, translationKey }) => {+ ({+ args,+ partialArgs,+ isArgumentsStreaming,+ pluginState,+ isLoading,+ translationKey,+ icon: BrandIcon,+ }) => {const { t } = useTranslation('plugin');const command = getRunCommandDisplayCommand(args?.command || partialArgs?.command);const description = args?.description || partialArgs?.description || command;+ // Brand icon leads the row (before the label); otherwise the terminal glyph sits in the chip.+ const leading = BrandIcon ? <BrandIcon className={styles.leadingIcon} size={14} /> : null;+ const chipIcon = BrandIcon ? null : (+ <SquareChevronRight className={styles.terminalIcon} size={14} />+ );+if (isArgumentsStreaming) {if (!description)return (<div className={cx(inspectorTextStyles.root, shinyTextStyles.shinyText)}>+ {leading}<span>{t(translationKey as any)}</span></div>);return (<div className={cx(inspectorTextStyles.root, shinyTextStyles.shinyText)}>+ {leading}<span>{t(translationKey as any)}:</span><span className={styles.chip}>- <SquareChevronRight className={styles.terminalIcon} size={14} />+ {chipIcon}<span className={styles.command}>{description}</span></span></div>@@ -91,10 +118,11 @@ export const RunCommandInspector = memo<RunCommandInspectorProps>(return (<div className={cx(inspectorTextStyles.root, isLoading && shinyTextStyles.shinyText)}>+ {leading}<span>{t(translationKey as any)}:</span>{description && (<span className={styles.chip}>- <SquareChevronRight className={styles.terminalIcon} size={14} />+ {chipIcon}<span className={styles.command}>{description}</span></span>)}