|
|
@@ -29,6 +29,7 @@ import {
|
|
|
} from "./layout"
|
|
|
import { PaasPreview, clearPreviewCache, type PaasPreviewFile } from "./preview"
|
|
|
import { PaasChat } from "./chat"
|
|
|
+import { groupAgents, resolveAgentProfile } from "./agent-profiles"
|
|
|
import { ProjectSwitcher } from "./project-switcher"
|
|
|
import { bindProjectWorkspace, newProject, readProjectState, writeProjectState } from "./projects"
|
|
|
import { createTaskIndex, PaasTasks } from "./tasks"
|
|
|
@@ -420,12 +421,21 @@ export default function PaasWorkspace(
|
|
|
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)]
|
|
|
+ return state.agents.filter((agent) => {
|
|
|
+ const profile = resolveAgentProfile(agent)
|
|
|
+ return [
|
|
|
+ paasText(agent.name),
|
|
|
+ paasText(agent.description),
|
|
|
+ paasText(agent.id),
|
|
|
+ profile.summary,
|
|
|
+ ...profile.capabilities,
|
|
|
+ ...profile.inputs,
|
|
|
+ ...profile.outputs,
|
|
|
+ ]
|
|
|
.join(" ")
|
|
|
.toLocaleLowerCase()
|
|
|
- .includes(query),
|
|
|
- )
|
|
|
+ .includes(query)
|
|
|
+ })
|
|
|
}
|
|
|
const pageLabel = () => {
|
|
|
if (state.page === "edit-agent") return "编辑智能体"
|
|
|
@@ -582,6 +592,109 @@ export default function PaasWorkspace(
|
|
|
workspace.setState("page", "edit-agent")
|
|
|
}
|
|
|
|
|
|
+ const renderAgentCard = (agent: Record<string, unknown>) => {
|
|
|
+ const id = () => paasText(agent.id)
|
|
|
+ const name = () => paasText(agent.name)
|
|
|
+ const profile = () => resolveAgentProfile(agent)
|
|
|
+ const version = () =>
|
|
|
+ typeof agent.current_version === "number" ? String(agent.current_version) : paasText(agent.current_version)
|
|
|
+
|
|
|
+ function openTasks() {
|
|
|
+ workspace.selectAgent(id())
|
|
|
+ workspace.setState("page", "tasks")
|
|
|
+ void tasks.refresh()
|
|
|
+ }
|
|
|
+
|
|
|
+ function openResources() {
|
|
|
+ workspace.selectAgent(id())
|
|
|
+ workspace.setState("page", "resources")
|
|
|
+ void workspace.verify()
|
|
|
+ }
|
|
|
+
|
|
|
+ return (
|
|
|
+ <article class="paas-agent-card">
|
|
|
+ <header>
|
|
|
+ <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>
|
|
|
+ <Show when={version()}>
|
|
|
+ <small class="paas-muted">v{version()}</small>
|
|
|
+ </Show>
|
|
|
+ </div>
|
|
|
+ <DropdownMenu modal={false} placement="bottom-end" gutter={6}>
|
|
|
+ <DropdownMenu.Trigger
|
|
|
+ class="paas-agent-card-more"
|
|
|
+ aria-label={`${name()}的更多操作`}
|
|
|
+ disabled={disabled()}
|
|
|
+ >
|
|
|
+ <span aria-hidden="true">···</span>
|
|
|
+ </DropdownMenu.Trigger>
|
|
|
+ <DropdownMenu.Portal>
|
|
|
+ <DropdownMenu.Content>
|
|
|
+ <DropdownMenu.Item onSelect={openTasks}>查看任务</DropdownMenu.Item>
|
|
|
+ <DropdownMenu.Item onSelect={openResources}>检查资源</DropdownMenu.Item>
|
|
|
+ </DropdownMenu.Content>
|
|
|
+ </DropdownMenu.Portal>
|
|
|
+ </DropdownMenu>
|
|
|
+ </header>
|
|
|
+ <Show when={profile().summary}>
|
|
|
+ <p class="paas-agent-card-description" title={profile().summary}>
|
|
|
+ {profile().summary}
|
|
|
+ </p>
|
|
|
+ </Show>
|
|
|
+ <Show when={profile().capabilities.length}>
|
|
|
+ <div class="paas-agent-tags">
|
|
|
+ <For each={profile().capabilities}>{(item) => <span>{item}</span>}</For>
|
|
|
+ </div>
|
|
|
+ </Show>
|
|
|
+ <footer>
|
|
|
+ <Show
|
|
|
+ when={profile().entryMode !== "internal"}
|
|
|
+ fallback={<span class="paas-muted">由研究流程调用</span>}
|
|
|
+ >
|
|
|
+ <button
|
|
|
+ type="button"
|
|
|
+ class="paas-directory-primary"
|
|
|
+ disabled={disabled()}
|
|
|
+ aria-label={`与 ${name()} 对话`}
|
|
|
+ onClick={() => {
|
|
|
+ setUI("chatAgentID", id())
|
|
|
+ workspace.setState("page", "chat")
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <Icon name="speech-bubble" size="small" />
|
|
|
+ 对话
|
|
|
+ </button>
|
|
|
+ </Show>
|
|
|
+ <button
|
|
|
+ type="button"
|
|
|
+ disabled={disabled()}
|
|
|
+ aria-label={`编辑 ${name()}`}
|
|
|
+ onClick={() => {
|
|
|
+ editAgent(id(), "agents")
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <Icon name="sliders" size="small" />
|
|
|
+ 编辑
|
|
|
+ </button>
|
|
|
+ </footer>
|
|
|
+ </article>
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ const renderAgentGroup = (title: string, id: string, agents: Record<string, unknown>[]) => (
|
|
|
+ <Show when={agents.length}>
|
|
|
+ <section class="paas-agent-section" aria-labelledby={id}>
|
|
|
+ <h2 id={id}>{title}</h2>
|
|
|
+ <div class="paas-directory-grid">
|
|
|
+ <For each={agents}>{renderAgentCard}</For>
|
|
|
+ </div>
|
|
|
+ </section>
|
|
|
+ </Show>
|
|
|
+ )
|
|
|
+
|
|
|
return (
|
|
|
<div
|
|
|
class="paas-workspace"
|
|
|
@@ -1143,96 +1256,21 @@ export default function PaasWorkspace(
|
|
|
/>
|
|
|
}
|
|
|
>
|
|
|
- <div class="paas-directory-grid">
|
|
|
- <For each={visibleAgents()}>
|
|
|
- {(agent) => {
|
|
|
- const id = () => paasText(agent.id)
|
|
|
- const name = () => paasText(agent.name)
|
|
|
- const version = () =>
|
|
|
- typeof agent.current_version === "number"
|
|
|
- ? String(agent.current_version)
|
|
|
- : paasText(agent.current_version)
|
|
|
-
|
|
|
- function openTasks() {
|
|
|
- workspace.selectAgent(id())
|
|
|
- workspace.setState("page", "tasks")
|
|
|
- void tasks.refresh()
|
|
|
- }
|
|
|
-
|
|
|
- function openResources() {
|
|
|
- workspace.selectAgent(id())
|
|
|
- workspace.setState("page", "resources")
|
|
|
- void workspace.verify()
|
|
|
- }
|
|
|
-
|
|
|
- return (
|
|
|
- <article class="paas-agent-card">
|
|
|
- <header>
|
|
|
- <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>
|
|
|
- <Show when={version()}>
|
|
|
- <small class="paas-muted">v{version()}</small>
|
|
|
- </Show>
|
|
|
- </div>
|
|
|
- <DropdownMenu modal={false} placement="bottom-end" gutter={6}>
|
|
|
- <DropdownMenu.Trigger
|
|
|
- class="paas-agent-card-more"
|
|
|
- aria-label={`${name()}的更多操作`}
|
|
|
- disabled={disabled()}
|
|
|
- >
|
|
|
- <span aria-hidden="true">···</span>
|
|
|
- </DropdownMenu.Trigger>
|
|
|
- <DropdownMenu.Portal>
|
|
|
- <DropdownMenu.Content>
|
|
|
- <DropdownMenu.Item onSelect={openTasks}>查看任务</DropdownMenu.Item>
|
|
|
- <DropdownMenu.Item onSelect={openResources}>检查资源</DropdownMenu.Item>
|
|
|
- </DropdownMenu.Content>
|
|
|
- </DropdownMenu.Portal>
|
|
|
- </DropdownMenu>
|
|
|
- </header>
|
|
|
- <Show when={paasText(agent.description)}>
|
|
|
- <p class="paas-agent-card-description" title={paasText(agent.description)}>
|
|
|
- {paasText(agent.description)}
|
|
|
- </p>
|
|
|
- </Show>
|
|
|
- <footer>
|
|
|
- <button
|
|
|
- type="button"
|
|
|
- class="paas-directory-primary"
|
|
|
- disabled={disabled()}
|
|
|
- aria-label={`与 ${name()} 对话`}
|
|
|
- onClick={() => {
|
|
|
- setUI("chatAgentID", id())
|
|
|
- workspace.setState("page", "chat")
|
|
|
- }}
|
|
|
- >
|
|
|
- <Icon name="speech-bubble" size="small" />
|
|
|
- 对话
|
|
|
- </button>
|
|
|
- <button
|
|
|
- type="button"
|
|
|
- disabled={disabled()}
|
|
|
- aria-label={`编辑 ${name()}`}
|
|
|
- onClick={() => {
|
|
|
- editAgent(id(), "agents")
|
|
|
- }}
|
|
|
- >
|
|
|
- <Icon name="sliders" size="small" />
|
|
|
- 编辑
|
|
|
- </button>
|
|
|
- </footer>
|
|
|
- </article>
|
|
|
- )
|
|
|
- }}
|
|
|
- </For>
|
|
|
- </div>
|
|
|
+ <For each={[
|
|
|
+ ["默认入口", "paas-agents-default", groupAgents(visibleAgents()).default],
|
|
|
+ ["专业任务", "paas-agents-professional", groupAgents(visibleAgents()).professional],
|
|
|
+ ["研究流水线", "paas-agents-workflow", groupAgents(visibleAgents()).workflow],
|
|
|
+ ] as const}>
|
|
|
+ {([title, id, agents]) => renderAgentGroup(title, id, agents)}
|
|
|
+ </For>
|
|
|
+ <Show when={groupAgents(visibleAgents()).internal.length}>
|
|
|
+ <details class="paas-agent-internal">
|
|
|
+ <summary>流程内部能力 · {groupAgents(visibleAgents()).internal.length}</summary>
|
|
|
+ <div class="paas-directory-grid">
|
|
|
+ <For each={groupAgents(visibleAgents()).internal}>{renderAgentCard}</For>
|
|
|
+ </div>
|
|
|
+ </details>
|
|
|
+ </Show>
|
|
|
</Show>
|
|
|
</Match>
|
|
|
|