mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-22 13:42:00 +00:00
AgentLab:可视化 Agent 编排实验台
在画布上拖拽编排 agent 工作流,并实时看着它执行。 后端 FastAPI + LangGraph:把画布 JSON 编译成 StateGraph,15 种节点 (模型/Agent/多Agent、工具/沙箱、分支/循环/子图、记忆/检索/整形、 人工介入/结构校验)。选 LangGraph 是因为可视化编排真正难的是暂停、 恢复和回放,而 checkpointer + interrupt() 正好把这几件事做在了底层。 前端 React + React Flow:节点元数据驱动属性面板与连接桩,运行时 节点高亮、边流动画、卡片内流式 token 全部由同一份事件流驱动。 关键实现: - Agent 内工具审批用 @task 缓存模型调用,interrupt 重放时不重复计费 - 沙箱保持只读根文件系统,代码经 exec+base64 写入(put_archive 会被 只读容器拒绝),断网、非 root、内存/CPU/超时限额 - 检索为向量与 BM25 混合,本地哈希 embedding 零配置可用 - 分支条件走 AST 白名单求值器;HTTP 工具逐 IP 拦截内网与元数据地址 - Mock provider 让无 API Key 也能跑通完整链路 7 个内置模板全部冒烟通过,含真实模型端到端验证。
This commit is contained in:
@@ -0,0 +1,304 @@
|
||||
@import 'tailwindcss';
|
||||
@import '@xyflow/react/dist/style.css';
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
主题 token。深色是默认(长时间盯画布,深色更省眼),浅色由 data-theme 切换。
|
||||
-------------------------------------------------------------------------- */
|
||||
:root {
|
||||
--bg: #0b0e14;
|
||||
--bg-elev: #11151f;
|
||||
--bg-panel: #141926;
|
||||
--bg-hover: #1b2232;
|
||||
--border: #232a3a;
|
||||
--border-strong: #333c52;
|
||||
--text: #e4e8f1;
|
||||
--text-dim: #94a0b8;
|
||||
--text-faint: #5f6b82;
|
||||
--accent: #4f8cff;
|
||||
--accent-soft: #1e3a6b;
|
||||
--ok: #3fb950;
|
||||
--warn: #d29922;
|
||||
--err: #f85149;
|
||||
--canvas-dot: #1e2534;
|
||||
}
|
||||
|
||||
:root[data-theme='light'] {
|
||||
--bg: #f6f7f9;
|
||||
--bg-elev: #ffffff;
|
||||
--bg-panel: #ffffff;
|
||||
--bg-hover: #eef1f6;
|
||||
--border: #dfe3ea;
|
||||
--border-strong: #c3cad6;
|
||||
--text: #1a1f2b;
|
||||
--text-dim: #5a6579;
|
||||
--text-faint: #8b95a7;
|
||||
--accent: #2563eb;
|
||||
--accent-soft: #dbeafe;
|
||||
--ok: #1a7f37;
|
||||
--warn: #9a6700;
|
||||
--err: #cf222e;
|
||||
--canvas-dot: #d8dde6;
|
||||
}
|
||||
|
||||
@theme inline {
|
||||
--color-bg: var(--bg);
|
||||
--color-elev: var(--bg-elev);
|
||||
--color-panel: var(--bg-panel);
|
||||
--color-hover: var(--bg-hover);
|
||||
--color-line: var(--border);
|
||||
--color-line-strong: var(--border-strong);
|
||||
--color-fg: var(--text);
|
||||
--color-dim: var(--text-dim);
|
||||
--color-faint: var(--text-faint);
|
||||
--color-accent: var(--accent);
|
||||
--color-accent-soft: var(--accent-soft);
|
||||
--color-ok: var(--ok);
|
||||
--color-warn: var(--warn);
|
||||
--color-err: var(--err);
|
||||
}
|
||||
|
||||
* {
|
||||
border-color: var(--border);
|
||||
}
|
||||
|
||||
html,
|
||||
body,
|
||||
#root {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
|
||||
'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
|
||||
font-size: 13px;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
code,
|
||||
pre,
|
||||
.mono {
|
||||
font-family: 'SF Mono', ui-monospace, 'JetBrains Mono', Menlo, Consolas, monospace;
|
||||
}
|
||||
|
||||
/* 滚动条:细一点,不抢视觉 */
|
||||
::-webkit-scrollbar {
|
||||
width: 9px;
|
||||
height: 9px;
|
||||
}
|
||||
::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: var(--border-strong);
|
||||
border-radius: 5px;
|
||||
}
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: var(--text-faint);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
节点类型配色。同一个色相贯穿:图标底色、边框、连线高亮。
|
||||
-------------------------------------------------------------------------- */
|
||||
.nt-input { --nt: #3fb950; }
|
||||
.nt-output { --nt: #a371f7; }
|
||||
.nt-llm { --nt: #4f8cff; }
|
||||
.nt-agent { --nt: #6366f1; }
|
||||
.nt-supervisor { --nt: #db61a2; }
|
||||
.nt-tool { --nt: #f0883e; }
|
||||
.nt-code { --nt: #2dd4bf; }
|
||||
.nt-branch { --nt: #d29922; }
|
||||
.nt-loop { --nt: #ec4899; }
|
||||
.nt-human { --nt: #f85149; }
|
||||
.nt-validate { --nt: #84cc16; }
|
||||
.nt-memory { --nt: #14b8a6; }
|
||||
.nt-retrieve { --nt: #0ea5e9; }
|
||||
.nt-transform { --nt: #8b949e; }
|
||||
.nt-subgraph { --nt: #bc8cff; }
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
React Flow 覆盖
|
||||
-------------------------------------------------------------------------- */
|
||||
.react-flow {
|
||||
background: var(--bg);
|
||||
}
|
||||
.react-flow__attribution {
|
||||
display: none;
|
||||
}
|
||||
.react-flow__handle {
|
||||
width: 9px;
|
||||
height: 9px;
|
||||
background: var(--bg-elev);
|
||||
border: 2px solid var(--border-strong);
|
||||
transition: all 0.12s;
|
||||
}
|
||||
.react-flow__handle:hover {
|
||||
border-color: var(--accent);
|
||||
transform: scale(1.25);
|
||||
}
|
||||
.react-flow__handle-connecting {
|
||||
border-color: var(--accent);
|
||||
}
|
||||
.react-flow__edge-path {
|
||||
stroke: var(--border-strong);
|
||||
stroke-width: 1.6;
|
||||
}
|
||||
.react-flow__edge.selected .react-flow__edge-path {
|
||||
stroke: var(--accent);
|
||||
stroke-width: 2.4;
|
||||
}
|
||||
.react-flow__edge-text {
|
||||
fill: var(--text-dim);
|
||||
font-size: 10px;
|
||||
}
|
||||
.react-flow__controls-button {
|
||||
background: var(--bg-panel);
|
||||
border-color: var(--border);
|
||||
fill: var(--text-dim);
|
||||
}
|
||||
.react-flow__controls-button:hover {
|
||||
background: var(--bg-hover);
|
||||
}
|
||||
.react-flow__minimap {
|
||||
background: var(--bg-elev);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
/* 正在执行的边:让数据流动可见 */
|
||||
.react-flow__edge.edge-active .react-flow__edge-path {
|
||||
stroke: var(--accent);
|
||||
stroke-width: 2.4;
|
||||
stroke-dasharray: 6 4;
|
||||
animation: dash 0.5s linear infinite;
|
||||
}
|
||||
@keyframes dash {
|
||||
to {
|
||||
stroke-dashoffset: -10;
|
||||
}
|
||||
}
|
||||
|
||||
/* 节点运行状态 */
|
||||
@keyframes pulse-ring {
|
||||
0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--nt, #4f8cff) 55%, transparent); }
|
||||
70% { box-shadow: 0 0 0 9px transparent; }
|
||||
100% { box-shadow: 0 0 0 0 transparent; }
|
||||
}
|
||||
.node-running {
|
||||
animation: pulse-ring 1.4s ease-out infinite;
|
||||
border-color: var(--nt, #4f8cff) !important;
|
||||
}
|
||||
.node-done {
|
||||
border-color: color-mix(in srgb, var(--ok) 60%, transparent) !important;
|
||||
}
|
||||
.node-failed {
|
||||
border-color: var(--err) !important;
|
||||
}
|
||||
.node-waiting {
|
||||
border-color: var(--warn) !important;
|
||||
}
|
||||
|
||||
@keyframes fade-up {
|
||||
from { opacity: 0; transform: translateY(4px); }
|
||||
to { opacity: 1; transform: none; }
|
||||
}
|
||||
.fade-up {
|
||||
animation: fade-up 0.16s ease-out;
|
||||
}
|
||||
|
||||
/* 表单控件统一外观 */
|
||||
.field {
|
||||
width: 100%;
|
||||
background: var(--bg);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 6px;
|
||||
padding: 6px 9px;
|
||||
color: var(--text);
|
||||
font-size: 12px;
|
||||
outline: none;
|
||||
transition: border-color 0.12s;
|
||||
}
|
||||
.field:focus {
|
||||
border-color: var(--accent);
|
||||
}
|
||||
.field::placeholder {
|
||||
color: var(--text-faint);
|
||||
}
|
||||
textarea.field {
|
||||
resize: vertical;
|
||||
min-height: 62px;
|
||||
line-height: 1.55;
|
||||
}
|
||||
select.field {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
border-radius: 6px;
|
||||
padding: 6px 11px;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
border: 1px solid var(--border);
|
||||
background: var(--bg-elev);
|
||||
color: var(--text);
|
||||
cursor: pointer;
|
||||
transition: all 0.12s;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.btn:hover:not(:disabled) {
|
||||
background: var(--bg-hover);
|
||||
border-color: var(--border-strong);
|
||||
}
|
||||
.btn:disabled {
|
||||
opacity: 0.45;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
.btn-primary {
|
||||
background: var(--accent);
|
||||
border-color: var(--accent);
|
||||
color: #fff;
|
||||
}
|
||||
.btn-primary:hover:not(:disabled) {
|
||||
filter: brightness(1.12);
|
||||
background: var(--accent);
|
||||
}
|
||||
.btn-danger {
|
||||
color: var(--err);
|
||||
border-color: color-mix(in srgb, var(--err) 40%, transparent);
|
||||
}
|
||||
.btn-ghost {
|
||||
background: transparent;
|
||||
border-color: transparent;
|
||||
}
|
||||
.btn-ghost:hover:not(:disabled) {
|
||||
background: var(--bg-hover);
|
||||
}
|
||||
.btn-sm {
|
||||
padding: 3px 7px;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 1px 7px;
|
||||
border-radius: 999px;
|
||||
font-size: 10.5px;
|
||||
border: 1px solid var(--border);
|
||||
color: var(--text-dim);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.label {
|
||||
display: block;
|
||||
font-size: 11px;
|
||||
color: var(--text-dim);
|
||||
margin-bottom: 4px;
|
||||
font-weight: 500;
|
||||
}
|
||||
Reference in New Issue
Block a user