PageSourceSearch

https://www.specifeye.ai/assets/AgentContainerSideBySide-C6gKtp6m.js

js specifeye.ai collected 2026-10-05 08:49:31 UTC 34,220 bytes, 56 lines download raw bytes

1import{r as s,I as He,p as qe,a as he,j as e,e as Ge,c as xe,J as Oe,S as Xe,K as Ve,B as je,T as Ke,H as Qe,F as Ye,a7 as Ze,a8 as et,a9 as tt}from"./index-BW3EAEBQ.js";import{p as Be,h as st,F as _e,A as rt,R as at,D as nt,T as ot,P as it,C as lt}from"./ToolCallGroup-8Zq2RYxK.js";import{L as De}from"./Logo-CcHCLqMW.js";import{M as ct}from"./Modal-BUorrtTv.js";import{m as ze,X as ft}from"./index-HY-JQ2cX.js";import{B as Ee}from"./Button-BPUlKjhg.js";import{T as X}from"./index-D0d1YD8-.js";import{R as $e}from"./EyeOutlined-pRH-NpTz.js";import{R as Te}from"./DownloadOutlined-BXMVsMGu.js";import{D as dt}from"./index-D09t_dJQ.js";import"./useBreakpoint-r_S45w4P.js";import"./index-BZHKfVuX.js";import"./context-yiBDwOb1.js";import"./TextArea-Dysqy9nf.js";import"./useMergedValue-B8T115iH.js";var ut={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M955.7 856l-416-720c-6.2-10.7-16.9-16-27.7-16s-21.6 5.3-27.7 16l-416 720C56 877.4 71.4 904 96 904h832c24.6 0 40-26.6 27.7-48zM480 416c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v184c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V416zm32 352a48.01 48.01 0 010-96 48.01 48.01 0 010 96z"}}]},name:"warning",theme:"filled"};function Pe(){return Pe=Object.assign?Object.assign.bind():function(g){for(var S=1;S<arguments.length;S++){var N=arguments[S];for(var P in N)Object.prototype.hasOwnProperty.call(N,P)&&(g[P]=N[P])}return g},Pe.apply(this,arguments)}const mt=(g,S)=>s.createElement(He,Pe({},g,{ref:S,icon:ut})),pt=s.forwardRef(mt);var gt={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M869 487.8L491.2 159.9c-2.9-2.5-6.6-3.9-10.5-3.9h-88.5c-7.4 0-10.8 9.2-5.2 14l350.2 304H152c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h585.1L386.9 854c-5.6 4.9-2.2 14 5.2 14h91.5c1.9 0 3.8-.7 5.2-2L869 536.2a32.07 32.07 0 000-48.4z"}}]},name:"arrow-right",theme:"outlined"};function Me(){return Me=Object.assign?Object.assign.bind():function(g){for(var S=1;S<arguments.length;S++){var N=arguments[S];for(var P in N)Object.prototype.hasOwnProperty.call(N,P)&&(g[P]=N[P])}return g},Me.apply(this,arguments)}const xt=(g,S)=>s.createElement(He,Me({},g,{ref:S,icon:gt})),ht=s.forwardRef(xt),We=g=>e.jsx(ot,{tools:g}),Le=s.forwardRef(function(S,N){const{orgId:P,openNotification:E}=s.useContext(qe),{loadedSessionId:H,createSession:le,basicAgent:Ae,onStreamingChange:Se,onConversationItemsChange:ke}=S,[v,M]=s.useState(null),[ce,F]=s.useState(-1),[R,q]=s.useState(!1),[x,A]=s.useState(null),[fe,O]=s.useState([]),[w,Y]=s.useState(null),[Z,Ce]=s.useState(!1),[ae,T]=s.useState(!1),[de,ne]=s.useState(!1),[Ne,ue]=s.useState(!1),B=s.useRef(null),$=s.useRef(null),ee=s.useRef(!0),k=s.useRef(!0),_=s.useRef(""),te=s.useRef(""),be=s.useRef(null),me=s.useRef(!1),pe=s.useRef(null),l=s.useRef(!1),[G,j]=s.useState(!1),D=s.useCallback(t=>{const f=/^([\s\S]*?)<artifact[^>]*type=["']([^"']+)["'][^>]*title=["']([^"']+)["'][^>]*>([\s\S]*?)<\/artifact>([\s\S]*)$/,a=t.match(f);if(a){const[,n,i,u,b,m]=a;return{hasArtifact:!0,isComplete:!0,type:i,title:u,content:b.trim(),textBefore:n.trim()||void 0,textAfter:m.trim()||void 0}}const o=/^([\s\S]*?)<artifact[^>]*type=["']([^"']+)["'][^>]*title=["']([^"']+)["'][^>]*>([\s\S]*)$/,r=t.match(o);if(r){const[,n,i,u,b]=r;return{hasArtifact:!0,isComplete:!1,type:i,title:u,content:b.trim(),textBefore:n.trim()||void 0,textAfter:void 0}}return{hasArtifact:!1,isComplete:!1,textBefore:t,textAfter:void 0}},[]),y=s.useCallback(t=>/<artifact[^>]*>[\s\S]*?<\/artifact>/.test(t)?t.replace(/<artifact[^>]*>[\s\S]*?<\/artifact>/,`
2
3`).trim().replace(/\n{3,}/g,`
4
5`):/<artifact[^>]*>[\s\S]*$/.test(t)?t.replace(/<artifact[^>]*>[\s\S]*$/,"").trim():t,[]),V=s.useCallback(()=>{if(!B.current)return!0;const{scrollTop:t,scrollHeight:f,clientHeight:a}=B.current;return f-t-a<50},[]),p=s.useCallback(()=>{B.current&&requestAnimationFrame(()=>{B.current&&(B.current.scrollTop=B.current.scrollHeight)})},[]),I=s.useCallback(()=>{$.current&&requestAnimationFrame(()=>{$.current&&($.current.scrollTop=$.current.scrollHeight)})},[]),z=s.useCallback(()=>{if(!$.current)return!0;const{scrollTop:t,scrollHeight:f,clientHeight:a}=$.current;return f-t-a<50},[]),se=s.useCallback(()=>
5{if(!B.current)return;const t=V();ee.current=t},[V]),ge=s.useCallback(()=>{if(!$.current)return;const t=z();k.current=t},[z]),oe=()=>{Ue()},re=s.useCallback(async(t,f=null)=>{const a=f||w;if(a?.artifactContent)try{if(t==="markdown"){const o=new Blob([a.artifactContent],{type:"text/markdown"}),r=URL.createObjectURL(o),n=document.createElement("a");n.href=r,n.download=`${a.artifactTitle}.md`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(r)}else{const o=async L=>{const c=await fetch(he.getEndpointURL(`static/${L}`)),C=new Uint8Array(await c.arrayBuffer());let h="";for(let U=0;U<C.length;U+=8192)h+=String.fromCharCode(...C.subarray(U,U+8192));return btoa(h)},[r,n,i,u,b,m,d,W,K]=await Promise.all([o("SofiaSans-Regular.ttf"),o("SofiaSans-Bold.ttf"),o("SofiaSans-Italic.ttf"),o("SofiaSans-BoldItalic.ttf"),o("NotoEmoji-Regular.ttf"),o("CourierPrime-Regular.ttf"),o("CourierPrime-Bold.ttf"),o("CourierPrime-Italic.ttf"),o("CourierPrime-BoldItalic.ttf")]);Be.addVirtualFileSystem({"SofiaSans-Regular.ttf":r,"SofiaSans-Bold.ttf":n,"SofiaSans-Italic.ttf":i,"SofiaSans-BoldItalic.ttf":u,"NotoEmoji-Regular.ttf":b,"CourierPrime-Regular.ttf":m,"CourierPrime-Bold.ttf":d,"CourierPrime-Italic.ttf":W,"CourierPrime-BoldItalic.ttf":K}),Be.addFonts({SofiaSans:{normal:"SofiaSans-Regular.ttf",bold:"SofiaSans-Bold.ttf",italics:"SofiaSans-Italic.ttf",bolditalics:"SofiaSans-BoldItalic.ttf"},NotoEmoji:{normal:"NotoEmoji-Regular.ttf",bold:"NotoEmoji-Regular.ttf",italics:"NotoEmoji-Regular.ttf",bolditalics:"NotoEmoji-Regular.ttf"},CourierPrime:{normal:"CourierPrime-Regular.ttf",bold:"CourierPrime-Bold.ttf",italics:"CourierPrime-Italic.ttf",bolditalics:"CourierPrime-BoldItalic.ttf"}});const J=new RegExp("\\p{Emoji}\\uFE0F|\\p{Emoji_Presentation}","gu"),Q=L=>Array.isArray(L)?L.flatMap(c=>typeof c=="string"?Re(c):typeof c.text=="string"&&J.test(c.text)?(J.lastIndex=0,[{...c,text:Re(c.text,c)}]):Array.isArray(c.text)?[{...c,text:Q(c.text)}]:c.stack?[{...c,stack:Q(c.stack)}]:c.ul?[{...c,ul:Q(c.ul)}]:c.ol?[{...c,ol:Q(c.ol)}]:c.table?.body?[{...c,table:{...c.table,body:c.table.body.map(C=>Q(C))}}]:[c]):L,Re=(L,c={})=>{const C=[];let h=0;for(const U of L.matchAll(new RegExp("\\p{Emoji}\\uFE0F|\\p{Emoji_Presentation}","gu")))U.index>h&&C.push({...c,text:L.slice(h,U.index)}),C.push({...c,text:U[0],font:"NotoEmoji"}),h=U.index+U[0].length;return h<L.length&&C.push({...c,text:L.slice(h)}),C};ze.use({renderer:{image:()=>""}});const Ie=ze(a.artifactContent),ie=st(Ie,{removeExtraBlanks:!0,defaultStyles:{h1:{fontSize:20,bold:!0,marginBottom:6,marginTop:14},h2:{fontSize:16,bold:!0,marginBottom:5,marginTop:12},h3:{fontSize:13,bold:!0,marginBottom:4,marginTop:10},p:{margin:[0,0,0,8]},li:{margin:[0,2,0,2]},ul:{margin:[0,0,0,8]},ol:{margin:[0,0,0,8]},code:{font:"CourierPrime",fontSize:10},pre:{font:"CourierPrime",fontSize:10}}}),we=Q(Array.isArray(ie)?ie:[ie]);Be.createPdf({content:we,defaultStyle:{font:"SofiaSans",fontSize:11,lineHeight:1.2},pageMargins:[50,50,50,50]}).download(`${a.artifactTitle}.pdf`)}}catch(o){console.error("Error downloading artifact:",o),E("error","Failed to download artifact")}},[w,E]),ye=s.useCallback(async(t=H,f=[])=>{console.log("Requesting session with ID:",t),await he.sendRequest(`sessions/${t}`,{},!0).then(a=>{if(a?.error)console.error("get_sessions failed",a.error);else{console.log("Session data:",a),M(a.session);let o=null;const r=a.messages.flatMap(({id:n,role:i,content:u,toolCalls:b,hasArtifact:m,artifactType:d,artifactTitle:W,artifactContent:K},J)=>{const{type:Q,title:Re,content:Ie,textBefore:ie,textAfter:we}=D(u||""),c=m||Q?{hasArtifact:!0,artifactType:d||Q,artifactTitle:W||Re,artifactContent:K||Ie,messageId:n}:null;c&&(o=c);const C=[];return ie&&ie.trim()&&C.push({type:"message",from:i,text:ie}),c&&C.push({type:"artifactButton",artifact:c}),we&&we.trim()&&C.push({type:"message",from:i,text:we}),b&&b.length>0&&C.push({type:"toolGroup",tools:b.map(h=>({key:h.toolId||h.id,title:h.toolName,status:h.status==="completed"?"success":h.status==="failed"?"error":h.status,content:h.toolOutput?`Input:
6${JSON.stringify(h.toolInput,null,2)}
7
8Output:
9${JSON.stringify(h.toolOutput,null,2)}`:JSON.stringify(h.toolInput,null,2),footer:h.durationMs?`Completed in ${h.durationMs}ms`:void 0,description:h.errorMessage||void 0}))}),C});
9A([...f,...r]),o&&(Y(o),T(!1))}})},[P,H,D]),ve=s.useCallback((t,f=null,a=!1)=>{const o=be.current;if(!(!o||f&&f!==o)&&!(a&&me.current))switch(t.type){case"conversation_title":if(t.title){const r=f||v?.id;r&&M(n=>n?.id===r?{...n,title:t.title}:n)}break;case"text_delta":if(t.text){_.current+=t.text;const{hasArtifact:r,type:n,title:i,content:u,textBefore:b}=D(_.current);r&&(T(m=>m||!0),Y({hasArtifact:!0,artifactType:n,artifactTitle:i,artifactContent:u})),O(m=>(A(d=>{const W=d&&d[d.length-1];if(m.length>0){te.current=t.text;const J={type:"message",from:"assistant",text:y(t.text),resume:a};return[...d||[],{type:"toolGroup",tools:[...m],resume:a},J]}te.current+=t.text;const K=y(te.current);return W&&W.type==="message"&&W.from==="assistant"?[...d?d.slice(0,-1):[],{type:"message",from:"assistant",text:K,resume:a}]:[...d||[],{type:"message",from:"assistant",text:K,resume:a}]}),m.length>0?[]:m))}break;case"tool_call_start":if(t.tool&&t.tool.tool_name){const r=t.tool;O(n=>n.find(u=>u.key===r.tool_id)?n.map(u=>u.key===r.tool_id?{...u,status:r.status==="running"?"pending":u.status,content:r.tool_input?JSON.stringify(r.tool_input,null,2):u.content}:u):[...n||[],{key:r.tool_id,title:r.tool_name,status:"pending",content:r.tool_input?JSON.stringify(r.tool_input,null,2):"Running..."}])}break;case"tool_call_complete":if(t.tool&&t.tool.tool_name){const r=t.tool;O(n=>n.map(i=>i.key===r.tool_id?{...i,status:r.status==="completed"?"success":r.status==="failed"?"error":i.status,footer:r.duration_ms?`Completed in ${r.duration_ms}ms`:void 0,description:r.error||void 0,content:r.tool_output?`Input:
10${JSON.stringify(r.tool_input,null,2)}
11
12Output:
13${JSON.stringify(r.tool_output,null,2)}`:i.content}:i))}break;case"done":if(me.current){T(!1),q(!1);return}me.current=!0,t.artifact&&t.artifact.hasArtifact&&(A(r=>{if(r.find(d=>d.type==="artifactButton"&&d.artifact?.messageId===t.artifact.messageId))return r;const i=r.findLastIndex(d=>d.type==="message"&&d.from==="assistant");if(i===-1)return r;const u=r[i],b=te.current||"",m=D(b);if(m.hasArtifact){const d=[...r.slice(0,i)];return m.textBefore&&d.push({type:"message",from:"assistant",text:m.textBefore}),d.push({type:"artifactButton",artifact:{...t.artifact,artifactContent:m.content||t.artifact.artifactContent}}),m.textAfter&&d.push({type:"message",from:"assistant",text:m.textAfter}),d.push(...r.slice(i+1)),console.log("[done] Restructured items:",d.length,d),d}if(t.artifact.autoReformatted){const d=u.text.match(/^(##?\s+.+)$/m);if(d){const W=d.index,K=u.text.substring(0,W).trim(),J=[...r.slice(0,i)];return K&&J.push({type:"message",from:"assistant",text:K}),J.push({type:"artifactButton",artifact:t.artifact}),J.push(...r.slice(i+1)),J}}return[...r,{type:"artifactButton",artifact:t.artifact}]}),t.artifact.autoReformatted&&E("info","Response formatted as artifact for better readability"),Y(r=>({...r,...t.artifact,artifactContent:t.artifact.artifactContent||r?.artifactContent}))),T(!1),q(!1);break;case"error":if(t.error){let r=`
14[Error: ${t.error}]
15`;A(n=>{const i=n[n.length-1];return i&&i.type==="message"&&i.from==="assistant"?[...n?n.slice(0,-1):[],{type:"message",from:"assistant",text:i.text+r,resume:a}]:[...n||[],{type:"message",from:"assistant",text:r,resume:a}]})}q(!1);break}},[D,y,v,E]),Je=s.useCallback(async t=>{let f=v;if(f)A(a=>[...a||[],{type:"message",from:"user",text:t}]);else{pe.current=t,j(!0);const a=await le();j(!1);const o=Ae?a?.basic:a?.full;if(!o){E("error","Failed to create session");return}M(o),be.current=o.id,f=o}O([]),Y(null),T(!1),_.current="",te.current="",me.current=!1,ee.current=!0,l.current=!0,q(!0);try{const a=await he.sendRequest(`sessions/${f.id}/messages`,{message:t},!0,"POST",!0);if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);const o=a.body.getReader(),r=new TextDecoder;let n="";for(;;){const{done:i,value:u}=await o.read();if(i)break;n+=r.decode(u,{stream:!0});const b=n.split(`
16
17`);n=b.pop()||"";for(const m of b)if(m.startsWith("data: "))try{const d=m.slice(6),W=JSON.parse(d);ve(W,f.id)}catch(d){console.error("Failed to parse SSE message:",d)}}}catch(a){a.name!=="AbortError"&&(console.error("Error during streaming:",a),E("error",`Streaming error: ${a.message}`),A(o=>[...o||[],{type:"message",from:"assistant",text:`[Error: ${a.message}]`}]))}finally{l.current=!1,q(!1),T(!1)}},[v,le,ve,E]),Fe=s.useCallback(async()=>{let t=v;if(!t||l.current)return;const f=await he.sendRequest(`sessions/${t.id}/messages/resume`,{},!0,"POST",!0);if(!(f.status===204||!f.ok)){O([]),Y(null),T(!1),_.current="",te.current="",ee.current=!0,q(!0);try{const a=f.body.getReader(),o=new TextDecoder;let r="";for(;v.id===t.id;){const{done:n,value:i}=await a.read();if(n)break;r+=o.decode(i,{stream:!0});const u=r.split(`
18
19`);r=u.pop()||"";for(const b of u)if(b.startsWith("data: "))try{const m=JSON.parse(b.slice(6));ve(m,t.id,!0)}catch(m){console.error("Failed to parse SSE message:",m)}}}catch(a){a.name!=="AbortError"&&(console.error("Error during streaming:",a),E("error",`Streaming error: ${a.message}`),A(o=>[...o||[],{type:"message",from:"assistant",text:`[Error: ${a.message}]`}]))}finally{q(!1)}}},[v,le,ve,E]),Ue=s.useCallback(async()=>{let t=v;t&&he.sendRequest(`sessions/${t.id}/messages/cancel`,{},!0)},[v]);return s.useEffect(()=>{ee.current&&p()},[x,fe,p]),s.useEffect(()=>{R&&(ee.current=!0)},[R]),s.useEffect(()=>{Z&&k.current&&w?.artifactContent&&I()},[w?.artifactContent,Z,I]),s.useEffect(()=>{Z&&(k.current=!0)}
19,[Z]),s.useEffect(()=>{be.current=v?.id||null},[v]),s.useEffect(()=>{F(0)},[v]),s.useEffect(()=>{H?(pe.current?(A([{type:"message",from:"user",text:pe.current}]),pe.current=null):A(null),F(1)):A([])},[H]),s.useEffect(()=>{ce===1&&(console.log("Loading conversation items for session ID:",H),x===null?ye().then(()=>F(2)):F(2))},[ce,x]),s.useEffect(()=>{ce===2&&(Fe(),F(3))},[ce,Fe]),s.useEffect(()=>{if(x){let t=[],f=[],a=!1;if(x.forEach(o=>{o.resume&&(a=!0),a?f.push(o):t.push(o)}),f.length){let o=!1;f.toReversed().forEach(n=>{if(!t.length)return!0;let i=t[t.length-1];if(i.type==="message"&&n.type==="message"&&i.from===n.from&&i.text===n.text)o=!0;else if(i.type==="toolGroup"&&n.type==="toolGroup"&&i.tools.length===n.tools.length&&i.tools.every(({key:u},b)=>u===n.tools[b].key))o=!0;else if(o)return!0;o&&t.pop()});const r=[...t,...f.map(n=>({...n,resume:void 0}))];r.length<x.length&&A(r)}}},[x]),s.useEffect(()=>console.log("Conversation items updated:",x),[x]),s.useEffect(()=>{Se?.(R)},[R,Se]),s.useEffect(()=>{ke?.(x)},[x,ke]),s.useImperativeHandle(N,()=>({sendMessage:Je,stopStreaming:oe})),e.jsxs(e.Fragment,{children:[x?e.jsx("div",{className:"grow h-full flex flex-col px-2",children:e.jsxs("div",{ref:B,onScroll:se,className:"grow flex flex-col overflow-y-auto overflow-x-hidden p-4",children:[G?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(Ge,{size:"large"})}):!R&&x.length===0?e.jsx("div",{className:"flex flex-col items-center justify-center h-full",children:e.jsx("h1",{className:"text-xl mb-4",children:"Enter your question:"})}):null,x.map((t,f)=>t.type==="message"?e.jsx(_e,{className:"py-1",placement:t.from==="user"?"end":"start",avatar:t.from==="user"?e.jsx(rt,{icon:e.jsx(at,{}),style:{background:"#87d068"}}):e.jsx("div",{className:"flex items-center justify-center shrink-0",style:{width:32,height:32,background:xe.colors.secondary,borderRadius:8},children:e.jsx(Oe,{color:"white",width:"18",height:"14"})}),style:{maxWidth:600},styles:t.from==="user"?{content:{background:"linear-gradient(135deg, #001128 0%, #001d3d 55%, #0d3060 100%)",color:"white"}}:{content:{background:"transparent",boxShadow:"none",padding:"4px 0"}},content:t.text,contentRender:a=>e.jsx(X.Paragraph,{className:"whitespace-pre-wrap mb-0",style:t.from==="user"?{color:"white"}:{},children:a})},`msg-${f}`):t.type==="toolGroup"?e.jsx("div",{className:"pl-10 pr-2 py-1.5",children:We(t.tools)},`tools-${f}`):t.type==="artifactButton"?e.jsx("div",{className:"pl-10 pr-2 py-1.5 min-w-0",children:e.jsx("div",{className:"border border-solid border-black/10 dark:border-white/10 rounded-xl overflow-hidden bg-white dark:bg-dark-white shadow-sm",style:{maxWidth:"100%"},children:e.jsxs("div",{className:"flex items-stretch",children:[e.jsxs("div",{className:"w-16 shrink-0 flex flex-col",style:{background:"#f4f5f7"},children:[e.jsx("div",{className:"h-6",style:{background:xe.colors.primary["dark-blue"]}}),e.jsx("div",{className:"flex-1 p-1.5 flex flex-col gap-1.5",children:[.85,.65,.75,.5].map((a,o)=>e.jsx("div",{className:"h-1 rounded-sm",style:{width:`${a*100}%`,background:"#d1d5db"}},o))}),e.jsx("div",{className:"mx-1.5 mb-1.5 h-1 rounded-sm",style:{background:xe.colors.secondary,width:"45%"}})]}),e.jsx("div",{className:"w-px shrink-0 bg-black/5 dark:bg-white/5"}),e.jsxs("div",{className:"flex-1 min-w-0 p-3 flex flex-col justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-gray-medium dark:text-dark-gray-medium mb-1",style:{letterSpacing:"0.08em",textTransform:"uppercase"},children:"Document"}),e.jsx("p",{className:"font-semibold softer-text text-sm leading-tight mb-1 truncate",children:t.artifact?.artifactTitle||"Artifact"})]}),e.jsxs("div",{className:"flex gap-2 mt-2 flex-wrap",children:[e.jsx(Ee,{variant:"primary",icon:e.jsx($e,{}),onClick:()=>{Y(t.artifact),Ce(!0)},children:"Open"}),e.jsx(Ee,{variant:"secondary",icon:e.jsx(Te,{}),onClick:()=>re("pdf",t.artifact),children:"PDF"})]})]})]})})},`artifact-${f}`):null),fe.length>0&&e.jsx("div",{className:"pl-10 pr-2 py-1.5",children:We(fe)}),R&&(!x.length||x[x.length-1].type==="message"&&x[x.length-1].from!=="assistant")&&e.jsx(_e,{className:"py-1",placement:"start",avatar:e.jsx("div",{className:"flex items-center justify-center shrink-0",style:{width:32,height:32,background:xe.colors.secondary,borderRadius:8},children:e.jsx(Oe,{color:"white",width:"18",height:"14"})}),style:{maxWidth:600},content:"",loading:!0}),w&&w.hasArtifact&&!w.messageId&&e.jsx("div",{className:"pl-10 pr-2 py-1.5 min-w-0",children:e.jsx("div",{className:"border border-solid border-black/10 dark:border-white/10 rounded-xl overflow-hidden bg-white dark:bg-dark-white shadow-sm",style:{maxWidth:"100%"},children:e.jsxs("div",{className:"flex items-stretch",children:[e.jsxs("div",{className:"w-16 shrink-0 flex flex-col",style:{background:"#f4f5f7"},children:[e.jsx("div",{className:"h-6",style:{background:xe.colors.primary["dark-blue"]}}),e.jsx("div",{className:"flex-1 p-1.5 flex flex-col gap-1.5",children:[.85,.65,.75,.5].map((t,f)=>
19e.jsx("div",{className:R?"h-1 rounded-sm skeleton-shimmer":"h-1 rounded-sm",style:{width:`${t*100}%`,...R?{}:{background:"#e5e7eb"}}},f))}),e.jsx("div",{className:"mx-1.5 mb-1.5 h-1 rounded-sm",style:{background:R?xe.colors.secondary:"#d1d5db",width:"45%"}})]}),e.jsx("div",{className:"w-px shrink-0 bg-black/5 dark:bg-white/5"}),e.jsxs("div",{className:"flex-1 min-w-0 p-3 flex flex-col justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-gray-medium dark:text-dark-gray-medium mb-1",style:{letterSpacing:"0.08em",textTransform:"uppercase"},children:"Document"}),e.jsx("p",{className:"font-semibold softer-text text-sm leading-tight mb-1 truncate",children:w.artifactTitle||(R?"Generating…":"Incomplete")}),R?e.jsxs("p",{className:"text-xs flex items-center gap-1.5",style:{color:"#f59e0b"},children:[e.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full animate-pulse",style:{background:"#f59e0b"}}),"Generating…"]}):e.jsx("p",{className:"text-xs softer-text",children:"Generation stopped"})]}),e.jsx("div",{className:"flex gap-2 mt-2",children:e.jsx(Ee,{variant:R?"primary":"secondary",icon:e.jsx($e,{}),onClick:()=>Ce(!0),children:"Preview"})})]})]})})})]})}):e.jsx(Xe,{active:!0,paragraph:{rows:10},className:"w-full m-2"}),e.jsx(nt,{title:w?.artifactTitle||"Artifact",placement:"right",size:720,open:Z,onClose:()=>Ce(!1),styles:{body:{padding:0,height:"100%",overflow:"hidden"}},extra:e.jsxs(Ve,{children:[e.jsx(je,{icon:e.jsx(Te,{}),onClick:()=>{ne(!0),re("markdown").then(()=>ne(!1))},disabled:ae||!w?.messageId,loading:ae||de,children:"Markdown"}),e.jsx(je,{icon:e.jsx(Te,{}),onClick:()=>{ue(!0),re("pdf").then(()=>ue(!1))},disabled:ae||!w?.messageId,loading:ae||Ne,children:"PDF"})]}),children:e.jsx("div",{ref:$,onScroll:ge,style:{height:"100%",overflow:"auto",padding:"24px"},children:e.jsx(ft,{children:w?.artifactContent||""},"artifact-content")},w?.messageId||"streaming")})]})});function $t(){const{darkMode:g}=s.useContext(Ke),{demoSandbox:S}=s.useContext(qe),[N,P,E]=Qe(),[H,le]=s.useState(""),[Ae,Se]=s.useState(!1),[ke,v]=s.useState(!1),[M,ce]=s.useState(null),[F,R]=s.useState(null),[q,x]=s.useState(""),[A,fe]=s.useState(!1),[O,w]=s.useState(!1),[Y,Z]=s.useState(!1),[Ce,ae]=s.useState(!1),T=s.useRef(null),de=s.useRef(null),ne=s.useRef(null),Ne=s.useRef(!1),ue=s.useMemo(()=>{const l=q.match(/```json\s*([\s\S]*?)```/);return l?l[1].trim():null},[q]),B=s.useMemo(()=>{if(!ue)return null;try{return JSON.parse(ue)}catch{return null}},[ue]),$=s.useCallback(async()=>{if(!N)return;const l=[...M||[]].reverse().find(y=>y.type==="message"&&y.from==="user")?.text??"",G=y=>{if(!y?.length)return"";const V=y.reduce((p,I,z)=>I.type==="message"&&I.from==="user"?z:p,-1);return y.slice(V+1).flatMap(p=>p.type==="message"&&p.from==="assistant"?[p.text]:p.type==="artifactButton"&&p.artifact?.artifactContent?[`[Artifact: ${p.artifact.artifactTitle}]
20${p.artifact.artifactContent}`]:[]).join(`
21
22`)},j=G(M),D=G(F);x(""),w(!0),ae(!1),console.log(M),console.log(j),console.log(D);try{const y=await he.sendRequest(`sessions/${N}/comparison`,{question:l,basic_response:j,full_response:D},!0,"POST",!0);if(!y.ok)throw new Error(`HTTP error! status: ${y.status}`);const V=y.body.getReader(),p=new TextDecoder;let I="";for(;;){const{done:z,value:se}=await V.read();if(z)break;I+=p.decode(se,{stream:!0});const ge=I.split(`
23
24`);I=ge.pop()||"";for(const oe of ge)if(oe.startsWith("data: "))try{const re=JSON.parse(oe.slice(6));re.type==="text_delta"&&x(ye=>ye+re.text)}catch{}}}catch(y){console.error("Comparison failed:",y)}finally{w(!1)}},[N,M,F]),ee=s.useCallback(async()=>(ne.current||(fe(!0),ne.current=E().finally(()=>{ne.current=null,fe(!1)})),ne.current),[E]),k=Ae||ke,_=M?.some(l=>l.type==="message"&&l.from==="assistant")&&F?.some(l=>l.type==="message"&&l.from==="assistant");s.useEffect(()=>{if(Ne.current&&!k){const l=M?.some(j=>j.type==="message"&&j.from==="assistant"),G=F?.some(j=>j.type==="message"&&j.from==="assistant");l&&G&&$()}Ne.current=k},[k]);function te(){H.trim()&&(T.current?.sendMessage(H),de.current?.sendMessage(H),le(""))}function be(l){T.current?.sendMessage(l),de.current?.sendMessage(l)}const me=M?.some(l=>l.type==="message")||F?.some(l=>l.type==="message");function pe(){T.current?.stopStreaming(),de.current?.stopStreaming()}return e.jsxs("div",{className:"flex flex-col gap-0 h-full w-full",children:[e.jsx("style",{children:`
25        @keyframes step-slide-in {
26          from { opacity: 0; transform: translateX(20px); }
27          to   { opacity: 1; transform: translateX(0); }
28        }
29        .step-slide { animation: step-slide-in 0.4s ease-out forwards; }
30      `}),e.jsxs("div",{className:"flex flex-row items-center justify-between px-4 py-3",children:[(()=>{const[l,G,j]=k?["streaming","Wait for the agents to respond",!1]:O?["comparing","Wait for the comparison to generate",!1]:B?["ready","Check out how the agents performed",!0]:_?["idle","Run the comparison analysis",!0]:["idle","Enter a query to ask both agents",!1];return e.jsxs("p",{className:"step-slide font-sans-header font-bold !mb-0 flex items-center gap-2",style:{fontSize:"1.1rem"},children:[G,j&&e.jsx(ht,{style:{fontSize:16}})]},l)})(),e.jsx(je,{loading:O,className:"comparison-btn font-sans-header font-bold",style:{background:"linear-gradient(180deg, #2d52a0 0%, #172f68 100%)",border:"none",boxShadow:"inset 0 1px 0 rgba(255,255,255,0.18), 0 2px 6px rgba(0,0,0,0.25)",color:"white",height:40,paddingLeft:8,paddingRight:16,borderRadius:10,opacity:k||!_?.45:1,pointerEvents:k||!_?"none":"auto",cursor:k||!_?"not-allowed":"pointer"},onClick:()=>{Z(!0),ae(!0)},icon:e.jsx("span",{style:{backgroundColor:"#F5A623",borderRadius:7,padding:"2px 5px",fontSize:11,fontWeight:900,color:"white",marginRight:4,letterSpacing:"0.02em"},children:"VS"}),children:"Comparison"})]}),e.jsxs("div",{className:"flex flex-row",children:[e.jsxs("div",{className:"basis-1/2 min-w-0 flex flex-col px-4 py-2 gap-1 bg-black/5 dark:bg-black/50",style:{borderTop:`1px solid ${g?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.08)"}`,borderBottom:`1px solid ${g?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.08)"}`},children:[e.jsxs("div",{className:"flex flex-row items-center justify-between h-10",children:[e.jsxs("div",{className:"flex flex-row items-center gap-2",children:[e.jsx("div",{className:"flex items-center justify-center rounded-lg shrink-0",style:{width:28,height:28,backgroundColor:g?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.07)"},children:e.jsx(Ye,{className:"opacity-60",size:"sm",icon:Ze})}),e.jsx("span",{className:"font-sans-header font-semibold text-sm",children:"Basic Agent"})]}),e.jsx("span",{className:"font-sans text-xs font-semibold uppercase tracking-widest px-2.5 py-1 rounded-full",style:{backgroundColor:g?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.08)",color:g?"rgba(255,255,255,0.4)":"rgba(0,0,0,0.5)"},children:"Generic AI + Connectors"})]}),e.jsx("span",{className:"font-sans text-xs opacity-50",children:"Broad AI with direct data access — Salesforce accounts, Gong call transcripts, and surface-level lookups. No cross-customer pattern detection."})]}),e.jsxs("div",{className:"basis-1/2 min-w-0 flex flex-col px-4 py-2 gap-1 bg-white/50 dark:bg-white/5",style:{borderTop:"3px solid #F5BA16",borderLeft:`1px solid ${g?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.08)"}`,borderBottom:`1px solid ${g?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.08)"}`},children:[e.jsxs("div",{className:"flex flex-row items-center justify-between h-10",children:[e.jsx("div",{className:"scale-75 origin-left shrink-0",children:e.jsx(De,{black:!g})}),e.jsx("span",{className:"font-sans text-xs font-semibold uppercase tracking-widest px-2.5 py-1 rounded-full shrink-0",style:{backgroundColor:"rgba(245,186,22,0.12)",border:"1px solid #F5BA16",color:"#b38600"},children:"Customer Intelligence"})]}),e.jsx("span",{className:"font-sans text-xs opacity-50",children:"Purpose-built customer intelligence powered by GraphRAG — cross-references every customer conversation, Salesforce account, Gong call, and Linear issue to surface patterns generic AI misses entirely."})]})]}),e.jsxs("div",{className:"flex flex-row gap-0 flex-1 min-h-0",children:[e.jsx("div",{className:"basis-1/2 min-w-0 bg-black/5 dark:bg-black/50",children:e.jsx(Le,{ref:T,loadedSessionId:P,createSession:ee,basicAgent:!0,onStreamingChange:Se,onConversationItemsChange:ce})}),e.jsx(dt,{className:"m-0",orientation:"vertical",style:{height:"100%"}}),e.jsx("div",{className:"basis-1/2 min-w-0 bg-white/50 dark:bg-white/5",children:e.jsx(Le,{ref:de,loadedSessionId:N,createSession:ee,basicAgent:!1,onStreamingChange:v,onConversationItemsChange:R})})]}),e.jsxs("div",{className:"px-20 box-border border-t border-black/10 dark:border-[#303030]",children:[S&&!me&&!k&&!A&&e.jsxs(e.Fragment,{children:[e.jsx("style",{children:`
31              .sbs-prompts .ant-prompts-item { text-transform: none !important; font-family: 'Plus Jakarta Sans', sans-serif !important; }
32              .sbs-prompts .ant-prompts-label { text-transform: none !important; font-size: 13px !important; font-weight: 500 !important; }
33            `}),e.jsx(it,{className:"sbs-prompts font-sans pt-4",wrap:!0,items:[{key:"1",label:"Which active accounts are at risk of churning right now, and what are the warning signs?"},{key:"2",label:"How many customers have asked for advanced reporting or custom dashboards, and what's the total ARR at stake?"},{key:"3",label:"Give me everything I should know about Meridian Financial before my call with them tomorrow."},{key:"4",label:"My team wants to deprioritize advanced reporting. Build me the case to keep it."},{key:"5",label:"I just took over the compliance feature area. What do I need to know about Crestview Digital's requests?"}],onItemClick:l=>be(l.data.label)})]}),e.jsx("div",{className:"py-4",children:e.jsx(lt,{loading:k||A,value:H,onChange:l=>le(l),onSubmit:te,onCancel:pe,placeholder:"Ask both agents the same question…"})})]}),e.jsx("style",{children:`
34        .comparison-modal, .comparison-modal * {
35          font-family: 'Plus Jakarta Sans', sans-serif !important;
36        }
37        .comparison-table { font-size: 12px !important; }
38        .comparison-table * { font-size: 12px !important; }
39        @keyframes slide-from-right {
40          from { opacity: 0; transform: translateX(24px); }
41          to   { opacity: 1; transform: translateX(0); }
42        }
43        .headline-slide {
44          opacity: 0;
45          animation: slide-from-right 0.45s ease-out forwards;
46        }
47        @keyframes row-rise {
48          from { opacity: 0; transform: translateY(10px); }
49          to   { opacity: 1; transform: translateY(0); }
50        }
51        .comparison-row {
52          opacity: 0;
53          animation: row-rise 0.6s ease-out forwards;
54        }
55      `}),e.jsx(ct,{isActive:Y,onClose:()=>Z(!1),header:"Comparison Analysis",closeButton:!0,className:"comparison-modal max-w-5xl max-h-[85vh]",children:e.jsxs("div",{className:"font-sans flex flex-col gap-4 overflow-y-auto -m-2",children:[!O&&!B&&e.jsx("div",{className:"p-4",children:e.jsx(je,{type:"primary",onClick:$,disabled:k||!_,children:"Run Analysis"})}),O&&e.jsxs("div",{className:"flex flex-col items-center gap-3 py-12",children:[e.jsx(Ge,{size:"large"}),e.jsx(X.Text,{type:"secondary",children:"Analysing responses..."})]}),!O&&B&&(()=>{const{header:l,table:G,analysis:j}=B,D=p=>p?.startsWith("❌")?"fail":p?.startsWith("⚠️")?"warn":"pass",y=p=>{const[I,z,se]=p==="fail"?[et,"#ff4d4f","rgba(255,77,79,0.12)"]:
55p==="warn"?[pt,"#fa8c16","rgba(250,140,22,0.12)"]:[tt,"#52c41a","rgba(82,196,26,0.12)"];return e.jsx("div",{className:"shrink-0 flex items-center justify-center rounded-md",style:{width:26,height:26,backgroundColor:se},children:e.jsx(I,{style:{color:z,fontSize:13}})})},V=p=>p?.replace(/^(❌|⚠️|✅)\s*/,"")??p;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-8 py-7 flex flex-col gap-3",style:{background:"radial-gradient(ellipse at center, #0c47a1 0%, #052e6e 100%)"},children:[e.jsxs(X.Text,{style:{color:"rgba(255,255,255,0.45)",fontSize:12},children:['"',l.question,'"']}),e.jsxs("div",{className:"leading-tight",children:[e.jsx("p",{className:"headline-slide font-sans-header !mb-0",style:{fontSize:"1.9rem",fontWeight:800,color:"#F5BA16",animationDelay:"150ms"},children:l.headline?.[0]??"SpecifEye beats Claude + connectors."}),e.jsx("p",{className:"headline-slide font-sans-header !mb-0",style:{fontSize:"1.9rem",fontWeight:800,color:"white",animationDelay:"300ms"},children:l.headline?.[1]??"Here's the proof."})]}),e.jsx(X.Text,{style:{color:"rgba(255,255,255,0.6)"},children:l.summary})]}),e.jsxs("div",{className:"comparison-table px-5 flex flex-col",children:[e.jsxs("div",{className:"flex flex-row gap-3 pb-2 border-b border-black/10 dark:border-white/10",children:[e.jsx("div",{className:"w-1/4"}),e.jsx("div",{className:"flex-1 flex flex-row items-center gap-1",children:e.jsx(X.Text,{className:"!text-xs !font-semibold uppercase tracking-wider",children:"Basic Agent"})}),e.jsxs("div",{className:"flex-1 flex flex-row items-center gap-1",children:[e.jsx("div",{className:"scale-60 -mx-7 -mb-px shrink-0",children:e.jsx(De,{black:!g})}),e.jsx(X.Text,{className:"!text-xs !font-semibold uppercase tracking-wider",children:"Agent"})]})]}),G.rows.map(([p,I,z],se)=>{const[ge,oe]=p.split(`
56`),re=D(I),ye=D(z);return e.jsxs("div",{className:"comparison-row flex flex-row gap-3 py-3 items-center border-b border-black/5 dark:border-white/5 last:border-0",style:{animationDelay:`${se*150}ms`},children:[e.jsxs("div",{className:"w-1/4 flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-sans text-sm font-semibold",children:ge}),oe&&e.jsx(X.Text,{type:"secondary",className:"!text-xs",children:oe})]}),e.jsx("div",{className:"flex-1",children:e.jsxs("div",{className:"font-sans rounded-xl px-3 py-2.5 text-sm border border-black/8 dark:border-white/8 bg-black/4 dark:bg-white/4 flex items-center gap-2",children:[y(re),e.jsx("span",{children:V(I)})]})}),e.jsx("div",{className:"flex-1",children:e.jsxs("div",{className:"font-sans rounded-xl px-3 py-2.5 text-sm border flex items-center gap-2",style:{borderColor:"rgba(245,186,22,0.5)",backgroundColor:"rgba(245,186,22,0.07)",boxShadow:"0 0 12px rgba(245,186,22,0.12)"},children:[y(ye),e.jsx("span",{children:V(z)})]})})]},se)})]}),j&&e.jsxs("div",{className:"px-5 flex flex-col gap-2",children:[e.jsxs("div",{className:"flex flex-row items-center gap-2",children:[e.jsx("div",{className:"w-1 h-5 rounded-full shrink-0",style:{backgroundColor:"#F5BA16"}}),e.jsx(X.Text,{strong:!0,children:"The bottom line"})]}),e.jsx(X.Paragraph,{className:"!mb-0 !text-sm",children:j})]}),e.jsxs("div",{className:"mx-5 mb-5 flex flex-row items-center justify-between rounded-xl px-6 py-4 gap-4",style:{background:"#052e6e"},children:[e.jsx(X.Text,{style:{color:"white",fontWeight:500,fontSize:14},children:l.cta??"Purpose-built intelligence. Not generic AI bolted onto your data."}),e.jsx(je,{icon:e.jsx($e,{}),onClick:$,disabled:k||!_,style:{backgroundColor:"#F5BA16",borderColor:"#F5BA16",color:"#1a1a1a",fontWeight:600,whiteSpace:"nowrap"},children:"Re-run Analysis"})]})]})})()]})})]})}export{$t as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.