import type { ComponentType } from "react"; import { Button, Tag } from "@douyinfe/semi-ui-19"; import { ResearchToolCard } from "../research/ResearchToolCard"; import { BacktestToolCard } from "../backtests/BacktestToolCard"; import { CatalogToolCard } from "../research/CatalogToolCard"; import { AlphaToolCard } from "./AlphaToolCard"; import { JobToolCard } from "./JobToolCard"; import type { ToolCardProps } from "./types"; // The server owns labels, effects and refresh targets. This is the only place // where a new presentation shape joins the workspace; tool names are domain-local. const renderers: Record> = { research: ResearchToolCard, alpha: AlphaToolCard, jobs: JobToolCard, catalog: CatalogToolCard, backtest: BacktestToolCard, }; const labels: Record = { pending: "待确认", completed: "已完成", failed: "失败", denied: "已拒绝", cancelled: "已取消", }; export function BusinessCard( props: ToolCardProps & { onDecision: (id: string, approved: boolean) => Promise; disabled: boolean; }, ) { const { call, onDecision, disabled } = props; const renderer = call.presentation?.renderer ?? "generic"; const Renderer = Object.hasOwn(renderers, renderer) ? renderers[renderer] : undefined; const pending = call.status === "pending"; const result = call.result ?? {}; return (
{call.presentation?.label ?? call.name} {labels[call.status] ?? call.status}
{Renderer ? ( ) : ( <>

此记录暂不支持专用展示,原始结果仍可查看。

查看业务记录
              {JSON.stringify(pending ? call.preview : result, null, 2)}
            
)} {pending && (

确认后执行以上预览中的固定操作。

)} {typeof result.error === "string" && (

{result.error}

)} {typeof result._warning === "string" && (

{result._warning}

)} {result.denied === true &&

已拒绝,未执行此操作。

}
); }