/* eslint-disable react-refresh/only-export-components */ import { useMemo, useSyncExternalStore } from "react"; import { AuiConfig, Tools, defineToolkit, useExternalStoreRuntime, type ToolCallMessagePartComponent } from "@assistant-ui/react"; import type { HarnessClientStore } from "./HarnessClientStore.js"; const AdsTool: ToolCallMessagePartComponent, unknown> = ({ args, result, status }) =>
mock_ads_metrics{status.type}

账户:{String(args.accountId ?? "等待参数")}

范围:最近 {String(args.days ?? "–")} 天

{result !== undefined &&
{JSON.stringify(result, null, 2).slice(0, 800)}
}
; const AnalyzeReportTool: ToolCallMessagePartComponent, unknown> = ({ args, result, status }) =>
analyze_uploaded_report{status.type}

正在解析上传的 Excel/CSV 日报

附件:{String(args.attachmentId ?? "等待附件")}

{result !== undefined &&

表格证据已生成,Agent 正在形成日报结论。

}
; const BuildBriefTool: ToolCallMessagePartComponent, unknown> = ({ args, result, status }) =>
build_daily_brief{status.type}

正在套用 daily-campaign-triage 固定四段式模板

日报日期:{String(args.analysis_date ?? "等待日期")}

{result !== undefined &&

Skill 模板 Word 已生成,可点击下载。

}
; export const toolkit = defineToolkit({ mock_ads_metrics: { type: "backend", display: "standalone", render: AdsTool }, analyze_uploaded_report: { type: "backend", display: "standalone", render: AnalyzeReportTool }, build_daily_brief: { type: "backend", display: "standalone", render: BuildBriefTool } }); export const harnessAuiConfig = AuiConfig({ tools: Tools({ toolkit }) }); export function useHarnessRuntime(store: HarnessClientStore) { const snapshot = useSyncExternalStore(store.subscribe, store.getSnapshot); const runtime = useExternalStoreRuntime({ messages: snapshot.messages, convertMessage: (message) => message, isRunning: snapshot.running, isSendDisabled: !snapshot.model.configured, onNew: store.onNew, onCancel: store.cancel, adapters: { attachments: store.attachmentAdapter } }); return useMemo(() => ({ runtime, snapshot }), [runtime, snapshot]); }