feat:markdown区分场景

This commit is contained in:
ai-business-hql
2025-03-04 11:21:57 +08:00
parent 147b15a7fc
commit 7357c4e38e
6 changed files with 17 additions and 10 deletions
@@ -1,6 +1,6 @@
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["copilot_web/workflowChat-f8Iuyckz.js","copilot_web/vendor-markdown-Dek94WS0.js","copilot_web/vendor-react-V04_Axys.js","copilot_web/message-components-CM_pXuGY.js","copilot_web/input.js","copilot_web/assets/input-CJq8z6H1.css"].map(path => {
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["copilot_web/workflowChat-BJRfUUaH.js","copilot_web/vendor-markdown-Dek94WS0.js","copilot_web/vendor-react-V04_Axys.js","copilot_web/message-components-f2lQ6Vte.js","copilot_web/input.js","copilot_web/assets/input-CJq8z6H1.css"].map(path => {
const apiBase = window.comfyAPI?.api?.api?.api_base;
const prefix = apiBase ? `${apiBase.substring(1)}/` : '';
return `${prefix}${path}`;
}))))=>i.map(i=>d[i]);
import{_ as E}from"./input.js";import{j as s}from"./vendor-markdown-Dek94WS0.js";import{r as t,R as w}from"./vendor-react-V04_Axys.js";import{C as v}from"./message-components-CM_pXuGY.js";const y=9999999,x={EXPLAIN_NODE:"copilot:explain-node"},D="/copilot_web/assets/logo-BTZhX0BN.png";function _(n={}){const[u,l]=t.useState({x:n.initialX??window.innerWidth-160,y:n.initialY??20}),[o,r]=t.useState(!1),[a,m]=t.useState({x:0,y:0}),[d,c]=t.useState(0),[g,b]=t.useState({x:0,y:0}),f=t.useCallback(e=>{if(o){const i=Math.min(Math.max(0,e.clientX-g.x),window.innerWidth-(n.boundaryPadding?.right??100)),h=Math.min(Math.max(0,e.clientY-g.y),window.innerHeight-(n.boundaryPadding?.bottom??40));l({x:i,y:h})}},[o,g,n.boundaryPadding]),p=t.useCallback(e=>{if(o){const i=Math.sqrt(Math.pow(e.clientX-a.x,2)+Math.pow(e.clientY-a.y,2)),h=Date.now()-d;i<5&&h<200&&n.onClick?.()}r(!1)},[o,a,d,n.onClick]);return t.useEffect(()=>(o&&(document.addEventListener("mousemove",f),document.addEventListener("mouseup",p)),()=>{document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",p)}),[o,f,p]),{position:u,isDragging:o,handleMouseDown:e=>{e.preventDefault(),r(!0),c(Date.now()),m({x:e.clientX,y:e.clientY});const i=e.currentTarget.getBoundingClientRect();b({x:e.clientX-i.left,y:e.clientY-i.top})}}}const C=w.lazy(()=>E(()=>import("./workflowChat-f8Iuyckz.js"),__vite__mapDeps([0,1,2,3,4,5])).then(n=>({default:n.default})));function M(){const n=t.useRef(null),[u,l]=t.useState(!1),[o,r]=t.useState(!1),{position:a,isDragging:m,handleMouseDown:d}=_({boundaryPadding:{right:100,bottom:40},onClick:()=>l(!0)});return t.useEffect(()=>{const c=()=>{l(!0),r(!0)};return window.addEventListener(x.EXPLAIN_NODE,c),()=>window.removeEventListener(x.EXPLAIN_NODE,c)},[]),a?s.jsx(v,{children:s.jsx("div",{ref:n,children:s.jsxs("div",{className:"fixed",style:{zIndex:y,left:a.x,top:a.y,cursor:m?"grabbing":"grab"},children:[s.jsxs("button",{onMouseDown:d,className:"px-2 py-1 border border-gray-300 rounded-md bg-white text-black hover:bg-blue-300 hover:font-bold transition-colors select-none w-40 flex items-center space-x-1",style:{marginLeft:"-40px"},children:[s.jsx("img",{src:D,alt:"ComfyUI-Copilot Logo",className:"h-8 w-8"}),s.jsx("span",{className:"text-[14px] font-medium text-gray-800",children:"ComfyUI-Copilot"})]}),s.jsx(w.Suspense,{fallback:s.jsx("div",{children:"Loading..."}),children:s.jsx(C,{onClose:()=>{l(!1),r(!1)},visible:u,triggerUsage:o,onUsageTriggered:()=>r(!1)})})]})})}):null}const I=Object.freeze(Object.defineProperty({__proto__:null,default:M},Symbol.toStringTag,{value:"Module"}));export{I as A,D as l};
import{_ as E}from"./input.js";import{j as s}from"./vendor-markdown-Dek94WS0.js";import{r as t,R as w}from"./vendor-react-V04_Axys.js";import{C as v}from"./message-components-f2lQ6Vte.js";const y=9999999,x={EXPLAIN_NODE:"copilot:explain-node"},D="/copilot_web/assets/logo-BTZhX0BN.png";function _(n={}){const[u,l]=t.useState({x:n.initialX??window.innerWidth-160,y:n.initialY??20}),[o,r]=t.useState(!1),[a,m]=t.useState({x:0,y:0}),[d,c]=t.useState(0),[g,b]=t.useState({x:0,y:0}),f=t.useCallback(e=>{if(o){const i=Math.min(Math.max(0,e.clientX-g.x),window.innerWidth-(n.boundaryPadding?.right??100)),h=Math.min(Math.max(0,e.clientY-g.y),window.innerHeight-(n.boundaryPadding?.bottom??40));l({x:i,y:h})}},[o,g,n.boundaryPadding]),p=t.useCallback(e=>{if(o){const i=Math.sqrt(Math.pow(e.clientX-a.x,2)+Math.pow(e.clientY-a.y,2)),h=Date.now()-d;i<5&&h<200&&n.onClick?.()}r(!1)},[o,a,d,n.onClick]);return t.useEffect(()=>(o&&(document.addEventListener("mousemove",f),document.addEventListener("mouseup",p)),()=>{document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",p)}),[o,f,p]),{position:u,isDragging:o,handleMouseDown:e=>{e.preventDefault(),r(!0),c(Date.now()),m({x:e.clientX,y:e.clientY});const i=e.currentTarget.getBoundingClientRect();b({x:e.clientX-i.left,y:e.clientY-i.top})}}}const C=w.lazy(()=>E(()=>import("./workflowChat-BJRfUUaH.js"),__vite__mapDeps([0,1,2,3,4,5])).then(n=>({default:n.default})));function M(){const n=t.useRef(null),[u,l]=t.useState(!1),[o,r]=t.useState(!1),{position:a,isDragging:m,handleMouseDown:d}=_({boundaryPadding:{right:100,bottom:40},onClick:()=>l(!0)});return t.useEffect(()=>{const c=()=>{l(!0),r(!0)};return window.addEventListener(x.EXPLAIN_NODE,c),()=>window.removeEventListener(x.EXPLAIN_NODE,c)},[]),a?s.jsx(v,{children:s.jsx("div",{ref:n,children:s.jsxs("div",{className:"fixed",style:{zIndex:y,left:a.x,top:a.y,cursor:m?"grabbing":"grab"},children:[s.jsxs("button",{onMouseDown:d,className:"px-2 py-1 border border-gray-300 rounded-md bg-white text-black hover:bg-blue-300 hover:font-bold transition-colors select-none w-40 flex items-center space-x-1",style:{marginLeft:"-40px"},children:[s.jsx("img",{src:D,alt:"ComfyUI-Copilot Logo",className:"h-8 w-8"}),s.jsx("span",{className:"text-[14px] font-medium text-gray-800",children:"ComfyUI-Copilot"})]}),s.jsx(w.Suspense,{fallback:s.jsx("div",{children:"Loading..."}),children:s.jsx(C,{onClose:()=>{l(!1),r(!1)},visible:u,triggerUsage:o,onUsageTriggered:()=>r(!1)})})]})})}):null}const I=Object.freeze(Object.defineProperty({__proto__:null,default:M},Symbol.toStringTag,{value:"Module"}));export{I as A,D as l};
@@ -1 +1 @@
import{j as o}from"./vendor-markdown-Dek94WS0.js";import{W as l,g as h,a as d}from"./message-components-CM_pXuGY.js";import"./vendor-react-V04_Axys.js";function W({content:g,name:k="Assistant",avatar:b,latestInput:w,installedNodes:x,onAddMessage:c}){const m=JSON.parse(g).ext?.find(e=>e.type==="workflow")?.data||[],u=async e=>{if(!e.id){console.error("No workflow id provided");return}l.trackEvent({event_type:"workflow_accept",message_type:"workflow",data:{workflow_id:e.id,workflow_name:e.name}});try{const t=await l.getOptimizedWorkflow(e.id,w);if(t.workflow){const n=new Set;for(const s of t.workflow.nodes)n.add(s.type);const r=Array.from(n).filter(s=>!x.includes(s));if(console.log("[WorkflowOption] Missing node types:",r),r.length>0)try{console.log("[WorkflowOption] Fetching info for missing nodes");const s=await l.batchGetNodeInfo(r);console.log("[WorkflowOption] Received node infos:",s);const p={text:"",ext:[{type:"node_install_guide",data:s.map(a=>({name:a.name,repository_url:a.github_url}))}]},i={id:h(),role:"ai",content:JSON.stringify(p),format:"markdown",name:"Assistant",metadata:{pendingWorkflow:t.workflow,optimizedParams:t.optimized_params}};c?.(i);return}catch(s){console.error("[WorkflowOption] Error fetching node info:",s),alert("Error checking required nodes. Please try again.");return}v(t.workflow,t.optimized_params)}}catch(t){console.error("Failed to optimize workflow:",t)}},v=(e,t)=>{d.loadGraphData(e);for(const[r,s,p,i,a]of t){const y=d.graph._nodes_by_id[r].widgets;for(const f of y)f.name===i&&(f.value=a)}d.graph.setDirtyCanvas(!1,!0);const n={id:h(),role:"tool",content:JSON.stringify({text:"The workflow has been successfully loaded to the canvas",ext:[]}),format:"markdown",name:"Assistant"};c?.(n)};return o.jsx("div",{className:"space-y-3",children:m.length>0&&o.jsx("div",{className:"flex flex-col space-y-4",children:m.map((e,t)=>o.jsxs("div",{className:"flex items-center gap-4 p-4 rounded-lg border border-gray-200 hover:bg-gray-50",children:[e.image&&o.jsx("img",{src:e.image,alt:e.name,className:"w-14 h-14 object-cover rounded-lg",onError:n=>{const r=n.target;r.onerror=null,r.src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56' fill='none'%3E%3Crect width='56' height='56' fill='%23F3F4F6'/%3E%3Cpath d='M28 28C30.2091 28 32 26.2091 32 24C32 21.7909 30.2091 20 28 20C25.7909 20 24 21.7909 24 24C24 26.2091 25.7909 28 28 28Z' fill='%239CA3AF'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M18.7253 37.6307C19.8278 35.1533 22.6897 33.6 26 33.6H30C33.3103 33.6 36.1722 35.1533 37.2747 37.6307C37.6419 38.4561 37.0611 39.2 36.1694 39.2H19.8306C18.9389 39.2 18.3581 38.4561 18.7253 37.6307Z' fill='%239CA3AF'/%3E%3C/svg%3E"}}),o.jsxs("div",{className:"flex-1 break-words flex flex-col h-[4.5rem] justify-between",children:[o.jsx("div",{children:o.jsx("h3",{className:"font-medium text-sm line-clamp-2 h-10 overflow-hidden",children:e.name})}),o.jsxs("div",{className:"flex justify-between items-center mt-1",children:[e.description&&o.jsxs("div",{className:"relative group",children:[o.jsx("div",{className:"w-5 h-5 flex items-center justify-center text-gray-500 cursor-help",children:o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9 5.25h.008v.008H12v-.008z"})})}),o.jsx("div",{className:"absolute bottom-full left-0 mb-2 hidden group-hover:block",children:o.jsx("div",{className:"bg-gray-900 text-white text-xs rounded-md py-2 px-3 min-w-[400px] whitespace-normal break-words",children:e.description})})]}),o.jsx("button",{onClick:()=>u(e),className:"px-3 py-1.5 bg-blue-500 text-white rounded-md hover:bg-blue-600 transition-colors text-xs",children:"Accept"})]})]})]},t))})})}export{W as WorkflowOption};
import{j as o}from"./vendor-markdown-Dek94WS0.js";import{W as l,g as h,a as d}from"./message-components-f2lQ6Vte.js";import"./vendor-react-V04_Axys.js";function W({content:g,name:k="Assistant",avatar:b,latestInput:w,installedNodes:x,onAddMessage:c}){const m=JSON.parse(g).ext?.find(e=>e.type==="workflow")?.data||[],u=async e=>{if(!e.id){console.error("No workflow id provided");return}l.trackEvent({event_type:"workflow_accept",message_type:"workflow",data:{workflow_id:e.id,workflow_name:e.name}});try{const t=await l.getOptimizedWorkflow(e.id,w);if(t.workflow){const n=new Set;for(const s of t.workflow.nodes)n.add(s.type);const r=Array.from(n).filter(s=>!x.includes(s));if(console.log("[WorkflowOption] Missing node types:",r),r.length>0)try{console.log("[WorkflowOption] Fetching info for missing nodes");const s=await l.batchGetNodeInfo(r);console.log("[WorkflowOption] Received node infos:",s);const p={text:"",ext:[{type:"node_install_guide",data:s.map(a=>({name:a.name,repository_url:a.github_url}))}]},i={id:h(),role:"ai",content:JSON.stringify(p),format:"markdown",name:"Assistant",metadata:{pendingWorkflow:t.workflow,optimizedParams:t.optimized_params}};c?.(i);return}catch(s){console.error("[WorkflowOption] Error fetching node info:",s),alert("Error checking required nodes. Please try again.");return}v(t.workflow,t.optimized_params)}}catch(t){console.error("Failed to optimize workflow:",t)}},v=(e,t)=>{d.loadGraphData(e);for(const[r,s,p,i,a]of t){const y=d.graph._nodes_by_id[r].widgets;for(const f of y)f.name===i&&(f.value=a)}d.graph.setDirtyCanvas(!1,!0);const n={id:h(),role:"tool",content:JSON.stringify({text:"The workflow has been successfully loaded to the canvas",ext:[]}),format:"markdown",name:"Assistant"};c?.(n)};return o.jsx("div",{className:"space-y-3",children:m.length>0&&o.jsx("div",{className:"flex flex-col space-y-4",children:m.map((e,t)=>o.jsxs("div",{className:"flex items-center gap-4 p-4 rounded-lg border border-gray-200 hover:bg-gray-50",children:[e.image&&o.jsx("img",{src:e.image,alt:e.name,className:"w-14 h-14 object-cover rounded-lg",onError:n=>{const r=n.target;r.onerror=null,r.src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56' fill='none'%3E%3Crect width='56' height='56' fill='%23F3F4F6'/%3E%3Cpath d='M28 28C30.2091 28 32 26.2091 32 24C32 21.7909 30.2091 20 28 20C25.7909 20 24 21.7909 24 24C24 26.2091 25.7909 28 28 28Z' fill='%239CA3AF'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M18.7253 37.6307C19.8278 35.1533 22.6897 33.6 26 33.6H30C33.3103 33.6 36.1722 35.1533 37.2747 37.6307C37.6419 38.4561 37.0611 39.2 36.1694 39.2H19.8306C18.9389 39.2 18.3581 38.4561 18.7253 37.6307Z' fill='%239CA3AF'/%3E%3C/svg%3E"}}),o.jsxs("div",{className:"flex-1 break-words flex flex-col h-[4.5rem] justify-between",children:[o.jsx("div",{children:o.jsx("h3",{className:"font-medium text-sm line-clamp-2 h-10 overflow-hidden",children:e.name})}),o.jsxs("div",{className:"flex justify-between items-center mt-1",children:[e.description&&o.jsxs("div",{className:"relative group",children:[o.jsx("div",{className:"w-5 h-5 flex items-center justify-center text-gray-500 cursor-help",children:o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9 5.25h.008v.008H12v-.008z"})})}),o.jsx("div",{className:"absolute bottom-full left-0 mb-2 hidden group-hover:block",children:o.jsx("div",{className:"bg-gray-900 text-white text-xs rounded-md py-2 px-3 min-w-[400px] whitespace-normal break-words",children:e.description})})]}),o.jsx("button",{onClick:()=>u(e),className:"px-3 py-1.5 bg-blue-500 text-white rounded-md hover:bg-blue-600 transition-colors text-xs",children:"Accept"})]})]})]},t))})})}export{W as WorkflowOption};
+2 -2
View File
@@ -1,2 +1,2 @@
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["copilot_web/App-CC1iCmEI.js","copilot_web/vendor-markdown-Dek94WS0.js","copilot_web/vendor-react-V04_Axys.js","copilot_web/message-components-CM_pXuGY.js"])))=>i.map(i=>d[i]);
import{j as u}from"./vendor-markdown-Dek94WS0.js";import{a as v,R as p}from"./vendor-react-V04_Axys.js";import{w}from"./message-components-CM_pXuGY.js";const R="modulepreload",b=function(e){return"/"+e},m={},P=function(a,s,S){let d=Promise.resolve();if(s&&s.length>0){document.getElementsByTagName("link");const r=document.querySelector("meta[property=csp-nonce]"),t=r?.nonce||r?.getAttribute("nonce");d=Promise.allSettled(s.map(o=>{if(o=b(o),o in m)return;m[o]=!0;const c=o.endsWith(".css"),h=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${o}"]${h}`))return;const n=document.createElement("link");if(n.rel=c?"stylesheet":R,c||(n.as="script"),n.crossOrigin="",n.href=o,t&&n.setAttribute("nonce",t),document.head.appendChild(n),c)return new Promise((y,E)=>{n.addEventListener("load",y),n.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${o}`)))})}))}function l(r){const t=new Event("vite:preloadError",{cancelable:!0});if(t.payload=r,window.dispatchEvent(t),!t.defaultPrevented)throw r}return d.then(r=>{for(const t of r||[])t.status==="rejected"&&l(t.reason);return a().catch(l)})};var i={},f=v;i.createRoot=f.createRoot,i.hydrateRoot=f.hydrateRoot;const _=p.lazy(()=>P(async()=>{const{default:e}=await import("./App-CC1iCmEI.js").then(a=>a.A);return{default:e}},__vite__mapDeps([0,1,2,3])).then(({default:e})=>({default:e})));function A(){return new Promise(e=>{if(document.body)return e(document.body);document.addEventListener("DOMContentLoaded",()=>{e(document.body)})})}A().then(()=>w()).then(()=>{const e=document.createElement("div");e.id="comfyui-copilot-plugin",document.body.append(e),i.createRoot(e).render(u.jsx(p.StrictMode,{children:u.jsx(_,{})}))});export{P as _};
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["copilot_web/App-Bjdsi6pR.js","copilot_web/vendor-markdown-Dek94WS0.js","copilot_web/vendor-react-V04_Axys.js","copilot_web/message-components-f2lQ6Vte.js"])))=>i.map(i=>d[i]);
import{j as u}from"./vendor-markdown-Dek94WS0.js";import{a as v,R as p}from"./vendor-react-V04_Axys.js";import{w}from"./message-components-f2lQ6Vte.js";const R="modulepreload",b=function(e){return"/"+e},m={},P=function(a,s,S){let d=Promise.resolve();if(s&&s.length>0){document.getElementsByTagName("link");const r=document.querySelector("meta[property=csp-nonce]"),t=r?.nonce||r?.getAttribute("nonce");d=Promise.allSettled(s.map(o=>{if(o=b(o),o in m)return;m[o]=!0;const c=o.endsWith(".css"),h=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${o}"]${h}`))return;const n=document.createElement("link");if(n.rel=c?"stylesheet":R,c||(n.as="script"),n.crossOrigin="",n.href=o,t&&n.setAttribute("nonce",t),document.head.appendChild(n),c)return new Promise((y,E)=>{n.addEventListener("load",y),n.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${o}`)))})}))}function l(r){const t=new Event("vite:preloadError",{cancelable:!0});if(t.payload=r,window.dispatchEvent(t),!t.defaultPrevented)throw r}return d.then(r=>{for(const t of r||[])t.status==="rejected"&&l(t.reason);return a().catch(l)})};var i={},f=v;i.createRoot=f.createRoot,i.hydrateRoot=f.hydrateRoot;const _=p.lazy(()=>P(async()=>{const{default:e}=await import("./App-Bjdsi6pR.js").then(a=>a.A);return{default:e}},__vite__mapDeps([0,1,2,3])).then(({default:e})=>({default:e})));function A(){return new Promise(e=>{if(document.body)return e(document.body);document.addEventListener("DOMContentLoaded",()=>{e(document.body)})})}A().then(()=>w()).then(()=>{const e=document.createElement("div");e.id="comfyui-copilot-plugin",document.body.append(e),i.createRoot(e).render(u.jsx(p.StrictMode,{children:u.jsx(_,{})}))});export{P as _};
@@ -37,7 +37,7 @@ If you don't have an API key, please email us at ComfyUI-Copilot@service.alibaba
prose-li:text-xs
prose-code:text-xs
prose-pre:text-xs
`,components:{p:({children:c})=>O.jsx("p",{className:"!my-0.5 leading-relaxed text-xs",children:c}),h1:({children:c})=>O.jsx("h1",{className:"text-base font-semibold !my-1",children:c}),h2:({children:c})=>O.jsx("h2",{className:"text-sm font-semibold !my-1",children:c}),h3:({children:c})=>O.jsx("h3",{className:"text-xs font-semibold !my-1",children:c}),h4:({children:c})=>O.jsx("h4",{className:"text-xs font-semibold !my-1",children:c}),table:({children:c})=>O.jsx("table",{className:"border-solid border border-[#979797] w-[100%] text-xs",children:c}),th:({children:c})=>O.jsx("th",{className:"border-solid bg-[#E5E7ED] dark:bg-[#FFFFFF] dark:text-[#000000] border border-[#979797] text-center pt-2 text-xs",children:c}),td:({children:c})=>{if(Array.isArray(c)&&c?.length>0){const f=[],v=c.length;for(let p=0;p<v;p++)c[p]==="<br>"?f.push(O.jsx("br",{})):f.push(c[p]);c=f}return O.jsx("td",{className:"border-solid border border-[#979797] text-center text-xs",children:c})},code:({children:c})=>{const[f,v]=We.useState(!1),p=async()=>{try{await navigator.clipboard.writeText(c),v(!0),setTimeout(()=>v(!1),2e3)}catch(g){console.error("Failed to copy text:",g)}};return O.jsxs("span",{className:"relative group inline-flex items-center",children:[O.jsx("code",{className:"text-xs bg-gray-100 text-gray-800 rounded px-1",children:c}),O.jsx("button",{onClick:p,className:"absolute top-0 right-0 bg-gray-200 rounded p-1 opacity-0 group-hover:opacity-100 transition-opacity hover:bg-gray-300 z-10","aria-label":"Copy code",children:f?O.jsx("svg",{className:"w-3 h-3",fill:"currentColor",viewBox:"0 0 20 20",children:O.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}):O.jsxs("svg",{className:"w-3 h-3",fill:"currentColor",viewBox:"0 0 20 20",children:[O.jsx("path",{d:"M8 2a1 1 0 000 2h2a1 1 0 100-2H8z"}),O.jsx("path",{d:"M3 5a2 2 0 012-2 3 3 0 003 3h2a3 3 0 003-3 2 2 0 012 2v6h-4.586l1.293-1.293a1 1 0 00-1.414-1.414l-3 3a1 1 0 000 1.414l3 3a1 1 0 001.414-1.414L10.414 13H15v3a2 2 0 01-2 2H5a2 2 0 01-2-2V5z"})]})})]})},pre:({children:c})=>O.jsx("pre",{className:"text-xs bg-gray-100 text-gray-800 rounded p-2 overflow-x-auto",children:c}),img:({node:c,...f})=>O.jsx("div",{className:"w-1/2 mx-auto",children:O.jsx("img",{...f,loading:"lazy",className:"w-full h-auto block",onError:v=>{console.warn("Image failed to load:",f.src,"Error:",v),v.currentTarget.style.opacity="0"}})}),a:({href:c,children:f})=>O.jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer",onClick:()=>{Li.trackEvent({event_type:"markdown_link_click",message_type:"markdown",data:{link_url:c,link_text:f}})},children:f})},children:h}),l=()=>{try{const h=JSON.parse(i),d=h.ext?.find(c=>c.type==="guides")?.data||[];if(o?.intent){const c=o.intent;if(c==="node_explain")return O.jsx(MI,{content:u(h.text||"")});if(c==="node_params")return O.jsx(BI,{content:u(h.text||"")})}return O.jsxs("div",{className:"space-y-3",children:[t==="markdown"&&h.text?O.jsx("div",{ref:s,children:u(h.text)}):h.text?O.jsx("p",{className:"whitespace-pre-wrap text-left",children:h.text}):null,d.length>0&&O.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:d.map((c,f)=>O.jsx("button",{className:"px-3 py-1.5 bg-white text-gray-700 rounded-md hover:bg-gray-50 transition-colors text-[12px] w-[calc(50%-0.25rem)]",onClick:()=>n?.(c),children:c},f))}),a]})}catch{return O.jsx("p",{className:"whitespace-pre-wrap text-left",children:i})}};return O.jsx(q$,{name:r,children:O.jsx("div",{className:"w-full rounded-lg bg-gray-50 p-4 text-gray-700 text-sm break-words overflow-hidden",children:l()})})}const FI=LiteGraph;function Y$(i,r={}){const e=FI.createNode(i,"",r);if(!r.pos){const t=Mt.canvas.canvas.getBoundingClientRect(),n=t.width/2/Mt.canvas.ds.scale+-Mt.canvas.ds.offset[0]/Mt.canvas.ds.scale,a=t.height/2/Mt.canvas.ds.scale+-Mt.canvas.ds.offset[1]/Mt.canvas.ds.scale;e.pos=[n-e.size[0]/2,a-e.size[1]/2]}return Mt.graph.add(e),e}function jI({content:i,name:r="Assistant",avatar:e,installedNodes:t}){const n=JSON.parse(i),[a,o]=We.useState(null),s=n.ext?.find(c=>c.type==="node")?.data||[],u=c=>t.some(f=>f===c),l=s.filter(c=>u(c.name)),h=s.filter(c=>!u(c.name)),d=c=>c>=1e4?`${(c/1e4).toFixed(1)}w`:c>=1e3?`${(c/1e3).toFixed(1)}k`:c.toString();return O.jsxs("div",{className:"rounded-lg bg-green-50 p-3 text-gray-700 text-xs break-words overflow-visible",children:[l.length>0&&O.jsxs("div",{className:"space-y-3",children:[O.jsx("p",{className:"text-xs font-medium",children:"Installed nodes:"}),O.jsx("div",{className:"grid grid-cols-2 gap-3",children:l.map(c=>O.jsxs("div",{className:`w-full p-3 bg-white rounded-lg border border-gray-200
`,components:{p:({children:c})=>O.jsx("p",{className:"!my-0.5 leading-relaxed text-xs",children:c}),h1:({children:c})=>O.jsx("h1",{className:"text-base font-semibold !my-1",children:c}),h2:({children:c})=>O.jsx("h2",{className:"text-sm font-semibold !my-1",children:c}),h3:({children:c})=>O.jsx("h3",{className:"text-xs font-semibold !my-1",children:c}),h4:({children:c})=>O.jsx("h4",{className:"text-xs font-semibold !my-1",children:c}),table:({children:c})=>O.jsx("table",{className:"border-solid border border-[#979797] w-[100%] text-xs",children:c}),th:({children:c})=>O.jsx("th",{className:"border-solid bg-[#E5E7ED] dark:bg-[#FFFFFF] dark:text-[#000000] border border-[#979797] text-center pt-2 text-xs",children:c}),td:({children:c})=>{if(Array.isArray(c)&&c?.length>0){const f=[],v=c.length;for(let p=0;p<v;p++)c[p]==="<br>"?f.push(O.jsx("br",{})):f.push(c[p]);c=f}return O.jsx("td",{className:"border-solid border border-[#979797] text-center text-xs",children:c})},code:({children:c})=>{const[f,v]=We.useState(!1),p=async()=>{try{await navigator.clipboard.writeText(c),v(!0),setTimeout(()=>v(!1),2e3)}catch(g){console.error("Failed to copy text:",g)}};return O.jsxs("span",{className:"relative group inline-flex items-center",children:[O.jsx("code",{className:"text-xs bg-gray-100 text-gray-800 rounded px-1",children:c}),O.jsx("button",{onClick:p,className:"absolute top-0 right-0 bg-gray-200 rounded p-1 opacity-0 group-hover:opacity-100 transition-opacity hover:bg-gray-300 z-10","aria-label":"Copy code",children:f?O.jsx("svg",{className:"w-3 h-3",fill:"currentColor",viewBox:"0 0 20 20",children:O.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}):O.jsxs("svg",{className:"w-3 h-3",fill:"currentColor",viewBox:"0 0 20 20",children:[O.jsx("path",{d:"M8 2a1 1 0 000 2h2a1 1 0 100-2H8z"}),O.jsx("path",{d:"M3 5a2 2 0 012-2 3 3 0 003 3h2a3 3 0 003-3 2 2 0 012 2v6h-4.586l1.293-1.293a1 1 0 00-1.414-1.414l-3 3a1 1 0 000 1.414l3 3a1 1 0 001.414-1.414L10.414 13H15v3a2 2 0 01-2 2H5a2 2 0 01-2-2V5z"})]})})]})},pre:({children:c})=>O.jsx("pre",{className:"text-xs bg-gray-100 text-gray-800 rounded p-2 overflow-x-auto",children:c}),img:({node:c,...f})=>O.jsx("div",{className:"w-1/2 mx-auto",children:O.jsx("img",{...f,loading:"lazy",className:"w-full h-auto block",onError:v=>{console.warn("Image failed to load:",f.src,"Error:",v),v.currentTarget.style.opacity="0"}})}),a:({href:c,children:f})=>{let v="markdown";try{v=JSON.parse(i).ext?.[0]?.type||"markdown"}catch(p){console.error("Error parsing content:",p)}return O.jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer",onClick:()=>{Li.trackEvent({event_type:"markdown_link_click",message_type:v,data:{link_url:c,link_text:f}})},children:f})}},children:h}),l=()=>{try{const h=JSON.parse(i),d=h.ext?.find(c=>c.type==="guides")?.data||[];if(o?.intent){const c=o.intent;if(c==="node_explain")return O.jsx(MI,{content:u(h.text||"")});if(c==="node_params")return O.jsx(BI,{content:u(h.text||"")})}return O.jsxs("div",{className:"space-y-3",children:[t==="markdown"&&h.text?O.jsx("div",{ref:s,children:u(h.text)}):h.text?O.jsx("p",{className:"whitespace-pre-wrap text-left",children:h.text}):null,d.length>0&&O.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:d.map((c,f)=>O.jsx("button",{className:"px-3 py-1.5 bg-white text-gray-700 rounded-md hover:bg-gray-50 transition-colors text-[12px] w-[calc(50%-0.25rem)]",onClick:()=>n?.(c),children:c},f))}),a]})}catch{return O.jsx("p",{className:"whitespace-pre-wrap text-left",children:i})}};return O.jsx(q$,{name:r,children:O.jsx("div",{className:"w-full rounded-lg bg-gray-50 p-4 text-gray-700 text-sm break-words overflow-hidden",children:l()})})}const FI=LiteGraph;function Y$(i,r={}){const e=FI.createNode(i,"",r);if(!r.pos){const t=Mt.canvas.canvas.getBoundingClientRect(),n=t.width/2/Mt.canvas.ds.scale+-Mt.canvas.ds.offset[0]/Mt.canvas.ds.scale,a=t.height/2/Mt.canvas.ds.scale+-Mt.canvas.ds.offset[1]/Mt.canvas.ds.scale;e.pos=[n-e.size[0]/2,a-e.size[1]/2]}return Mt.graph.add(e),e}function jI({content:i,name:r="Assistant",avatar:e,installedNodes:t}){const n=JSON.parse(i),[a,o]=We.useState(null),s=n.ext?.find(c=>c.type==="node")?.data||[],u=c=>t.some(f=>f===c),l=s.filter(c=>u(c.name)),h=s.filter(c=>!u(c.name)),d=c=>c>=1e4?`${(c/1e4).toFixed(1)}w`:c>=1e3?`${(c/1e3).toFixed(1)}k`:c.toString();return O.jsxs("div",{className:"rounded-lg bg-green-50 p-3 text-gray-700 text-xs break-words overflow-visible",children:[l.length>0&&O.jsxs("div",{className:"space-y-3",children:[O.jsx("p",{className:"text-xs font-medium",children:"Installed nodes:"}),O.jsx("div",{className:"grid grid-cols-2 gap-3",children:l.map(c=>O.jsxs("div",{className:`w-full p-3 bg-white rounded-lg border border-gray-200
hover:shadow-sm transition-all duration-200 relative group`,onMouseEnter:()=>o(c.name),onMouseLeave:()=>o(null),children:[O.jsx("h3",{className:"text-[12px] font-medium text-gray-800 mb-4",children:c.name}),O.jsxs("div",{className:"flex items-center justify-between text-[11px]",children:[O.jsxs("div",{className:"flex items-center gap-1 text-gray-600",children:[O.jsx("svg",{className:"w-3.5 h-3.5",fill:"currentColor",viewBox:"0 0 24 24",children:O.jsx("path",{d:"M12 .25a.75.75 0 0 1 .673.418l3.058 6.197 6.839.994a.75.75 0 0 1 .415 1.279l-4.948 4.823 1.168 6.811a.75.75 0 0 1-1.088.791L12 18.347l-6.117 3.216a.75.75 0 0 1-1.088-.79l1.168-6.812-4.948-4.823a.75.75 0 0 1 .416-1.28l6.838-.993L11.327.668A.75.75 0 0 1 12 .25z"})}),O.jsx("span",{children:d(c.github_stars||0)})]}),O.jsxs("button",{className:`px-2 py-1 bg-blue-500 text-white rounded-md
hover:bg-blue-600 transition-colors text-[10px] flex items-center gap-1`,onClick:()=>{const f=Y$(c.name);f&&(f.connect(c.from_index,f,c.to_index),Li.trackEvent({event_type:"node_add_to_canvas",message_type:"node",data:{node_name:c.name}}))},children:[O.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:O.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),"Add to Canvas"]})]}),a===c.name&&c.description&&O.jsxs("div",{className:`fixed -translate-y-full z-[9999] w-64 p-2
bg-gray-800 text-white text-xs rounded-md shadow-lg mb-2`,style:{left:"calc(var(--mouse-x, 0) + 16px)",top:"calc(var(--mouse-y, 0) - 8px)"},children:[c.description,O.jsx("div",{className:`absolute -bottom-1 left-1/2 -translate-x-1/2
@@ -1,5 +1,5 @@
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["copilot_web/WorkflowOption-mnIyOJxP.js","copilot_web/vendor-markdown-Dek94WS0.js","copilot_web/vendor-react-V04_Axys.js","copilot_web/message-components-CM_pXuGY.js"])))=>i.map(i=>d[i]);
import{j as h,r as vg,b as xg}from"./vendor-markdown-Dek94WS0.js";import{r as S,R as st,c as Ct}from"./vendor-react-V04_Axys.js";import{f as mg,v as yg,a as sn,B as wg,U as bg,A as yr,b as Ag,g as Je,c as Sg,u as Oo,M as Eg,W as Lt}from"./message-components-CM_pXuGY.js";import{l as Ig}from"./App-CC1iCmEI.js";import{_ as Sr}from"./input.js";/**
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["copilot_web/WorkflowOption-BZbpc0xc.js","copilot_web/vendor-markdown-Dek94WS0.js","copilot_web/vendor-react-V04_Axys.js","copilot_web/message-components-f2lQ6Vte.js"])))=>i.map(i=>d[i]);
import{j as h,r as vg,b as xg}from"./vendor-markdown-Dek94WS0.js";import{r as S,R as st,c as Ct}from"./vendor-react-V04_Axys.js";import{f as mg,v as yg,a as sn,B as wg,U as bg,A as yr,b as Ag,g as Je,c as Sg,u as Oo,M as Eg,W as Lt}from"./message-components-f2lQ6Vte.js";import{l as Ig}from"./App-Bjdsi6pR.js";import{_ as Sr}from"./input.js";/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
@@ -101,7 +101,7 @@ ${U.join(`
hover:bg-gray-50`,children:"Close"})})]})})]})}function Hg(){const y=Object.values(sn.canvas.selected_nodes)[0],L=new Set;function o(W,J){if(!(!W||J>=1)&&W.inputs)for(const N of Object.values(W.inputs)){const O=N.link;if(O&&sn.graph.links[O]){const Q=sn.graph.links[O].origin_id,x=sn.graph._nodes_by_id[Q];x&&(L.add(x.type),o(x,J+1))}}}return y?(o(y,0),[{type:"upstream_node_types",data:Array.from(L)}]):null}function $g({nodeInfo:y,onSendWithIntent:L,loading:o,onSendWithContent:W}){return h.jsx("div",{className:"mb-3 p-3 rounded-md bg-gray-50 border border-gray-200",children:h.jsxs("div",{className:"text-sm text-gray-700",children:[h.jsxs("p",{children:["Selected node: ",y.type]}),h.jsxs("div",{className:"flex gap-2 mt-2",children:[h.jsx("button",{className:`px-3 py-1 text-xs rounded-md bg-blue-50
text-blue-700 hover:bg-blue-100`,onClick:()=>W(`Reply in ${navigator.language} language: How does the ${y.type} node work? I need its official usage guide.`),disabled:o,children:"Usage"}),h.jsx("button",{className:`px-3 py-1 text-xs rounded-md bg-green-100
text-green-700 hover:bg-green-200`,onClick:()=>W(`Reply in ${navigator.language} language: Show me the technical specifications for the ${y.type} node's inputs and outputs.`),disabled:o,children:"Parameters"}),h.jsx("button",{className:`px-3 py-1 text-xs rounded-md bg-purple-100
text-purple-700 hover:bg-purple-200`,onClick:()=>L("downstream_subgraph_search",Hg()),disabled:o,children:"Downstream Nodes"})]})]})})}function qg(){return h.jsx(wg,{name:"Assistant",children:h.jsxs("div",{className:"flex items-center space-x-2 p-4 bg-gray-50 rounded-lg",children:[h.jsxs("div",{className:"flex space-x-1",children:[h.jsx("div",{className:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{animationDelay:"0ms"}}),h.jsx("div",{className:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{animationDelay:"150ms"}}),h.jsx("div",{className:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{animationDelay:"300ms"}})]}),h.jsx("span",{className:"text-sm text-gray-500",children:"AI is thinking..."})]})})}const Zg=y=>`https://ui-avatars.com/api/?name=${y||"User"}&background=random`,Yg=S.lazy(()=>Sr(()=>import("./WorkflowOption-mnIyOJxP.js"),__vite__mapDeps([0,1,2,3])).then(y=>({default:y.WorkflowOption}))),Xg=S.lazy(()=>Sr(()=>import("./message-components-CM_pXuGY.js").then(y=>y.N),__vite__mapDeps([3,2,1])).then(y=>({default:y.NodeSearch}))),Jg=S.lazy(()=>Sr(()=>import("./message-components-CM_pXuGY.js").then(y=>y.D),__vite__mapDeps([3,2,1])).then(y=>({default:y.DownstreamSubgraphs}))),Qg=S.lazy(()=>Sr(()=>import("./message-components-CM_pXuGY.js").then(y=>y.d),__vite__mapDeps([3,2,1])).then(y=>({default:y.NodeInstallGuide})));function Vg({messages:y,latestInput:L,onOptionClick:o,installedNodes:W,onAddMessage:J,loading:N}){const O=st.useMemo(()=>x=>{if(x.role==="user")return h.jsx(bg,{content:x.content,trace_id:x.trace_id},x.id);if(x.role==="ai"||x.role==="tool"){const G=Zg(x.role);try{const B=JSON.parse(x.content),K=B.ext?.find(U=>U.type==="workflow"),ae=B.ext?.find(U=>U.type==="node"),le=B.ext?.find(U=>U.type==="downstream_subgraph_search"),me=B.ext?.find(U=>U.type==="node_install_guide");let k=null;if(K)k=h.jsx(S.Suspense,{fallback:h.jsx("div",{children:"Loading..."}),children:h.jsx(Yg,{content:x.content,name:x.name,avatar:G,latestInput:L,installedNodes:W,onAddMessage:J})});else if(ae)k=h.jsx(S.Suspense,{fallback:h.jsx("div",{children:"Loading..."}),children:h.jsx(Xg,{content:x.content,name:x.name,avatar:G,installedNodes:W})});else if(le){const U=h.jsx(S.Suspense,{fallback:h.jsx("div",{children:"Loading..."}),children:h.jsx(Jg,{content:x.content,name:x.name,avatar:G,onAddMessage:J})});if(x.metadata?.intent==="downstream_subgraph_search")return h.jsx(yr,{content:x.content,name:x.name,avatar:G,format:x.format,onOptionClick:o,extComponent:U,metadata:x.metadata},x.id);k=U}else me&&(k=h.jsx(S.Suspense,{fallback:h.jsx("div",{children:"Loading..."}),children:h.jsx(Qg,{content:x.content,onLoadSubgraph:()=>{if(x.metadata?.pendingSubgraph){const U=Object.values(sn.canvas.selected_nodes)[0];if(U){const se=x.metadata.pendingSubgraph,re=se.json.nodes,ge=se.json.links,we=re.find(Z=>Z.id===0),ce=we?.id,H={};ce&&(H[ce]=U),sn.canvas.emitBeforeChange();try{for(const Z of re)if(Z.id!==ce){const be=we?.pos||[0,0],_e=U._pos||[0,0],yn=[Z.pos[0]+_e[0]-be[0],Z.pos[1]+_e[1]-be[1]];H[Z.id]=Ag(Z.type,{pos:yn})}}finally{sn.canvas.emitAfterChange()}for(const Z of ge){const be=H[Z.origin_id],_e=H[Z.target_id];be&&_e&&be.connect(Z.origin_slot,_e,Z.target_slot)}}else alert("Please select a upstream node first before adding a subgraph.")}else if(x.metadata?.pendingWorkflow){const U=x.metadata.pendingWorkflow,se=x.metadata.optimizedParams;sn.loadGraphData(U);for(const[ge,we,ce,H,Z]of se){const be=sn.graph._nodes_by_id[ge].widgets;for(const _e of be)_e.name===H&&(_e.value=Z)}sn.graph.setDirtyCanvas(!1,!0);const re={id:Je(),role:"tool",content:JSON.stringify({text:"The workflow has been successfully loaded to the canvas",ext:[]}),format:"markdown",name:"Assistant"};J?.(re)}}})}));return B.text||k?h.jsx(yr,{content:x.content,name:x.name,avatar:G,format:x.format,onOptionClick:o,extComponent:k,metadata:x.metadata},x.id):k||h.jsx(yr,{content:x.content,name:x.name,avatar:G,format:x.format,onOptionClick:o,metadata:x.metadata},x.id)}catch(B){return console.error("[MessageList] Error parsing message content:",B),console.error("解析JSON失败",x.content),h.jsx(yr,{content:x.content,name:x.name,avatar:G,format:x.format,onOptionClick:o,metadata:x.metadata},x.id)}}return null},[W,o,J,L]),Q=st.useMemo(()=>y?.map(O),[y,O]);return h.jsxs("div",{className:"flex flex-col gap-4 w-full",children:[Q,N&&h.jsx(qg,{})]})}async function ep(){try{return await(await Sg.fetchApi("/object_info",{method:"GET"})).json()}catch(y){throw console.error("Error fetching object info:",y),y}}async function np(){const y=await ep();return Object.keys(y)}var br={exports:{}};/**
text-purple-700 hover:bg-purple-200`,onClick:()=>L("downstream_subgraph_search",Hg()),disabled:o,children:"Downstream Nodes"})]})]})})}function qg(){return h.jsx(wg,{name:"Assistant",children:h.jsxs("div",{className:"flex items-center space-x-2 p-4 bg-gray-50 rounded-lg",children:[h.jsxs("div",{className:"flex space-x-1",children:[h.jsx("div",{className:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{animationDelay:"0ms"}}),h.jsx("div",{className:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{animationDelay:"150ms"}}),h.jsx("div",{className:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{animationDelay:"300ms"}})]}),h.jsx("span",{className:"text-sm text-gray-500",children:"AI is thinking..."})]})})}const Zg=y=>`https://ui-avatars.com/api/?name=${y||"User"}&background=random`,Yg=S.lazy(()=>Sr(()=>import("./WorkflowOption-BZbpc0xc.js"),__vite__mapDeps([0,1,2,3])).then(y=>({default:y.WorkflowOption}))),Xg=S.lazy(()=>Sr(()=>import("./message-components-f2lQ6Vte.js").then(y=>y.N),__vite__mapDeps([3,2,1])).then(y=>({default:y.NodeSearch}))),Jg=S.lazy(()=>Sr(()=>import("./message-components-f2lQ6Vte.js").then(y=>y.D),__vite__mapDeps([3,2,1])).then(y=>({default:y.DownstreamSubgraphs}))),Qg=S.lazy(()=>Sr(()=>import("./message-components-f2lQ6Vte.js").then(y=>y.d),__vite__mapDeps([3,2,1])).then(y=>({default:y.NodeInstallGuide})));function Vg({messages:y,latestInput:L,onOptionClick:o,installedNodes:W,onAddMessage:J,loading:N}){const O=st.useMemo(()=>x=>{if(x.role==="user")return h.jsx(bg,{content:x.content,trace_id:x.trace_id},x.id);if(x.role==="ai"||x.role==="tool"){const G=Zg(x.role);try{const B=JSON.parse(x.content),K=B.ext?.find(U=>U.type==="workflow"),ae=B.ext?.find(U=>U.type==="node"),le=B.ext?.find(U=>U.type==="downstream_subgraph_search"),me=B.ext?.find(U=>U.type==="node_install_guide");let k=null;if(K)k=h.jsx(S.Suspense,{fallback:h.jsx("div",{children:"Loading..."}),children:h.jsx(Yg,{content:x.content,name:x.name,avatar:G,latestInput:L,installedNodes:W,onAddMessage:J})});else if(ae)k=h.jsx(S.Suspense,{fallback:h.jsx("div",{children:"Loading..."}),children:h.jsx(Xg,{content:x.content,name:x.name,avatar:G,installedNodes:W})});else if(le){const U=h.jsx(S.Suspense,{fallback:h.jsx("div",{children:"Loading..."}),children:h.jsx(Jg,{content:x.content,name:x.name,avatar:G,onAddMessage:J})});if(x.metadata?.intent==="downstream_subgraph_search")return h.jsx(yr,{content:x.content,name:x.name,avatar:G,format:x.format,onOptionClick:o,extComponent:U,metadata:x.metadata},x.id);k=U}else me&&(k=h.jsx(S.Suspense,{fallback:h.jsx("div",{children:"Loading..."}),children:h.jsx(Qg,{content:x.content,onLoadSubgraph:()=>{if(x.metadata?.pendingSubgraph){const U=Object.values(sn.canvas.selected_nodes)[0];if(U){const se=x.metadata.pendingSubgraph,re=se.json.nodes,ge=se.json.links,we=re.find(Z=>Z.id===0),ce=we?.id,H={};ce&&(H[ce]=U),sn.canvas.emitBeforeChange();try{for(const Z of re)if(Z.id!==ce){const be=we?.pos||[0,0],_e=U._pos||[0,0],yn=[Z.pos[0]+_e[0]-be[0],Z.pos[1]+_e[1]-be[1]];H[Z.id]=Ag(Z.type,{pos:yn})}}finally{sn.canvas.emitAfterChange()}for(const Z of ge){const be=H[Z.origin_id],_e=H[Z.target_id];be&&_e&&be.connect(Z.origin_slot,_e,Z.target_slot)}}else alert("Please select a upstream node first before adding a subgraph.")}else if(x.metadata?.pendingWorkflow){const U=x.metadata.pendingWorkflow,se=x.metadata.optimizedParams;sn.loadGraphData(U);for(const[ge,we,ce,H,Z]of se){const be=sn.graph._nodes_by_id[ge].widgets;for(const _e of be)_e.name===H&&(_e.value=Z)}sn.graph.setDirtyCanvas(!1,!0);const re={id:Je(),role:"tool",content:JSON.stringify({text:"The workflow has been successfully loaded to the canvas",ext:[]}),format:"markdown",name:"Assistant"};J?.(re)}}})}));return B.text||k?h.jsx(yr,{content:x.content,name:x.name,avatar:G,format:x.format,onOptionClick:o,extComponent:k,metadata:x.metadata},x.id):k||h.jsx(yr,{content:x.content,name:x.name,avatar:G,format:x.format,onOptionClick:o,metadata:x.metadata},x.id)}catch(B){return console.error("[MessageList] Error parsing message content:",B),console.error("解析JSON失败",x.content),h.jsx(yr,{content:x.content,name:x.name,avatar:G,format:x.format,onOptionClick:o,metadata:x.metadata},x.id)}}return null},[W,o,J,L]),Q=st.useMemo(()=>y?.map(O),[y,O]);return h.jsxs("div",{className:"flex flex-col gap-4 w-full",children:[Q,N&&h.jsx(qg,{})]})}async function ep(){try{return await(await Sg.fetchApi("/object_info",{method:"GET"})).json()}catch(y){throw console.error("Error fetching object info:",y),y}}async function np(){const y=await ep();return Object.keys(y)}var br={exports:{}};/**
* @license
* Lodash <https://lodash.com/>
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
@@ -176,6 +176,13 @@ export function AIMessage({ content, name = 'Assistant', avatar, format, onOptio
</div>
),
a: ({ href, children }) => {
let messageType = 'markdown';
try {
const response = JSON.parse(content);
messageType = response.ext?.[0]?.type || 'markdown';
} catch (e) {
console.error('Error parsing content:', e);
}
return (
<a
href={href}
@@ -184,7 +191,7 @@ export function AIMessage({ content, name = 'Assistant', avatar, format, onOptio
onClick={() => {
WorkflowChatAPI.trackEvent({
event_type: 'markdown_link_click',
message_type: 'markdown',
message_type: messageType,
data: {
link_url: href,
link_text: children