@glodon-aiot/agent-cli-ui 3.26.0-alpha.24 → 3.26.0-alpha.26

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
@@ -6960,7 +6960,7 @@ const is = Qe((M, e) => {
6960
6960
  })]
6961
6961
  })
6962
6962
  });
6963
- }), Ds = "@glodon-aiot/agent-cli-ui", zs = "3.26.0-alpha.24", gs = "./dist/es/index.mjs", ns = "./dist/lib/index.js", Is = "./dist/src/index.d.ts", us = {
6963
+ }), Ds = "@glodon-aiot/agent-cli-ui", zs = "3.26.0-alpha.26", gs = "./dist/es/index.mjs", ns = "./dist/lib/index.js", Is = "./dist/src/index.d.ts", us = {
6964
6964
  import: "./dist/es/index.mjs",
6965
6965
  require: "./dist/lib/index.js",
6966
6966
  types: "./dist/src/index.d.ts"
@@ -6982,9 +6982,9 @@ const is = Qe((M, e) => {
6982
6982
  commit: "cz"
6983
6983
  }, as = {
6984
6984
  "@ant-design/icons": "^5.3.4",
6985
- "@glodon-aiot/apis": "^3.26.0-alpha.24",
6986
- "@glodon-aiot/bot-client-sdk": "^3.26.0-alpha.24",
6987
- "@glodon-aiot/react-components": "^3.26.0-alpha.24",
6985
+ "@glodon-aiot/apis": "^3.26.0-alpha.26",
6986
+ "@glodon-aiot/bot-client-sdk": "^3.26.0-alpha.26",
6987
+ "@glodon-aiot/react-components": "^3.26.0-alpha.26",
6988
6988
  "@matejmazur/react-mathjax": "^0.1.10",
6989
6989
  "@react-pdf-viewer/core": "^3.12.0",
6990
6990
  "@react-pdf-viewer/default-layout": "^3.12.0",
package/dist/lib/index.js CHANGED
@@ -13,7 +13,7 @@
13
13
  ${i}`:i}if(e&&e.length>0){const s=e.filter(Boolean).map(D=>`![](${D})`).join(`
14
14
  `);i=s?`${s}
15
15
  ${i}`:i}}return i},Ug=M=>{const e=Math.floor(M/3600),N=Math.floor(M%3600/60),t=M%60,i=s=>String(s).padStart(2,"0");return`${i(e)}:${i(N)}:${i(t)}`},pg=z.forwardRef((M,e)=>{var Mj,ej,Nj,tj,ij,jj,sj,Dj,zj,nj,gj,uj,Ij,Tj,cj,rj;const{application:N,docViewerUrl:t="",currentSession:i,onCreateSession:s,embeddingService:D,setCurrentSession:n,networkStatus:g,setNetworkStatus:I}=M,[u,o]=z.useState([]),[y,a]=z.useState([]),[T,L]=z.useState(!1),[d,O]=z.useState(null),w=z.useRef(0),[k,S]=z.useState(),[U,_]=z.useState(),R=z.useRef(null),q=z.useRef(!0),E=z.useRef(!1),eM=z.useRef(!1),{service:G,agentClient:p,depId:F,footer:jM,transform:v,defaultInput:yM,onMessage:mM,onHistoryLoad:LM,beforeMessageSend:rM,bodyStyle:PM,disabled:xM,features:f,popupContainer:x,icon:NM,sider:AM,mode:UM,silencedSeconds:HM,localFilesUI:$,localFilesApprovalBridge:YM}=z.useContext(JM),lM=N.type===Z.ApplicationTypes.Agent&&$?p==null?void 0:p.localWorkspace:void 0,[tM]=xs(lM),C=Ye.useMemoizedFn(()=>(x==null?void 0:x.current)||document.body),[B,J]=z.useState(!1),m=z.useRef(u),uM=z.useRef(void 0),A=z.useRef(new Set),[Y,h]=z.useState(0),[H,K]=z.useState([]),[V,dM]=z.useState([]),[CM,SM]=z.useState(0),[pM,ge]=z.useState(!1);z.useEffect(()=>{ge(CM>0)},[CM]);const bM=z.useRef(null),[fM,Ne]=z.useState([]),[qM,de]=z.useState(!1),[uN,OD]=z.useState(!1),[xD,YD]=z.useState(""),[wD,Ke]=z.useState(),[qe,IN]=z.useState({}),TN=z.useRef(null),fi=z.useRef(null),lt=z.useRef(null),[mi,ED]=z.useState(!1),[hD,QD]=z.useState([]),[SD,pN]=z.useState(!0),[fD,mD]=z.useState(!0),[ki,oe]=z.useState(!1),[dt,Ce]=z.useState(!1),[kD,Ct]=z.useState(!1),[ue,cN]=z.useState(typeof(f==null?void 0:f.promptVariables)=="object"?f.promptVariables.default||[]:[]),[UD,pD]=z.useState(()=>{const c=typeof(f==null?void 0:f.knowledges)=="object"&&f.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(et(c)>ve)throw Error(`knowledges and fileIds total count cannot exceed ${ve}`)}return c}),[Ui,We]=z.useState(!1),[pi,rN]=z.useState(!1),[bD,aN]=z.useState(typeof(f==null?void 0:f.connectNetwork)=="object"&&typeof(f==null?void 0:f.connectNetwork.default)=="boolean"?f.connectNetwork.default:!1),[bi,bN]=z.useState(!1),[vD,ke]=z.useState(!1),[GD,PD]=z.useState(null),[vN,Ze]=z.useState(!1),[vi,Gi]=z.useState(!1),{isSwitchingToExistingSession:Pi,setIsSwitchingToExistingSession:GN}=ni(),MN=z.useRef(null),[Ot,RD]=z.useState("");z.useEffect(()=>{if(!HM)return;let c=Ug(HM);RD(c)},[HM]);const oN=wn((Mj=f==null?void 0:f.botMessageBox)==null?void 0:Mj.artifacts),PN=oN.visible,xt=Ye.useMemoizedFn(c=>gM(exports,null,function*(){var W,sM,iM;if(!PN)return;const l=i,Q=c||((W=l==null?void 0:l.data)==null?void 0:W.id);if(!l||!Q||((sM=l.data)==null?void 0:sM.id)!==Q)return;const P=++w.current;try{const kM=yield l.getArtifacts();if(P!==w.current||((iM=i==null?void 0:i.data)==null?void 0:iM.id)!==Q)return;a(kM||[])}catch(kM){}}));z.useEffect(()=>{if(PD(i),i===null)ke(!1);else if(i===void 0)ke(!0);else{if(GD===null){if(Pi){ke(!0),GN(!1);return}ke(!1);return}i.ready?ke(!1):ke(!0)}},[i,i==null?void 0:i.ready,Pi]);const[Yt,WD]=z.useState(null),Ri=z.useRef(null);z.useEffect(()=>{var c;WD((c=x==null?void 0:x.current)!=null?c:null)},[x]),z.useEffect(()=>{d&&L(!0)},[d]),z.useEffect(()=>{var l;const c=(l=i==null?void 0:i.data)==null?void 0:l.id;w.current+=1,a([]),L(!1),O(null),c&&PN&&xt(c)},[(ej=i==null?void 0:i.data)==null?void 0:ej.id,PN]),z.useEffect(()=>{var Q,P;i&&(m.current=[]),o([]),q.current=!0,E.current=!1;const c=R.current;if(c&&c.scrollTo({top:0}),!((Q=i==null?void 0:i.data)!=null&&Q.id))return;if(Ce(!1),oe(!1),(P=i.messages)!=null&&P.length){const sM=[...i.messages.filter(iM=>iM==null?void 0:iM.messageId)].reverse();m.current=[...sM],o([...sM]),ke(!1)}const l=W=>{var sM;(sM=i==null?void 0:i.data)!=null&&sM.id&&(m.current=[...W].reverse(),o([...W].reverse()),!W||W.length<10?rN(!1):rN(!0),ke(!1),LM&&LM({applicationId:N.id,sessionId:i.data.id,histories:W}))};return i.addEventListener("history:loaded",l),()=>{m.current=[],o([]),i==null||i.removeEventListener("history:loaded",l)}},[i]),z.useEffect(()=>{const c=()=>{var l;(l=i==null?void 0:i.data)!=null&&l.id&&(i.promptVariables&&cN(i.promptVariables.sort((Q,P)=>Q.key.localeCompare(P.key))),i.knowledges&&pD(i.knowledges),I(i.netOpen))};return i==null||i.addEventListener("data:updated",c),()=>{i==null||i.removeEventListener("data:updated",c)}},[i]),z.useEffect(()=>{var l;if(!((l=i==null?void 0:i.data)!=null&&l.id))return;const c=Q=>{var P;console.error(Q.message,Q.cause,"e.case"),r.notification.config({getContainer:()=>(x==null?void 0:x.current)||document.body,prefixCls:"gbot-notification"}),r.notification.error({message:((P=Q.cause)==null?void 0:P.message)||Q.message}),r.notification.config({getContainer:void 0,prefixCls:"gbot-notification"})};return i.addEventListener("error",c),()=>{i==null||i.removeEventListener("error",c)}},[i]);const ZD=()=>{var Q;if(!((Q=i==null?void 0:i.data)!=null&&Q.id)||!(N!=null&&N.id))return;const c=i.data.id,l=u[u.length-1];if(l&&l.isContext){te("success","已开启新话题");return}else i.clear().then(()=>{const P=new Be("",c,Z.IHistoryRole.System);P.isContext=!0,o([P,...u])})};z.useEffect(()=>{N!=null&&N.id&&(G==null||G.getRecommendQues(N.id).then(c=>{Ne(c)}))},[F,N]);const wt=c=>gM(exports,null,function*(){var Me,TM;if(xM)return te("error","发送功能被禁用"),!1;const l=c||k;if(!(l!=null&&l.trim()))return te("error","请输入你想问的"),!1;if(!(ue==null?void 0:ue.every(ZM=>!!(ZM!=null&&ZM.value)))){if(v!=null&&v.promptVariables)return te("error","变量值不能为空"),!1;console.error("变量值不能为空",ue==null?void 0:ue.map(ZM=>!!(ZM!=null&&ZM.value)))}if(dt)return te("error","正在回复中"),!1;if(B)return te("error","等待初始化"),!1;if(!SD)return te("error","正在解析文件"),!1;if(pM)return te("error","正在上传图片"),!1;K([]),dM([]);const P=(Me=i==null?void 0:i.data)==null?void 0:Me.id;if(!P)return vN?!1:(Ze(!0),s==null||s({netOpen:g?pe.OPEN:pe.CLOSE}).then(ZM=>{var IM,XM;We(!0),I(!!((IM=ZM.data)!=null&&IM.netOpen)),aN(!!((XM=ZM.data)!=null&&XM.enableNetOpen)),Et(ZM).then(()=>{n==null||n(ZM),We(!1),_(l)})}).catch(ZM=>{Ze(!1)}),!0);if(vN)return!1;Ze(!0),bN(!0);const W=Pt(l,V,qe[P],(N==null?void 0:N.type)||0);let sM;try{rM?sM=yield rM==null?void 0:rM({applicationId:N.id,sessionId:P,message:{content:W,sessionId:P,role:Z.ChatMessageRole.User,files:qe[P]}}):sM=!0}catch(ZM){sM=!1}if(bN(!1),sM===!1)return Ze(!1),!1;let iM=l;typeof sM=="object"&&(iM=sM.content||l);const vM=yield(()=>new Promise(ZM=>{cN(IM=>(ZM(IM),IM))}))();return(yield i.setPromptVariables(vM))?(((TM=qe[P])==null?void 0:TM.length)>0?yield _D(iM):yield ht(iM),!0):(Ze(!1),!1)}),Et=c=>new Promise((l,Q)=>gM(exports,null,function*(){const sM=(c==null?void 0:c.promptVariables).filter(iM=>iM.type?!((iM.type===Z.PromptVariableType.User||iM.type===void 0)&&iM.key==="query")&&!((iM.type===Z.PromptVariableType.System||iM.type===void 0)&&iM.key==="datetime"):iM.key!=="query").map(iM=>{var vM;const kM=(vM=ue.find(DM=>DM.key===iM.key&&DM.type===iM.type))==null?void 0:vM.value;return iM.value=kM||"",iM});cN(sM.sort((iM,kM)=>iM.key.localeCompare(kM.key))),yield c==null?void 0:c.setPromptVariables(sM).catch(iM=>{console.error(iM),te("error",iM.message)}),l()})),_D=c=>{var W,sM,iM;if(pN(!1),!((W=i==null?void 0:i.data)!=null&&W.id)||!(N!=null&&N.id))return;const l=((sM=i.data)==null?void 0:sM.id)||"";let Q=[],P=new Set;return(iM=qe[l])==null||iM.forEach(kM=>{P.has(kM.id)||(Q.push(kM),P.add(kM.id))}),pN(!0),ht(c,Q)};z.useEffect(()=>{if(!U||!i)return;const c=U,l=()=>gM(exports,null,function*(){bN(!0);const Q=Pt(c,V,qe[i.id],(N==null?void 0:N.type)||0);let P;try{rM?P=yield rM==null?void 0:rM({applicationId:N.id,sessionId:i.id,message:{content:Q,sessionId:i.id,role:Z.ChatMessageRole.User,files:qe[i.id]}}):P=!0}catch(W){P=!1}if(bN(!1),P===!1){Ze(!1);return}ht(c),_(void 0)});return i.ready?l():i.addEventListener("ready",l,!0),()=>{i==null||i.removeEventListener("ready",l)}},[U,i]);const ht=(c,l)=>gM(exports,null,function*(){var Me,TM,ZM;const Q=(Me=i==null?void 0:i.data)==null?void 0:Me.id;if(!Q)return;Ce(!0),oe(!0);const P=Pt(c,V,l,(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&&((TM=N.arrange)!=null&&TM.length)&&N.arrange[0].visionOpen){const IM=V&&V.length?V.filter(Boolean):[];W=IM.length?IM:void 0}else W=void 0;const sM=new Be(P,Q,Z.IHistoryRole.User,l,W);S(void 0),Ke(void 0),m.current=[sM,...u],o(m.current),N.id&&mM&&mM({applicationId:N.id,sessionId:Q,message:sM});const iM=new Be("",Q,Z.IHistoryRole.System);iM.isWaiting=!0,m.current=[iM,...m.current],o(m.current);const kM=(l==null?void 0:l.filter(IM=>!IM.localAttachment).map(IM=>IM.id))||[],vM={stream:be.configuration.stream,referenceFirst:!1};if(v!=null&&v.promptVariables){const IM=ue==null?void 0:ue.reduce((XM,Ue)=>(XM[Ue.key]=Ue.value,XM),{});vM.formatValues=IM}if(v!=null&&v.knowledges){const IM=UD;vM.knowledges=IM}const DM={text:P,fileIds:kM,files:l,uuid:sM.messageId};W&&W.length>0&&(DM.imageContent=W),i.ready||(yield new Promise(IM=>{i.addEventListener("ready",()=>IM(),!0)})),yield i.send(DM,vM),IN({[Q]:[]}),(ZM=TN.current)==null||ZM.update({keepLocalAttachments:!1}),K([]),dM([]),Ze(!1)});z.useEffect(()=>{var vM;const c=(vM=i==null?void 0:i.data)==null?void 0:vM.id;if(!c)return;let l=null,Q=null,P="";const W=()=>{l=null,Q&&(o([Q,...m.current]),Q=null)},sM=()=>{l!==null&&(cancelAnimationFrame(l),l=null,Q=null)},iM=DM=>{if(!DM.sessionId||DM.sessionId&&DM.sessionId!==uM.current)return;if(DM.role===Z.IHistoryRole.User){if(m.current.some(yN=>yN.messageId&&yN.messageId===DM.messageId))return;const XM=new Be(DM.content,c,Z.IHistoryRole.User,DM.files,DM.imageContent);XM.messageId=DM.messageId||XM.messageId,XM.renderKey=XM.messageId;const Ue=new Be("",c,Z.IHistoryRole.System);Ue.isWaiting=!0,m.current=m.current.filter(yN=>!yN.isWaiting),m.current=[Ue,XM,...m.current],o(m.current),oe(!0),Ce(!0),N.id&&mM&&mM({applicationId:N.id,sessionId:c,message:XM});return}if(DM.index===-1&&DM.code!==200&&DM.code!==11915&&DM.code!==11916&&(sM(),oe(!1),Ce(!1),m.current=m.current.filter(IM=>!IM.isWaiting),o([...m.current]),m.current=[...m.current],DM.content)){r.notification.config({getContainer:()=>(x==null?void 0:x.current)||document.body,prefixCls:"gbot-notification"}),r.notification.error({message:DM.content}),r.notification.config({getContainer:void 0,prefixCls:"gbot-notification"});return}const Me=DM.actions||[],TM=new Be(DM.content,c,Z.IHistoryRole.Robot);TM.reasoningContent=DM.reasoningContent,TM.searchReference=DM.searchReference,TM.thinkingSecs=DM.thinkingSecs,TM.thinkingStatus=DM.thinkingStatus,TM.actions=Me,TM.isLoading=!0,TM.searchingStatus=DM.searchingStatus;const ZM=m.current.some(IM=>IM.isWaiting);if(m.current=m.current.filter(IM=>!IM.isWaiting).filter(IM=>!IM.isReplying),ZM&&(P=""),TM.renderKey=P||DM.messageId||TM.messageId,P=TM.renderKey,TM.messageId=DM.messageId||TM.renderKey,DM.index===void 0){Q=TM,l===null&&(l=requestAnimationFrame(W));return}if(sM(),(DM.code===11915||DM.code===11916)&&(oe(!1),Ce(!1),TM.isLoading=!1,TM.content=DM.code===11916?"尊敬的用户您好,让我们换个话题再聊聊吧。":"请您换个问题问我吧~",TM.isSensitive=!0,o([TM,...m.current])),DM.index===-2&&(oe(!1),Ce(!1),TM.isLoading=!1,TM.content="回答已中止~",TM.isSuspend=!0,o([TM,...m.current]),xt(c)),DM.index===-1&&(oe(!1),Ce(!1),TM.isLoading=!1,TM.reference=DM.reference,o([TM,...m.current]),DM.code===200&&xt(c),N.id)){const IM=TM.messageId;A.current.has(IM)||(A.current.add(IM),mM&&mM({applicationId:N.id,sessionId:c,message:TM}))}DM.index===-3&&(oe(!1),Ce(!1),TM.isLoading=!1,TM.reference=DM.reference,TM.relatedQuesion=DM.relatedQuesion,o([TM,...m.current]))},kM=()=>{i.addEventListener("message:updated",iM)};return i.ready?i.addEventListener("message:updated",iM):i.addEventListener("ready",kM),()=>{sM(),i==null||i.removeEventListener("message:updated",iM),i==null||i.removeEventListener("ready",kM)}},[i]),z.useEffect(()=>{if(!i){J(!1);return}const c=l=>{J(l)};return J(i.frozen),i.addEventListener("frozen",c),()=>{i==null||i.removeEventListener("frozen",c)}},[i]),z.useEffect(()=>{if(!p)return;const c=p.questionContextMaxLength||4e3;h(c)},[p,G]),z.useEffect(()=>{yM&&Ke(yM.text)},[yM]);const te=(c,l,Q)=>{je(x,()=>{r.message.open({type:c,content:l,key:Q})})},Wi=c=>{const l=c.size;return l<=0?(te("error","该文件为空,请重新上传"),!1):l>Gt*Mt?(te("error",`图片须小于${Gt}M`),!1):(K(Q=>Q.length>=Je?(te("warning",`图片最多上传${Je}张`),Q):[...Q,c]),!1)},BD=()=>{var c;return(N.type===Z.ApplicationTypes.Agent&&(v==null?void 0:v.imageUpload)||N.type===Z.ApplicationTypes.Dialog&&((c=N.arrange)==null?void 0:c.length)&&!!N.arrange[0].visionOpen&&(v==null?void 0:v.imageUpload))&&!xM},JD=()=>!!D&&(v==null?void 0:v.fileUpload)&&(N==null?void 0:N.id)&&!xM,Zi=c=>{var TM,ZM;const l=Array.from(c||[]).filter(Boolean);if(!l.length)return;const Q=BD(),P=JD(),W=[],sM=[];let iM=0,kM=0,vM=0;l.forEach(IM=>{var aj,oj,yj;const XM=(oj=(aj=IM.name)==null?void 0:aj.split(".").pop())==null?void 0:oj.toLowerCase();if(us(IM)){P&&N.type===Z.ApplicationTypes.Agent?sM.push(IM):vM++;return}if(((yj=IM.type)==null?void 0:yj.startsWith("image/"))||!!xj(IM.name)){Q?W.push(IM):iM++;return}if(ns.includes(IM.type)||["pdf","doc","docx"].includes(XM||"")){P?sM.push(IM):kM++;return}vM++});const DM=[],Me=iM+kM+vM;if(!P&&!Q)Me&&DM.push(`当前不支持上传文件/图片,已忽略${Me}个文件`);else if(P&&!Q){const IM=iM+vM;if(IM){const XM=N.type===Z.ApplicationTypes.Agent?".doc/.docx/.pdf/.xls/.xlsx/.svg/.dwg/.json":".doc/.docx/.pdf";DM.push(`仅支持上传 ${XM} 文件,已忽略${IM}个其他类型文件`)}}else if(!P&&Q){const IM=kM+vM;IM&&DM.push(`仅支持上传图片(.jpg/.jpeg/.png/.bmp),已忽略${IM}个其他类型文件`)}else vM&&DM.push(`存在不支持的文件类型,已忽略${vM}个文件`);if(DM.length&&te("warning",DM.join(";"),"precheck-warn"),W.length){const IM=Math.max(0,Je-H.length),XM=W.slice(0,IM);XM.forEach(Ue=>Wi(Ue)),W.length>XM.length&&te("warning",`最多上传${Je}张图片`)}sM.length&&((ZM=(TM=TN.current)==null?void 0:TM.appendFiles)==null||ZM.call(TM,sM))},_i=c=>{var Q;const l=(Q=c.clipboardData)==null?void 0:Q.files;l&&l.length&&(c.preventDefault(),c.stopPropagation(),Zi(l))},Bi=c=>{c.preventDefault()},Ji=c=>{var Q;c.preventDefault(),c.stopPropagation();const l=(Q=c.dataTransfer)==null?void 0:Q.files;l&&l.length&&Zi(l)},Fi=()=>gM(exports,null,function*(){var c;return(c=i==null?void 0:i.data)!=null&&c.id?i:(MN.current||(MN.current=new Promise((l,Q)=>{We(!0),s==null||s({netOpen:g?pe.OPEN:pe.CLOSE}).then(P=>{var W,sM;n==null||n(P),We(!1),I(!!((W=P.data)!=null&&W.netOpen)),aN(!!((sM=P.data)!=null&&sM.enableNetOpen)),Et(P),l(P)}).catch(P=>{MN.current=null,Q(P)})})),MN.current)}),FD=c=>gM(exports,null,function*(){const l=yield Fi();return HD(l,c)}),HD=(c,l)=>{const Q=xj(l.name);return new Promise(P=>{var sM;const W={files:[`${DN.v4()}.${Q}`],isv:"minio",knowledgeId:((sM=c.data)==null?void 0:sM.id)||"",type:1};G==null||G.postTicket(W).then(iM=>{G.uploadMinioFile(iM.minio,l).then(()=>{var Me,TM;const kM=(Me=iM.minio.endpoints)==null?void 0:Me[0],vM=iM.minio.bucket,DM=(TM=iM.minio.fileKeys)==null?void 0:TM[0];P(`${iM.minio.useSSL?"https:":location.protocol}//${kM}/${vM}/${DM}`)}).catch(()=>{})}).catch(()=>{})})},VD=()=>{const c=R.current;!c||!q.current||c.scrollTo({top:c.scrollHeight})};z.useLayoutEffect(()=>{VD()},[u]),z.useEffect(()=>{const c=()=>{eM.current=!1;const l=R.current;(!l||l.scrollTop>-80)&&(E.current=!1)};return window.addEventListener("pointerup",c),()=>window.removeEventListener("pointerup",c)},[]);const Hi=(c,l)=>new Promise(Q=>{if(!l.file.url||!(N!=null&&N.id))return Q();const P=BM(zM({},l.file),{type:1});G==null||G.postApplicationIdSessionKnowledgeSessionFile(N==null?void 0:N.id,c,P).finally(()=>{var W;(W=TN.current)==null||W.update().finally(Q)})}),XD=()=>{var c;(c=i==null?void 0:i.data)!=null&&c.id&&(oe(!1),i.suspend())},$D=c=>{const l=R.current;l&&(q.current=!0,E.current=!1,Ct(!1),setTimeout(()=>{l.scrollTo({top:l.scrollHeight,behavior:c==null?void 0:c.behavior})},c==null?void 0:c.ms))},Vi=()=>{E.current=!0},KD=c=>{var Q;const l=(Q=c.target)==null?void 0:Q.closest(".bottom-right");l instanceof HTMLElement&&l.scrollHeight>l.clientHeight+1||(Vi(),requestAnimationFrame(()=>{const P=R.current;E.current&&P&&P.scrollTop>-80&&(E.current=!1)}))},qD=c=>{const l=c.currentTarget,{offsetX:Q,offsetY:P}=c.nativeEvent;(Q>l.clientWidth||P>l.clientHeight)&&(eM.current=!0,Vi())},Mz=()=>{const c=R.current;if(!c)return;if(!(c.scrollTop<=-80)){q.current=!0,E.current=!1,Ct(!1);return}(E.current||eM.current)&&(q.current=!1,E.current=!1,Ct(!0))},ez=Ye.useMemoizedFn(c=>{var l,Q;(l=bM.current)==null||l.update(c),(Q=bM.current)==null||Q.focus()}),Nz=Ye.useMemoizedFn(c=>{wt(c)}),tz=Ye.useMemoizedFn(()=>{var l;if(!((l=i==null?void 0:i.data)!=null&&l.id))return;m.current=[...u.slice(1,u.length)],o(m.current);const c=new Be("",i.data.id,Z.IHistoryRole.System);c.isWaiting=!0,m.current=[c,...m.current],o(m.current),Ce(!0),oe(!0),i.answerAgain()});z.useEffect(()=>{var c,l;uM.current=(c=i==null?void 0:i.data)==null?void 0:c.id,!Ui&&((l=lt.current)==null||l.clear())},[i]);const iz=()=>{var Q;if(!((Q=i==null?void 0:i.data)!=null&&Q.id))return;const l=u[u.length-1].messageTime;i.fetchMessages({endTime:l,pageSize:Pj}).then(P=>{const W=P||[];if(!W||!(W!=null&&W.length)){rN(!1);return}W.length<10?rN(!1):rN(!0),o([...u,...W.reverse()])})},jz=c=>gM(exports,null,function*(){var l,Q;if(!((l=i==null?void 0:i.data)!=null&&l.id))I(c);else{if(yield i.setNetOpen(c),!((Q=i.data)!=null&&Q.id))return;I(c)}}),Qt=()=>gM(exports,null,function*(){i?i.fetchData().then(c=>{var l;(l=i==null?void 0:i.data)!=null&&l.id&&(I(c.netOpen),aN(c.enableNetOpen))}):(I(typeof(f==null?void 0:f.connectNetwork)=="object"&&typeof(f==null?void 0:f.connectNetwork.default)=="boolean"?f.connectNetwork.default:!1),aN(N.arrange[0].enableNetOpen))});z.useEffect(()=>{Qt()},[i]),z.useEffect(()=>{let c=null,l=null;const Q=()=>{var DM,Me;if(!R.current)return;const W=document.getElementById("chat-main"),sM=(DM=R.current)==null?void 0:DM.querySelector(".infinite-scroll-component__outerdiv"),iM=(Me=R.current)==null?void 0:Me.querySelector(".infinite-scroll-component");if(!sM||!iM||!W)return;const kM=W.offsetHeight;if(iM.offsetHeight<=kM){if(sM.style.height==="100%")return;sM.style.height="100%"}else{if(sM.style.height==="auto")return;sM.style.height="auto"}},P=()=>{var iM;if(typeof ResizeObserver=="undefined"||!R.current)return;const W=document.getElementById("chat-main"),sM=(iM=R.current)==null?void 0:iM.querySelector(".infinite-scroll-component");!sM||!W||(l=new ResizeObserver(()=>{Q()}),l.observe(sM),l.observe(W))};return c=requestAnimationFrame(()=>{Q(),P()}),()=>{c!==null&&cancelAnimationFrame(c),l==null||l.disconnect()}},[u]),z.useEffect(()=>{if(i)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,sM)=>{var kM,vM;let iM="";return typeof(f==null?void 0:f.promptVariables)=="object"&&(iM=((vM=(kM=f.promptVariables.default)==null?void 0:kM.find(DM=>DM.key===W.key&&DM.type===W.type))==null?void 0:vM.value)||""),{id:sM+"",key:W.key,name:W.name,value:iM,type:W.type}});cN([...P].sort((W,sM)=>W.key.localeCompare(sM.key)))};return p!=null&&p.ready?c():p==null||p.addEventListener("ready",c),()=>{p==null||p.removeEventListener("ready",c)}},[i,p,f==null?void 0:f.promptVariables]);const Xi=()=>s==null?void 0:s({netOpen:g?pe.OPEN:pe.CLOSE}).then(c=>{var l,Q;return n==null||n(c),We(!1),I(!!((l=c.data)!=null&&l.netOpen)),aN(!!((Q=c.data)!=null&&Q.enableNetOpen)),Et(c),c}),$i=!!u.length,Ki=z.useMemo(()=>{var c;return N.arrange&&((c=N.arrange[0])!=null&&c.openingContent)?j.jsx(as,{application:N,history:{role:1,content:N.arrange[0].openingContent,code:200,messageId:"opening-message",sessionId:"",reference:[],searchReference:[],messageTime:$M(Date.now()).format("YYYY-MM-DD HH:mm:ss"),actions:[],isLoading:!1},actions:$i,markdown:f==null?void 0:f.markdown}):null},[N==null?void 0:N.arrange,$i]);z.useImperativeHandle(e,()=>({getCurrentInputText:()=>{var c;return(c=bM.current)==null?void 0:c.getCurrentText()},send:c=>gM(exports,null,function*(){if(!(yield wt(c)))throw new Error("send was blocked")})})),z.useEffect(()=>{var l;const c=(l=i==null?void 0:i.data)==null?void 0:l.id;c&&IN(Q=>BM(zM({},Q),{[c]:[]}))},[(Nj=i==null?void 0:i.data)==null?void 0:Nj.id]);const St=!!lM&&($==null?void 0:$.picker)!==!1&&!(AM&&UM==="inlay"),qi=St&&UM==="float";return j.jsxs(j.Fragment,{children:[j.jsxs("div",{className:`agent-chat${St&&!qi?" with-workspace-tree":""}`,children:[St&&lM&&j.jsx(Es,{workspace:lM,disclosureText:$==null?void 0:$.disclosureText,disclosure:$==null?void 0:$.disclosure,getContainer:C,highlight:tM,disabled:xM,collapsible:qi}),j.jsxs("div",{className:"agent-chat-column",children:[vD?j.jsx("div",{className:"session-loading",children:j.jsx(r.Spin,{})}):j.jsxs(j.Fragment,{children:[(v==null?void 0:v.promptVariables)&&j.jsx(ls,{ref:fi,appId:N.id,currentSession:i,promptVariables:ue,setPromptVariables:cN,setCurrentSession:n}),j.jsxs("div",{className:"chat-main",id:"chat-main",style:PM,children:[j.jsx("div",{className:"chat-main-wrapper",id:"scrollableDiv",style:{height:"100%",overflowY:"auto",display:"flex",flexDirection:"column-reverse"},ref:R,onScroll:Mz,onWheel:KD,onPointerDown:qD,children:(tj=i==null?void 0:i.data)!=null&&tj.id&&(u!=null&&u.length)?j.jsxs(Iz,{dataLength:u.length,next:iz,style:{display:"flex",flexDirection:"column-reverse",overflowX:"hidden",overflowAnchor:"none"},inverse:!0,endMessage:u.length>Pj&&((ij=R.current)!=null&&ij.scrollTop)&&((jj=R.current)==null?void 0:jj.scrollTop)<-10?j.jsx(r.Divider,{plain:!0,children:"没有更多数据了"}):null,hasMore:pi,loader:j.jsx("div",{style:{height:"50px",textAlign:"center",overflow:"hidden"},children:j.jsx(r.Spin,{})}),scrollableTarget:"scrollableDiv",children:[u.map((c,l)=>j.jsx(kg,{application:N,currentSession:i,history:c,docViewerUrl:t,isLastHistory:l===0,onRelatedClick:Nz,onAgainClick:tz,onEditClick:ez,markdown:f==null?void 0:f.markdown},c.renderKey||`${c.messageId}-${l}`)),!pi&&Ki]}):j.jsxs("div",{className:"main-empty",children:[(f==null?void 0:f.greeting)!==!1&&j.jsx(pn,{text:f!=null&&f.greeting&&typeof f.greeting=="object"&&f.greeting.text!==void 0?f.greeting.text:(sj=N.arrange)!=null&&sj.length&&((Dj=N.arrange[0])!=null&&Dj.greetings)?N.arrange[0].greetings:Gj.text,icon:f===void 0||f.greeting===!0||((zj=f.greeting)==null?void 0:zj.icon)===void 0?NM||Gj.icon:f.greeting.icon,children:!!fM.length&&(((f==null?void 0:f.greeting)===void 0||(f==null?void 0:f.greeting))===!0||typeof(f==null?void 0:f.greeting)=="object"&&f.greeting.questions!==!1)&&j.jsx(Ls,{ref:lt,sid:(nj=i==null?void 0:i.data)==null?void 0:nj.id,isRecommendClearing:qM,data:fM,layoutBreakpoints:typeof(f==null?void 0:f.greeting)=="object"?f.greeting.layoutBreakpoints:void 0,onItemClick:c=>{var Q,P,W;if(S(c==null?void 0:c.question),Ke(c==null?void 0:c.question),qM)return;c!=null&&c.id&&de(!0);const l=(Q=i==null?void 0:i.data)==null?void 0:Q.id;v!=null&&v.fileUpload?(W=(P=TN.current)==null?void 0:P.clear())==null||W.then(()=>{var sM,iM;c!=null&&c.id&&(l?(sM=Hi(l,c))==null||sM.finally(()=>{de(!1)}):(de(!1),We(!0),(iM=Xi())==null||iM.then(kM=>{var vM;(vM=Hi(kM.id,c))==null||vM.finally(()=>{de(!1)})})))}):l?de(!1):(de(!1),We(!0),Xi())}})}),Ki]})}),ki&&j.jsx("div",{className:"session-stop",children:j.jsx(r.Button,{type:"primary",style:{background:"white"},ghost:!0,size:"small",icon:j.jsx(oM,{type:"icon-zantinghuida",style:{fontSize:16}}),onClick:()=>XD(),children:"停止回答"})}),kD&&(u==null?void 0:u.length)>0&&j.jsx("div",{className:"back-bottom",children:j.jsx(r.Button,{size:"small",onClick:()=>$D({behavior:"smooth"}),type:"link",icon:j.jsx(oM,{type:"icon-yijianhuidaodibu",style:{fontSize:24}})})})]}),j.jsx("div",{className:"chat-footer",children:j.jsxs("div",{className:"chat-footer-input",children:[H.length>0&&j.jsx("div",{className:"input-files",children:H.map((c,l)=>j.jsx(mn,{className:"thumb-40",file:c,actions:{upload:Q=>gM(exports,null,function*(){SM(P=>P+1);try{return yield FD(Q)}finally{SM(P=>Math.max(0,P-1))}}),remove:()=>{K(Q=>Q.filter((P,W)=>W!==l)),dM(Q=>Q.filter((P,W)=>W!==l))}},onUrlChange:Q=>{dM(P=>{const W=[...P];return W[l]=Q,W})}},l))}),lM&&j.jsx(fg,{workspace:lM}),lM&&YM&&j.jsx(Qg,{bridge:YM,getContainer:C}),j.jsxs("div",{className:"footer-upload-action-wrapper",children:[j.jsxs(r.Space,{className:"footer-upload-action",onClick:c=>c.preventDefault(),children:[j.jsxs(r.Space,{children:[(N.type===Z.ApplicationTypes.Agent&&(v==null?void 0:v.imageUpload)||N.type===Z.ApplicationTypes.Dialog&&((gj=N.arrange)==null?void 0:gj.length)&&!!N.arrange[0].visionOpen&&(v==null?void 0:v.imageUpload))&&j.jsx(r.Upload,{multiple:!0,disabled:H.length>=Je||xM,accept:".jpg, .png, .jpeg,.bmp",listType:"picture-card",beforeUpload:Wi,className:"footer-upload-picture",showUploadList:!1,children:H.length<Je?j.jsx(r.Tooltip,{placement:"topLeft",overlayClassName:"footer-upload-tooltip",title:j.jsx("div",{children:`支持上传.jpg .png .jpeg
16
- .bmp格式的图片数据,单文件最大${Gt}M,最多${Je}张`}),children:j.jsx(r.Button,{type:"text",className:"camera-out-btn",style:{width:"22px",position:"relative",bottom:"-2px"},icon:j.jsx(oM,{type:"icon-shangchuantupian",className:"icon-tianjia",style:{fontSize:"22px"}})})}):j.jsx(r.Button,{type:"text",className:"camera-out-btn",style:{width:"22px",position:"relative",bottom:"-2px"},disabled:!0,icon:j.jsx(oM,{type:"icon-shangchuantupian",className:"icon-tianjia",style:{fontSize:"22px"}})})}),D&&(v!=null&&v.fileUpload)&&(N!=null&&N.id)?j.jsx(As,{appId:N==null?void 0:N.id,allowExcelAttachment:N.type===Z.ApplicationTypes.Agent,ref:TN,isFirstSession:Ui,docViewerUrl:t,onStatusChange:c=>gM(exports,null,function*(){c!=="process"?(pN(!0),Qt()):pN(!1)}),createSession:()=>Fi().then(c=>{var Q;return((Q=c.data)==null?void 0:Q.id)||""}),sid:(uj=i==null?void 0:i.data)==null?void 0:uj.id,disabled:dt||xM,afterFileAdd:(c,l)=>{l&&IN(Q=>{const P=Q[l]||[];return{[l]:[...P,c]}})},afterFileDelete:c=>{var Q;const l=(Q=i==null?void 0:i.data)==null?void 0:Q.id;l&&IN(P=>{const W=P[l]||[];return{[l]:W.filter(sM=>sM.id!==c)}})},onFileListChange:c=>{QD(c)},shouldContinue:fD,afterFilesClear:()=>{var l;const c=(l=i==null?void 0:i.data)==null?void 0:l.id;c&&(IN({[c]:[]}),Qt())}}):null,(v==null?void 0:v.prompt)&&(N==null?void 0:N.id)&&j.jsx(eg,{appId:N.id,list:[],search:uN?xD:"",onPromptSelect:c=>{Ke(c.context),S(c.context)},disabled:xM})]}),j.jsxs(r.Space,{children:[(v==null?void 0:v.connectNetwork)&&N.type===Z.ApplicationTypes.Dialog&&((Ij=N.arrange)==null?void 0:Ij.length)&&!!N.arrange[0].enableNetOpen&&j.jsx(Vn,{sessionId:(Tj=i==null?void 0:i.data)==null?void 0:Tj.id,netStatus:g,enable:typeof(f==null?void 0:f.connectNetwork)=="object"&&typeof(f==null?void 0:f.connectNetwork.diabled)=="boolean"?!(f!=null&&f.connectNetwork.diabled):bD,disabledTip:i?void 0:"网络访问已被禁用",onNetStatusChange:c=>{jz(c)}}),(v==null?void 0:v.sessionList)&&j.jsx(Bn,{currentSessionId:(cj=i==null?void 0:i.data)==null?void 0:cj.id,onSessionChange:(c,l)=>{Ke(void 0),GN(!0),n==null||n(l)},disabled:xM}),AM&&UM==="float"&&j.jsx("div",{className:"session-history-drawer-component",children:j.jsx(r.Popover,{placement:"topRight",showArrow:!1,overlayClassName:"session-history-overlay",overlayStyle:{padding:"4px"},getPopupContainer:c=>c.parentNode,content:"会话历史记录",children:j.jsx(r.Button,{className:"history-overlay-action",disabled:xM,type:"text",icon:j.jsx(oM,{type:"icon-lishijilu",style:{fontSize:24}}),onClick:()=>Gi(!0)})})}),(v==null?void 0:v.sessionOpen)&&j.jsx(r.Button,{icon:j.jsx(cM.PlusOutlined,{}),className:"add-btn",type:"primary",disabled:ki||!i||!u.length||xM,onClick:()=>{var c,l;GN(!1),n==null||n(null),MN.current=null,I(!1),(c=fi.current)==null||c.clear(),(l=lt.current)==null||l.clear()},children:"新会话"})]})]}),!!Ot&&j.jsx("div",{className:"remainingSeconds-mark"})]}),j.jsxs("div",{className:"footer-textarea",onPaste:_i,onPasteCapture:_i,onDrop:Ji,onDropCapture:Ji,onDragOver:Bi,onDragOverCapture:Bi,children:[j.jsx(ys,{ref:bM,maxLength:Y,text:wD,networkStatus:!1,loading:bi||vN,disabled:B||pM||xM||bi||vN,onTextSend:wt,onChange:(c,l)=>{Ke(c);const Q=l.getText().replace(/[\n\s]+$/,"");S(Q),YD(Q),uN||OD(!0)},clearAction:j.jsx(r.Space,{size:0,children:j.jsx(r.Button,{type:"link",disabled:dt||xM,ghost:!0,icon:j.jsx(oM,{style:{fontSize:22},type:"icon-qingchujiyi"}),onClick:()=>ZD()})})}),!!Ot&&j.jsxs("div",{className:"remainingSeconds-time",children:["您之前对话触发敏感词拦截,当前处于禁言状态,暂时无法发送消息,剩余禁言时长",Ot]})]})]})}),j.jsx(vn,{tips:jM}),mi&&j.jsx(Rn,{isvisible:mi,files:hD,sessionId:(rj=i==null?void 0:i.data)==null?void 0:rj.id,onClose:c=>{ED(!1),mD(!1)}})]}),vi&&j.jsx(Hn,{currentSession:i,application:N,networkStatus:g,setCurrentSession:n,disabled:xM,isSessionHistoryVisible:vi,setIsSessionHistoryVisible:Gi,onSessionChange:c=>{GN(!0)}})]})]}),Yt&&PN&&y.length>0&&Ms.createPortal(j.jsxs("div",{className:"artifacts-dock",ref:Ri,children:[j.jsxs("div",{className:`artifacts-drawer${T?" is-open":""}`,children:[j.jsxs("button",{type:"button",className:"artifacts-handle",onClick:()=>L(c=>!c),children:[j.jsx("span",{className:"artifacts-handle-text",children:"产出物"}),T?j.jsx(cM.RightOutlined,{}):j.jsx(cM.LeftOutlined,{})]}),j.jsxs("div",{className:"artifacts-panel",children:[j.jsxs("div",{className:"artifacts-panel-main",children:[j.jsx("div",{className:"artifacts-panel-title",children:"产出物"}),j.jsx(xn,{artifacts:y,activeArtifact:d,onPreview:O})]}),oN.preview==="column"&&d&&j.jsx(fn,{artifact:d,style:oN.style,onClose:()=>O(null)})]})]}),j.jsx(Sn,{placement:oN.preview,artifact:d,style:oN.style,onClose:()=>O(null),getContainer:()=>Ri.current||Yt})]}),Yt)]})});const hs=M=>{const{disabled:e,checkedValues:N,currKnowledgeList:t,selectCount:i,onSelectChange:s}=M,[D,n]=z.useState(!1),g=j.jsx(r.Checkbox.Group,{style:{width:"100%"},onChange:s,value:N,disabled:e,children:j.jsx(r.Row,{gutter:[20,12],children:t==null?void 0:t.map(u=>j.jsx(r.Col,{span:24,children:j.jsx(r.Checkbox,{value:u.id,children:u.name})},u.id))})}),I=u=>{n(u)};return j.jsx("div",{className:"knowledge-select",style:{borderColor:D?"#9C24F2":"#84868C"},children:j.jsx(r.Popover,{className:"select-popover",placement:"bottomRight",title:null,content:g,trigger:"click",overlayStyle:{width:280},onOpenChange:I,getPopupContainer:u=>u.parentNode,children:j.jsxs("div",{className:"",onClick:u=>u.preventDefault(),children:[j.jsx(oM,{className:"select-icon",type:"icon-open"}),j.jsx("span",{className:"title",children:"参考知识库"}),j.jsxs("span",{className:"content",children:["已选 ",i," 个"]})]})})})},bg=M=>{var d,O;const{currentSession:e,application:N,setCheckKnowledges:t}=M,{mode:i,transform:s,features:D}=z.useContext(JM),[n,g]=z.useState([]),[I,u]=z.useState(typeof(D==null?void 0:D.knowledges)=="object"?((d=D.knowledges.default)==null?void 0:d.map(w=>w.id))||[]:[]),[o,y]=z.useState(0),[a,T]=z.useState(!1);z.useEffect(()=>{if(!(N!=null&&N.id))return;const w=N.arrange;if(!(w!=null&&w.length))return;const S=w[0].knowledges||[];g(S);const U=typeof(D==null?void 0:D.knowledges)=="object"&&D.knowledges.default||S;if(Array.isArray(U)&&U.some(E=>Array.isArray(E.fileIds)&&E.fileIds.length===0))throw Error("fileIds cannot be an empty array");if(et(U||[])>ve)throw Error(`knowledges and fileIds total count cannot exceed ${ve}`);if(!e){u(U.map(q=>q.id)),y(U.length),t==null||t(U);return}const R=()=>{const q=e.knowledges||U;y(q.length);const E=q.map(eM=>eM.id);u(E)};return R(),e.addEventListener("data:updated",R),()=>{e==null||e.removeEventListener("data:updated",R)}},[N,e]),z.useEffect(()=>{var k;if(!a||(T(!1),!(N!=null&&N.id)))return;const w=[];I==null||I.map(S=>{const U=n==null?void 0:n.find(_=>_.id===S);w.push(U)}),(k=e==null?void 0:e.data)!=null&&k.id&&e.setKnowledges(w)},[a]);const L=w=>{T(!0),u(w);const k=[];w==null||w.map(S=>{const U=n==null?void 0:n.find(_=>_.id===S);k.push(U)}),t==null||t(k),y(w.length)};return j.jsxs("div",{className:"chat-header",children:[j.jsxs(r.Space,{className:"header-title",children:[i==="inlay"&&((O=e==null?void 0:e.data)==null?void 0:O.name),i==="float"&&(N==null?void 0:N.name)]}),(s==null?void 0:s.knowledges)&&n.length!==0&&j.jsx(hs,{disabled:typeof(D==null?void 0:D.knowledges)=="object"&&(D==null?void 0:D.knowledges.diabled)||!1,checkedValues:I,currKnowledgeList:n,selectCount:o,onSelectChange:L})]})},Qs="gbot-sider-tab:";function Rj(M){try{return localStorage.getItem(Qs+M)==="sessions"?"sessions":"workspace"}catch(e){return"workspace"}}function vg(M,e){try{localStorage.setItem(Qs+M,e)}catch(N){}}const Ss=z.forwardRef((M,e)=>{const{application:N}=M,{agentClient:t,sider:i,mode:s,localFilesUI:D,disabled:n,popupContainer:g}=z.useContext(JM),I=N!=null?N:t==null?void 0:t.application,u=i&&s==="inlay"&&(I==null?void 0:I.type)===Z.ApplicationTypes.Agent&&D&&D.picker!==!1?t==null?void 0:t.localWorkspace:void 0,{status:o}=Os(u),[y]=xs(u),[a,T]=z.useState("workspace"),L=z.useRef(!1),d=z.useRef(!1);if(z.useEffect(()=>{if(!u)return;let w=!0;return u.ready.then(()=>{!w||L.current||d.current||u.status==="granted"&&(d.current=!0,T(Rj(u.applicationId)))}),()=>{w=!1}},[u]),z.useEffect(()=>{!u||u.isSupported||o!=="granted"||L.current||d.current||(d.current=!0,T(Rj(u.applicationId)))},[u,o]),z.useEffect(()=>{y&&T("workspace")},[y]),!u)return j.jsx(Nt,zM({ref:e},M));const O=w=>{L.current=!0,T(w),u.status==="granted"&&vg(u.applicationId,w)};return j.jsxs("div",{className:"sider-tabs",children:[j.jsxs("div",{className:"sider-tabs-bar",role:"tablist",children:[j.jsxs("button",{type:"button",role:"tab","aria-selected":a==="workspace",className:VM("sider-tab",{"is-active":a==="workspace"}),onClick:()=>O("workspace"),children:["工作区",y&&a!=="workspace"&&j.jsx("span",{className:"sider-tab-dot"})]}),j.jsx("button",{type:"button",role:"tab","aria-selected":a==="sessions",className:VM("sider-tab",{"is-active":a==="sessions"}),onClick:()=>O("sessions"),children:"会话记录"})]}),j.jsxs("div",{className:"sider-tabs-panels",children:[j.jsx("div",{className:VM("sider-tabs-panel",{"is-hidden":a!=="workspace"}),role:"tabpanel",children:j.jsx(Es,{workspace:u,disclosureText:D==null?void 0:D.disclosureText,disclosure:D==null?void 0:D.disclosure,getContainer:()=>(g==null?void 0:g.current)||document.body,highlight:y,disabled:n})}),j.jsx("div",{className:VM("sider-tabs-panel",{"is-hidden":a!=="sessions"}),role:"tabpanel",children:j.jsx(Nt,zM({ref:e},M))})]})]})});Ss.displayName="SiderTabs";const Gg=z.forwardRef((M,e)=>{const{sessionId:N,appId:t,docViewerUrl:i}=M,[s,D]=z.useState(),{showHeader:n,agentClient:g,sider:I,onSessionLoad:u,features:o,mode:y}=z.useContext(JM),[a,T]=z.useState(),L=z.useRef(null),[d,O]=z.useState(""),[w,k]=z.useState(),S=z.useRef(null),[U,_]=z.useState(!1);z.useState([]);const{setIsSwitchingToExistingSession:R}=ni();z.useEffect(()=>{var E;_(s?!!((E=s.data)!=null&&E.netOpen):typeof(o==null?void 0:o.connectNetwork)=="object"&&typeof(o==null?void 0:o.connectNetwork.default)=="boolean"?o.connectNetwork.default:!1)},[s]),z.useEffect(()=>{const E=()=>gM(exports,null,function*(){const eM=g==null?void 0:g.application;if(!(eM!=null&&eM.id))return;const G=eM==null?void 0:eM.arrange;if(!(G!=null&&G.length))return;const F=G[0].embeddingService;O(F),T(eM)});if(g!=null&&g.ready){E();return}return g==null||g.addEventListener("ready",()=>E()),()=>{g==null||g.removeEventListener("ready",E)}},[g]),z.useEffect(()=>{g&&N&&(g.ready?g==null||g.getSessions().then(E=>gM(exports,null,function*(){D==null||D(E.find(eM=>eM.id===N))})):g.addEventListener("ready",()=>gM(exports,null,function*(){g==null||g.getSessions().then(E=>gM(exports,null,function*(){D==null||D(E.find(eM=>eM.id===N))}))}),!0))},[g,N]),z.useEffect(()=>{if(!s){u&&u({applicationId:t,sessionId:"",session:null,sessionInstance:null});return}s.data&&u&&u({applicationId:t,sessionId:s.data.id,session:s.data,sessionInstance:s}),s.addEventListener("data:loaded",()=>{s!=null&&s.data&&u&&u({applicationId:t,sessionId:s.data.id,session:s.data,sessionInstance:s})},!0)},[s]);const q=E=>{var eM;return(eM=L.current)==null?void 0:eM.create(BM(zM({},E),{knowledges:w}))};return z.useImperativeHandle(e,()=>({createSession:E=>q(E),getSessionList:()=>{var eM;const E=((eM=L.current)==null?void 0:eM.list())||[];return Promise.resolve(E)},getCurrentInputText:()=>{var E;return(E=S.current)==null?void 0:E.getCurrentInputText()},send:E=>{var eM;return(eM=S.current)!=null&&eM.send?S.current.send(E):Promise.reject(new Error("send is not available"))}})),j.jsx("div",{className:"dialog",children:j.jsxs("div",{className:"dialog-pannel",children:[j.jsx("div",{className:"dialog-sider",style:{display:I&&y==="inlay"?"block":"none"},children:j.jsx(Ss,{ref:L,appId:t,networkStatus:U,currentSession:s,application:a,setCurrentSession:D,checkKnowledges:w,setCheckKnowledges:n?k:void 0,sessionId:N,afterSessionClick:E=>{var eM,G;((eM=E.data)==null?void 0:eM.id)!==((G=s==null?void 0:s.data)==null?void 0:G.id)&&R(!0)}})}),j.jsx("div",{className:"dialog-content",children:j.jsxs("div",{className:"dialog-chat",children:[n&&j.jsx("div",{className:"dialog-chat-header",children:j.jsx(bg,{setCheckKnowledges:k,application:a,currentSession:s})}),j.jsx("div",{className:"dialog-chat-content",children:(a==null?void 0:a.id)&&j.jsx(pg,{setNetworkStatus:_,networkStatus:U,application:a,currentSession:s,onCreateSession:q,docViewerUrl:i,embeddingService:d,setCurrentSession:D,ref:S})})]})})]})})}),Pg=z.forwardRef((M,e)=>{const{className:N,triggerButton:t,size:i,theme:s,icon:D,docViewerUrl:n,token:g,debug:I,env:u,plugins:o,mcp:y,footer:a,defaultInput:T,onComment:L,onSessionLoad:d,onSessionUnload:O,onMessage:w,beforeMessageSend:k,bodyStyle:S,apiUrl:U,sessionId:_,disabled:R,transform:q,features:E,stream:eM,agentClient:G,application:p}=M,F=z.useRef(null),[jM,v]=z.useState(!1),[yM,mM]=z.useState(),[LM,rM]=z.useState(i),[PM,xM]=z.useState(M.open),f=z.useRef(null);z.useEffect(()=>{p&&(console.log("[AgentClientUI] token",G,p),mM(p.id))},[p]),r.ConfigProvider.config({theme:s}),z.useEffect(()=>{i&&rM(i)},[i]);const x=(NM,{element:AM,size:UM})=>{rM({width:Number(UM.width),height:UM.height})};return z.useImperativeHandle(e,()=>({createSession:NM=>{var AM;return(AM=f.current)==null?void 0:AM.createSession(NM)},getSessionList:()=>{var NM;return(NM=f.current)==null?void 0:NM.getSessionList()},getCurrentInputText:()=>{var NM;return(NM=f.current)==null?void 0:NM.getCurrentInputText()},send:NM=>{var AM;return(AM=f.current)!=null&&AM.send?f.current.send(NM):Promise.reject(new Error("send is not available"))}})),j.jsx(r.ConfigProvider,{locale:Ns,children:j.jsxs(js,{value:BM(zM({},M),{popupContainer:F,agentClient:G,footer:a,defaultInput:T,onComment:L,onSessionLoad:d,onSessionUnload:O,onMessage:w,beforeMessageSend:k,bodyStyle:S,disabled:R,transform:q,features:E}),children:[j.jsx(nz.Resizable,{height:(LM==null?void 0:LM.height)||"100%",width:(LM==null?void 0:LM.width)||"100%",maxConstraints:[document.body.clientWidth-45],minConstraints:[Number(i==null?void 0:i.minWidth)],onResize:x,handle:j.jsx("span",{className:"resize-handle-ew"}),resizeHandles:N=="float"?["w"]:[],children:j.jsxs("div",{id:"dialog-modal",className:`gbot-dialog-modal ${N} ${PM?"opened":"closed"}`,style:BM(zM({},i),{width:N=="float"?LM==null?void 0:LM.width:i==null?void 0:i.width,height:N==="float"?LM==null?void 0:LM.height:i==null?void 0:i.height,maxHeight:"100vh"}),ref:F,children:[jM?j.jsx("div",{className:"loading",children:j.jsx(r.Spin,{})}):yM&&G?j.jsx(Jn,{children:j.jsx(Gg,{ref:f,appId:yM,docViewerUrl:n,bodyStyle:S,sessionId:_})}):null,(t==null?void 0:t.visible)&&j.jsx(r.Button,{className:"trigger-btn close-btn",icon:j.jsx("img",{src:D}),onClick:()=>xM(!1)})]})}),(t==null?void 0:t.visible)&&!PM&&j.jsx(r.Button,{className:`${N}-trigger-btn open-btn`,style:t.style,icon:j.jsx("img",{src:D}),onClick:()=>xM(!0)})]})})}),Rg="@glodon-aiot/agent-cli-ui",Wg="3.26.0-alpha.24",Zg="./dist/es/index.mjs",_g="./dist/lib/index.js",Bg="./dist/src/index.d.ts",Jg={import:"./dist/es/index.mjs",require:"./dist/lib/index.js",types:"./dist/src/index.d.ts"},Fg=["dist"],Hg="module",Vg="dist/src/index.d.ts",Xg={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"},$g={"@ant-design/icons":"^5.3.4","@glodon-aiot/apis":"^3.26.0-alpha.24","@glodon-aiot/bot-client-sdk":"^3.26.0-alpha.24","@glodon-aiot/react-components":"^3.26.0-alpha.24","@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"},Kg={"@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"},qg=[">0.2%","not dead","not op_mini all"],Mu=["last 1 chrome version","last 1 firefox version","last 1 safari version"],eu={commitizen:{path:"node_modules/cz-customizable"},"cz-customizable":{config:".cz-config.cjs"}},Nu={access:"public",registry:"https://registry.npmjs.org/"},tu={hooks:{"commit-msg":"validate-commit-msg"}},iu={name:Rg,version:Wg,module:Zg,main:_g,typings:Bg,exports:Jg,files:Fg,type:Hg,types:Vg,scripts:Xg,dependencies:$g,devDependencies:Kg,"lint-staged":{"*.{js,css,md,jsx,less,ts,tsx,json}":"prettier --write"},production:qg,development:Mu,config:eu,publishConfig:Nu,husky:tu};var fs=(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))(fs||{});//! moment.js
16
+ .bmp格式的图片数据,单文件最大${Gt}M,最多${Je}张`}),children:j.jsx(r.Button,{type:"text",className:"camera-out-btn",style:{width:"22px",position:"relative",bottom:"-2px"},icon:j.jsx(oM,{type:"icon-shangchuantupian",className:"icon-tianjia",style:{fontSize:"22px"}})})}):j.jsx(r.Button,{type:"text",className:"camera-out-btn",style:{width:"22px",position:"relative",bottom:"-2px"},disabled:!0,icon:j.jsx(oM,{type:"icon-shangchuantupian",className:"icon-tianjia",style:{fontSize:"22px"}})})}),D&&(v!=null&&v.fileUpload)&&(N!=null&&N.id)?j.jsx(As,{appId:N==null?void 0:N.id,allowExcelAttachment:N.type===Z.ApplicationTypes.Agent,ref:TN,isFirstSession:Ui,docViewerUrl:t,onStatusChange:c=>gM(exports,null,function*(){c!=="process"?(pN(!0),Qt()):pN(!1)}),createSession:()=>Fi().then(c=>{var Q;return((Q=c.data)==null?void 0:Q.id)||""}),sid:(uj=i==null?void 0:i.data)==null?void 0:uj.id,disabled:dt||xM,afterFileAdd:(c,l)=>{l&&IN(Q=>{const P=Q[l]||[];return{[l]:[...P,c]}})},afterFileDelete:c=>{var Q;const l=(Q=i==null?void 0:i.data)==null?void 0:Q.id;l&&IN(P=>{const W=P[l]||[];return{[l]:W.filter(sM=>sM.id!==c)}})},onFileListChange:c=>{QD(c)},shouldContinue:fD,afterFilesClear:()=>{var l;const c=(l=i==null?void 0:i.data)==null?void 0:l.id;c&&(IN({[c]:[]}),Qt())}}):null,(v==null?void 0:v.prompt)&&(N==null?void 0:N.id)&&j.jsx(eg,{appId:N.id,list:[],search:uN?xD:"",onPromptSelect:c=>{Ke(c.context),S(c.context)},disabled:xM})]}),j.jsxs(r.Space,{children:[(v==null?void 0:v.connectNetwork)&&N.type===Z.ApplicationTypes.Dialog&&((Ij=N.arrange)==null?void 0:Ij.length)&&!!N.arrange[0].enableNetOpen&&j.jsx(Vn,{sessionId:(Tj=i==null?void 0:i.data)==null?void 0:Tj.id,netStatus:g,enable:typeof(f==null?void 0:f.connectNetwork)=="object"&&typeof(f==null?void 0:f.connectNetwork.diabled)=="boolean"?!(f!=null&&f.connectNetwork.diabled):bD,disabledTip:i?void 0:"网络访问已被禁用",onNetStatusChange:c=>{jz(c)}}),(v==null?void 0:v.sessionList)&&j.jsx(Bn,{currentSessionId:(cj=i==null?void 0:i.data)==null?void 0:cj.id,onSessionChange:(c,l)=>{Ke(void 0),GN(!0),n==null||n(l)},disabled:xM}),AM&&UM==="float"&&j.jsx("div",{className:"session-history-drawer-component",children:j.jsx(r.Popover,{placement:"topRight",showArrow:!1,overlayClassName:"session-history-overlay",overlayStyle:{padding:"4px"},getPopupContainer:c=>c.parentNode,content:"会话历史记录",children:j.jsx(r.Button,{className:"history-overlay-action",disabled:xM,type:"text",icon:j.jsx(oM,{type:"icon-lishijilu",style:{fontSize:24}}),onClick:()=>Gi(!0)})})}),(v==null?void 0:v.sessionOpen)&&j.jsx(r.Button,{icon:j.jsx(cM.PlusOutlined,{}),className:"add-btn",type:"primary",disabled:ki||!i||!u.length||xM,onClick:()=>{var c,l;GN(!1),n==null||n(null),MN.current=null,I(!1),(c=fi.current)==null||c.clear(),(l=lt.current)==null||l.clear()},children:"新会话"})]})]}),!!Ot&&j.jsx("div",{className:"remainingSeconds-mark"})]}),j.jsxs("div",{className:"footer-textarea",onPaste:_i,onPasteCapture:_i,onDrop:Ji,onDropCapture:Ji,onDragOver:Bi,onDragOverCapture:Bi,children:[j.jsx(ys,{ref:bM,maxLength:Y,text:wD,networkStatus:!1,loading:bi||vN,disabled:B||pM||xM||bi||vN,onTextSend:wt,onChange:(c,l)=>{Ke(c);const Q=l.getText().replace(/[\n\s]+$/,"");S(Q),YD(Q),uN||OD(!0)},clearAction:j.jsx(r.Space,{size:0,children:j.jsx(r.Button,{type:"link",disabled:dt||xM,ghost:!0,icon:j.jsx(oM,{style:{fontSize:22},type:"icon-qingchujiyi"}),onClick:()=>ZD()})})}),!!Ot&&j.jsxs("div",{className:"remainingSeconds-time",children:["您之前对话触发敏感词拦截,当前处于禁言状态,暂时无法发送消息,剩余禁言时长",Ot]})]})]})}),j.jsx(vn,{tips:jM}),mi&&j.jsx(Rn,{isvisible:mi,files:hD,sessionId:(rj=i==null?void 0:i.data)==null?void 0:rj.id,onClose:c=>{ED(!1),mD(!1)}})]}),vi&&j.jsx(Hn,{currentSession:i,application:N,networkStatus:g,setCurrentSession:n,disabled:xM,isSessionHistoryVisible:vi,setIsSessionHistoryVisible:Gi,onSessionChange:c=>{GN(!0)}})]})]}),Yt&&PN&&y.length>0&&Ms.createPortal(j.jsxs("div",{className:"artifacts-dock",ref:Ri,children:[j.jsxs("div",{className:`artifacts-drawer${T?" is-open":""}`,children:[j.jsxs("button",{type:"button",className:"artifacts-handle",onClick:()=>L(c=>!c),children:[j.jsx("span",{className:"artifacts-handle-text",children:"产出物"}),T?j.jsx(cM.RightOutlined,{}):j.jsx(cM.LeftOutlined,{})]}),j.jsxs("div",{className:"artifacts-panel",children:[j.jsxs("div",{className:"artifacts-panel-main",children:[j.jsx("div",{className:"artifacts-panel-title",children:"产出物"}),j.jsx(xn,{artifacts:y,activeArtifact:d,onPreview:O})]}),oN.preview==="column"&&d&&j.jsx(fn,{artifact:d,style:oN.style,onClose:()=>O(null)})]})]}),j.jsx(Sn,{placement:oN.preview,artifact:d,style:oN.style,onClose:()=>O(null),getContainer:()=>Ri.current||Yt})]}),Yt)]})});const hs=M=>{const{disabled:e,checkedValues:N,currKnowledgeList:t,selectCount:i,onSelectChange:s}=M,[D,n]=z.useState(!1),g=j.jsx(r.Checkbox.Group,{style:{width:"100%"},onChange:s,value:N,disabled:e,children:j.jsx(r.Row,{gutter:[20,12],children:t==null?void 0:t.map(u=>j.jsx(r.Col,{span:24,children:j.jsx(r.Checkbox,{value:u.id,children:u.name})},u.id))})}),I=u=>{n(u)};return j.jsx("div",{className:"knowledge-select",style:{borderColor:D?"#9C24F2":"#84868C"},children:j.jsx(r.Popover,{className:"select-popover",placement:"bottomRight",title:null,content:g,trigger:"click",overlayStyle:{width:280},onOpenChange:I,getPopupContainer:u=>u.parentNode,children:j.jsxs("div",{className:"",onClick:u=>u.preventDefault(),children:[j.jsx(oM,{className:"select-icon",type:"icon-open"}),j.jsx("span",{className:"title",children:"参考知识库"}),j.jsxs("span",{className:"content",children:["已选 ",i," 个"]})]})})})},bg=M=>{var d,O;const{currentSession:e,application:N,setCheckKnowledges:t}=M,{mode:i,transform:s,features:D}=z.useContext(JM),[n,g]=z.useState([]),[I,u]=z.useState(typeof(D==null?void 0:D.knowledges)=="object"?((d=D.knowledges.default)==null?void 0:d.map(w=>w.id))||[]:[]),[o,y]=z.useState(0),[a,T]=z.useState(!1);z.useEffect(()=>{if(!(N!=null&&N.id))return;const w=N.arrange;if(!(w!=null&&w.length))return;const S=w[0].knowledges||[];g(S);const U=typeof(D==null?void 0:D.knowledges)=="object"&&D.knowledges.default||S;if(Array.isArray(U)&&U.some(E=>Array.isArray(E.fileIds)&&E.fileIds.length===0))throw Error("fileIds cannot be an empty array");if(et(U||[])>ve)throw Error(`knowledges and fileIds total count cannot exceed ${ve}`);if(!e){u(U.map(q=>q.id)),y(U.length),t==null||t(U);return}const R=()=>{const q=e.knowledges||U;y(q.length);const E=q.map(eM=>eM.id);u(E)};return R(),e.addEventListener("data:updated",R),()=>{e==null||e.removeEventListener("data:updated",R)}},[N,e]),z.useEffect(()=>{var k;if(!a||(T(!1),!(N!=null&&N.id)))return;const w=[];I==null||I.map(S=>{const U=n==null?void 0:n.find(_=>_.id===S);w.push(U)}),(k=e==null?void 0:e.data)!=null&&k.id&&e.setKnowledges(w)},[a]);const L=w=>{T(!0),u(w);const k=[];w==null||w.map(S=>{const U=n==null?void 0:n.find(_=>_.id===S);k.push(U)}),t==null||t(k),y(w.length)};return j.jsxs("div",{className:"chat-header",children:[j.jsxs(r.Space,{className:"header-title",children:[i==="inlay"&&((O=e==null?void 0:e.data)==null?void 0:O.name),i==="float"&&(N==null?void 0:N.name)]}),(s==null?void 0:s.knowledges)&&n.length!==0&&j.jsx(hs,{disabled:typeof(D==null?void 0:D.knowledges)=="object"&&(D==null?void 0:D.knowledges.diabled)||!1,checkedValues:I,currKnowledgeList:n,selectCount:o,onSelectChange:L})]})},Qs="gbot-sider-tab:";function Rj(M){try{return localStorage.getItem(Qs+M)==="sessions"?"sessions":"workspace"}catch(e){return"workspace"}}function vg(M,e){try{localStorage.setItem(Qs+M,e)}catch(N){}}const Ss=z.forwardRef((M,e)=>{const{application:N}=M,{agentClient:t,sider:i,mode:s,localFilesUI:D,disabled:n,popupContainer:g}=z.useContext(JM),I=N!=null?N:t==null?void 0:t.application,u=i&&s==="inlay"&&(I==null?void 0:I.type)===Z.ApplicationTypes.Agent&&D&&D.picker!==!1?t==null?void 0:t.localWorkspace:void 0,{status:o}=Os(u),[y]=xs(u),[a,T]=z.useState("workspace"),L=z.useRef(!1),d=z.useRef(!1);if(z.useEffect(()=>{if(!u)return;let w=!0;return u.ready.then(()=>{!w||L.current||d.current||u.status==="granted"&&(d.current=!0,T(Rj(u.applicationId)))}),()=>{w=!1}},[u]),z.useEffect(()=>{!u||u.isSupported||o!=="granted"||L.current||d.current||(d.current=!0,T(Rj(u.applicationId)))},[u,o]),z.useEffect(()=>{y&&T("workspace")},[y]),!u)return j.jsx(Nt,zM({ref:e},M));const O=w=>{L.current=!0,T(w),u.status==="granted"&&vg(u.applicationId,w)};return j.jsxs("div",{className:"sider-tabs",children:[j.jsxs("div",{className:"sider-tabs-bar",role:"tablist",children:[j.jsxs("button",{type:"button",role:"tab","aria-selected":a==="workspace",className:VM("sider-tab",{"is-active":a==="workspace"}),onClick:()=>O("workspace"),children:["工作区",y&&a!=="workspace"&&j.jsx("span",{className:"sider-tab-dot"})]}),j.jsx("button",{type:"button",role:"tab","aria-selected":a==="sessions",className:VM("sider-tab",{"is-active":a==="sessions"}),onClick:()=>O("sessions"),children:"会话记录"})]}),j.jsxs("div",{className:"sider-tabs-panels",children:[j.jsx("div",{className:VM("sider-tabs-panel",{"is-hidden":a!=="workspace"}),role:"tabpanel",children:j.jsx(Es,{workspace:u,disclosureText:D==null?void 0:D.disclosureText,disclosure:D==null?void 0:D.disclosure,getContainer:()=>(g==null?void 0:g.current)||document.body,highlight:y,disabled:n})}),j.jsx("div",{className:VM("sider-tabs-panel",{"is-hidden":a!=="sessions"}),role:"tabpanel",children:j.jsx(Nt,zM({ref:e},M))})]})]})});Ss.displayName="SiderTabs";const Gg=z.forwardRef((M,e)=>{const{sessionId:N,appId:t,docViewerUrl:i}=M,[s,D]=z.useState(),{showHeader:n,agentClient:g,sider:I,onSessionLoad:u,features:o,mode:y}=z.useContext(JM),[a,T]=z.useState(),L=z.useRef(null),[d,O]=z.useState(""),[w,k]=z.useState(),S=z.useRef(null),[U,_]=z.useState(!1);z.useState([]);const{setIsSwitchingToExistingSession:R}=ni();z.useEffect(()=>{var E;_(s?!!((E=s.data)!=null&&E.netOpen):typeof(o==null?void 0:o.connectNetwork)=="object"&&typeof(o==null?void 0:o.connectNetwork.default)=="boolean"?o.connectNetwork.default:!1)},[s]),z.useEffect(()=>{const E=()=>gM(exports,null,function*(){const eM=g==null?void 0:g.application;if(!(eM!=null&&eM.id))return;const G=eM==null?void 0:eM.arrange;if(!(G!=null&&G.length))return;const F=G[0].embeddingService;O(F),T(eM)});if(g!=null&&g.ready){E();return}return g==null||g.addEventListener("ready",()=>E()),()=>{g==null||g.removeEventListener("ready",E)}},[g]),z.useEffect(()=>{g&&N&&(g.ready?g==null||g.getSessions().then(E=>gM(exports,null,function*(){D==null||D(E.find(eM=>eM.id===N))})):g.addEventListener("ready",()=>gM(exports,null,function*(){g==null||g.getSessions().then(E=>gM(exports,null,function*(){D==null||D(E.find(eM=>eM.id===N))}))}),!0))},[g,N]),z.useEffect(()=>{if(!s){u&&u({applicationId:t,sessionId:"",session:null,sessionInstance:null});return}s.data&&u&&u({applicationId:t,sessionId:s.data.id,session:s.data,sessionInstance:s}),s.addEventListener("data:loaded",()=>{s!=null&&s.data&&u&&u({applicationId:t,sessionId:s.data.id,session:s.data,sessionInstance:s})},!0)},[s]);const q=E=>{var eM;return(eM=L.current)==null?void 0:eM.create(BM(zM({},E),{knowledges:w}))};return z.useImperativeHandle(e,()=>({createSession:E=>q(E),getSessionList:()=>{var eM;const E=((eM=L.current)==null?void 0:eM.list())||[];return Promise.resolve(E)},getCurrentInputText:()=>{var E;return(E=S.current)==null?void 0:E.getCurrentInputText()},send:E=>{var eM;return(eM=S.current)!=null&&eM.send?S.current.send(E):Promise.reject(new Error("send is not available"))}})),j.jsx("div",{className:"dialog",children:j.jsxs("div",{className:"dialog-pannel",children:[j.jsx("div",{className:"dialog-sider",style:{display:I&&y==="inlay"?"block":"none"},children:j.jsx(Ss,{ref:L,appId:t,networkStatus:U,currentSession:s,application:a,setCurrentSession:D,checkKnowledges:w,setCheckKnowledges:n?k:void 0,sessionId:N,afterSessionClick:E=>{var eM,G;((eM=E.data)==null?void 0:eM.id)!==((G=s==null?void 0:s.data)==null?void 0:G.id)&&R(!0)}})}),j.jsx("div",{className:"dialog-content",children:j.jsxs("div",{className:"dialog-chat",children:[n&&j.jsx("div",{className:"dialog-chat-header",children:j.jsx(bg,{setCheckKnowledges:k,application:a,currentSession:s})}),j.jsx("div",{className:"dialog-chat-content",children:(a==null?void 0:a.id)&&j.jsx(pg,{setNetworkStatus:_,networkStatus:U,application:a,currentSession:s,onCreateSession:q,docViewerUrl:i,embeddingService:d,setCurrentSession:D,ref:S})})]})})]})})}),Pg=z.forwardRef((M,e)=>{const{className:N,triggerButton:t,size:i,theme:s,icon:D,docViewerUrl:n,token:g,debug:I,env:u,plugins:o,mcp:y,footer:a,defaultInput:T,onComment:L,onSessionLoad:d,onSessionUnload:O,onMessage:w,beforeMessageSend:k,bodyStyle:S,apiUrl:U,sessionId:_,disabled:R,transform:q,features:E,stream:eM,agentClient:G,application:p}=M,F=z.useRef(null),[jM,v]=z.useState(!1),[yM,mM]=z.useState(),[LM,rM]=z.useState(i),[PM,xM]=z.useState(M.open),f=z.useRef(null);z.useEffect(()=>{p&&(console.log("[AgentClientUI] token",G,p),mM(p.id))},[p]),r.ConfigProvider.config({theme:s}),z.useEffect(()=>{i&&rM(i)},[i]);const x=(NM,{element:AM,size:UM})=>{rM({width:Number(UM.width),height:UM.height})};return z.useImperativeHandle(e,()=>({createSession:NM=>{var AM;return(AM=f.current)==null?void 0:AM.createSession(NM)},getSessionList:()=>{var NM;return(NM=f.current)==null?void 0:NM.getSessionList()},getCurrentInputText:()=>{var NM;return(NM=f.current)==null?void 0:NM.getCurrentInputText()},send:NM=>{var AM;return(AM=f.current)!=null&&AM.send?f.current.send(NM):Promise.reject(new Error("send is not available"))}})),j.jsx(r.ConfigProvider,{locale:Ns,children:j.jsxs(js,{value:BM(zM({},M),{popupContainer:F,agentClient:G,footer:a,defaultInput:T,onComment:L,onSessionLoad:d,onSessionUnload:O,onMessage:w,beforeMessageSend:k,bodyStyle:S,disabled:R,transform:q,features:E}),children:[j.jsx(nz.Resizable,{height:(LM==null?void 0:LM.height)||"100%",width:(LM==null?void 0:LM.width)||"100%",maxConstraints:[document.body.clientWidth-45],minConstraints:[Number(i==null?void 0:i.minWidth)],onResize:x,handle:j.jsx("span",{className:"resize-handle-ew"}),resizeHandles:N=="float"?["w"]:[],children:j.jsxs("div",{id:"dialog-modal",className:`gbot-dialog-modal ${N} ${PM?"opened":"closed"}`,style:BM(zM({},i),{width:N=="float"?LM==null?void 0:LM.width:i==null?void 0:i.width,height:N==="float"?LM==null?void 0:LM.height:i==null?void 0:i.height,maxHeight:"100vh"}),ref:F,children:[jM?j.jsx("div",{className:"loading",children:j.jsx(r.Spin,{})}):yM&&G?j.jsx(Jn,{children:j.jsx(Gg,{ref:f,appId:yM,docViewerUrl:n,bodyStyle:S,sessionId:_})}):null,(t==null?void 0:t.visible)&&j.jsx(r.Button,{className:"trigger-btn close-btn",icon:j.jsx("img",{src:D}),onClick:()=>xM(!1)})]})}),(t==null?void 0:t.visible)&&!PM&&j.jsx(r.Button,{className:`${N}-trigger-btn open-btn`,style:t.style,icon:j.jsx("img",{src:D}),onClick:()=>xM(!0)})]})})}),Rg="@glodon-aiot/agent-cli-ui",Wg="3.26.0-alpha.26",Zg="./dist/es/index.mjs",_g="./dist/lib/index.js",Bg="./dist/src/index.d.ts",Jg={import:"./dist/es/index.mjs",require:"./dist/lib/index.js",types:"./dist/src/index.d.ts"},Fg=["dist"],Hg="module",Vg="dist/src/index.d.ts",Xg={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"},$g={"@ant-design/icons":"^5.3.4","@glodon-aiot/apis":"^3.26.0-alpha.26","@glodon-aiot/bot-client-sdk":"^3.26.0-alpha.26","@glodon-aiot/react-components":"^3.26.0-alpha.26","@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"},Kg={"@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"},qg=[">0.2%","not dead","not op_mini all"],Mu=["last 1 chrome version","last 1 firefox version","last 1 safari version"],eu={commitizen:{path:"node_modules/cz-customizable"},"cz-customizable":{config:".cz-config.cjs"}},Nu={access:"public",registry:"https://registry.npmjs.org/"},tu={hooks:{"commit-msg":"validate-commit-msg"}},iu={name:Rg,version:Wg,module:Zg,main:_g,typings:Bg,exports:Jg,files:Fg,type:Hg,types:Vg,scripts:Xg,dependencies:$g,devDependencies:Kg,"lint-staged":{"*.{js,css,md,jsx,less,ts,tsx,json}":"prettier --write"},production:qg,development:Mu,config:eu,publishConfig:Nu,husky:tu};var fs=(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))(fs||{});//! 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.24",
3
+ "version": "3.26.0-alpha.26",
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.24",
35
- "@glodon-aiot/bot-client-sdk": "^3.26.0-alpha.24",
36
- "@glodon-aiot/react-components": "^3.26.0-alpha.24",
34
+ "@glodon-aiot/apis": "^3.26.0-alpha.26",
35
+ "@glodon-aiot/bot-client-sdk": "^3.26.0-alpha.26",
36
+ "@glodon-aiot/react-components": "^3.26.0-alpha.26",
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",