F3: configure Speaker and task backends in prompt mode

This commit is contained in:
Xin Wang
2026-10-23 23:46:40 +08:00
parent 16ebfe358c
commit fff76fe889
16 changed files with 598 additions and 92 deletions
+56 -18
View File
@@ -406,6 +406,7 @@ export type Assistant = {
knowledgeBaseId: string | null;
knowledgeRetrievalConfig: KnowledgeRetrievalConfig;
toolBindings: ToolBinding[];
taskBackend: AssistantTaskBackend | null;
builtInTools: BuiltInTools;
prompt: string;
dynamicVariableDefinitions: Record<string, DynamicVariableDefinition>;
@@ -623,31 +624,16 @@ export type McpToolDefinition = {
};
};
export type TaskToolDefinition = {
schemaVersion: number;
type: "task";
config: {
provider: "opencode";
url: string;
directory: string;
username: string;
timeoutSeconds: number;
allowInterruptions: true;
executionMode: "immediate";
};
};
export type Tool = {
id: string;
name: string;
functionName: string;
type: "http" | "mcp" | "client" | "task";
type: "http" | "mcp" | "client";
description: string;
definition:
| HttpToolDefinition
| ClientToolDefinition
| McpToolDefinition
| TaskToolDefinition;
| McpToolDefinition;
secrets: Record<string, unknown>;
status: ToolStatus;
mcpServerId?: string | null;
@@ -982,12 +968,64 @@ export const batchRunsApi = {
),
};
// ---------- 任务后端资源 ----------
export type TaskBackendType = "reasoner" | "opencode";
export type ReasoningEffort = "provider_default" | "low" | "medium" | "high";
export type TaskSkill = { name: string; content: string };
export type TaskBackendCommonConfig = {
instructions: string;
timeoutSeconds: number;
maxConcurrency: 1;
};
export type ReasonerBackendConfig = TaskBackendCommonConfig & {
modelResourceId: string;
reasoningEffort: ReasoningEffort;
toolBindings: ToolBinding[];
skills: TaskSkill[];
};
export type OpenCodeBackendConfig = TaskBackendCommonConfig & {
url: string;
directory: string;
username: string;
agent: string;
modelProviderId: string;
modelId: string;
skillsNote: string;
};
type TaskBackendKind =
| { type: "reasoner"; config: ReasonerBackendConfig }
| { type: "opencode"; config: OpenCodeBackendConfig };
export type TaskBackendUpsert = TaskBackendKind & {
name: string;
description: string;
secrets: Record<string, unknown>;
enabled: boolean;
};
export type TaskBackendResource = TaskBackendUpsert & {
id: string;
updatedAt?: string | null;
};
export type AssistantTaskBackend = {
backendId: string;
instructions: string;
instructionSource: ValueSource;
};
export const taskBackendsApi = {
list: () => request<TaskBackendResource[]>("/api/task-backends"),
create: (body: TaskBackendUpsert) => request<TaskBackendResource>("/api/task-backends", { method: "POST", body: JSON.stringify(body) }),
update: (id: string, body: TaskBackendUpsert) => request<TaskBackendResource>(`/api/task-backends/${id}`, { method: "PUT", body: JSON.stringify(body) }),
duplicate: (id: string) => request<TaskBackendResource>(`/api/task-backends/${id}/duplicate`, { method: "POST" }),
remove: (id: string) => request<{ ok: boolean }>(`/api/task-backends/${id}`, { method: "DELETE" }),
};
// ---------- 提示词后台任务 ----------
export type BackgroundTask = {
id: string;
assistantId: string;
conversationId: string;
toolId: string;
backendId: string | null;
backendType: TaskBackendType;
toolId?: string | null;
instruction: string;
status: "queued" | "submitted" | "running" | "waiting_input" | "cancel_requested" | "succeeded" | "failed" | "cancelled" | "unknown";
summary: string;