@glodon-aiot/agent-cli-ui 3.26.0-alpha.4 → 3.26.0-alpha.8
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 +4 -4
- package/dist/lib/index.js +1 -1
- package/package.json +4 -4
package/dist/es/index.mjs
CHANGED
|
@@ -6291,7 +6291,7 @@ const e4 = ZN((M, N) => {
|
|
|
6291
6291
|
})]
|
|
6292
6292
|
})
|
|
6293
6293
|
});
|
|
6294
|
-
}), i4 = "@glodon-aiot/agent-cli-ui", j4 = "3.26.0-alpha.
|
|
6294
|
+
}), i4 = "@glodon-aiot/agent-cli-ui", j4 = "3.26.0-alpha.8", D4 = "./dist/es/index.mjs", z4 = "./dist/lib/index.js", g4 = "./dist/src/index.d.ts", I4 = {
|
|
6295
6295
|
import: "./dist/es/index.mjs",
|
|
6296
6296
|
require: "./dist/lib/index.js",
|
|
6297
6297
|
types: "./dist/src/index.d.ts"
|
|
@@ -6313,9 +6313,9 @@ const e4 = ZN((M, N) => {
|
|
|
6313
6313
|
commit: "cz"
|
|
6314
6314
|
}, c4 = {
|
|
6315
6315
|
"@ant-design/icons": "^5.3.4",
|
|
6316
|
-
"@glodon-aiot/apis": "^3.26.0-alpha.
|
|
6317
|
-
"@glodon-aiot/bot-client-sdk": "^3.26.0-alpha.
|
|
6318
|
-
"@glodon-aiot/react-components": "^3.26.0-alpha.
|
|
6316
|
+
"@glodon-aiot/apis": "^3.26.0-alpha.8",
|
|
6317
|
+
"@glodon-aiot/bot-client-sdk": "^3.26.0-alpha.8",
|
|
6318
|
+
"@glodon-aiot/react-components": "^3.26.0-alpha.8",
|
|
6319
6319
|
"@matejmazur/react-mathjax": "^0.1.10",
|
|
6320
6320
|
"@react-pdf-viewer/core": "^3.12.0",
|
|
6321
6321
|
"@react-pdf-viewer/default-layout": "^3.12.0",
|
package/dist/lib/index.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
${j}`:j}if(e&&e.length>0){const D=e.filter(Boolean).map(s=>``).join(`
|
|
13
13
|
`);j=D?`${D}
|
|
14
14
|
${j}`:j}}return j},fg=M=>{const e=Math.floor(M/3600),N=Math.floor(M%3600/60),t=M%60,j=D=>String(D).padStart(2,"0");return`${j(e)}:${j(N)}:${j(t)}`},Ug=z.forwardRef((M,e)=>{var Xj,$j,Kj,qj,Mi,ei,Ni,ti,ji,ii,Di,si,zi,gi,Ii,ui;const{application:N,docViewerUrl:t="",currentSession:j,onCreateSession:D,embeddingService:s,setCurrentSession:g,networkStatus:I,setNetworkStatus:u}=M,[n,y]=z.useState([]),[L,A]=z.useState([]),[c,r]=z.useState(!1),[C,O]=z.useState(null),S=z.useRef(0),[Q,m]=z.useState(),[U,W]=z.useState(),Z=z.useRef(null),MM=z.useRef(!0),x=z.useRef(!1),NM=z.useRef(!1),{service:v,agentClient:b,depId:G,footer:F,transform:h,defaultInput:zM,onMessage:mM,onHistoryLoad:CM,beforeMessageSend:YM,bodyStyle:wM,disabled:TM,features:E,popupContainer:d,icon:X,sider:lM,mode:pM,silencedSeconds:Me,localFilesUI:K,localFilesApprovalBridge:EM}=z.useContext(HM),dM=N.type===J.ApplicationTypes.Agent&&K?b==null?void 0:b.localWorkspace:void 0,[tM]=Tg(dM),l=we.useMemoizedFn(()=>(d==null?void 0:d.current)||document.body),[H,$]=z.useState(!1),f=z.useRef(n),IM=z.useRef(void 0),Y=z.useRef(new Set),[_,B]=z.useState(0),[cM,DM]=z.useState([]),[rM,GM]=z.useState([]),[k,kM]=z.useState(0),[PM,ee]=z.useState(!1);z.useEffect(()=>{ee(k>0)},[k]);const SM=z.useRef(null),[fM,qM]=z.useState([]),[VM,ge]=z.useState(!1),[pe,kN]=z.useState(!1),[fN,UN]=z.useState(""),[pN,de]=z.useState(),[BM,IN]=z.useState({}),uN=z.useRef(null),Ej=z.useRef(null),lt=z.useRef(null),[hj,Ds]=z.useState(!1),[ss,zs]=z.useState([]),[gs,bN]=z.useState(!0),[Is,us]=z.useState(!0),[Qj,ye]=z.useState(!1),[Ct,Oe]=z.useState(!1),[ns,dt]=z.useState(!1),[Te,nN]=z.useState(typeof(E==null?void 0:E.promptVariables)=="object"?E.promptVariables.default||[]:[]),[Ts,cs]=z.useState(()=>{const T=typeof(E==null?void 0:E.knowledges)=="object"&&E.knowledges.default||void 0;if(T){if(Array.isArray(T)&&T.some(P=>Array.isArray(P.fileIds)&&P.fileIds.length===0))throw Error("fileIds cannot be an empty array");if(Nt(T)>Pe)throw Error(`knowledges and fileIds total count cannot exceed ${Pe}`)}return T}),[Sj,_e]=z.useState(!1),[mj,TN]=z.useState(!1),[as,cN]=z.useState(typeof(E==null?void 0:E.connectNetwork)=="object"&&typeof(E==null?void 0:E.connectNetwork.default)=="boolean"?E.connectNetwork.default:!1),[kj,vN]=z.useState(!1),[Ls,be]=z.useState(!1),[As,ys]=z.useState(null),[GN,Be]=z.useState(!1),[fj,Uj]=z.useState(!1),{isSwitchingToExistingSession:pj,setIsSwitchingToExistingSession:PN}=jj(),qe=z.useRef(null),[Ot,rs]=z.useState("");z.useEffect(()=>{if(!Me)return;let T=fg(Me);rs(T)},[Me]);const aN=fz((Xj=E==null?void 0:E.botMessageBox)==null?void 0:Xj.artifacts),RN=aN.visible,xt=we.useMemoizedFn(T=>uM(exports,null,function*(){var R,jM,eM;if(!RN)return;const o=j,w=T||((R=o==null?void 0:o.data)==null?void 0:R.id);if(!o||!w||((jM=o.data)==null?void 0:jM.id)!==w)return;const P=++S.current;try{const UM=yield o.getArtifacts();if(P!==S.current||((eM=j==null?void 0:j.data)==null?void 0:eM.id)!==w)return;A(UM||[])}catch(UM){}}));z.useEffect(()=>{if(ys(j),j===null)be(!1);else if(j===void 0)be(!0);else{if(As===null){if(pj){be(!0),PN(!1);return}be(!1);return}j.ready?be(!1):be(!0)}},[j,j==null?void 0:j.ready,pj]);const[Yt,os]=z.useState(null),bj=z.useRef(null);z.useEffect(()=>{var T;os((T=d==null?void 0:d.current)!=null?T:null)},[d]),z.useEffect(()=>{C&&r(!0)},[C]),z.useEffect(()=>{var o;const T=(o=j==null?void 0:j.data)==null?void 0:o.id;S.current+=1,A([]),r(!1),O(null),T&&RN&&xt(T)},[($j=j==null?void 0:j.data)==null?void 0:$j.id,RN]),z.useEffect(()=>{var w,P;j&&(f.current=[]),y([]),MM.current=!0,x.current=!1;const T=Z.current;if(T&&T.scrollTo({top:0}),!((w=j==null?void 0:j.data)!=null&&w.id))return;if(Oe(!1),ye(!1),(P=j.messages)!=null&&P.length){const jM=[...j.messages.filter(eM=>eM==null?void 0:eM.messageId)].reverse();f.current=[...jM],y([...jM]),be(!1)}const o=R=>{var jM;(jM=j==null?void 0:j.data)!=null&&jM.id&&(f.current=[...R].reverse(),y([...R].reverse()),!R||R.length<10?TN(!1):TN(!0),be(!1),CM&&CM({applicationId:N.id,sessionId:j.data.id,histories:R}))};return j.addEventListener("history:loaded",o),()=>{f.current=[],y([]),j==null||j.removeEventListener("history:loaded",o)}},[j]),z.useEffect(()=>{const T=()=>{var o;(o=j==null?void 0:j.data)!=null&&o.id&&(j.promptVariables&&nN(j.promptVariables.sort((w,P)=>w.key.localeCompare(P.key))),j.knowledges&&cs(j.knowledges),u(j.netOpen))};return j==null||j.addEventListener("data:updated",T),()=>{j==null||j.removeEventListener("data:updated",T)}},[j]),z.useEffect(()=>{var o;if(!((o=j==null?void 0:j.data)!=null&&o.id))return;const T=w=>{var P;console.error(w.message,w.cause,"e.case"),a.notification.config({getContainer:()=>(d==null?void 0:d.current)||document.body,prefixCls:"gbot-notification"}),a.notification.error({message:((P=w.cause)==null?void 0:P.message)||w.message}),a.notification.config({getContainer:void 0,prefixCls:"gbot-notification"})};return j.addEventListener("error",T),()=>{j==null||j.removeEventListener("error",T)}},[j]);const ls=()=>{var w;if(!((w=j==null?void 0:j.data)!=null&&w.id)||!(N!=null&&N.id))return;const T=j.data.id,o=n[n.length-1];if(o&&o.isContext){ie("success","已开启新话题");return}else j.clear().then(()=>{const P=new Fe("",T,J.IHistoryRole.System);P.isContext=!0,y([P,...n])})};z.useEffect(()=>{N!=null&&N.id&&(v==null||v.getRecommendQues(N.id).then(T=>{qM(T)}))},[G,N]);const wt=T=>uM(exports,null,function*(){var Ne,aM;if(TM)return ie("error","发送功能被禁用"),!1;const o=T||Q;if(!(o!=null&&o.trim()))return ie("error","请输入你想问的"),!1;if(!(Te==null?void 0:Te.every(ZM=>!!(ZM!=null&&ZM.value)))){if(h!=null&&h.promptVariables)return ie("error","变量值不能为空"),!1;console.error("变量值不能为空",Te==null?void 0:Te.map(ZM=>!!(ZM!=null&&ZM.value)))}if(Ct)return ie("error","正在回复中"),!1;if(H)return ie("error","等待初始化"),!1;if(!gs)return ie("error","正在解析文件"),!1;if(PM)return ie("error","正在上传图片"),!1;DM([]),GM([]);const P=(Ne=j==null?void 0:j.data)==null?void 0:Ne.id;if(!P)return GN?!1:(Be(!0),D==null||D({netOpen:I?Ge.OPEN:Ge.CLOSE}).then(ZM=>{var nM,XM;_e(!0),u(!!((nM=ZM.data)!=null&&nM.netOpen)),cN(!!((XM=ZM.data)!=null&&XM.enableNetOpen)),Et(ZM).then(()=>{g==null||g(ZM),_e(!1),W(o)})}).catch(ZM=>{Be(!1)}),!0);if(GN)return!1;Be(!0),vN(!0);const R=bt(o,rM,BM[P],(N==null?void 0:N.type)||0);let jM;try{YM?jM=yield YM==null?void 0:YM({applicationId:N.id,sessionId:P,message:{content:R,sessionId:P,role:J.ChatMessageRole.User,files:BM[P]}}):jM=!0}catch(ZM){jM=!1}if(vN(!1),jM===!1)return Be(!1),!1;let eM=o;typeof jM=="object"&&(eM=jM.content||o);const bM=yield(()=>new Promise(ZM=>{nN(nM=>(ZM(nM),nM))}))();return(yield j.setPromptVariables(bM))?(((aM=BM[P])==null?void 0:aM.length)>0?yield Cs(eM):yield ht(eM),!0):(Be(!1),!1)}),Et=T=>new Promise((o,w)=>uM(exports,null,function*(){const jM=(T==null?void 0:T.promptVariables).filter(eM=>eM.type?!((eM.type===J.PromptVariableType.User||eM.type===void 0)&&eM.key==="query")&&!((eM.type===J.PromptVariableType.System||eM.type===void 0)&&eM.key==="datetime"):eM.key!=="query").map(eM=>{var bM;const UM=(bM=Te.find(iM=>iM.key===eM.key&&iM.type===eM.type))==null?void 0:bM.value;return eM.value=UM||"",eM});nN(jM.sort((eM,UM)=>eM.key.localeCompare(UM.key))),yield T==null?void 0:T.setPromptVariables(jM).catch(eM=>{console.error(eM),ie("error",eM.message)}),o()})),Cs=T=>{var R,jM,eM;if(bN(!1),!((R=j==null?void 0:j.data)!=null&&R.id)||!(N!=null&&N.id))return;const o=((jM=j.data)==null?void 0:jM.id)||"";let w=[],P=new Set;return(eM=BM[o])==null||eM.forEach(UM=>{P.has(UM.id)||(w.push(UM),P.add(UM.id))}),bN(!0),ht(T,w)};z.useEffect(()=>{if(!U||!j)return;const T=U,o=()=>uM(exports,null,function*(){vN(!0);const w=bt(T,rM,BM[j.id],(N==null?void 0:N.type)||0);let P;try{YM?P=yield YM==null?void 0:YM({applicationId:N.id,sessionId:j.id,message:{content:w,sessionId:j.id,role:J.ChatMessageRole.User,files:BM[j.id]}}):P=!0}catch(R){P=!1}if(vN(!1),P===!1){Be(!1);return}ht(T),W(void 0)});return j.ready?o():j.addEventListener("ready",o,!0),()=>{j==null||j.removeEventListener("ready",o)}},[U,j]);const ht=(T,o)=>uM(exports,null,function*(){var Ne,aM,ZM;const w=(Ne=j==null?void 0:j.data)==null?void 0:Ne.id;if(!w)return;Oe(!0),ye(!0);const P=bt(T,rM,o,(N==null?void 0:N.type)||0);let R;if(N.type===J.ApplicationTypes.Agent)R=void 0;else if(N.type===J.ApplicationTypes.Dialog&&((aM=N.arrange)!=null&&aM.length)&&N.arrange[0].visionOpen){const nM=rM&&rM.length?rM.filter(Boolean):[];R=nM.length?nM:void 0}else R=void 0;const jM=new Fe(P,w,J.IHistoryRole.User,o,R);m(void 0),de(void 0),f.current=[jM,...n],y(f.current),N.id&&mM&&mM({applicationId:N.id,sessionId:w,message:jM});const eM=new Fe("",w,J.IHistoryRole.System);eM.isWaiting=!0,f.current=[eM,...f.current],y(f.current);const UM=(o==null?void 0:o.filter(nM=>!nM.localAttachment).map(nM=>nM.id))||[],bM={stream:Ee.configuration.stream,referenceFirst:!1};if(h!=null&&h.promptVariables){const nM=Te==null?void 0:Te.reduce((XM,ve)=>(XM[ve.key]=ve.value,XM),{});bM.formatValues=nM}if(h!=null&&h.knowledges){const nM=Ts;bM.knowledges=nM}const iM={text:P,fileIds:UM,files:o,uuid:jM.messageId};R&&R.length>0&&(iM.imageContent=R),j.ready||(yield new Promise(nM=>{j.addEventListener("ready",()=>nM(),!0)})),yield j.send(iM,bM),IN({[w]:[]}),(ZM=uN.current)==null||ZM.update({keepLocalAttachments:!1}),DM([]),GM([]),Be(!1)});z.useEffect(()=>{var bM;const T=(bM=j==null?void 0:j.data)==null?void 0:bM.id;if(!T)return;let o=null,w=null,P="";const R=()=>{o=null,w&&(y([w,...f.current]),w=null)},jM=()=>{o!==null&&(cancelAnimationFrame(o),o=null,w=null)},eM=iM=>{if(!iM.sessionId||iM.sessionId&&iM.sessionId!==IM.current)return;if(iM.role===J.IHistoryRole.User){if(f.current.some(LN=>LN.messageId&&LN.messageId===iM.messageId))return;const XM=new Fe(iM.content,T,J.IHistoryRole.User,iM.files,iM.imageContent);XM.messageId=iM.messageId||XM.messageId,XM.renderKey=XM.messageId;const ve=new Fe("",T,J.IHistoryRole.System);ve.isWaiting=!0,f.current=f.current.filter(LN=>!LN.isWaiting),f.current=[ve,XM,...f.current],y(f.current),ye(!0),Oe(!0),N.id&&mM&&mM({applicationId:N.id,sessionId:T,message:XM});return}if(iM.index===-1&&iM.code!==200&&iM.code!==11915&&iM.code!==11916&&(jM(),ye(!1),Oe(!1),f.current=f.current.filter(nM=>!nM.isWaiting),y([...f.current]),f.current=[...f.current],iM.content)){a.notification.config({getContainer:()=>(d==null?void 0:d.current)||document.body,prefixCls:"gbot-notification"}),a.notification.error({message:iM.content}),a.notification.config({getContainer:void 0,prefixCls:"gbot-notification"});return}const Ne=iM.actions||[],aM=new Fe(iM.content,T,J.IHistoryRole.Robot);aM.reasoningContent=iM.reasoningContent,aM.searchReference=iM.searchReference,aM.thinkingSecs=iM.thinkingSecs,aM.thinkingStatus=iM.thinkingStatus,aM.actions=Ne,aM.isLoading=!0,aM.searchingStatus=iM.searchingStatus;const ZM=f.current.some(nM=>nM.isWaiting);if(f.current=f.current.filter(nM=>!nM.isWaiting).filter(nM=>!nM.isReplying),ZM&&(P=""),aM.renderKey=P||iM.messageId||aM.messageId,P=aM.renderKey,aM.messageId=iM.messageId||aM.renderKey,iM.index===void 0){w=aM,o===null&&(o=requestAnimationFrame(R));return}if(jM(),(iM.code===11915||iM.code===11916)&&(ye(!1),Oe(!1),aM.isLoading=!1,aM.content=iM.code===11916?"尊敬的用户您好,让我们换个话题再聊聊吧。":"请您换个问题问我吧~",aM.isSensitive=!0,y([aM,...f.current])),iM.index===-2&&(ye(!1),Oe(!1),aM.isLoading=!1,aM.content="回答已中止~",aM.isSuspend=!0,y([aM,...f.current]),xt(T)),iM.index===-1&&(ye(!1),Oe(!1),aM.isLoading=!1,aM.reference=iM.reference,y([aM,...f.current]),iM.code===200&&xt(T),N.id)){const nM=aM.messageId;Y.current.has(nM)||(Y.current.add(nM),mM&&mM({applicationId:N.id,sessionId:T,message:aM}))}iM.index===-3&&(ye(!1),Oe(!1),aM.isLoading=!1,aM.reference=iM.reference,aM.relatedQuesion=iM.relatedQuesion,y([aM,...f.current]))},UM=()=>{j.addEventListener("message:updated",eM)};return j.ready?j.addEventListener("message:updated",eM):j.addEventListener("ready",UM),()=>{jM(),j==null||j.removeEventListener("message:updated",eM),j==null||j.removeEventListener("ready",UM)}},[j]),z.useEffect(()=>{if(!j){$(!1);return}const T=o=>{$(o)};return $(j.frozen),j.addEventListener("frozen",T),()=>{j==null||j.removeEventListener("frozen",T)}},[j]),z.useEffect(()=>{if(!b)return;const T=b.questionContextMaxLength||4e3;B(T)},[b,v]),z.useEffect(()=>{zM&&de(zM.text)},[zM]);const ie=(T,o,w)=>{se(d,()=>{a.message.open({type:T,content:o,key:w})})},vj=T=>{const o=T.size;return o<=0?(ie("error","该文件为空,请重新上传"),!1):o>pt*et?(ie("error",`图片须小于${pt}M`),!1):(DM(w=>w.length>=He?(ie("warning",`图片最多上传${He}张`),w):[...w,T]),!1)},ds=()=>{var T;return(N.type===J.ApplicationTypes.Agent&&(h==null?void 0:h.imageUpload)||N.type===J.ApplicationTypes.Dialog&&((T=N.arrange)==null?void 0:T.length)&&!!N.arrange[0].visionOpen&&(h==null?void 0:h.imageUpload))&&!TM},Os=()=>!!s&&(h==null?void 0:h.fileUpload)&&(N==null?void 0:N.id)&&!TM,Gj=T=>{var aM,ZM;const o=Array.from(T||[]).filter(Boolean);if(!o.length)return;const w=ds(),P=Os(),R=[],jM=[];let eM=0,UM=0,bM=0;o.forEach(nM=>{var ni,Ti,ci;const XM=(Ti=(ni=nM.name)==null?void 0:ni.split(".").pop())==null?void 0:Ti.toLowerCase();if(MD(nM)){P&&N.type===J.ApplicationTypes.Agent?jM.push(nM):bM++;return}if(((ci=nM.type)==null?void 0:ci.startsWith("image/"))||!!oi(nM.name)){w?R.push(nM):eM++;return}if(Ki.includes(nM.type)||["pdf","doc","docx"].includes(XM||"")){P?jM.push(nM):UM++;return}bM++});const iM=[],Ne=eM+UM+bM;if(!P&&!w)Ne&&iM.push(`当前不支持上传文件/图片,已忽略${Ne}个文件`);else if(P&&!w){const nM=eM+bM;if(nM){const XM=N.type===J.ApplicationTypes.Agent?".doc/.docx/.pdf/.xls/.xlsx/.svg/.dwg/.json":".doc/.docx/.pdf";iM.push(`仅支持上传 ${XM} 文件,已忽略${nM}个其他类型文件`)}}else if(!P&&w){const nM=UM+bM;nM&&iM.push(`仅支持上传图片(.jpg/.jpeg/.png/.bmp),已忽略${nM}个其他类型文件`)}else bM&&iM.push(`存在不支持的文件类型,已忽略${bM}个文件`);if(iM.length&&ie("warning",iM.join(";"),"precheck-warn"),R.length){const nM=Math.max(0,He-cM.length),XM=R.slice(0,nM);XM.forEach(ve=>vj(ve)),R.length>XM.length&&ie("warning",`最多上传${He}张图片`)}jM.length&&((ZM=(aM=uN.current)==null?void 0:aM.appendFiles)==null||ZM.call(aM,jM))},Pj=T=>{var w;const o=(w=T.clipboardData)==null?void 0:w.files;o&&o.length&&(T.preventDefault(),T.stopPropagation(),Gj(o))},Rj=T=>{T.preventDefault()},Wj=T=>{var w;T.preventDefault(),T.stopPropagation();const o=(w=T.dataTransfer)==null?void 0:w.files;o&&o.length&&Gj(o)},Zj=()=>uM(exports,null,function*(){var T;return(T=j==null?void 0:j.data)!=null&&T.id?j:(qe.current||(qe.current=new Promise((o,w)=>{_e(!0),D==null||D({netOpen:I?Ge.OPEN:Ge.CLOSE}).then(P=>{var R,jM;g==null||g(P),_e(!1),u(!!((R=P.data)!=null&&R.netOpen)),cN(!!((jM=P.data)!=null&&jM.enableNetOpen)),Et(P),o(P)}).catch(P=>{qe.current=null,w(P)})})),qe.current)}),xs=T=>uM(exports,null,function*(){const o=yield Zj();return Ys(o,T)}),Ys=(T,o)=>{const w=oi(o.name);return new Promise(P=>{var jM;const R={files:[`${DN.v4()}.${w}`],isv:"minio",knowledgeId:((jM=T.data)==null?void 0:jM.id)||"",type:1};v==null||v.postTicket(R).then(eM=>{v.uploadMinioFile(eM.minio,o).then(()=>{var Ne,aM;const UM=(Ne=eM.minio.endpoints)==null?void 0:Ne[0],bM=eM.minio.bucket,iM=(aM=eM.minio.fileKeys)==null?void 0:aM[0];P(`${eM.minio.useSSL?"https:":location.protocol}//${UM}/${bM}/${iM}`)}).catch(()=>{})}).catch(()=>{})})},ws=()=>{const T=Z.current;!T||!MM.current||T.scrollTo({top:T.scrollHeight})};z.useLayoutEffect(()=>{ws()},[n]),z.useEffect(()=>{const T=()=>{NM.current=!1;const o=Z.current;(!o||o.scrollTop>-80)&&(x.current=!1)};return window.addEventListener("pointerup",T),()=>window.removeEventListener("pointerup",T)},[]);const _j=(T,o)=>new Promise(w=>{if(!o.file.url||!(N!=null&&N.id))return w();const P=JM(gM({},o.file),{type:1});v==null||v.postApplicationIdSessionKnowledgeSessionFile(N==null?void 0:N.id,T,P).finally(()=>{var R;(R=uN.current)==null||R.update().finally(w)})}),Es=()=>{var T;(T=j==null?void 0:j.data)!=null&&T.id&&(ye(!1),j.suspend())},hs=T=>{const o=Z.current;o&&(MM.current=!0,x.current=!1,dt(!1),setTimeout(()=>{o.scrollTo({top:o.scrollHeight,behavior:T==null?void 0:T.behavior})},T==null?void 0:T.ms))},Bj=()=>{x.current=!0},Qs=T=>{var w;const o=(w=T.target)==null?void 0:w.closest(".bottom-right");o instanceof HTMLElement&&o.scrollHeight>o.clientHeight+1||(Bj(),requestAnimationFrame(()=>{const P=Z.current;x.current&&P&&P.scrollTop>-80&&(x.current=!1)}))},Ss=T=>{const o=T.currentTarget,{offsetX:w,offsetY:P}=T.nativeEvent;(w>o.clientWidth||P>o.clientHeight)&&(NM.current=!0,Bj())},ms=()=>{const T=Z.current;if(!T)return;if(!(T.scrollTop<=-80)){MM.current=!0,x.current=!1,dt(!1);return}(x.current||NM.current)&&(MM.current=!1,x.current=!1,dt(!0))},ks=we.useMemoizedFn(T=>{var o,w;(o=SM.current)==null||o.update(T),(w=SM.current)==null||w.focus()}),fs=we.useMemoizedFn(T=>{wt(T)}),Us=we.useMemoizedFn(()=>{var o;if(!((o=j==null?void 0:j.data)!=null&&o.id))return;f.current=[...n.slice(1,n.length)],y(f.current);const T=new Fe("",j.data.id,J.IHistoryRole.System);T.isWaiting=!0,f.current=[T,...f.current],y(f.current),Oe(!0),ye(!0),j.answerAgain()});z.useEffect(()=>{var T,o;IM.current=(T=j==null?void 0:j.data)==null?void 0:T.id,!Sj&&((o=lt.current)==null||o.clear())},[j]);const ps=()=>{var w;if(!((w=j==null?void 0:j.data)!=null&&w.id))return;const o=n[n.length-1].messageTime;j.fetchMessages({endTime:o,pageSize:Qi}).then(P=>{const R=P||[];if(!R||!(R!=null&&R.length)){TN(!1);return}R.length<10?TN(!1):TN(!0),y([...n,...R.reverse()])})},bs=T=>uM(exports,null,function*(){var o,w;if(!((o=j==null?void 0:j.data)!=null&&o.id))u(T);else{if(yield j.setNetOpen(T),!((w=j.data)!=null&&w.id))return;u(T)}}),Qt=()=>uM(exports,null,function*(){j?j.fetchData().then(T=>{var o;(o=j==null?void 0:j.data)!=null&&o.id&&(u(T.netOpen),cN(T.enableNetOpen))}):(u(typeof(E==null?void 0:E.connectNetwork)=="object"&&typeof(E==null?void 0:E.connectNetwork.default)=="boolean"?E.connectNetwork.default:!1),cN(N.arrange[0].enableNetOpen))});z.useEffect(()=>{Qt()},[j]),z.useEffect(()=>{let T=null,o=null;const w=()=>{var iM,Ne;if(!Z.current)return;const R=document.getElementById("chat-main"),jM=(iM=Z.current)==null?void 0:iM.querySelector(".infinite-scroll-component__outerdiv"),eM=(Ne=Z.current)==null?void 0:Ne.querySelector(".infinite-scroll-component");if(!jM||!eM||!R)return;const UM=R.offsetHeight;if(eM.offsetHeight<=UM){if(jM.style.height==="100%")return;jM.style.height="100%"}else{if(jM.style.height==="auto")return;jM.style.height="auto"}},P=()=>{var eM;if(typeof ResizeObserver=="undefined"||!Z.current)return;const R=document.getElementById("chat-main"),jM=(eM=Z.current)==null?void 0:eM.querySelector(".infinite-scroll-component");!jM||!R||(o=new ResizeObserver(()=>{w()}),o.observe(jM),o.observe(R))};return T=requestAnimationFrame(()=>{w(),P()}),()=>{T!==null&&cancelAnimationFrame(T),o==null||o.disconnect()}},[n]),z.useEffect(()=>{if(j)return;const T=()=>{const P=((b==null?void 0:b.promptVariables)||[]).filter(R=>R.type?!(R.type===J.PromptVariableType.User&&R.key==="query")&&!(R.type===J.PromptVariableType.System&&R.key==="datetime")&&R.status===1:R.key!=="query"&&R.status===1).map((R,jM)=>{var UM,bM;let eM="";return typeof(E==null?void 0:E.promptVariables)=="object"&&(eM=((bM=(UM=E.promptVariables.default)==null?void 0:UM.find(iM=>iM.key===R.key&&iM.type===R.type))==null?void 0:bM.value)||""),{id:jM+"",key:R.key,name:R.name,value:eM,type:R.type}});nN([...P].sort((R,jM)=>R.key.localeCompare(jM.key)))};return b!=null&&b.ready?T():b==null||b.addEventListener("ready",T),()=>{b==null||b.removeEventListener("ready",T)}},[j,b,E==null?void 0:E.promptVariables]);const Jj=()=>D==null?void 0:D({netOpen:I?Ge.OPEN:Ge.CLOSE}).then(T=>{var o,w;return g==null||g(T),_e(!1),u(!!((o=T.data)!=null&&o.netOpen)),cN(!!((w=T.data)!=null&&w.enableNetOpen)),Et(T),T}),Fj=!!n.length,Hj=z.useMemo(()=>{var T;return N.arrange&&((T=N.arrange[0])!=null&&T.openingContent)?i.jsx(tD,{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:Fj,markdown:E==null?void 0:E.markdown}):null},[N==null?void 0:N.arrange,Fj]);z.useImperativeHandle(e,()=>({getCurrentInputText:()=>{var T;return(T=SM.current)==null?void 0:T.getCurrentText()},send:T=>uM(exports,null,function*(){if(!(yield wt(T)))throw new Error("send was blocked")})})),z.useEffect(()=>{var o;const T=(o=j==null?void 0:j.data)==null?void 0:o.id;T&&IN(w=>JM(gM({},w),{[T]:[]}))},[(Kj=j==null?void 0:j.data)==null?void 0:Kj.id]);const Vj=!!dM&&(K==null?void 0:K.picker)!==!1;return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:`agent-chat${Vj?" with-workspace-tree":""}`,children:[Vj&&dM&&i.jsx(og,{workspace:dM,disclosureText:K==null?void 0:K.disclosureText,disclosure:K==null?void 0:K.disclosure,getContainer:l,highlight:tM,disabled:TM}),i.jsxs("div",{className:"agent-chat-column",children:[Ls?i.jsx("div",{className:"session-loading",children:i.jsx(a.Spin,{})}):i.jsxs(i.Fragment,{children:[(h==null?void 0:h.promptVariables)&&i.jsx(zD,{ref:Ej,appId:N.id,currentSession:j,promptVariables:Te,setPromptVariables:nN,setCurrentSession:g}),i.jsxs("div",{className:"chat-main",id:"chat-main",style:wM,children:[i.jsx("div",{className:"chat-main-wrapper",id:"scrollableDiv",style:{height:"100%",overflowY:"auto",display:"flex",flexDirection:"column-reverse"},ref:Z,onScroll:ms,onWheel:Qs,onPointerDown:Ss,children:(qj=j==null?void 0:j.data)!=null&&qj.id&&(n!=null&&n.length)?i.jsxs(_s,{dataLength:n.length,next:ps,style:{display:"flex",flexDirection:"column-reverse",overflowX:"hidden",overflowAnchor:"none"},inverse:!0,endMessage:n.length>Qi&&((Mi=Z.current)!=null&&Mi.scrollTop)&&((ei=Z.current)==null?void 0:ei.scrollTop)<-10?i.jsx(a.Divider,{plain:!0,children:"没有更多数据了"}):null,hasMore:mj,loader:i.jsx("div",{style:{height:"50px",textAlign:"center",overflow:"hidden"},children:i.jsx(a.Spin,{})}),scrollableTarget:"scrollableDiv",children:[n.map((T,o)=>i.jsx(kg,{application:N,currentSession:j,history:T,docViewerUrl:t,isLastHistory:o===0,onRelatedClick:fs,onAgainClick:Us,onEditClick:ks,markdown:E==null?void 0:E.markdown},T.renderKey||`${T.messageId}-${o}`)),!mj&&Hj]}):i.jsxs("div",{className:"main-empty",children:[(E==null?void 0:E.greeting)!==!1&&i.jsx(Zz,{text:E!=null&&E.greeting&&typeof E.greeting=="object"&&E.greeting.text!==void 0?E.greeting.text:(Ni=N.arrange)!=null&&Ni.length&&((ti=N.arrange[0])!=null&&ti.greetings)?N.arrange[0].greetings:hi.text,icon:E===void 0||E.greeting===!0||((ji=E.greeting)==null?void 0:ji.icon)===void 0?X||hi.icon:E.greeting.icon,children:!!fM.length&&(((E==null?void 0:E.greeting)===void 0||(E==null?void 0:E.greeting))===!0||typeof(E==null?void 0:E.greeting)=="object"&&E.greeting.questions!==!1)&&i.jsx(DD,{ref:lt,sid:(ii=j==null?void 0:j.data)==null?void 0:ii.id,isRecommendClearing:VM,data:fM,layoutBreakpoints:typeof(E==null?void 0:E.greeting)=="object"?E.greeting.layoutBreakpoints:void 0,onItemClick:T=>{var w,P,R;if(m(T==null?void 0:T.question),de(T==null?void 0:T.question),VM)return;T!=null&&T.id&&ge(!0);const o=(w=j==null?void 0:j.data)==null?void 0:w.id;h!=null&&h.fileUpload?(R=(P=uN.current)==null?void 0:P.clear())==null||R.then(()=>{var jM,eM;T!=null&&T.id&&(o?(jM=_j(o,T))==null||jM.finally(()=>{ge(!1)}):(ge(!1),_e(!0),(eM=Jj())==null||eM.then(UM=>{var bM;(bM=_j(UM.id,T))==null||bM.finally(()=>{ge(!1)})})))}):o?ge(!1):(ge(!1),_e(!0),Jj())}})}),Hj]})}),Qj&&i.jsx("div",{className:"session-stop",children:i.jsx(a.Button,{type:"primary",style:{background:"white"},ghost:!0,size:"small",icon:i.jsx(yM,{type:"icon-zantinghuida",style:{fontSize:16}}),onClick:()=>Es(),children:"停止回答"})}),ns&&(n==null?void 0:n.length)>0&&i.jsx("div",{className:"back-bottom",children:i.jsx(a.Button,{size:"small",onClick:()=>hs({behavior:"smooth"}),type:"link",icon:i.jsx(yM,{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((T,o)=>i.jsx(Pz,{className:"thumb-40",file:T,actions:{upload:w=>uM(exports,null,function*(){kM(P=>P+1);try{return yield xs(w)}finally{kM(P=>Math.max(0,P-1))}}),remove:()=>{DM(w=>w.filter((P,R)=>R!==o)),GM(w=>w.filter((P,R)=>R!==o))}},onUrlChange:w=>{GM(P=>{const R=[...P];return R[o]=w,R})}},o))}),dM&&i.jsx(Sg,{workspace:dM}),dM&&EM&&i.jsx(hg,{bridge:EM,getContainer:l}),i.jsxs("div",{className:"footer-upload-action-wrapper",children:[i.jsxs(a.Space,{className:"footer-upload-action",onClick:T=>T.preventDefault(),children:[i.jsxs(a.Space,{children:[(N.type===J.ApplicationTypes.Agent&&(h==null?void 0:h.imageUpload)||N.type===J.ApplicationTypes.Dialog&&((Di=N.arrange)==null?void 0:Di.length)&&!!N.arrange[0].visionOpen&&(h==null?void 0:h.imageUpload))&&i.jsx(a.Upload,{multiple:!0,disabled:cM.length>=He||TM,accept:".jpg, .png, .jpeg,.bmp",listType:"picture-card",beforeUpload:vj,className:"footer-upload-picture",showUploadList:!1,children:cM.length<He?i.jsx(a.Tooltip,{placement:"topLeft",overlayClassName:"footer-upload-tooltip",title:i.jsx("div",{children:`支持上传.jpg .png .jpeg
|
|
15
|
-
.bmp格式的图片数据,单文件最大${pt}M,最多${He}张`}),children:i.jsx(a.Button,{type:"text",className:"camera-out-btn",style:{width:"22px",position:"relative",bottom:"-2px"},icon:i.jsx(yM,{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(yM,{type:"icon-shangchuantupian",className:"icon-tianjia",style:{fontSize:"22px"}})})}),s&&(h!=null&&h.fileUpload)&&(N!=null&&N.id)?i.jsx(sD,{appId:N==null?void 0:N.id,allowExcelAttachment:N.type===J.ApplicationTypes.Agent,ref:uN,isFirstSession:Sj,docViewerUrl:t,onStatusChange:T=>uM(exports,null,function*(){T!=="process"?(bN(!0),Qt()):bN(!1)}),createSession:()=>Zj().then(T=>{var w;return((w=T.data)==null?void 0:w.id)||""}),sid:(si=j==null?void 0:j.data)==null?void 0:si.id,disabled:Ct||TM,afterFileAdd:(T,o)=>{o&&IN(w=>{const P=w[o]||[];return{[o]:[...P,T]}})},afterFileDelete:T=>{var w;const o=(w=j==null?void 0:j.data)==null?void 0:w.id;o&&IN(P=>{const R=P[o]||[];return{[o]:R.filter(jM=>jM.id!==T)}})},onFileListChange:T=>{zs(T)},shouldContinue:Is,afterFilesClear:()=>{var o;const T=(o=j==null?void 0:j.data)==null?void 0:o.id;T&&(IN({[T]:[]}),Qt())}}):null,(h==null?void 0:h.prompt)&&(N==null?void 0:N.id)&&i.jsx(zg,{appId:N.id,list:[],search:pe?fN:"",onPromptSelect:T=>{de(T.context),m(T.context)},disabled:TM})]}),i.jsxs(a.Space,{children:[(h==null?void 0:h.connectNetwork)&&N.type===J.ApplicationTypes.Dialog&&((zi=N.arrange)==null?void 0:zi.length)&&!!N.arrange[0].enableNetOpen&&i.jsx(Ng,{sessionId:(gi=j==null?void 0:j.data)==null?void 0:gi.id,netStatus:I,enable:typeof(E==null?void 0:E.connectNetwork)=="object"&&typeof(E==null?void 0:E.connectNetwork.diabled)=="boolean"?!(E!=null&&E.connectNetwork.diabled):as,disabledTip:j?void 0:"网络访问已被禁用",onNetStatusChange:T=>{bs(T)}}),(h==null?void 0:h.sessionList)&&i.jsx(Kz,{currentSessionId:(Ii=j==null?void 0:j.data)==null?void 0:Ii.id,onSessionChange:(T,o)=>{de(void 0),PN(!0),g==null||g(o)},disabled:TM}),lM&&pM==="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:T=>T.parentNode,content:"会话历史记录",children:i.jsx(a.Button,{className:"history-overlay-action",disabled:TM,type:"text",icon:i.jsx(yM,{type:"icon-lishijilu",style:{fontSize:24}}),onClick:()=>Uj(!0)})})}),(h==null?void 0:h.sessionOpen)&&i.jsx(a.Button,{icon:i.jsx(LM.PlusOutlined,{}),className:"add-btn",type:"primary",disabled:Qj||!j||!n.length||TM,onClick:()=>{var T,o;PN(!1),g==null||g(null),qe.current=null,u(!1),(T=Ej.current)==null||T.clear(),(o=lt.current)==null||o.clear()},children:"新会话"})]})]}),!!Ot&&i.jsx("div",{className:"remainingSeconds-mark"})]}),i.jsxs("div",{className:"footer-textarea",onPaste:Pj,onPasteCapture:Pj,onDrop:Wj,onDropCapture:Wj,onDragOver:Rj,onDragOverCapture:Rj,children:[i.jsx(iD,{ref:SM,maxLength:_,text:pN,networkStatus:!1,loading:kj||GN,disabled:H||PM||TM||kj||GN,onTextSend:wt,onChange:(T,o)=>{de(T);const w=o.getText().replace(/[\n\s]+$/,"");m(w),UN(w),pe||kN(!0)},clearAction:i.jsx(a.Space,{size:0,children:i.jsx(a.Button,{type:"link",disabled:Ct||TM,ghost:!0,icon:i.jsx(yM,{style:{fontSize:22},type:"icon-qingchujiyi"}),onClick:()=>ls()})})}),!!Ot&&i.jsxs("div",{className:"remainingSeconds-time",children:["您之前对话触发敏感词拦截,当前处于禁言状态,暂时无法发送消息,剩余禁言时长",Ot]})]})]})}),i.jsx(Bz,{tips:F}),hj&&i.jsx(Hz,{isvisible:hj,files:ss,sessionId:(ui=j==null?void 0:j.data)==null?void 0:ui.id,onClose:T=>{Ds(!1),us(!1)}})]}),fj&&i.jsx(eg,{currentSession:j,application:N,networkStatus:I,setCurrentSession:g,disabled:TM,isSessionHistoryVisible:fj,setIsSessionHistoryVisible:Uj,onSessionChange:T=>{PN(!0)}})]})]}),Yt&&RN&&L.length>0&&Zi.createPortal(i.jsxs("div",{className:"artifacts-dock",ref:bj,children:[i.jsxs("div",{className:`artifacts-drawer${c?" is-open":""}`,children:[i.jsxs("button",{type:"button",className:"artifacts-handle",onClick:()=>r(T=>!T),children:[i.jsx("span",{className:"artifacts-handle-text",children:"产出物"}),c?i.jsx(LM.RightOutlined,{}):i.jsx(LM.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(mz,{artifacts:L,activeArtifact:C,onPreview:O})]}),aN.preview==="column"&&C&&i.jsx(Gz,{artifact:C,style:aN.style,onClose:()=>O(null)})]})]}),i.jsx(vz,{placement:aN.preview,artifact:C,style:aN.style,onClose:()=>O(null),getContainer:()=>bj.current||Yt})]}),Yt)]})});const TD=M=>{const{disabled:e,checkedValues:N,currKnowledgeList:t,selectCount:j,onSelectChange:D}=M,[s,g]=z.useState(!1),I=i.jsx(a.Checkbox.Group,{style:{width:"100%"},onChange:D,value:N,disabled:e,children:i.jsx(a.Row,{gutter:[20,12],children:t==null?void 0:t.map(n=>i.jsx(a.Col,{span:24,children:i.jsx(a.Checkbox,{value:n.id,children:n.name})},n.id))})}),u=n=>{g(n)};return i.jsx("div",{className:"knowledge-select",style:{borderColor:s?"#9C24F2":"#84868C"},children:i.jsx(a.Popover,{className:"select-popover",placement:"bottomRight",title:null,content:I,trigger:"click",overlayStyle:{width:280},onOpenChange:u,getPopupContainer:n=>n.parentNode,children:i.jsxs("div",{className:"",onClick:n=>n.preventDefault(),children:[i.jsx(yM,{className:"select-icon",type:"icon-open"}),i.jsx("span",{className:"title",children:"参考知识库"}),i.jsxs("span",{className:"content",children:["已选 ",j," 个"]})]})})})},pg=M=>{var C,O;const{currentSession:e,application:N,setCheckKnowledges:t}=M,{mode:j,transform:D,features:s}=z.useContext(HM),[g,I]=z.useState([]),[u,n]=z.useState(typeof(s==null?void 0:s.knowledges)=="object"?((C=s.knowledges.default)==null?void 0:C.map(S=>S.id))||[]:[]),[y,L]=z.useState(0),[A,c]=z.useState(!1);z.useEffect(()=>{if(!(N!=null&&N.id))return;const S=N.arrange;if(!(S!=null&&S.length))return;const m=S[0].knowledges||[];I(m);const U=typeof(s==null?void 0:s.knowledges)=="object"&&s.knowledges.default||m;if(Array.isArray(U)&&U.some(x=>Array.isArray(x.fileIds)&&x.fileIds.length===0))throw Error("fileIds cannot be an empty array");if(Nt(U||[])>Pe)throw Error(`knowledges and fileIds total count cannot exceed ${Pe}`);if(!e){n(U.map(MM=>MM.id)),L(U.length),t==null||t(U);return}const Z=()=>{const MM=e.knowledges||U;L(MM.length);const x=MM.map(NM=>NM.id);n(x)};return Z(),e.addEventListener("data:updated",Z),()=>{e==null||e.removeEventListener("data:updated",Z)}},[N,e]),z.useEffect(()=>{var Q;if(!A||(c(!1),!(N!=null&&N.id)))return;const S=[];u==null||u.map(m=>{const U=g==null?void 0:g.find(W=>W.id===m);S.push(U)}),(Q=e==null?void 0:e.data)!=null&&Q.id&&e.setKnowledges(S)},[A]);const r=S=>{c(!0),n(S);const Q=[];S==null||S.map(m=>{const U=g==null?void 0:g.find(W=>W.id===m);Q.push(U)}),t==null||t(Q),L(S.length)};return i.jsxs("div",{className:"chat-header",children:[i.jsxs(a.Space,{className:"header-title",children:[j==="inlay"&&((O=e==null?void 0:e.data)==null?void 0:O.name),j==="float"&&(N==null?void 0:N.name)]}),(D==null?void 0:D.knowledges)&&g.length!==0&&i.jsx(TD,{disabled:typeof(s==null?void 0:s.knowledges)=="object"&&(s==null?void 0:s.knowledges.diabled)||!1,checkedValues:u,currKnowledgeList:g,selectCount:y,onSelectChange:r})]})};const bg=z.forwardRef((M,e)=>{const{sessionId:N,appId:t,docViewerUrl:j}=M,[D,s]=z.useState(),{showHeader:g,agentClient:I,sider:u,onSessionLoad:n,features:y,mode:L}=z.useContext(HM),[A,c]=z.useState(),r=z.useRef(null),[C,O]=z.useState(""),[S,Q]=z.useState(),m=z.useRef(null),[U,W]=z.useState(!1);z.useState([]);const{setIsSwitchingToExistingSession:Z}=jj();z.useEffect(()=>{var x;W(D?!!((x=D.data)!=null&&x.netOpen):typeof(y==null?void 0:y.connectNetwork)=="object"&&typeof(y==null?void 0:y.connectNetwork.default)=="boolean"?y.connectNetwork.default:!1)},[D]),z.useEffect(()=>{const x=()=>uM(exports,null,function*(){const NM=I==null?void 0:I.application;if(!(NM!=null&&NM.id))return;const v=NM==null?void 0:NM.arrange;if(!(v!=null&&v.length))return;const G=v[0].embeddingService;O(G),c(NM)});if(I!=null&&I.ready){x();return}return I==null||I.addEventListener("ready",()=>x()),()=>{I==null||I.removeEventListener("ready",x)}},[I]),z.useEffect(()=>{I&&N&&(I.ready?I==null||I.getSessions().then(x=>uM(exports,null,function*(){s==null||s(x.find(NM=>NM.id===N))})):I.addEventListener("ready",()=>uM(exports,null,function*(){I==null||I.getSessions().then(x=>uM(exports,null,function*(){s==null||s(x.find(NM=>NM.id===N))}))}),!0))},[I,N]),z.useEffect(()=>{if(!D){n&&n({applicationId:t,sessionId:"",session:null,sessionInstance:null});return}D.data&&n&&n({applicationId:t,sessionId:D.data.id,session:D.data,sessionInstance:D}),D.addEventListener("data:loaded",()=>{D!=null&&D.data&&n&&n({applicationId:t,sessionId:D.data.id,session:D.data,sessionInstance:D})},!0)},[D]);const MM=x=>{var NM;return(NM=r.current)==null?void 0:NM.create(JM(gM({},x),{knowledges:S}))};return z.useImperativeHandle(e,()=>({createSession:x=>MM(x),getSessionList:()=>{var NM;const x=((NM=r.current)==null?void 0:NM.list())||[];return Promise.resolve(x)},getCurrentInputText:()=>{var x;return(x=m.current)==null?void 0:x.getCurrentInputText()},send:x=>{var NM;return(NM=m.current)!=null&&NM.send?m.current.send(x):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:u&&L==="inlay"?"block":"none"},children:i.jsx(ij,{ref:r,appId:t,networkStatus:U,currentSession:D,application:A,setCurrentSession:s,checkKnowledges:S,setCheckKnowledges:g?Q:void 0,sessionId:N,afterSessionClick:x=>{var NM,v;((NM=x.data)==null?void 0:NM.id)!==((v=D==null?void 0:D.data)==null?void 0:v.id)&&Z(!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(pg,{setCheckKnowledges:Q,application:A,currentSession:D})}),i.jsx("div",{className:"dialog-chat-content",children:(A==null?void 0:A.id)&&i.jsx(Ug,{setNetworkStatus:W,networkStatus:U,application:A,currentSession:D,onCreateSession:MM,docViewerUrl:j,embeddingService:C,setCurrentSession:s,ref:m})})]})})]})})}),vg=z.forwardRef((M,e)=>{const{className:N,triggerButton:t,size:j,theme:D,icon:s,docViewerUrl:g,token:I,debug:u,env:n,plugins:y,mcp:L,footer:A,defaultInput:c,onComment:r,onSessionLoad:C,onSessionUnload:O,onMessage:S,beforeMessageSend:Q,bodyStyle:m,apiUrl:U,sessionId:W,disabled:Z,transform:MM,features:x,stream:NM,agentClient:v,application:b}=M,G=z.useRef(null),[F,h]=z.useState(!1),[zM,mM]=z.useState(),[CM,YM]=z.useState(j),[wM,TM]=z.useState(M.open),E=z.useRef(null);z.useEffect(()=>{b&&(console.log("[AgentClientUI] token",v,b),mM(b.id))},[b]),a.ConfigProvider.config({theme:D}),z.useEffect(()=>{j&&YM(j)},[j]);const d=(X,{element:lM,size:pM})=>{YM({width:Number(pM.width),height:pM.height})};return z.useImperativeHandle(e,()=>({createSession:X=>{var lM;return(lM=E.current)==null?void 0:lM.createSession(X)},getSessionList:()=>{var X;return(X=E.current)==null?void 0:X.getSessionList()},getCurrentInputText:()=>{var X;return(X=E.current)==null?void 0:X.getCurrentInputText()},send:X=>{var lM;return(lM=E.current)!=null&&lM.send?E.current.send(X):Promise.reject(new Error("send is not available"))}})),i.jsx(a.ConfigProvider,{locale:Bi,children:i.jsxs(Hi,{value:JM(gM({},M),{popupContainer:G,agentClient:v,footer:A,defaultInput:c,onComment:r,onSessionLoad:C,onSessionUnload:O,onMessage:S,beforeMessageSend:Q,bodyStyle:m,disabled:Z,transform:MM,features:x}),children:[i.jsx(Rs.Resizable,{height:(CM==null?void 0:CM.height)||"100%",width:(CM==null?void 0:CM.width)||"100%",maxConstraints:[document.body.clientWidth-45],minConstraints:[Number(j==null?void 0:j.minWidth)],onResize:d,handle:i.jsx("span",{className:"resize-handle-ew"}),resizeHandles:N=="float"?["w"]:[],children:i.jsxs("div",{id:"dialog-modal",className:`gbot-dialog-modal ${N} ${wM?"opened":"closed"}`,style:JM(gM({},j),{width:N=="float"?CM==null?void 0:CM.width:j==null?void 0:j.width,height:N==="float"?CM==null?void 0:CM.height:j==null?void 0:j.height,maxHeight:"100vh"}),ref:G,children:[F?i.jsx("div",{className:"loading",children:i.jsx(a.Spin,{})}):zM&&v?i.jsx(qz,{children:i.jsx(bg,{ref:E,appId:zM,docViewerUrl:g,bodyStyle:m,sessionId:W})}):null,(t==null?void 0:t.visible)&&i.jsx(a.Button,{className:"trigger-btn close-btn",icon:i.jsx("img",{src:s}),onClick:()=>TM(!1)})]})}),(t==null?void 0:t.visible)&&!wM&&i.jsx(a.Button,{className:`${N}-trigger-btn open-btn`,style:t.style,icon:i.jsx("img",{src:s}),onClick:()=>TM(!0)})]})})}),Gg="@glodon-aiot/agent-cli-ui",Pg="3.26.0-alpha.4",Rg="./dist/es/index.mjs",Wg="./dist/lib/index.js",Zg="./dist/src/index.d.ts",_g={import:"./dist/es/index.mjs",require:"./dist/lib/index.js",types:"./dist/src/index.d.ts"},Bg=["dist"],Jg="module",Fg="dist/src/index.d.ts",Hg={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"},Vg={"@ant-design/icons":"^5.3.4","@glodon-aiot/apis":"^3.26.0-alpha.4","@glodon-aiot/bot-client-sdk":"^3.26.0-alpha.4","@glodon-aiot/react-components":"^3.26.0-alpha.4","@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"},Xg={"@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"},$g=[">0.2%","not dead","not op_mini all"],Kg=["last 1 chrome version","last 1 firefox version","last 1 safari version"],qg={commitizen:{path:"node_modules/cz-customizable"},"cz-customizable":{config:".cz-config.cjs"}},MI={access:"public",registry:"https://registry.npmjs.org/"},eI={hooks:{"commit-msg":"validate-commit-msg"}},NI={name:Gg,version:Pg,module:Rg,main:Wg,typings:Zg,exports:_g,files:Bg,type:Jg,types:Fg,scripts:Hg,dependencies:Vg,devDependencies:Xg,"lint-staged":{"*.{js,css,md,jsx,less,ts,tsx,json}":"prettier --write"},production:$g,development:Kg,config:qg,publishConfig:MI,husky:eI};var cD=(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))(cD||{});//! moment.js
|
|
15
|
+
.bmp格式的图片数据,单文件最大${pt}M,最多${He}张`}),children:i.jsx(a.Button,{type:"text",className:"camera-out-btn",style:{width:"22px",position:"relative",bottom:"-2px"},icon:i.jsx(yM,{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(yM,{type:"icon-shangchuantupian",className:"icon-tianjia",style:{fontSize:"22px"}})})}),s&&(h!=null&&h.fileUpload)&&(N!=null&&N.id)?i.jsx(sD,{appId:N==null?void 0:N.id,allowExcelAttachment:N.type===J.ApplicationTypes.Agent,ref:uN,isFirstSession:Sj,docViewerUrl:t,onStatusChange:T=>uM(exports,null,function*(){T!=="process"?(bN(!0),Qt()):bN(!1)}),createSession:()=>Zj().then(T=>{var w;return((w=T.data)==null?void 0:w.id)||""}),sid:(si=j==null?void 0:j.data)==null?void 0:si.id,disabled:Ct||TM,afterFileAdd:(T,o)=>{o&&IN(w=>{const P=w[o]||[];return{[o]:[...P,T]}})},afterFileDelete:T=>{var w;const o=(w=j==null?void 0:j.data)==null?void 0:w.id;o&&IN(P=>{const R=P[o]||[];return{[o]:R.filter(jM=>jM.id!==T)}})},onFileListChange:T=>{zs(T)},shouldContinue:Is,afterFilesClear:()=>{var o;const T=(o=j==null?void 0:j.data)==null?void 0:o.id;T&&(IN({[T]:[]}),Qt())}}):null,(h==null?void 0:h.prompt)&&(N==null?void 0:N.id)&&i.jsx(zg,{appId:N.id,list:[],search:pe?fN:"",onPromptSelect:T=>{de(T.context),m(T.context)},disabled:TM})]}),i.jsxs(a.Space,{children:[(h==null?void 0:h.connectNetwork)&&N.type===J.ApplicationTypes.Dialog&&((zi=N.arrange)==null?void 0:zi.length)&&!!N.arrange[0].enableNetOpen&&i.jsx(Ng,{sessionId:(gi=j==null?void 0:j.data)==null?void 0:gi.id,netStatus:I,enable:typeof(E==null?void 0:E.connectNetwork)=="object"&&typeof(E==null?void 0:E.connectNetwork.diabled)=="boolean"?!(E!=null&&E.connectNetwork.diabled):as,disabledTip:j?void 0:"网络访问已被禁用",onNetStatusChange:T=>{bs(T)}}),(h==null?void 0:h.sessionList)&&i.jsx(Kz,{currentSessionId:(Ii=j==null?void 0:j.data)==null?void 0:Ii.id,onSessionChange:(T,o)=>{de(void 0),PN(!0),g==null||g(o)},disabled:TM}),lM&&pM==="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:T=>T.parentNode,content:"会话历史记录",children:i.jsx(a.Button,{className:"history-overlay-action",disabled:TM,type:"text",icon:i.jsx(yM,{type:"icon-lishijilu",style:{fontSize:24}}),onClick:()=>Uj(!0)})})}),(h==null?void 0:h.sessionOpen)&&i.jsx(a.Button,{icon:i.jsx(LM.PlusOutlined,{}),className:"add-btn",type:"primary",disabled:Qj||!j||!n.length||TM,onClick:()=>{var T,o;PN(!1),g==null||g(null),qe.current=null,u(!1),(T=Ej.current)==null||T.clear(),(o=lt.current)==null||o.clear()},children:"新会话"})]})]}),!!Ot&&i.jsx("div",{className:"remainingSeconds-mark"})]}),i.jsxs("div",{className:"footer-textarea",onPaste:Pj,onPasteCapture:Pj,onDrop:Wj,onDropCapture:Wj,onDragOver:Rj,onDragOverCapture:Rj,children:[i.jsx(iD,{ref:SM,maxLength:_,text:pN,networkStatus:!1,loading:kj||GN,disabled:H||PM||TM||kj||GN,onTextSend:wt,onChange:(T,o)=>{de(T);const w=o.getText().replace(/[\n\s]+$/,"");m(w),UN(w),pe||kN(!0)},clearAction:i.jsx(a.Space,{size:0,children:i.jsx(a.Button,{type:"link",disabled:Ct||TM,ghost:!0,icon:i.jsx(yM,{style:{fontSize:22},type:"icon-qingchujiyi"}),onClick:()=>ls()})})}),!!Ot&&i.jsxs("div",{className:"remainingSeconds-time",children:["您之前对话触发敏感词拦截,当前处于禁言状态,暂时无法发送消息,剩余禁言时长",Ot]})]})]})}),i.jsx(Bz,{tips:F}),hj&&i.jsx(Hz,{isvisible:hj,files:ss,sessionId:(ui=j==null?void 0:j.data)==null?void 0:ui.id,onClose:T=>{Ds(!1),us(!1)}})]}),fj&&i.jsx(eg,{currentSession:j,application:N,networkStatus:I,setCurrentSession:g,disabled:TM,isSessionHistoryVisible:fj,setIsSessionHistoryVisible:Uj,onSessionChange:T=>{PN(!0)}})]})]}),Yt&&RN&&L.length>0&&Zi.createPortal(i.jsxs("div",{className:"artifacts-dock",ref:bj,children:[i.jsxs("div",{className:`artifacts-drawer${c?" is-open":""}`,children:[i.jsxs("button",{type:"button",className:"artifacts-handle",onClick:()=>r(T=>!T),children:[i.jsx("span",{className:"artifacts-handle-text",children:"产出物"}),c?i.jsx(LM.RightOutlined,{}):i.jsx(LM.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(mz,{artifacts:L,activeArtifact:C,onPreview:O})]}),aN.preview==="column"&&C&&i.jsx(Gz,{artifact:C,style:aN.style,onClose:()=>O(null)})]})]}),i.jsx(vz,{placement:aN.preview,artifact:C,style:aN.style,onClose:()=>O(null),getContainer:()=>bj.current||Yt})]}),Yt)]})});const TD=M=>{const{disabled:e,checkedValues:N,currKnowledgeList:t,selectCount:j,onSelectChange:D}=M,[s,g]=z.useState(!1),I=i.jsx(a.Checkbox.Group,{style:{width:"100%"},onChange:D,value:N,disabled:e,children:i.jsx(a.Row,{gutter:[20,12],children:t==null?void 0:t.map(n=>i.jsx(a.Col,{span:24,children:i.jsx(a.Checkbox,{value:n.id,children:n.name})},n.id))})}),u=n=>{g(n)};return i.jsx("div",{className:"knowledge-select",style:{borderColor:s?"#9C24F2":"#84868C"},children:i.jsx(a.Popover,{className:"select-popover",placement:"bottomRight",title:null,content:I,trigger:"click",overlayStyle:{width:280},onOpenChange:u,getPopupContainer:n=>n.parentNode,children:i.jsxs("div",{className:"",onClick:n=>n.preventDefault(),children:[i.jsx(yM,{className:"select-icon",type:"icon-open"}),i.jsx("span",{className:"title",children:"参考知识库"}),i.jsxs("span",{className:"content",children:["已选 ",j," 个"]})]})})})},pg=M=>{var C,O;const{currentSession:e,application:N,setCheckKnowledges:t}=M,{mode:j,transform:D,features:s}=z.useContext(HM),[g,I]=z.useState([]),[u,n]=z.useState(typeof(s==null?void 0:s.knowledges)=="object"?((C=s.knowledges.default)==null?void 0:C.map(S=>S.id))||[]:[]),[y,L]=z.useState(0),[A,c]=z.useState(!1);z.useEffect(()=>{if(!(N!=null&&N.id))return;const S=N.arrange;if(!(S!=null&&S.length))return;const m=S[0].knowledges||[];I(m);const U=typeof(s==null?void 0:s.knowledges)=="object"&&s.knowledges.default||m;if(Array.isArray(U)&&U.some(x=>Array.isArray(x.fileIds)&&x.fileIds.length===0))throw Error("fileIds cannot be an empty array");if(Nt(U||[])>Pe)throw Error(`knowledges and fileIds total count cannot exceed ${Pe}`);if(!e){n(U.map(MM=>MM.id)),L(U.length),t==null||t(U);return}const Z=()=>{const MM=e.knowledges||U;L(MM.length);const x=MM.map(NM=>NM.id);n(x)};return Z(),e.addEventListener("data:updated",Z),()=>{e==null||e.removeEventListener("data:updated",Z)}},[N,e]),z.useEffect(()=>{var Q;if(!A||(c(!1),!(N!=null&&N.id)))return;const S=[];u==null||u.map(m=>{const U=g==null?void 0:g.find(W=>W.id===m);S.push(U)}),(Q=e==null?void 0:e.data)!=null&&Q.id&&e.setKnowledges(S)},[A]);const r=S=>{c(!0),n(S);const Q=[];S==null||S.map(m=>{const U=g==null?void 0:g.find(W=>W.id===m);Q.push(U)}),t==null||t(Q),L(S.length)};return i.jsxs("div",{className:"chat-header",children:[i.jsxs(a.Space,{className:"header-title",children:[j==="inlay"&&((O=e==null?void 0:e.data)==null?void 0:O.name),j==="float"&&(N==null?void 0:N.name)]}),(D==null?void 0:D.knowledges)&&g.length!==0&&i.jsx(TD,{disabled:typeof(s==null?void 0:s.knowledges)=="object"&&(s==null?void 0:s.knowledges.diabled)||!1,checkedValues:u,currKnowledgeList:g,selectCount:y,onSelectChange:r})]})};const bg=z.forwardRef((M,e)=>{const{sessionId:N,appId:t,docViewerUrl:j}=M,[D,s]=z.useState(),{showHeader:g,agentClient:I,sider:u,onSessionLoad:n,features:y,mode:L}=z.useContext(HM),[A,c]=z.useState(),r=z.useRef(null),[C,O]=z.useState(""),[S,Q]=z.useState(),m=z.useRef(null),[U,W]=z.useState(!1);z.useState([]);const{setIsSwitchingToExistingSession:Z}=jj();z.useEffect(()=>{var x;W(D?!!((x=D.data)!=null&&x.netOpen):typeof(y==null?void 0:y.connectNetwork)=="object"&&typeof(y==null?void 0:y.connectNetwork.default)=="boolean"?y.connectNetwork.default:!1)},[D]),z.useEffect(()=>{const x=()=>uM(exports,null,function*(){const NM=I==null?void 0:I.application;if(!(NM!=null&&NM.id))return;const v=NM==null?void 0:NM.arrange;if(!(v!=null&&v.length))return;const G=v[0].embeddingService;O(G),c(NM)});if(I!=null&&I.ready){x();return}return I==null||I.addEventListener("ready",()=>x()),()=>{I==null||I.removeEventListener("ready",x)}},[I]),z.useEffect(()=>{I&&N&&(I.ready?I==null||I.getSessions().then(x=>uM(exports,null,function*(){s==null||s(x.find(NM=>NM.id===N))})):I.addEventListener("ready",()=>uM(exports,null,function*(){I==null||I.getSessions().then(x=>uM(exports,null,function*(){s==null||s(x.find(NM=>NM.id===N))}))}),!0))},[I,N]),z.useEffect(()=>{if(!D){n&&n({applicationId:t,sessionId:"",session:null,sessionInstance:null});return}D.data&&n&&n({applicationId:t,sessionId:D.data.id,session:D.data,sessionInstance:D}),D.addEventListener("data:loaded",()=>{D!=null&&D.data&&n&&n({applicationId:t,sessionId:D.data.id,session:D.data,sessionInstance:D})},!0)},[D]);const MM=x=>{var NM;return(NM=r.current)==null?void 0:NM.create(JM(gM({},x),{knowledges:S}))};return z.useImperativeHandle(e,()=>({createSession:x=>MM(x),getSessionList:()=>{var NM;const x=((NM=r.current)==null?void 0:NM.list())||[];return Promise.resolve(x)},getCurrentInputText:()=>{var x;return(x=m.current)==null?void 0:x.getCurrentInputText()},send:x=>{var NM;return(NM=m.current)!=null&&NM.send?m.current.send(x):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:u&&L==="inlay"?"block":"none"},children:i.jsx(ij,{ref:r,appId:t,networkStatus:U,currentSession:D,application:A,setCurrentSession:s,checkKnowledges:S,setCheckKnowledges:g?Q:void 0,sessionId:N,afterSessionClick:x=>{var NM,v;((NM=x.data)==null?void 0:NM.id)!==((v=D==null?void 0:D.data)==null?void 0:v.id)&&Z(!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(pg,{setCheckKnowledges:Q,application:A,currentSession:D})}),i.jsx("div",{className:"dialog-chat-content",children:(A==null?void 0:A.id)&&i.jsx(Ug,{setNetworkStatus:W,networkStatus:U,application:A,currentSession:D,onCreateSession:MM,docViewerUrl:j,embeddingService:C,setCurrentSession:s,ref:m})})]})})]})})}),vg=z.forwardRef((M,e)=>{const{className:N,triggerButton:t,size:j,theme:D,icon:s,docViewerUrl:g,token:I,debug:u,env:n,plugins:y,mcp:L,footer:A,defaultInput:c,onComment:r,onSessionLoad:C,onSessionUnload:O,onMessage:S,beforeMessageSend:Q,bodyStyle:m,apiUrl:U,sessionId:W,disabled:Z,transform:MM,features:x,stream:NM,agentClient:v,application:b}=M,G=z.useRef(null),[F,h]=z.useState(!1),[zM,mM]=z.useState(),[CM,YM]=z.useState(j),[wM,TM]=z.useState(M.open),E=z.useRef(null);z.useEffect(()=>{b&&(console.log("[AgentClientUI] token",v,b),mM(b.id))},[b]),a.ConfigProvider.config({theme:D}),z.useEffect(()=>{j&&YM(j)},[j]);const d=(X,{element:lM,size:pM})=>{YM({width:Number(pM.width),height:pM.height})};return z.useImperativeHandle(e,()=>({createSession:X=>{var lM;return(lM=E.current)==null?void 0:lM.createSession(X)},getSessionList:()=>{var X;return(X=E.current)==null?void 0:X.getSessionList()},getCurrentInputText:()=>{var X;return(X=E.current)==null?void 0:X.getCurrentInputText()},send:X=>{var lM;return(lM=E.current)!=null&&lM.send?E.current.send(X):Promise.reject(new Error("send is not available"))}})),i.jsx(a.ConfigProvider,{locale:Bi,children:i.jsxs(Hi,{value:JM(gM({},M),{popupContainer:G,agentClient:v,footer:A,defaultInput:c,onComment:r,onSessionLoad:C,onSessionUnload:O,onMessage:S,beforeMessageSend:Q,bodyStyle:m,disabled:Z,transform:MM,features:x}),children:[i.jsx(Rs.Resizable,{height:(CM==null?void 0:CM.height)||"100%",width:(CM==null?void 0:CM.width)||"100%",maxConstraints:[document.body.clientWidth-45],minConstraints:[Number(j==null?void 0:j.minWidth)],onResize:d,handle:i.jsx("span",{className:"resize-handle-ew"}),resizeHandles:N=="float"?["w"]:[],children:i.jsxs("div",{id:"dialog-modal",className:`gbot-dialog-modal ${N} ${wM?"opened":"closed"}`,style:JM(gM({},j),{width:N=="float"?CM==null?void 0:CM.width:j==null?void 0:j.width,height:N==="float"?CM==null?void 0:CM.height:j==null?void 0:j.height,maxHeight:"100vh"}),ref:G,children:[F?i.jsx("div",{className:"loading",children:i.jsx(a.Spin,{})}):zM&&v?i.jsx(qz,{children:i.jsx(bg,{ref:E,appId:zM,docViewerUrl:g,bodyStyle:m,sessionId:W})}):null,(t==null?void 0:t.visible)&&i.jsx(a.Button,{className:"trigger-btn close-btn",icon:i.jsx("img",{src:s}),onClick:()=>TM(!1)})]})}),(t==null?void 0:t.visible)&&!wM&&i.jsx(a.Button,{className:`${N}-trigger-btn open-btn`,style:t.style,icon:i.jsx("img",{src:s}),onClick:()=>TM(!0)})]})})}),Gg="@glodon-aiot/agent-cli-ui",Pg="3.26.0-alpha.8",Rg="./dist/es/index.mjs",Wg="./dist/lib/index.js",Zg="./dist/src/index.d.ts",_g={import:"./dist/es/index.mjs",require:"./dist/lib/index.js",types:"./dist/src/index.d.ts"},Bg=["dist"],Jg="module",Fg="dist/src/index.d.ts",Hg={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"},Vg={"@ant-design/icons":"^5.3.4","@glodon-aiot/apis":"^3.26.0-alpha.8","@glodon-aiot/bot-client-sdk":"^3.26.0-alpha.8","@glodon-aiot/react-components":"^3.26.0-alpha.8","@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"},Xg={"@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"},$g=[">0.2%","not dead","not op_mini all"],Kg=["last 1 chrome version","last 1 firefox version","last 1 safari version"],qg={commitizen:{path:"node_modules/cz-customizable"},"cz-customizable":{config:".cz-config.cjs"}},MI={access:"public",registry:"https://registry.npmjs.org/"},eI={hooks:{"commit-msg":"validate-commit-msg"}},NI={name:Gg,version:Pg,module:Rg,main:Wg,typings:Zg,exports:_g,files:Bg,type:Jg,types:Fg,scripts:Hg,dependencies:Vg,devDependencies:Xg,"lint-staged":{"*.{js,css,md,jsx,less,ts,tsx,json}":"prettier --write"},production:$g,development:Kg,config:qg,publishConfig:MI,husky:eI};var cD=(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))(cD||{});//! moment.js
|
|
16
16
|
//! version : 2.30.1
|
|
17
17
|
//! authors : Tim Wood, Iskren Chernev, Moment.js contributors
|
|
18
18
|
//! 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.
|
|
3
|
+
"version": "3.26.0-alpha.8",
|
|
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.
|
|
35
|
-
"@glodon-aiot/bot-client-sdk": "^3.26.0-alpha.
|
|
36
|
-
"@glodon-aiot/react-components": "^3.26.0-alpha.
|
|
34
|
+
"@glodon-aiot/apis": "^3.26.0-alpha.8",
|
|
35
|
+
"@glodon-aiot/bot-client-sdk": "^3.26.0-alpha.8",
|
|
36
|
+
"@glodon-aiot/react-components": "^3.26.0-alpha.8",
|
|
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",
|