feat(web): add Skill draft creation UI

This commit is contained in:
yu
2026-08-05 02:46:18 +08:00
parent f01cb889ef
commit 98858ada4f
8 changed files with 222 additions and 36 deletions
@@ -17,7 +17,7 @@ import { useShallow } from "zustand/react/shallow";
import { useAgentStore, type AgentCanvasContext, type AgentChatItem, type AgentModel, type AgentPendingApproval, type AgentPendingToolCall, type AgentPermissionMode, type AgentReasoningEffort, type AgentThreadSummary } from "@/stores/use-agent-store";
import { type CanvasAgentOp, type CanvasAgentSnapshot } from "@/lib/canvas/canvas-agent-ops";
import { isSiteTool, runSiteTool } from "@/lib/agent/agent-site-tools";
import { acknowledgeCodexHistory, activateAgentClient, discoverAgentConfig, fetchAgentJson, postCodexApproval, postState, postToolResult } from "@/services/api/canvas-agent";
import { acknowledgeCodexHistory, activateAgentClient, discoverAgentConfig, fetchAgentJson, interruptCodexTurn, postCodexApproval, postState, postToolResult } from "@/services/api/canvas-agent";
import { AgentChatTimeline, AgentTaskProgress, AgentUsageBar } from "./agent-chat";
import { AgentChatComposer } from "./agent-chat-composer";
import { AgentConnectView } from "./agent-connect-view";
@@ -66,7 +66,7 @@ import { AgentSkillsView } from "./agent-skills-view";
const MAX_ATTACHMENTS = 6;
const MAX_ATTACHMENT_PAYLOAD_BYTES = 28 * 1024 * 1024;
const DEFAULT_AGENT_URL = "http://127.0.0.1:17371";
const AGENT_PROTOCOL_VERSION = 4;
const AGENT_PROTOCOL_VERSION = 5;
const HISTORY_RETRY_DELAYS_MS = [0, 150, 350, 700, 1200];
const AGENT_REASONING_EFFORTS = new Set<AgentReasoningEffort>(["minimal", "low", "medium", "high", "xhigh", "max", "ultra"]);
const AGENT_REASONING_LABELS: Record<AgentReasoningEffort, string> = { minimal: "最低", low: "轻度", medium: "中", high: "高", xhigh: "极高", max: "最高", ultra: "Ultra" };
@@ -676,10 +676,11 @@ export function LocalAgentPanel({ embedded, headless, autoConnect }: { embedded?
if (!connected || (!sending && !waiting)) return;
setAgentState({ activity: "停止中" });
try {
await fetch(`${endpoint}/agent/codex/interrupt?token=${encodeURIComponent(token)}`, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ threadId: useAgentStore.getState().activeThreadId || undefined }) });
addEventLog("停止任务", "已发送停止请求");
} catch {
await interruptCodexTurn(endpoint, token, useAgentStore.getState().activeThreadId || undefined);
addEventLog("停止任务", "任务已停止");
} catch (error) {
setAgentState({ activity: "停止失败" });
addEventLog("停止失败", error);
}
};
@@ -1281,7 +1282,7 @@ export function LocalAgentPanel({ embedded, headless, autoConnect }: { embedded?
onToggleEnabled={toggleAgentConnection}
/>
) : activeTab === "skills" ? (
<AgentSkillsView />
<AgentSkillsView clientId={clientIdRef.current} />
) : activeTab === "history" ? (
<AgentHistoryView
theme={theme}