@glodon-aiot/agent-cli-ui 3.26.0-alpha.18 → 3.26.0-alpha.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/es/index.mjs CHANGED
@@ -6661,7 +6661,7 @@ const Pu = he((M, e) => {
6661
6661
  })]
6662
6662
  })
6663
6663
  });
6664
- }), Ru = "@glodon-aiot/agent-cli-ui", Zu = "3.26.0-alpha.18", _u = "./dist/es/index.mjs", Ju = "./dist/lib/index.js", Bu = "./dist/src/index.d.ts", Hu = {
6664
+ }), Ru = "@glodon-aiot/agent-cli-ui", Zu = "3.26.0-alpha.20", _u = "./dist/es/index.mjs", Ju = "./dist/lib/index.js", Bu = "./dist/src/index.d.ts", Hu = {
6665
6665
  import: "./dist/es/index.mjs",
6666
6666
  require: "./dist/lib/index.js",
6667
6667
  types: "./dist/src/index.d.ts"
@@ -6683,9 +6683,9 @@ const Pu = he((M, e) => {
6683
6683
  commit: "cz"
6684
6684
  }, Ku = {
6685
6685
  "@ant-design/icons": "^5.3.4",
6686
- "@glodon-aiot/apis": "^3.26.0-alpha.18",
6687
- "@glodon-aiot/bot-client-sdk": "^3.26.0-alpha.18",
6688
- "@glodon-aiot/react-components": "^3.26.0-alpha.18",
6686
+ "@glodon-aiot/apis": "^3.26.0-alpha.20",
6687
+ "@glodon-aiot/bot-client-sdk": "^3.26.0-alpha.20",
6688
+ "@glodon-aiot/react-components": "^3.26.0-alpha.20",
6689
6689
  "@matejmazur/react-mathjax": "^0.1.10",
6690
6690
  "@react-pdf-viewer/core": "^3.12.0",
6691
6691
  "@react-pdf-viewer/default-layout": "^3.12.0",
package/dist/lib/index.js CHANGED
@@ -13,7 +13,7 @@
13
13
  ${j}`:j}if(e&&e.length>0){const s=e.filter(Boolean).map(D=>`![](${D})`).join(`
14
14
  `);j=s?`${s}
15
15
  ${j}`:j}}return j},Lu=M=>{const e=Math.floor(M/3600),N=Math.floor(M%3600/60),t=M%60,j=s=>String(s).padStart(2,"0");return`${j(e)}:${j(N)}:${j(t)}`},Au=z.forwardRef((M,e)=>{var Vj,Xj,$j,Kj,qj,Mi,ei,Ni,ti,ji,ii,si,Di,zi,gi,ui;const{application:N,docViewerUrl:t="",currentSession:j,onCreateSession:s,embeddingService:D,setCurrentSession:g,networkStatus:u,setNetworkStatus:n}=M,[I,A]=z.useState([]),[L,r]=z.useState([]),[T,y]=z.useState(!1),[l,C]=z.useState(null),x=z.useRef(0),[m,S]=z.useState(),[f,_]=z.useState(),R=z.useRef(null),MM=z.useRef(!0),Y=z.useRef(!1),eM=z.useRef(!1),{service:v,agentClient:p,depId:F,footer:tM,transform:b,defaultInput:lM,onMessage:bM,onHistoryLoad:dM,beforeMessageSend:rM,bodyStyle:_M,disabled:xM,features:h,popupContainer:O,icon:U,sider:gM,mode:IM,silencedSeconds:hM,localFilesUI:H,localFilesApprovalBridge:CM}=z.useContext(JM),oM=N.type===Z.ApplicationTypes.Agent&&H?p==null?void 0:p.localWorkspace:void 0,[$]=ys(oM),d=xe.useMemoizedFn(()=>(O==null?void 0:O.current)||document.body),[G,V]=z.useState(!1),Q=z.useRef(I),uM=z.useRef(void 0),w=z.useRef(new Set),[B,J]=z.useState(0),[cM,DM]=z.useState([]),[q,EM]=z.useState([]),[RM,UM]=z.useState(0),[KM,uN]=z.useState(!1);z.useEffect(()=>{uN(RM>0)},[RM]);const vM=z.useRef(null),[pM,Ne]=z.useState([]),[qM,le]=z.useState(!1),[IN,AD]=z.useState(!1),[yD,oD]=z.useState(""),[lD,$e]=z.useState(),[Ke,nN]=z.useState({}),TN=z.useRef(null),wj=z.useRef(null),ot=z.useRef(null),[Ej,dD]=z.useState(!1),[CD,OD]=z.useState([]),[xD,UN]=z.useState(!0),[YD,wD]=z.useState(!0),[hj,re]=z.useState(!1),[lt,de]=z.useState(!1),[ED,dt]=z.useState(!1),[ue,cN]=z.useState(typeof(h==null?void 0:h.promptVariables)=="object"?h.promptVariables.default||[]:[]),[hD,QD]=z.useState(()=>{const c=typeof(h==null?void 0:h.knowledges)=="object"&&h.knowledges.default||void 0;if(c){if(Array.isArray(c)&&c.some(P=>Array.isArray(P.fileIds)&&P.fileIds.length===0))throw Error("fileIds cannot be an empty array");if(Mt(c)>be)throw Error(`knowledges and fileIds total count cannot exceed ${be}`)}return c}),[Qj,Re]=z.useState(!1),[Sj,aN]=z.useState(!1),[SD,rN]=z.useState(typeof(h==null?void 0:h.connectNetwork)=="object"&&typeof(h==null?void 0:h.connectNetwork.default)=="boolean"?h.connectNetwork.default:!1),[mj,pN]=z.useState(!1),[mD,fe]=z.useState(!1),[fD,kD]=z.useState(null),[bN,We]=z.useState(!1),[fj,kj]=z.useState(!1),{isSwitchingToExistingSession:Uj,setIsSwitchingToExistingSession:vN}=jj(),qe=z.useRef(null),[Ct,UD]=z.useState("");z.useEffect(()=>{if(!hM)return;let c=Lu(hM);UD(c)},[hM]);const LN=og((Vj=h==null?void 0:h.botMessageBox)==null?void 0:Vj.artifacts),GN=LN.visible,Ot=xe.useMemoizedFn(c=>nM(exports,null,function*(){var W,jM,NM;if(!GN)return;const o=j,E=c||((W=o==null?void 0:o.data)==null?void 0:W.id);if(!o||!E||((jM=o.data)==null?void 0:jM.id)!==E)return;const P=++x.current;try{const mM=yield o.getArtifacts();if(P!==x.current||((NM=j==null?void 0:j.data)==null?void 0:NM.id)!==E)return;r(mM||[])}catch(mM){}}));z.useEffect(()=>{if(kD(j),j===null)fe(!1);else if(j===void 0)fe(!0);else{if(fD===null){if(Uj){fe(!0),vN(!1);return}fe(!1);return}j.ready?fe(!1):fe(!0)}},[j,j==null?void 0:j.ready,Uj]);const[xt,pD]=z.useState(null),pj=z.useRef(null);z.useEffect(()=>{var c;pD((c=O==null?void 0:O.current)!=null?c:null)},[O]),z.useEffect(()=>{l&&y(!0)},[l]),z.useEffect(()=>{var o;const c=(o=j==null?void 0:j.data)==null?void 0:o.id;x.current+=1,r([]),y(!1),C(null),c&&GN&&Ot(c)},[(Xj=j==null?void 0:j.data)==null?void 0:Xj.id,GN]),z.useEffect(()=>{var E,P;j&&(Q.current=[]),A([]),MM.current=!0,Y.current=!1;const c=R.current;if(c&&c.scrollTo({top:0}),!((E=j==null?void 0:j.data)!=null&&E.id))return;if(de(!1),re(!1),(P=j.messages)!=null&&P.length){const jM=[...j.messages.filter(NM=>NM==null?void 0:NM.messageId)].reverse();Q.current=[...jM],A([...jM]),fe(!1)}const o=W=>{var jM;(jM=j==null?void 0:j.data)!=null&&jM.id&&(Q.current=[...W].reverse(),A([...W].reverse()),!W||W.length<10?aN(!1):aN(!0),fe(!1),dM&&dM({applicationId:N.id,sessionId:j.data.id,histories:W}))};return j.addEventListener("history:loaded",o),()=>{Q.current=[],A([]),j==null||j.removeEventListener("history:loaded",o)}},[j]),z.useEffect(()=>{const c=()=>{var o;(o=j==null?void 0:j.data)!=null&&o.id&&(j.promptVariables&&cN(j.promptVariables.sort((E,P)=>E.key.localeCompare(P.key))),j.knowledges&&QD(j.knowledges),n(j.netOpen))};return j==null||j.addEventListener("data:updated",c),()=>{j==null||j.removeEventListener("data:updated",c)}},[j]),z.useEffect(()=>{var o;if(!((o=j==null?void 0:j.data)!=null&&o.id))return;const c=E=>{var P;console.error(E.message,E.cause,"e.case"),a.notification.config({getContainer:()=>(O==null?void 0:O.current)||document.body,prefixCls:"gbot-notification"}),a.notification.error({message:((P=E.cause)==null?void 0:P.message)||E.message}),a.notification.config({getContainer:void 0,prefixCls:"gbot-notification"})};return j.addEventListener("error",c),()=>{j==null||j.removeEventListener("error",c)}},[j]);const bD=()=>{var E;if(!((E=j==null?void 0:j.data)!=null&&E.id)||!(N!=null&&N.id))return;const c=j.data.id,o=I[I.length-1];if(o&&o.isContext){te("success","已开启新话题");return}else j.clear().then(()=>{const P=new _e("",c,Z.IHistoryRole.System);P.isContext=!0,A([P,...I])})};z.useEffect(()=>{N!=null&&N.id&&(v==null||v.getRecommendQues(N.id).then(c=>{Ne(c)}))},[F,N]);const Yt=c=>nM(exports,null,function*(){var Me,aM;if(xM)return te("error","发送功能被禁用"),!1;const o=c||m;if(!(o!=null&&o.trim()))return te("error","请输入你想问的"),!1;if(!(ue==null?void 0:ue.every(WM=>!!(WM!=null&&WM.value)))){if(b!=null&&b.promptVariables)return te("error","变量值不能为空"),!1;console.error("变量值不能为空",ue==null?void 0:ue.map(WM=>!!(WM!=null&&WM.value)))}if(lt)return te("error","正在回复中"),!1;if(G)return te("error","等待初始化"),!1;if(!xD)return te("error","正在解析文件"),!1;if(KM)return te("error","正在上传图片"),!1;DM([]),EM([]);const P=(Me=j==null?void 0:j.data)==null?void 0:Me.id;if(!P)return bN?!1:(We(!0),s==null||s({netOpen:u?Ue.OPEN:Ue.CLOSE}).then(WM=>{var TM,VM;Re(!0),n(!!((TM=WM.data)!=null&&TM.netOpen)),rN(!!((VM=WM.data)!=null&&VM.enableNetOpen)),wt(WM).then(()=>{g==null||g(WM),Re(!1),_(o)})}).catch(WM=>{We(!1)}),!0);if(bN)return!1;We(!0),pN(!0);const W=bt(o,q,Ke[P],(N==null?void 0:N.type)||0);let jM;try{rM?jM=yield rM==null?void 0:rM({applicationId:N.id,sessionId:P,message:{content:W,sessionId:P,role:Z.ChatMessageRole.User,files:Ke[P]}}):jM=!0}catch(WM){jM=!1}if(pN(!1),jM===!1)return We(!1),!1;let NM=o;typeof jM=="object"&&(NM=jM.content||o);const fM=yield(()=>new Promise(WM=>{cN(TM=>(WM(TM),TM))}))();return(yield j.setPromptVariables(fM))?(((aM=Ke[P])==null?void 0:aM.length)>0?yield vD(NM):yield Et(NM),!0):(We(!1),!1)}),wt=c=>new Promise((o,E)=>nM(exports,null,function*(){const jM=(c==null?void 0:c.promptVariables).filter(NM=>NM.type?!((NM.type===Z.PromptVariableType.User||NM.type===void 0)&&NM.key==="query")&&!((NM.type===Z.PromptVariableType.System||NM.type===void 0)&&NM.key==="datetime"):NM.key!=="query").map(NM=>{var fM;const mM=(fM=ue.find(iM=>iM.key===NM.key&&iM.type===NM.type))==null?void 0:fM.value;return NM.value=mM||"",NM});cN(jM.sort((NM,mM)=>NM.key.localeCompare(mM.key))),yield c==null?void 0:c.setPromptVariables(jM).catch(NM=>{console.error(NM),te("error",NM.message)}),o()})),vD=c=>{var W,jM,NM;if(UN(!1),!((W=j==null?void 0:j.data)!=null&&W.id)||!(N!=null&&N.id))return;const o=((jM=j.data)==null?void 0:jM.id)||"";let E=[],P=new Set;return(NM=Ke[o])==null||NM.forEach(mM=>{P.has(mM.id)||(E.push(mM),P.add(mM.id))}),UN(!0),Et(c,E)};z.useEffect(()=>{if(!f||!j)return;const c=f,o=()=>nM(exports,null,function*(){pN(!0);const E=bt(c,q,Ke[j.id],(N==null?void 0:N.type)||0);let P;try{rM?P=yield rM==null?void 0:rM({applicationId:N.id,sessionId:j.id,message:{content:E,sessionId:j.id,role:Z.ChatMessageRole.User,files:Ke[j.id]}}):P=!0}catch(W){P=!1}if(pN(!1),P===!1){We(!1);return}Et(c),_(void 0)});return j.ready?o():j.addEventListener("ready",o,!0),()=>{j==null||j.removeEventListener("ready",o)}},[f,j]);const Et=(c,o)=>nM(exports,null,function*(){var Me,aM,WM;const E=(Me=j==null?void 0:j.data)==null?void 0:Me.id;if(!E)return;de(!0),re(!0);const P=bt(c,q,o,(N==null?void 0:N.type)||0);let W;if(N.type===Z.ApplicationTypes.Agent)W=void 0;else if(N.type===Z.ApplicationTypes.Dialog&&((aM=N.arrange)!=null&&aM.length)&&N.arrange[0].visionOpen){const TM=q&&q.length?q.filter(Boolean):[];W=TM.length?TM:void 0}else W=void 0;const jM=new _e(P,E,Z.IHistoryRole.User,o,W);S(void 0),$e(void 0),Q.current=[jM,...I],A(Q.current),N.id&&bM&&bM({applicationId:N.id,sessionId:E,message:jM});const NM=new _e("",E,Z.IHistoryRole.System);NM.isWaiting=!0,Q.current=[NM,...Q.current],A(Q.current);const mM=(o==null?void 0:o.filter(TM=>!TM.localAttachment).map(TM=>TM.id))||[],fM={stream:pe.configuration.stream,referenceFirst:!1};if(b!=null&&b.promptVariables){const TM=ue==null?void 0:ue.reduce((VM,ke)=>(VM[ke.key]=ke.value,VM),{});fM.formatValues=TM}if(b!=null&&b.knowledges){const TM=hD;fM.knowledges=TM}const iM={text:P,fileIds:mM,files:o,uuid:jM.messageId};W&&W.length>0&&(iM.imageContent=W),j.ready||(yield new Promise(TM=>{j.addEventListener("ready",()=>TM(),!0)})),yield j.send(iM,fM),nN({[E]:[]}),(WM=TN.current)==null||WM.update({keepLocalAttachments:!1}),DM([]),EM([]),We(!1)});z.useEffect(()=>{var fM;const c=(fM=j==null?void 0:j.data)==null?void 0:fM.id;if(!c)return;let o=null,E=null,P="";const W=()=>{o=null,E&&(A([E,...Q.current]),E=null)},jM=()=>{o!==null&&(cancelAnimationFrame(o),o=null,E=null)},NM=iM=>{if(!iM.sessionId||iM.sessionId&&iM.sessionId!==uM.current)return;if(iM.role===Z.IHistoryRole.User){if(Q.current.some(AN=>AN.messageId&&AN.messageId===iM.messageId))return;const VM=new _e(iM.content,c,Z.IHistoryRole.User,iM.files,iM.imageContent);VM.messageId=iM.messageId||VM.messageId,VM.renderKey=VM.messageId;const ke=new _e("",c,Z.IHistoryRole.System);ke.isWaiting=!0,Q.current=Q.current.filter(AN=>!AN.isWaiting),Q.current=[ke,VM,...Q.current],A(Q.current),re(!0),de(!0),N.id&&bM&&bM({applicationId:N.id,sessionId:c,message:VM});return}if(iM.index===-1&&iM.code!==200&&iM.code!==11915&&iM.code!==11916&&(jM(),re(!1),de(!1),Q.current=Q.current.filter(TM=>!TM.isWaiting),A([...Q.current]),Q.current=[...Q.current],iM.content)){a.notification.config({getContainer:()=>(O==null?void 0:O.current)||document.body,prefixCls:"gbot-notification"}),a.notification.error({message:iM.content}),a.notification.config({getContainer:void 0,prefixCls:"gbot-notification"});return}const Me=iM.actions||[],aM=new _e(iM.content,c,Z.IHistoryRole.Robot);aM.reasoningContent=iM.reasoningContent,aM.searchReference=iM.searchReference,aM.thinkingSecs=iM.thinkingSecs,aM.thinkingStatus=iM.thinkingStatus,aM.actions=Me,aM.isLoading=!0,aM.searchingStatus=iM.searchingStatus;const WM=Q.current.some(TM=>TM.isWaiting);if(Q.current=Q.current.filter(TM=>!TM.isWaiting).filter(TM=>!TM.isReplying),WM&&(P=""),aM.renderKey=P||iM.messageId||aM.messageId,P=aM.renderKey,aM.messageId=iM.messageId||aM.renderKey,iM.index===void 0){E=aM,o===null&&(o=requestAnimationFrame(W));return}if(jM(),(iM.code===11915||iM.code===11916)&&(re(!1),de(!1),aM.isLoading=!1,aM.content=iM.code===11916?"尊敬的用户您好,让我们换个话题再聊聊吧。":"请您换个问题问我吧~",aM.isSensitive=!0,A([aM,...Q.current])),iM.index===-2&&(re(!1),de(!1),aM.isLoading=!1,aM.content="回答已中止~",aM.isSuspend=!0,A([aM,...Q.current]),Ot(c)),iM.index===-1&&(re(!1),de(!1),aM.isLoading=!1,aM.reference=iM.reference,A([aM,...Q.current]),iM.code===200&&Ot(c),N.id)){const TM=aM.messageId;w.current.has(TM)||(w.current.add(TM),bM&&bM({applicationId:N.id,sessionId:c,message:aM}))}iM.index===-3&&(re(!1),de(!1),aM.isLoading=!1,aM.reference=iM.reference,aM.relatedQuesion=iM.relatedQuesion,A([aM,...Q.current]))},mM=()=>{j.addEventListener("message:updated",NM)};return j.ready?j.addEventListener("message:updated",NM):j.addEventListener("ready",mM),()=>{jM(),j==null||j.removeEventListener("message:updated",NM),j==null||j.removeEventListener("ready",mM)}},[j]),z.useEffect(()=>{if(!j){V(!1);return}const c=o=>{V(o)};return V(j.frozen),j.addEventListener("frozen",c),()=>{j==null||j.removeEventListener("frozen",c)}},[j]),z.useEffect(()=>{if(!p)return;const c=p.questionContextMaxLength||4e3;J(c)},[p,v]),z.useEffect(()=>{lM&&$e(lM.text)},[lM]);const te=(c,o,E)=>{ie(O,()=>{a.message.open({type:c,content:o,key:E})})},bj=c=>{const o=c.size;return o<=0?(te("error","该文件为空,请重新上传"),!1):o>pt*qN?(te("error",`图片须小于${pt}M`),!1):(DM(E=>E.length>=Be?(te("warning",`图片最多上传${Be}张`),E):[...E,c]),!1)},GD=()=>{var c;return(N.type===Z.ApplicationTypes.Agent&&(b==null?void 0:b.imageUpload)||N.type===Z.ApplicationTypes.Dialog&&((c=N.arrange)==null?void 0:c.length)&&!!N.arrange[0].visionOpen&&(b==null?void 0:b.imageUpload))&&!xM},PD=()=>!!D&&(b==null?void 0:b.fileUpload)&&(N==null?void 0:N.id)&&!xM,vj=c=>{var aM,WM;const o=Array.from(c||[]).filter(Boolean);if(!o.length)return;const E=GD(),P=PD(),W=[],jM=[];let NM=0,mM=0,fM=0;o.forEach(TM=>{var Ii,ni,Ti;const VM=(ni=(Ii=TM.name)==null?void 0:Ii.split(".").pop())==null?void 0:ni.toLowerCase();if(is(TM)){P&&N.type===Z.ApplicationTypes.Agent?jM.push(TM):fM++;return}if(((Ti=TM.type)==null?void 0:Ti.startsWith("image/"))||!!yi(TM.name)){E?W.push(TM):NM++;return}if(ts.includes(TM.type)||["pdf","doc","docx"].includes(VM||"")){P?jM.push(TM):mM++;return}fM++});const iM=[],Me=NM+mM+fM;if(!P&&!E)Me&&iM.push(`当前不支持上传文件/图片,已忽略${Me}个文件`);else if(P&&!E){const TM=NM+fM;if(TM){const VM=N.type===Z.ApplicationTypes.Agent?".doc/.docx/.pdf/.xls/.xlsx/.svg/.dwg/.json":".doc/.docx/.pdf";iM.push(`仅支持上传 ${VM} 文件,已忽略${TM}个其他类型文件`)}}else if(!P&&E){const TM=mM+fM;TM&&iM.push(`仅支持上传图片(.jpg/.jpeg/.png/.bmp),已忽略${TM}个其他类型文件`)}else fM&&iM.push(`存在不支持的文件类型,已忽略${fM}个文件`);if(iM.length&&te("warning",iM.join(";"),"precheck-warn"),W.length){const TM=Math.max(0,Be-cM.length),VM=W.slice(0,TM);VM.forEach(ke=>bj(ke)),W.length>VM.length&&te("warning",`最多上传${Be}张图片`)}jM.length&&((WM=(aM=TN.current)==null?void 0:aM.appendFiles)==null||WM.call(aM,jM))},Gj=c=>{var E;const o=(E=c.clipboardData)==null?void 0:E.files;o&&o.length&&(c.preventDefault(),c.stopPropagation(),vj(o))},Pj=c=>{c.preventDefault()},Rj=c=>{var E;c.preventDefault(),c.stopPropagation();const o=(E=c.dataTransfer)==null?void 0:E.files;o&&o.length&&vj(o)},Wj=()=>nM(exports,null,function*(){var c;return(c=j==null?void 0:j.data)!=null&&c.id?j:(qe.current||(qe.current=new Promise((o,E)=>{Re(!0),s==null||s({netOpen:u?Ue.OPEN:Ue.CLOSE}).then(P=>{var W,jM;g==null||g(P),Re(!1),n(!!((W=P.data)!=null&&W.netOpen)),rN(!!((jM=P.data)!=null&&jM.enableNetOpen)),wt(P),o(P)}).catch(P=>{qe.current=null,E(P)})})),qe.current)}),RD=c=>nM(exports,null,function*(){const o=yield Wj();return WD(o,c)}),WD=(c,o)=>{const E=yi(o.name);return new Promise(P=>{var jM;const W={files:[`${sN.v4()}.${E}`],isv:"minio",knowledgeId:((jM=c.data)==null?void 0:jM.id)||"",type:1};v==null||v.postTicket(W).then(NM=>{v.uploadMinioFile(NM.minio,o).then(()=>{var Me,aM;const mM=(Me=NM.minio.endpoints)==null?void 0:Me[0],fM=NM.minio.bucket,iM=(aM=NM.minio.fileKeys)==null?void 0:aM[0];P(`${NM.minio.useSSL?"https:":location.protocol}//${mM}/${fM}/${iM}`)}).catch(()=>{})}).catch(()=>{})})},ZD=()=>{const c=R.current;!c||!MM.current||c.scrollTo({top:c.scrollHeight})};z.useLayoutEffect(()=>{ZD()},[I]),z.useEffect(()=>{const c=()=>{eM.current=!1;const o=R.current;(!o||o.scrollTop>-80)&&(Y.current=!1)};return window.addEventListener("pointerup",c),()=>window.removeEventListener("pointerup",c)},[]);const Zj=(c,o)=>new Promise(E=>{if(!o.file.url||!(N!=null&&N.id))return E();const P=BM(sM({},o.file),{type:1});v==null||v.postApplicationIdSessionKnowledgeSessionFile(N==null?void 0:N.id,c,P).finally(()=>{var W;(W=TN.current)==null||W.update().finally(E)})}),_D=()=>{var c;(c=j==null?void 0:j.data)!=null&&c.id&&(re(!1),j.suspend())},BD=c=>{const o=R.current;o&&(MM.current=!0,Y.current=!1,dt(!1),setTimeout(()=>{o.scrollTo({top:o.scrollHeight,behavior:c==null?void 0:c.behavior})},c==null?void 0:c.ms))},_j=()=>{Y.current=!0},JD=c=>{var E;const o=(E=c.target)==null?void 0:E.closest(".bottom-right");o instanceof HTMLElement&&o.scrollHeight>o.clientHeight+1||(_j(),requestAnimationFrame(()=>{const P=R.current;Y.current&&P&&P.scrollTop>-80&&(Y.current=!1)}))},FD=c=>{const o=c.currentTarget,{offsetX:E,offsetY:P}=c.nativeEvent;(E>o.clientWidth||P>o.clientHeight)&&(eM.current=!0,_j())},HD=()=>{const c=R.current;if(!c)return;if(!(c.scrollTop<=-80)){MM.current=!0,Y.current=!1,dt(!1);return}(Y.current||eM.current)&&(MM.current=!1,Y.current=!1,dt(!0))},VD=xe.useMemoizedFn(c=>{var o,E;(o=vM.current)==null||o.update(c),(E=vM.current)==null||E.focus()}),XD=xe.useMemoizedFn(c=>{Yt(c)}),$D=xe.useMemoizedFn(()=>{var o;if(!((o=j==null?void 0:j.data)!=null&&o.id))return;Q.current=[...I.slice(1,I.length)],A(Q.current);const c=new _e("",j.data.id,Z.IHistoryRole.System);c.isWaiting=!0,Q.current=[c,...Q.current],A(Q.current),de(!0),re(!0),j.answerAgain()});z.useEffect(()=>{var c,o;uM.current=(c=j==null?void 0:j.data)==null?void 0:c.id,!Qj&&((o=ot.current)==null||o.clear())},[j]);const KD=()=>{var E;if(!((E=j==null?void 0:j.data)!=null&&E.id))return;const o=I[I.length-1].messageTime;j.fetchMessages({endTime:o,pageSize:ki}).then(P=>{const W=P||[];if(!W||!(W!=null&&W.length)){aN(!1);return}W.length<10?aN(!1):aN(!0),A([...I,...W.reverse()])})},qD=c=>nM(exports,null,function*(){var o,E;if(!((o=j==null?void 0:j.data)!=null&&o.id))n(c);else{if(yield j.setNetOpen(c),!((E=j.data)!=null&&E.id))return;n(c)}}),ht=()=>nM(exports,null,function*(){j?j.fetchData().then(c=>{var o;(o=j==null?void 0:j.data)!=null&&o.id&&(n(c.netOpen),rN(c.enableNetOpen))}):(n(typeof(h==null?void 0:h.connectNetwork)=="object"&&typeof(h==null?void 0:h.connectNetwork.default)=="boolean"?h.connectNetwork.default:!1),rN(N.arrange[0].enableNetOpen))});z.useEffect(()=>{ht()},[j]),z.useEffect(()=>{let c=null,o=null;const E=()=>{var iM,Me;if(!R.current)return;const W=document.getElementById("chat-main"),jM=(iM=R.current)==null?void 0:iM.querySelector(".infinite-scroll-component__outerdiv"),NM=(Me=R.current)==null?void 0:Me.querySelector(".infinite-scroll-component");if(!jM||!NM||!W)return;const mM=W.offsetHeight;if(NM.offsetHeight<=mM){if(jM.style.height==="100%")return;jM.style.height="100%"}else{if(jM.style.height==="auto")return;jM.style.height="auto"}},P=()=>{var NM;if(typeof ResizeObserver=="undefined"||!R.current)return;const W=document.getElementById("chat-main"),jM=(NM=R.current)==null?void 0:NM.querySelector(".infinite-scroll-component");!jM||!W||(o=new ResizeObserver(()=>{E()}),o.observe(jM),o.observe(W))};return c=requestAnimationFrame(()=>{E(),P()}),()=>{c!==null&&cancelAnimationFrame(c),o==null||o.disconnect()}},[I]),z.useEffect(()=>{if(j)return;const c=()=>{const P=((p==null?void 0:p.promptVariables)||[]).filter(W=>W.type?!(W.type===Z.PromptVariableType.User&&W.key==="query")&&!(W.type===Z.PromptVariableType.System&&W.key==="datetime")&&W.status===1:W.key!=="query"&&W.status===1).map((W,jM)=>{var mM,fM;let NM="";return typeof(h==null?void 0:h.promptVariables)=="object"&&(NM=((fM=(mM=h.promptVariables.default)==null?void 0:mM.find(iM=>iM.key===W.key&&iM.type===W.type))==null?void 0:fM.value)||""),{id:jM+"",key:W.key,name:W.name,value:NM,type:W.type}});cN([...P].sort((W,jM)=>W.key.localeCompare(jM.key)))};return p!=null&&p.ready?c():p==null||p.addEventListener("ready",c),()=>{p==null||p.removeEventListener("ready",c)}},[j,p,h==null?void 0:h.promptVariables]);const Bj=()=>s==null?void 0:s({netOpen:u?Ue.OPEN:Ue.CLOSE}).then(c=>{var o,E;return g==null||g(c),Re(!1),n(!!((o=c.data)!=null&&o.netOpen)),rN(!!((E=c.data)!=null&&E.enableNetOpen)),wt(c),c}),Jj=!!I.length,Fj=z.useMemo(()=>{var c;return N.arrange&&((c=N.arrange[0])!=null&&c.openingContent)?i.jsx(us,{application:N,history:{role:1,content:N.arrange[0].openingContent,code:200,messageId:"opening-message",sessionId:"",reference:[],searchReference:[],messageTime:XM(Date.now()).format("YYYY-MM-DD HH:mm:ss"),actions:[],isLoading:!1},actions:Jj,markdown:h==null?void 0:h.markdown}):null},[N==null?void 0:N.arrange,Jj]);z.useImperativeHandle(e,()=>({getCurrentInputText:()=>{var c;return(c=vM.current)==null?void 0:c.getCurrentText()},send:c=>nM(exports,null,function*(){if(!(yield Yt(c)))throw new Error("send was blocked")})})),z.useEffect(()=>{var o;const c=(o=j==null?void 0:j.data)==null?void 0:o.id;c&&nN(E=>BM(sM({},E),{[c]:[]}))},[($j=j==null?void 0:j.data)==null?void 0:$j.id]);const Qt=!!oM&&(H==null?void 0:H.picker)!==!1&&!(gM&&IM==="inlay"),Hj=Qt&&IM==="float";return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:`agent-chat${Qt&&!Hj?" with-workspace-tree":""}`,children:[Qt&&oM&&i.jsx(ds,{workspace:oM,disclosureText:H==null?void 0:H.disclosureText,disclosure:H==null?void 0:H.disclosure,getContainer:d,highlight:$,disabled:xM,collapsible:Hj}),i.jsxs("div",{className:"agent-chat-column",children:[mD?i.jsx("div",{className:"session-loading",children:i.jsx(a.Spin,{})}):i.jsxs(i.Fragment,{children:[(b==null?void 0:b.promptVariables)&&i.jsx(as,{ref:wj,appId:N.id,currentSession:j,promptVariables:ue,setPromptVariables:cN,setCurrentSession:g}),i.jsxs("div",{className:"chat-main",id:"chat-main",style:_M,children:[i.jsx("div",{className:"chat-main-wrapper",id:"scrollableDiv",style:{height:"100%",overflowY:"auto",display:"flex",flexDirection:"column-reverse"},ref:R,onScroll:HD,onWheel:JD,onPointerDown:FD,children:(Kj=j==null?void 0:j.data)!=null&&Kj.id&&(I!=null&&I.length)?i.jsxs(sz,{dataLength:I.length,next:KD,style:{display:"flex",flexDirection:"column-reverse",overflowX:"hidden",overflowAnchor:"none"},inverse:!0,endMessage:I.length>ki&&((qj=R.current)!=null&&qj.scrollTop)&&((Mi=R.current)==null?void 0:Mi.scrollTop)<-10?i.jsx(a.Divider,{plain:!0,children:"没有更多数据了"}):null,hasMore:Sj,loader:i.jsx("div",{style:{height:"50px",textAlign:"center",overflow:"hidden"},children:i.jsx(a.Spin,{})}),scrollableTarget:"scrollableDiv",children:[I.map((c,o)=>i.jsx(ru,{application:N,currentSession:j,history:c,docViewerUrl:t,isLastHistory:o===0,onRelatedClick:XD,onAgainClick:$D,onEditClick:VD,markdown:h==null?void 0:h.markdown},c.renderKey||`${c.messageId}-${o}`)),!Sj&&Fj]}):i.jsxs("div",{className:"main-empty",children:[(h==null?void 0:h.greeting)!==!1&&i.jsx(hg,{text:h!=null&&h.greeting&&typeof h.greeting=="object"&&h.greeting.text!==void 0?h.greeting.text:(ei=N.arrange)!=null&&ei.length&&((Ni=N.arrange[0])!=null&&Ni.greetings)?N.arrange[0].greetings:fi.text,icon:h===void 0||h.greeting===!0||((ti=h.greeting)==null?void 0:ti.icon)===void 0?U||fi.icon:h.greeting.icon,children:!!pM.length&&(((h==null?void 0:h.greeting)===void 0||(h==null?void 0:h.greeting))===!0||typeof(h==null?void 0:h.greeting)=="object"&&h.greeting.questions!==!1)&&i.jsx(Ts,{ref:ot,sid:(ji=j==null?void 0:j.data)==null?void 0:ji.id,isRecommendClearing:qM,data:pM,layoutBreakpoints:typeof(h==null?void 0:h.greeting)=="object"?h.greeting.layoutBreakpoints:void 0,onItemClick:c=>{var E,P,W;if(S(c==null?void 0:c.question),$e(c==null?void 0:c.question),qM)return;c!=null&&c.id&&le(!0);const o=(E=j==null?void 0:j.data)==null?void 0:E.id;b!=null&&b.fileUpload?(W=(P=TN.current)==null?void 0:P.clear())==null||W.then(()=>{var jM,NM;c!=null&&c.id&&(o?(jM=Zj(o,c))==null||jM.finally(()=>{le(!1)}):(le(!1),Re(!0),(NM=Bj())==null||NM.then(mM=>{var fM;(fM=Zj(mM.id,c))==null||fM.finally(()=>{le(!1)})})))}):o?le(!1):(le(!1),Re(!0),Bj())}})}),Fj]})}),hj&&i.jsx("div",{className:"session-stop",children:i.jsx(a.Button,{type:"primary",style:{background:"white"},ghost:!0,size:"small",icon:i.jsx(AM,{type:"icon-zantinghuida",style:{fontSize:16}}),onClick:()=>_D(),children:"停止回答"})}),ED&&(I==null?void 0:I.length)>0&&i.jsx("div",{className:"back-bottom",children:i.jsx(a.Button,{size:"small",onClick:()=>BD({behavior:"smooth"}),type:"link",icon:i.jsx(AM,{type:"icon-yijianhuidaodibu",style:{fontSize:24}})})})]}),i.jsx("div",{className:"chat-footer",children:i.jsxs("div",{className:"chat-footer-input",children:[cM.length>0&&i.jsx("div",{className:"input-files",children:cM.map((c,o)=>i.jsx(Yg,{className:"thumb-40",file:c,actions:{upload:E=>nM(exports,null,function*(){UM(P=>P+1);try{return yield RD(E)}finally{UM(P=>Math.max(0,P-1))}}),remove:()=>{DM(E=>E.filter((P,W)=>W!==o)),EM(E=>E.filter((P,W)=>W!==o))}},onUrlChange:E=>{EM(P=>{const W=[...P];return W[o]=E,W})}},o))}),oM&&i.jsx(cu,{workspace:oM}),oM&&CM&&i.jsx(nu,{bridge:CM,getContainer:d}),i.jsxs("div",{className:"footer-upload-action-wrapper",children:[i.jsxs(a.Space,{className:"footer-upload-action",onClick:c=>c.preventDefault(),children:[i.jsxs(a.Space,{children:[(N.type===Z.ApplicationTypes.Agent&&(b==null?void 0:b.imageUpload)||N.type===Z.ApplicationTypes.Dialog&&((ii=N.arrange)==null?void 0:ii.length)&&!!N.arrange[0].visionOpen&&(b==null?void 0:b.imageUpload))&&i.jsx(a.Upload,{multiple:!0,disabled:cM.length>=Be||xM,accept:".jpg, .png, .jpeg,.bmp",listType:"picture-card",beforeUpload:bj,className:"footer-upload-picture",showUploadList:!1,children:cM.length<Be?i.jsx(a.Tooltip,{placement:"topLeft",overlayClassName:"footer-upload-tooltip",title:i.jsx("div",{children:`支持上传.jpg .png .jpeg
16
- .bmp格式的图片数据,单文件最大${pt}M,最多${Be}张`}),children:i.jsx(a.Button,{type:"text",className:"camera-out-btn",style:{width:"22px",position:"relative",bottom:"-2px"},icon:i.jsx(AM,{type:"icon-shangchuantupian",className:"icon-tianjia",style:{fontSize:"22px"}})})}):i.jsx(a.Button,{type:"text",className:"camera-out-btn",style:{width:"22px",position:"relative",bottom:"-2px"},disabled:!0,icon:i.jsx(AM,{type:"icon-shangchuantupian",className:"icon-tianjia",style:{fontSize:"22px"}})})}),D&&(b!=null&&b.fileUpload)&&(N!=null&&N.id)?i.jsx(cs,{appId:N==null?void 0:N.id,allowExcelAttachment:N.type===Z.ApplicationTypes.Agent,ref:TN,isFirstSession:Qj,docViewerUrl:t,onStatusChange:c=>nM(exports,null,function*(){c!=="process"?(UN(!0),ht()):UN(!1)}),createSession:()=>Wj().then(c=>{var E;return((E=c.data)==null?void 0:E.id)||""}),sid:(si=j==null?void 0:j.data)==null?void 0:si.id,disabled:lt||xM,afterFileAdd:(c,o)=>{o&&nN(E=>{const P=E[o]||[];return{[o]:[...P,c]}})},afterFileDelete:c=>{var E;const o=(E=j==null?void 0:j.data)==null?void 0:E.id;o&&nN(P=>{const W=P[o]||[];return{[o]:W.filter(jM=>jM.id!==c)}})},onFileListChange:c=>{OD(c)},shouldContinue:YD,afterFilesClear:()=>{var o;const c=(o=j==null?void 0:j.data)==null?void 0:o.id;c&&(nN({[c]:[]}),ht())}}):null,(b==null?void 0:b.prompt)&&(N==null?void 0:N.id)&&i.jsx(Hg,{appId:N.id,list:[],search:IN?yD:"",onPromptSelect:c=>{$e(c.context),S(c.context)},disabled:xM})]}),i.jsxs(a.Space,{children:[(b==null?void 0:b.connectNetwork)&&N.type===Z.ApplicationTypes.Dialog&&((Di=N.arrange)==null?void 0:Di.length)&&!!N.arrange[0].enableNetOpen&&i.jsx(Wg,{sessionId:(zi=j==null?void 0:j.data)==null?void 0:zi.id,netStatus:u,enable:typeof(h==null?void 0:h.connectNetwork)=="object"&&typeof(h==null?void 0:h.connectNetwork.diabled)=="boolean"?!(h!=null&&h.connectNetwork.diabled):SD,disabledTip:j?void 0:"网络访问已被禁用",onNetStatusChange:c=>{qD(c)}}),(b==null?void 0:b.sessionList)&&i.jsx(vg,{currentSessionId:(gi=j==null?void 0:j.data)==null?void 0:gi.id,onSessionChange:(c,o)=>{$e(void 0),vN(!0),g==null||g(o)},disabled:xM}),gM&&IM==="float"&&i.jsx("div",{className:"session-history-drawer-component",children:i.jsx(a.Popover,{placement:"topRight",showArrow:!1,overlayClassName:"session-history-overlay",overlayStyle:{padding:"4px"},getPopupContainer:c=>c.parentNode,content:"会话历史记录",children:i.jsx(a.Button,{className:"history-overlay-action",disabled:xM,type:"text",icon:i.jsx(AM,{type:"icon-lishijilu",style:{fontSize:24}}),onClick:()=>kj(!0)})})}),(b==null?void 0:b.sessionOpen)&&i.jsx(a.Button,{icon:i.jsx(yM.PlusOutlined,{}),className:"add-btn",type:"primary",disabled:hj||!j||!I.length||xM,onClick:()=>{var c,o;vN(!1),g==null||g(null),qe.current=null,n(!1),(c=wj.current)==null||c.clear(),(o=ot.current)==null||o.clear()},children:"新会话"})]})]}),!!Ct&&i.jsx("div",{className:"remainingSeconds-mark"})]}),i.jsxs("div",{className:"footer-textarea",onPaste:Gj,onPasteCapture:Gj,onDrop:Rj,onDropCapture:Rj,onDragOver:Pj,onDragOverCapture:Pj,children:[i.jsx(ns,{ref:vM,maxLength:B,text:lD,networkStatus:!1,loading:mj||bN,disabled:G||KM||xM||mj||bN,onTextSend:Yt,onChange:(c,o)=>{$e(c);const E=o.getText().replace(/[\n\s]+$/,"");S(E),oD(E),IN||AD(!0)},clearAction:i.jsx(a.Space,{size:0,children:i.jsx(a.Button,{type:"link",disabled:lt||xM,ghost:!0,icon:i.jsx(AM,{style:{fontSize:22},type:"icon-qingchujiyi"}),onClick:()=>bD()})})}),!!Ct&&i.jsxs("div",{className:"remainingSeconds-time",children:["您之前对话触发敏感词拦截,当前处于禁言状态,暂时无法发送消息,剩余禁言时长",Ct]})]})]})}),i.jsx(Sg,{tips:tM}),Ej&&i.jsx(kg,{isvisible:Ej,files:CD,sessionId:(ui=j==null?void 0:j.data)==null?void 0:ui.id,onClose:c=>{dD(!1),wD(!1)}})]}),fj&&i.jsx(Rg,{currentSession:j,application:N,networkStatus:u,setCurrentSession:g,disabled:xM,isSessionHistoryVisible:fj,setIsSessionHistoryVisible:kj,onSessionChange:c=>{vN(!0)}})]})]}),xt&&GN&&L.length>0&&Hi.createPortal(i.jsxs("div",{className:"artifacts-dock",ref:pj,children:[i.jsxs("div",{className:`artifacts-drawer${T?" is-open":""}`,children:[i.jsxs("button",{type:"button",className:"artifacts-handle",onClick:()=>y(c=>!c),children:[i.jsx("span",{className:"artifacts-handle-text",children:"产出物"}),T?i.jsx(yM.RightOutlined,{}):i.jsx(yM.LeftOutlined,{})]}),i.jsxs("div",{className:"artifacts-panel",children:[i.jsxs("div",{className:"artifacts-panel-main",children:[i.jsx("div",{className:"artifacts-panel-title",children:"产出物"}),i.jsx(Ag,{artifacts:L,activeArtifact:l,onPreview:C})]}),LN.preview==="column"&&l&&i.jsx(xg,{artifact:l,style:LN.style,onClose:()=>C(null)})]})]}),i.jsx(Og,{placement:LN.preview,artifact:l,style:LN.style,onClose:()=>C(null),getContainer:()=>pj.current||xt})]}),xt)]})});const Cs=M=>{const{disabled:e,checkedValues:N,currKnowledgeList:t,selectCount:j,onSelectChange:s}=M,[D,g]=z.useState(!1),u=i.jsx(a.Checkbox.Group,{style:{width:"100%"},onChange:s,value:N,disabled:e,children:i.jsx(a.Row,{gutter:[20,12],children:t==null?void 0:t.map(I=>i.jsx(a.Col,{span:24,children:i.jsx(a.Checkbox,{value:I.id,children:I.name})},I.id))})}),n=I=>{g(I)};return i.jsx("div",{className:"knowledge-select",style:{borderColor:D?"#9C24F2":"#84868C"},children:i.jsx(a.Popover,{className:"select-popover",placement:"bottomRight",title:null,content:u,trigger:"click",overlayStyle:{width:280},onOpenChange:n,getPopupContainer:I=>I.parentNode,children:i.jsxs("div",{className:"",onClick:I=>I.preventDefault(),children:[i.jsx(AM,{className:"select-icon",type:"icon-open"}),i.jsx("span",{className:"title",children:"参考知识库"}),i.jsxs("span",{className:"content",children:["已选 ",j," 个"]})]})})})},yu=M=>{var l,C;const{currentSession:e,application:N,setCheckKnowledges:t}=M,{mode:j,transform:s,features:D}=z.useContext(JM),[g,u]=z.useState([]),[n,I]=z.useState(typeof(D==null?void 0:D.knowledges)=="object"?((l=D.knowledges.default)==null?void 0:l.map(x=>x.id))||[]:[]),[A,L]=z.useState(0),[r,T]=z.useState(!1);z.useEffect(()=>{if(!(N!=null&&N.id))return;const x=N.arrange;if(!(x!=null&&x.length))return;const S=x[0].knowledges||[];u(S);const f=typeof(D==null?void 0:D.knowledges)=="object"&&D.knowledges.default||S;if(Array.isArray(f)&&f.some(Y=>Array.isArray(Y.fileIds)&&Y.fileIds.length===0))throw Error("fileIds cannot be an empty array");if(Mt(f||[])>be)throw Error(`knowledges and fileIds total count cannot exceed ${be}`);if(!e){I(f.map(MM=>MM.id)),L(f.length),t==null||t(f);return}const R=()=>{const MM=e.knowledges||f;L(MM.length);const Y=MM.map(eM=>eM.id);I(Y)};return R(),e.addEventListener("data:updated",R),()=>{e==null||e.removeEventListener("data:updated",R)}},[N,e]),z.useEffect(()=>{var m;if(!r||(T(!1),!(N!=null&&N.id)))return;const x=[];n==null||n.map(S=>{const f=g==null?void 0:g.find(_=>_.id===S);x.push(f)}),(m=e==null?void 0:e.data)!=null&&m.id&&e.setKnowledges(x)},[r]);const y=x=>{T(!0),I(x);const m=[];x==null||x.map(S=>{const f=g==null?void 0:g.find(_=>_.id===S);m.push(f)}),t==null||t(m),L(x.length)};return i.jsxs("div",{className:"chat-header",children:[i.jsxs(a.Space,{className:"header-title",children:[j==="inlay"&&((C=e==null?void 0:e.data)==null?void 0:C.name),j==="float"&&(N==null?void 0:N.name)]}),(s==null?void 0:s.knowledges)&&g.length!==0&&i.jsx(Cs,{disabled:typeof(D==null?void 0:D.knowledges)=="object"&&(D==null?void 0:D.knowledges.diabled)||!1,checkedValues:n,currKnowledgeList:g,selectCount:A,onSelectChange:y})]})},Os="gbot-sider-tab:";function Ui(M){try{return localStorage.getItem(Os+M)==="sessions"?"sessions":"workspace"}catch(e){return"workspace"}}function ou(M,e){try{localStorage.setItem(Os+M,e)}catch(N){}}const xs=z.forwardRef((M,e)=>{const{application:N}=M,{agentClient:t,sider:j,mode:s,localFilesUI:D,disabled:g,popupContainer:u}=z.useContext(JM),n=N!=null?N:t==null?void 0:t.application,I=j&&s==="inlay"&&(n==null?void 0:n.type)===Z.ApplicationTypes.Agent&&D&&D.picker!==!1?t==null?void 0:t.localWorkspace:void 0,{status:A}=As(I),[L]=ys(I),[r,T]=z.useState("workspace"),y=z.useRef(!1),l=z.useRef(!1);if(z.useEffect(()=>{if(!I)return;let x=!0;return I.ready.then(()=>{!x||y.current||l.current||I.status==="granted"&&(l.current=!0,T(Ui(I.applicationId)))}),()=>{x=!1}},[I]),z.useEffect(()=>{!I||I.isSupported||A!=="granted"||y.current||l.current||(l.current=!0,T(Ui(I.applicationId)))},[I,A]),z.useEffect(()=>{L&&T("workspace")},[L]),!I)return i.jsx(et,sM({ref:e},M));const C=x=>{y.current=!0,T(x),I.status==="granted"&&ou(I.applicationId,x)};return i.jsxs("div",{className:"sider-tabs",children:[i.jsxs("div",{className:"sider-tabs-bar",role:"tablist",children:[i.jsxs("button",{type:"button",role:"tab","aria-selected":r==="workspace",className:HM("sider-tab",{"is-active":r==="workspace"}),onClick:()=>C("workspace"),children:["工作区",L&&r!=="workspace"&&i.jsx("span",{className:"sider-tab-dot"})]}),i.jsx("button",{type:"button",role:"tab","aria-selected":r==="sessions",className:HM("sider-tab",{"is-active":r==="sessions"}),onClick:()=>C("sessions"),children:"会话记录"})]}),i.jsxs("div",{className:"sider-tabs-panels",children:[i.jsx("div",{className:HM("sider-tabs-panel",{"is-hidden":r!=="workspace"}),role:"tabpanel",children:i.jsx(ds,{workspace:I,disclosureText:D==null?void 0:D.disclosureText,disclosure:D==null?void 0:D.disclosure,getContainer:()=>(u==null?void 0:u.current)||document.body,highlight:L,disabled:g})}),i.jsx("div",{className:HM("sider-tabs-panel",{"is-hidden":r!=="sessions"}),role:"tabpanel",children:i.jsx(et,sM({ref:e},M))})]})]})});xs.displayName="SiderTabs";const lu=z.forwardRef((M,e)=>{const{sessionId:N,appId:t,docViewerUrl:j}=M,[s,D]=z.useState(),{showHeader:g,agentClient:u,sider:n,onSessionLoad:I,features:A,mode:L}=z.useContext(JM),[r,T]=z.useState(),y=z.useRef(null),[l,C]=z.useState(""),[x,m]=z.useState(),S=z.useRef(null),[f,_]=z.useState(!1);z.useState([]);const{setIsSwitchingToExistingSession:R}=jj();z.useEffect(()=>{var Y;_(s?!!((Y=s.data)!=null&&Y.netOpen):typeof(A==null?void 0:A.connectNetwork)=="object"&&typeof(A==null?void 0:A.connectNetwork.default)=="boolean"?A.connectNetwork.default:!1)},[s]),z.useEffect(()=>{const Y=()=>nM(exports,null,function*(){const eM=u==null?void 0:u.application;if(!(eM!=null&&eM.id))return;const v=eM==null?void 0:eM.arrange;if(!(v!=null&&v.length))return;const F=v[0].embeddingService;C(F),T(eM)});if(u!=null&&u.ready){Y();return}return u==null||u.addEventListener("ready",()=>Y()),()=>{u==null||u.removeEventListener("ready",Y)}},[u]),z.useEffect(()=>{u&&N&&(u.ready?u==null||u.getSessions().then(Y=>nM(exports,null,function*(){D==null||D(Y.find(eM=>eM.id===N))})):u.addEventListener("ready",()=>nM(exports,null,function*(){u==null||u.getSessions().then(Y=>nM(exports,null,function*(){D==null||D(Y.find(eM=>eM.id===N))}))}),!0))},[u,N]),z.useEffect(()=>{if(!s){I&&I({applicationId:t,sessionId:"",session:null,sessionInstance:null});return}s.data&&I&&I({applicationId:t,sessionId:s.data.id,session:s.data,sessionInstance:s}),s.addEventListener("data:loaded",()=>{s!=null&&s.data&&I&&I({applicationId:t,sessionId:s.data.id,session:s.data,sessionInstance:s})},!0)},[s]);const MM=Y=>{var eM;return(eM=y.current)==null?void 0:eM.create(BM(sM({},Y),{knowledges:x}))};return z.useImperativeHandle(e,()=>({createSession:Y=>MM(Y),getSessionList:()=>{var eM;const Y=((eM=y.current)==null?void 0:eM.list())||[];return Promise.resolve(Y)},getCurrentInputText:()=>{var Y;return(Y=S.current)==null?void 0:Y.getCurrentInputText()},send:Y=>{var eM;return(eM=S.current)!=null&&eM.send?S.current.send(Y):Promise.reject(new Error("send is not available"))}})),i.jsx("div",{className:"dialog",children:i.jsxs("div",{className:"dialog-pannel",children:[i.jsx("div",{className:"dialog-sider",style:{display:n&&L==="inlay"?"block":"none"},children:i.jsx(xs,{ref:y,appId:t,networkStatus:f,currentSession:s,application:r,setCurrentSession:D,checkKnowledges:x,setCheckKnowledges:g?m:void 0,sessionId:N,afterSessionClick:Y=>{var eM,v;((eM=Y.data)==null?void 0:eM.id)!==((v=s==null?void 0:s.data)==null?void 0:v.id)&&R(!0)}})}),i.jsx("div",{className:"dialog-content",children:i.jsxs("div",{className:"dialog-chat",children:[g&&i.jsx("div",{className:"dialog-chat-header",children:i.jsx(yu,{setCheckKnowledges:m,application:r,currentSession:s})}),i.jsx("div",{className:"dialog-chat-content",children:(r==null?void 0:r.id)&&i.jsx(Au,{setNetworkStatus:_,networkStatus:f,application:r,currentSession:s,onCreateSession:MM,docViewerUrl:j,embeddingService:l,setCurrentSession:D,ref:S})})]})})]})})}),du=z.forwardRef((M,e)=>{const{className:N,triggerButton:t,size:j,theme:s,icon:D,docViewerUrl:g,token:u,debug:n,env:I,plugins:A,mcp:L,footer:r,defaultInput:T,onComment:y,onSessionLoad:l,onSessionUnload:C,onMessage:x,beforeMessageSend:m,bodyStyle:S,apiUrl:f,sessionId:_,disabled:R,transform:MM,features:Y,stream:eM,agentClient:v,application:p}=M,F=z.useRef(null),[tM,b]=z.useState(!1),[lM,bM]=z.useState(),[dM,rM]=z.useState(j),[_M,xM]=z.useState(M.open),h=z.useRef(null);z.useEffect(()=>{p&&(console.log("[AgentClientUI] token",v,p),bM(p.id))},[p]),a.ConfigProvider.config({theme:s}),z.useEffect(()=>{j&&rM(j)},[j]);const O=(U,{element:gM,size:IM})=>{rM({width:Number(IM.width),height:IM.height})};return z.useImperativeHandle(e,()=>({createSession:U=>{var gM;return(gM=h.current)==null?void 0:gM.createSession(U)},getSessionList:()=>{var U;return(U=h.current)==null?void 0:U.getSessionList()},getCurrentInputText:()=>{var U;return(U=h.current)==null?void 0:U.getCurrentInputText()},send:U=>{var gM;return(gM=h.current)!=null&&gM.send?h.current.send(U):Promise.reject(new Error("send is not available"))}})),i.jsx(a.ConfigProvider,{locale:Xi,children:i.jsxs(qi,{value:BM(sM({},M),{popupContainer:F,agentClient:v,footer:r,defaultInput:T,onComment:y,onSessionLoad:l,onSessionUnload:C,onMessage:x,beforeMessageSend:m,bodyStyle:S,disabled:R,transform:MM,features:Y}),children:[i.jsx(tz.Resizable,{height:(dM==null?void 0:dM.height)||"100%",width:(dM==null?void 0:dM.width)||"100%",maxConstraints:[document.body.clientWidth-45],minConstraints:[Number(j==null?void 0:j.minWidth)],onResize:O,handle:i.jsx("span",{className:"resize-handle-ew"}),resizeHandles:N=="float"?["w"]:[],children:i.jsxs("div",{id:"dialog-modal",className:`gbot-dialog-modal ${N} ${_M?"opened":"closed"}`,style:BM(sM({},j),{width:N=="float"?dM==null?void 0:dM.width:j==null?void 0:j.width,height:N==="float"?dM==null?void 0:dM.height:j==null?void 0:j.height,maxHeight:"100vh"}),ref:F,children:[tM?i.jsx("div",{className:"loading",children:i.jsx(a.Spin,{})}):lM&&v?i.jsx(Gg,{children:i.jsx(lu,{ref:h,appId:lM,docViewerUrl:g,bodyStyle:S,sessionId:_})}):null,(t==null?void 0:t.visible)&&i.jsx(a.Button,{className:"trigger-btn close-btn",icon:i.jsx("img",{src:D}),onClick:()=>xM(!1)})]})}),(t==null?void 0:t.visible)&&!_M&&i.jsx(a.Button,{className:`${N}-trigger-btn open-btn`,style:t.style,icon:i.jsx("img",{src:D}),onClick:()=>xM(!0)})]})})}),Cu="@glodon-aiot/agent-cli-ui",Ou="3.26.0-alpha.18",xu="./dist/es/index.mjs",Yu="./dist/lib/index.js",wu="./dist/src/index.d.ts",Eu={import:"./dist/es/index.mjs",require:"./dist/lib/index.js",types:"./dist/src/index.d.ts"},hu=["dist"],Qu="module",Su="dist/src/index.d.ts",mu={dev:"vite",start:"vite",build:"tsc && node --max-old-space-size=4096 ./node_modules/vite/bin/vite.js build --mode prod && yarn build:cdn","build:pre":"tsc && node --max-old-space-size=4096 ./node_modules/vite/bin/vite.js build --mode prod","build:cdn":"tsc && vite build --mode prod --config ./vite.config.cdn.ts",preview:"vite preview",check:"yarn prettier --check .",write:"yarn prettier --write .",lint:"eslint --ext .tsx,.ts --fix ./example -c .eslintrc.js",storybook:"start-storybook -p 6006 -s public","build-storybook":"build-storybook -s public",docs:"start-storybook -p 6006",commit:"cz"},fu={"@ant-design/icons":"^5.3.4","@glodon-aiot/apis":"^3.26.0-alpha.18","@glodon-aiot/bot-client-sdk":"^3.26.0-alpha.18","@glodon-aiot/react-components":"^3.26.0-alpha.18","@matejmazur/react-mathjax":"^0.1.10","@react-pdf-viewer/core":"^3.12.0","@react-pdf-viewer/default-layout":"^3.12.0","@react-pdf-viewer/locales":"^1.0.0","@react-pdf-viewer/toolbar":"^3.12.0",ahooks:"^3.8.5",antd:"^4.24.16",axios:"0.24.0",classnames:"^2.5.1","copy-to-clipboard":"^3.3.3",dayjs:"^1.11.13",lodash:"^4.17.21","pdfjs-dist":"^3.0.279","quill-delta":"^5.1.0",react:">=17.0.0 <19.0.0","react-dom":">=17.0.0 <19.0.0","react-infinite-scroll-component":"^6.1.0","react-quill-new":"^3.6.0","react-resizable":"^3.0.5",uuid:"^11.1.0"},ku={"@babel/core":"^7.20.12","@commitlint/cli":"^17.0.3","@commitlint/config-conventional":"^17.0.3","@rollup/plugin-babel":"^6.0.4","@rollup/plugin-commonjs":"^28.0.0","@rollup/plugin-typescript":"^11.1.6","@storybook/addon-actions":"6.3.6","@storybook/addon-essentials":"6.4.9","@storybook/addon-interactions":"^6.5.16","@storybook/addon-links":"6.3.5","@storybook/addon-postcss":"2.0.0","@storybook/builder-vite":"^0.4.0","@storybook/node-logger":"6.4.9","@storybook/react":"6.4.9","@storybook/testing-library":"^0.0.13","@types/lodash":"^4","@types/react":"^18","@types/react-dom":"^18","@typescript-eslint/eslint-plugin":"^5.35.1","@typescript-eslint/parser":"^5.35.1","@vitejs/plugin-react":"^3.1.0",antd:"^4.24.0","babel-loader":"^8.3.0","babel-plugin-import":"^1.13.8",commitizen:"^4.3.0","css-loader":"^6.7.3","cz-conventional-changelog":"^3.3.0","cz-customizable":"^7.0.0",eslint:"^8.0.1","eslint-config-prettier":"^8.5.0","eslint-config-standard-with-typescript":"^22.0.0","eslint-plugin-import":"^2.25.2","eslint-plugin-n":"^15.0.0","eslint-plugin-promise":"^6.0.0","eslint-plugin-react":"^7.31.0","eslint-plugin-storybook":"^0.6.10",husky:">=6",less:"^4.1.2","less-loader":"^11.1.0","lint-staged":">=10","postcss-loader":"^7.2.4",prettier:"2.7.1","require-from-string":"^2.0.2","rollup-plugin-visualizer":"^6.0.1","storybook-less-loader":"^0.1.0",typescript:"*",vite:"^4.1.1","vite-plugin-css-injected-by-js":"^3.5.0","vite-plugin-dts":"^4.3.0","vite-plugin-externalize-deps":"^0.9.0"},Uu=[">0.2%","not dead","not op_mini all"],pu=["last 1 chrome version","last 1 firefox version","last 1 safari version"],bu={commitizen:{path:"node_modules/cz-customizable"},"cz-customizable":{config:".cz-config.cjs"}},vu={access:"public",registry:"https://registry.npmjs.org/"},Gu={hooks:{"commit-msg":"validate-commit-msg"}},Pu={name:Cu,version:Ou,module:xu,main:Yu,typings:wu,exports:Eu,files:hu,type:Qu,types:Su,scripts:mu,dependencies:fu,devDependencies:ku,"lint-staged":{"*.{js,css,md,jsx,less,ts,tsx,json}":"prettier --write"},production:Uu,development:pu,config:bu,publishConfig:vu,husky:Gu};var Ys=(M=>(M.dev="https://aiot-dev.glodon.com/api/cvforcepd",M.test="https://aiot-dev.glodon.com/api/cvforce",M.prod="https://copilot.glodon.com/api/cvforce",M.local="http://localhost:3000/api/cvforcepd",M))(Ys||{});//! moment.js
16
+ .bmp格式的图片数据,单文件最大${pt}M,最多${Be}张`}),children:i.jsx(a.Button,{type:"text",className:"camera-out-btn",style:{width:"22px",position:"relative",bottom:"-2px"},icon:i.jsx(AM,{type:"icon-shangchuantupian",className:"icon-tianjia",style:{fontSize:"22px"}})})}):i.jsx(a.Button,{type:"text",className:"camera-out-btn",style:{width:"22px",position:"relative",bottom:"-2px"},disabled:!0,icon:i.jsx(AM,{type:"icon-shangchuantupian",className:"icon-tianjia",style:{fontSize:"22px"}})})}),D&&(b!=null&&b.fileUpload)&&(N!=null&&N.id)?i.jsx(cs,{appId:N==null?void 0:N.id,allowExcelAttachment:N.type===Z.ApplicationTypes.Agent,ref:TN,isFirstSession:Qj,docViewerUrl:t,onStatusChange:c=>nM(exports,null,function*(){c!=="process"?(UN(!0),ht()):UN(!1)}),createSession:()=>Wj().then(c=>{var E;return((E=c.data)==null?void 0:E.id)||""}),sid:(si=j==null?void 0:j.data)==null?void 0:si.id,disabled:lt||xM,afterFileAdd:(c,o)=>{o&&nN(E=>{const P=E[o]||[];return{[o]:[...P,c]}})},afterFileDelete:c=>{var E;const o=(E=j==null?void 0:j.data)==null?void 0:E.id;o&&nN(P=>{const W=P[o]||[];return{[o]:W.filter(jM=>jM.id!==c)}})},onFileListChange:c=>{OD(c)},shouldContinue:YD,afterFilesClear:()=>{var o;const c=(o=j==null?void 0:j.data)==null?void 0:o.id;c&&(nN({[c]:[]}),ht())}}):null,(b==null?void 0:b.prompt)&&(N==null?void 0:N.id)&&i.jsx(Hg,{appId:N.id,list:[],search:IN?yD:"",onPromptSelect:c=>{$e(c.context),S(c.context)},disabled:xM})]}),i.jsxs(a.Space,{children:[(b==null?void 0:b.connectNetwork)&&N.type===Z.ApplicationTypes.Dialog&&((Di=N.arrange)==null?void 0:Di.length)&&!!N.arrange[0].enableNetOpen&&i.jsx(Wg,{sessionId:(zi=j==null?void 0:j.data)==null?void 0:zi.id,netStatus:u,enable:typeof(h==null?void 0:h.connectNetwork)=="object"&&typeof(h==null?void 0:h.connectNetwork.diabled)=="boolean"?!(h!=null&&h.connectNetwork.diabled):SD,disabledTip:j?void 0:"网络访问已被禁用",onNetStatusChange:c=>{qD(c)}}),(b==null?void 0:b.sessionList)&&i.jsx(vg,{currentSessionId:(gi=j==null?void 0:j.data)==null?void 0:gi.id,onSessionChange:(c,o)=>{$e(void 0),vN(!0),g==null||g(o)},disabled:xM}),gM&&IM==="float"&&i.jsx("div",{className:"session-history-drawer-component",children:i.jsx(a.Popover,{placement:"topRight",showArrow:!1,overlayClassName:"session-history-overlay",overlayStyle:{padding:"4px"},getPopupContainer:c=>c.parentNode,content:"会话历史记录",children:i.jsx(a.Button,{className:"history-overlay-action",disabled:xM,type:"text",icon:i.jsx(AM,{type:"icon-lishijilu",style:{fontSize:24}}),onClick:()=>kj(!0)})})}),(b==null?void 0:b.sessionOpen)&&i.jsx(a.Button,{icon:i.jsx(yM.PlusOutlined,{}),className:"add-btn",type:"primary",disabled:hj||!j||!I.length||xM,onClick:()=>{var c,o;vN(!1),g==null||g(null),qe.current=null,n(!1),(c=wj.current)==null||c.clear(),(o=ot.current)==null||o.clear()},children:"新会话"})]})]}),!!Ct&&i.jsx("div",{className:"remainingSeconds-mark"})]}),i.jsxs("div",{className:"footer-textarea",onPaste:Gj,onPasteCapture:Gj,onDrop:Rj,onDropCapture:Rj,onDragOver:Pj,onDragOverCapture:Pj,children:[i.jsx(ns,{ref:vM,maxLength:B,text:lD,networkStatus:!1,loading:mj||bN,disabled:G||KM||xM||mj||bN,onTextSend:Yt,onChange:(c,o)=>{$e(c);const E=o.getText().replace(/[\n\s]+$/,"");S(E),oD(E),IN||AD(!0)},clearAction:i.jsx(a.Space,{size:0,children:i.jsx(a.Button,{type:"link",disabled:lt||xM,ghost:!0,icon:i.jsx(AM,{style:{fontSize:22},type:"icon-qingchujiyi"}),onClick:()=>bD()})})}),!!Ct&&i.jsxs("div",{className:"remainingSeconds-time",children:["您之前对话触发敏感词拦截,当前处于禁言状态,暂时无法发送消息,剩余禁言时长",Ct]})]})]})}),i.jsx(Sg,{tips:tM}),Ej&&i.jsx(kg,{isvisible:Ej,files:CD,sessionId:(ui=j==null?void 0:j.data)==null?void 0:ui.id,onClose:c=>{dD(!1),wD(!1)}})]}),fj&&i.jsx(Rg,{currentSession:j,application:N,networkStatus:u,setCurrentSession:g,disabled:xM,isSessionHistoryVisible:fj,setIsSessionHistoryVisible:kj,onSessionChange:c=>{vN(!0)}})]})]}),xt&&GN&&L.length>0&&Hi.createPortal(i.jsxs("div",{className:"artifacts-dock",ref:pj,children:[i.jsxs("div",{className:`artifacts-drawer${T?" is-open":""}`,children:[i.jsxs("button",{type:"button",className:"artifacts-handle",onClick:()=>y(c=>!c),children:[i.jsx("span",{className:"artifacts-handle-text",children:"产出物"}),T?i.jsx(yM.RightOutlined,{}):i.jsx(yM.LeftOutlined,{})]}),i.jsxs("div",{className:"artifacts-panel",children:[i.jsxs("div",{className:"artifacts-panel-main",children:[i.jsx("div",{className:"artifacts-panel-title",children:"产出物"}),i.jsx(Ag,{artifacts:L,activeArtifact:l,onPreview:C})]}),LN.preview==="column"&&l&&i.jsx(xg,{artifact:l,style:LN.style,onClose:()=>C(null)})]})]}),i.jsx(Og,{placement:LN.preview,artifact:l,style:LN.style,onClose:()=>C(null),getContainer:()=>pj.current||xt})]}),xt)]})});const Cs=M=>{const{disabled:e,checkedValues:N,currKnowledgeList:t,selectCount:j,onSelectChange:s}=M,[D,g]=z.useState(!1),u=i.jsx(a.Checkbox.Group,{style:{width:"100%"},onChange:s,value:N,disabled:e,children:i.jsx(a.Row,{gutter:[20,12],children:t==null?void 0:t.map(I=>i.jsx(a.Col,{span:24,children:i.jsx(a.Checkbox,{value:I.id,children:I.name})},I.id))})}),n=I=>{g(I)};return i.jsx("div",{className:"knowledge-select",style:{borderColor:D?"#9C24F2":"#84868C"},children:i.jsx(a.Popover,{className:"select-popover",placement:"bottomRight",title:null,content:u,trigger:"click",overlayStyle:{width:280},onOpenChange:n,getPopupContainer:I=>I.parentNode,children:i.jsxs("div",{className:"",onClick:I=>I.preventDefault(),children:[i.jsx(AM,{className:"select-icon",type:"icon-open"}),i.jsx("span",{className:"title",children:"参考知识库"}),i.jsxs("span",{className:"content",children:["已选 ",j," 个"]})]})})})},yu=M=>{var l,C;const{currentSession:e,application:N,setCheckKnowledges:t}=M,{mode:j,transform:s,features:D}=z.useContext(JM),[g,u]=z.useState([]),[n,I]=z.useState(typeof(D==null?void 0:D.knowledges)=="object"?((l=D.knowledges.default)==null?void 0:l.map(x=>x.id))||[]:[]),[A,L]=z.useState(0),[r,T]=z.useState(!1);z.useEffect(()=>{if(!(N!=null&&N.id))return;const x=N.arrange;if(!(x!=null&&x.length))return;const S=x[0].knowledges||[];u(S);const f=typeof(D==null?void 0:D.knowledges)=="object"&&D.knowledges.default||S;if(Array.isArray(f)&&f.some(Y=>Array.isArray(Y.fileIds)&&Y.fileIds.length===0))throw Error("fileIds cannot be an empty array");if(Mt(f||[])>be)throw Error(`knowledges and fileIds total count cannot exceed ${be}`);if(!e){I(f.map(MM=>MM.id)),L(f.length),t==null||t(f);return}const R=()=>{const MM=e.knowledges||f;L(MM.length);const Y=MM.map(eM=>eM.id);I(Y)};return R(),e.addEventListener("data:updated",R),()=>{e==null||e.removeEventListener("data:updated",R)}},[N,e]),z.useEffect(()=>{var m;if(!r||(T(!1),!(N!=null&&N.id)))return;const x=[];n==null||n.map(S=>{const f=g==null?void 0:g.find(_=>_.id===S);x.push(f)}),(m=e==null?void 0:e.data)!=null&&m.id&&e.setKnowledges(x)},[r]);const y=x=>{T(!0),I(x);const m=[];x==null||x.map(S=>{const f=g==null?void 0:g.find(_=>_.id===S);m.push(f)}),t==null||t(m),L(x.length)};return i.jsxs("div",{className:"chat-header",children:[i.jsxs(a.Space,{className:"header-title",children:[j==="inlay"&&((C=e==null?void 0:e.data)==null?void 0:C.name),j==="float"&&(N==null?void 0:N.name)]}),(s==null?void 0:s.knowledges)&&g.length!==0&&i.jsx(Cs,{disabled:typeof(D==null?void 0:D.knowledges)=="object"&&(D==null?void 0:D.knowledges.diabled)||!1,checkedValues:n,currKnowledgeList:g,selectCount:A,onSelectChange:y})]})},Os="gbot-sider-tab:";function Ui(M){try{return localStorage.getItem(Os+M)==="sessions"?"sessions":"workspace"}catch(e){return"workspace"}}function ou(M,e){try{localStorage.setItem(Os+M,e)}catch(N){}}const xs=z.forwardRef((M,e)=>{const{application:N}=M,{agentClient:t,sider:j,mode:s,localFilesUI:D,disabled:g,popupContainer:u}=z.useContext(JM),n=N!=null?N:t==null?void 0:t.application,I=j&&s==="inlay"&&(n==null?void 0:n.type)===Z.ApplicationTypes.Agent&&D&&D.picker!==!1?t==null?void 0:t.localWorkspace:void 0,{status:A}=As(I),[L]=ys(I),[r,T]=z.useState("workspace"),y=z.useRef(!1),l=z.useRef(!1);if(z.useEffect(()=>{if(!I)return;let x=!0;return I.ready.then(()=>{!x||y.current||l.current||I.status==="granted"&&(l.current=!0,T(Ui(I.applicationId)))}),()=>{x=!1}},[I]),z.useEffect(()=>{!I||I.isSupported||A!=="granted"||y.current||l.current||(l.current=!0,T(Ui(I.applicationId)))},[I,A]),z.useEffect(()=>{L&&T("workspace")},[L]),!I)return i.jsx(et,sM({ref:e},M));const C=x=>{y.current=!0,T(x),I.status==="granted"&&ou(I.applicationId,x)};return i.jsxs("div",{className:"sider-tabs",children:[i.jsxs("div",{className:"sider-tabs-bar",role:"tablist",children:[i.jsxs("button",{type:"button",role:"tab","aria-selected":r==="workspace",className:HM("sider-tab",{"is-active":r==="workspace"}),onClick:()=>C("workspace"),children:["工作区",L&&r!=="workspace"&&i.jsx("span",{className:"sider-tab-dot"})]}),i.jsx("button",{type:"button",role:"tab","aria-selected":r==="sessions",className:HM("sider-tab",{"is-active":r==="sessions"}),onClick:()=>C("sessions"),children:"会话记录"})]}),i.jsxs("div",{className:"sider-tabs-panels",children:[i.jsx("div",{className:HM("sider-tabs-panel",{"is-hidden":r!=="workspace"}),role:"tabpanel",children:i.jsx(ds,{workspace:I,disclosureText:D==null?void 0:D.disclosureText,disclosure:D==null?void 0:D.disclosure,getContainer:()=>(u==null?void 0:u.current)||document.body,highlight:L,disabled:g})}),i.jsx("div",{className:HM("sider-tabs-panel",{"is-hidden":r!=="sessions"}),role:"tabpanel",children:i.jsx(et,sM({ref:e},M))})]})]})});xs.displayName="SiderTabs";const lu=z.forwardRef((M,e)=>{const{sessionId:N,appId:t,docViewerUrl:j}=M,[s,D]=z.useState(),{showHeader:g,agentClient:u,sider:n,onSessionLoad:I,features:A,mode:L}=z.useContext(JM),[r,T]=z.useState(),y=z.useRef(null),[l,C]=z.useState(""),[x,m]=z.useState(),S=z.useRef(null),[f,_]=z.useState(!1);z.useState([]);const{setIsSwitchingToExistingSession:R}=jj();z.useEffect(()=>{var Y;_(s?!!((Y=s.data)!=null&&Y.netOpen):typeof(A==null?void 0:A.connectNetwork)=="object"&&typeof(A==null?void 0:A.connectNetwork.default)=="boolean"?A.connectNetwork.default:!1)},[s]),z.useEffect(()=>{const Y=()=>nM(exports,null,function*(){const eM=u==null?void 0:u.application;if(!(eM!=null&&eM.id))return;const v=eM==null?void 0:eM.arrange;if(!(v!=null&&v.length))return;const F=v[0].embeddingService;C(F),T(eM)});if(u!=null&&u.ready){Y();return}return u==null||u.addEventListener("ready",()=>Y()),()=>{u==null||u.removeEventListener("ready",Y)}},[u]),z.useEffect(()=>{u&&N&&(u.ready?u==null||u.getSessions().then(Y=>nM(exports,null,function*(){D==null||D(Y.find(eM=>eM.id===N))})):u.addEventListener("ready",()=>nM(exports,null,function*(){u==null||u.getSessions().then(Y=>nM(exports,null,function*(){D==null||D(Y.find(eM=>eM.id===N))}))}),!0))},[u,N]),z.useEffect(()=>{if(!s){I&&I({applicationId:t,sessionId:"",session:null,sessionInstance:null});return}s.data&&I&&I({applicationId:t,sessionId:s.data.id,session:s.data,sessionInstance:s}),s.addEventListener("data:loaded",()=>{s!=null&&s.data&&I&&I({applicationId:t,sessionId:s.data.id,session:s.data,sessionInstance:s})},!0)},[s]);const MM=Y=>{var eM;return(eM=y.current)==null?void 0:eM.create(BM(sM({},Y),{knowledges:x}))};return z.useImperativeHandle(e,()=>({createSession:Y=>MM(Y),getSessionList:()=>{var eM;const Y=((eM=y.current)==null?void 0:eM.list())||[];return Promise.resolve(Y)},getCurrentInputText:()=>{var Y;return(Y=S.current)==null?void 0:Y.getCurrentInputText()},send:Y=>{var eM;return(eM=S.current)!=null&&eM.send?S.current.send(Y):Promise.reject(new Error("send is not available"))}})),i.jsx("div",{className:"dialog",children:i.jsxs("div",{className:"dialog-pannel",children:[i.jsx("div",{className:"dialog-sider",style:{display:n&&L==="inlay"?"block":"none"},children:i.jsx(xs,{ref:y,appId:t,networkStatus:f,currentSession:s,application:r,setCurrentSession:D,checkKnowledges:x,setCheckKnowledges:g?m:void 0,sessionId:N,afterSessionClick:Y=>{var eM,v;((eM=Y.data)==null?void 0:eM.id)!==((v=s==null?void 0:s.data)==null?void 0:v.id)&&R(!0)}})}),i.jsx("div",{className:"dialog-content",children:i.jsxs("div",{className:"dialog-chat",children:[g&&i.jsx("div",{className:"dialog-chat-header",children:i.jsx(yu,{setCheckKnowledges:m,application:r,currentSession:s})}),i.jsx("div",{className:"dialog-chat-content",children:(r==null?void 0:r.id)&&i.jsx(Au,{setNetworkStatus:_,networkStatus:f,application:r,currentSession:s,onCreateSession:MM,docViewerUrl:j,embeddingService:l,setCurrentSession:D,ref:S})})]})})]})})}),du=z.forwardRef((M,e)=>{const{className:N,triggerButton:t,size:j,theme:s,icon:D,docViewerUrl:g,token:u,debug:n,env:I,plugins:A,mcp:L,footer:r,defaultInput:T,onComment:y,onSessionLoad:l,onSessionUnload:C,onMessage:x,beforeMessageSend:m,bodyStyle:S,apiUrl:f,sessionId:_,disabled:R,transform:MM,features:Y,stream:eM,agentClient:v,application:p}=M,F=z.useRef(null),[tM,b]=z.useState(!1),[lM,bM]=z.useState(),[dM,rM]=z.useState(j),[_M,xM]=z.useState(M.open),h=z.useRef(null);z.useEffect(()=>{p&&(console.log("[AgentClientUI] token",v,p),bM(p.id))},[p]),a.ConfigProvider.config({theme:s}),z.useEffect(()=>{j&&rM(j)},[j]);const O=(U,{element:gM,size:IM})=>{rM({width:Number(IM.width),height:IM.height})};return z.useImperativeHandle(e,()=>({createSession:U=>{var gM;return(gM=h.current)==null?void 0:gM.createSession(U)},getSessionList:()=>{var U;return(U=h.current)==null?void 0:U.getSessionList()},getCurrentInputText:()=>{var U;return(U=h.current)==null?void 0:U.getCurrentInputText()},send:U=>{var gM;return(gM=h.current)!=null&&gM.send?h.current.send(U):Promise.reject(new Error("send is not available"))}})),i.jsx(a.ConfigProvider,{locale:Xi,children:i.jsxs(qi,{value:BM(sM({},M),{popupContainer:F,agentClient:v,footer:r,defaultInput:T,onComment:y,onSessionLoad:l,onSessionUnload:C,onMessage:x,beforeMessageSend:m,bodyStyle:S,disabled:R,transform:MM,features:Y}),children:[i.jsx(tz.Resizable,{height:(dM==null?void 0:dM.height)||"100%",width:(dM==null?void 0:dM.width)||"100%",maxConstraints:[document.body.clientWidth-45],minConstraints:[Number(j==null?void 0:j.minWidth)],onResize:O,handle:i.jsx("span",{className:"resize-handle-ew"}),resizeHandles:N=="float"?["w"]:[],children:i.jsxs("div",{id:"dialog-modal",className:`gbot-dialog-modal ${N} ${_M?"opened":"closed"}`,style:BM(sM({},j),{width:N=="float"?dM==null?void 0:dM.width:j==null?void 0:j.width,height:N==="float"?dM==null?void 0:dM.height:j==null?void 0:j.height,maxHeight:"100vh"}),ref:F,children:[tM?i.jsx("div",{className:"loading",children:i.jsx(a.Spin,{})}):lM&&v?i.jsx(Gg,{children:i.jsx(lu,{ref:h,appId:lM,docViewerUrl:g,bodyStyle:S,sessionId:_})}):null,(t==null?void 0:t.visible)&&i.jsx(a.Button,{className:"trigger-btn close-btn",icon:i.jsx("img",{src:D}),onClick:()=>xM(!1)})]})}),(t==null?void 0:t.visible)&&!_M&&i.jsx(a.Button,{className:`${N}-trigger-btn open-btn`,style:t.style,icon:i.jsx("img",{src:D}),onClick:()=>xM(!0)})]})})}),Cu="@glodon-aiot/agent-cli-ui",Ou="3.26.0-alpha.20",xu="./dist/es/index.mjs",Yu="./dist/lib/index.js",wu="./dist/src/index.d.ts",Eu={import:"./dist/es/index.mjs",require:"./dist/lib/index.js",types:"./dist/src/index.d.ts"},hu=["dist"],Qu="module",Su="dist/src/index.d.ts",mu={dev:"vite",start:"vite",build:"tsc && node --max-old-space-size=4096 ./node_modules/vite/bin/vite.js build --mode prod && yarn build:cdn","build:pre":"tsc && node --max-old-space-size=4096 ./node_modules/vite/bin/vite.js build --mode prod","build:cdn":"tsc && vite build --mode prod --config ./vite.config.cdn.ts",preview:"vite preview",check:"yarn prettier --check .",write:"yarn prettier --write .",lint:"eslint --ext .tsx,.ts --fix ./example -c .eslintrc.js",storybook:"start-storybook -p 6006 -s public","build-storybook":"build-storybook -s public",docs:"start-storybook -p 6006",commit:"cz"},fu={"@ant-design/icons":"^5.3.4","@glodon-aiot/apis":"^3.26.0-alpha.20","@glodon-aiot/bot-client-sdk":"^3.26.0-alpha.20","@glodon-aiot/react-components":"^3.26.0-alpha.20","@matejmazur/react-mathjax":"^0.1.10","@react-pdf-viewer/core":"^3.12.0","@react-pdf-viewer/default-layout":"^3.12.0","@react-pdf-viewer/locales":"^1.0.0","@react-pdf-viewer/toolbar":"^3.12.0",ahooks:"^3.8.5",antd:"^4.24.16",axios:"0.24.0",classnames:"^2.5.1","copy-to-clipboard":"^3.3.3",dayjs:"^1.11.13",lodash:"^4.17.21","pdfjs-dist":"^3.0.279","quill-delta":"^5.1.0",react:">=17.0.0 <19.0.0","react-dom":">=17.0.0 <19.0.0","react-infinite-scroll-component":"^6.1.0","react-quill-new":"^3.6.0","react-resizable":"^3.0.5",uuid:"^11.1.0"},ku={"@babel/core":"^7.20.12","@commitlint/cli":"^17.0.3","@commitlint/config-conventional":"^17.0.3","@rollup/plugin-babel":"^6.0.4","@rollup/plugin-commonjs":"^28.0.0","@rollup/plugin-typescript":"^11.1.6","@storybook/addon-actions":"6.3.6","@storybook/addon-essentials":"6.4.9","@storybook/addon-interactions":"^6.5.16","@storybook/addon-links":"6.3.5","@storybook/addon-postcss":"2.0.0","@storybook/builder-vite":"^0.4.0","@storybook/node-logger":"6.4.9","@storybook/react":"6.4.9","@storybook/testing-library":"^0.0.13","@types/lodash":"^4","@types/react":"^18","@types/react-dom":"^18","@typescript-eslint/eslint-plugin":"^5.35.1","@typescript-eslint/parser":"^5.35.1","@vitejs/plugin-react":"^3.1.0",antd:"^4.24.0","babel-loader":"^8.3.0","babel-plugin-import":"^1.13.8",commitizen:"^4.3.0","css-loader":"^6.7.3","cz-conventional-changelog":"^3.3.0","cz-customizable":"^7.0.0",eslint:"^8.0.1","eslint-config-prettier":"^8.5.0","eslint-config-standard-with-typescript":"^22.0.0","eslint-plugin-import":"^2.25.2","eslint-plugin-n":"^15.0.0","eslint-plugin-promise":"^6.0.0","eslint-plugin-react":"^7.31.0","eslint-plugin-storybook":"^0.6.10",husky:">=6",less:"^4.1.2","less-loader":"^11.1.0","lint-staged":">=10","postcss-loader":"^7.2.4",prettier:"2.7.1","require-from-string":"^2.0.2","rollup-plugin-visualizer":"^6.0.1","storybook-less-loader":"^0.1.0",typescript:"*",vite:"^4.1.1","vite-plugin-css-injected-by-js":"^3.5.0","vite-plugin-dts":"^4.3.0","vite-plugin-externalize-deps":"^0.9.0"},Uu=[">0.2%","not dead","not op_mini all"],pu=["last 1 chrome version","last 1 firefox version","last 1 safari version"],bu={commitizen:{path:"node_modules/cz-customizable"},"cz-customizable":{config:".cz-config.cjs"}},vu={access:"public",registry:"https://registry.npmjs.org/"},Gu={hooks:{"commit-msg":"validate-commit-msg"}},Pu={name:Cu,version:Ou,module:xu,main:Yu,typings:wu,exports:Eu,files:hu,type:Qu,types:Su,scripts:mu,dependencies:fu,devDependencies:ku,"lint-staged":{"*.{js,css,md,jsx,less,ts,tsx,json}":"prettier --write"},production:Uu,development:pu,config:bu,publishConfig:vu,husky:Gu};var Ys=(M=>(M.dev="https://aiot-dev.glodon.com/api/cvforcepd",M.test="https://aiot-dev.glodon.com/api/cvforce",M.prod="https://copilot.glodon.com/api/cvforce",M.local="http://localhost:3000/api/cvforcepd",M))(Ys||{});//! moment.js
17
17
  //! version : 2.30.1
18
18
  //! authors : Tim Wood, Iskren Chernev, Moment.js contributors
19
19
  //! license : MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glodon-aiot/agent-cli-ui",
3
- "version": "3.26.0-alpha.18",
3
+ "version": "3.26.0-alpha.20",
4
4
  "module": "./dist/es/index.mjs",
5
5
  "main": "./dist/lib/index.js",
6
6
  "typings": "./dist/src/index.d.ts",
@@ -31,9 +31,9 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@ant-design/icons": "^5.3.4",
34
- "@glodon-aiot/apis": "^3.26.0-alpha.18",
35
- "@glodon-aiot/bot-client-sdk": "^3.26.0-alpha.18",
36
- "@glodon-aiot/react-components": "^3.26.0-alpha.18",
34
+ "@glodon-aiot/apis": "^3.26.0-alpha.20",
35
+ "@glodon-aiot/bot-client-sdk": "^3.26.0-alpha.20",
36
+ "@glodon-aiot/react-components": "^3.26.0-alpha.20",
37
37
  "@matejmazur/react-mathjax": "^0.1.10",
38
38
  "@react-pdf-viewer/core": "^3.12.0",
39
39
  "@react-pdf-viewer/default-layout": "^3.12.0",