Skip to content

JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.

Python

feat(web): add enterprise skill management UI

huben62e543ca8e1b
diff --git a/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/InputArea.tsx b/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/InputArea.tsx
index 5a17a5283e..3624b0feda 100644
--- a/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/InputArea.tsx
+++ b/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/InputArea.tsx
@@ -63,6 +63,8 @@ type InputAreaSkillItem = {
is_builtin?: boolean;
is_builtin_source?: boolean;
enabled?: boolean;
+ installed?: boolean;
+ source_type?: 'prebuilt' | 'user' | string;
};
/** 已安装插件信息(用于判定技能是否已安装) */
@@ -3000,6 +3002,7 @@ function SkillSelector({ onNavigateToSkills, onInsertSkill, onRemoveSkill }: {
const isSkillInstalled = useCallback(
(skill: InputAreaSkillItem): boolean =>
+ skill.installed === true ||
installedSkillMap.has(skill.name) ||
skill.source === 'local' ||
skill.source === 'project',
diff --git a/jiuwenswarm/channels/web/frontend/src/components/SkillPanel/index.tsx b/jiuwenswarm/channels/web/frontend/src/components/SkillPanel/index.tsx
index 7a879d5c2f..94be7e18f0 100644
--- a/jiuwenswarm/channels/web/frontend/src/components/SkillPanel/index.tsx
+++ b/jiuwenswarm/channels/web/frontend/src/components/SkillPanel/index.tsx
@@ -11,6 +11,8 @@ import { SourceManagerModal } from "../../features/SourceManagerModal";
import { SkillNetSearchModal } from "../../features/SkillNetSearchModal";
import { ClawHubSearchModal } from "../../features/ClawHubSearchModal";
import { TeamSkillsHubModal } from "../../features/TeamSkillsHubModal";
+import { EnterpriseSkillSourcePanel } from "../../features/EnterpriseSkillSourcePanel";
+import { Pagination } from "../common/Pagination";
import { OnlineSkillSearchPanel } from "../../features/OnlineSkillSearchPanel";
import { SkillEvolutionModal } from "../../features/SkillEvolutionModal";
import { normalizeSkillNetUrl } from "../../utils/skillNetUrl";
@@ -26,6 +28,7 @@ const SKILLS_FETCH_TIMEOUT_NORMAL_MS = 30_000;
const SKILL_RETRIEVAL_RUNNING_POLL_MS = 10_000;
const SKILL_RETRIEVAL_IDLE_POLL_MS = 5 * 60_000;
const GRAPH_READING_MIN_VISIBLE_MS = 500;
+const MY_SKILLS_PAGE_SIZE = 20;
type SkillItem = {
name: string;
@@ -52,6 +55,12 @@ type SkillItem = {
has_evolutions?: boolean;
/** 是否启用 */
enabled?: boolean;
+ /** 是否已落盘并登记(企业 DTO) */
+ installed?: boolean;
+ /** 企业安装类型;prebuilt 由管理员统一管理 */
+ source_type?: 'prebuilt' | 'user' | string;
+ /** 是否允许当前调用方卸载(企业 DTO) */
+ removable?: boolean;
};
type InstalledPluginItem = {
@@ -142,17 +151,22 @@ interface SkillPanelProps {
isActive?: boolean;
}
-function getSourceLabel(source: string, t: (key: string) => string, isBuiltinSource?: boolean): string {
+function getSourceLabel(source: string, t: (key: string) => string, isBuiltinSource?: boolean, sourceType?: string): string {
+ if (sourceType === 'prebuilt') return t('skills.enterprisePrebuilt');
if (isBuiltinSource) return t('skills.source.builtin');
if (source === "local") return t('skills.source.local');
if (source === "project") return t('skills.source.project');
if (source === "builtin") return t('skills.source.builtin');
if (source === "clawhub") return t('skills.source.clawhub');
if (source === "skillnet") return t('skills.source.skillnet');
- if (source === "teamskillshub") return t('skills.source.teamskillshub');
+ if (source === "teamskillshub" || source === "swarmskillhub") return t('skills.source.teamskillshub');
return source || t('skills.source.unknown');
}
+function isAdministratorManagedSkill(skill: SkillItem): boolean {
+ return skill.source_type === 'prebuilt';
+}
+
/** 与后端一致:tags/allowed_tools 可能是逗号分隔字符串,统一为 string[] */
function coerceStringList(val: unknown): string[] {
if (val == null) return [];
@@ -590,6 +604,7 @@ export function SkillPanel({ sessionId, onNavigateToConfig, isActive = false }:
const readOnly = isEnterprise();
const [activeTab, setActiveTab] = useState<"my" | "marketplace" | "index" | "graph">("my");
const [mySkillsSubTab, setMySkillsSubTab] = useState<"all" | "enabled" | "disabled">("all");
+ const [mySkillsPage, setMySkillsPage] = useState(1);
const [marketplaceSubTab, setMarketplaceSubTab] = useState<"builtin" | "swarmskills" | "online">("builtin");
const [searchTrigger, setSearchTrigger] = useState(0);
const [skills, setSkills] = useState<SkillItem[]>([]);
@@ -718,8 +733,8 @@ export function SkillPanel({ sessionId, onNavigateToConfig, isActive = false }:
}, [plugins]);
const installedSkillNames = useMemo(
- () => new Set(installedSkillMap.keys()),
- [installedSkillMap]
+ () => new Set([...installedSkillMap.keys(), ...skills.filter((skill) => skill.installed === true).map((skill) => skill.name)]),
+ [installedSkillMap, skills]
);
/** 已安装技能的来源 URL(规范化),与 SkillNet 搜索结果的 skill_url 匹配 */
@@ -737,10 +752,11 @@ export function SkillPanel({ sessionId, onNavigateToConfig, isActive = false }:
const filteredSkills = useMemo(() => {
let result = skills;
if (activeTab === "my") {
- result = result.filter((skill) =>
- installedSkillMap.has(skill.name) ||
- skill.source === "local" ||
- skill.is_builtin === true ||
+ result = result.filter((skill) =>
+ skill.installed === true ||
+ installedSkillMap.has(skill.name) ||
+ skill.source === "local" ||
+ skill.is_builtin === true ||
skill.is_builtin_source === true
);
}
@@ -764,7 +780,7 @@ export function SkillPanel({ sessionId, onNavigateToConfig, isActive = false }:
let filtered = [...filteredSkills];
if (activeTab === "my") {
filtered = filtered.filter((skill) => {
- if (skill.is_builtin_source && !installedSkillMap.has(skill.name) && skill.source !== "local") {
+ if (skill.is_builtin_source && !skill.is_builtin && skill.installed !== true && !installedSkillMap.has(skill.name) && skill.source !== "local") {
return false;
}
return true;
@@ -827,12 +843,14 @@ export function SkillPanel({ sessionId, onNavigateToConfig, isActive = false }:
setPlugins(data.plugins || []);
setListState("success");
- fetchMarketplaces();
+ if (!readOnly) {
+ fetchMarketplaces();
+ }
} catch (error) {
console.error(error);
setListState("error");
}
- }, [fetchMarketplaces, withSession]);
+ }, [fetchMarketplaces, readOnly, withSession]);
const fetchSkillDetail = useCallback(
async (skillName: string, origin?: string) => {
@@ -932,8 +950,9 @@ export function SkillPanel({ sessionId, onNavigateToConfig, isActive = false }:
}, [isActive, activeTab, fetchSkills]);
useEffect(() => {
+ if (readOnly) return;
fetchRetrievalStatus();
- }, [fetchRetrievalStatus]);
+ }, [fetchRetrievalStatus, readOnly]);
useEffect(() => {
if (retrievalStatus?.build_status === "running") {
@@ -1270,11 +1289,23 @@ export function SkillPanel({ sessionId, onNavigateToConfig, isActive = false }:
);
const renderActionButton = (skill: SkillItem) => {
+ if (isAdministratorManagedSkill(skill)) {
+ return (
+ <button
+ className="px-4 py-2 rounded-2xl text-sm text-text-muted cursor-not-allowed whitespace-nowrap border border-gray-300"
+ disabled
+ title={t('skills.enterpriseManagedHint')}
+ >
+ {t('skills.enterprisePrebuilt')}
+ </button>
+ );
+ }
+
const plugin = installedSkillMap.get(skill.name);
// 未安装到用户目录的内置技能(来自内置目录,需要安装)
// 判断条件:is_builtin_source 为 true 且不在已安装列表中
- const isInstalled = installedSkillMap.has(skill.name) || skill.source === "local";
+ const isInstalled = skill.installed === true || installedSkillMap.has(skill.name) || skill.source === "local";
if (skill.is_builtin_source && !isInstalled) {
const isLoading = actionTarget === `${skill.name}@builtin`;
return (
@@ -1386,6 +1417,7 @@ export function SkillPanel({ sessionId, onNavigateToConfig, isActive = false }:
};
const renderStatus = (skill: SkillItem) => {
+ if (skill.installed === true) return t('skills.status.installed');
if (installedSkillMap.has(skill.name)) return t('skills.status.installed');
if (skill.source === "local") return t('skills.status.installed');
if (skill.is_builtin) {
@@ -1396,7 +1428,7 @@ export function SkillPanel({ sessionId, onNavigateToConfig, isActive = false }:
};
const isSkillInstalled = (skill: SkillItem): boolean => {
- return installedSkillMap.has(skill.name) || skill.source === "local" || skill.source === "project";
+ return skill.installed === true || installedSkillMap.has(skill.name) || skill.source === "local" || skill.source === "project";
};
const getMySkillsFiltered = useCallback(() => {
@@ -1414,9 +1446,28 @@ export function SkillPanel({ sessionId, onNavigateToConfig, isActive = false }:
return filtered;
}, [visibleSkills, mySkillsSubTab, installedSkillMap]);
+ const mySkillsFiltered = useMemo(() => getMySkillsFiltered(), [getMySkillsFiltered]);
+ const mySkillsTotalPages = Math.max(1, Math.ceil(mySkillsFiltered.length / MY_SKILLS_PAGE_SIZE));
+ const pagedMySkills = useMemo(
+ () => mySkillsFiltered.slice(
+ (mySkillsPage - 1) * MY_SKILLS_PAGE_SIZE,
+ mySkillsPage * MY_SKILLS_PAGE_SIZE
+ ),
+ [mySkillsFiltered, mySkillsPage]
+ );
+
+ useEffect(() => {
+ setMySkillsPage(1);
+ }, [mySkillsSubTab, debouncedSearch, viewMode]);
+
+ useEffect(() => {
+ if (mySkillsPage > mySkillsTotalPages) setMySkillsPage(mySkillsTotalPages);
+ }, [mySkillsPage, mySkillsTotalPages]);
+
const toggleSkillDisabled = async (skillName: string, origin?: string) => {
// 找技能时优先按 origin 定位(同名不同源时精确匹配),无 origin 时按 name 回退
const skill = skills.find(s => s.name === skillName && (!origin || s.origin === origin));
+ if (skill && isAdministratorManagedSkill(skill)) return;
const newEnabled = skill?.enabled === false ? true : false;
const toggleKey = `toggle:${origin || skillName}`;
@@ -1649,7 +1700,10 @@ export function SkillPanel({ sessionId, onNavigateToConfig, isActive = false }:
{t('skills.tabs.mySkills')}
</button>
<button
- onClick={() => setActiveTab("marketplace")}
+ onClick={() => {
+ setActiveTab("marketplace");
+ if (readOnly) setMarketplaceSubTab("swarmskills");
+ }}
className={`px-4 text-sm font-medium ${
activeTab === "marketplace"
? "rounded-[8px] bg-secondary h-8 text-text"
@@ -1658,26 +1712,30 @@ export function SkillPanel({ sessionId, onNavigateToConfig, isActive = false }:
>
{t('skills.tabs.marketplace')}
</button>
- <button
- onClick={() => setActiveTab("graph")}
- className={`px-4 text-sm font-medium ${
- activeTab === "graph"
- ? "rounded-[8px] bg-secondary h-8 text-text"
- : "text-text-muted hover:text-text"
- }`}
- >
- {t('skills.tabs.skillGraph')}
- </button>
- <button
- onClick={() => setActiveTab("index")}
- className={`px-4 text-sm font-medium ${
- activeTab === "index"
- ? "rounded-[8px] bg-secondary h-8 text-text"
- : "text-text-muted hover:text-text"
- }`}
- >
- {t('skills.tabs.skillIndex')}
- </button>
+ {!readOnly && (
+ <button
+ onClick={() => setActiveTab("graph")}
+ className={`px-4 text-sm font-medium ${
+ activeTab === "graph"
+ ? "rounded-[8px] bg-secondary h-8 text-text"
+ : "text-text-muted hover:text-text"
+ }`}
+ >
+ {t('skills.tabs.skillGraph')}
+ </button>
+ )}
+ {!readOnly && (
+ <button
+ onClick={() => setActiveTab("index")}
+ className={`px-4 text-sm font-medium ${
+ activeTab === "index"
+ ? "rounded-[8px] bg-secondary h-8 text-text"
+ : "text-text-muted hover:text-text"
+ }`}
+ >
+ {t('skills.tabs.skillIndex')}
+ </button>
+ )}
</div>
{activeTab !== "index" && activeTab !== "graph" ? (
<div className="flex items-center gap-1 border border-border rounded-lg p-1">
@@ -1941,24 +1999,26 @@ export function SkillPanel({ sessionId, onNavigateToConfig, isActive = false }:
</div>
) : null}
- {!readOnly && activeTab === "marketplace" ? (
+ {activeTab === "marketplace" ? (
<>
<div className="mt-4 flex items-center justify-between gap-4">
<div className="flex items-center gap-2">
- <button
- onClick={() => {
- setMarketplaceSubTab("builtin");
- setDebouncedSearch(search);
- setSearchTrigger((prev) => prev + 1);
- }}
- className={`px-4 text-sm font-medium ${
- marketplaceSubTab === "builtin"
- ? "rounded-[8px] bg-secondary h-8 text-text"
- : "text-text-muted hover:text-text"
- }`}
- >
- {t('skills.marketplaceTabs.builtin')}
- </button>
+ {!readOnly && (
+ <button
+ onClick={() => {
+ setMarketplaceSubTab("builtin");
+ setDebouncedSearch(search);
+ setSearchTrigger((prev) => prev + 1);
+ }}
+ className={`px-4 text-sm font-medium ${
+ marketplaceSubTab === "builtin"
+ ? "rounded-[8px] bg-secondary h-8 text-text"
+ : "text-text-muted hover:text-text"
+ }`}
+ >
+ {t('skills.marketplaceTabs.builtin')}
+ </button>
+ )}
<button
onClick={() => {
setMarketplaceSubTab("swarmskills");
@@ -1973,36 +2033,40 @@ export function SkillPanel({ sessionId, onNavigateToConfig, isActive = false }:
>
{t('skills.swarmskills.title')}
</button>
- <button
- onClick={() => {
- setMarketplaceSubTab("online");
- setDebouncedSearch(search);
- setSearchTrigger((prev) => prev + 1);
- }}
- className={`px-4 text-sm font-medium ${
- marketplaceSubTab === "online"
- ? "rounded-[8px] bg-secondary h-8 text-text"
- : "text-text-muted hover:text-text"
- }`}
- >
- {t('skills.onlineSearch.title')}
- </button>
- </div>
- <div className="flex-1">
- <input
- type="text"
- value={search}
- onChange={(e) => setSearch(e.target.value)}
- placeholder={
- marketplaceSubTab === "builtin"
- ? t("skills.searchPlaceholder")
- : marketplaceSubTab === "swarmskills"
- ? t("skills.swarmskills.searchPlaceholder")
- : t("skills.onlineSearch.searchPlaceholder")
- }
- className="w-full px-3 py-1.5 rounded-lg text-sm bg-secondary border border-border text-text placeholder:text-text-muted"
- />
+ {!readOnly && (
+ <button
+ onClick={() => {
+ setMarketplaceSubTab("online");
+ setDebouncedSearch(search);
+ setSearchTrigger((prev) => prev + 1);
+ }}
+ className={`px-4 text-sm font-medium ${
+ marketplaceSubTab === "online"
+ ? "rounded-[8px] bg-secondary h-8 text-text"
+ : "text-text-muted hover:text-text"
+ }`}
+ >
+ {t('skills.onlineSearch.title')}
+ </button>
+ )}
</div>
+ {(marketplaceSubTab !== "swarmskills" || !readOnly) && (
+ <div className="flex-1">
+ <input
+ type="text"
+ value={search}
+ onChange={(e) => setSearch(e.target.value)}
+ placeholder={
+ marketplaceSubTab === "builtin"
+ ? t("skills.searchPlaceholder")
+ : marketplaceSubTab === "swarmskills"
+ ? t("skills.swarmskills.searchPlaceholder")
+ : t("skills.onlineSearch.searchPlaceholder")
+ }
+ className="w-full px-3 py-1.5 rounded-lg text-sm bg-secondary border border-border text-text placeholder:text-text-muted"
+ />
+ </div>
+ )}
</div>
<div className={`mt-4 flex-1 min-h-0 overflow-y-auto ${viewMode === "grid" && marketplaceSubTab === "builtin" ? "flex flex-wrap gap-4 content-start" : "space-y-3"}`}>
@@ -2023,7 +2087,7 @@ export function SkillPanel({ sessionId, onNavigateToConfig, isActive = false }:
const displayName = skill.display_name || skill.name;
const isDisabled = skill.enabled === false;
const isToggling = actionTarget === `toggle:${skill.name}`;
- const isInstalled = installedSkillMap.has(skill.name) || skill.source === "local";
+ const isInstalled = skill.installed === true || installedSkillMap.has(skill.name) || skill.source === "local";
const isInstalling = actionTarget === `${skill.name}@builtin`;
return (
<div
@@ -2085,7 +2149,7 @@ export function SkillPanel({ sessionId, onNavigateToConfig, isActive = false }:
</div>
<div className="flex flex-wrap gap-1.5 mt-2 flex-shrink-0 text-xs text-text-muted">
<span className="px-2 py-0.5 rounded-full bg-secondary border border-border truncate">
- {t('skills.sourceLabel')}: {getSourceLabel(skill.source, t, skill.is_builtin_source)}
+ {t('skills.sourceLabel')}: {getSourceLabel(skill.source, t, skill.is_builtin_source, skill.source_type)}
</span>
</div>
<div className="flex items-center mt-auto pt-2 gap-2 flex-shrink-0" style={{ width: "100%" }}>
@@ -2107,18 +2171,28 @@ export function SkillPanel({ sessionId, onNavigateToConfig, isActive = false }:
{marketplaceSubTab === "swarmskills" && (
<div className="h-full" key={`swarmskills-${searchTrigger}`}>
- <TeamSkillsHubModal
- open={true}
- embedded={true}
- sessionId={sessionId}
- externalSearchQuery={debouncedSearch}
- installedSkillOrigins={installedSkillOrigins}
- viewMode={viewMode}
- onClose={() => {}}
- onInstalled={(_skillName: string) => {
- void fetchSkills();
- }}
- />
+ {readOnly ? (
+ <EnterpriseSkillSourcePanel
+ sessionId={sessionId}
+ viewMode={viewMode}
+ onInstalled={() => {
+ void fetchSkills();
+ }}
+ />
+ ) : (
+ <TeamSkillsHubModal
+ open={true}
+ embedded={true}
+ sessionId={sessionId}
+ externalSearchQuery={debouncedSearch}
+ installedSkillOrigins={installedSkillOrigins}
+ viewMode={viewMode}
+ onClose={() => {}}
+ onInstalled={(_skillName: string) => {
+ void fetchSkills();
+ }}
+ />
+ )}
</div>
)}
@@ -2177,7 +2251,7 @@ export function SkillPanel({ sessionId, onNavigateToConfig, isActive = false }:
</div>
<div className="flex flex-wrap gap-2 mt-3 text-xs text-text-muted">
<span className="px-2 py-1 rounded-full bg-secondary border border-border">
- {t('skills.sourceLabel')}: {getSourceLabel(selectedSkill.source, t, selectedSkill.is_builtin_source)}
+ {t('skills.sourceLabel')}: {getSourceLabel(selectedSkill.source, t, selectedSkill.is_builtin_source, selectedSkill.source_type)}
</span>
<span className="px-2 py-1 rounded-full bg-secondary border border-border">
{t('skills.versionLabel')}: {selectedSkill.version || 'unknown'}
@@ -2196,12 +2270,15 @@ export function SkillPanel({ sessionId, onNavigateToConfig, isActive = false }:
<Switch
checked={selectedSkill.enabled !== false}
onChange={() => toggleSkillDisabled(selectedSkill.name, selectedSkill.origin)}
- disabled={actionTarget === `toggle:${selectedSkill.origin || selectedSkill.name}`}
+ disabled={
+ actionTarget === `toggle:${selectedSkill.origin || selectedSkill.name}` ||
+ isAdministratorManagedSkill(selectedSkill)
+ }
/>
</div>
{renderActionButton(selectedSkill)}
</div>
- {renderEvolutionButton(selectedSkill)}
+ {!readOnly && renderEvolutionButton(selectedSkill)}
</div>
</div>
@@ -2279,7 +2356,7 @@ export function SkillPanel({ sessionId, onNavigateToConfig, isActive = false }:
/>
</div>
<div className="text-xs text-text-muted flex-shrink-0">
- {t('skills.totalCount', { count: getMySkillsFiltered().length })}
+ {t('skills.totalCount', { count: mySkillsFiltered.length })}
</div>
</div>
@@ -2292,7 +2369,7 @@ export function SkillPanel({ sessionId, onNavigateToConfig, isActive = false }:
{t('skills.listError')}
</div>
)}
- {listState === "success" && getMySkillsFiltered().length === 0 && (
+ {listState === "success" && mySkillsFiltered.length === 0 && (
<div className="text-sm text-text-muted">
{mySkillsSubTab === "disabled" ? t('skills.noDisabledSkills') :
mySkillsSubTab === "enabled" ? t('skills.noEnabledSkills') :
@@ -2300,7 +2377,7 @@ export function SkillPanel({ sessionId, onNavigateToConfig, isActive = false }:
</div>
)}
{listState === "success" &&
- getMySkillsFiltered().map((skill) => {
+ pagedMySkills.map((skill) => {
const avatar = getSkillAvatar(skill.name);
const displayName = skill.display_name || skill.name;
const isDisabled = skill.enabled === false;
@@ -2327,7 +2404,7 @@ export function SkillPanel({ sessionId, onNavigateToConfig, isActive = false }:
</div>
<div className="flex flex-wrap gap-2 mt-3 text-xs text-text-muted">
<span className="px-2 py-1 rounded-full bg-secondary border border-border">
- {t('skills.sourceLabel')}: {getSourceLabel(skill.source, t, skill.is_builtin_source)}
+ {t('skills.sourceLabel')}: {getSourceLabel(skill.source, t, skill.is_builtin_source, skill.source_type)}
</span>
<span className="px-2 py-1 rounded-full bg-secondary border border-border">
{t('skills.statusLabel')}: {renderStatus(skill)}
@@ -2341,7 +2418,7 @@ export function SkillPanel({ sessionId, onNavigateToConfig, isActive = false }:
<Switch
checked={!isDisabled}
onChange={() => toggleSkillDisabled(skill.name, skill.origin)}
- disabled={readOnly || isToggling}
+ disabled={isToggling || isAdministratorManagedSkill(skill)}
/>
</div>
</div>
@@ -2363,7 +2440,7 @@ export function SkillPanel({ sessionId, onNavigateToConfig, isActive = false }:
</div>
<div className="flex flex-wrap gap-1.5 mt-2 flex-shrink-0 text-xs text-text-muted">
<span className="px-2 py-0.5 rounded-full bg-secondary border border-border truncate">
- {t('skills.sourceLabel')}: {getSourceLabel(skill.source, t, skill.is_builtin_source)}
+ {t('skills.sourceLabel')}: {getSourceLabel(skill.source, t, skill.is_builtin_source, skill.source_type)}
</span>
<span className="px-2 py-0.5 rounded-full bg-secondary border border-border truncate">
{t('skills.statusLabel')}: {renderStatus(skill)}
@@ -2377,7 +2454,7 @@ export function SkillPanel({ sessionId, onNavigateToConfig, isActive = false }:
<Switch
checked={!isDisabled}
onChange={() => toggleSkillDisabled(skill.name, skill.origin)}
- disabled={readOnly || isToggling}
+ disabled={isToggling || isAdministratorManagedSkill(skill)}
/>
</div>
</div>
@@ -2387,6 +2464,14 @@ export function SkillPanel({ sessionId, onNavigateToConfig, isActive = false }:
);
})}
</div>
+ {listState === "success" && (
+ <Pagination
+ page={mySkillsPage}
+ totalPages={mySkillsTotalPages}
+ onPageChange={(page) => setMySkillsPage(page)}
+ className="mt-3"
+ />
+ )}
</div>
)}
</>
diff --git a/jiuwenswarm/channels/web/frontend/src/components/common/ConfirmDialog.tsx b/jiuwenswarm/channels/web/frontend/src/components/common/ConfirmDialog.tsx
new file mode 100644
index 0000000000..5367a44630
--- /dev/null
+++ b/jiuwenswarm/channels/web/frontend/src/components/common/ConfirmDialog.tsx
@@ -0,0 +1,56 @@
+/**
+ * 通用确认弹窗(替代 window.confirm),统一可访问性与交互。
+ */
+import { useTranslation } from "react-i18next";
+import { X } from "lucide-react";
+
+interface ConfirmDialogProps {
+ title: string;
+ message: string;
+ confirmLabel?: string;
+ onConfirm: () => void;
+ onCancel: () => void;
+ loading?: boolean;
+}
+
+export function ConfirmDialog({
+ title,
+ message,
+ confirmLabel,
+ onConfirm,
+ onCancel,
+ loading = false,
+}: ConfirmDialogProps) {
+ const { t } = useTranslation();
+ return (
+ <div className="fixed inset-0 z-50 flex items-center justify-center bg-black/60" onClick={onCancel}>
+ <div
+ className="relative w-[420px] rounded-lg bg-card p-6 shadow-xl animate-rise"
+ onClick={(e) => e.stopPropagation()}
+ >
+ <div className="mb-5 flex items-center justify-between">
+ <h3 className="text-base font-semibold text-text-strong">{title}</h3>
+ <button onClick={onCancel} className="text-text-muted hover:text-text" aria-label={t("common.close")}>
+ <X size={20} />
+ </button>
+ </div>
+ <p className="mb-6 break-words text-sm text-text">{message}</p>
+ <div className="flex justify-center gap-3">
+ <button
+ onClick={onConfirm}
+ disabled={loading}
+ className="px-6 py-1.5 rounded-full text-sm font-medium bg-primary text-text-inverse hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-60"
+ >
+ {confirmLabel || t("common.confirm")}
+ </button>
+ <button
+ onClick={onCancel}
+ className="px-6 py-1.5 rounded-full border border-border text-sm font-medium text-text hover:bg-secondary/50"
+ >
+ {t("common.cancel")}
+ </button>
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/jiuwenswarm/channels/web/frontend/src/components/common/Pagination.tsx b/jiuwenswarm/channels/web/frontend/src/components/common/Pagination.tsx
new file mode 100644
index 0000000000..84b8175e58
--- /dev/null
+++ b/jiuwenswarm/channels/web/frontend/src/components/common/Pagination.tsx
@@ -0,0 +1,48 @@
+/**
+ * 通用分页条:上一页/下一页 + 页码指示 + 可选总数。
+ * 供「我的技能」列表、企业技能源面板等列表复用。
+ */
+import { useTranslation } from "react-i18next";
+
+interface PaginationProps {
+ page: number;
+ totalPages: number;
+ total?: number;
+ onPageChange: (page: number) => void;
+ className?: string;
+}
+
+export function Pagination({
+ page,
+ totalPages,
+ total,
+ onPageChange,
+ className = "",
+}: PaginationProps) {
+ const { t } = useTranslation();
+ if (totalPages <= 1) return null;
+ return (
+ <div className={`flex items-center justify-end gap-3 text-sm text-text-muted flex-shrink-0 ${className}`}>
+ {total != null && <span>{t("common.pagination.total", { count: total })}</span>}
+ <button
+ type="button"
+ onClick={() => onPageChange(page - 1)}
+ disabled={page <= 1}
+ aria-label={t("common.pagination.prev")}
+ className="px-3 py-1 rounded-md border border-border hover:bg-secondary/50 disabled:text-text-muted disabled:cursor-not-allowed"
+ >
+ ‹
+ </button>
+ <span>{page} / {totalPages}</span>
+ <button
+ type="button"
+ onClick={() => onPageChange(page + 1)}
+ disabled={page >= totalPages}
+ aria-label={t("common.pagination.next")}
+ className="px-3 py-1 rounded-md border border-border hover:bg-secondary/50 disabled:text-text-muted disabled:cursor-not-allowed"
+ >
+ ›
+ </button>
+ </div>
+ );
+}
diff --git a/jiuwenswarm/channels/web/frontend/src/components/common/useToast.ts b/jiuwenswarm/channels/web/frontend/src/components/common/useToast.ts
new file mode 100644
index 0000000000..9f3c25f797
--- /dev/null
+++ b/jiuwenswarm/channels/web/frontend/src/components/common/useToast.ts
@@ -0,0 +1,51 @@
+/**
+ * 通用 toast 提示 hook:统一成功/失败结果反馈。
+ */
+import { useCallback, useEffect, useRef, useState } from "react";
+
+export type ToastType = "success" | "error";
+
+export interface ToastState {
+ type: ToastType;
+ text: string;
+}
+
+export function useToast(durationMs = 3000) {
+ const [toast, setToast] = useState<ToastState | null>(null);
+ const timerRef = useRef<number | null>(null);
+
+ const showToast = useCallback(
+ (type: ToastType, text: string) => {
+ if (timerRef.current !== null) {
+ window.clearTimeout(timerRef.current);
+ timerRef.current = null;
+ }
+ setToast({ type, text });
+ timerRef.current = window.setTimeout(() => {
+ setToast(null);
+ timerRef.current = null;
+ }, durationMs);
+ },
+ [durationMs]
+ );
+
+ const clearToast = useCallback(() => {
+ if (timerRef.current !== null) {
+ window.clearTimeout(timerRef.current);
+ timerRef.current = null;
+ }
+ setToast(null);
+ }, []);
+
+ useEffect(
+ () => () => {
+ if (timerRef.current !== null) {
+ window.clearTimeout(timerRef.current);
+ timerRef.current = null;
+ }
+ },
+ []
+ );
+
+ return { toast, showToast, clearToast };
+}
diff --git a/jiuwenswarm/channels/web/frontend/src/features/EnterpriseSkillSourcePanel/index.tsx b/jiuwenswarm/channels/web/frontend/src/features/EnterpriseSkillSourcePanel/index.tsx
new file mode 100644
index 0000000000..7b1d9fbbfb
--- /dev/null
+++ b/jiuwenswarm/channels/web/frontend/src/features/EnterpriseSkillSourcePanel/index.tsx
@@ -0,0 +1,454 @@
+/**
+ * 企业技能源面板:企业版专用,浏览/搜索/安装/更新第三方技能源(SwarmSkillHub 等)。
+ *
+ * 与个人版 TeamSkillsHubModal 走同一套 skills.source.* / skills.updates.check /
+ * skills.update 通用接口,仅 UI 与展示字段更贴合企业形态:补齐所属空间、作者、
+ * 评分、下载量、更新时间、标签,以及分页。
+ */
+import { useCallback, useEffect, useMemo, useState } from 'react';
+import { useTranslation } from 'react-i18next';
+import { webRequest } from '../../services/webClient';
+import { getSkillAvatar } from '../../utils/skillAvatar';
+import { Pagination } from '../../components/common/Pagination';
+import { ConfirmDialog } from '../../components/common/ConfirmDialog';
+import { useToast } from '../../components/common/useToast';
+
+const PAGE_SIZE = 20;
+
+type LoadState = 'idle' | 'loading' | 'success' | 'error';
+
+type SourceDescriptor = {
+ source_id: string;
+ display_name?: string;
+ enabled: boolean;
+ capabilities?: string[];
+};
+
+type SkillCandidate = {
+ source_id: string;
+ skill_id?: string;
+ version_id: string;
+ name: string;
+ display_name?: string;
+ summary?: string;
+ version?: string;
+ namespace?: string;
+ owner_display_name?: string;
+ rating_avg?: number;
+ rating_count?: number;
+ download_count?: number;
+ updated_at?: string | number;
+ labels?: Array<{ name?: string } | string>;
+ downloadable?: boolean;
+ accessible?: boolean;
+};
+
+type UpdateStatus = {
+ source_id: string;
+ name: string;
+ skill_id?: string;
+ current_version_id?: string;
+ latest_version_id?: string;
+ current_version?: string;
+ latest_version?: string;
+ has_update: boolean;
+ remote_status?: string;
+ accessible?: boolean;
+ downloadable?: boolean;
+};
+
+interface EnterpriseSkillSourcePanelProps {
+ sessionId: string;
+ viewMode?: 'list' | 'grid';
+ onInstalled?: (skillName: string) => void | Promise<void>;
+}
+
+function normalizeUpdatedAt(value: SkillCandidate['updated_at']): string {
+ if (value == null || value === '') return '';
+ if (typeof value === 'number') {
+ const millis = value > 10_000_000_000 ? value : value * 1000;
+ const date = new Date(millis);
+ if (!Number.isNaN(date.getTime())) return date.toLocaleDateString();
+ return '';
+ }
+ return String(value).slice(0, 10);
+}
+
+function labelText(label: { name?: string } | string | undefined): string {
+ if (label == null) return '';
+ if (typeof label === 'string') return label;
+ return label.name || '';
+}
+
+export function EnterpriseSkillSourcePanel({ sessionId, viewMode = 'list', onInstalled }: EnterpriseSkillSourcePanelProps) {
+ const { t } = useTranslation();
+ const [sources, setSources] = useState<SourceDescriptor[]>([]);
+ const [sourceId, setSourceId] = useState('');
+ const [query, setQuery] = useState('');
+ const [results, setResults] = useState<SkillCandidate[]>([]);
+ const [total, setTotal] = useState(0);
+ const [page, setPage] = useState(1);
+ const [loadState, setLoadState] = useState<LoadState>('idle');
+ const { toast, showToast, clearToast } = useToast();
+ const [installingId, setInstallingId] = useState<string | null>(null);
+ const [updateStatuses, setUpdateStatuses] = useState<Map<string, UpdateStatus>>(new Map());
+ const [pendingConfirm, setPendingConfirm] = useState<SkillCandidate | null>(null);
+
+ const totalPages = useMemo(() => Math.max(1, Math.ceil(total / PAGE_SIZE)), [total]);
+
+ const withSession = useCallback((params?: Record<string, unknown>) => ({ ...(params || {}), session_id: sessionId }), [sessionId]);
+
+ // 1) 拉取可用技能源,默认选中第一个可搜索的来源
+ useEffect(() => {
+ let cancelled = false;
+ void (async () => {
+ try {
+ const data = await webRequest<{
+ success: boolean;
+ error_message?: string;
+ providers?: SourceDescriptor[];
+ }>('skills.source.providers', withSession());
+ if (!data.success) throw new Error(data.error_message || t('skills.source.errors.loadFailed'));
+ const enabled = (data.providers || []).filter(item => item.enabled !== false && (item.capabilities || []).includes('search'));
+ if (cancelled) return;
+ setSources(enabled);
+ if (enabled.length > 0) setSourceId(enabled[0].source_id);
+ else setLoadState('error');
+ } catch (error) {
+ if (cancelled) return;
+ setLoadState('error');
+ showToast('error', error instanceof Error ? error.message : t('skills.source.errors.loadFailed'));
+ }
+ })();
+ return () => {
+ cancelled = true;
+ };
+ }, [showToast, t, withSession]);
+
+ // 2) 已安装技能的更新状态(按 source_id:name 作为已装判定)
+ useEffect(() => {
+ if (!sourceId) return;
+ let cancelled = false;
+ void (async () => {
+ try {
+ const data = await webRequest<{
+ success: boolean;
+ items?: UpdateStatus[];
+ }>('skills.updates.check', withSession({ source_id: sourceId }));
+ if (!cancelled && data.success) {
+ setUpdateStatuses(new Map((data.items || []).map(item => [`${item.source_id}:${item.name}`, item])));
+ }
+ } catch {
+ // 更新状态查询失败不阻断搜索展示
+ }
+ })();
+ return () => {
+ cancelled = true;
+ };
+ }, [sourceId, withSession]);
+
+ // 3) 搜索
+ const runSearch = useCallback(
+ async (targetPage: number) => {
+ if (!sourceId) return;
+ setLoadState('loading');
+ clearToast();
+ try {
+ const data = await webRequest<{
+ success: boolean;
+ error_message?: string;
+ items?: SkillCandidate[];
+ total?: number;
+ }>(
+ 'skills.source.search',
+ withSession({
+ source_id: sourceId,
+ q: query.trim(),
+ page: targetPage,
+ page_size: PAGE_SIZE,
+ }),
+ );
+ if (!data.success) throw new Error(data.error_message || t('skills.source.errors.searchFailed'));
+ setResults(data.items || []);
+ setTotal(data.total ?? (data.items || []).length);
+ setPage(targetPage);
+ setLoadState('success');
+ } catch (error) {
+ setResults([]);
+ setTotal(0);
+ setLoadState('error');
+ showToast('error', error instanceof Error ? error.message : t('skills.source.errors.searchFailed'));
+ }
+ },
+ [query, showToast, sourceId, t, withSession],
+ );
+
+ useEffect(() => {
+ if (sourceId) {
+ setPage(1);
+ void runSearch(1);
+ }
+ // 仅 sourceId 变化时触发;query 变化由搜索按钮/回车触发
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [sourceId]);
+
+ const handleInstall = useCallback(
+ async (item: SkillCandidate, force = false) => {
+ if (installingId) return;
+ setInstallingId(item.name);
+ clearToast();
+ try {
+ const data = await webRequest<{
+ success: boolean;
+ error_code?: string;
+ error_message?: string;
+ skill?: { name: string };
+ }>(
+ 'skills.source.install',
+ withSession({
+ source_id: item.source_id || sourceId,
+ skill_id: item.skill_id,
+ version_id: item.version_id,
+ force,
+ }),
+ );
+ if (!data.success) {
+ if (!force && data.error_code === 'skill_already_installed') {
+ setInstallingId(null);
+ setPendingConfirm(item);
+ return;
+ }
+ throw new Error(data.error_message || t('skills.source.errors.installFailed'));
+ }
+ const skillName = data.skill?.name || item.name;
+ showToast('success', t('skills.source.messages.installed', { name: skillName }));
+ await onInstalled?.(skillName);
+ void runSearch(page);
+ } catch (error) {
+ showToast('error', error instanceof Error ? error.message : t('skills.source.errors.installFailed'));
+ } finally {
+ setInstallingId(null);
+ }
+ },
+ [installingId, onInstalled, page, runSearch, showToast, sourceId, t, withSession],
+ );
+
+ const handleConfirmInstall = useCallback(() => {
+ const item = pendingConfirm;
+ setPendingConfirm(null);
+ if (item) void handleInstall(item, true);
+ }, [pendingConfirm, handleInstall]);
+
+ const handleUpdate = useCallback(
+ async (item: SkillCandidate, status: UpdateStatus) => {
+ if (installingId) return;
+ const targetVersionId = status.latest_version_id || item.version_id;
+ setInstallingId(item.name);
+ clearToast();
+ try {
+ const data = await webRequest<{
+ success: boolean;
+ error_message?: string;
+ skill?: { name?: string };
+ }>(
+ 'skills.update',
+ withSession({
+ source_id: item.source_id || sourceId,
+ skill_id: item.skill_id,
+ target_version_id: targetVersionId,
+ expected_current_version_id: status.current_version_id,
+ }),
+ );
+ if (!data.success) throw new Error(data.error_message || t('skills.source.errors.updateFailed'));
+ setUpdateStatuses(previous => {
+ const next = new Map(previous);
+ next.set(`${item.source_id}:${item.name}`, {
+ ...status,
+ current_version_id: targetVersionId,
+ latest_version_id: targetVersionId,
+ has_update: false,
+ });
+ return next;
+ });
+ showToast('success', t('skills.source.messages.updated', { name: data.skill?.name || item.name }));
+ await onInstalled?.(data.skill?.name || item.name);
+ } catch (error) {
+ showToast('error', error instanceof Error ? error.message : t('skills.source.errors.updateFailed'));
+ } finally {
+ setInstallingId(null);
+ }
+ },
+ [installingId, onInstalled, showToast, sourceId, t, withSession],
+ );
+
+ const renderAction = (item: SkillCandidate) => {
+ const status = updateStatuses.get(`${item.source_id}:${item.name}`);
+ const isInstalled = Boolean(status);
+ const isInstalling = installingId === item.name;
+ if (isInstalled && status?.has_update) {
+ return (
+ <button
+ type="button"
+ onClick={() => void handleUpdate(item, status)}
+ disabled={isInstalling}
+ className="min-w-[76px] h-[28px] px-3 rounded-[24px] text-sm text-text border border-text hover:bg-secondary/50 whitespace-nowrap disabled:text-text-muted disabled:cursor-not-allowed"
+ >
+ {isInstalling ? t('common.loading') : t('common.update')}
+ </button>
+ );
+ }
+ if (isInstalled) {
+ return (
+ <span className="px-4 h-[28px] flex items-center rounded-2xl text-sm whitespace-nowrap border border-[color:var(--color-border-success)] bg-ok-subtle text-ok">
+ {t('skills.status.installed')}
+ </span>
+ );
+ }
+ return (
+ <button
+ type="button"
+ onClick={() => void handleInstall(item)}
+ disabled={isInstalling}
+ className={`min-w-[76px] h-[28px] px-3 rounded-[24px] text-sm text-text border border-text hover:bg-secondary/50 whitespace-nowrap ${
+ isInstalling ? 'text-text-muted cursor-not-allowed' : 'text-text'
+ }`}
+ >
+ {isInstalling ? t('common.loading') : t('skills.actions.install')}
+ </button>
+ );
+ };
+
+ const renderCard = (item: SkillCandidate) => {
+ const avatar = getSkillAvatar(item.name);
+ const displayName = item.display_name || item.name;
+ const tags = (item.labels || []).map(labelText).filter(Boolean).slice(0, 4);
+ const status = updateStatuses.get(`${item.source_id}:${item.name}`);
+ return (
+ <div
+ key={`${item.source_id}:${item.name}:${item.version_id}`}
+ className={`p-4 rounded-lg border border-border bg-panel ${viewMode === 'grid' ? 'flex flex-col' : 'flex items-start justify-between gap-4'}`}
+ style={viewMode === 'grid' ? { width: '496px', height: '220px', flexShrink: 0 } : undefined}
+ >
+ <div className="flex items-start gap-3 min-w-0 flex-1">
+ <div className={`w-10 h-10 rounded-lg ${avatar.color} flex items-center justify-center flex-shrink-0 text-text-inverse font-semibold`}>
+ {avatar.firstChar}
+ </div>
+ <div className="min-w-0 flex-1">
+ <div className="flex items-center gap-2">
+ <span className="text-base font-semibold text-text-strong truncate">{displayName}</span>
+ {item.namespace && <span className="shrink-0 text-xs text-text-muted">{item.namespace}</span>}
+ </div>
+ <div className="text-sm text-text-muted mt-1 line-clamp-2">{item.summary || t('skills.noDescription')}</div>
+ <div className="flex flex-wrap gap-x-3 gap-y-1 mt-2 text-xs text-text-muted">
+ {item.owner_display_name && (
+ <span>
+ {t('skills.source.author')}: {item.owner_display_name}
+ </span>
+ )}
+ {item.rating_avg != null && (
+ <span>
+ {t('skills.source.rating')}: {Number(item.rating_avg).toFixed(1)}
+ {item.rating_count != null ? ` (${item.rating_count})` : ''}
+ </span>
+ )}
+ {item.download_count != null && (
+ <span>
+ {t('skills.source.downloads')}: {item.download_count}
+ </span>
+ )}
+ <span>
+ {t('skills.versionLabel')}: {status?.latest_version || item.version || 'latest'}
+ </span>
+ {status?.current_version && (
+ <span>
+ {t('skills.source.localVersion')}: {status.current_version}
+ </span>
+ )}
+ {normalizeUpdatedAt(item.updated_at) && (
+ <span>
+ {t('skills.source.updatedAt')}: {normalizeUpdatedAt(item.updated_at)}
+ </span>
+ )}
+ </div>
+ {tags.length > 0 && (
+ <div className="flex flex-wrap gap-1.5 mt-2">
+ {tags.map(tag => (
+ <span key={tag} className="px-2 py-0.5 rounded-full bg-secondary border border-border text-xs text-text-muted">
+ {tag}
+ </span>
+ ))}
+ </div>
+ )}
+ </div>
+ </div>
+ <div className="flex-shrink-0 self-end">{renderAction(item)}</div>
+ </div>
+ );
+ };
+
+ return (
+ <div className="flex flex-col h-full">
+ {toast && (
+ <div
+ className={`mb-3 px-3 py-2.5 rounded-lg text-sm leading-snug border ${
+ toast.type === 'success' ? 'border-[color:var(--color-border-success)] bg-ok-subtle text-ok' : 'border-danger/40 bg-danger/10 text-danger'
+ }`}
+ >
+ {toast.text.replace('√', '')}
+ </div>
+ )}
+
+ <div className="flex items-center gap-2">
+ {sources.length > 1 && (
+ <select
+ value={sourceId}
+ onChange={e => setSourceId(e.target.value)}
+ className="px-2 py-1.5 rounded-lg text-sm bg-secondary border border-border text-text"
+ >
+ {sources.map(s => (
+ <option key={s.source_id} value={s.source_id}>
+ {s.display_name || s.source_id}
+ </option>
+ ))}
+ </select>
+ )}
+ <input
+ value={query}
+ onChange={e => setQuery(e.target.value)}
+ onKeyDown={e => e.key === 'Enter' && void runSearch(1)}
+ placeholder={t('skills.source.searchPlaceholder')}
+ className="flex-1 min-w-0 px-3 py-1.5 rounded-lg text-sm bg-secondary border border-border text-text placeholder:text-text-muted"
+ />
+ <button
+ type="button"
+ onClick={() => void runSearch(1)}
+ disabled={loadState === 'loading' || !sourceId}
+ className={`px-4 py-1.5 rounded-2xl text-sm border border-gray-400 hover:border-gray-600 hover:bg-secondary/50 ${
+ loadState === 'loading' || !sourceId ? 'text-text-muted cursor-not-allowed' : 'text-text'
+ }`}
+ >
+ {loadState === 'loading' ? t('common.loading') : t('skills.teamskillshub.search')}
+ </button>
+ </div>
+
+ {loadState === 'loading' && <div className="flex items-center justify-center flex-1 text-text-muted">{t('common.loading')}</div>}
+ {loadState === 'error' && <div className="mt-4 text-sm text-text-muted">{t('skills.source.errors.searchFailed')}</div>}
+ {loadState === 'success' && (
+ <div className={`mt-4 flex-1 min-h-0 overflow-y-auto ${viewMode === 'grid' ? 'flex flex-wrap gap-4 content-start' : 'space-y-3'}`}>
+ {results.length === 0 ? <div className="text-sm text-text-muted">{t('skills.source.noResults')}</div> : results.map(renderCard)}
+ </div>
+ )}
+
+ {loadState === 'success' && <Pagination page={page} totalPages={totalPages} total={total} onPageChange={p => void runSearch(p)} className="mt-3" />}
+ {pendingConfirm && (
+ <ConfirmDialog
+ title={t('skills.source.replaceConfirmTitle')}
+ message={t('skills.source.replaceConfirm', { name: pendingConfirm.name })}
+ onConfirm={handleConfirmInstall}
+ onCancel={() => setPendingConfirm(null)}
+ loading={installingId === pendingConfirm.name}
+ />
+ )}
+ </div>
+ );
+}
diff --git a/jiuwenswarm/channels/web/frontend/src/features/TeamSkillsHubModal/index.tsx b/jiuwenswarm/channels/web/frontend/src/features/TeamSkillsHubModal/index.tsx
index 609106fdad..b695beadc7 100644
--- a/jiuwenswarm/channels/web/frontend/src/features/TeamSkillsHubModal/index.tsx
+++ b/jiuwenswarm/channels/web/frontend/src/features/TeamSkillsHubModal/index.tsx
@@ -1,23 +1,42 @@
/**
* Team Skills Hub(teamskillshub)在线检索弹窗:从 Hub 检索并安装技能。
*/
-import { useCallback, useEffect, useRef, useState } from "react";
-import { useTranslation } from "react-i18next";
-import { webRequest } from "../../services/webClient";
-import { getSkillAvatar } from "../../utils/skillAvatar";
+import { useCallback, useEffect, useRef, useState } from 'react';
+import { useTranslation } from 'react-i18next';
+import { webRequest } from '../../services/webClient';
+import { getSkillAvatar } from '../../utils/skillAvatar';
/** 与后端 TEAM_SKILLS_HUB_BASE_URL 默认值一致(info 请求失败时的回退) */
-const DEFAULT_TEAMSKILLS_HUB_BASE_URL = "https://teamskills.openjiuwen.com";
+const DEFAULT_TEAMSKILLS_HUB_BASE_URL = 'https://teamskills.openjiuwen.com';
-type LoadState = "idle" | "loading" | "success" | "error";
+type LoadState = 'idle' | 'loading' | 'success' | 'error';
type TeamSkillsHubSkillItem = {
- asset_id: string;
+ source_id: string;
+ skill_id?: string;
+ version_id: string;
name: string;
- display_name: string;
- summary: string;
- version: string;
- updated_at: number;
+ display_name?: string;
+ summary?: string;
+ version?: string;
+ updated_at?: string | number;
+};
+
+type SkillUpdateStatus = {
+ source_id: string;
+ name: string;
+ skill_id?: string;
+ current_version_id?: string;
+ latest_version_id?: string;
+ has_update: boolean;
+ remote_status?: string;
+};
+
+type SkillSourceDescriptor = {
+ source?: string;
+ source_id: string;
+ enabled: boolean;
+ capabilities?: string[];
};
interface TeamSkillsHubModalProps {
@@ -29,7 +48,7 @@ interface TeamSkillsHubModalProps {
/** 已安装技能的来源标识(用于精确匹配,避免同名误判) */
installedSkillOrigins?: ReadonlySet<string>;
/** 视图模式:列表或平铺 */
- viewMode?: "list" | "grid";
+ viewMode?: 'list' | 'grid';
onClose: () => void;
onInstalled?: (skillName: string) => void | Promise<void>;
}
@@ -40,19 +59,20 @@ export function TeamSkillsHubModal({
sessionId,
externalSearchQuery,
installedSkillOrigins,
- viewMode = "list",
+ viewMode = 'list',
onClose,
onInstalled,
}: TeamSkillsHubModalProps) {
const { t } = useTranslation();
- const [query, setQuery] = useState("");
+ const [query, setQuery] = useState('');
const [results, setResults] = useState<TeamSkillsHubSkillItem[]>([]);
- const [loadState, setLoadState] = useState<LoadState>("idle");
- const [message, setMessage] = useState<{ type: "success" | "error"; text: string } | null>(null);
- const [installingAssetId, setInstallingAssetId] = useState<string | null>(null);
- // 按 asset_id 记录已装(而非 name):两个 skill name 相同但 asset_id 不同时,
- // 按 name 会让 B 被误判为"已安装"(A 已装),导致 B 的安装按钮变灰、永远装不上。
- const [installedAssetIds, setInstalledAssetIds] = useState<Set<string>>(new Set());
+ const [loadState, setLoadState] = useState<LoadState>('idle');
+ const [message, setMessage] = useState<{ type: 'success' | 'error'; text: string } | null>(null);
+ const [installingSkillName, setInstallingSkillName] = useState<string | null>(null);
+ // 公共 Skill Source 安装身份以 SKILL.md.name 为准;skill_id 仅保留为来源追溯字段。
+ const [installedSkillNames, setInstalledSkillNames] = useState<Set<string>>(new Set());
+ const [updateStatuses, setUpdateStatuses] = useState<Map<string, SkillUpdateStatus>>(new Map());
+ const [sourceId, setSourceId] = useState('');
const [hubBaseUrl, setHubBaseUrl] = useState(DEFAULT_TEAMSKILLS_HUB_BASE_URL);
const messageTimerRef = useRef<number | null>(null);
@@ -61,10 +81,10 @@ export function TeamSkillsHubModal({
...(params || {}),
session_id: sessionId,
}),
- [sessionId]
+ [sessionId],
);
- const showMessage = useCallback((type: "success" | "error", text: string) => {
+ const showMessage = useCallback((type: 'success' | 'error', text: string) => {
if (messageTimerRef.current !== null) {
window.clearTimeout(messageTimerRef.current);
messageTimerRef.current = null;
@@ -83,14 +103,61 @@ export function TeamSkillsHubModal({
messageTimerRef.current = null;
}
},
- []
+ [],
);
useEffect(() => {
if (!open) return;
- setInstalledAssetIds(new Set());
+ setInstalledSkillNames(new Set());
+ setUpdateStatuses(new Map());
+ setSourceId('');
setHubBaseUrl(DEFAULT_TEAMSKILLS_HUB_BASE_URL);
- }, [open]);
+ let cancelled = false;
+ void (async () => {
+ try {
+ const data = await webRequest<{
+ success: boolean;
+ error_message?: string;
+ providers?: SkillSourceDescriptor[];
+ }>('skills.source.providers', withSession());
+ const provider = (data.providers || []).find(item => item.enabled !== false && (item.capabilities || []).includes('search'));
+ const selected = provider?.source_id || provider?.source || '';
+ if (!data.success || !selected) {
+ throw new Error(data.error_message || t('skills.teamskillshub.errors.searchFailed'));
+ }
+ if (!cancelled) setSourceId(selected);
+ } catch (error) {
+ if (cancelled) return;
+ setResults([]);
+ setLoadState('error');
+ showMessage('error', error instanceof Error ? error.message : t('skills.teamskillshub.errors.searchFailed'));
+ }
+ })();
+ return () => {
+ cancelled = true;
+ };
+ }, [open, showMessage, t, withSession]);
+
+ useEffect(() => {
+ if (!open || !sourceId) return;
+ let cancelled = false;
+ void (async () => {
+ try {
+ const data = await webRequest<{
+ success: boolean;
+ items?: SkillUpdateStatus[];
+ }>('skills.updates.check', withSession({ source_id: sourceId }));
+ if (!cancelled && data.success) {
+ setUpdateStatuses(new Map((data.items || []).map(item => [`${item.source_id}:${item.name}`, item])));
+ }
+ } catch (error) {
+ console.debug('Skill update check skipped', error);
+ }
+ })();
+ return () => {
+ cancelled = true;
+ };
+ }, [open, sourceId, withSession]);
useEffect(() => {
if (embedded && externalSearchQuery !== undefined) {
@@ -99,34 +166,39 @@ export function TeamSkillsHubModal({
}, [externalSearchQuery, embedded]);
useEffect(() => {
- if (embedded && query.trim()) {
+ if (embedded && sourceId && query.trim()) {
const q = query.trim();
- setLoadState("loading");
+ setLoadState('loading');
setMessage(null);
void (async () => {
try {
const data = await webRequest<{
success: boolean;
- detail?: string;
- skills?: TeamSkillsHubSkillItem[];
- }>("skills.teamskillshub.search", withSession({ q, limit: 50 }));
+ error_message?: string;
+ items?: TeamSkillsHubSkillItem[];
+ }>(
+ 'skills.source.search',
+ withSession({
+ source_id: sourceId,
+ q,
+ page: 1,
+ page_size: 50,
+ }),
+ );
if (!data.success) {
- throw new Error(data.detail || t("skills.teamskillshub.errors.searchFailed"));
+ throw new Error(data.error_message || t('skills.teamskillshub.errors.searchFailed'));
}
- setResults(data.skills || []);
- setLoadState("success");
+ setResults(data.items || []);
+ setLoadState('success');
} catch (error) {
console.error(error);
setResults([]);
- setLoadState("error");
- showMessage(
- "error",
- error instanceof Error ? error.message : t("skills.teamskillshub.errors.searchFailed")
- );
+ setLoadState('error');
+ showMessage('error', error instanceof Error ? error.message : t('skills.teamskillshub.errors.searchFailed'));
}
})();
}
- }, [query, embedded, showMessage, t, withSession]);
+ }, [query, embedded, showMessage, sourceId, t, withSession]);
useEffect(() => {
if (!open) return;
@@ -136,14 +208,14 @@ export function TeamSkillsHubModal({
const data = await webRequest<{
success?: boolean;
market_base_url?: string;
- }>("skills.teamskillshub.info", withSession());
+ }>('skills.teamskillshub.info', withSession());
const url = data.market_base_url?.trim();
if (!cancelled && data.success && url) {
try {
// 确保为合法绝对 URL(与服务端配置的基地址一致)
- setHubBaseUrl(new URL(url).href.replace(/\/$/, ""));
+ setHubBaseUrl(new URL(url).href.replace(/\/$/, ''));
} catch {
- setHubBaseUrl(url.replace(/\/$/, ""));
+ setHubBaseUrl(url.replace(/\/$/, ''));
}
}
} catch {
@@ -157,95 +229,140 @@ export function TeamSkillsHubModal({
useEffect(() => {
const handleKeyDown = (e: KeyboardEvent) => {
- if (e.key === "Escape") onClose();
+ if (e.key === 'Escape') onClose();
};
if (open) {
- window.addEventListener("keydown", handleKeyDown);
- return () => window.removeEventListener("keydown", handleKeyDown);
+ window.addEventListener('keydown', handleKeyDown);
+ return () => window.removeEventListener('keydown', handleKeyDown);
}
}, [open, onClose]);
const handleSearch = useCallback(async () => {
const q = query.trim();
- if (!q) return;
- setLoadState("loading");
+ if (!q || !sourceId) return;
+ setLoadState('loading');
setMessage(null);
try {
const data = await webRequest<{
success: boolean;
- detail?: string;
- skills?: TeamSkillsHubSkillItem[];
- }>("skills.teamskillshub.search", withSession({ q, limit: 50 }));
+ error_message?: string;
+ items?: TeamSkillsHubSkillItem[];
+ }>(
+ 'skills.source.search',
+ withSession({
+ source_id: sourceId,
+ q,
+ page: 1,
+ page_size: 50,
+ }),
+ );
if (!data.success) {
- throw new Error(data.detail || t("skills.teamskillshub.errors.searchFailed"));
+ throw new Error(data.error_message || t('skills.teamskillshub.errors.searchFailed'));
}
- setResults(data.skills || []);
- setLoadState("success");
+ setResults(data.items || []);
+ setLoadState('success');
} catch (error) {
console.error(error);
setResults([]);
- setLoadState("error");
- showMessage(
- "error",
- error instanceof Error ? error.message : t("skills.teamskillshub.errors.searchFailed")
- );
+ setLoadState('error');
+ showMessage('error', error instanceof Error ? error.message : t('skills.teamskillshub.errors.searchFailed'));
}
- }, [query, showMessage, t, withSession]);
+ }, [query, showMessage, sourceId, t, withSession]);
const handleInstall = useCallback(
async (item: TeamSkillsHubSkillItem) => {
- if (installingAssetId) return;
- setInstallingAssetId(item.asset_id);
+ if (installingSkillName) return;
+ setInstallingSkillName(item.name);
setMessage(null);
let force = false;
try {
while (true) {
const data = await webRequest<{
success: boolean;
- detail?: string;
- detail_key?: string;
+ error_code?: string;
+ error_message?: string;
skill?: { name: string };
- }>("skills.teamskillshub.install", withSession({
- asset_id: item.asset_id,
- force,
- // 随手把搜索结果里已有的市场展示文案传给后端落盘,
- // 使「我的技能」页显示与搜索页一致的描述(summary = 市场 short_desc)
- short_desc: item.summary,
- display_name: item.display_name,
- }));
+ }>(
+ 'skills.source.install',
+ withSession({
+ source_id: item.source_id || sourceId,
+ skill_id: item.skill_id,
+ version_id: item.version_id,
+ force,
+ }),
+ );
if (!data.success) {
// 已安装冲突:弹确认框询问是否覆盖
- if (!force && data.detail_key === "skills.teamskillshub.errors.skillAlreadyInstalled") {
- const confirmed = window.confirm(
- t("skills.teamskillshub.replaceConfirm", { name: item.name })
- );
+ if (!force && data.error_code === 'skill_already_installed') {
+ const confirmed = window.confirm(t('skills.teamskillshub.replaceConfirm', { name: item.name }));
if (confirmed) {
force = true;
continue;
}
return;
}
- throw new Error(data.detail || t("skills.teamskillshub.errors.installFailed"));
+ throw new Error(data.error_message || t('skills.teamskillshub.errors.installFailed'));
}
// 安装成功
const skillName = data.skill?.name || item.name;
- // 按 asset_id 标记已装(唯一身份),同名 B 不会被误判
- setInstalledAssetIds((prev) => new Set([...prev, item.asset_id]));
- showMessage("success", t("skills.teamskillshub.messages.installed", { name: skillName }));
+ setInstalledSkillNames(prev => new Set([...prev, item.name]));
+ showMessage('success', t('skills.teamskillshub.messages.installed', { name: skillName }));
await onInstalled?.(skillName);
break;
}
} catch (error) {
console.error(error);
- showMessage(
- "error",
- error instanceof Error ? error.message : t("skills.teamskillshub.errors.installFailed")
+ showMessage('error', error instanceof Error ? error.message : t('skills.teamskillshub.errors.installFailed'));
+ } finally {
+ setInstallingSkillName(null);
+ }
+ },
+ [installingSkillName, onInstalled, showMessage, sourceId, t, withSession],
+ );
+
+ const handleUpdate = useCallback(
+ async (item: TeamSkillsHubSkillItem, status: SkillUpdateStatus) => {
+ if (installingSkillName) return;
+ const targetVersionId = status.latest_version_id || item.version_id;
+ setInstallingSkillName(item.name);
+ setMessage(null);
+ try {
+ const data = await webRequest<{
+ success: boolean;
+ error_message?: string;
+ skill?: { name?: string };
+ }>(
+ 'skills.update',
+ withSession({
+ source_id: item.source_id || sourceId,
+ skill_id: item.skill_id,
+ target_version_id: targetVersionId,
+ expected_current_version_id: status.current_version_id,
+ }),
);
+ if (!data.success) {
+ throw new Error(data.error_message || t('skills.teamskillshub.errors.updateFailed'));
+ }
+ setUpdateStatuses(previous => {
+ const next = new Map(previous);
+ next.set(`${item.source_id}:${item.name}`, {
+ ...status,
+ current_version_id: targetVersionId,
+ latest_version_id: targetVersionId,
+ has_update: false,
+ });
+ return next;
+ });
+ showMessage('success', t('skills.teamskillshub.messages.updated', { name: data.skill?.name || item.name }));
+ await onInstalled?.(data.skill?.name || item.name);
+ } catch (error) {
+ console.error(error);
+ showMessage('error', error instanceof Error ? error.message : t('skills.teamskillshub.errors.updateFailed'));
} finally {
- setInstallingAssetId(null);
+ setInstallingSkillName(null);
}
},
- [installingAssetId, onInstalled, showMessage, t, withSession]
+ [installingSkillName, onInstalled, showMessage, sourceId, t, withSession],
);
if (!open) return null;
@@ -254,17 +371,20 @@ export function TeamSkillsHubModal({
return (
<div className="flex flex-col h-full">
<div className="overflow-auto flex-1 min-h-0">
- {message && message.type === "success" && (
- <div className="fixed top-4 right-4 z-[9999] rounded-[4px] text-sm text-text shadow-lg flex items-center gap-3 px-4" style={{ backgroundColor: "var(--color-feedback-success-toast)", width: "564px", height: "40px" }}>
+ {message && message.type === 'success' && (
+ <div
+ className="fixed top-4 right-4 z-[9999] rounded-[4px] text-sm text-text shadow-lg flex items-center gap-3 px-4"
+ style={{ backgroundColor: 'var(--color-feedback-success-toast)', width: '564px', height: '40px' }}
+ >
<span className="w-4 h-4 rounded-full bg-[var(--color-feedback-success-indicator)] flex items-center justify-center flex-shrink-0">
<svg className="w-3 h-3 text-text-inverse" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={3} d="M5 13l4 4L19 7" />
</svg>
</span>
- {message.text.replace("√", "")}
+ {message.text.replace('√', '')}
<button
type="button"
- onClick={() => showMessage("success", "")}
+ onClick={() => showMessage('success', '')}
className="ml-auto w-6 h-6 flex items-center justify-center hover:bg-card/30 rounded-full "
>
<svg className="w-4 h-4 text-gray-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
@@ -273,53 +393,108 @@ export function TeamSkillsHubModal({
</button>
</div>
)}
- {message && message.type === "error" && (
- <div className="mb-3 px-3 py-2.5 rounded-lg text-sm leading-snug border border-danger/40 bg-danger/10 text-danger">
- {message.text}
- </div>
+ {message && message.type === 'error' && (
+ <div className="mb-3 px-3 py-2.5 rounded-lg text-sm leading-snug border border-danger/40 bg-danger/10 text-danger">{message.text}</div>
)}
- {loadState === "loading" && (
- <div className="flex items-center justify-center h-full text-text-muted">{t("common.loading")}</div>
- )}
- {loadState === "error" && (
- <div className="text-sm text-text-muted">{t("skills.teamskillshub.errors.searchFailed")}</div>
- )}
- {loadState === "success" && (
- <div className={`mt-4 flex-1 min-h-0 overflow-y-auto ${viewMode === "grid" ? "flex flex-wrap gap-4 content-start" : "space-y-3"}`}>
- {results.length === 0 ? (
- <div className="text-sm text-text-muted">{t("skills.teamskillshub.noResults")}</div>
- ) : (
- results.map((item) => {
- const isInstalled =
- installedAssetIds.has(item.asset_id) || (installedSkillOrigins?.has(`teamskillshub:${item.asset_id}`) ?? false);
- const isInstalling = installingAssetId === item.asset_id;
- const avatar = getSkillAvatar(item.name);
- return (
- <div
- key={item.asset_id}
- className={`p-4 rounded-lg border border-border bg-panel ${viewMode === "grid" ? "flex flex-col" : "flex items-start justify-between gap-4"}`}
- style={viewMode === "grid" ? { width: "496px", height: "168px", flexShrink: 0 } : undefined}
- >
- {viewMode === "list" ? (
- <>
- <div className="flex items-center gap-3 min-w-0 flex-1">
- <div className={`w-10 h-10 rounded-lg ${avatar.color} flex items-center justify-center flex-shrink-0 text-text-inverse font-semibold`}>
- {avatar.firstChar}
- </div>
- <div className="min-w-0 flex-1">
- <div className="text-base font-semibold text-text-strong truncate">
- {item.name}
- </div>
- <div className="text-sm text-text-muted mt-1 line-clamp-3">
- {item.summary || t("skills.noDescription")}
- </div>
- </div>
+ {loadState === 'loading' && <div className="flex items-center justify-center h-full text-text-muted">{t('common.loading')}</div>}
+ {loadState === 'error' && <div className="text-sm text-text-muted">{t('skills.teamskillshub.errors.searchFailed')}</div>}
+ {loadState === 'success' && (
+ <div className={`mt-4 flex-1 min-h-0 overflow-y-auto ${viewMode === 'grid' ? 'flex flex-wrap gap-4 content-start' : 'space-y-3'}`}>
+ {results.length === 0 ? (
+ <div className="text-sm text-text-muted">{t('skills.teamskillshub.noResults')}</div>
+ ) : (
+ results.map(item => {
+ const updateStatus = updateStatuses.get(`${item.source_id}:${item.name}`);
+ const isInstalled =
+ Boolean(updateStatus) ||
+ installedSkillNames.has(item.name) ||
+ (installedSkillOrigins?.has(`${item.source_id || sourceId}:${item.name}`) ?? false) ||
+ (item.skill_id != null &&
+ ((installedSkillOrigins?.has(`${item.source_id || sourceId}:${item.skill_id}`) ?? false) ||
+ (installedSkillOrigins?.has(`teamskillshub:${item.skill_id}`) ?? false)));
+ const isInstalling = installingSkillName === item.name;
+ const avatar = getSkillAvatar(item.name);
+ return (
+ <div
+ key={`${item.source_id}:${item.name}:${item.version_id}`}
+ className={`p-4 rounded-lg border border-border bg-panel ${viewMode === 'grid' ? 'flex flex-col' : 'flex items-start justify-between gap-4'}`}
+ style={viewMode === 'grid' ? { width: '496px', height: '168px', flexShrink: 0 } : undefined}
+ >
+ {viewMode === 'list' ? (
+ <>
+ <div className="flex items-center gap-3 min-w-0 flex-1">
+ <div
+ className={`w-10 h-10 rounded-lg ${avatar.color} flex items-center justify-center flex-shrink-0 text-text-inverse font-semibold`}
+ >
+ {avatar.firstChar}
+ </div>
+ <div className="min-w-0 flex-1">
+ <div className="text-base font-semibold text-text-strong truncate">{item.name}</div>
+ <div className="text-sm text-text-muted mt-1 line-clamp-3">{item.summary || t('skills.noDescription')}</div>
+ </div>
+ </div>
+ <div className="flex flex-col items-end gap-2 flex-shrink-0">
+ {isInstalled && updateStatus?.has_update ? (
+ <button
+ type="button"
+ onClick={() => void handleUpdate(item, updateStatus)}
+ disabled={isInstalling}
+ className="min-w-[76px] h-[28px] px-3 rounded-[24px] text-sm text-text border border-text hover:bg-secondary/50 whitespace-nowrap disabled:text-text-muted disabled:cursor-not-allowed"
+ >
+ {isInstalling ? t('skills.teamskillshub.updating') : t('common.update')}
+ </button>
+ ) : isInstalled ? (
+ <span className="px-4 h-[28px] flex items-center rounded-2xl text-sm whitespace-nowrap border border-[color:var(--color-border-success)] bg-ok-subtle text-ok">
+ {t('skills.status.installed')}
+ </span>
+ ) : (
+ <button
+ type="button"
+ onClick={() => void handleInstall(item)}
+ disabled={isInstalling}
+ className={`min-w-[76px] h-[28px] px-3 rounded-[24px] text-sm text-text border border-text hover:bg-secondary/50 whitespace-nowrap ${
+ isInstalling ? 'text-text-muted cursor-not-allowed' : 'text-text'
+ }`}
+ >
+ {isInstalling ? t('skills.teamskillshub.installing') : t('skills.actions.install')}
+ </button>
+ )}
+ </div>
+ </>
+ ) : (
+ <>
+ <div className="flex items-start gap-3 flex-shrink-0">
+ <div
+ className={`w-10 h-10 rounded-lg ${avatar.color} flex items-center justify-center flex-shrink-0 text-text-inverse font-semibold text-sm`}
+ >
+ {avatar.firstChar}
</div>
- <div className="flex flex-col items-end gap-2 flex-shrink-0">
- {isInstalled ? (
+ <div className="min-w-0 flex-1">
+ <div className="text-sm font-semibold text-text-strong truncate">{item.name}</div>
+ <div className="text-xs text-text-muted mt-1 line-clamp-2">{item.summary || t('skills.noDescription')}</div>
+ </div>
+ </div>
+ <div className="flex flex-wrap gap-1.5 mt-2 flex-shrink-0 text-xs text-text-muted">
+ <span className="px-2 py-0.5 rounded-full bg-secondary border border-border truncate">
+ {t('skills.versionLabel')}: {item.version || 'latest'}
+ </span>
+ </div>
+ <div className="flex items-center mt-auto pt-2 gap-2 flex-shrink-0" style={{ width: '100%' }}>
+ <div className="flex gap-1.5 flex-1"></div>
+ <div className="flex-shrink-0 ml-auto">
+ {isInstalled && updateStatus?.has_update ? (
+ <button
+ type="button"
+ onClick={() => void handleUpdate(item, updateStatus)}
+ disabled={isInstalling}
+ className="min-w-[76px] h-[28px] px-3 rounded-[24px] text-sm text-text border border-text hover:bg-secondary/50 whitespace-nowrap disabled:text-text-muted disabled:cursor-not-allowed"
+ >
+ {isInstalling ? t('skills.teamskillshub.updating') : t('common.update')}
+ </button>
+ ) : isInstalled ? (
<span className="px-4 h-[28px] flex items-center rounded-2xl text-sm whitespace-nowrap border border-[color:var(--color-border-success)] bg-ok-subtle text-ok">
- {t("skills.status.installed")}
+ {t('skills.status.installed')}
</span>
) : (
<button
@@ -327,69 +502,21 @@ export function TeamSkillsHubModal({
onClick={() => void handleInstall(item)}
disabled={isInstalling}
className={`min-w-[76px] h-[28px] px-3 rounded-[24px] text-sm text-text border border-text hover:bg-secondary/50 whitespace-nowrap ${
- isInstalling
- ? "text-text-muted cursor-not-allowed"
- : "text-text"
+ isInstalling ? 'text-text-muted cursor-not-allowed' : 'text-text'
}`}
>
- {isInstalling
- ? t("skills.teamskillshub.installing")
- : t("skills.actions.install")}
+ {isInstalling ? t('skills.teamskillshub.installing') : t('skills.actions.install')}
</button>
)}
</div>
- </>
- ) : (
- <>
- <div className="flex items-start gap-3 flex-shrink-0">
- <div className={`w-10 h-10 rounded-lg ${avatar.color} flex items-center justify-center flex-shrink-0 text-text-inverse font-semibold text-sm`}>
- {avatar.firstChar}
- </div>
- <div className="min-w-0 flex-1">
- <div className="text-sm font-semibold text-text-strong truncate">
- {item.name}
- </div>
- <div className="text-xs text-text-muted mt-1 line-clamp-2">
- {item.summary || t("skills.noDescription")}
- </div>
- </div>
- </div>
- <div className="flex flex-wrap gap-1.5 mt-2 flex-shrink-0 text-xs text-text-muted">
- <span className="px-2 py-0.5 rounded-full bg-secondary border border-border truncate">
- {t("skills.versionLabel")}: {item.version || "latest"}
- </span>
- </div>
- <div className="flex items-center mt-auto pt-2 gap-2 flex-shrink-0" style={{ width: "100%" }}>
- <div className="flex gap-1.5 flex-1">
- </div>
- <div className="flex-shrink-0 ml-auto">
- {isInstalled ? (
- <span className="px-4 h-[28px] flex items-center rounded-2xl text-sm whitespace-nowrap border border-[color:var(--color-border-success)] bg-ok-subtle text-ok">
- {t("skills.status.installed")}
- </span>
- ) : (
- <button
- type="button"
- onClick={() => void handleInstall(item)}
- disabled={isInstalling}
- className={`min-w-[76px] h-[28px] px-3 rounded-[24px] text-sm text-text border border-text hover:bg-secondary/50 whitespace-nowrap ${
- isInstalling
- ? "text-text-muted cursor-not-allowed"
- : "text-text"
- }`}
- >
- {isInstalling ? t("skills.teamskillshub.installing") : t("skills.actions.install")}
- </button>
- )}
- </div>
- </div>
- </>
- )}
- </div>
- );
- })
- )}
- </div>
+ </div>
+ </>
+ )}
+ </div>
+ );
+ })
+ )}
+ </div>
)}
</div>
</div>
@@ -398,25 +525,20 @@ export function TeamSkillsHubModal({
return (
<div className="fixed inset-0 z-50 flex items-center justify-center p-4">
- <button
- type="button"
- className="absolute inset-0 bg-black/60"
- onClick={onClose}
- aria-label={t("common.close")}
- />
+ <button type="button" className="absolute inset-0 bg-black/60" onClick={onClose} aria-label={t('common.close')} />
<div className="relative w-full max-w-2xl max-h-[85vh] overflow-hidden rounded-xl border border-border bg-card shadow-2xl animate-rise flex flex-col">
<div className="flex items-start justify-between gap-3 px-5 py-3 border-b border-border bg-panel flex-shrink-0">
<div className="min-w-0 flex-1 space-y-1">
- <h3 className="text-base font-semibold text-text">{t("skills.teamskillshub.title")}</h3>
+ <h3 className="text-base font-semibold text-text">{t('skills.teamskillshub.title')}</h3>
<p className="text-[11px] leading-snug text-text-muted">
<a
href={hubBaseUrl}
target="_blank"
rel="noopener noreferrer"
className="font-medium text-accent underline decoration-accent/35 underline-offset-2 hover:text-accent-hover hover:decoration-accent/60"
- aria-label={t("skills.teamskillshub.titleHubAria")}
+ aria-label={t('skills.teamskillshub.titleHubAria')}
>
- {t("skills.teamskillshub.titleHubLinkText")}
+ {t('skills.teamskillshub.titleHubLinkText')}
</a>
</p>
</div>
@@ -425,22 +547,25 @@ export function TeamSkillsHubModal({
onClick={onClose}
className="px-4 py-2 rounded-2xl text-sm text-text border border-gray-400 hover:border-gray-600 hover:bg-secondary/50 "
>
- {t("common.close")}
+ {t('common.close')}
</button>
</div>
<div className="p-5 overflow-auto flex-1 min-h-0">
- {message && message.type === "success" && (
- <div className="fixed top-4 right-4 z-[9999] rounded-[4px] text-sm text-text shadow-lg flex items-center gap-3 px-4" style={{ backgroundColor: "var(--color-feedback-success-toast)", width: "564px", height: "40px" }}>
+ {message && message.type === 'success' && (
+ <div
+ className="fixed top-4 right-4 z-[9999] rounded-[4px] text-sm text-text shadow-lg flex items-center gap-3 px-4"
+ style={{ backgroundColor: 'var(--color-feedback-success-toast)', width: '564px', height: '40px' }}
+ >
<span className="w-4 h-4 rounded-full bg-[var(--color-feedback-success-indicator)] flex items-center justify-center flex-shrink-0">
<svg className="w-3 h-3 text-text-inverse" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={3} d="M5 13l4 4L19 7" />
</svg>
</span>
- {message.text.replace("√", "")}
+ {message.text.replace('√', '')}
<button
type="button"
- onClick={() => showMessage("success", "")}
+ onClick={() => showMessage('success', '')}
className="ml-auto w-6 h-6 flex items-center justify-center hover:bg-card/30 rounded-full "
>
<svg className="w-4 h-4 text-gray-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
@@ -449,87 +574,92 @@ export function TeamSkillsHubModal({
</button>
</div>
)}
- {message && message.type === "error" && (
- <div className="mb-3 px-3 py-2.5 rounded-lg text-sm leading-snug border border-danger/40 bg-danger/10 text-danger">
- {message.text}
- </div>
+ {message && message.type === 'error' && (
+ <div className="mb-3 px-3 py-2.5 rounded-lg text-sm leading-snug border border-danger/40 bg-danger/10 text-danger">{message.text}</div>
)}
<div className="flex items-center gap-2">
<input
value={query}
- onChange={(e) => setQuery(e.target.value)}
- onKeyDown={(e) => e.key === "Enter" && handleSearch()}
- placeholder={t("skills.teamskillshub.searchPlaceholder")}
+ onChange={e => setQuery(e.target.value)}
+ onKeyDown={e => e.key === 'Enter' && handleSearch()}
+ placeholder={t('skills.teamskillshub.searchPlaceholder')}
className="flex-1 min-w-0 px-3 py-2 rounded-md bg-secondary border border-border text-sm text-text placeholder:text-text-muted"
/>
<button
type="button"
onClick={() => void handleSearch()}
- disabled={loadState === "loading" || !query.trim()}
+ disabled={loadState === 'loading' || !query.trim()}
className={`px-4 py-2 rounded-2xl text-sm border border-gray-400 hover:border-gray-600 hover:bg-secondary/50 ${
- loadState === "loading" || !query.trim()
- ? "text-text-muted cursor-not-allowed"
- : "text-text"
+ loadState === 'loading' || !query.trim() ? 'text-text-muted cursor-not-allowed' : 'text-text'
}`}
>
- {loadState === "loading" ? t("common.loading") : t("skills.teamskillshub.search")}
+ {loadState === 'loading' ? t('common.loading') : t('skills.teamskillshub.search')}
</button>
</div>
- {loadState === "success" && (
+ {loadState === 'success' && (
<div className="mt-4 flex min-h-0 max-h-[50vh] flex-col gap-2">
<div className="min-h-0 flex-1 space-y-2 overflow-y-auto pr-0.5">
{results.length === 0 ? (
- <div className="text-xs text-text-muted">{t("skills.teamskillshub.noResults")}</div>
+ <div className="text-xs text-text-muted">{t('skills.teamskillshub.noResults')}</div>
) : (
- results.map((item) => {
+ results.map(item => {
+ const updateStatus = updateStatuses.get(`${item.source_id}:${item.name}`);
const isInstalled =
- installedAssetIds.has(item.asset_id) || (installedSkillOrigins?.has(`teamskillshub:${item.asset_id}`) ?? false);
- const isInstalling = installingAssetId === item.asset_id;
+ Boolean(updateStatus) ||
+ installedSkillNames.has(item.name) ||
+ (installedSkillOrigins?.has(`${item.source_id || sourceId}:${item.name}`) ?? false) ||
+ (item.skill_id != null &&
+ ((installedSkillOrigins?.has(`${item.source_id || sourceId}:${item.skill_id}`) ?? false) ||
+ (installedSkillOrigins?.has(`teamskillshub:${item.skill_id}`) ?? false)));
+ const isInstalling = installingSkillName === item.name;
const avatar = getSkillAvatar(item.name);
return (
<div
- key={item.asset_id}
+ key={`${item.source_id}:${item.name}:${item.version_id}`}
className="p-4 rounded-lg border border-border bg-panel flex items-start justify-between gap-4"
>
<div className="flex items-center gap-3 min-w-0 flex-1">
- <div className={`w-10 h-10 rounded-lg ${avatar.color} flex items-center justify-center flex-shrink-0 text-text-inverse font-semibold`}>
+ <div
+ className={`w-10 h-10 rounded-lg ${avatar.color} flex items-center justify-center flex-shrink-0 text-text-inverse font-semibold`}
+ >
{avatar.firstChar}
</div>
<div className="min-w-0 flex-1">
- <div className="text-base font-semibold text-text-strong truncate">
- {item.name}
- </div>
- <div className="text-sm text-text-muted mt-1 line-clamp-3">
- {item.summary || t("skills.noDescription")}
- </div>
+ <div className="text-base font-semibold text-text-strong truncate">{item.name}</div>
+ <div className="text-sm text-text-muted mt-1 line-clamp-3">{item.summary || t('skills.noDescription')}</div>
<div className="text-xs text-text-muted mt-1">
- {t("skills.versionLabel")}: {item.version || "latest"}
+ {t('skills.versionLabel')}: {item.version || 'latest'}
</div>
</div>
</div>
<div className="flex-shrink-0">
- {isInstalled ? (
- <span className="px-4 py-2 rounded-2xl text-sm whitespace-nowrap border border-[color:var(--color-border-success)] bg-ok-subtle text-ok">
- {t("skills.status.installed")}
- </span>
- ) : (
- <button
- type="button"
- onClick={() => void handleInstall(item)}
- disabled={isInstalling}
- className={`min-w-[76px] h-[28px] px-3 rounded-[24px] text-sm text-text border border-text hover:bg-secondary/50 whitespace-nowrap ${
- isInstalling
- ? "text-text-muted cursor-not-allowed"
- : "text-text"
- }`}
- >
- {isInstalling
- ? t("skills.teamskillshub.installing")
- : t("skills.actions.install")}
- </button>
- )}
+ {isInstalled && updateStatus?.has_update ? (
+ <button
+ type="button"
+ onClick={() => void handleUpdate(item, updateStatus)}
+ disabled={isInstalling}
+ className="min-w-[76px] h-[28px] px-3 rounded-[24px] text-sm text-text border border-text hover:bg-secondary/50 whitespace-nowrap disabled:text-text-muted disabled:cursor-not-allowed"
+ >
+ {isInstalling ? t('skills.teamskillshub.updating') : t('common.update')}
+ </button>
+ ) : isInstalled ? (
+ <span className="px-4 py-2 rounded-2xl text-sm whitespace-nowrap border border-[color:var(--color-border-success)] bg-ok-subtle text-ok">
+ {t('skills.status.installed')}
+ </span>
+ ) : (
+ <button
+ type="button"
+ onClick={() => void handleInstall(item)}
+ disabled={isInstalling}
+ className={`min-w-[76px] h-[28px] px-3 rounded-[24px] text-sm text-text border border-text hover:bg-secondary/50 whitespace-nowrap ${
+ isInstalling ? 'text-text-muted cursor-not-allowed' : 'text-text'
+ }`}
+ >
+ {isInstalling ? t('skills.teamskillshub.installing') : t('skills.actions.install')}
+ </button>
+ )}
</div>
</div>
);
diff --git a/jiuwenswarm/channels/web/frontend/src/i18n/locales/en.json b/jiuwenswarm/channels/web/frontend/src/i18n/locales/en.json
index c1a358a84d..5896bbfb8b 100644
--- a/jiuwenswarm/channels/web/frontend/src/i18n/locales/en.json
+++ b/jiuwenswarm/channels/web/frontend/src/i18n/locales/en.json
@@ -13,7 +13,12 @@
"ok": "OK",
"and": "and",
"modify": "Modify",
- "delete": "Delete"
+ "delete": "Delete",
+ "pagination": {
+ "total": "{{count}} total",
+ "prev": "Previous",
+ "next": "Next"
+ }
},
"a2ui": {
"generating": "Generating A2UI interface...",
@@ -1529,6 +1534,8 @@
"disabling": "Disabling..."
},
"builtIn": "Built-in",
+ "enterprisePrebuilt": "Enterprise prebuilt",
+ "enterpriseManagedHint": "This skill is managed by an administrator and cannot be removed or toggled",
"status": {
"installed": "Installed",
"notInstalled": "Not installed",
@@ -1541,7 +1548,28 @@
"clawhub": "ClawHub",
"skillnet": "SkillNet",
"teamskillshub": "TeamSkillsHub",
- "unknown": "Unknown"
+ "unknown": "Unknown",
+ "author": "Author",
+ "rating": "Rating",
+ "downloads": "Downloads",
+ "localVersion": "Local version",
+ "updatedAt": "Updated",
+ "searchPlaceholder": "Search skills",
+ "noResults": "No matching skills",
+ "prev": "Previous",
+ "next": "Next",
+ "replaceConfirm": "Skill {{name}} is already installed. Overwrite?",
+ "replaceConfirmTitle": "Confirm overwrite",
+ "errors": {
+ "loadFailed": "Failed to load skill sources",
+ "searchFailed": "Search failed",
+ "installFailed": "Install failed",
+ "updateFailed": "Update failed"
+ },
+ "messages": {
+ "installed": "Installed: {{name}}",
+ "updated": "Updated: {{name}}"
+ }
},
"sourceLabel": "Source",
"statusLabel": "Status",
@@ -1865,6 +1893,7 @@
"install": "Install",
"replaceConfirm": "A skill named \"{{name}}\" is already installed. Continuing will uninstall the current version and replace it with the selected one. Continue?",
"installing": "Installing…",
+ "updating": "Updating…",
"updatedAt": "Updated {{date}}",
"configTitle": "Configure",
"configDescription": "Enter the CLI Token from the ClawHub platform to access the ClawHub skill library.",
@@ -1894,11 +1923,13 @@
"installing": "Installing…",
"replaceConfirm": "A skill named \"{{name}}\" is already installed. Continuing will uninstall the current version and replace it with the selected one. Continue?",
"messages": {
- "installed": "Installed: {{name}}"
+ "installed": "Installed: {{name}}",
+ "updated": "Updated: {{name}}"
},
"errors": {
"searchFailed": "Search failed",
"installFailed": "Install failed",
+ "updateFailed": "Update failed",
"skillAlreadyInstalled": "This skill is already installed."
}
},
diff --git a/jiuwenswarm/channels/web/frontend/src/i18n/locales/zh.json b/jiuwenswarm/channels/web/frontend/src/i18n/locales/zh.json
index 2e8fbfcb89..83287f70c6 100644
--- a/jiuwenswarm/channels/web/frontend/src/i18n/locales/zh.json
+++ b/jiuwenswarm/channels/web/frontend/src/i18n/locales/zh.json
@@ -13,7 +13,12 @@
"ok": "确定",
"and": "和",
"modify": "修改",
- "delete": "删除"
+ "delete": "删除",
+ "pagination": {
+ "total": "共 {{count}} 个",
+ "prev": "上一页",
+ "next": "下一页"
+ }
},
"a2ui": {
"generating": "A2UI 界面生成中...",
@@ -1530,6 +1535,8 @@
"disabling": "禁用中..."
},
"builtIn": "内置",
+ "enterprisePrebuilt": "企业预置",
+ "enterpriseManagedHint": "该技能由管理员统一管理,不允许卸载或启停",
"status": {
"installed": "已安装",
"notInstalled": "未安装",
@@ -1542,7 +1549,28 @@
"clawhub": "ClawHub",
"skillnet": "SkillNet",
"teamskillshub": "TeamSkillsHub",
- "unknown": "未知"
+ "unknown": "未知",
+ "author": "作者",
+ "rating": "评分",
+ "downloads": "下载量",
+ "localVersion": "本地版本",
+ "updatedAt": "更新时间",
+ "searchPlaceholder": "搜索技能名称或描述",
+ "noResults": "暂无匹配的技能",
+ "prev": "上一页",
+ "next": "下一页",
+ "replaceConfirm": "技能 {{name}} 已安装,是否覆盖重装?",
+ "replaceConfirmTitle": "覆盖安装确认",
+ "errors": {
+ "loadFailed": "获取技能源失败",
+ "searchFailed": "搜索失败",
+ "installFailed": "安装失败",
+ "updateFailed": "更新失败"
+ },
+ "messages": {
+ "installed": "已安装:{{name}}",
+ "updated": "已更新:{{name}}"
+ }
},
"sourceLabel": "来源",
"statusLabel": "状态",
@@ -1866,6 +1894,7 @@
"install": "安装",
"replaceConfirm": "已安装同名技能「{{name}}」,继续安装将卸载已安装的版本并替换为当前选择的版本。是否继续?",
"installing": "安装中…",
+ "updating": "更新中…",
"updatedAt": "更新于 {{date}}",
"configTitle": "配置",
"configDescription": "请输入从 ClawHub 平台获取的 CLI Token,用于访问 ClawHub 技能库。",
@@ -1895,11 +1924,13 @@
"installing": "安装中…",
"replaceConfirm": "已安装同名技能「{{name}}」,继续安装将卸载已安装的版本并替换为当前选择的版本。是否继续?",
"messages": {
- "installed": "已安装:{{name}}"
+ "installed": "已安装:{{name}}",
+ "updated": "已更新:{{name}}"
},
"errors": {
"searchFailed": "搜索失败",
"installFailed": "安装失败",
+ "updateFailed": "更新失败",
"skillAlreadyInstalled": "该技能已安装。"
}
},
diff --git a/jiuwenswarm/channels/web/frontend/src/services/webHttpClient.ts b/jiuwenswarm/channels/web/frontend/src/services/webHttpClient.ts
index 61d4639463..581ffe9052 100644
--- a/jiuwenswarm/channels/web/frontend/src/services/webHttpClient.ts
+++ b/jiuwenswarm/channels/web/frontend/src/services/webHttpClient.ts
@@ -79,8 +79,25 @@ const ROUTES: Record<string, RouteRow> = {
'cron.job.toggle': { verb: 'POST', path: '/cron/jobs/{id}/actions/toggle', kind: 'unary' },
'cron.job.preview': { verb: 'POST', path: '/cron/jobs/{id}/actions/preview', kind: 'unary' },
'cron.job.run_now': { verb: 'POST', path: '/cron/jobs/{id}/actions/run-now', kind: 'unary' },
+ 'skills.list': { verb: 'GET', path: '/skills', kind: 'unary' },
+ 'skills.installed': { verb: 'GET', path: '/skills/installed', kind: 'unary' },
+ 'skills.get': { verb: 'GET', path: '/skills/{name}', kind: 'unary' },
+ 'skills.install': { verb: 'POST', path: '/skills/actions/install', kind: 'unary' },
+ 'skills.uninstall': { verb: 'POST', path: '/skills/actions/uninstall', kind: 'unary' },
+ 'skills.toggle': { verb: 'POST', path: '/skills/actions/toggle', kind: 'unary' },
+ 'skills.import_local': { verb: 'POST', path: '/skills/actions/import-local', kind: 'unary' },
+ 'skills.source.providers': { verb: 'GET', path: '/skills/sources', kind: 'unary' },
+ 'skills.source.search': { verb: 'GET', path: '/skills/sources/search', kind: 'unary' },
+ 'skills.source.install': { verb: 'POST', path: '/skills/sources/install', kind: 'unary' },
+ 'skills.updates.check': { verb: 'GET', path: '/skills/updates', kind: 'unary' },
+ 'skills.update': { verb: 'POST', path: '/skills/actions/update', kind: 'unary' },
+ 'skills.teamskillshub.info': { verb: 'GET', path: '/skills/teamskillshub', kind: 'unary' },
+ 'skills.retrieval.status': { verb: 'GET', path: '/skills/retrieval/status', kind: 'unary' },
+ 'skills.retrieval.tree': { verb: 'GET', path: '/skills/retrieval/tree', kind: 'unary' },
+ 'skills.retrieval.index_build': { verb: 'POST', path: '/skills/retrieval/actions/index-build', kind: 'unary' },
+ 'skills.retrieval.index_cancel': { verb: 'POST', path: '/skills/retrieval/actions/index-cancel', kind: 'unary' },
'skills.enterprise.list': { verb: 'GET', path: '/skills/enterprise', kind: 'unary' },
- 'skills.enterprise.install': { verb: 'POST', path: '/skills/enterprise/actions/install', kind: 'unary' },
+ 'skills.enterprise.install': { verb: 'POST', path: '/skills/enterprise/install', kind: 'unary' },
'skills.enterprise.uninstall': { verb: 'POST', path: '/skills/enterprise/actions/uninstall', kind: 'unary' },
'skills.marketplace.list': { verb: 'GET', path: '/skills/marketplace', kind: 'unary' },
'skills.marketplace.add': { verb: 'POST', path: '/skills/marketplace', kind: 'unary' },
diff --git a/jiuwenswarm/channels/web/frontend/tests/webHttpClient.test.mjs b/jiuwenswarm/channels/web/frontend/tests/webHttpClient.test.mjs
index 903712ca1e..0f6f917fc4 100644
--- a/jiuwenswarm/channels/web/frontend/tests/webHttpClient.test.mjs
+++ b/jiuwenswarm/channels/web/frontend/tests/webHttpClient.test.mjs
@@ -177,6 +177,23 @@ const ENTERPRISE_ASSEMBLE = [
['cron.job.toggle', 'POST', '/api/v1/cron/jobs/job-1/actions/toggle', { id: 'job-1', enabled: true }, 'unary'],
['cron.job.preview', 'POST', '/api/v1/cron/jobs/job-1/actions/preview', { id: 'job-1', count: 3 }, 'unary'],
['cron.job.run_now', 'POST', '/api/v1/cron/jobs/job-1/actions/run-now', { id: 'job-1' }, 'unary'],
+ ['skills.list', 'GET', '/api/v1/skills', { with_installed: true }, 'unary'],
+ ['skills.installed', 'GET', '/api/v1/skills/installed', {}, 'unary'],
+ ['skills.get', 'GET', '/api/v1/skills/demo-skill', { name: 'demo-skill' }, 'unary'],
+ ['skills.install', 'POST', '/api/v1/skills/actions/install', { spec: 'owner/repo' }, 'unary'],
+ ['skills.uninstall', 'POST', '/api/v1/skills/actions/uninstall', { name: 'demo-skill' }, 'unary'],
+ ['skills.toggle', 'POST', '/api/v1/skills/actions/toggle', { name: 'demo-skill', enabled: false }, 'unary'],
+ ['skills.import_local', 'POST', '/api/v1/skills/actions/import-local', { path: '/tmp/demo' }, 'unary'],
+ ['skills.source.providers', 'GET', '/api/v1/skills/sources', {}, 'unary'],
+ ['skills.source.search', 'POST', '/api/v1/skills/sources/actions/search', { source_id: 'swarmskillhub', q: 'demo' }, 'unary'],
+ ['skills.source.install', 'POST', '/api/v1/skills/sources/actions/install', { source_id: 'swarmskillhub', skill_id: 'skill-1', version_id: 'v1' }, 'unary'],
+ ['skills.updates.check', 'GET', '/api/v1/skills/updates', { source_id: 'swarmskillhub' }, 'unary'],
+ ['skills.update', 'POST', '/api/v1/skills/actions/update', { source_id: 'swarmskillhub', skill_id: 'skill-1' }, 'unary'],
+ ['skills.teamskillshub.info', 'GET', '/api/v1/skills/teamskillshub', {}, 'unary'],
+ ['skills.retrieval.status', 'GET', '/api/v1/skills/retrieval/status', {}, 'unary'],
+ ['skills.retrieval.tree', 'GET', '/api/v1/skills/retrieval/tree', {}, 'unary'],
+ ['skills.retrieval.index_build', 'POST', '/api/v1/skills/retrieval/actions/index-build', {}, 'unary'],
+ ['skills.retrieval.index_cancel', 'POST', '/api/v1/skills/retrieval/actions/index-cancel', {}, 'unary'],
['skills.enterprise.list', 'GET', '/api/v1/skills/enterprise', {}, 'unary'],
['skills.enterprise.install', 'POST', '/api/v1/skills/enterprise/actions/install', { url: 'http://x' }, 'unary'],
['skills.enterprise.uninstall', 'POST', '/api/v1/skills/enterprise/actions/uninstall', { name: 's' }, 'unary'],
@@ -197,7 +214,7 @@ const ENTERPRISE_ASSEMBLE = [
];
test('every enterprise mapped method assembles verb+url+kind', () => {
- assert.equal(ENTERPRISE_ASSEMBLE.length, 35);
+ assert.equal(ENTERPRISE_ASSEMBLE.length, 52);
const seen = new Set();
for (const [method, verb, url, params, kind] of ENTERPRISE_ASSEMBLE) {
seen.add(method);
@@ -312,7 +329,6 @@ test('unmapped A2 and personal methods stay null', () => {
'chat.resume',
'permissions.tools.get',
'harness.packages',
- 'skills.list',
];
for (const method of unmapped) {
assert.equal(assembleWebRest(method, { session_id: 's', id: '1', name: 'n' }, BASE), null, method);
@@ -388,4 +404,3 @@ test('interrupt unary maps only real interrupt_result, never forges success', ()
});
assert.equal(pause.payload.intent, 'pause');
});
-