wi-chat 0.3.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.
- package/dist/core/index.cjs +1 -1
- package/dist/core/index.js +129 -123
- package/dist/core/useChat.d.ts +11 -3
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.js +101 -68
- package/dist/mobile-ui/chat/ChatContainer.vue.d.ts +8 -3
- package/dist/mobile-ui/chat/ChatMessagesView.vue.d.ts +5 -0
- package/dist/mobile-ui/index.cjs +1 -1
- package/dist/mobile-ui/index.d.ts +2 -2
- package/dist/mobile-ui/index.js +79 -71
- package/dist/mobile-ui/inputbox/Inputbox.vue.d.ts +1 -1
- package/dist/mobile-ui/style.css +1 -1
- package/dist/page-context/extArgs.d.ts +46 -0
- package/dist/page-context/index.cjs +2 -0
- package/dist/page-context/index.d.ts +18 -0
- package/dist/page-context/index.js +48 -0
- package/dist/page-context/state.d.ts +10 -0
- package/dist/page-context/types.d.ts +218 -0
- package/dist/parser/answerCom/actionExecute/actionProtocol.d.ts +38 -0
- package/dist/parser/answerCom/actionExecute/clarification.d.ts +67 -0
- package/dist/parser/answerCom/actionExecute/parseActionExecute.d.ts +28 -0
- package/dist/parser/answerCom/actionExecute/types.d.ts +153 -0
- package/dist/parser/answerCom/outputFile/parseOutputFile.d.ts +43 -0
- package/dist/parser/answerCom/outputFile/types.d.ts +17 -0
- package/dist/parser/index.cjs +2 -2
- package/dist/parser/index.d.ts +12 -0
- package/dist/parser/index.js +537 -211
- package/dist/parser/registry.d.ts +8 -1
- package/dist/parser/title.d.ts +27 -0
- package/dist/renderers/clarification/ClarificationCard.vue.d.ts +19 -0
- package/dist/renderers/index.cjs +1 -1
- package/dist/renderers/index.d.ts +4 -0
- package/dist/renderers/index.js +796 -143
- package/dist/renderers/outputFile/OutputFile.vue.d.ts +19 -0
- package/dist/renderers/outputFile/useOutputFile.d.ts +85 -0
- package/dist/renderers/style.css +1 -1
- package/dist/right-panel/RightPanel.vue.d.ts +43 -0
- package/dist/right-panel/RightPanelIcon.vue.d.ts +38 -0
- package/dist/right-panel/RightPanelTabs.vue.d.ts +39 -0
- package/dist/right-panel/icons.d.ts +48 -0
- package/dist/right-panel/index.cjs +2 -0
- package/dist/right-panel/index.d.ts +43 -0
- package/dist/right-panel/index.js +1004 -0
- package/dist/right-panel/panels/index.d.ts +7 -0
- package/dist/right-panel/panels/newtab/NewTabPanel.vue.d.ts +27 -0
- package/dist/right-panel/panels/newtab/defaults.d.ts +6 -0
- package/dist/right-panel/panels/newtab/index.d.ts +4 -0
- package/dist/right-panel/panels/web/WebPanel.vue.d.ts +28 -0
- package/dist/right-panel/panels/web/index.d.ts +4 -0
- package/dist/right-panel/panels/web/useWebview.d.ts +59 -0
- package/dist/right-panel/registry.d.ts +24 -0
- package/dist/right-panel/runtime.d.ts +45 -0
- package/dist/right-panel/scope.d.ts +34 -0
- package/dist/right-panel/shared/BrowserToolbar.vue.d.ts +23 -0
- package/dist/right-panel/shared/RightPanelToolList.vue.d.ts +48 -0
- package/dist/right-panel/style.css +1 -0
- package/dist/right-panel/types.d.ts +363 -0
- package/dist/right-panel/useRightPanel.d.ts +39 -0
- package/dist/right-panel/useRightPanelTabs.d.ts +14 -0
- package/dist/tools/index.cjs +4 -4
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.js +182 -162
- package/dist/tools/markdown/index.d.ts +1 -1
- package/dist/tools/markdown/renderMarkdown.d.ts +25 -0
- package/dist/web-ui/attach/AttachmentList.vue.d.ts +1 -1
- package/dist/web-ui/chat/ChatContainer.vue.d.ts +8 -3
- package/dist/web-ui/chat/ChatMessagesView.vue.d.ts +5 -0
- package/dist/web-ui/envswitch/EnvSwitch.vue.d.ts +2 -2
- package/dist/web-ui/index.cjs +1 -1
- package/dist/web-ui/index.d.ts +2 -2
- package/dist/web-ui/index.js +428 -408
- package/dist/web-ui/inputbox/Inputbox.vue.d.ts +4 -7
- package/dist/web-ui/style.css +1 -1
- package/package.json +13 -6
package/dist/core/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("vue"),
|
|
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
|
package/dist/core/index.js
CHANGED
|
@@ -1,87 +1,93 @@
|
|
|
1
|
-
import { ref as y, getCurrentInstance as
|
|
2
|
-
import { loadGroupMessagesByStep as
|
|
3
|
-
import { createRequest as Ee, createChatApi as Me, login as
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
}),
|
|
10
|
-
let I = null,
|
|
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
|
|
18
|
-
return g.value =
|
|
19
|
-
} catch (
|
|
20
|
-
throw G.value =
|
|
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 = (
|
|
23
|
-
typeof URL > "u" || typeof URL.revokeObjectURL != "function" ||
|
|
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
|
|
27
|
-
|
|
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 (
|
|
36
|
+
}, Q = async (s) => {
|
|
31
37
|
const w = ++_;
|
|
32
|
-
j += 1,
|
|
33
|
-
const h = [],
|
|
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((
|
|
36
|
-
d.push(
|
|
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((
|
|
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
|
|
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,
|
|
50
|
+
j -= 1, j <= 0 && (j = 0, n.value = !1);
|
|
45
51
|
}
|
|
46
52
|
}, V = async () => {
|
|
47
|
-
if (!t.value ||
|
|
53
|
+
if (!t.value || n.value || !f.value || v.value)
|
|
48
54
|
return;
|
|
49
|
-
const
|
|
55
|
+
const s = t.value, w = _, h = A.value;
|
|
50
56
|
v.value = !0;
|
|
51
57
|
try {
|
|
52
|
-
const
|
|
53
|
-
if (b < L && (f.value = !1), w === _ && t.value ===
|
|
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((
|
|
56
|
-
|
|
61
|
+
o.value.forEach((E) => {
|
|
62
|
+
E.historyId && d.add(E.historyId), E.id && d.add(E.id);
|
|
57
63
|
});
|
|
58
|
-
const
|
|
59
|
-
o.value = [...
|
|
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
|
-
},
|
|
65
|
-
const w = await
|
|
70
|
+
}, ce = async (s = C) => {
|
|
71
|
+
const w = await ie(T, s);
|
|
66
72
|
return t.value = w, w;
|
|
67
73
|
}, X = () => {
|
|
68
|
-
|
|
69
|
-
},
|
|
70
|
-
|
|
71
|
-
},
|
|
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
|
|
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 =
|
|
76
|
-
}).filter((
|
|
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
|
|
80
|
-
|
|
85
|
+
const K = k + 1;
|
|
86
|
+
k = K, _ += 1;
|
|
81
87
|
let $ = !1;
|
|
82
88
|
try {
|
|
83
89
|
i.value = !0;
|
|
84
|
-
const
|
|
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 =
|
|
99
|
-
id:
|
|
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:
|
|
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 (
|
|
114
|
-
const c = B
|
|
115
|
-
e.onFirstQuestion ? e.onFirstQuestion({ question: c, groupId: z }) : u && c &&
|
|
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
|
|
125
|
+
const pe = await T.questionStream(
|
|
120
126
|
{
|
|
121
127
|
// 先铺开外部透传的额外字段(raw_mode / tables / metrics / group_type 等),
|
|
122
128
|
// 已知字段随后覆盖,避免同名额外字段篡改核心参数
|
|
123
|
-
...
|
|
129
|
+
...E,
|
|
124
130
|
question: B,
|
|
125
|
-
historyGroupId:
|
|
126
|
-
entryId:
|
|
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(
|
|
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
|
|
148
|
+
A.value += 1, await Ae(pe, (c) => {
|
|
143
149
|
var W;
|
|
144
|
-
if (!r(
|
|
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
|
-
|
|
151
|
-
}), r(
|
|
152
|
-
} catch (
|
|
153
|
-
r(
|
|
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(
|
|
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
|
-
},
|
|
164
|
+
}, Z = (s, w) => {
|
|
159
165
|
if (!i.value)
|
|
160
166
|
return !1;
|
|
161
|
-
const h = typeof
|
|
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
|
|
167
|
-
X(),
|
|
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:
|
|
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:
|
|
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:
|
|
213
|
+
createGroup: ce,
|
|
208
214
|
/** 提交问题并走 SSE 流式问答(支持传参 entryId、files 与文本;无文本 / 发送中 / 无分组时不发送) */
|
|
209
|
-
submitQuestion:
|
|
215
|
+
submitQuestion: de,
|
|
210
216
|
/**
|
|
211
217
|
* 向当前提问的 WebSocket 连接追发自定义消息(B/M/E 分帧):
|
|
212
218
|
* 连接就绪立即发出、未就绪入队待连接建立后按序补发;仅在 talking 期间受理,
|
|
213
219
|
* 无在途会话返回 false。见 sendWsMessage 的 JSDoc。
|
|
214
220
|
*/
|
|
215
|
-
sendWsMessage:
|
|
221
|
+
sendWsMessage: Z,
|
|
216
222
|
/** 停止在途会话:中断流、把当前回答标记为 stopped,并复位 talking */
|
|
217
223
|
stopQuestion: X
|
|
218
224
|
};
|
|
219
|
-
},
|
|
225
|
+
}, Te = "wi-chat-history-groups", qe = (e) => {
|
|
220
226
|
var O;
|
|
221
227
|
const {
|
|
222
228
|
api: p,
|
|
223
|
-
defaultGroupTitle:
|
|
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 ??
|
|
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
|
-
},
|
|
263
|
+
}, T = async (a, r = L) => {
|
|
258
264
|
l.value = !0;
|
|
259
265
|
try {
|
|
260
|
-
t.value = a ? await
|
|
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
|
|
266
|
-
},
|
|
271
|
+
i.value = a, g && await T(a);
|
|
272
|
+
}, S = async () => {
|
|
267
273
|
if (!G) {
|
|
268
274
|
G = !0;
|
|
269
275
|
try {
|
|
270
|
-
|
|
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
|
-
},
|
|
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
|
-
|
|
288
|
+
n.value = a;
|
|
283
289
|
else {
|
|
284
|
-
const
|
|
285
|
-
A(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
|
-
|
|
289
|
-
await
|
|
294
|
+
n.value = a;
|
|
295
|
+
await S();
|
|
290
296
|
} finally {
|
|
291
297
|
l.value = !1;
|
|
292
298
|
}
|
|
293
|
-
}, _ = async (a =
|
|
294
|
-
const r = await
|
|
295
|
-
return o && D({ group_id: r, group_title: a }), await
|
|
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:
|
|
304
|
+
groups: n,
|
|
299
305
|
activeGroupId: i,
|
|
300
306
|
messages: t,
|
|
301
307
|
loading: l,
|
|
302
|
-
loadGroups:
|
|
308
|
+
loadGroups: k,
|
|
303
309
|
createGroup: _,
|
|
304
310
|
renameGroup: async (a, r) => {
|
|
305
|
-
await
|
|
306
|
-
const
|
|
307
|
-
|
|
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 =
|
|
311
|
-
if (await
|
|
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
|
|
314
|
-
if (
|
|
315
|
-
await I(
|
|
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 _(
|
|
324
|
+
u ? await _(C) : (i.value = "", t.value = []);
|
|
319
325
|
},
|
|
320
326
|
selectGroup: I,
|
|
321
|
-
loadMessages:
|
|
327
|
+
loadMessages: T
|
|
322
328
|
};
|
|
323
|
-
},
|
|
324
|
-
const { api: p, defaultEntryId:
|
|
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
|
-
},
|
|
332
|
+
}, n = async () => {
|
|
327
333
|
var i;
|
|
328
334
|
o.value = !0;
|
|
329
335
|
try {
|
|
330
|
-
let t =
|
|
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 && (
|
|
349
|
-
|
|
350
|
-
}) :
|
|
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:
|
|
361
|
+
loadAgents: n,
|
|
356
362
|
selectAgent: U
|
|
357
363
|
};
|
|
358
|
-
},
|
|
364
|
+
}, We = (e = {}) => {
|
|
359
365
|
const p = e.parsers ?? [];
|
|
360
|
-
let
|
|
361
|
-
const u =
|
|
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
|
-
|
|
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 =
|
|
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
|
-
},
|
|
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 =
|
|
412
|
-
|
|
417
|
+
const G = C;
|
|
418
|
+
C = null, G && await G, await x();
|
|
413
419
|
};
|
|
414
|
-
return
|
|
415
|
-
t && (x(),
|
|
416
|
-
}),
|
|
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:
|
|
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
|
-
|
|
450
|
-
|
|
451
|
-
|
|
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
|
package/dist/core/useChat.d.ts
CHANGED
|
@@ -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
|
-
*
|
|
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
|
|
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,"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,"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,"normalizeRecordsetReport",{enumerable:!0,get:()=>e.normalizeRecordsetReport});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,"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
|