wi-chat 0.4.0 → 0.5.0

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.
Files changed (68) hide show
  1. package/dist/core/index.cjs +1 -1
  2. package/dist/core/index.js +129 -123
  3. package/dist/core/useChat.d.ts +11 -3
  4. package/dist/index.cjs +1 -1
  5. package/dist/index.d.ts +5 -3
  6. package/dist/index.js +102 -74
  7. package/dist/mobile-ui/chat/ChatContainer.vue.d.ts +3 -3
  8. package/dist/mobile-ui/index.cjs +1 -1
  9. package/dist/mobile-ui/index.d.ts +1 -1
  10. package/dist/mobile-ui/index.js +26 -25
  11. package/dist/mobile-ui/inputbox/Inputbox.vue.d.ts +1 -1
  12. package/dist/page-context/extArgs.d.ts +46 -0
  13. package/dist/page-context/index.cjs +2 -0
  14. package/dist/page-context/index.d.ts +18 -0
  15. package/dist/page-context/index.js +48 -0
  16. package/dist/page-context/state.d.ts +10 -0
  17. package/dist/page-context/types.d.ts +218 -0
  18. package/dist/parser/answerCom/actionExecute/actionProtocol.d.ts +38 -0
  19. package/dist/parser/answerCom/actionExecute/clarification.d.ts +67 -0
  20. package/dist/parser/answerCom/actionExecute/parseActionExecute.d.ts +28 -0
  21. package/dist/parser/answerCom/actionExecute/types.d.ts +153 -0
  22. package/dist/parser/index.cjs +2 -2
  23. package/dist/parser/index.d.ts +9 -0
  24. package/dist/parser/index.js +537 -251
  25. package/dist/parser/registry.d.ts +8 -1
  26. package/dist/parser/title.d.ts +27 -0
  27. package/dist/renderers/clarification/ClarificationCard.vue.d.ts +19 -0
  28. package/dist/renderers/index.cjs +1 -1
  29. package/dist/renderers/index.d.ts +1 -0
  30. package/dist/renderers/index.js +641 -354
  31. package/dist/renderers/style.css +1 -1
  32. package/dist/right-panel/RightPanel.vue.d.ts +43 -0
  33. package/dist/right-panel/RightPanelIcon.vue.d.ts +38 -0
  34. package/dist/right-panel/RightPanelTabs.vue.d.ts +39 -0
  35. package/dist/right-panel/icons.d.ts +48 -0
  36. package/dist/right-panel/index.cjs +2 -0
  37. package/dist/right-panel/index.d.ts +43 -0
  38. package/dist/right-panel/index.js +1004 -0
  39. package/dist/right-panel/panels/index.d.ts +7 -0
  40. package/dist/right-panel/panels/newtab/NewTabPanel.vue.d.ts +27 -0
  41. package/dist/right-panel/panels/newtab/defaults.d.ts +6 -0
  42. package/dist/right-panel/panels/newtab/index.d.ts +4 -0
  43. package/dist/right-panel/panels/web/WebPanel.vue.d.ts +28 -0
  44. package/dist/right-panel/panels/web/index.d.ts +4 -0
  45. package/dist/right-panel/panels/web/useWebview.d.ts +59 -0
  46. package/dist/right-panel/registry.d.ts +24 -0
  47. package/dist/right-panel/runtime.d.ts +45 -0
  48. package/dist/right-panel/scope.d.ts +34 -0
  49. package/dist/right-panel/shared/BrowserToolbar.vue.d.ts +23 -0
  50. package/dist/right-panel/shared/RightPanelToolList.vue.d.ts +48 -0
  51. package/dist/right-panel/style.css +1 -0
  52. package/dist/right-panel/types.d.ts +363 -0
  53. package/dist/right-panel/useRightPanel.d.ts +39 -0
  54. package/dist/right-panel/useRightPanelTabs.d.ts +14 -0
  55. package/dist/tools/index.cjs +4 -4
  56. package/dist/tools/index.d.ts +1 -1
  57. package/dist/tools/index.js +182 -162
  58. package/dist/tools/markdown/index.d.ts +1 -1
  59. package/dist/tools/markdown/renderMarkdown.d.ts +25 -0
  60. package/dist/web-ui/attach/AttachmentList.vue.d.ts +1 -1
  61. package/dist/web-ui/chat/ChatContainer.vue.d.ts +3 -3
  62. package/dist/web-ui/envswitch/EnvSwitch.vue.d.ts +2 -2
  63. package/dist/web-ui/index.cjs +1 -1
  64. package/dist/web-ui/index.d.ts +1 -1
  65. package/dist/web-ui/index.js +301 -295
  66. package/dist/web-ui/inputbox/Inputbox.vue.d.ts +4 -7
  67. package/dist/web-ui/style.css +1 -1
  68. package/package.json +13 -6
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("vue"),L=require("wi-chat/parser"),X=require("wi-chat/request"),ne=e=>{var ee;const p=e.login,C=e.defaultGroupTitle??"新对话",A=e.lastCount??10,o=e.autoSetGroupTitleOnFirstQuestion??!0,G=e.beforeKnowledgeRender||(ee=e.parsers)!=null&&ee.length?{beforeKnowledgeRender:e.beforeKnowledgeRender,parsers:e.parsers}:void 0,v=l.ref(""),i=l.ref([]),x=l.ref(""),q=l.ref(e.incPrevQuestion??"Y"),s=l.ref(!1),c=l.ref(!1),t=l.ref(""),u=l.ref(!1),m=l.ref(""),d=l.ref(!0),y=l.ref(!1),I=l.ref(0),D=e.api?null:X.createRequest({baseURL:e.baseURL??"",getWisession:()=>v.value}),T=e.api??X.createChatApi(D);let S=null,M=null,k=0,_=0,V=0,B=null,P=[];const a=async()=>{if(m.value="",!D||!p){u.value=!0;return}try{const n=await X.login(D,p);return v.value=n.wisession||"",u.value=!0,n}catch(n){throw m.value=n instanceof Error?n.message:String(n),n}},r=n=>n===k,Q=n=>{typeof URL>"u"||typeof URL.revokeObjectURL!="function"||n.forEach(w=>{w.role!=="user"||!w.attachments||w.attachments.forEach(h=>{var b;const E=(b=h.attachContent)==null?void 0:b.url;E&&E.startsWith("blob:")&&URL.revokeObjectURL(E)})})},F=async n=>{const w=++_;V+=1,s.value=!0,Q(i.value),i.value=[],t.value=n,d.value=!0,y.value=!1,I.value=0;const h=[],E=()=>{const g=[];h.forEach(O=>{g.push(O.user),O.assistant&&g.push(O.assistant)}),w===_&&(i.value=g)},b=g=>{w===_&&(g.type==="users"?(h.length=0,g.users.forEach(O=>h.push({user:O}))):h[g.index]&&(g.user&&(h[g.index].user=g.user),h[g.index].assistant=g.assistant),E())};try{await L.loadGroupMessagesByStep(T,n,A,b,0,G),E(),w===_&&(I.value=h.length,h.length<A&&(d.value=!1))}finally{V-=1,V<=0&&(V=0,s.value=!1)}},Y=async()=>{if(!t.value||s.value||!d.value||y.value)return;const n=t.value,w=_,h=I.value;y.value=!0;try{const E=await L.loadGroupMessagesByStep(T,n,A,void 0,h,G),b=E.filter(g=>g.role==="user").length;if(b<A&&(d.value=!1),w===_&&t.value===n){const g=new Set;i.value.forEach(R=>{R.historyId&&g.add(R.historyId),R.id&&g.add(R.id)});const O=E.filter(R=>!(R.historyId&&g.has(R.historyId)||R.id&&g.has(R.id)));i.value=[...O,...i.value],I.value+=b}}finally{y.value=!1}},oe=async(n=C)=>{const w=await L.createHistoryGroup(T,n);return t.value=w,w},$=()=>{k+=1,_+=1,M&&(M.stopped=!0,M.thinking.expanded=!1),S==null||S.abort(),S=null,B=null,P=[],M=null,c.value=!1},ie=()=>{M&&(M.error=!0,M.thinking.expanded=!1)},ce=async n=>{var ae,se;const w=typeof n=="string"?{text:n}:n||{},{text:h,entryId:E,files:b,attachments:g,extArgs:O,...R}=w,j=(h!==void 0?h:x.value).trim(),ge=O??e.extArgs??{},ve=b&&b.length>0?b:(g??[]).map(K=>{var z;return(z=K.attachContent)==null?void 0:z.raw}).filter(K=>!!K);if(!j||c.value||!t.value)return;const H=k+1;k=H,_+=1;let te=!1;try{c.value=!0;const K=t.value,z=g||(b||[]).map(f=>{var W;const J=f.name.includes(".")&&((W=f.name.split(".").pop())==null?void 0:W.toLowerCase())||"";return{type:"file",name:f.name,description:J?J.toUpperCase():"",attachContent:{file_name:f.name,size:f.size,suffix:J,raw:f}}}),ye=I.value===0&&!i.value.some(f=>f.role==="user"),Z=K,re=l.reactive({id:L.nextLocalMessageId("user"),role:"user",content:j,attachments:z.length>0?z:void 0});i.value.push(re);const U=l.reactive({id:L.nextLocalMessageId("answer"),role:"assistant",answer:L.createEmptyAnswerValues("",j),error:!1,stopped:!1,thinking:{steps:[],expanded:!0}});if(M=U,i.value.push(U),x.value="",(ae=e.onSubmitQuestion)==null||ae.call(e,j),ye&&Z){const f=j.replace(/[\r\n]+/g," ").trim().slice(0,100);e.onFirstQuestion?e.onFirstQuestion({question:f,groupId:Z}):o&&f&&T.setHistoryGroupTitle(Z,f).catch(()=>{})}S=new AbortController;const he=await T.questionStream({...R,question:j,historyGroupId:K,entryId:E,files:ve,ext_args:JSON.stringify(ge),incPrevQuestion:q.value,onOpen:f=>{if(!r(H))return;B=f;const J=P;P=[],J.forEach(({payloadText:W,chunkSize:N})=>f(W,N))}},S.signal);I.value+=1,await L.consumeStream(he,f=>{var W;if(!r(H))return;if(f.mode==="history_id"){const N=typeof f.value=="object"&&f.value!==null?f.value.history_id:f.value;N&&(re.historyId=String(N),U.historyId=String(N),U.answer&&(U.answer.id=String(N)))}L.applyAnswerChunk(U.answer,f,G).includes("deep_thinking")&&(U.thinking.steps=L.collectThinkingSteps(U.answer)),f.mode==="finish"&&(U.thinking.expanded=!1),(W=e.onChunk)==null||W.call(e,f)}),r(H)&&(U.thinking.expanded=!1),r(H)&&(te=!0)}catch(K){r(H)&&!X.isCancelError(K)&&ie()}finally{r(H)&&(c.value=!1,S=null,M=null,B=null,P=[])}te&&((se=e.onFinish)==null||se.call(e))},fe=(n,w)=>{if(!c.value)return!1;const h=typeof n=="string"?n:JSON.stringify(n)??"";return B?B(h,w):P.push({payloadText:h,chunkSize:w}),!0},de=e.autoLogin!==!1?a().then(()=>{}).catch(()=>{}):Promise.resolve();return l.getCurrentInstance()&&l.onBeforeUnmount(()=>{$(),Q(i.value)}),{messages:i,question:x,incPrevQuestion:q,talking:c,loading:s,session:v,autoLoginDone:u,autoLoginError:m,loginDone:de,historyGroupId:t,selfRequest:D,api:T,doAutoLogin:a,loadGroup:F,loadOlder:Y,hasMore:d,loadMoreLoading:y,createGroup:oe,submitQuestion:ce,sendWsMessage:fe,stopQuestion:$}},pe="wi-chat-history-groups",le=e=>{var P;const{api:p,defaultGroupTitle:C="新对话",lastCount:A=10,ensureGroup:o=!0,autoSelectFirst:G=!0,autoLoadMessages:v=!0}=e,i=e.persistGroups??!1,x=e.storageKey??pe,q=e.beforeKnowledgeRender||(P=e.parsers)!=null&&P.length?{beforeKnowledgeRender:e.beforeKnowledgeRender,parsers:e.parsers}:void 0,s=l.ref([]),c=l.ref(""),t=l.ref([]),u=l.ref(!1);let m=!1,d=null;const y=()=>{if(d===!1)return null;let a;try{a=localStorage.getItem(x)}catch{return d=!1,null}if(a===null)return[];try{const r=JSON.parse(a);return Array.isArray(r)?r:[]}catch{return[]}},I=a=>{if(d!==!1)try{localStorage.setItem(x,JSON.stringify(a))}catch{d=!1}},D=a=>{const r=y();r!==null&&I([...r,a])},T=async(a,r=A)=>{u.value=!0;try{t.value=a?await L.loadGroupMessages(p,a,r,0,q):[]}finally{u.value=!1}},S=async a=>{c.value=a,v&&await T(a)},M=async()=>{if(!m){m=!0;try{s.value.length===0?o&&await _(C):!c.value&&G&&await S(s.value[0].group_id)}finally{m=!1}}},k=async()=>{u.value=!0;try{const a=await L.getHistoryGroups(p);if(i){const r=y();if(r===null)s.value=a;else{const Q=new Set(r.map(Y=>Y.group_id)),F=a.filter(Y=>Q.has(Y.group_id));I(F),s.value=F}}else s.value=a;await M()}finally{u.value=!1}},_=async(a=C)=>{const r=await L.createHistoryGroup(p,a);return i&&D({group_id:r,group_title:a}),await k(),c.value!==r&&await S(r),r};return{groups:s,activeGroupId:c,messages:t,loading:u,loadGroups:k,createGroup:_,renameGroup:async(a,r)=>{await L.setHistoryGroupTitle(p,a,r);const Q=s.value.find(F=>F.group_id===a);Q&&(Q.group_title=r),i&&I(s.value)},deleteGroup:async a=>{const r=s.value.findIndex(F=>F.group_id===a);if(await L.deleteHistoryGroup(p,a),s.value=s.value.filter(F=>F.group_id!==a),i&&I(s.value),c.value!==a)return;const Q=s.value[r]??s.value[s.value.length-1];if(Q){await S(Q.group_id);return}o?await _(C):(c.value="",t.value=[])},selectGroup:S,loadMessages:T}},ue=e=>{const{api:p,defaultEntryId:C,entryGroup:A="智能助手",autoLoad:o=!0}=e,G=l.ref([]),v=l.ref(null),i=l.ref(!1),x=c=>c?typeof p.getFileUrl=="function"?p.getFileUrl(c):L.resolveRemoteFileUrl(c,"","/algorithm/get_file_data"):"",q=c=>{v.value=c},s=async()=>{var c;i.value=!0;try{let t=C||((c=v.value)==null?void 0:c.entry_id);if(!t)try{const y=await p.getDefaultLlmId();t=y==null?void 0:y.default_entry_id}catch(y){console.warn("[useAgent] 获取默认智能体 ID 失败:",y)}const u=await p.getLlmEntryListByRole({entry_group:A}),d=((u==null?void 0:u.values)||[]).filter(y=>y.entry_enable!==!1);if(G.value=d,t){const y=d.find(I=>I.entry_id===t);y?v.value=y:d.length>0&&(v.value=d[0])}else d.length>0&&!v.value&&(v.value=d[0])}finally{i.value=!1}};return o&&(l.getCurrentInstance()?l.onMounted(()=>{s()}):s()),{agentList:G,currentAgent:v,loading:i,getFileUrl:x,loadAgents:s,selectAgent:q}},we=(e={})=>{const p=e.parsers??[];let C=null,A;const o=ne({...e.chat,parsers:p,onFirstQuestion:({question:t,groupId:u})=>{A==null||A(u,t)}}),G=le({...e.history,api:o.api,autoLoadMessages:!1,parsers:p});A=(t,u)=>{C=G.renameGroup(t,u).catch(m=>{var d;(d=e.onError)==null||d.call(e,m,"groups")})};const v=ue({...e.agent,api:o.api,autoLoad:!1}),i=(t,u)=>{var m;(m=e.onError)==null||m.call(e,t,u)},x=async()=>{try{await G.loadGroups()}catch(t){i(t,"groups")}},q=async t=>{try{await o.loadGroup(t)}catch(u){i(u,"messages")}},s=async()=>{try{await v.loadAgents()}catch(t){i(t,"agents")}},c=async t=>{var d;const u=typeof t=="string"?{text:t}:t;await o.submitQuestion({...u,entryId:(u==null?void 0:u.entryId)??((d=v.currentAgent.value)==null?void 0:d.entry_id)});const m=C;C=null,m&&await m,await x()};return l.watch(o.session,t=>{t&&(x(),s())}),l.watch(G.activeGroupId,t=>{t&&q(t)}),{chat:o,history:G,agent:v,parsers:p,messages:o.messages,question:o.question,incPrevQuestion:o.incPrevQuestion,talking:o.talking,loading:o.loading,session:o.session,groups:G.groups,activeGroupId:G.activeGroupId,historyLoading:G.loading,agentList:v.agentList,currentAgent:v.currentAgent,agentLoading:v.loading,hasMore:o.hasMore,loadMoreLoading:o.loadMoreLoading,loadGroup:q,loadOlder:o.loadOlder,refreshGroups:x,loadAgents:s,selectAgent:v.selectAgent,getFileUrl:v.getFileUrl,submitQuestion:c,sendWsMessage:o.sendWsMessage,stopQuestion:o.stopQuestion}};exports.useAgent=ue;exports.useChat=ne;exports.useChatSession=we;exports.useHistory=le;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("vue"),p=require("wi-chat/parser"),X=require("wi-chat/request"),ne=e=>{const w=e.login,b=e.defaultGroupTitle??"新对话",A=e.lastCount??10,o=e.autoSetGroupTitleOnFirstQuestion??!0,m={beforeKnowledgeRender:e.beforeKnowledgeRender,parsers:e.parsers,frontReply:{...e.frontReply,reply:s=>ee(s)}},v=l.ref(""),i=l.ref([]),x=l.ref(""),q=l.ref(e.incPrevQuestion??"Y"),r=l.ref(!1),c=l.ref(!1),t=l.ref(""),u=l.ref(!1),L=l.ref(""),d=l.ref(!0),y=l.ref(!1),I=l.ref(0),D=e.api?null:X.createRequest({baseURL:e.baseURL??"",getWisession:()=>v.value}),T=e.api??X.createChatApi(D);let C=null,M=null,H=0,S=0,V=0,B=null,P=[];const a=async()=>{if(L.value="",!D||!w){u.value=!0;return}try{const s=await X.login(D,w);return v.value=s.wisession||"",u.value=!0,s}catch(s){throw L.value=s instanceof Error?s.message:String(s),s}},n=s=>s===H,Q=s=>{typeof URL>"u"||typeof URL.revokeObjectURL!="function"||s.forEach(G=>{G.role!=="user"||!G.attachments||G.attachments.forEach(h=>{var _;const R=(_=h.attachContent)==null?void 0:_.url;R&&R.startsWith("blob:")&&URL.revokeObjectURL(R)})})},F=async s=>{const G=++S;V+=1,r.value=!0,Q(i.value),p.clearPendingClarifications(),i.value=[],t.value=s,d.value=!0,y.value=!1,I.value=0;const h=[],R=()=>{const g=[];h.forEach(O=>{g.push(O.user),O.assistant&&g.push(O.assistant)}),G===S&&(i.value=g)},_=g=>{G===S&&(g.type==="users"?(h.length=0,g.users.forEach(O=>h.push({user:O}))):h[g.index]&&(g.user&&(h[g.index].user=g.user),h[g.index].assistant=g.assistant),R())};try{await p.loadGroupMessagesByStep(T,s,A,_,0,m),R(),G===S&&(I.value=h.length,h.length<A&&(d.value=!1))}finally{V-=1,V<=0&&(V=0,r.value=!1)}},Y=async()=>{if(!t.value||r.value||!d.value||y.value)return;const s=t.value,G=S,h=I.value;y.value=!0;try{const R=await p.loadGroupMessagesByStep(T,s,A,void 0,h,m),_=R.filter(g=>g.role==="user").length;if(_<A&&(d.value=!1),G===S&&t.value===s){const g=new Set;i.value.forEach(E=>{E.historyId&&g.add(E.historyId),E.id&&g.add(E.id)});const O=R.filter(E=>!(E.historyId&&g.has(E.historyId)||E.id&&g.has(E.id)));i.value=[...O,...i.value],I.value+=_}}finally{y.value=!1}},oe=async(s=b)=>{const G=await p.createHistoryGroup(T,s);return t.value=G,G},$=()=>{H+=1,S+=1,M&&(M.stopped=!0,M.thinking.expanded=!1),C==null||C.abort(),C=null,B=null,P=[],p.clearPendingClarifications(),M=null,c.value=!1},ie=()=>{M&&(M.error=!0,M.thinking.expanded=!1)},ce=async s=>{var ae,se;const G=typeof s=="string"?{text:s}:s||{},{text:h,entryId:R,files:_,attachments:g,extArgs:O,...E}=G,j=(h!==void 0?h:x.value).trim(),de=O??e.extArgs??{},ge=_&&_.length>0?_:(g??[]).map(k=>{var z;return(z=k.attachContent)==null?void 0:z.raw}).filter(k=>!!k);if(!j||c.value||!t.value)return;const K=H+1;H=K,S+=1;let te=!1;try{c.value=!0;const k=t.value,z=g||(_||[]).map(f=>{var W;const J=f.name.includes(".")&&((W=f.name.split(".").pop())==null?void 0:W.toLowerCase())||"";return{type:"file",name:f.name,description:J?J.toUpperCase():"",attachContent:{file_name:f.name,size:f.size,suffix:J,raw:f}}}),ve=I.value===0&&!i.value.some(f=>f.role==="user"),Z=k,re=l.reactive({id:p.nextLocalMessageId("user"),role:"user",content:j,attachments:z.length>0?z:void 0});i.value.push(re);const U=l.reactive({id:p.nextLocalMessageId("answer"),role:"assistant",answer:p.createEmptyAnswerValues("",j),error:!1,stopped:!1,thinking:{steps:[],expanded:!0}});if(M=U,i.value.push(U),x.value="",(ae=e.onSubmitQuestion)==null||ae.call(e,j),ve&&Z){const f=p.buildChatTitle(j);e.onFirstQuestion?e.onFirstQuestion({question:f,groupId:Z}):o&&f&&T.setHistoryGroupTitle(Z,f).catch(()=>{})}C=new AbortController;const ye=await T.questionStream({...E,question:j,historyGroupId:k,entryId:R,files:ge,ext_args:JSON.stringify(de),incPrevQuestion:q.value,onOpen:f=>{if(!n(K))return;B=f;const J=P;P=[],J.forEach(({payloadText:W,chunkSize:N})=>f(W,N))}},C.signal);I.value+=1,await p.consumeStream(ye,f=>{var W;if(!n(K))return;if(f.mode==="history_id"){const N=typeof f.value=="object"&&f.value!==null?f.value.history_id:f.value;N&&(re.historyId=String(N),U.historyId=String(N),U.answer&&(U.answer.id=String(N)))}p.applyAnswerChunk(U.answer,f,m).includes("deep_thinking")&&(U.thinking.steps=p.collectThinkingSteps(U.answer)),f.mode==="finish"&&(U.thinking.expanded=!1),(W=e.onChunk)==null||W.call(e,f)}),n(K)&&(U.thinking.expanded=!1),n(K)&&(te=!0)}catch(k){n(K)&&!X.isCancelError(k)&&ie()}finally{n(K)&&(c.value=!1,C=null,M=null,B=null,P=[])}te&&((se=e.onFinish)==null||se.call(e))},ee=(s,G)=>{if(!c.value)return!1;const h=typeof s=="string"?s:JSON.stringify(s)??"";return B?B(h,G):P.push({payloadText:h,chunkSize:G}),!0},fe=e.autoLogin!==!1?a().then(()=>{}).catch(()=>{}):Promise.resolve();return l.getCurrentInstance()&&l.onBeforeUnmount(()=>{$(),Q(i.value)}),{messages:i,question:x,incPrevQuestion:q,talking:c,loading:r,session:v,autoLoginDone:u,autoLoginError:L,loginDone:fe,historyGroupId:t,selfRequest:D,api:T,doAutoLogin:a,loadGroup:F,loadOlder:Y,hasMore:d,loadMoreLoading:y,createGroup:oe,submitQuestion:ce,sendWsMessage:ee,stopQuestion:$}},he="wi-chat-history-groups",le=e=>{var P;const{api:w,defaultGroupTitle:b="新对话",lastCount:A=10,ensureGroup:o=!0,autoSelectFirst:m=!0,autoLoadMessages:v=!0}=e,i=e.persistGroups??!1,x=e.storageKey??he,q=e.beforeKnowledgeRender||(P=e.parsers)!=null&&P.length?{beforeKnowledgeRender:e.beforeKnowledgeRender,parsers:e.parsers}:void 0,r=l.ref([]),c=l.ref(""),t=l.ref([]),u=l.ref(!1);let L=!1,d=null;const y=()=>{if(d===!1)return null;let a;try{a=localStorage.getItem(x)}catch{return d=!1,null}if(a===null)return[];try{const n=JSON.parse(a);return Array.isArray(n)?n:[]}catch{return[]}},I=a=>{if(d!==!1)try{localStorage.setItem(x,JSON.stringify(a))}catch{d=!1}},D=a=>{const n=y();n!==null&&I([...n,a])},T=async(a,n=A)=>{u.value=!0;try{t.value=a?await p.loadGroupMessages(w,a,n,0,q):[]}finally{u.value=!1}},C=async a=>{c.value=a,v&&await T(a)},M=async()=>{if(!L){L=!0;try{r.value.length===0?o&&await S(b):!c.value&&m&&await C(r.value[0].group_id)}finally{L=!1}}},H=async()=>{u.value=!0;try{const a=await p.getHistoryGroups(w);if(i){const n=y();if(n===null)r.value=a;else{const Q=new Set(n.map(Y=>Y.group_id)),F=a.filter(Y=>Q.has(Y.group_id));I(F),r.value=F}}else r.value=a;await M()}finally{u.value=!1}},S=async(a=b)=>{const n=await p.createHistoryGroup(w,a);return i&&D({group_id:n,group_title:a}),await H(),c.value!==n&&await C(n),n};return{groups:r,activeGroupId:c,messages:t,loading:u,loadGroups:H,createGroup:S,renameGroup:async(a,n)=>{await p.setHistoryGroupTitle(w,a,n);const Q=r.value.find(F=>F.group_id===a);Q&&(Q.group_title=n),i&&I(r.value)},deleteGroup:async a=>{const n=r.value.findIndex(F=>F.group_id===a);if(await p.deleteHistoryGroup(w,a),r.value=r.value.filter(F=>F.group_id!==a),i&&I(r.value),c.value!==a)return;const Q=r.value[n]??r.value[r.value.length-1];if(Q){await C(Q.group_id);return}o?await S(b):(c.value="",t.value=[])},selectGroup:C,loadMessages:T}},ue=e=>{const{api:w,defaultEntryId:b,entryGroup:A="智能助手",autoLoad:o=!0}=e,m=l.ref([]),v=l.ref(null),i=l.ref(!1),x=c=>c?typeof w.getFileUrl=="function"?w.getFileUrl(c):p.resolveRemoteFileUrl(c,"","/algorithm/get_file_data"):"",q=c=>{v.value=c},r=async()=>{var c;i.value=!0;try{let t=b||((c=v.value)==null?void 0:c.entry_id);if(!t)try{const y=await w.getDefaultLlmId();t=y==null?void 0:y.default_entry_id}catch(y){console.warn("[useAgent] 获取默认智能体 ID 失败:",y)}const u=await w.getLlmEntryListByRole({entry_group:A}),d=((u==null?void 0:u.values)||[]).filter(y=>y.entry_enable!==!1);if(m.value=d,t){const y=d.find(I=>I.entry_id===t);y?v.value=y:d.length>0&&(v.value=d[0])}else d.length>0&&!v.value&&(v.value=d[0])}finally{i.value=!1}};return o&&(l.getCurrentInstance()?l.onMounted(()=>{r()}):r()),{agentList:m,currentAgent:v,loading:i,getFileUrl:x,loadAgents:r,selectAgent:q}},pe=(e={})=>{const w=e.parsers??[];let b=null,A;const o=ne({...e.chat,parsers:w,onFirstQuestion:({question:t,groupId:u})=>{A==null||A(u,t)}}),m=le({...e.history,api:o.api,autoLoadMessages:!1,parsers:w});A=(t,u)=>{b=m.renameGroup(t,u).catch(L=>{var d;(d=e.onError)==null||d.call(e,L,"groups")})};const v=ue({...e.agent,api:o.api,autoLoad:!1}),i=(t,u)=>{var L;(L=e.onError)==null||L.call(e,t,u)},x=async()=>{try{await m.loadGroups()}catch(t){i(t,"groups")}},q=async t=>{try{await o.loadGroup(t)}catch(u){i(u,"messages")}},r=async()=>{try{await v.loadAgents()}catch(t){i(t,"agents")}},c=async t=>{var d;const u=typeof t=="string"?{text:t}:t;await o.submitQuestion({...u,entryId:(u==null?void 0:u.entryId)??((d=v.currentAgent.value)==null?void 0:d.entry_id)});const L=b;b=null,L&&await L,await x()};return l.watch(o.session,t=>{t&&(x(),r())}),l.watch(m.activeGroupId,t=>{t&&q(t)}),{chat:o,history:m,agent:v,parsers:w,messages:o.messages,question:o.question,incPrevQuestion:o.incPrevQuestion,talking:o.talking,loading:o.loading,session:o.session,groups:m.groups,activeGroupId:m.activeGroupId,historyLoading:m.loading,agentList:v.agentList,currentAgent:v.currentAgent,agentLoading:v.loading,hasMore:o.hasMore,loadMoreLoading:o.loadMoreLoading,loadGroup:q,loadOlder:o.loadOlder,refreshGroups:x,loadAgents:r,selectAgent:v.selectAgent,getFileUrl:v.getFileUrl,submitQuestion:c,sendWsMessage:o.sendWsMessage,stopQuestion:o.stopQuestion}};exports.useAgent=ue;exports.useChat=ne;exports.useChatSession=pe;exports.useHistory=le;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1,87 +1,93 @@
1
- import { ref as y, getCurrentInstance as ue, onBeforeUnmount as we, reactive as se, onMounted as me, watch as re } from "vue";
2
- import { loadGroupMessagesByStep as ne, createHistoryGroup as oe, nextLocalMessageId as le, createEmptyAnswerValues as Ge, consumeStream as Le, applyAnswerChunk as Ae, collectThinkingSteps as xe, loadGroupMessages as Ie, deleteHistoryGroup as _e, setHistoryGroupTitle as be, getHistoryGroups as Se, resolveRemoteFileUrl as Ce } from "wi-chat/parser";
3
- import { createRequest as Ee, createChatApi as Me, login as Re, isCancelError as Qe } from "wi-chat/request";
4
- const Fe = (e) => {
5
- var Z;
6
- const p = e.login, S = e.defaultGroupTitle ?? "新对话", L = e.lastCount ?? 10, u = e.autoSetGroupTitleOnFirstQuestion ?? !0, m = e.beforeKnowledgeRender || (Z = e.parsers) != null && Z.length ? { beforeKnowledgeRender: e.beforeKnowledgeRender, parsers: e.parsers } : void 0, g = y(""), o = y([]), x = y(""), U = y(e.incPrevQuestion ?? "Y"), s = y(!1), i = y(!1), t = y(""), l = y(!1), G = y(""), f = y(!0), v = y(!1), A = y(0), D = e.api ? null : Ee({
1
+ import { ref as y, getCurrentInstance as oe, onBeforeUnmount as we, reactive as se, onMounted as me, watch as ne } from "vue";
2
+ import { clearPendingClarifications as re, loadGroupMessagesByStep as le, createHistoryGroup as ie, nextLocalMessageId as ue, createEmptyAnswerValues as Ge, buildChatTitle as Le, consumeStream as Ae, applyAnswerChunk as xe, collectThinkingSteps as Ie, loadGroupMessages as _e, deleteHistoryGroup as be, setHistoryGroupTitle as Ce, getHistoryGroups as Se, resolveRemoteFileUrl as Re } from "wi-chat/parser";
3
+ import { createRequest as Ee, createChatApi as Me, login as Qe, isCancelError as Fe } from "wi-chat/request";
4
+ const Ue = (e) => {
5
+ const p = e.login, C = e.defaultGroupTitle ?? "新对话", L = e.lastCount ?? 10, u = e.autoSetGroupTitleOnFirstQuestion ?? !0, m = {
6
+ beforeKnowledgeRender: e.beforeKnowledgeRender,
7
+ parsers: e.parsers,
8
+ frontReply: {
9
+ ...e.frontReply,
10
+ reply: (s) => Z(s)
11
+ }
12
+ }, g = y(""), o = y([]), x = y(""), U = y(e.incPrevQuestion ?? "Y"), n = y(!1), i = y(!1), t = y(""), l = y(!1), G = y(""), f = y(!0), v = y(!1), A = y(0), D = e.api ? null : Ee({
7
13
  baseURL: e.baseURL ?? "",
8
14
  getWisession: () => g.value
9
- }), q = e.api ?? Me(D);
10
- let I = null, C = null, P = 0, _ = 0, j = 0, H = null, O = [];
15
+ }), T = e.api ?? Me(D);
16
+ let I = null, S = null, k = 0, _ = 0, j = 0, H = null, O = [];
11
17
  const a = async () => {
12
18
  if (G.value = "", !D || !p) {
13
19
  l.value = !0;
14
20
  return;
15
21
  }
16
22
  try {
17
- const n = await Re(D, p);
18
- return g.value = n.wisession || "", l.value = !0, n;
19
- } catch (n) {
20
- throw G.value = n instanceof Error ? n.message : String(n), n;
23
+ const s = await Qe(D, p);
24
+ return g.value = s.wisession || "", l.value = !0, s;
25
+ } catch (s) {
26
+ throw G.value = s instanceof Error ? s.message : String(s), s;
21
27
  }
22
- }, r = (n) => n === P, R = (n) => {
23
- typeof URL > "u" || typeof URL.revokeObjectURL != "function" || n.forEach((w) => {
28
+ }, r = (s) => s === k, M = (s) => {
29
+ typeof URL > "u" || typeof URL.revokeObjectURL != "function" || s.forEach((w) => {
24
30
  w.role !== "user" || !w.attachments || w.attachments.forEach((h) => {
25
31
  var b;
26
- const E = (b = h.attachContent) == null ? void 0 : b.url;
27
- E && E.startsWith("blob:") && URL.revokeObjectURL(E);
32
+ const R = (b = h.attachContent) == null ? void 0 : b.url;
33
+ R && R.startsWith("blob:") && URL.revokeObjectURL(R);
28
34
  });
29
35
  });
30
- }, Q = async (n) => {
36
+ }, Q = async (s) => {
31
37
  const w = ++_;
32
- j += 1, s.value = !0, R(o.value), o.value = [], t.value = n, f.value = !0, v.value = !1, A.value = 0;
33
- const h = [], E = () => {
38
+ j += 1, n.value = !0, M(o.value), re(), o.value = [], t.value = s, f.value = !0, v.value = !1, A.value = 0;
39
+ const h = [], R = () => {
34
40
  const d = [];
35
- h.forEach((T) => {
36
- d.push(T.user), T.assistant && d.push(T.assistant);
41
+ h.forEach((q) => {
42
+ d.push(q.user), q.assistant && d.push(q.assistant);
37
43
  }), w === _ && (o.value = d);
38
44
  }, b = (d) => {
39
- w === _ && (d.type === "users" ? (h.length = 0, d.users.forEach((T) => h.push({ user: T }))) : h[d.index] && (d.user && (h[d.index].user = d.user), h[d.index].assistant = d.assistant), E());
45
+ w === _ && (d.type === "users" ? (h.length = 0, d.users.forEach((q) => h.push({ user: q }))) : h[d.index] && (d.user && (h[d.index].user = d.user), h[d.index].assistant = d.assistant), R());
40
46
  };
41
47
  try {
42
- await ne(q, n, L, b, 0, m), E(), w === _ && (A.value = h.length, h.length < L && (f.value = !1));
48
+ await le(T, s, L, b, 0, m), R(), w === _ && (A.value = h.length, h.length < L && (f.value = !1));
43
49
  } finally {
44
- j -= 1, j <= 0 && (j = 0, s.value = !1);
50
+ j -= 1, j <= 0 && (j = 0, n.value = !1);
45
51
  }
46
52
  }, V = async () => {
47
- if (!t.value || s.value || !f.value || v.value)
53
+ if (!t.value || n.value || !f.value || v.value)
48
54
  return;
49
- const n = t.value, w = _, h = A.value;
55
+ const s = t.value, w = _, h = A.value;
50
56
  v.value = !0;
51
57
  try {
52
- const E = await ne(q, n, L, void 0, h, m), b = E.filter((d) => d.role === "user").length;
53
- if (b < L && (f.value = !1), w === _ && t.value === n) {
58
+ const R = await le(T, s, L, void 0, h, m), b = R.filter((d) => d.role === "user").length;
59
+ if (b < L && (f.value = !1), w === _ && t.value === s) {
54
60
  const d = /* @__PURE__ */ new Set();
55
- o.value.forEach((M) => {
56
- M.historyId && d.add(M.historyId), M.id && d.add(M.id);
61
+ o.value.forEach((E) => {
62
+ E.historyId && d.add(E.historyId), E.id && d.add(E.id);
57
63
  });
58
- const T = E.filter((M) => !(M.historyId && d.has(M.historyId) || M.id && d.has(M.id)));
59
- o.value = [...T, ...o.value], A.value += b;
64
+ const q = R.filter((E) => !(E.historyId && d.has(E.historyId) || E.id && d.has(E.id)));
65
+ o.value = [...q, ...o.value], A.value += b;
60
66
  }
61
67
  } finally {
62
68
  v.value = !1;
63
69
  }
64
- }, ie = async (n = S) => {
65
- const w = await oe(q, n);
70
+ }, ce = async (s = C) => {
71
+ const w = await ie(T, s);
66
72
  return t.value = w, w;
67
73
  }, X = () => {
68
- P += 1, _ += 1, C && (C.stopped = !0, C.thinking.expanded = !1), I == null || I.abort(), I = null, H = null, O = [], C = null, i.value = !1;
69
- }, ce = () => {
70
- C && (C.error = !0, C.thinking.expanded = !1);
71
- }, fe = async (n) => {
74
+ k += 1, _ += 1, S && (S.stopped = !0, S.thinking.expanded = !1), I == null || I.abort(), I = null, H = null, O = [], re(), S = null, i.value = !1;
75
+ }, fe = () => {
76
+ S && (S.error = !0, S.thinking.expanded = !1);
77
+ }, de = async (s) => {
72
78
  var ee, te;
73
- const w = typeof n == "string" ? { text: n } : n || {}, { text: h, entryId: E, files: b, attachments: d, extArgs: T, ...M } = w, B = (h !== void 0 ? h : x.value).trim(), ve = T ?? e.extArgs ?? {}, ye = b && b.length > 0 ? b : (d ?? []).map((K) => {
79
+ const w = typeof s == "string" ? { text: s } : s || {}, { text: h, entryId: R, files: b, attachments: d, extArgs: q, ...E } = w, B = (h !== void 0 ? h : x.value).trim(), ve = q ?? e.extArgs ?? {}, ye = b && b.length > 0 ? b : (d ?? []).map((P) => {
74
80
  var Y;
75
- return (Y = K.attachContent) == null ? void 0 : Y.raw;
76
- }).filter((K) => !!K);
81
+ return (Y = P.attachContent) == null ? void 0 : Y.raw;
82
+ }).filter((P) => !!P);
77
83
  if (!B || i.value || !t.value)
78
84
  return;
79
- const k = P + 1;
80
- P = k, _ += 1;
85
+ const K = k + 1;
86
+ k = K, _ += 1;
81
87
  let $ = !1;
82
88
  try {
83
89
  i.value = !0;
84
- const K = t.value, Y = d || (b || []).map((c) => {
90
+ const P = t.value, Y = d || (b || []).map((c) => {
85
91
  var W;
86
92
  const J = c.name.includes(".") && ((W = c.name.split(".").pop()) == null ? void 0 : W.toLowerCase()) || "";
87
93
  return {
@@ -95,42 +101,42 @@ const Fe = (e) => {
95
101
  raw: c
96
102
  }
97
103
  };
98
- }), he = A.value === 0 && !o.value.some((c) => c.role === "user"), z = K, ae = se({
99
- id: le("user"),
104
+ }), he = A.value === 0 && !o.value.some((c) => c.role === "user"), z = P, ae = se({
105
+ id: ue("user"),
100
106
  role: "user",
101
107
  content: B,
102
108
  attachments: Y.length > 0 ? Y : void 0
103
109
  });
104
110
  o.value.push(ae);
105
111
  const F = se({
106
- id: le("answer"),
112
+ id: ue("answer"),
107
113
  role: "assistant",
108
114
  answer: Ge("", B),
109
115
  error: !1,
110
116
  stopped: !1,
111
117
  thinking: { steps: [], expanded: !0 }
112
118
  });
113
- if (C = F, o.value.push(F), x.value = "", (ee = e.onSubmitQuestion) == null || ee.call(e, B), he && z) {
114
- const c = B.replace(/[\r\n]+/g, " ").trim().slice(0, 100);
115
- e.onFirstQuestion ? e.onFirstQuestion({ question: c, groupId: z }) : u && c && q.setHistoryGroupTitle(z, c).catch(() => {
119
+ if (S = F, o.value.push(F), x.value = "", (ee = e.onSubmitQuestion) == null || ee.call(e, B), he && z) {
120
+ const c = Le(B);
121
+ e.onFirstQuestion ? e.onFirstQuestion({ question: c, groupId: z }) : u && c && T.setHistoryGroupTitle(z, c).catch(() => {
116
122
  });
117
123
  }
118
124
  I = new AbortController();
119
- const pe = await q.questionStream(
125
+ const pe = await T.questionStream(
120
126
  {
121
127
  // 先铺开外部透传的额外字段(raw_mode / tables / metrics / group_type 等),
122
128
  // 已知字段随后覆盖,避免同名额外字段篡改核心参数
123
- ...M,
129
+ ...E,
124
130
  question: B,
125
- historyGroupId: K,
126
- entryId: E,
131
+ historyGroupId: P,
132
+ entryId: R,
127
133
  files: ye,
128
134
  ext_args: JSON.stringify(ve),
129
135
  incPrevQuestion: U.value,
130
136
  // 连接建立且首包发完后接收分片发送器,并按序补发连接建立前入队的追发消息
131
137
  // (sendWsMessage 在连接未就绪时调用会先入队,见 sendWsMessage)
132
138
  onOpen: (c) => {
133
- if (!r(k))
139
+ if (!r(K))
134
140
  return;
135
141
  H = c;
136
142
  const J = O;
@@ -139,32 +145,32 @@ const Fe = (e) => {
139
145
  },
140
146
  I.signal
141
147
  );
142
- A.value += 1, await Le(pe, (c) => {
148
+ A.value += 1, await Ae(pe, (c) => {
143
149
  var W;
144
- if (!r(k))
150
+ if (!r(K))
145
151
  return;
146
152
  if (c.mode === "history_id") {
147
153
  const N = typeof c.value == "object" && c.value !== null ? c.value.history_id : c.value;
148
154
  N && (ae.historyId = String(N), F.historyId = String(N), F.answer && (F.answer.id = String(N)));
149
155
  }
150
- Ae(F.answer, c, m).includes("deep_thinking") && (F.thinking.steps = xe(F.answer)), c.mode === "finish" && (F.thinking.expanded = !1), (W = e.onChunk) == null || W.call(e, c);
151
- }), r(k) && (F.thinking.expanded = !1), r(k) && ($ = !0);
152
- } catch (K) {
153
- r(k) && !Qe(K) && ce();
156
+ xe(F.answer, c, m).includes("deep_thinking") && (F.thinking.steps = Ie(F.answer)), c.mode === "finish" && (F.thinking.expanded = !1), (W = e.onChunk) == null || W.call(e, c);
157
+ }), r(K) && (F.thinking.expanded = !1), r(K) && ($ = !0);
158
+ } catch (P) {
159
+ r(K) && !Fe(P) && fe();
154
160
  } finally {
155
- r(k) && (i.value = !1, I = null, C = null, H = null, O = []);
161
+ r(K) && (i.value = !1, I = null, S = null, H = null, O = []);
156
162
  }
157
163
  $ && ((te = e.onFinish) == null || te.call(e));
158
- }, de = (n, w) => {
164
+ }, Z = (s, w) => {
159
165
  if (!i.value)
160
166
  return !1;
161
- const h = typeof n == "string" ? n : JSON.stringify(n) ?? "";
167
+ const h = typeof s == "string" ? s : JSON.stringify(s) ?? "";
162
168
  return H ? H(h, w) : O.push({ payloadText: h, chunkSize: w }), !0;
163
169
  }, ge = e.autoLogin !== !1 ? a().then(() => {
164
170
  }).catch(() => {
165
171
  }) : Promise.resolve();
166
- return ue() && we(() => {
167
- X(), R(o.value);
172
+ return oe() && we(() => {
173
+ X(), M(o.value);
168
174
  }), {
169
175
  /** 当前分组的消息列表(user / assistant 交错;loadGroup / loadOlder / submitQuestion 会更新) */
170
176
  messages: o,
@@ -178,7 +184,7 @@ const Fe = (e) => {
178
184
  /** 会话发送 / 流式回答进行中(true 时 submitQuestion 不再受理新提问) */
179
185
  talking: i,
180
186
  /** 历史加载中(首屏 loadGroup 及并发加载全部完成后结束) */
181
- loading: s,
187
+ loading: n,
182
188
  /** 当前会话 token(自动登录写入;未自动登录时可自行赋值) */
183
189
  session: g,
184
190
  /** 自动登录流程已结束(成功 / 失败 / 跳过均置 true;UI 可等待它再渲染登录状态) */
@@ -192,7 +198,7 @@ const Fe = (e) => {
192
198
  /** 内部自建的 request 客户端(注入 api 时为 null,无使用价值) */
193
199
  selfRequest: D,
194
200
  /** 实际使用的业务 API(外部注入的实例或内部自建) */
195
- api: q,
201
+ api: T,
196
202
  /** 手动触发一次自动登录(成功返回登录结果;失败抛错并记录到 autoLoginError) */
197
203
  doAutoLogin: a,
198
204
  /** 按分组加载消息(插空式渐进渲染;并发调用时仅最新一次生效) */
@@ -204,28 +210,28 @@ const Fe = (e) => {
204
210
  /** 向上翻页加载中(触顶防重) */
205
211
  loadMoreLoading: v,
206
212
  /** 新建历史分组并选中(返回分组 id) */
207
- createGroup: ie,
213
+ createGroup: ce,
208
214
  /** 提交问题并走 SSE 流式问答(支持传参 entryId、files 与文本;无文本 / 发送中 / 无分组时不发送) */
209
- submitQuestion: fe,
215
+ submitQuestion: de,
210
216
  /**
211
217
  * 向当前提问的 WebSocket 连接追发自定义消息(B/M/E 分帧):
212
218
  * 连接就绪立即发出、未就绪入队待连接建立后按序补发;仅在 talking 期间受理,
213
219
  * 无在途会话返回 false。见 sendWsMessage 的 JSDoc。
214
220
  */
215
- sendWsMessage: de,
221
+ sendWsMessage: Z,
216
222
  /** 停止在途会话:中断流、把当前回答标记为 stopped,并复位 talking */
217
223
  stopQuestion: X
218
224
  };
219
- }, Ue = "wi-chat-history-groups", qe = (e) => {
225
+ }, Te = "wi-chat-history-groups", qe = (e) => {
220
226
  var O;
221
227
  const {
222
228
  api: p,
223
- defaultGroupTitle: S = "新对话",
229
+ defaultGroupTitle: C = "新对话",
224
230
  lastCount: L = 10,
225
231
  ensureGroup: u = !0,
226
232
  autoSelectFirst: m = !0,
227
233
  autoLoadMessages: g = !0
228
- } = e, o = e.persistGroups ?? !1, x = e.storageKey ?? Ue, U = e.beforeKnowledgeRender || (O = e.parsers) != null && O.length ? { beforeKnowledgeRender: e.beforeKnowledgeRender, parsers: e.parsers } : void 0, s = y([]), i = y(""), t = y([]), l = y(!1);
234
+ } = e, o = e.persistGroups ?? !1, x = e.storageKey ?? Te, U = e.beforeKnowledgeRender || (O = e.parsers) != null && O.length ? { beforeKnowledgeRender: e.beforeKnowledgeRender, parsers: e.parsers } : void 0, n = y([]), i = y(""), t = y([]), l = y(!1);
229
235
  let G = !1, f = null;
230
236
  const v = () => {
231
237
  if (f === !1)
@@ -254,80 +260,80 @@ const Fe = (e) => {
254
260
  }, D = (a) => {
255
261
  const r = v();
256
262
  r !== null && A([...r, a]);
257
- }, q = async (a, r = L) => {
263
+ }, T = async (a, r = L) => {
258
264
  l.value = !0;
259
265
  try {
260
- t.value = a ? await Ie(p, a, r, 0, U) : [];
266
+ t.value = a ? await _e(p, a, r, 0, U) : [];
261
267
  } finally {
262
268
  l.value = !1;
263
269
  }
264
270
  }, I = async (a) => {
265
- i.value = a, g && await q(a);
266
- }, C = async () => {
271
+ i.value = a, g && await T(a);
272
+ }, S = async () => {
267
273
  if (!G) {
268
274
  G = !0;
269
275
  try {
270
- s.value.length === 0 ? u && await _(S) : !i.value && m && await I(s.value[0].group_id);
276
+ n.value.length === 0 ? u && await _(C) : !i.value && m && await I(n.value[0].group_id);
271
277
  } finally {
272
278
  G = !1;
273
279
  }
274
280
  }
275
- }, P = async () => {
281
+ }, k = async () => {
276
282
  l.value = !0;
277
283
  try {
278
284
  const a = await Se(p);
279
285
  if (o) {
280
286
  const r = v();
281
287
  if (r === null)
282
- s.value = a;
288
+ n.value = a;
283
289
  else {
284
- const R = new Set(r.map((V) => V.group_id)), Q = a.filter((V) => R.has(V.group_id));
285
- A(Q), s.value = Q;
290
+ const M = new Set(r.map((V) => V.group_id)), Q = a.filter((V) => M.has(V.group_id));
291
+ A(Q), n.value = Q;
286
292
  }
287
293
  } else
288
- s.value = a;
289
- await C();
294
+ n.value = a;
295
+ await S();
290
296
  } finally {
291
297
  l.value = !1;
292
298
  }
293
- }, _ = async (a = S) => {
294
- const r = await oe(p, a);
295
- return o && D({ group_id: r, group_title: a }), await P(), i.value !== r && await I(r), r;
299
+ }, _ = async (a = C) => {
300
+ const r = await ie(p, a);
301
+ return o && D({ group_id: r, group_title: a }), await k(), i.value !== r && await I(r), r;
296
302
  };
297
303
  return {
298
- groups: s,
304
+ groups: n,
299
305
  activeGroupId: i,
300
306
  messages: t,
301
307
  loading: l,
302
- loadGroups: P,
308
+ loadGroups: k,
303
309
  createGroup: _,
304
310
  renameGroup: async (a, r) => {
305
- await be(p, a, r);
306
- const R = s.value.find((Q) => Q.group_id === a);
307
- R && (R.group_title = r), o && A(s.value);
311
+ await Ce(p, a, r);
312
+ const M = n.value.find((Q) => Q.group_id === a);
313
+ M && (M.group_title = r), o && A(n.value);
308
314
  },
309
315
  deleteGroup: async (a) => {
310
- const r = s.value.findIndex((Q) => Q.group_id === a);
311
- if (await _e(p, a), s.value = s.value.filter((Q) => Q.group_id !== a), o && A(s.value), i.value !== a)
316
+ const r = n.value.findIndex((Q) => Q.group_id === a);
317
+ if (await be(p, a), n.value = n.value.filter((Q) => Q.group_id !== a), o && A(n.value), i.value !== a)
312
318
  return;
313
- const R = s.value[r] ?? s.value[s.value.length - 1];
314
- if (R) {
315
- await I(R.group_id);
319
+ const M = n.value[r] ?? n.value[n.value.length - 1];
320
+ if (M) {
321
+ await I(M.group_id);
316
322
  return;
317
323
  }
318
- u ? await _(S) : (i.value = "", t.value = []);
324
+ u ? await _(C) : (i.value = "", t.value = []);
319
325
  },
320
326
  selectGroup: I,
321
- loadMessages: q
327
+ loadMessages: T
322
328
  };
323
- }, Te = (e) => {
324
- const { api: p, defaultEntryId: S, entryGroup: L = "智能助手", autoLoad: u = !0 } = e, m = y([]), g = y(null), o = y(!1), x = (i) => i ? typeof p.getFileUrl == "function" ? p.getFileUrl(i) : Ce(i, "", "/algorithm/get_file_data") : "", U = (i) => {
329
+ }, Oe = (e) => {
330
+ const { api: p, defaultEntryId: C, entryGroup: L = "智能助手", autoLoad: u = !0 } = e, m = y([]), g = y(null), o = y(!1), x = (i) => i ? typeof p.getFileUrl == "function" ? p.getFileUrl(i) : Re(i, "", "/algorithm/get_file_data") : "", U = (i) => {
325
331
  g.value = i;
326
- }, s = async () => {
332
+ }, n = async () => {
327
333
  var i;
328
334
  o.value = !0;
329
335
  try {
330
- let t = S || ((i = g.value) == null ? void 0 : i.entry_id);
336
+ let t = C || ((i = g.value) == null ? void 0 : i.entry_id);
331
337
  if (!t)
332
338
  try {
333
339
  const v = await p.getDefaultLlmId();
@@ -345,20 +351,20 @@ const Fe = (e) => {
345
351
  o.value = !1;
346
352
  }
347
353
  };
348
- return u && (ue() ? me(() => {
349
- s();
350
- }) : s()), {
354
+ return u && (oe() ? me(() => {
355
+ n();
356
+ }) : n()), {
351
357
  agentList: m,
352
358
  currentAgent: g,
353
359
  loading: o,
354
360
  getFileUrl: x,
355
- loadAgents: s,
361
+ loadAgents: n,
356
362
  selectAgent: U
357
363
  };
358
- }, ke = (e = {}) => {
364
+ }, We = (e = {}) => {
359
365
  const p = e.parsers ?? [];
360
- let S = null, L;
361
- const u = Fe({
366
+ let C = null, L;
367
+ const u = Ue({
362
368
  ...e.chat,
363
369
  parsers: p,
364
370
  onFirstQuestion: ({ question: t, groupId: l }) => {
@@ -371,12 +377,12 @@ const Fe = (e) => {
371
377
  parsers: p
372
378
  });
373
379
  L = (t, l) => {
374
- S = m.renameGroup(t, l).catch((G) => {
380
+ C = m.renameGroup(t, l).catch((G) => {
375
381
  var f;
376
382
  (f = e.onError) == null || f.call(e, G, "groups");
377
383
  });
378
384
  };
379
- const g = Te({
385
+ const g = Oe({
380
386
  ...e.agent,
381
387
  api: u.api,
382
388
  autoLoad: !1
@@ -395,7 +401,7 @@ const Fe = (e) => {
395
401
  } catch (l) {
396
402
  o(l, "messages");
397
403
  }
398
- }, s = async () => {
404
+ }, n = async () => {
399
405
  try {
400
406
  await g.loadAgents();
401
407
  } catch (t) {
@@ -408,12 +414,12 @@ const Fe = (e) => {
408
414
  ...l,
409
415
  entryId: (l == null ? void 0 : l.entryId) ?? ((f = g.currentAgent.value) == null ? void 0 : f.entry_id)
410
416
  });
411
- const G = S;
412
- S = null, G && await G, await x();
417
+ const G = C;
418
+ C = null, G && await G, await x();
413
419
  };
414
- return re(u.session, (t) => {
415
- t && (x(), s());
416
- }), re(m.activeGroupId, (t) => {
420
+ return ne(u.session, (t) => {
421
+ t && (x(), n());
422
+ }), ne(m.activeGroupId, (t) => {
417
423
  t && U(t);
418
424
  }), {
419
425
  chat: u,
@@ -437,7 +443,7 @@ const Fe = (e) => {
437
443
  loadGroup: U,
438
444
  loadOlder: u.loadOlder,
439
445
  refreshGroups: x,
440
- loadAgents: s,
446
+ loadAgents: n,
441
447
  selectAgent: g.selectAgent,
442
448
  getFileUrl: g.getFileUrl,
443
449
  submitQuestion: i,
@@ -446,9 +452,9 @@ const Fe = (e) => {
446
452
  };
447
453
  };
448
454
  export {
449
- Te as useAgent,
450
- Fe as useChat,
451
- ke as useChatSession,
455
+ Oe as useAgent,
456
+ Ue as useChat,
457
+ We as useChatSession,
452
458
  qe as useHistory
453
459
  };
454
460
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
- import { AnswerParser, BeforeKnowledgeRender, ChatAttachment, StreamChunk } from 'wi-chat/parser';
1
+ import { AnswerParser, BeforeKnowledgeRender, ChatAttachment, FrontReplyOptions, StreamChunk } from 'wi-chat/parser';
2
2
  import { ChatApi, LoginParams, RequestClient } from 'wi-chat/request';
3
3
 
4
4
  export interface UseChatOptions {
@@ -32,7 +32,7 @@ export interface UseChatOptions {
32
32
  */
33
33
  onSubmitQuestion?: (question: string) => void;
34
34
  /**
35
- * 当在某个会话分组提出第一个问题时,是否自动将提问文本作为 history_group 的 title。
35
+ * 当在某个会话分组提出第一个问题时,是否自动将提问文本(经 buildChatTitle 清洗后)作为 history_group 的 title。
36
36
  * 默认 true;若显式传 false 则不自动更新分组标题。
37
37
  */
38
38
  autoSetGroupTitleOnFirstQuestion?: boolean;
@@ -40,7 +40,7 @@ export interface UseChatOptions {
40
40
  * 当在某个会话分组提出第一个问题时的回调。
41
41
  * 若提供此回调,会由该回调全权负责首问联动(例如调用 useHistory.renameGroup 同步远端及分组列表);
42
42
  * 若未提供此回调且 autoSetGroupTitleOnFirstQuestion 为 true,则内部直接调用 api.setHistoryGroupTitle。
43
- * @param payload 包含提问标题文本与分组 ID
43
+ * @param payload 包含清洗后的提问标题文本与分组 ID
44
44
  */
45
45
  onFirstQuestion?: (payload: {
46
46
  question: string;
@@ -69,6 +69,14 @@ export interface UseChatOptions {
69
69
  parsers?: AnswerParser[];
70
70
  /** 已构造的业务 API(供测试注入或外部已配置 auth 的场景);未提供则内部用 createRequest+createChatApi 自建 */
71
71
  api?: ChatApi;
72
+ /**
73
+ * front_reply 指令处理配置(action_execute):
74
+ * - `execute`:`executor === 'host'` 时由宿主执行 Action(返回 { success, message, data });
75
+ * - `onError`:非致命错误回调(指令解析失败 / 执行异常 / 回包失败)。
76
+ * 确认卡片(agent 侧 `collect_clarifications`)无需配置:内部自动注入 reply = sendWsMessage,
77
+ * 用户提交/取消后即回传 wait_reply。
78
+ */
79
+ frontReply?: Omit<FrontReplyOptions, 'reply'>;
72
80
  }
73
81
  /** 提交问题入参选项 */
74
82
  export interface SubmitQuestionOptions {
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("wi-chat/style.css");const r=require("wi-chat/request"),e=require("wi-chat/parser"),a=require("wi-chat/theme"),n=require("wi-chat/core"),t=require("wi-chat/tools");Object.defineProperty(exports,"AuthExpiredError",{enumerable:!0,get:()=>r.AuthExpiredError});Object.defineProperty(exports,"buildChatWsUrl",{enumerable:!0,get:()=>r.buildChatWsUrl});Object.defineProperty(exports,"createChatApi",{enumerable:!0,get:()=>r.createChatApi});Object.defineProperty(exports,"createRequest",{enumerable:!0,get:()=>r.createRequest});Object.defineProperty(exports,"fileToBase64",{enumerable:!0,get:()=>r.fileToBase64});Object.defineProperty(exports,"formDataToJson",{enumerable:!0,get:()=>r.formDataToJson});Object.defineProperty(exports,"isCancelError",{enumerable:!0,get:()=>r.isCancelError});Object.defineProperty(exports,"login",{enumerable:!0,get:()=>r.login});Object.defineProperty(exports,"openChatWebSocketStream",{enumerable:!0,get:()=>r.openChatWebSocketStream});Object.defineProperty(exports,"pwdEncrypt",{enumerable:!0,get:()=>r.pwdEncrypt});Object.defineProperty(exports,"resolveMessageData",{enumerable:!0,get:()=>r.resolveMessageData});Object.defineProperty(exports,"sendPayloadInChunks",{enumerable:!0,get:()=>r.sendPayloadInChunks});Object.defineProperty(exports,"IFRAME_RESIZER_CHILD_SCRIPT",{enumerable:!0,get:()=>e.IFRAME_RESIZER_CHILD_SCRIPT});Object.defineProperty(exports,"IMAGE_EXTENSIONS",{enumerable:!0,get:()=>e.IMAGE_EXTENSIONS});Object.defineProperty(exports,"OUTPUT_FILE_ANSWER_TYPE",{enumerable:!0,get:()=>e.OUTPUT_FILE_ANSWER_TYPE});Object.defineProperty(exports,"RECORDSET_ANSWER_TYPE",{enumerable:!0,get:()=>e.RECORDSET_ANSWER_TYPE});Object.defineProperty(exports,"RoleEnum",{enumerable:!0,get:()=>e.RoleEnum});Object.defineProperty(exports,"applyAnswerChunk",{enumerable:!0,get:()=>e.applyAnswerChunk});Object.defineProperty(exports,"applyDeepThinkingChunk",{enumerable:!0,get:()=>e.applyDeepThinkingChunk});Object.defineProperty(exports,"applyIframePageChunk",{enumerable:!0,get:()=>e.applyIframePageChunk});Object.defineProperty(exports,"applyKnowledgeStreamChunk",{enumerable:!0,get:()=>e.applyKnowledgeStreamChunk});Object.defineProperty(exports,"applyOutputFileChunk",{enumerable:!0,get:()=>e.applyOutputFileChunk});Object.defineProperty(exports,"applyRecordsetChunk",{enumerable:!0,get:()=>e.applyRecordsetChunk});Object.defineProperty(exports,"collectDeepThinkingSteps",{enumerable:!0,get:()=>e.collectDeepThinkingSteps});Object.defineProperty(exports,"collectThinkingSteps",{enumerable:!0,get:()=>e.collectThinkingSteps});Object.defineProperty(exports,"consumeStream",{enumerable:!0,get:()=>e.consumeStream});Object.defineProperty(exports,"createEmptyAnswerValues",{enumerable:!0,get:()=>e.createEmptyAnswerValues});Object.defineProperty(exports,"createHistoryGroup",{enumerable:!0,get:()=>e.createHistoryGroup});Object.defineProperty(exports,"createLineSplitter",{enumerable:!0,get:()=>e.createLineSplitter});Object.defineProperty(exports,"deepThinkingParser",{enumerable:!0,get:()=>e.deepThinkingParser});Object.defineProperty(exports,"deleteHistoryGroup",{enumerable:!0,get:()=>e.deleteHistoryGroup});Object.defineProperty(exports,"extractAttachmentsFromHistory",{enumerable:!0,get:()=>e.extractAttachmentsFromHistory});Object.defineProperty(exports,"extractHistoryAttachments",{enumerable:!0,get:()=>e.extractHistoryAttachments});Object.defineProperty(exports,"formatFileSize",{enumerable:!0,get:()=>e.formatFileSize});Object.defineProperty(exports,"getHistoryGroups",{enumerable:!0,get:()=>e.getHistoryGroups});Object.defineProperty(exports,"iframePageParser",{enumerable:!0,get:()=>e.iframePageParser});Object.defineProperty(exports,"injectIframeResizerScript",{enumerable:!0,get:()=>e.injectIframeResizerScript});Object.defineProperty(exports,"isImageAttachment",{enumerable:!0,get:()=>e.isImageAttachment});Object.defineProperty(exports,"knowledgeStreamParser",{enumerable:!0,get:()=>e.knowledgeStreamParser});Object.defineProperty(exports,"loadGroupMessages",{enumerable:!0,get:()=>e.loadGroupMessages});Object.defineProperty(exports,"loadGroupMessagesByStep",{enumerable:!0,get:()=>e.loadGroupMessagesByStep});Object.defineProperty(exports,"nextLocalMessageId",{enumerable:!0,get:()=>e.nextLocalMessageId});Object.defineProperty(exports,"normalizeAnswer",{enumerable:!0,get:()=>e.normalizeAnswer});Object.defineProperty(exports,"normalizeAnswerReport",{enumerable:!0,get:()=>e.normalizeAnswerReport});Object.defineProperty(exports,"normalizeAttachment",{enumerable:!0,get:()=>e.normalizeAttachment});Object.defineProperty(exports,"normalizeIframePageReport",{enumerable:!0,get:()=>e.normalizeIframePageReport});Object.defineProperty(exports,"normalizeKnowledgeStreamReport",{enumerable:!0,get:()=>e.normalizeKnowledgeStreamReport});Object.defineProperty(exports,"normalizeOutputFileReport",{enumerable:!0,get:()=>e.normalizeOutputFileReport});Object.defineProperty(exports,"normalizeRecordsetReport",{enumerable:!0,get:()=>e.normalizeRecordsetReport});Object.defineProperty(exports,"outputFileParser",{enumerable:!0,get:()=>e.outputFileParser});Object.defineProperty(exports,"parseHistoryAttachment",{enumerable:!0,get:()=>e.parseHistoryAttachment});Object.defineProperty(exports,"parseRealtimeAttachment",{enumerable:!0,get:()=>e.parseRealtimeAttachment});Object.defineProperty(exports,"parseSseLine",{enumerable:!0,get:()=>e.parseSseLine});Object.defineProperty(exports,"readOutputFilePayload",{enumerable:!0,get:()=>e.readOutputFilePayload});Object.defineProperty(exports,"readRecordsetPayload",{enumerable:!0,get:()=>e.readRecordsetPayload});Object.defineProperty(exports,"recordsetParser",{enumerable:!0,get:()=>e.recordsetParser});Object.defineProperty(exports,"resolveAttachDownloadUrl",{enumerable:!0,get:()=>e.resolveAttachDownloadUrl});Object.defineProperty(exports,"resolveAttachPreviewUrl",{enumerable:!0,get:()=>e.resolveAttachPreviewUrl});Object.defineProperty(exports,"resolveRemoteFileUrl",{enumerable:!0,get:()=>e.resolveRemoteFileUrl});Object.defineProperty(exports,"setHistoryGroupTitle",{enumerable:!0,get:()=>e.setHistoryGroupTitle});Object.defineProperty(exports,"DEFAULT_PRIMARY",{enumerable:!0,get:()=>a.DEFAULT_PRIMARY});Object.defineProperty(exports,"applyTheme",{enumerable:!0,get:()=>a.applyTheme});Object.defineProperty(exports,"createChatTheme",{enumerable:!0,get:()=>a.createChatTheme});Object.defineProperty(exports,"useAgent",{enumerable:!0,get:()=>n.useAgent});Object.defineProperty(exports,"useChat",{enumerable:!0,get:()=>n.useChat});Object.defineProperty(exports,"useChatSession",{enumerable:!0,get:()=>n.useChatSession});Object.defineProperty(exports,"useHistory",{enumerable:!0,get:()=>n.useHistory});Object.defineProperty(exports,"closeImagePreview",{enumerable:!0,get:()=>t.closeImagePreview});Object.defineProperty(exports,"downloadAttachment",{enumerable:!0,get:()=>t.downloadAttachment});Object.defineProperty(exports,"openImagePreview",{enumerable:!0,get:()=>t.openImagePreview});Object.defineProperty(exports,"renderMarkdown",{enumerable:!0,get:()=>t.renderMarkdown});Object.defineProperty(exports,"useAutoScroll",{enumerable:!0,get:()=>t.useAutoScroll});
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("wi-chat/style.css");const t=require("wi-chat/request"),e=require("wi-chat/parser"),r=require("wi-chat/page-context"),o=require("wi-chat/theme"),a=require("wi-chat/core"),n=require("wi-chat/tools");Object.defineProperty(exports,"AuthExpiredError",{enumerable:!0,get:()=>t.AuthExpiredError});Object.defineProperty(exports,"buildChatWsUrl",{enumerable:!0,get:()=>t.buildChatWsUrl});Object.defineProperty(exports,"createChatApi",{enumerable:!0,get:()=>t.createChatApi});Object.defineProperty(exports,"createRequest",{enumerable:!0,get:()=>t.createRequest});Object.defineProperty(exports,"fileToBase64",{enumerable:!0,get:()=>t.fileToBase64});Object.defineProperty(exports,"formDataToJson",{enumerable:!0,get:()=>t.formDataToJson});Object.defineProperty(exports,"isCancelError",{enumerable:!0,get:()=>t.isCancelError});Object.defineProperty(exports,"login",{enumerable:!0,get:()=>t.login});Object.defineProperty(exports,"openChatWebSocketStream",{enumerable:!0,get:()=>t.openChatWebSocketStream});Object.defineProperty(exports,"pwdEncrypt",{enumerable:!0,get:()=>t.pwdEncrypt});Object.defineProperty(exports,"resolveMessageData",{enumerable:!0,get:()=>t.resolveMessageData});Object.defineProperty(exports,"sendPayloadInChunks",{enumerable:!0,get:()=>t.sendPayloadInChunks});Object.defineProperty(exports,"ACTION_EXECUTE_ANSWER_TYPE",{enumerable:!0,get:()=>e.ACTION_EXECUTE_ANSWER_TYPE});Object.defineProperty(exports,"CHAT_TITLE_MAX_LENGTH",{enumerable:!0,get:()=>e.CHAT_TITLE_MAX_LENGTH});Object.defineProperty(exports,"IFRAME_RESIZER_CHILD_SCRIPT",{enumerable:!0,get:()=>e.IFRAME_RESIZER_CHILD_SCRIPT});Object.defineProperty(exports,"IMAGE_EXTENSIONS",{enumerable:!0,get:()=>e.IMAGE_EXTENSIONS});Object.defineProperty(exports,"OUTPUT_FILE_ANSWER_TYPE",{enumerable:!0,get:()=>e.OUTPUT_FILE_ANSWER_TYPE});Object.defineProperty(exports,"RECORDSET_ANSWER_TYPE",{enumerable:!0,get:()=>e.RECORDSET_ANSWER_TYPE});Object.defineProperty(exports,"RoleEnum",{enumerable:!0,get:()=>e.RoleEnum});Object.defineProperty(exports,"actionExecuteParser",{enumerable:!0,get:()=>e.actionExecuteParser});Object.defineProperty(exports,"applyActionExecuteChunk",{enumerable:!0,get:()=>e.applyActionExecuteChunk});Object.defineProperty(exports,"applyAnswerChunk",{enumerable:!0,get:()=>e.applyAnswerChunk});Object.defineProperty(exports,"applyDeepThinkingChunk",{enumerable:!0,get:()=>e.applyDeepThinkingChunk});Object.defineProperty(exports,"applyIframePageChunk",{enumerable:!0,get:()=>e.applyIframePageChunk});Object.defineProperty(exports,"applyKnowledgeStreamChunk",{enumerable:!0,get:()=>e.applyKnowledgeStreamChunk});Object.defineProperty(exports,"applyOutputFileChunk",{enumerable:!0,get:()=>e.applyOutputFileChunk});Object.defineProperty(exports,"applyRecordsetChunk",{enumerable:!0,get:()=>e.applyRecordsetChunk});Object.defineProperty(exports,"buildChatTitle",{enumerable:!0,get:()=>e.buildChatTitle});Object.defineProperty(exports,"cancelClarification",{enumerable:!0,get:()=>e.cancelClarification});Object.defineProperty(exports,"clearPendingClarifications",{enumerable:!0,get:()=>e.clearPendingClarifications});Object.defineProperty(exports,"collectDeepThinkingSteps",{enumerable:!0,get:()=>e.collectDeepThinkingSteps});Object.defineProperty(exports,"collectThinkingSteps",{enumerable:!0,get:()=>e.collectThinkingSteps});Object.defineProperty(exports,"consumeStream",{enumerable:!0,get:()=>e.consumeStream});Object.defineProperty(exports,"createEmptyAnswerValues",{enumerable:!0,get:()=>e.createEmptyAnswerValues});Object.defineProperty(exports,"createFailureResult",{enumerable:!0,get:()=>e.createFailureResult});Object.defineProperty(exports,"createHistoryGroup",{enumerable:!0,get:()=>e.createHistoryGroup});Object.defineProperty(exports,"createLineSplitter",{enumerable:!0,get:()=>e.createLineSplitter});Object.defineProperty(exports,"deepThinkingParser",{enumerable:!0,get:()=>e.deepThinkingParser});Object.defineProperty(exports,"deleteHistoryGroup",{enumerable:!0,get:()=>e.deleteHistoryGroup});Object.defineProperty(exports,"extractAttachmentsFromHistory",{enumerable:!0,get:()=>e.extractAttachmentsFromHistory});Object.defineProperty(exports,"extractHistoryAttachments",{enumerable:!0,get:()=>e.extractHistoryAttachments});Object.defineProperty(exports,"formatFileSize",{enumerable:!0,get:()=>e.formatFileSize});Object.defineProperty(exports,"getHistoryGroups",{enumerable:!0,get:()=>e.getHistoryGroups});Object.defineProperty(exports,"hasPendingClarification",{enumerable:!0,get:()=>e.hasPendingClarification});Object.defineProperty(exports,"iframePageParser",{enumerable:!0,get:()=>e.iframePageParser});Object.defineProperty(exports,"injectIframeResizerScript",{enumerable:!0,get:()=>e.injectIframeResizerScript});Object.defineProperty(exports,"isImageAttachment",{enumerable:!0,get:()=>e.isImageAttachment});Object.defineProperty(exports,"knowledgeStreamParser",{enumerable:!0,get:()=>e.knowledgeStreamParser});Object.defineProperty(exports,"loadGroupMessages",{enumerable:!0,get:()=>e.loadGroupMessages});Object.defineProperty(exports,"loadGroupMessagesByStep",{enumerable:!0,get:()=>e.loadGroupMessagesByStep});Object.defineProperty(exports,"nextClarificationRequestId",{enumerable:!0,get:()=>e.nextClarificationRequestId});Object.defineProperty(exports,"nextLocalMessageId",{enumerable:!0,get:()=>e.nextLocalMessageId});Object.defineProperty(exports,"normalizeActionDefinition",{enumerable:!0,get:()=>e.normalizeActionDefinition});Object.defineProperty(exports,"normalizeActionExecuteReport",{enumerable:!0,get:()=>e.normalizeActionExecuteReport});Object.defineProperty(exports,"normalizeActionResult",{enumerable:!0,get:()=>e.normalizeActionResult});Object.defineProperty(exports,"normalizeAnswer",{enumerable:!0,get:()=>e.normalizeAnswer});Object.defineProperty(exports,"normalizeAnswerReport",{enumerable:!0,get:()=>e.normalizeAnswerReport});Object.defineProperty(exports,"normalizeAttachment",{enumerable:!0,get:()=>e.normalizeAttachment});Object.defineProperty(exports,"normalizeIframePageReport",{enumerable:!0,get:()=>e.normalizeIframePageReport});Object.defineProperty(exports,"normalizeKnowledgeStreamReport",{enumerable:!0,get:()=>e.normalizeKnowledgeStreamReport});Object.defineProperty(exports,"normalizeOutputFileReport",{enumerable:!0,get:()=>e.normalizeOutputFileReport});Object.defineProperty(exports,"normalizeRecordsetReport",{enumerable:!0,get:()=>e.normalizeRecordsetReport});Object.defineProperty(exports,"outputFileParser",{enumerable:!0,get:()=>e.outputFileParser});Object.defineProperty(exports,"parseActionExecuteCommand",{enumerable:!0,get:()=>e.parseActionExecuteCommand});Object.defineProperty(exports,"parseClarificationArguments",{enumerable:!0,get:()=>e.parseClarificationArguments});Object.defineProperty(exports,"parseHistoryAttachment",{enumerable:!0,get:()=>e.parseHistoryAttachment});Object.defineProperty(exports,"parseRealtimeAttachment",{enumerable:!0,get:()=>e.parseRealtimeAttachment});Object.defineProperty(exports,"parseSseLine",{enumerable:!0,get:()=>e.parseSseLine});Object.defineProperty(exports,"readOutputFilePayload",{enumerable:!0,get:()=>e.readOutputFilePayload});Object.defineProperty(exports,"readRecordsetPayload",{enumerable:!0,get:()=>e.readRecordsetPayload});Object.defineProperty(exports,"recordsetParser",{enumerable:!0,get:()=>e.recordsetParser});Object.defineProperty(exports,"registerClarification",{enumerable:!0,get:()=>e.registerClarification});Object.defineProperty(exports,"resolveAttachDownloadUrl",{enumerable:!0,get:()=>e.resolveAttachDownloadUrl});Object.defineProperty(exports,"resolveAttachPreviewUrl",{enumerable:!0,get:()=>e.resolveAttachPreviewUrl});Object.defineProperty(exports,"resolveRemoteFileUrl",{enumerable:!0,get:()=>e.resolveRemoteFileUrl});Object.defineProperty(exports,"setHistoryGroupTitle",{enumerable:!0,get:()=>e.setHistoryGroupTitle});Object.defineProperty(exports,"submitClarification",{enumerable:!0,get:()=>e.submitClarification});Object.defineProperty(exports,"wrapActionFrame",{enumerable:!0,get:()=>e.wrapActionFrame});Object.defineProperty(exports,"AGENT_TABLE_STATE_ROW_LIMIT",{enumerable:!0,get:()=>r.AGENT_TABLE_STATE_ROW_LIMIT});Object.defineProperty(exports,"PAGE_CONTEXT_EXT_ARGS_KEY",{enumerable:!0,get:()=>r.PAGE_CONTEXT_EXT_ARGS_KEY});Object.defineProperty(exports,"PAGE_CONTEXT_SCHEMA_VERSION",{enumerable:!0,get:()=>r.PAGE_CONTEXT_SCHEMA_VERSION});Object.defineProperty(exports,"createPageContext",{enumerable:!0,get:()=>r.createPageContext});Object.defineProperty(exports,"isAgentPageContext",{enumerable:!0,get:()=>r.isAgentPageContext});Object.defineProperty(exports,"normalizeAgentPageState",{enumerable:!0,get:()=>r.normalizeAgentPageState});Object.defineProperty(exports,"parsePageContextExtArgs",{enumerable:!0,get:()=>r.parsePageContextExtArgs});Object.defineProperty(exports,"toPageContextExtArgs",{enumerable:!0,get:()=>r.toPageContextExtArgs});Object.defineProperty(exports,"DEFAULT_PRIMARY",{enumerable:!0,get:()=>o.DEFAULT_PRIMARY});Object.defineProperty(exports,"applyTheme",{enumerable:!0,get:()=>o.applyTheme});Object.defineProperty(exports,"createChatTheme",{enumerable:!0,get:()=>o.createChatTheme});Object.defineProperty(exports,"useAgent",{enumerable:!0,get:()=>a.useAgent});Object.defineProperty(exports,"useChat",{enumerable:!0,get:()=>a.useChat});Object.defineProperty(exports,"useChatSession",{enumerable:!0,get:()=>a.useChatSession});Object.defineProperty(exports,"useHistory",{enumerable:!0,get:()=>a.useHistory});Object.defineProperty(exports,"closeImagePreview",{enumerable:!0,get:()=>n.closeImagePreview});Object.defineProperty(exports,"createStyleScope",{enumerable:!0,get:()=>n.createStyleScope});Object.defineProperty(exports,"downloadAttachment",{enumerable:!0,get:()=>n.downloadAttachment});Object.defineProperty(exports,"openImagePreview",{enumerable:!0,get:()=>n.openImagePreview});Object.defineProperty(exports,"renderMarkdown",{enumerable:!0,get:()=>n.renderMarkdown});Object.defineProperty(exports,"useAutoScroll",{enumerable:!0,get:()=>n.useAutoScroll});
2
2
  //# sourceMappingURL=index.cjs.map