@glodon-aiot/agent-cli-ui 3.26.0-alpha.5 → 3.26.0-alpha.9
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
|
@@ -6350,7 +6350,7 @@ const n4 = PN((M, N) => {
|
|
|
6350
6350
|
})]
|
|
6351
6351
|
})
|
|
6352
6352
|
});
|
|
6353
|
-
}), s4 = "@glodon-aiot/agent-cli-ui", c4 = "3.26.0-alpha.
|
|
6353
|
+
}), s4 = "@glodon-aiot/agent-cli-ui", c4 = "3.26.0-alpha.9", L4 = "./dist/es/index.mjs", A4 = "./dist/lib/index.js", y4 = "./dist/src/index.d.ts", r4 = {
|
|
6354
6354
|
import: "./dist/es/index.mjs",
|
|
6355
6355
|
require: "./dist/lib/index.js",
|
|
6356
6356
|
types: "./dist/src/index.d.ts"
|
|
@@ -6372,9 +6372,9 @@ const n4 = PN((M, N) => {
|
|
|
6372
6372
|
commit: "cz"
|
|
6373
6373
|
}, d4 = {
|
|
6374
6374
|
"@ant-design/icons": "^5.3.4",
|
|
6375
|
-
"@glodon-aiot/apis": "^3.26.0-alpha.
|
|
6376
|
-
"@glodon-aiot/bot-client-sdk": "^3.26.0-alpha.
|
|
6377
|
-
"@glodon-aiot/react-components": "^3.26.0-alpha.
|
|
6375
|
+
"@glodon-aiot/apis": "^3.26.0-alpha.9",
|
|
6376
|
+
"@glodon-aiot/bot-client-sdk": "^3.26.0-alpha.9",
|
|
6377
|
+
"@glodon-aiot/react-components": "^3.26.0-alpha.9",
|
|
6378
6378
|
"@matejmazur/react-mathjax": "^0.1.10",
|
|
6379
6379
|
"@react-pdf-viewer/core": "^3.12.0",
|
|
6380
6380
|
"@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},Zg=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)}`},_g=z.forwardRef((M,e)=>{var Bj,Jj,Fj,Hj,Vj,Xj,$j,Kj,qj,Mi,ei,Ni,ti,ji,ii,Di;const{application:N,docViewerUrl:t="",currentSession:j,onCreateSession:D,embeddingService:s,setCurrentSession:g,networkStatus:I,setNetworkStatus:n}=M,[u,r]=z.useState([]),[L,A]=z.useState([]),[T,y]=z.useState(!1),[C,O]=z.useState(null),w=z.useRef(0),[m,h]=z.useState(),[f,W]=z.useState(),R=z.useRef(null),MM=z.useRef(!0),Y=z.useRef(!1),eM=z.useRef(!1),{service:b,agentClient:p,depId:G,footer:J,transform:Q,defaultInput:zM,onMessage:QM,onHistoryLoad:oM,beforeMessageSend:yM,bodyStyle:ZM,disabled:TM,features:S,popupContainer:d,icon:$,sider:dM,mode:mM,silencedSeconds:XM,localFilesUI:K,localFilesApprovalBridge:wM}=z.useContext(JM),CM=N.type===B.ApplicationTypes.Agent&&K?p==null?void 0:p.localWorkspace:void 0,[tM]=Cg(CM),l=Oe.useMemoizedFn(()=>(d==null?void 0:d.current)||document.body),[F,V]=z.useState(!1),k=z.useRef(u),IM=z.useRef(void 0),x=z.useRef(new Set),[Z,_]=z.useState(0),[cM,DM]=z.useState([]),[q,YM]=z.useState([]),[PM,UM]=z.useState(0),[$M,zN]=z.useState(!1);z.useEffect(()=>{zN(PM>0)},[PM]);const bM=z.useRef(null),[pM,Ne]=z.useState([]),[KM,oe]=z.useState(!1),[gN,js]=z.useState(!1),[is,Ds]=z.useState(""),[ss,Ve]=z.useState(),[Xe,IN]=z.useState({}),uN=z.useRef(null),dj=z.useRef(null),Lt=z.useRef(null),[Oj,zs]=z.useState(!1),[gs,Is]=z.useState([]),[us,kN]=z.useState(!0),[ns,Ts]=z.useState(!0),[xj,ae]=z.useState(!1),[At,le]=z.useState(!1),[cs,rt]=z.useState(!1),[Ie,nN]=z.useState(typeof(S==null?void 0:S.promptVariables)=="object"?S.promptVariables.default||[]:[]),[as,Ls]=z.useState(()=>{const c=typeof(S==null?void 0:S.knowledges)=="object"&&S.knowledges.default||void 0;if(c){if(Array.isArray(c)&&c.some(v=>Array.isArray(v.fileIds)&&v.fileIds.length===0))throw Error("fileIds cannot be an empty array");if($N(c)>pe)throw Error(`knowledges and fileIds total count cannot exceed ${pe}`)}return c}),[Yj,Pe]=z.useState(!1),[wj,TN]=z.useState(!1),[As,cN]=z.useState(typeof(S==null?void 0:S.connectNetwork)=="object"&&typeof(S==null?void 0:S.connectNetwork.default)=="boolean"?S.connectNetwork.default:!1),[Ej,fN]=z.useState(!1),[rs,ke]=z.useState(!1),[ys,os]=z.useState(null),[UN,Re]=z.useState(!1),[hj,Qj]=z.useState(!1),{isSwitchingToExistingSession:Sj,setIsSwitchingToExistingSession:pN}=qt(),$e=z.useRef(null),[yt,ls]=z.useState("");z.useEffect(()=>{if(!XM)return;let c=Zg(XM);ls(c)},[XM]);const aN=Zz((Bj=S==null?void 0:S.botMessageBox)==null?void 0:Bj.artifacts),bN=aN.visible,ot=Oe.useMemoizedFn(c=>uM(exports,null,function*(){var P,jM,NM;if(!bN)return;const o=j,E=c||((P=o==null?void 0:o.data)==null?void 0:P.id);if(!o||!E||((jM=o.data)==null?void 0:jM.id)!==E)return;const v=++w.current;try{const SM=yield o.getArtifacts();if(v!==w.current||((NM=j==null?void 0:j.data)==null?void 0:NM.id)!==E)return;A(SM||[])}catch(SM){}}));z.useEffect(()=>{if(os(j),j===null)ke(!1);else if(j===void 0)ke(!0);else{if(ys===null){if(Sj){ke(!0),pN(!1);return}ke(!1);return}j.ready?ke(!1):ke(!0)}},[j,j==null?void 0:j.ready,Sj]);const[lt,Cs]=z.useState(null),mj=z.useRef(null);z.useEffect(()=>{var c;Cs((c=d==null?void 0:d.current)!=null?c:null)},[d]),z.useEffect(()=>{C&&y(!0)},[C]),z.useEffect(()=>{var o;const c=(o=j==null?void 0:j.data)==null?void 0:o.id;w.current+=1,A([]),y(!1),O(null),c&&bN&&ot(c)},[(Jj=j==null?void 0:j.data)==null?void 0:Jj.id,bN]),z.useEffect(()=>{var E,v;j&&(k.current=[]),r([]),MM.current=!0,Y.current=!1;const c=R.current;if(c&&c.scrollTo({top:0}),!((E=j==null?void 0:j.data)!=null&&E.id))return;if(le(!1),ae(!1),(v=j.messages)!=null&&v.length){const jM=[...j.messages.filter(NM=>NM==null?void 0:NM.messageId)].reverse();k.current=[...jM],r([...jM]),ke(!1)}const o=P=>{var jM;(jM=j==null?void 0:j.data)!=null&&jM.id&&(k.current=[...P].reverse(),r([...P].reverse()),!P||P.length<10?TN(!1):TN(!0),ke(!1),oM&&oM({applicationId:N.id,sessionId:j.data.id,histories:P}))};return j.addEventListener("history:loaded",o),()=>{k.current=[],r([]),j==null||j.removeEventListener("history:loaded",o)}},[j]),z.useEffect(()=>{const c=()=>{var o;(o=j==null?void 0:j.data)!=null&&o.id&&(j.promptVariables&&nN(j.promptVariables.sort((E,v)=>E.key.localeCompare(v.key))),j.knowledges&&Ls(j.knowledges),n(j.netOpen))};return j==null||j.addEventListener("data:updated",c),()=>{j==null||j.removeEventListener("data:updated",c)}},[j]),z.useEffect(()=>{var o;if(!((o=j==null?void 0:j.data)!=null&&o.id))return;const c=E=>{var v;console.error(E.message,E.cause,"e.case"),a.notification.config({getContainer:()=>(d==null?void 0:d.current)||document.body,prefixCls:"gbot-notification"}),a.notification.error({message:((v=E.cause)==null?void 0:v.message)||E.message}),a.notification.config({getContainer:void 0,prefixCls:"gbot-notification"})};return j.addEventListener("error",c),()=>{j==null||j.removeEventListener("error",c)}},[j]);const ds=()=>{var E;if(!((E=j==null?void 0:j.data)!=null&&E.id)||!(N!=null&&N.id))return;const c=j.data.id,o=u[u.length-1];if(o&&o.isContext){te("success","已开启新话题");return}else j.clear().then(()=>{const v=new Ze("",c,B.IHistoryRole.System);v.isContext=!0,r([v,...u])})};z.useEffect(()=>{N!=null&&N.id&&(b==null||b.getRecommendQues(N.id).then(c=>{Ne(c)}))},[G,N]);const Ct=c=>uM(exports,null,function*(){var qM,aM;if(TM)return te("error","发送功能被禁用"),!1;const o=c||m;if(!(o!=null&&o.trim()))return te("error","请输入你想问的"),!1;if(!(Ie==null?void 0:Ie.every(RM=>!!(RM!=null&&RM.value)))){if(Q!=null&&Q.promptVariables)return te("error","变量值不能为空"),!1;console.error("变量值不能为空",Ie==null?void 0:Ie.map(RM=>!!(RM!=null&&RM.value)))}if(At)return te("error","正在回复中"),!1;if(F)return te("error","等待初始化"),!1;if(!us)return te("error","正在解析文件"),!1;if($M)return te("error","正在上传图片"),!1;DM([]),YM([]);const v=(qM=j==null?void 0:j.data)==null?void 0:qM.id;if(!v)return UN?!1:(Re(!0),D==null||D({netOpen:I?Ue.OPEN:Ue.CLOSE}).then(RM=>{var nM,FM;Pe(!0),n(!!((nM=RM.data)!=null&&nM.netOpen)),cN(!!((FM=RM.data)!=null&&FM.enableNetOpen)),dt(RM).then(()=>{g==null||g(RM),Pe(!1),W(o)})}).catch(RM=>{Re(!1)}),!0);if(UN)return!1;Re(!0),fN(!0);const P=mt(o,q,Xe[v],(N==null?void 0:N.type)||0);let jM;try{yM?jM=yield yM==null?void 0:yM({applicationId:N.id,sessionId:v,message:{content:P,sessionId:v,role:B.ChatMessageRole.User,files:Xe[v]}}):jM=!0}catch(RM){jM=!1}if(fN(!1),jM===!1)return Re(!1),!1;let NM=o;typeof jM=="object"&&(NM=jM.content||o);const kM=yield(()=>new Promise(RM=>{nN(nM=>(RM(nM),nM))}))();return(yield j.setPromptVariables(kM))?(((aM=Xe[v])==null?void 0:aM.length)>0?yield Os(NM):yield Ot(NM),!0):(Re(!1),!1)}),dt=c=>new Promise((o,E)=>uM(exports,null,function*(){const jM=(c==null?void 0:c.promptVariables).filter(NM=>NM.type?!((NM.type===B.PromptVariableType.User||NM.type===void 0)&&NM.key==="query")&&!((NM.type===B.PromptVariableType.System||NM.type===void 0)&&NM.key==="datetime"):NM.key!=="query").map(NM=>{var kM;const SM=(kM=Ie.find(iM=>iM.key===NM.key&&iM.type===NM.type))==null?void 0:kM.value;return NM.value=SM||"",NM});nN(jM.sort((NM,SM)=>NM.key.localeCompare(SM.key))),yield c==null?void 0:c.setPromptVariables(jM).catch(NM=>{console.error(NM),te("error",NM.message)}),o()})),Os=c=>{var P,jM,NM;if(kN(!1),!((P=j==null?void 0:j.data)!=null&&P.id)||!(N!=null&&N.id))return;const o=((jM=j.data)==null?void 0:jM.id)||"";let E=[],v=new Set;return(NM=Xe[o])==null||NM.forEach(SM=>{v.has(SM.id)||(E.push(SM),v.add(SM.id))}),kN(!0),Ot(c,E)};z.useEffect(()=>{if(!f||!j)return;const c=f,o=()=>uM(exports,null,function*(){fN(!0);const E=mt(c,q,Xe[j.id],(N==null?void 0:N.type)||0);let v;try{yM?v=yield yM==null?void 0:yM({applicationId:N.id,sessionId:j.id,message:{content:E,sessionId:j.id,role:B.ChatMessageRole.User,files:Xe[j.id]}}):v=!0}catch(P){v=!1}if(fN(!1),v===!1){Re(!1);return}Ot(c),W(void 0)});return j.ready?o():j.addEventListener("ready",o,!0),()=>{j==null||j.removeEventListener("ready",o)}},[f,j]);const Ot=(c,o)=>uM(exports,null,function*(){var qM,aM,RM;const E=(qM=j==null?void 0:j.data)==null?void 0:qM.id;if(!E)return;le(!0),ae(!0);const v=mt(c,q,o,(N==null?void 0:N.type)||0);let P;if(N.type===B.ApplicationTypes.Agent)P=void 0;else if(N.type===B.ApplicationTypes.Dialog&&((aM=N.arrange)!=null&&aM.length)&&N.arrange[0].visionOpen){const nM=q&&q.length?q.filter(Boolean):[];P=nM.length?nM:void 0}else P=void 0;const jM=new Ze(v,E,B.IHistoryRole.User,o,P);h(void 0),Ve(void 0),k.current=[jM,...u],r(k.current),N.id&&QM&&QM({applicationId:N.id,sessionId:E,message:jM});const NM=new Ze("",E,B.IHistoryRole.System);NM.isWaiting=!0,k.current=[NM,...k.current],r(k.current);const SM=(o==null?void 0:o.filter(nM=>!nM.localAttachment).map(nM=>nM.id))||[],kM={stream:xe.configuration.stream,referenceFirst:!1};if(Q!=null&&Q.promptVariables){const nM=Ie==null?void 0:Ie.reduce((FM,fe)=>(FM[fe.key]=fe.value,FM),{});kM.formatValues=nM}if(Q!=null&&Q.knowledges){const nM=as;kM.knowledges=nM}const iM={text:v,fileIds:SM,files:o,uuid:jM.messageId};P&&P.length>0&&(iM.imageContent=P),j.ready||(yield new Promise(nM=>{j.addEventListener("ready",()=>nM(),!0)})),yield j.send(iM,kM),IN({[E]:[]}),(RM=uN.current)==null||RM.update({keepLocalAttachments:!1}),DM([]),YM([]),Re(!1)});z.useEffect(()=>{var kM;const c=(kM=j==null?void 0:j.data)==null?void 0:kM.id;if(!c)return;let o=null,E=null,v="";const P=()=>{o=null,E&&(r([E,...k.current]),E=null)},jM=()=>{o!==null&&(cancelAnimationFrame(o),o=null,E=null)},NM=iM=>{if(!iM.sessionId||iM.sessionId&&iM.sessionId!==IM.current)return;if(iM.role===B.IHistoryRole.User){if(k.current.some(LN=>LN.messageId&&LN.messageId===iM.messageId))return;const FM=new Ze(iM.content,c,B.IHistoryRole.User,iM.files,iM.imageContent);FM.messageId=iM.messageId||FM.messageId,FM.renderKey=FM.messageId;const fe=new Ze("",c,B.IHistoryRole.System);fe.isWaiting=!0,k.current=k.current.filter(LN=>!LN.isWaiting),k.current=[fe,FM,...k.current],r(k.current),ae(!0),le(!0),N.id&&QM&&QM({applicationId:N.id,sessionId:c,message:FM});return}if(iM.index===-1&&iM.code!==200&&iM.code!==11915&&iM.code!==11916&&(jM(),ae(!1),le(!1),k.current=k.current.filter(nM=>!nM.isWaiting),r([...k.current]),k.current=[...k.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 qM=iM.actions||[],aM=new Ze(iM.content,c,B.IHistoryRole.Robot);aM.reasoningContent=iM.reasoningContent,aM.searchReference=iM.searchReference,aM.thinkingSecs=iM.thinkingSecs,aM.thinkingStatus=iM.thinkingStatus,aM.actions=qM,aM.isLoading=!0,aM.searchingStatus=iM.searchingStatus;const RM=k.current.some(nM=>nM.isWaiting);if(k.current=k.current.filter(nM=>!nM.isWaiting).filter(nM=>!nM.isReplying),RM&&(v=""),aM.renderKey=v||iM.messageId||aM.messageId,v=aM.renderKey,aM.messageId=iM.messageId||aM.renderKey,iM.index===void 0){E=aM,o===null&&(o=requestAnimationFrame(P));return}if(jM(),(iM.code===11915||iM.code===11916)&&(ae(!1),le(!1),aM.isLoading=!1,aM.content=iM.code===11916?"尊敬的用户您好,让我们换个话题再聊聊吧。":"请您换个问题问我吧~",aM.isSensitive=!0,r([aM,...k.current])),iM.index===-2&&(ae(!1),le(!1),aM.isLoading=!1,aM.content="回答已中止~",aM.isSuspend=!0,r([aM,...k.current]),ot(c)),iM.index===-1&&(ae(!1),le(!1),aM.isLoading=!1,aM.reference=iM.reference,r([aM,...k.current]),iM.code===200&&ot(c),N.id)){const nM=aM.messageId;x.current.has(nM)||(x.current.add(nM),QM&&QM({applicationId:N.id,sessionId:c,message:aM}))}iM.index===-3&&(ae(!1),le(!1),aM.isLoading=!1,aM.reference=iM.reference,aM.relatedQuesion=iM.relatedQuesion,r([aM,...k.current]))},SM=()=>{j.addEventListener("message:updated",NM)};return j.ready?j.addEventListener("message:updated",NM):j.addEventListener("ready",SM),()=>{jM(),j==null||j.removeEventListener("message:updated",NM),j==null||j.removeEventListener("ready",SM)}},[j]),z.useEffect(()=>{if(!j){V(!1);return}const c=o=>{V(o)};return V(j.frozen),j.addEventListener("frozen",c),()=>{j==null||j.removeEventListener("frozen",c)}},[j]),z.useEffect(()=>{if(!p)return;const c=p.questionContextMaxLength||4e3;_(c)},[p,b]),z.useEffect(()=>{zM&&Ve(zM.text)},[zM]);const te=(c,o,E)=>{ie(d,()=>{a.message.open({type:c,content:o,key:E})})},kj=c=>{const o=c.size;return o<=0?(te("error","该文件为空,请重新上传"),!1):o>St*XN?(te("error",`图片须小于${St}M`),!1):(DM(E=>E.length>=_e?(te("warning",`图片最多上传${_e}张`),E):[...E,c]),!1)},xs=()=>{var c;return(N.type===B.ApplicationTypes.Agent&&(Q==null?void 0:Q.imageUpload)||N.type===B.ApplicationTypes.Dialog&&((c=N.arrange)==null?void 0:c.length)&&!!N.arrange[0].visionOpen&&(Q==null?void 0:Q.imageUpload))&&!TM},Ys=()=>!!s&&(Q==null?void 0:Q.fileUpload)&&(N==null?void 0:N.id)&&!TM,fj=c=>{var aM,RM;const o=Array.from(c||[]).filter(Boolean);if(!o.length)return;const E=xs(),v=Ys(),P=[],jM=[];let NM=0,SM=0,kM=0;o.forEach(nM=>{var si,zi,gi;const FM=(zi=(si=nM.name)==null?void 0:si.split(".").pop())==null?void 0:zi.toLowerCase();if(Xi(nM)){v&&N.type===B.ApplicationTypes.Agent?jM.push(nM):kM++;return}if(((gi=nM.type)==null?void 0:gi.startsWith("image/"))||!!ai(nM.name)){E?P.push(nM):NM++;return}if(Hi.includes(nM.type)||["pdf","doc","docx"].includes(FM||"")){v?jM.push(nM):SM++;return}kM++});const iM=[],qM=NM+SM+kM;if(!v&&!E)qM&&iM.push(`当前不支持上传文件/图片,已忽略${qM}个文件`);else if(v&&!E){const nM=NM+kM;if(nM){const FM=N.type===B.ApplicationTypes.Agent?".doc/.docx/.pdf/.xls/.xlsx/.svg/.dwg/.json":".doc/.docx/.pdf";iM.push(`仅支持上传 ${FM} 文件,已忽略${nM}个其他类型文件`)}}else if(!v&&E){const nM=SM+kM;nM&&iM.push(`仅支持上传图片(.jpg/.jpeg/.png/.bmp),已忽略${nM}个其他类型文件`)}else kM&&iM.push(`存在不支持的文件类型,已忽略${kM}个文件`);if(iM.length&&te("warning",iM.join(";"),"precheck-warn"),P.length){const nM=Math.max(0,_e-cM.length),FM=P.slice(0,nM);FM.forEach(fe=>kj(fe)),P.length>FM.length&&te("warning",`最多上传${_e}张图片`)}jM.length&&((RM=(aM=uN.current)==null?void 0:aM.appendFiles)==null||RM.call(aM,jM))},Uj=c=>{var E;const o=(E=c.clipboardData)==null?void 0:E.files;o&&o.length&&(c.preventDefault(),c.stopPropagation(),fj(o))},pj=c=>{c.preventDefault()},bj=c=>{var E;c.preventDefault(),c.stopPropagation();const o=(E=c.dataTransfer)==null?void 0:E.files;o&&o.length&&fj(o)},vj=()=>uM(exports,null,function*(){var c;return(c=j==null?void 0:j.data)!=null&&c.id?j:($e.current||($e.current=new Promise((o,E)=>{Pe(!0),D==null||D({netOpen:I?Ue.OPEN:Ue.CLOSE}).then(v=>{var P,jM;g==null||g(v),Pe(!1),n(!!((P=v.data)!=null&&P.netOpen)),cN(!!((jM=v.data)!=null&&jM.enableNetOpen)),dt(v),o(v)}).catch(v=>{$e.current=null,E(v)})})),$e.current)}),ws=c=>uM(exports,null,function*(){const o=yield vj();return Es(o,c)}),Es=(c,o)=>{const E=ai(o.name);return new Promise(v=>{var jM;const P={files:[`${jN.v4()}.${E}`],isv:"minio",knowledgeId:((jM=c.data)==null?void 0:jM.id)||"",type:1};b==null||b.postTicket(P).then(NM=>{b.uploadMinioFile(NM.minio,o).then(()=>{var qM,aM;const SM=(qM=NM.minio.endpoints)==null?void 0:qM[0],kM=NM.minio.bucket,iM=(aM=NM.minio.fileKeys)==null?void 0:aM[0];v(`${NM.minio.useSSL?"https:":location.protocol}//${SM}/${kM}/${iM}`)}).catch(()=>{})}).catch(()=>{})})},hs=()=>{const c=R.current;!c||!MM.current||c.scrollTo({top:c.scrollHeight})};z.useLayoutEffect(()=>{hs()},[u]),z.useEffect(()=>{const c=()=>{eM.current=!1;const o=R.current;(!o||o.scrollTop>-80)&&(Y.current=!1)};return window.addEventListener("pointerup",c),()=>window.removeEventListener("pointerup",c)},[]);const Gj=(c,o)=>new Promise(E=>{if(!o.file.url||!(N!=null&&N.id))return E();const v=_M(gM({},o.file),{type:1});b==null||b.postApplicationIdSessionKnowledgeSessionFile(N==null?void 0:N.id,c,v).finally(()=>{var P;(P=uN.current)==null||P.update().finally(E)})}),Qs=()=>{var c;(c=j==null?void 0:j.data)!=null&&c.id&&(ae(!1),j.suspend())},Ss=c=>{const o=R.current;o&&(MM.current=!0,Y.current=!1,rt(!1),setTimeout(()=>{o.scrollTo({top:o.scrollHeight,behavior:c==null?void 0:c.behavior})},c==null?void 0:c.ms))},Pj=()=>{Y.current=!0},ms=c=>{var E;const o=(E=c.target)==null?void 0:E.closest(".bottom-right");o instanceof HTMLElement&&o.scrollHeight>o.clientHeight+1||(Pj(),requestAnimationFrame(()=>{const v=R.current;Y.current&&v&&v.scrollTop>-80&&(Y.current=!1)}))},ks=c=>{const o=c.currentTarget,{offsetX:E,offsetY:v}=c.nativeEvent;(E>o.clientWidth||v>o.clientHeight)&&(eM.current=!0,Pj())},fs=()=>{const c=R.current;if(!c)return;if(!(c.scrollTop<=-80)){MM.current=!0,Y.current=!1,rt(!1);return}(Y.current||eM.current)&&(MM.current=!1,Y.current=!1,rt(!0))},Us=Oe.useMemoizedFn(c=>{var o,E;(o=bM.current)==null||o.update(c),(E=bM.current)==null||E.focus()}),ps=Oe.useMemoizedFn(c=>{Ct(c)}),bs=Oe.useMemoizedFn(()=>{var o;if(!((o=j==null?void 0:j.data)!=null&&o.id))return;k.current=[...u.slice(1,u.length)],r(k.current);const c=new Ze("",j.data.id,B.IHistoryRole.System);c.isWaiting=!0,k.current=[c,...k.current],r(k.current),le(!0),ae(!0),j.answerAgain()});z.useEffect(()=>{var c,o;IM.current=(c=j==null?void 0:j.data)==null?void 0:c.id,!Yj&&((o=Lt.current)==null||o.clear())},[j]);const vs=()=>{var E;if(!((E=j==null?void 0:j.data)!=null&&E.id))return;const o=u[u.length-1].messageTime;j.fetchMessages({endTime:o,pageSize:Yi}).then(v=>{const P=v||[];if(!P||!(P!=null&&P.length)){TN(!1);return}P.length<10?TN(!1):TN(!0),r([...u,...P.reverse()])})},Gs=c=>uM(exports,null,function*(){var o,E;if(!((o=j==null?void 0:j.data)!=null&&o.id))n(c);else{if(yield j.setNetOpen(c),!((E=j.data)!=null&&E.id))return;n(c)}}),xt=()=>uM(exports,null,function*(){j?j.fetchData().then(c=>{var o;(o=j==null?void 0:j.data)!=null&&o.id&&(n(c.netOpen),cN(c.enableNetOpen))}):(n(typeof(S==null?void 0:S.connectNetwork)=="object"&&typeof(S==null?void 0:S.connectNetwork.default)=="boolean"?S.connectNetwork.default:!1),cN(N.arrange[0].enableNetOpen))});z.useEffect(()=>{xt()},[j]),z.useEffect(()=>{let c=null,o=null;const E=()=>{var iM,qM;if(!R.current)return;const P=document.getElementById("chat-main"),jM=(iM=R.current)==null?void 0:iM.querySelector(".infinite-scroll-component__outerdiv"),NM=(qM=R.current)==null?void 0:qM.querySelector(".infinite-scroll-component");if(!jM||!NM||!P)return;const SM=P.offsetHeight;if(NM.offsetHeight<=SM){if(jM.style.height==="100%")return;jM.style.height="100%"}else{if(jM.style.height==="auto")return;jM.style.height="auto"}},v=()=>{var NM;if(typeof ResizeObserver=="undefined"||!R.current)return;const P=document.getElementById("chat-main"),jM=(NM=R.current)==null?void 0:NM.querySelector(".infinite-scroll-component");!jM||!P||(o=new ResizeObserver(()=>{E()}),o.observe(jM),o.observe(P))};return c=requestAnimationFrame(()=>{E(),v()}),()=>{c!==null&&cancelAnimationFrame(c),o==null||o.disconnect()}},[u]),z.useEffect(()=>{if(j)return;const c=()=>{const v=((p==null?void 0:p.promptVariables)||[]).filter(P=>P.type?!(P.type===B.PromptVariableType.User&&P.key==="query")&&!(P.type===B.PromptVariableType.System&&P.key==="datetime")&&P.status===1:P.key!=="query"&&P.status===1).map((P,jM)=>{var SM,kM;let NM="";return typeof(S==null?void 0:S.promptVariables)=="object"&&(NM=((kM=(SM=S.promptVariables.default)==null?void 0:SM.find(iM=>iM.key===P.key&&iM.type===P.type))==null?void 0:kM.value)||""),{id:jM+"",key:P.key,name:P.name,value:NM,type:P.type}});nN([...v].sort((P,jM)=>P.key.localeCompare(jM.key)))};return p!=null&&p.ready?c():p==null||p.addEventListener("ready",c),()=>{p==null||p.removeEventListener("ready",c)}},[j,p,S==null?void 0:S.promptVariables]);const Rj=()=>D==null?void 0:D({netOpen:I?Ue.OPEN:Ue.CLOSE}).then(c=>{var o,E;return g==null||g(c),Pe(!1),n(!!((o=c.data)!=null&&o.netOpen)),cN(!!((E=c.data)!=null&&E.enableNetOpen)),dt(c),c}),Wj=!!u.length,Zj=z.useMemo(()=>{var c;return N.arrange&&((c=N.arrange[0])!=null&&c.openingContent)?i.jsx(eD,{application:N,history:{role:1,content:N.arrange[0].openingContent,code:200,messageId:"opening-message",sessionId:"",reference:[],searchReference:[],messageTime:HM(Date.now()).format("YYYY-MM-DD HH:mm:ss"),actions:[],isLoading:!1},actions:Wj,markdown:S==null?void 0:S.markdown}):null},[N==null?void 0:N.arrange,Wj]);z.useImperativeHandle(e,()=>({getCurrentInputText:()=>{var c;return(c=bM.current)==null?void 0:c.getCurrentText()},send:c=>uM(exports,null,function*(){if(!(yield Ct(c)))throw new Error("send was blocked")})})),z.useEffect(()=>{var o;const c=(o=j==null?void 0:j.data)==null?void 0:o.id;c&&IN(E=>_M(gM({},E),{[c]:[]}))},[(Fj=j==null?void 0:j.data)==null?void 0:Fj.id]);const _j=!!CM&&(K==null?void 0:K.picker)!==!1;return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:`agent-chat${_j?" with-workspace-tree":""}`,children:[_j&&CM&&i.jsx(hg,{workspace:CM,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:[rs?i.jsx("div",{className:"session-loading",children:i.jsx(a.Spin,{})}):i.jsxs(i.Fragment,{children:[(Q==null?void 0:Q.promptVariables)&&i.jsx(DD,{ref:dj,appId:N.id,currentSession:j,promptVariables:Ie,setPromptVariables:nN,setCurrentSession:g}),i.jsxs("div",{className:"chat-main",id:"chat-main",style:ZM,children:[i.jsx("div",{className:"chat-main-wrapper",id:"scrollableDiv",style:{height:"100%",overflowY:"auto",display:"flex",flexDirection:"column-reverse"},ref:R,onScroll:fs,onWheel:ms,onPointerDown:ks,children:(Hj=j==null?void 0:j.data)!=null&&Hj.id&&(u!=null&&u.length)?i.jsxs(Js,{dataLength:u.length,next:vs,style:{display:"flex",flexDirection:"column-reverse",overflowX:"hidden",overflowAnchor:"none"},inverse:!0,endMessage:u.length>Yi&&((Vj=R.current)!=null&&Vj.scrollTop)&&((Xj=R.current)==null?void 0:Xj.scrollTop)<-10?i.jsx(a.Divider,{plain:!0,children:"没有更多数据了"}):null,hasMore:wj,loader:i.jsx("div",{style:{height:"50px",textAlign:"center",overflow:"hidden"},children:i.jsx(a.Spin,{})}),scrollableTarget:"scrollableDiv",children:[u.map((c,o)=>i.jsx(Wg,{application:N,currentSession:j,history:c,docViewerUrl:t,isLastHistory:o===0,onRelatedClick:ps,onAgainClick:bs,onEditClick:Us,markdown:S==null?void 0:S.markdown},c.renderKey||`${c.messageId}-${o}`)),!wj&&Zj]}):i.jsxs("div",{className:"main-empty",children:[(S==null?void 0:S.greeting)!==!1&&i.jsx(Kz,{text:S!=null&&S.greeting&&typeof S.greeting=="object"&&S.greeting.text!==void 0?S.greeting.text:($j=N.arrange)!=null&&$j.length&&((Kj=N.arrange[0])!=null&&Kj.greetings)?N.arrange[0].greetings:xi.text,icon:S===void 0||S.greeting===!0||((qj=S.greeting)==null?void 0:qj.icon)===void 0?$||xi.icon:S.greeting.icon,children:!!pM.length&&(((S==null?void 0:S.greeting)===void 0||(S==null?void 0:S.greeting))===!0||typeof(S==null?void 0:S.greeting)=="object"&&S.greeting.questions!==!1)&&i.jsx(jD,{ref:Lt,sid:(Mi=j==null?void 0:j.data)==null?void 0:Mi.id,isRecommendClearing:KM,data:pM,layoutBreakpoints:typeof(S==null?void 0:S.greeting)=="object"?S.greeting.layoutBreakpoints:void 0,onItemClick:c=>{var E,v,P;if(h(c==null?void 0:c.question),Ve(c==null?void 0:c.question),KM)return;c!=null&&c.id&&oe(!0);const o=(E=j==null?void 0:j.data)==null?void 0:E.id;Q!=null&&Q.fileUpload?(P=(v=uN.current)==null?void 0:v.clear())==null||P.then(()=>{var jM,NM;c!=null&&c.id&&(o?(jM=Gj(o,c))==null||jM.finally(()=>{oe(!1)}):(oe(!1),Pe(!0),(NM=Rj())==null||NM.then(SM=>{var kM;(kM=Gj(SM.id,c))==null||kM.finally(()=>{oe(!1)})})))}):o?oe(!1):(oe(!1),Pe(!0),Rj())}})}),Zj]})}),xj&&i.jsx("div",{className:"session-stop",children:i.jsx(a.Button,{type:"primary",style:{background:"white"},ghost:!0,size:"small",icon:i.jsx(AM,{type:"icon-zantinghuida",style:{fontSize:16}}),onClick:()=>Qs(),children:"停止回答"})}),cs&&(u==null?void 0:u.length)>0&&i.jsx("div",{className:"back-bottom",children:i.jsx(a.Button,{size:"small",onClick:()=>Ss({behavior:"smooth"}),type:"link",icon:i.jsx(AM,{type:"icon-yijianhuidaodibu",style:{fontSize:24}})})})]}),i.jsx("div",{className:"chat-footer",children:i.jsxs("div",{className:"chat-footer-input",children:[cM.length>0&&i.jsx("div",{className:"input-files",children:cM.map((c,o)=>i.jsx(Vz,{className:"thumb-40",file:c,actions:{upload:E=>uM(exports,null,function*(){UM(v=>v+1);try{return yield ws(E)}finally{UM(v=>Math.max(0,v-1))}}),remove:()=>{DM(E=>E.filter((v,P)=>P!==o)),YM(E=>E.filter((v,P)=>P!==o))}},onUrlChange:E=>{YM(v=>{const P=[...v];return P[o]=E,P})}},o))}),CM&&i.jsx(Pg,{workspace:CM}),CM&&wM&&i.jsx(vg,{bridge:wM,getContainer:l}),i.jsxs("div",{className:"footer-upload-action-wrapper",children:[i.jsxs(a.Space,{className:"footer-upload-action",onClick:c=>c.preventDefault(),children:[i.jsxs(a.Space,{children:[(N.type===B.ApplicationTypes.Agent&&(Q==null?void 0:Q.imageUpload)||N.type===B.ApplicationTypes.Dialog&&((ei=N.arrange)==null?void 0:ei.length)&&!!N.arrange[0].visionOpen&&(Q==null?void 0:Q.imageUpload))&&i.jsx(a.Upload,{multiple:!0,disabled:cM.length>=_e||TM,accept:".jpg, .png, .jpeg,.bmp",listType:"picture-card",beforeUpload:kj,className:"footer-upload-picture",showUploadList:!1,children:cM.length<_e?i.jsx(a.Tooltip,{placement:"topLeft",overlayClassName:"footer-upload-tooltip",title:i.jsx("div",{children:`支持上传.jpg .png .jpeg
|
|
15
|
-
.bmp格式的图片数据,单文件最大${St}M,最多${_e}张`}),children:i.jsx(a.Button,{type:"text",className:"camera-out-btn",style:{width:"22px",position:"relative",bottom:"-2px"},icon:i.jsx(AM,{type:"icon-shangchuantupian",className:"icon-tianjia",style:{fontSize:"22px"}})})}):i.jsx(a.Button,{type:"text",className:"camera-out-btn",style:{width:"22px",position:"relative",bottom:"-2px"},disabled:!0,icon:i.jsx(AM,{type:"icon-shangchuantupian",className:"icon-tianjia",style:{fontSize:"22px"}})})}),s&&(Q!=null&&Q.fileUpload)&&(N!=null&&N.id)?i.jsx(iD,{appId:N==null?void 0:N.id,allowExcelAttachment:N.type===B.ApplicationTypes.Agent,ref:uN,isFirstSession:Yj,docViewerUrl:t,onStatusChange:c=>uM(exports,null,function*(){c!=="process"?(kN(!0),xt()):kN(!1)}),createSession:()=>vj().then(c=>{var E;return((E=c.data)==null?void 0:E.id)||""}),sid:(Ni=j==null?void 0:j.data)==null?void 0:Ni.id,disabled:At||TM,afterFileAdd:(c,o)=>{o&&IN(E=>{const v=E[o]||[];return{[o]:[...v,c]}})},afterFileDelete:c=>{var E;const o=(E=j==null?void 0:j.data)==null?void 0:E.id;o&&IN(v=>{const P=v[o]||[];return{[o]:P.filter(jM=>jM.id!==c)}})},onFileListChange:c=>{Is(c)},shouldContinue:ns,afterFilesClear:()=>{var o;const c=(o=j==null?void 0:j.data)==null?void 0:o.id;c&&(IN({[c]:[]}),xt())}}):null,(Q==null?void 0:Q.prompt)&&(N==null?void 0:N.id)&&i.jsx(Ag,{appId:N.id,list:[],search:gN?is:"",onPromptSelect:c=>{Ve(c.context),h(c.context)},disabled:TM})]}),i.jsxs(a.Space,{children:[(Q==null?void 0:Q.connectNetwork)&&N.type===B.ApplicationTypes.Dialog&&((ti=N.arrange)==null?void 0:ti.length)&&!!N.arrange[0].enableNetOpen&&i.jsx(ug,{sessionId:(ji=j==null?void 0:j.data)==null?void 0:ji.id,netStatus:I,enable:typeof(S==null?void 0:S.connectNetwork)=="object"&&typeof(S==null?void 0:S.connectNetwork.diabled)=="boolean"?!(S!=null&&S.connectNetwork.diabled):As,disabledTip:j?void 0:"网络访问已被禁用",onNetStatusChange:c=>{Gs(c)}}),(Q==null?void 0:Q.sessionList)&&i.jsx(sg,{currentSessionId:(ii=j==null?void 0:j.data)==null?void 0:ii.id,onSessionChange:(c,o)=>{Ve(void 0),pN(!0),g==null||g(o)},disabled:TM}),dM&&mM==="float"&&i.jsx("div",{className:"session-history-drawer-component",children:i.jsx(a.Popover,{placement:"topRight",showArrow:!1,overlayClassName:"session-history-overlay",overlayStyle:{padding:"4px"},getPopupContainer:c=>c.parentNode,content:"会话历史记录",children:i.jsx(a.Button,{className:"history-overlay-action",disabled:TM,type:"text",icon:i.jsx(AM,{type:"icon-lishijilu",style:{fontSize:24}}),onClick:()=>Qj(!0)})})}),(Q==null?void 0:Q.sessionOpen)&&i.jsx(a.Button,{icon:i.jsx(rM.PlusOutlined,{}),className:"add-btn",type:"primary",disabled:xj||!j||!u.length||TM,onClick:()=>{var c,o;pN(!1),g==null||g(null),$e.current=null,n(!1),(c=dj.current)==null||c.clear(),(o=Lt.current)==null||o.clear()},children:"新会话"})]})]}),!!yt&&i.jsx("div",{className:"remainingSeconds-mark"})]}),i.jsxs("div",{className:"footer-textarea",onPaste:Uj,onPasteCapture:Uj,onDrop:bj,onDropCapture:bj,onDragOver:pj,onDragOverCapture:pj,children:[i.jsx(tD,{ref:bM,maxLength:Z,text:ss,networkStatus:!1,loading:Ej||UN,disabled:F||$M||TM||Ej||UN,onTextSend:Ct,onChange:(c,o)=>{Ve(c);const E=o.getText().replace(/[\n\s]+$/,"");h(E),Ds(E),gN||js(!0)},clearAction:i.jsx(a.Space,{size:0,children:i.jsx(a.Button,{type:"link",disabled:At||TM,ghost:!0,icon:i.jsx(AM,{style:{fontSize:22},type:"icon-qingchujiyi"}),onClick:()=>ds()})})}),!!yt&&i.jsxs("div",{className:"remainingSeconds-time",children:["您之前对话触发敏感词拦截,当前处于禁言状态,暂时无法发送消息,剩余禁言时长",yt]})]})]})}),i.jsx(Mg,{tips:J}),Oj&&i.jsx(tg,{isvisible:Oj,files:gs,sessionId:(Di=j==null?void 0:j.data)==null?void 0:Di.id,onClose:c=>{zs(!1),Ts(!1)}})]}),hj&&i.jsx(Ig,{currentSession:j,application:N,networkStatus:I,setCurrentSession:g,disabled:TM,isSessionHistoryVisible:hj,setIsSessionHistoryVisible:Qj,onSessionChange:c=>{pN(!0)}})]})]}),lt&&bN&&L.length>0&&Gi.createPortal(i.jsxs("div",{className:"artifacts-dock",ref:mj,children:[i.jsxs("div",{className:`artifacts-drawer${T?" is-open":""}`,children:[i.jsxs("button",{type:"button",className:"artifacts-handle",onClick:()=>y(c=>!c),children:[i.jsx("span",{className:"artifacts-handle-text",children:"产出物"}),T?i.jsx(rM.RightOutlined,{}):i.jsx(rM.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(Rz,{artifacts:L,activeArtifact:C,onPreview:O})]}),aN.preview==="column"&&C&&i.jsx(Hz,{artifact:C,style:aN.style,onClose:()=>O(null)})]})]}),i.jsx(Fz,{placement:aN.preview,artifact:C,style:aN.style,onClose:()=>O(null),getContainer:()=>mj.current||lt})]}),lt)]})});const uD=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(u=>i.jsx(a.Col,{span:24,children:i.jsx(a.Checkbox,{value:u.id,children:u.name})},u.id))})}),n=u=>{g(u)};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:n,getPopupContainer:u=>u.parentNode,children:i.jsxs("div",{className:"",onClick:u=>u.preventDefault(),children:[i.jsx(AM,{className:"select-icon",type:"icon-open"}),i.jsx("span",{className:"title",children:"参考知识库"}),i.jsxs("span",{className:"content",children:["已选 ",j," 个"]})]})})})},Bg=M=>{var C,O;const{currentSession:e,application:N,setCheckKnowledges:t}=M,{mode:j,transform:D,features:s}=z.useContext(JM),[g,I]=z.useState([]),[n,u]=z.useState(typeof(s==null?void 0:s.knowledges)=="object"?((C=s.knowledges.default)==null?void 0:C.map(w=>w.id))||[]:[]),[r,L]=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 h=w[0].knowledges||[];I(h);const f=typeof(s==null?void 0:s.knowledges)=="object"&&s.knowledges.default||h;if(Array.isArray(f)&&f.some(Y=>Array.isArray(Y.fileIds)&&Y.fileIds.length===0))throw Error("fileIds cannot be an empty array");if($N(f||[])>pe)throw Error(`knowledges and fileIds total count cannot exceed ${pe}`);if(!e){u(f.map(MM=>MM.id)),L(f.length),t==null||t(f);return}const R=()=>{const MM=e.knowledges||f;L(MM.length);const Y=MM.map(eM=>eM.id);u(Y)};return R(),e.addEventListener("data:updated",R),()=>{e==null||e.removeEventListener("data:updated",R)}},[N,e]),z.useEffect(()=>{var m;if(!A||(T(!1),!(N!=null&&N.id)))return;const w=[];n==null||n.map(h=>{const f=g==null?void 0:g.find(W=>W.id===h);w.push(f)}),(m=e==null?void 0:e.data)!=null&&m.id&&e.setKnowledges(w)},[A]);const y=w=>{T(!0),u(w);const m=[];w==null||w.map(h=>{const f=g==null?void 0:g.find(W=>W.id===h);m.push(f)}),t==null||t(m),L(w.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(uD,{disabled:typeof(s==null?void 0:s.knowledges)=="object"&&(s==null?void 0:s.knowledges.diabled)||!1,checkedValues:n,currKnowledgeList:g,selectCount:r,onSelectChange:y})]})};const Jg=z.forwardRef((M,e)=>{const{sessionId:N,appId:t,docViewerUrl:j}=M,[D,s]=z.useState(),{showHeader:g,agentClient:I,sider:n,onSessionLoad:u,features:r,mode:L}=z.useContext(JM),[A,T]=z.useState(),y=z.useRef(null),[C,O]=z.useState(""),[w,m]=z.useState(),h=z.useRef(null),[f,W]=z.useState(!1);z.useState([]);const{setIsSwitchingToExistingSession:R}=qt();z.useEffect(()=>{var Y;W(D?!!((Y=D.data)!=null&&Y.netOpen):typeof(r==null?void 0:r.connectNetwork)=="object"&&typeof(r==null?void 0:r.connectNetwork.default)=="boolean"?r.connectNetwork.default:!1)},[D]),z.useEffect(()=>{const Y=()=>uM(exports,null,function*(){const eM=I==null?void 0:I.application;if(!(eM!=null&&eM.id))return;const b=eM==null?void 0:eM.arrange;if(!(b!=null&&b.length))return;const G=b[0].embeddingService;O(G),T(eM)});if(I!=null&&I.ready){Y();return}return I==null||I.addEventListener("ready",()=>Y()),()=>{I==null||I.removeEventListener("ready",Y)}},[I]),z.useEffect(()=>{I&&N&&(I.ready?I==null||I.getSessions().then(Y=>uM(exports,null,function*(){s==null||s(Y.find(eM=>eM.id===N))})):I.addEventListener("ready",()=>uM(exports,null,function*(){I==null||I.getSessions().then(Y=>uM(exports,null,function*(){s==null||s(Y.find(eM=>eM.id===N))}))}),!0))},[I,N]),z.useEffect(()=>{if(!D){u&&u({applicationId:t,sessionId:"",session:null,sessionInstance:null});return}D.data&&u&&u({applicationId:t,sessionId:D.data.id,session:D.data,sessionInstance:D}),D.addEventListener("data:loaded",()=>{D!=null&&D.data&&u&&u({applicationId:t,sessionId:D.data.id,session:D.data,sessionInstance:D})},!0)},[D]);const MM=Y=>{var eM;return(eM=y.current)==null?void 0:eM.create(_M(gM({},Y),{knowledges:w}))};return z.useImperativeHandle(e,()=>({createSession:Y=>MM(Y),getSessionList:()=>{var eM;const Y=((eM=y.current)==null?void 0:eM.list())||[];return Promise.resolve(Y)},getCurrentInputText:()=>{var Y;return(Y=h.current)==null?void 0:Y.getCurrentInputText()},send:Y=>{var eM;return(eM=h.current)!=null&&eM.send?h.current.send(Y):Promise.reject(new Error("send is not available"))}})),i.jsx("div",{className:"dialog",children:i.jsxs("div",{className:"dialog-pannel",children:[i.jsx("div",{className:"dialog-sider",style:{display:n&&L==="inlay"?"block":"none"},children:i.jsx(Mj,{ref:y,appId:t,networkStatus:f,currentSession:D,application:A,setCurrentSession:s,checkKnowledges:w,setCheckKnowledges:g?m:void 0,sessionId:N,afterSessionClick:Y=>{var eM,b;((eM=Y.data)==null?void 0:eM.id)!==((b=D==null?void 0:D.data)==null?void 0:b.id)&&R(!0)}})}),i.jsx("div",{className:"dialog-content",children:i.jsxs("div",{className:"dialog-chat",children:[g&&i.jsx("div",{className:"dialog-chat-header",children:i.jsx(Bg,{setCheckKnowledges:m,application:A,currentSession:D})}),i.jsx("div",{className:"dialog-chat-content",children:(A==null?void 0:A.id)&&i.jsx(_g,{setNetworkStatus:W,networkStatus:f,application:A,currentSession:D,onCreateSession:MM,docViewerUrl:j,embeddingService:C,setCurrentSession:s,ref:h})})]})})]})})}),Fg=z.forwardRef((M,e)=>{const{className:N,triggerButton:t,size:j,theme:D,icon:s,docViewerUrl:g,token:I,debug:n,env:u,plugins:r,mcp:L,footer:A,defaultInput:T,onComment:y,onSessionLoad:C,onSessionUnload:O,onMessage:w,beforeMessageSend:m,bodyStyle:h,apiUrl:f,sessionId:W,disabled:R,transform:MM,features:Y,stream:eM,agentClient:b,application:p}=M,G=z.useRef(null),[J,Q]=z.useState(!1),[zM,QM]=z.useState(),[oM,yM]=z.useState(j),[ZM,TM]=z.useState(M.open),S=z.useRef(null);z.useEffect(()=>{p&&(console.log("[AgentClientUI] token",b,p),QM(p.id))},[p]),a.ConfigProvider.config({theme:D}),z.useEffect(()=>{j&&yM(j)},[j]);const d=($,{element:dM,size:mM})=>{yM({width:Number(mM.width),height:mM.height})};return z.useImperativeHandle(e,()=>({createSession:$=>{var dM;return(dM=S.current)==null?void 0:dM.createSession($)},getSessionList:()=>{var $;return($=S.current)==null?void 0:$.getSessionList()},getCurrentInputText:()=>{var $;return($=S.current)==null?void 0:$.getCurrentInputText()},send:$=>{var dM;return(dM=S.current)!=null&&dM.send?S.current.send($):Promise.reject(new Error("send is not available"))}})),i.jsx(a.ConfigProvider,{locale:Ri,children:i.jsxs(_i,{value:_M(gM({},M),{popupContainer:G,agentClient:b,footer:A,defaultInput:T,onComment:y,onSessionLoad:C,onSessionUnload:O,onMessage:w,beforeMessageSend:m,bodyStyle:h,disabled:R,transform:MM,features:Y}),children:[i.jsx(Zs.Resizable,{height:(oM==null?void 0:oM.height)||"100%",width:(oM==null?void 0:oM.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} ${ZM?"opened":"closed"}`,style:_M(gM({},j),{width:N=="float"?oM==null?void 0:oM.width:j==null?void 0:j.width,height:N==="float"?oM==null?void 0:oM.height:j==null?void 0:j.height,maxHeight:"100vh"}),ref:G,children:[J?i.jsx("div",{className:"loading",children:i.jsx(a.Spin,{})}):zM&&b?i.jsx(zg,{children:i.jsx(Jg,{ref:S,appId:zM,docViewerUrl:g,bodyStyle:h,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)&&!ZM&&i.jsx(a.Button,{className:`${N}-trigger-btn open-btn`,style:t.style,icon:i.jsx("img",{src:s}),onClick:()=>TM(!0)})]})})}),Hg="@glodon-aiot/agent-cli-ui",Vg="3.26.0-alpha.5",Xg="./dist/es/index.mjs",$g="./dist/lib/index.js",Kg="./dist/src/index.d.ts",qg={import:"./dist/es/index.mjs",require:"./dist/lib/index.js",types:"./dist/src/index.d.ts"},MI=["dist"],eI="module",NI="dist/src/index.d.ts",tI={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"},jI={"@ant-design/icons":"^5.3.4","@glodon-aiot/apis":"^3.26.0-alpha.5","@glodon-aiot/bot-client-sdk":"^3.26.0-alpha.5","@glodon-aiot/react-components":"^3.26.0-alpha.5","@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"},iI={"@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"},DI=[">0.2%","not dead","not op_mini all"],sI=["last 1 chrome version","last 1 firefox version","last 1 safari version"],zI={commitizen:{path:"node_modules/cz-customizable"},"cz-customizable":{config:".cz-config.cjs"}},gI={access:"public",registry:"https://registry.npmjs.org/"},II={hooks:{"commit-msg":"validate-commit-msg"}},uI={name:Hg,version:Vg,module:Xg,main:$g,typings:Kg,exports:qg,files:MI,type:eI,types:NI,scripts:tI,dependencies:jI,devDependencies:iI,"lint-staged":{"*.{js,css,md,jsx,less,ts,tsx,json}":"prettier --write"},production:DI,development:sI,config:zI,publishConfig:gI,husky:II};var nD=(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))(nD||{});//! moment.js
|
|
15
|
+
.bmp格式的图片数据,单文件最大${St}M,最多${_e}张`}),children:i.jsx(a.Button,{type:"text",className:"camera-out-btn",style:{width:"22px",position:"relative",bottom:"-2px"},icon:i.jsx(AM,{type:"icon-shangchuantupian",className:"icon-tianjia",style:{fontSize:"22px"}})})}):i.jsx(a.Button,{type:"text",className:"camera-out-btn",style:{width:"22px",position:"relative",bottom:"-2px"},disabled:!0,icon:i.jsx(AM,{type:"icon-shangchuantupian",className:"icon-tianjia",style:{fontSize:"22px"}})})}),s&&(Q!=null&&Q.fileUpload)&&(N!=null&&N.id)?i.jsx(iD,{appId:N==null?void 0:N.id,allowExcelAttachment:N.type===B.ApplicationTypes.Agent,ref:uN,isFirstSession:Yj,docViewerUrl:t,onStatusChange:c=>uM(exports,null,function*(){c!=="process"?(kN(!0),xt()):kN(!1)}),createSession:()=>vj().then(c=>{var E;return((E=c.data)==null?void 0:E.id)||""}),sid:(Ni=j==null?void 0:j.data)==null?void 0:Ni.id,disabled:At||TM,afterFileAdd:(c,o)=>{o&&IN(E=>{const v=E[o]||[];return{[o]:[...v,c]}})},afterFileDelete:c=>{var E;const o=(E=j==null?void 0:j.data)==null?void 0:E.id;o&&IN(v=>{const P=v[o]||[];return{[o]:P.filter(jM=>jM.id!==c)}})},onFileListChange:c=>{Is(c)},shouldContinue:ns,afterFilesClear:()=>{var o;const c=(o=j==null?void 0:j.data)==null?void 0:o.id;c&&(IN({[c]:[]}),xt())}}):null,(Q==null?void 0:Q.prompt)&&(N==null?void 0:N.id)&&i.jsx(Ag,{appId:N.id,list:[],search:gN?is:"",onPromptSelect:c=>{Ve(c.context),h(c.context)},disabled:TM})]}),i.jsxs(a.Space,{children:[(Q==null?void 0:Q.connectNetwork)&&N.type===B.ApplicationTypes.Dialog&&((ti=N.arrange)==null?void 0:ti.length)&&!!N.arrange[0].enableNetOpen&&i.jsx(ug,{sessionId:(ji=j==null?void 0:j.data)==null?void 0:ji.id,netStatus:I,enable:typeof(S==null?void 0:S.connectNetwork)=="object"&&typeof(S==null?void 0:S.connectNetwork.diabled)=="boolean"?!(S!=null&&S.connectNetwork.diabled):As,disabledTip:j?void 0:"网络访问已被禁用",onNetStatusChange:c=>{Gs(c)}}),(Q==null?void 0:Q.sessionList)&&i.jsx(sg,{currentSessionId:(ii=j==null?void 0:j.data)==null?void 0:ii.id,onSessionChange:(c,o)=>{Ve(void 0),pN(!0),g==null||g(o)},disabled:TM}),dM&&mM==="float"&&i.jsx("div",{className:"session-history-drawer-component",children:i.jsx(a.Popover,{placement:"topRight",showArrow:!1,overlayClassName:"session-history-overlay",overlayStyle:{padding:"4px"},getPopupContainer:c=>c.parentNode,content:"会话历史记录",children:i.jsx(a.Button,{className:"history-overlay-action",disabled:TM,type:"text",icon:i.jsx(AM,{type:"icon-lishijilu",style:{fontSize:24}}),onClick:()=>Qj(!0)})})}),(Q==null?void 0:Q.sessionOpen)&&i.jsx(a.Button,{icon:i.jsx(rM.PlusOutlined,{}),className:"add-btn",type:"primary",disabled:xj||!j||!u.length||TM,onClick:()=>{var c,o;pN(!1),g==null||g(null),$e.current=null,n(!1),(c=dj.current)==null||c.clear(),(o=Lt.current)==null||o.clear()},children:"新会话"})]})]}),!!yt&&i.jsx("div",{className:"remainingSeconds-mark"})]}),i.jsxs("div",{className:"footer-textarea",onPaste:Uj,onPasteCapture:Uj,onDrop:bj,onDropCapture:bj,onDragOver:pj,onDragOverCapture:pj,children:[i.jsx(tD,{ref:bM,maxLength:Z,text:ss,networkStatus:!1,loading:Ej||UN,disabled:F||$M||TM||Ej||UN,onTextSend:Ct,onChange:(c,o)=>{Ve(c);const E=o.getText().replace(/[\n\s]+$/,"");h(E),Ds(E),gN||js(!0)},clearAction:i.jsx(a.Space,{size:0,children:i.jsx(a.Button,{type:"link",disabled:At||TM,ghost:!0,icon:i.jsx(AM,{style:{fontSize:22},type:"icon-qingchujiyi"}),onClick:()=>ds()})})}),!!yt&&i.jsxs("div",{className:"remainingSeconds-time",children:["您之前对话触发敏感词拦截,当前处于禁言状态,暂时无法发送消息,剩余禁言时长",yt]})]})]})}),i.jsx(Mg,{tips:J}),Oj&&i.jsx(tg,{isvisible:Oj,files:gs,sessionId:(Di=j==null?void 0:j.data)==null?void 0:Di.id,onClose:c=>{zs(!1),Ts(!1)}})]}),hj&&i.jsx(Ig,{currentSession:j,application:N,networkStatus:I,setCurrentSession:g,disabled:TM,isSessionHistoryVisible:hj,setIsSessionHistoryVisible:Qj,onSessionChange:c=>{pN(!0)}})]})]}),lt&&bN&&L.length>0&&Gi.createPortal(i.jsxs("div",{className:"artifacts-dock",ref:mj,children:[i.jsxs("div",{className:`artifacts-drawer${T?" is-open":""}`,children:[i.jsxs("button",{type:"button",className:"artifacts-handle",onClick:()=>y(c=>!c),children:[i.jsx("span",{className:"artifacts-handle-text",children:"产出物"}),T?i.jsx(rM.RightOutlined,{}):i.jsx(rM.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(Rz,{artifacts:L,activeArtifact:C,onPreview:O})]}),aN.preview==="column"&&C&&i.jsx(Hz,{artifact:C,style:aN.style,onClose:()=>O(null)})]})]}),i.jsx(Fz,{placement:aN.preview,artifact:C,style:aN.style,onClose:()=>O(null),getContainer:()=>mj.current||lt})]}),lt)]})});const uD=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(u=>i.jsx(a.Col,{span:24,children:i.jsx(a.Checkbox,{value:u.id,children:u.name})},u.id))})}),n=u=>{g(u)};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:n,getPopupContainer:u=>u.parentNode,children:i.jsxs("div",{className:"",onClick:u=>u.preventDefault(),children:[i.jsx(AM,{className:"select-icon",type:"icon-open"}),i.jsx("span",{className:"title",children:"参考知识库"}),i.jsxs("span",{className:"content",children:["已选 ",j," 个"]})]})})})},Bg=M=>{var C,O;const{currentSession:e,application:N,setCheckKnowledges:t}=M,{mode:j,transform:D,features:s}=z.useContext(JM),[g,I]=z.useState([]),[n,u]=z.useState(typeof(s==null?void 0:s.knowledges)=="object"?((C=s.knowledges.default)==null?void 0:C.map(w=>w.id))||[]:[]),[r,L]=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 h=w[0].knowledges||[];I(h);const f=typeof(s==null?void 0:s.knowledges)=="object"&&s.knowledges.default||h;if(Array.isArray(f)&&f.some(Y=>Array.isArray(Y.fileIds)&&Y.fileIds.length===0))throw Error("fileIds cannot be an empty array");if($N(f||[])>pe)throw Error(`knowledges and fileIds total count cannot exceed ${pe}`);if(!e){u(f.map(MM=>MM.id)),L(f.length),t==null||t(f);return}const R=()=>{const MM=e.knowledges||f;L(MM.length);const Y=MM.map(eM=>eM.id);u(Y)};return R(),e.addEventListener("data:updated",R),()=>{e==null||e.removeEventListener("data:updated",R)}},[N,e]),z.useEffect(()=>{var m;if(!A||(T(!1),!(N!=null&&N.id)))return;const w=[];n==null||n.map(h=>{const f=g==null?void 0:g.find(W=>W.id===h);w.push(f)}),(m=e==null?void 0:e.data)!=null&&m.id&&e.setKnowledges(w)},[A]);const y=w=>{T(!0),u(w);const m=[];w==null||w.map(h=>{const f=g==null?void 0:g.find(W=>W.id===h);m.push(f)}),t==null||t(m),L(w.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(uD,{disabled:typeof(s==null?void 0:s.knowledges)=="object"&&(s==null?void 0:s.knowledges.diabled)||!1,checkedValues:n,currKnowledgeList:g,selectCount:r,onSelectChange:y})]})};const Jg=z.forwardRef((M,e)=>{const{sessionId:N,appId:t,docViewerUrl:j}=M,[D,s]=z.useState(),{showHeader:g,agentClient:I,sider:n,onSessionLoad:u,features:r,mode:L}=z.useContext(JM),[A,T]=z.useState(),y=z.useRef(null),[C,O]=z.useState(""),[w,m]=z.useState(),h=z.useRef(null),[f,W]=z.useState(!1);z.useState([]);const{setIsSwitchingToExistingSession:R}=qt();z.useEffect(()=>{var Y;W(D?!!((Y=D.data)!=null&&Y.netOpen):typeof(r==null?void 0:r.connectNetwork)=="object"&&typeof(r==null?void 0:r.connectNetwork.default)=="boolean"?r.connectNetwork.default:!1)},[D]),z.useEffect(()=>{const Y=()=>uM(exports,null,function*(){const eM=I==null?void 0:I.application;if(!(eM!=null&&eM.id))return;const b=eM==null?void 0:eM.arrange;if(!(b!=null&&b.length))return;const G=b[0].embeddingService;O(G),T(eM)});if(I!=null&&I.ready){Y();return}return I==null||I.addEventListener("ready",()=>Y()),()=>{I==null||I.removeEventListener("ready",Y)}},[I]),z.useEffect(()=>{I&&N&&(I.ready?I==null||I.getSessions().then(Y=>uM(exports,null,function*(){s==null||s(Y.find(eM=>eM.id===N))})):I.addEventListener("ready",()=>uM(exports,null,function*(){I==null||I.getSessions().then(Y=>uM(exports,null,function*(){s==null||s(Y.find(eM=>eM.id===N))}))}),!0))},[I,N]),z.useEffect(()=>{if(!D){u&&u({applicationId:t,sessionId:"",session:null,sessionInstance:null});return}D.data&&u&&u({applicationId:t,sessionId:D.data.id,session:D.data,sessionInstance:D}),D.addEventListener("data:loaded",()=>{D!=null&&D.data&&u&&u({applicationId:t,sessionId:D.data.id,session:D.data,sessionInstance:D})},!0)},[D]);const MM=Y=>{var eM;return(eM=y.current)==null?void 0:eM.create(_M(gM({},Y),{knowledges:w}))};return z.useImperativeHandle(e,()=>({createSession:Y=>MM(Y),getSessionList:()=>{var eM;const Y=((eM=y.current)==null?void 0:eM.list())||[];return Promise.resolve(Y)},getCurrentInputText:()=>{var Y;return(Y=h.current)==null?void 0:Y.getCurrentInputText()},send:Y=>{var eM;return(eM=h.current)!=null&&eM.send?h.current.send(Y):Promise.reject(new Error("send is not available"))}})),i.jsx("div",{className:"dialog",children:i.jsxs("div",{className:"dialog-pannel",children:[i.jsx("div",{className:"dialog-sider",style:{display:n&&L==="inlay"?"block":"none"},children:i.jsx(Mj,{ref:y,appId:t,networkStatus:f,currentSession:D,application:A,setCurrentSession:s,checkKnowledges:w,setCheckKnowledges:g?m:void 0,sessionId:N,afterSessionClick:Y=>{var eM,b;((eM=Y.data)==null?void 0:eM.id)!==((b=D==null?void 0:D.data)==null?void 0:b.id)&&R(!0)}})}),i.jsx("div",{className:"dialog-content",children:i.jsxs("div",{className:"dialog-chat",children:[g&&i.jsx("div",{className:"dialog-chat-header",children:i.jsx(Bg,{setCheckKnowledges:m,application:A,currentSession:D})}),i.jsx("div",{className:"dialog-chat-content",children:(A==null?void 0:A.id)&&i.jsx(_g,{setNetworkStatus:W,networkStatus:f,application:A,currentSession:D,onCreateSession:MM,docViewerUrl:j,embeddingService:C,setCurrentSession:s,ref:h})})]})})]})})}),Fg=z.forwardRef((M,e)=>{const{className:N,triggerButton:t,size:j,theme:D,icon:s,docViewerUrl:g,token:I,debug:n,env:u,plugins:r,mcp:L,footer:A,defaultInput:T,onComment:y,onSessionLoad:C,onSessionUnload:O,onMessage:w,beforeMessageSend:m,bodyStyle:h,apiUrl:f,sessionId:W,disabled:R,transform:MM,features:Y,stream:eM,agentClient:b,application:p}=M,G=z.useRef(null),[J,Q]=z.useState(!1),[zM,QM]=z.useState(),[oM,yM]=z.useState(j),[ZM,TM]=z.useState(M.open),S=z.useRef(null);z.useEffect(()=>{p&&(console.log("[AgentClientUI] token",b,p),QM(p.id))},[p]),a.ConfigProvider.config({theme:D}),z.useEffect(()=>{j&&yM(j)},[j]);const d=($,{element:dM,size:mM})=>{yM({width:Number(mM.width),height:mM.height})};return z.useImperativeHandle(e,()=>({createSession:$=>{var dM;return(dM=S.current)==null?void 0:dM.createSession($)},getSessionList:()=>{var $;return($=S.current)==null?void 0:$.getSessionList()},getCurrentInputText:()=>{var $;return($=S.current)==null?void 0:$.getCurrentInputText()},send:$=>{var dM;return(dM=S.current)!=null&&dM.send?S.current.send($):Promise.reject(new Error("send is not available"))}})),i.jsx(a.ConfigProvider,{locale:Ri,children:i.jsxs(_i,{value:_M(gM({},M),{popupContainer:G,agentClient:b,footer:A,defaultInput:T,onComment:y,onSessionLoad:C,onSessionUnload:O,onMessage:w,beforeMessageSend:m,bodyStyle:h,disabled:R,transform:MM,features:Y}),children:[i.jsx(Zs.Resizable,{height:(oM==null?void 0:oM.height)||"100%",width:(oM==null?void 0:oM.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} ${ZM?"opened":"closed"}`,style:_M(gM({},j),{width:N=="float"?oM==null?void 0:oM.width:j==null?void 0:j.width,height:N==="float"?oM==null?void 0:oM.height:j==null?void 0:j.height,maxHeight:"100vh"}),ref:G,children:[J?i.jsx("div",{className:"loading",children:i.jsx(a.Spin,{})}):zM&&b?i.jsx(zg,{children:i.jsx(Jg,{ref:S,appId:zM,docViewerUrl:g,bodyStyle:h,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)&&!ZM&&i.jsx(a.Button,{className:`${N}-trigger-btn open-btn`,style:t.style,icon:i.jsx("img",{src:s}),onClick:()=>TM(!0)})]})})}),Hg="@glodon-aiot/agent-cli-ui",Vg="3.26.0-alpha.9",Xg="./dist/es/index.mjs",$g="./dist/lib/index.js",Kg="./dist/src/index.d.ts",qg={import:"./dist/es/index.mjs",require:"./dist/lib/index.js",types:"./dist/src/index.d.ts"},MI=["dist"],eI="module",NI="dist/src/index.d.ts",tI={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"},jI={"@ant-design/icons":"^5.3.4","@glodon-aiot/apis":"^3.26.0-alpha.9","@glodon-aiot/bot-client-sdk":"^3.26.0-alpha.9","@glodon-aiot/react-components":"^3.26.0-alpha.9","@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"},iI={"@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"},DI=[">0.2%","not dead","not op_mini all"],sI=["last 1 chrome version","last 1 firefox version","last 1 safari version"],zI={commitizen:{path:"node_modules/cz-customizable"},"cz-customizable":{config:".cz-config.cjs"}},gI={access:"public",registry:"https://registry.npmjs.org/"},II={hooks:{"commit-msg":"validate-commit-msg"}},uI={name:Hg,version:Vg,module:Xg,main:$g,typings:Kg,exports:qg,files:MI,type:eI,types:NI,scripts:tI,dependencies:jI,devDependencies:iI,"lint-staged":{"*.{js,css,md,jsx,less,ts,tsx,json}":"prettier --write"},production:DI,development:sI,config:zI,publishConfig:gI,husky:II};var nD=(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))(nD||{});//! 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.9",
|
|
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.9",
|
|
35
|
+
"@glodon-aiot/bot-client-sdk": "^3.26.0-alpha.9",
|
|
36
|
+
"@glodon-aiot/react-components": "^3.26.0-alpha.9",
|
|
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",
|