feat: add system tools and state updates

This commit is contained in:
Xin Wang
2026-08-04 15:27:39 +08:00
parent 5bf5987fe4
commit 731a372df9
33 changed files with 1787 additions and 124 deletions
+12 -4
View File
@@ -216,6 +216,12 @@ export type StartupConfig = {
} | null;
};
export type SystemToolKind =
| "end_conversation"
| "update_state"
| "skip_turn"
| "request_human_handoff";
/** 后端 AssistantOut(宽表 STI:瘦字段平铺,workflow 用 graph)。apiKey 读时打码 */
export type Assistant = {
id: string;
@@ -226,6 +232,7 @@ export type Assistant = {
enableInterrupt: boolean;
turnConfig: TurnConfig;
startup: StartupConfig;
systemTools: SystemToolKind[];
visionEnabled: boolean;
visionModelResourceId: string | null;
modelResourceIds: Partial<Record<ModelType, string>>;
@@ -354,10 +361,11 @@ export type ToolParameter = {
required: boolean;
};
export type EndCallToolDefinition = {
export type SystemToolDefinition = {
schemaVersion: number;
type: "end_call";
type: "system";
config: {
kind: "end_conversation";
messageType: "none" | "custom";
customMessage: string;
captureReason: boolean;
@@ -411,10 +419,10 @@ export type Tool = {
id: string;
name: string;
functionName: string;
type: "end_call" | "http" | "mcp" | "client";
type: "system" | "http" | "mcp" | "client";
description: string;
definition:
| EndCallToolDefinition
| SystemToolDefinition
| HttpToolDefinition
| ClientToolDefinition
| McpToolDefinition;
+28
View File
@@ -0,0 +1,28 @@
import type { SystemToolKind } from "@/lib/api";
export const SYSTEM_TOOL_OPTIONS: Array<{
value: SystemToolKind;
label: string;
description: string;
}> = [
{
value: "end_conversation",
label: "结束对话",
description: "模型可在用户告别或任务完成时主动结束通话。",
},
{
value: "update_state",
label: "更新状态",
description: "模型可更新明确授权的动态变量,记录本轮获得的信息。",
},
{
value: "skip_turn",
label: "跳过本轮",
description: "用户要求稍等、话未说完或输入只是噪音时保持静默。",
},
{
value: "request_human_handoff",
label: "请求人工接管",
description: "模型可提交人工接管请求;请求成功不代表人工已经接通。",
},
];