From b9854192c6f69766b4ea2289ccdd0b2b831c8ebd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=AC=E6=98=8E?= <83812544+Ed1s0nZ@users.noreply.github.com> Date: Fri, 31 Jul 2026 21:04:11 +0800 Subject: [PATCH] Add files via upload --- web/static/css/style.css | 262 ++++++++++++++++ web/static/i18n/en-US.json | 77 ++++- web/static/i18n/zh-CN.json | 77 ++++- web/static/js/chat.js | 74 ++++- web/static/js/monitor.js | 2 +- web/static/js/workflows.js | 590 ++++++++++++++++++++++++++++++++++++- web/templates/index.html | 42 ++- 7 files changed, 1109 insertions(+), 15 deletions(-) diff --git a/web/static/css/style.css b/web/static/css/style.css index b13b449d..17e8ecb6 100644 --- a/web/static/css/style.css +++ b/web/static/css/style.css @@ -40124,6 +40124,247 @@ html[data-theme="dark"] .workflow-status-toggle.is-disabled { padding: 12px 18px; } +.workflow-ai-modal-content { + width: min(760px, calc(100vw - 32px)); + max-height: calc(100vh - 64px); + overflow: hidden; +} + +.workflow-ai-modal-header { + align-items: flex-start; +} + +.workflow-ai-modal-header h2 { + margin-bottom: 4px; +} + +.workflow-ai-subtitle { + margin: 0; + color: var(--text-secondary); + font-size: 13px; +} + +.workflow-ai-modal-body { + display: grid; + gap: 14px; + max-height: min(66vh, 640px); + overflow-y: auto; +} + +.workflow-ai-prompt-field textarea { + resize: vertical; + min-height: 116px; +} + +.workflow-ai-examples, +.workflow-ai-options { + display: flex; + flex-wrap: wrap; + gap: 8px; +} + +.workflow-ai-options label { + display: inline-flex; + align-items: center; + gap: 6px; + padding: 7px 10px; + border: 1px solid var(--border-color); + border-radius: 7px; + color: var(--text-secondary); + font-size: 13px; +} + +.workflow-ai-result { + display: grid; + gap: 10px; +} + +.workflow-ai-result:empty { + display: none; +} + +.workflow-ai-result-grid { + display: grid; + grid-template-columns: repeat(4, minmax(0, 1fr)); + gap: 8px; +} + +.workflow-ai-progress { + display: grid; + grid-template-columns: repeat(4, minmax(0, 1fr)); + gap: 8px; +} + +.workflow-ai-progress[hidden] { + display: none; +} + +.workflow-ai-progress span { + display: flex; + align-items: center; + gap: 8px; + min-width: 0; + padding: 9px 10px; + border: 1px solid var(--border-color); + border-radius: 8px; + color: var(--text-secondary); + background: var(--bg-secondary); +} + +.workflow-ai-progress b { + display: inline-grid; + flex: 0 0 22px; + width: 22px; + height: 22px; + place-items: center; + border-radius: 50%; + background: var(--bg-primary); + color: var(--text-secondary); + font-size: 12px; +} + +.workflow-ai-progress small { + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.workflow-ai-progress .is-active { + border-color: color-mix(in srgb, var(--accent-color) 45%, var(--border-color)); + color: var(--text-primary); +} + +.workflow-ai-progress .is-active b { + background: var(--accent-color); + color: white; +} + +.workflow-ai-progress .is-complete b { + background: #16a34a; + color: white; +} + +.workflow-ai-preview { + display: grid; + gap: 8px; + padding: 10px; + border: 1px solid var(--border-color); + border-radius: 8px; + background: var(--bg-secondary); +} + +.workflow-ai-preview-title { + color: var(--text-secondary); + font-size: 12px; + font-weight: 700; +} + +.workflow-ai-preview-flow { + display: flex; + align-items: center; + gap: 7px; + overflow-x: auto; + padding-bottom: 2px; +} + +.workflow-ai-preview-flow i { + flex: 0 0 auto; + color: var(--text-secondary); + font-style: normal; +} + +.workflow-ai-preview-node { + display: grid; + flex: 0 0 auto; + gap: 2px; + width: 128px; + min-height: 48px; + padding: 7px 9px; + border: 1px solid color-mix(in srgb, var(--accent-color) 22%, var(--border-color)); + border-radius: 8px; + background: var(--bg-primary); +} + +.workflow-ai-preview-node small { + color: var(--text-secondary); + font-size: 11px; +} + +.workflow-ai-preview-node strong { + overflow: hidden; + color: var(--text-primary); + font-size: 12px; + line-height: 1.35; + text-overflow: ellipsis; + white-space: nowrap; +} + +.workflow-ai-preview-node.is-risky { + border-color: rgba(249, 115, 22, 0.62); + background: rgba(249, 115, 22, 0.08); +} + +.workflow-ai-result-grid span, +.workflow-ai-result-section { + border: 1px solid var(--border-color); + border-radius: 8px; + background: var(--bg-secondary); +} + +.workflow-ai-result-grid span { + display: grid; + gap: 4px; + padding: 10px; + color: var(--text-secondary); + font-size: 12px; +} + +.workflow-ai-result-grid strong { + color: var(--text-primary); + font-size: 16px; +} + +.workflow-ai-result-section { + padding: 10px 12px; + font-size: 13px; +} + +.workflow-ai-result-section p { + margin: 4px 0 0; + color: var(--text-secondary); +} + +.workflow-ai-result-section ul { + margin: 8px 0 0; + padding-left: 18px; + color: var(--text-secondary); +} + +.workflow-ai-result-section.is-warning { + border-color: rgba(245, 158, 11, 0.45); + background: rgba(245, 158, 11, 0.08); +} + +.workflow-ai-result-section.is-attention { + border-color: rgba(14, 165, 233, 0.42); + background: rgba(14, 165, 233, 0.08); +} + +.workflow-ai-modal-footer { + gap: 8px; +} + +@media (max-width: 640px) { + .workflow-ai-progress { + grid-template-columns: repeat(2, minmax(0, 1fr)); + } + + .workflow-ai-result-grid { + grid-template-columns: repeat(2, minmax(0, 1fr)); + } +} + html[data-theme="dark"] .workflow-dry-run-modal-icon { color: #bfdbfe; background: rgba(59, 130, 246, 0.14); @@ -40364,6 +40605,27 @@ html[data-theme="dark"] .workflow-toolbar #workflow-connect-btn[aria-pressed="tr font-weight: 600; } +.workflow-ai-canvas-status { + position: absolute; + top: 14px; + left: 50%; + z-index: 2; + transform: translateX(-50%); + padding: 9px 14px; + border: 1px solid color-mix(in srgb, var(--accent-color) 35%, var(--border-color)); + border-radius: 999px; + background: color-mix(in srgb, var(--bg-primary) 92%, var(--accent-color)); + box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12); + color: var(--text-primary); + font-size: 13px; + font-weight: 700; + pointer-events: none; +} + +.workflow-ai-canvas-status[hidden] { + display: none; +} + .workflow-properties { display: flex; flex-direction: column; diff --git a/web/static/i18n/en-US.json b/web/static/i18n/en-US.json index 4913c5f8..9c9bf687 100644 --- a/web/static/i18n/en-US.json +++ b/web/static/i18n/en-US.json @@ -3532,6 +3532,81 @@ "canvasTools": "Canvas tools", "moreActions": "More", "deleteWorkflow": "Delete workflow", + "ai": { + "open": "Create from natural language", + "title": "Create Workflow from Natural Language", + "subtitle": "AI generates an editable draft and will not save or run it automatically.", + "promptLabel": "Workflow request", + "promptPlaceholder": "Example: continuously monitor a domain's subdomains, certificates, and exposed pages, then generate a report when new assets appear", + "examplesLabel": "Example requests", + "exampleDomain": "Domain monitor", + "exampleReport": "Report approval", + "exampleTriage": "Asset triage", + "includeObjective": "Generate objective configuration too", + "allowSchedule": "Allow scheduled trigger suggestions", + "allowHighRisk": "Allow high-risk node drafts", + "allowFallback": "Allow deterministic fallback if AI fails", + "promptRequired": "Describe the workflow request first.", + "generateFailed": "Generation failed", + "generatedWithIssues": "The draft still has validation issues. Adjust the request and try again.", + "generate": "Generate draft", + "generating": "Generating…", + "apply": "Render to canvas", + "rendering": "Rendering…", + "applied": "Workflow draft generated. Review it before saving.", + "canvasRendering": "AI is composing the canvas…", + "generatorAI": "AI channel", + "generatorLLM": "Model generated", + "generatorServer": "Server draft generator", + "generatorFallback": "Deterministic fallback", + "generatorUnknown": "Unknown generator", + "llmTitle": "Generated with the platform default AI channel and structurally validated", + "serverTitle": "Generated on the server and structurally audited", + "fallbackTitle": "Deterministic fallback was used", + "serverFallbackNotice": "Model generation is unavailable: {{reason}}", + "preview": "Flow preview", + "resultNodes": "Nodes", + "resultEdges": "Edges", + "resultRepairs": "Repair rounds", + "resultCapabilities": "Node capabilities", + "resultTools": "Tool capabilities", + "resultRisk": "Risk", + "resultSaveState": "Savable", + "yes": "Yes", + "no": "No", + "missingFields": "Missing configuration", + "riskWarnings": "Risk warnings", + "assumptions": "Assumptions", + "capabilityTrace": "Capability toolchain", + "nodeGenerated": "AI generated", + "nodeNeedsInput": "Needs input", + "riskLow": "Low", + "riskMedium": "Medium", + "riskHigh": "High", + "steps": { + "understand": "Understand request", + "match": "Match tools", + "draft": "Generate nodes", + "audit": "Safety audit" + }, + "examples": { + "domainMonitor": "Continuously monitor a domain's subdomains, certificates, and exposed pages, then generate a report when new assets appear", + "reportReview": "Collect threat intelligence every day, generate a report, and send it to the security owner for approval", + "assetTriage": "Extract high-risk assets from scan results, deduplicate them, and output remediation suggestions" + } + }, + "audit": { + "title": "Draft Audit", + "ready": "No blocking items found in this draft", + "review": "Review before saving or running", + "aiNodes": "AI nodes", + "needsInput": "Needs input", + "highRisk": "High risk", + "validation": "Structure issues", + "nodeIssues": "Node notes", + "validationIssues": "Structure checks", + "saveConfirm": "This draft contains missing configuration or high-risk nodes. Save as draft anyway?" + }, "package": { "importLocal": "Import local package", "export": "Export", @@ -3641,7 +3716,7 @@ "deleteSelected": "Delete selected", "autoLayout": "Auto layout", "dryRun": "Dry run", - "canvasEmpty": "Drag nodes from the left onto the canvas, or click node buttons to add quickly", + "canvasEmpty": "Drag nodes from the left onto the canvas, or generate a workflow from natural language", "properties": "Properties", "nodeProperties": "Node properties", "edgeProperties": "Edge properties", diff --git a/web/static/i18n/zh-CN.json b/web/static/i18n/zh-CN.json index 4176005a..4e7b5de8 100644 --- a/web/static/i18n/zh-CN.json +++ b/web/static/i18n/zh-CN.json @@ -3520,6 +3520,81 @@ "canvasTools": "画布工具", "moreActions": "更多", "deleteWorkflow": "删除工作流", + "ai": { + "open": "用自然语言创建", + "title": "用自然语言创建工作流", + "subtitle": "AI 会生成可编辑草稿,不会自动保存或运行。", + "promptLabel": "工作流需求", + "promptPlaceholder": "例如:持续监控一个域名的子域名、证书和暴露页面,发现新增资产后生成报告", + "examplesLabel": "示例需求", + "exampleDomain": "域名监控", + "exampleReport": "报告审批", + "exampleTriage": "资产研判", + "includeObjective": "同时生成 objective 配置", + "allowSchedule": "允许生成定时触发建议", + "allowHighRisk": "允许包含高风险节点草稿", + "allowFallback": "AI 失败时允许确定性兜底", + "promptRequired": "请先描述工作流需求。", + "generateFailed": "生成失败", + "generatedWithIssues": "草稿仍有校验问题,请调整需求后重试。", + "generate": "生成草稿", + "generating": "正在生成…", + "apply": "渲染到画布", + "rendering": "正在渲染…", + "applied": "已生成工作流草稿,请检查后保存。", + "canvasRendering": "AI 正在编排画布…", + "generatorAI": "AI 通道", + "generatorLLM": "大模型生成", + "generatorServer": "服务端草稿生成器", + "generatorFallback": "确定性兜底", + "generatorUnknown": "未知生成器", + "llmTitle": "已调用平台默认 AI 通道生成,并完成结构校验", + "serverTitle": "已通过服务端生成并完成结构审计", + "fallbackTitle": "已使用确定性兜底", + "serverFallbackNotice": "大模型生成不可用:{{reason}}", + "preview": "流程预览", + "resultNodes": "节点", + "resultEdges": "连线", + "resultRepairs": "修复轮次", + "resultCapabilities": "节点能力", + "resultTools": "工具能力", + "resultRisk": "风险", + "resultSaveState": "可保存", + "yes": "是", + "no": "否", + "missingFields": "缺失配置", + "riskWarnings": "风险提示", + "assumptions": "生成假设", + "capabilityTrace": "能力工具链", + "nodeGenerated": "AI 生成", + "nodeNeedsInput": "需补配置", + "riskLow": "低", + "riskMedium": "中", + "riskHigh": "高", + "steps": { + "understand": "理解需求", + "match": "匹配工具", + "draft": "生成节点", + "audit": "安全审计" + }, + "examples": { + "domainMonitor": "持续监控一个域名的子域名、证书和暴露页面,发现新增资产后生成报告", + "reportReview": "每天收集威胁情报,生成报告后交给安全负责人审批", + "assetTriage": "从扫描结果中提取高风险资产,去重后输出处置建议" + } + }, + "audit": { + "title": "草稿审计", + "ready": "当前草稿未发现阻断项", + "review": "保存或运行前建议检查", + "aiNodes": "AI 节点", + "needsInput": "需补配置", + "highRisk": "高风险", + "validation": "结构问题", + "nodeIssues": "节点提示", + "validationIssues": "结构校验", + "saveConfirm": "当前草稿包含需补配置或高风险节点,确认仅保存为草稿?" + }, "package": { "importLocal": "导入本地包", "export": "导出", @@ -3629,7 +3704,7 @@ "deleteSelected": "删除选中", "autoLayout": "自动布局", "dryRun": "试运行", - "canvasEmpty": "从左侧拖拽节点到画布,或点击节点按钮快速添加", + "canvasEmpty": "从左侧拖拽节点到画布,或用自然语言生成工作流", "properties": "属性", "nodeProperties": "节点属性", "edgeProperties": "连线属性", diff --git a/web/static/js/chat.js b/web/static/js/chat.js index c96d28f4..44bc337e 100644 --- a/web/static/js/chat.js +++ b/web/static/js/chat.js @@ -3584,13 +3584,14 @@ function setPendingMcpExecutionIds(messageElement, executionIds) { function normalizeToolExecutionSummaryForButton(raw) { const data = raw && typeof raw === 'object' ? raw : {}; - return { - toolName: data.toolName || data.name || '', - status: data.status || '', - executionId: data.executionId || '', - toolCallId: data.toolCallId || '', - processDetailId: data.processDetailId || '' - }; + return { + toolName: data.toolName || data.name || '', + status: data.status || '', + executionId: data.executionId || '', + toolCallId: data.toolCallId || '', + processDetailId: data.processDetailId || '', + resultDetailId: data.resultDetailId || '' + }; } function cacheToolExecutionSummaries(messageElement, summaries) { @@ -3924,6 +3925,15 @@ async function fetchProcessDetailDataForModal(detailId) { return detail && detail.data ? detail.data : null; } +async function fetchProcessDetailForModal(detailId) { + const id = detailId != null ? String(detailId).trim() : ''; + if (!id || typeof apiFetch !== 'function') return null; + const res = await apiFetch('/api/process-details/' + encodeURIComponent(id)); + const j = await res.json().catch(() => ({})); + if (!res.ok) return null; + return j && j.processDetail ? j.processDetail : null; +} + function processToolResultTextFromData(resultData) { if (!resultData) return ''; const noResultText = typeof window.t === 'function' ? window.t('timeline.noResult') : '无结果'; @@ -3950,6 +3960,56 @@ function processToolResultToMCPResult(resultData, rawText) { } async function showMCPDetailFromProcessToolItem(messageElement, summary, index) { + const item = normalizeToolExecutionSummaryForButton(summary); + if (item.processDetailId) { + const callDetail = await fetchProcessDetailForModal(item.processDetailId); + const callData = callDetail && callDetail.data ? callDetail.data : null; + if (callData) { + const args = typeof window.parseToolCallArgsFromData === 'function' + ? window.parseToolCallArgsFromData(callData) + : (callData.argumentsObj || {}); + let resultData = callData._mergedResult || null; + let resultDetailId = item.resultDetailId || callData._mergedResultDetailId || ''; + let rawText = resultData ? processToolResultTextFromData(resultData) : ''; + const resultPayloadDeferred = resultData && resultData._payloadDeferred === true; + const resultOnlyHasPreview = resultData && resultData.result == null && resultData.error == null && resultData.resultPreview != null; + if (resultDetailId && (!resultData || resultPayloadDeferred || resultOnlyHasPreview)) { + const resultDetail = await fetchProcessDetailForModal(resultDetailId); + const fullResult = resultDetail && resultDetail.data ? resultDetail.data : null; + if (fullResult) { + resultData = fullResult; + rawText = processToolResultTextFromData(fullResult); + } + } + const displayState = resultData && typeof window.getToolResultDisplayState === 'function' + ? window.getToolResultDisplayState(resultData, { rawText: rawText }) + : null; + const backgroundRunning = (displayState && displayState.kind === 'background_running') || String(item.status || '').toLowerCase() === 'background_running'; + const success = resultData + ? !(displayState ? displayState.isError : (resultData.isError || resultData.success === false)) + : String(item.status || '').toLowerCase() !== 'failed'; + const status = backgroundRunning + ? 'background_running' + : (resultData || item.status + ? (success ? 'completed' : 'failed') + : 'running'); + const exec = { + id: (resultData && resultData.executionId) || item.executionId || callData.executionId || '', + toolName: item.toolName || callData.toolName || (typeof window.t === 'function' ? window.t('chat.unknownTool') : '未知工具'), + status: status, + startTime: callDetail.createdAt || '', + arguments: args || {}, + result: processToolResultToMCPResult(resultData, rawText), + error: resultData && resultData.error ? String(resultData.error) : '' + }; + openAppModal('mcp-detail-modal', { focus: false }); + deferModalContent(function () { + renderMCPDetailModal(exec); + }); + return; + } + } + const target = await findToolExecutionTimelineItem(messageElement, summary, index); if (!target) { alert(typeof window.t === 'function' diff --git a/web/static/js/monitor.js b/web/static/js/monitor.js index b5791fee..44fae0da 100644 --- a/web/static/js/monitor.js +++ b/web/static/js/monitor.js @@ -5681,7 +5681,7 @@ function updateMonitorTimelineSection() { } -const MCP_STATS_TOP_N = 3; +const MCP_STATS_TOP_N = 6; const MCP_TIMELINE_RANGES = ['24h', '7d', '30d']; function getMcpMonitorTimelineRange() { diff --git a/web/static/js/workflows.js b/web/static/js/workflows.js index fe4aa43f..6cd3ae3e 100644 --- a/web/static/js/workflows.js +++ b/web/static/js/workflows.js @@ -37,6 +37,12 @@ requestSignature: '', dragDepth: 0 }; + const workflowAiState = { + draft: null, + result: null, + activeStep: '', + animating: false + }; const WORKFLOW_PACKAGE_INSPECTION_STORAGE_KEY = 'csai.workflow-package.inspection-id'; const WORKFLOW_PACKAGE_IMPORT_STORAGE_KEY = 'csai.workflow-package.import-id'; @@ -67,6 +73,18 @@ const NODE_PLACEMENT_PADDING = 20; const WORKFLOW_EDIT_ICON = ''; + const WORKFLOW_AI_TOOL_HINTS = [ + { keywords: ['子域名', 'subdomain', 'subfinder', 'amass'], tools: ['subfinder', 'amass'], label: '子域名发现' }, + { keywords: ['端口', 'port', 'nmap', 'rustscan', 'masscan'], tools: ['nmap', 'rustscan', 'masscan'], label: '端口扫描' }, + { keywords: ['漏洞', 'vuln', '漏洞扫描', 'nuclei', 'nikto', 'zap'], tools: ['nuclei', 'nikto', 'zap'], label: '漏洞扫描' }, + { keywords: ['目录', '路径', '暴露页面', 'dir', 'ffuf', 'gobuster', 'feroxbuster'], tools: ['ffuf', 'gobuster', 'feroxbuster', 'dirsearch'], label: '暴露面探测' }, + { keywords: ['证书', 'certificate', 'crt'], tools: ['subfinder'], label: '证书与域名线索收集' }, + { keywords: ['云', 'cloud', '配置审计', 'prowler', 'scout'], tools: ['prowler', 'scout-suite'], label: '云配置审计' }, + { keywords: ['容器', '镜像', 'k8s', 'kubernetes', 'trivy', 'kube'], tools: ['trivy', 'kube-bench', 'kube-hunter'], label: '容器安全检查' }, + { keywords: ['情报', '威胁情报', 'threat', 'ioc', 'virustotal', 'shodan', 'fofa'], tools: ['virustotal_search', 'shodan_search', 'fofa_search'], label: '威胁情报收集' } + ]; + const WORKFLOW_AI_HIGH_RISK_RE = /(隔离|封禁|加固|修复|执行|命令|脚本|删除|清理|阻断|封锁|攻击|利用|getshell|shell|payload|exploit|isolate|block|execute|script|delete|exploit|payload)/i; + const WORKFLOW_AI_PROGRESS_STEPS = ['understand', 'match', 'draft', 'audit']; function esc(text) { if (typeof escapeHtml === 'function') return escapeHtml(text == null ? '' : String(text)); @@ -166,6 +184,10 @@ function graphToElements(graph) { const nodes = (graph.nodes || []).map((node, index) => ({ group: 'nodes', + classes: [ + node.config && node.config.generated_by === 'natural_language' ? 'ai-generated' : '', + node.config && (node.config.risk_level === 'high' || node.config.requires_human_confirmation === 'true') ? 'high-risk' : '' + ].filter(Boolean).join(' '), data: { id: node.id || `node-${index + 1}`, label: node.label || wfNodeLabel(node.type) || node.id || _t('workflows.nodeFallback', { n: index + 1 }), @@ -265,6 +287,8 @@ { selector: 'node[type="hitl"]', style: { 'background-color': '#0f766e', 'border-color': '#5eead4' } }, { selector: 'node[type="output"]', style: { 'background-color': '#4338ca', 'border-color': '#a5b4fc' } }, { selector: 'node[type="end"]', style: { 'background-color': '#be123c', 'border-color': '#fb7185' } }, + { selector: 'node.ai-generated', style: { 'border-width': 2, 'border-color': '#38bdf8' } }, + { selector: 'node.high-risk', style: { 'border-width': 3, 'border-color': '#f97316' } }, { selector: 'edge', style: { @@ -1350,6 +1374,559 @@ } } + function workflowAiOption(id) { + const el = document.getElementById(id); + return !!(el && el.checked); + } + + function workflowAiSleep(ms) { + return new Promise(function (resolve) { setTimeout(resolve, ms); }); + } + + function workflowAiStepLabel(step) { + return _t('workflows.ai.steps.' + step); + } + + function workflowAiSetProgress(activeStep, done) { + workflowAiState.activeStep = activeStep || ''; + const wrap = document.getElementById('workflow-ai-progress'); + if (!wrap) return; + if (!activeStep && !done) { + wrap.hidden = true; + wrap.innerHTML = ''; + return; + } + wrap.hidden = false; + const activeIndex = WORKFLOW_AI_PROGRESS_STEPS.indexOf(activeStep); + wrap.innerHTML = WORKFLOW_AI_PROGRESS_STEPS.map(function (step, index) { + const complete = done || (activeIndex >= 0 && index < activeIndex); + const active = !done && step === activeStep; + return ` + ${complete ? '✓' : index + 1} + ${esc(workflowAiStepLabel(step))} + `; + }).join(''); + } + + function workflowAiPreviewItems(graph) { + const nodes = (graph.nodes || []).slice().sort(function (a, b) { + const ax = a.position && typeof a.position.x === 'number' ? a.position.x : 0; + const bx = b.position && typeof b.position.x === 'number' ? b.position.x : 0; + const ay = a.position && typeof a.position.y === 'number' ? a.position.y : 0; + const by = b.position && typeof b.position.y === 'number' ? b.position.y : 0; + return ax === bx ? ay - by : ax - bx; + }); + return nodes.slice(0, 9); + } + + function workflowAiPreviewHtml(graph) { + const items = workflowAiPreviewItems(graph); + if (!items.length) return ''; + return `
${esc(generator === 'llm' ? _t('workflows.ai.llmTitle') : (generator === 'deterministic' ? _t('workflows.ai.serverTitle') : _t('workflows.ai.fallbackTitle')))}