|
|
@@ -28,6 +28,29 @@ const pages = [
|
|
|
{ id: "connection", icon: "server", name: "平台设置" },
|
|
|
] as const
|
|
|
|
|
|
+const agentTones = [
|
|
|
+ ["#315fce", "#83a8ff"],
|
|
|
+ ["#7c3aed", "#c4b5fd"],
|
|
|
+ ["#0f766e", "#7dd8b5"],
|
|
|
+ ["#b45309", "#f3c77a"],
|
|
|
+ ["#be185d", "#f9a8d4"],
|
|
|
+ ["#0369a1", "#7dd3fc"],
|
|
|
+] as const
|
|
|
+
|
|
|
+function agentTone(agent: Record<string, unknown>) {
|
|
|
+ const key = paasText(agent.id) || paasText(agent.name)
|
|
|
+ let hash = 0
|
|
|
+ for (const char of key) hash = (hash * 31 + (char.codePointAt(0) ?? 0)) % 100000
|
|
|
+ const tone = agentTones[hash % agentTones.length]
|
|
|
+ return `light-dark(${tone[0]}, ${tone[1]})`
|
|
|
+}
|
|
|
+
|
|
|
+function agentInitial(agent: Record<string, unknown>) {
|
|
|
+ const chars = Array.from(paasText(agent.name) || paasText(agent.id))
|
|
|
+ const first = chars[0] || "?"
|
|
|
+ return /^[a-z]/i.test(first) ? chars.slice(0, 2).join("").toUpperCase() : first
|
|
|
+}
|
|
|
+
|
|
|
export default function PaasWorkspace(props: { standalone?: boolean; onOpenDeveloper?: () => void } = {}) {
|
|
|
const platform = usePlatform()
|
|
|
const dialog = useDialog()
|
|
|
@@ -45,6 +68,7 @@ export default function PaasWorkspace(props: { standalone?: boolean; onOpenDevel
|
|
|
chatAgentID: "",
|
|
|
openingWorkspace: false,
|
|
|
navOpen: false,
|
|
|
+ agentSearch: "",
|
|
|
editAgentID: "",
|
|
|
editReturn: "agents",
|
|
|
})
|
|
|
@@ -109,6 +133,16 @@ export default function PaasWorkspace(props: { standalone?: boolean; onOpenDevel
|
|
|
|
|
|
const localServer = () => server?.list.find(ServerConnection.builtin) ?? server?.list.find(ServerConnection.local)
|
|
|
const settingsPage = () => state.page === "connection" || state.page === "resources"
|
|
|
+ const visibleAgents = () => {
|
|
|
+ const query = ui.agentSearch.trim().toLocaleLowerCase()
|
|
|
+ if (!query) return state.agents
|
|
|
+ return state.agents.filter((agent) =>
|
|
|
+ [paasText(agent.name), paasText(agent.description), paasText(agent.id)]
|
|
|
+ .join(" ")
|
|
|
+ .toLocaleLowerCase()
|
|
|
+ .includes(query),
|
|
|
+ )
|
|
|
+ }
|
|
|
const pageLabel = () => {
|
|
|
if (state.page === "edit-agent") return "编辑智能体"
|
|
|
if (settingsPage()) return "平台设置"
|
|
|
@@ -471,10 +505,22 @@ export default function PaasWorkspace(props: { standalone?: boolean; onOpenDevel
|
|
|
<div>
|
|
|
<h1>智能体</h1>
|
|
|
<Show when={state.connected}>
|
|
|
- <p class="paas-muted">共 {state.agents.length} 个智能体</p>
|
|
|
+ <p class="paas-muted">
|
|
|
+ {ui.agentSearch.trim()
|
|
|
+ ? `显示 ${visibleAgents().length} / ${state.agents.length} 个智能体`
|
|
|
+ : `共 ${state.agents.length} 个智能体`}
|
|
|
+ </p>
|
|
|
</Show>
|
|
|
</div>
|
|
|
<div class="paas-directory-actions">
|
|
|
+ <input
|
|
|
+ class="paas-directory-search"
|
|
|
+ type="search"
|
|
|
+ aria-label="搜索智能体"
|
|
|
+ placeholder="搜索名称或能力"
|
|
|
+ value={ui.agentSearch}
|
|
|
+ onInput={(event) => setUI("agentSearch", event.currentTarget.value)}
|
|
|
+ />
|
|
|
<button type="button" disabled={disabled()} onClick={workspace.catalog}>
|
|
|
<Icon name="reset" size="small" />
|
|
|
刷新
|
|
|
@@ -506,16 +552,26 @@ export default function PaasWorkspace(props: { standalone?: boolean; onOpenDevel
|
|
|
</p>
|
|
|
</Show>
|
|
|
<Show
|
|
|
- when={state.agents.length}
|
|
|
+ when={visibleAgents().length}
|
|
|
fallback={
|
|
|
<Empty
|
|
|
- title={state.connected ? "暂未发现智能体" : "连接后查看智能体"}
|
|
|
- text="平台目录为空、发现未完成或尚未连接时,不会显示演示智能体。"
|
|
|
+ title={
|
|
|
+ !state.agents.length
|
|
|
+ ? state.connected
|
|
|
+ ? "暂未发现智能体"
|
|
|
+ : "连接后查看智能体"
|
|
|
+ : "没有匹配的智能体"
|
|
|
+ }
|
|
|
+ text={
|
|
|
+ !state.agents.length
|
|
|
+ ? "平台目录为空、发现未完成或尚未连接时,不会显示演示智能体。"
|
|
|
+ : "换个关键词,或清空搜索查看全部智能体。"
|
|
|
+ }
|
|
|
/>
|
|
|
}
|
|
|
>
|
|
|
<div class="paas-directory-grid">
|
|
|
- <For each={state.agents}>
|
|
|
+ <For each={visibleAgents()}>
|
|
|
{(agent) => {
|
|
|
const id = () => paasText(agent.id)
|
|
|
const name = () => paasText(agent.name)
|
|
|
@@ -539,8 +595,12 @@ export default function PaasWorkspace(props: { standalone?: boolean; onOpenDevel
|
|
|
return (
|
|
|
<article class="paas-agent-card">
|
|
|
<header>
|
|
|
- <span class="paas-agent-card-icon" aria-hidden="true">
|
|
|
- <Icon name="brain" size="large" />
|
|
|
+ <span
|
|
|
+ class="paas-agent-card-icon paas-agent-monogram"
|
|
|
+ aria-hidden="true"
|
|
|
+ style={{ "--agent-tone": agentTone(agent) }}
|
|
|
+ >
|
|
|
+ {agentInitial(agent)}
|
|
|
</span>
|
|
|
<div class="paas-agent-card-identity">
|
|
|
<h2 title={name()}>{name()}</h2>
|
|
|
@@ -564,9 +624,11 @@ export default function PaasWorkspace(props: { standalone?: boolean; onOpenDevel
|
|
|
</DropdownMenu.Portal>
|
|
|
</DropdownMenu>
|
|
|
</header>
|
|
|
- <p class="paas-agent-card-description" title={paasText(agent.description)}>
|
|
|
- {paasText(agent.description) || "平台未提供能力说明。"}
|
|
|
- </p>
|
|
|
+ <Show when={paasText(agent.description)}>
|
|
|
+ <p class="paas-agent-card-description" title={paasText(agent.description)}>
|
|
|
+ {paasText(agent.description)}
|
|
|
+ </p>
|
|
|
+ </Show>
|
|
|
<footer>
|
|
|
<button
|
|
|
type="button"
|