@glodon-aiot/agent-cli-ui 2.4.7 → 3.0.4

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 (150) hide show
  1. package/dist/es/AgentClientUI.mjs +97 -110
  2. package/dist/es/Dialog/AgentChat/index.mjs +516 -467
  3. package/dist/es/Dialog/ConnectToNetwork/index.mjs +25 -24
  4. package/dist/es/Dialog/FileCard/index.mjs +48 -55
  5. package/dist/es/Dialog/FilePreview/index.mjs +35 -42
  6. package/dist/es/Dialog/HistoryItem/index.mjs +48 -53
  7. package/dist/es/Dialog/KnowledgeList/index.mjs +55 -48
  8. package/dist/es/Dialog/PromptManager/index.mjs +29 -36
  9. package/dist/es/Dialog/PromptSetting/index.mjs +53 -66
  10. package/dist/es/Dialog/SessionAction/index.mjs +92 -91
  11. package/dist/es/Dialog/SessionList/index.mjs +135 -121
  12. package/dist/es/Dialog/SessionListDrawer/index.mjs +8 -7
  13. package/dist/es/Dialog/SessionRefer/ReferItem/index.mjs +29 -36
  14. package/dist/es/Dialog/SessionRefer/index.mjs +29 -36
  15. package/dist/es/Dialog/SessionRelated/index.mjs +17 -14
  16. package/dist/es/Dialog/UploadKnowledgeFiles/index.mjs +125 -132
  17. package/dist/es/Dialog/index.mjs +125 -93
  18. package/dist/es/QuillEditor/index.mjs +91 -86
  19. package/dist/es/_virtual/index.mjs +2 -2
  20. package/dist/es/components/Markdown/Image/index.mjs +20 -20
  21. package/dist/es/components/Markdown/index.mjs +27 -22
  22. package/dist/es/constant.mjs +8 -5
  23. package/dist/es/index.mjs +178 -152
  24. package/dist/es/node_modules/classnames/index.mjs +1 -1
  25. package/dist/es/node_modules/comma-separated-tokens/index.mjs +13 -0
  26. package/dist/es/node_modules/devlop/lib/default.mjs +5 -0
  27. package/dist/es/node_modules/hast-util-from-dom/lib/index.mjs +93 -0
  28. package/dist/es/node_modules/hast-util-from-dom/node_modules/hastscript/lib/create-h.mjs +126 -0
  29. package/dist/es/node_modules/hast-util-from-dom/node_modules/hastscript/lib/index.mjs +8 -0
  30. package/dist/es/node_modules/hast-util-from-dom/node_modules/hastscript/lib/svg-case-sensitive-tag-names.mjs +4 -0
  31. package/dist/es/node_modules/hast-util-from-dom/node_modules/property-information/index.mjs +12 -0
  32. package/dist/es/node_modules/hast-util-from-dom/node_modules/property-information/lib/aria.mjs +61 -0
  33. package/dist/es/node_modules/hast-util-from-dom/node_modules/property-information/lib/find.mjs +33 -0
  34. package/dist/es/node_modules/hast-util-from-dom/node_modules/property-information/lib/html.mjs +368 -0
  35. package/dist/es/node_modules/hast-util-from-dom/node_modules/property-information/lib/normalize.mjs +6 -0
  36. package/dist/es/node_modules/hast-util-from-dom/node_modules/property-information/lib/svg.mjs +566 -0
  37. package/dist/es/node_modules/hast-util-from-dom/node_modules/property-information/lib/util/case-insensitive-transform.mjs +7 -0
  38. package/dist/es/node_modules/hast-util-from-dom/node_modules/property-information/lib/util/case-sensitive-transform.mjs +6 -0
  39. package/dist/es/node_modules/hast-util-from-dom/node_modules/property-information/lib/util/create.mjs +14 -0
  40. package/dist/es/node_modules/hast-util-from-dom/node_modules/property-information/lib/util/defined-info.mjs +36 -0
  41. package/dist/es/node_modules/hast-util-from-dom/node_modules/property-information/lib/util/info.mjs +28 -0
  42. package/dist/es/node_modules/hast-util-from-dom/node_modules/property-information/lib/util/merge.mjs +10 -0
  43. package/dist/es/node_modules/hast-util-from-dom/node_modules/property-information/lib/util/schema.mjs +21 -0
  44. package/dist/es/node_modules/hast-util-from-dom/node_modules/property-information/lib/util/types.mjs +15 -0
  45. package/dist/es/node_modules/hast-util-from-dom/node_modules/property-information/lib/xlink.mjs +19 -0
  46. package/dist/es/node_modules/hast-util-from-dom/node_modules/property-information/lib/xml.mjs +15 -0
  47. package/dist/es/node_modules/hast-util-from-dom/node_modules/property-information/lib/xmlns.mjs +16 -0
  48. package/dist/es/node_modules/hast-util-from-html-isomorphic/lib/browser.mjs +16 -0
  49. package/dist/es/node_modules/hast-util-is-element/lib/index.mjs +61 -0
  50. package/dist/es/node_modules/hast-util-parse-selector/lib/index.mjs +20 -0
  51. package/dist/es/node_modules/hast-util-to-text/lib/index.mjs +223 -0
  52. package/dist/es/node_modules/katex/dist/katex.min.css.mjs +4 -0
  53. package/dist/es/node_modules/katex/dist/katex.mjs +11700 -0
  54. package/dist/es/node_modules/longest-streak/index.mjs +12 -0
  55. package/dist/es/node_modules/mdast-util-math/lib/index.mjs +170 -0
  56. package/dist/es/node_modules/micromark-extension-math/lib/math-flow.mjs +76 -0
  57. package/dist/es/node_modules/micromark-extension-math/lib/math-text.mjs +48 -0
  58. package/dist/es/node_modules/micromark-extension-math/lib/syntax.mjs +15 -0
  59. package/dist/es/node_modules/micromark-factory-space/index.mjs +15 -0
  60. package/dist/es/node_modules/micromark-util-character/index.mjs +10 -0
  61. package/dist/es/node_modules/rehype-katex/lib/index.mjs +83 -0
  62. package/dist/es/node_modules/remark-math/lib/index.mjs +13 -0
  63. package/dist/es/node_modules/space-separated-tokens/index.mjs +7 -0
  64. package/dist/es/node_modules/unist-util-find-after/lib/index.mjs +32 -0
  65. package/dist/es/node_modules/unist-util-is/lib/index.mjs +81 -0
  66. package/dist/es/node_modules/unist-util-visit-parents/lib/color.mjs +6 -0
  67. package/dist/es/node_modules/unist-util-visit-parents/lib/index.mjs +56 -0
  68. package/dist/es/node_modules/web-namespaces/index.mjs +11 -0
  69. package/dist/es/utils/index.mjs +44 -27
  70. package/dist/lib/index.js +278 -138
  71. package/dist/src/Dialog/AgentChat/index.d.ts +4 -2
  72. package/dist/src/Dialog/ConnectToNetwork/index.d.ts +1 -0
  73. package/dist/src/Dialog/KnowledgeList/KnowledgeSelect/index.d.ts +1 -1
  74. package/dist/src/Dialog/KnowledgeList/index.d.ts +2 -3
  75. package/dist/src/Dialog/PromptSetting/index.d.ts +1 -0
  76. package/dist/src/Dialog/SessionAction/index.d.ts +2 -0
  77. package/dist/src/Dialog/SessionList/index.d.ts +5 -4
  78. package/dist/src/QuillEditor/index.d.ts +1 -0
  79. package/dist/src/components/Markdown/Text/index.d.ts +8 -0
  80. package/dist/src/components/MathJaxLoader/index.d.ts +7 -0
  81. package/dist/src/components/MathJaxRender/index.d.ts +6 -0
  82. package/dist/src/constant.d.ts +1 -1
  83. package/dist/src/contexts/MathJaxContext.d.ts +12 -0
  84. package/dist/src/index.d.ts +4 -1
  85. package/dist/src/types.d.ts +26 -6
  86. package/dist/src/utils/index.d.ts +15 -0
  87. package/package.json +18 -17
  88. package/dist/es/_virtual/index2.mjs +0 -4
  89. package/dist/es/_virtual/index3.mjs +0 -4
  90. package/dist/es/_virtual/index4.mjs +0 -4
  91. package/dist/es/_virtual/minio-zj.mjs +0 -4
  92. package/dist/es/node_modules/@glodon-aiot/minio/dist/minio-zj.mjs +0 -26485
  93. package/dist/es/node_modules/@socket.io/component-emitter/lib/esm/index.mjs +0 -54
  94. package/dist/es/node_modules/base64-js/index.mjs +0 -47
  95. package/dist/es/node_modules/buffer/index.mjs +0 -927
  96. package/dist/es/node_modules/engine.io-client/build/esm/contrib/has-cors.mjs +0 -9
  97. package/dist/es/node_modules/engine.io-client/build/esm/contrib/parseqs.mjs +0 -18
  98. package/dist/es/node_modules/engine.io-client/build/esm/contrib/parseuri.mjs +0 -24
  99. package/dist/es/node_modules/engine.io-client/build/esm/contrib/yeast.mjs +0 -19
  100. package/dist/es/node_modules/engine.io-client/build/esm/globalThis.browser.mjs +0 -4
  101. package/dist/es/node_modules/engine.io-client/build/esm/socket.mjs +0 -317
  102. package/dist/es/node_modules/engine.io-client/build/esm/transport.mjs +0 -113
  103. package/dist/es/node_modules/engine.io-client/build/esm/transports/index.mjs +0 -11
  104. package/dist/es/node_modules/engine.io-client/build/esm/transports/polling.mjs +0 -273
  105. package/dist/es/node_modules/engine.io-client/build/esm/transports/websocket-constructor.browser.mjs +0 -8
  106. package/dist/es/node_modules/engine.io-client/build/esm/transports/websocket.mjs +0 -87
  107. package/dist/es/node_modules/engine.io-client/build/esm/transports/webtransport.mjs +0 -52
  108. package/dist/es/node_modules/engine.io-client/build/esm/transports/xmlhttprequest.browser.mjs +0 -21
  109. package/dist/es/node_modules/engine.io-client/build/esm/util.mjs +0 -23
  110. package/dist/es/node_modules/engine.io-parser/build/esm/commons.mjs +0 -21
  111. package/dist/es/node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.mjs +0 -14
  112. package/dist/es/node_modules/engine.io-parser/build/esm/decodePacket.browser.mjs +0 -39
  113. package/dist/es/node_modules/engine.io-parser/build/esm/encodePacket.browser.mjs +0 -28
  114. package/dist/es/node_modules/engine.io-parser/build/esm/index.mjs +0 -105
  115. package/dist/es/node_modules/ieee754/index.mjs +0 -28
  116. package/dist/es/node_modules/js-base64/base64.mjs +0 -31
  117. package/dist/es/node_modules/socket.io-client/build/esm/contrib/backo2.mjs +0 -26
  118. package/dist/es/node_modules/socket.io-client/build/esm/index.mjs +0 -25
  119. package/dist/es/node_modules/socket.io-client/build/esm/manager.mjs +0 -242
  120. package/dist/es/node_modules/socket.io-client/build/esm/on.mjs +0 -8
  121. package/dist/es/node_modules/socket.io-client/build/esm/socket.mjs +0 -608
  122. package/dist/es/node_modules/socket.io-client/build/esm/url.mjs +0 -19
  123. package/dist/es/node_modules/socket.io-parser/build/esm/binary.mjs +0 -52
  124. package/dist/es/node_modules/socket.io-parser/build/esm/index.mjs +0 -203
  125. package/dist/es/node_modules/socket.io-parser/build/esm/is-binary.mjs +0 -26
  126. package/dist/es/packages/agent-cli-sdk/src/AgentSession.mjs +0 -243
  127. package/dist/es/packages/agent-cli-sdk/src/BotClient.mjs +0 -242
  128. package/dist/es/packages/agent-cli-sdk/src/Config.mjs +0 -34
  129. package/dist/es/packages/agent-cli-sdk/src/DialogSession.mjs +0 -281
  130. package/dist/es/packages/agent-cli-sdk/src/EventBus.mjs +0 -64
  131. package/dist/es/packages/agent-cli-sdk/src/Logger.mjs +0 -31
  132. package/dist/es/packages/agent-cli-sdk/src/PayloadTypes.mjs +0 -4
  133. package/dist/es/packages/agent-cli-sdk/src/Session.mjs +0 -527
  134. package/dist/es/packages/agent-cli-sdk/src/api/fetchEventSource/fetch.mjs +0 -112
  135. package/dist/es/packages/agent-cli-sdk/src/api/fetchEventSource/parse.mjs +0 -97
  136. package/dist/es/packages/agent-cli-sdk/src/api/index.mjs +0 -48
  137. package/dist/es/packages/agent-cli-sdk/src/utils.mjs +0 -11
  138. package/dist/es/packages/apis/dist/es/aecpilot/cosntant.mjs +0 -5
  139. package/dist/es/packages/apis/dist/es/aecpilot/model.mjs +0 -9
  140. package/dist/es/packages/apis/dist/es/aecpilotui/index.mjs +0 -8
  141. package/dist/es/packages/apis/dist/es/agentcliui/index.mjs +0 -414
  142. package/dist/es/packages/apis/dist/es/base/index.mjs +0 -154
  143. package/dist/es/packages/apis/dist/es/cvforce/index.mjs +0 -431
  144. package/dist/es/packages/apis/dist/es/cvforce/model.mjs +0 -6
  145. package/dist/es/packages/apis/dist/es/node_modules/uuid/dist/esm-browser/native.mjs +0 -6
  146. package/dist/es/packages/apis/dist/es/node_modules/uuid/dist/esm-browser/rng.mjs +0 -10
  147. package/dist/es/packages/apis/dist/es/node_modules/uuid/dist/esm-browser/stringify.mjs +0 -9
  148. package/dist/es/packages/apis/dist/es/node_modules/uuid/dist/esm-browser/v4.mjs +0 -19
  149. package/dist/es/packages/apis/dist/es/utils/fetchEventSource/fetch.mjs +0 -106
  150. package/dist/es/packages/apis/dist/es/utils/fetchEventSource/parse.mjs +0 -97
@@ -1,242 +0,0 @@
1
- var u = Object.defineProperty;
2
- var y = (c, i, t) => i in c ? u(c, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : c[i] = t;
3
- var a = (c, i, t) => (y(c, typeof i != "symbol" ? i + "" : i, t), t);
4
- var r = (c, i, t) => new Promise((e, s) => {
5
- var h = (n) => {
6
- try {
7
- o(t.next(n));
8
- } catch (l) {
9
- s(l);
10
- }
11
- }, p = (n) => {
12
- try {
13
- o(t.throw(n));
14
- } catch (l) {
15
- s(l);
16
- }
17
- }, o = (n) => n.done ? e(n.value) : Promise.resolve(n.value).then(h, p);
18
- o((t = t.apply(c, i)).next());
19
- });
20
- import { parseJWT as d } from "./utils.mjs";
21
- import v from "./Logger.mjs";
22
- import { getCVForceService as g } from "./api/index.mjs";
23
- import { configure as m, configuration as f } from "./Config.mjs";
24
- import "axios";
25
- import "../../../node_modules/@glodon-aiot/minio/dist/minio-zj.mjs";
26
- import "dayjs";
27
- import "../../apis/dist/es/node_modules/uuid/dist/esm-browser/native.mjs";
28
- import "../../apis/dist/es/node_modules/uuid/dist/esm-browser/stringify.mjs";
29
- import "../../apis/dist/es/agentcliui/index.mjs";
30
- import "../../apis/dist/es/aecpilotui/index.mjs";
31
- import { ApplicationTypes as _ } from "../../apis/dist/es/cvforce/model.mjs";
32
- import S from "./AgentSession.mjs";
33
- import w from "./DialogSession.mjs";
34
- import k from "./EventBus.mjs";
35
- const A = new v("[BotClient] ");
36
- class F {
37
- constructor(i, t, e = !0) {
38
- a(this, "event", new k());
39
- a(this, "cvforceApi");
40
- //从token解析出来的用户信息
41
- a(this, "_applicationId");
42
- a(this, "_application", null);
43
- //session列表,被加载过的session将会被缓存到这个列表中
44
- a(this, "_sessions", []);
45
- //活跃的session,只支持一个活跃的session
46
- a(this, "_activeSession");
47
- a(this, "_ready", !1);
48
- //问题长度
49
- a(this, "_questionContextMaxLength", 4e3);
50
- a(this, "_promptVariables", []);
51
- if (this._token = i, this.lazyload = e, m(t), this._applicationId = d(i).rid || f.applicationId, !this._applicationId)
52
- throw "token is not vaild";
53
- this.cvforceApi = this.getService(), this.loadApplication().then(() => {
54
- this.event.emit("ready");
55
- });
56
- }
57
- checkReady() {
58
- if (!this.ready)
59
- throw Error("client is not ready.");
60
- }
61
- get ready() {
62
- return this._ready;
63
- }
64
- set ready(i) {
65
- this._ready = i;
66
- }
67
- get questionContextMaxLength() {
68
- return this.checkReady(), this._questionContextMaxLength;
69
- }
70
- get promptVariables() {
71
- return this.checkReady(), this._promptVariables;
72
- }
73
- get knowledges() {
74
- var i;
75
- return this.checkReady(), (i = this._application) == null ? void 0 : i.arrange[0].knowledges;
76
- }
77
- get sessions() {
78
- return this.checkReady(), this._sessions;
79
- }
80
- set sessions(i) {
81
- this.checkReady(), this._sessions = i, this.event.emit("sessions:updated", i);
82
- }
83
- loadApplication() {
84
- return r(this, null, function* () {
85
- var t, e;
86
- this._application = yield this.cvforceApi.getApplicationId(this._applicationId);
87
- const i = (e = (t = this._application.arrange) == null ? void 0 : t[0]) == null ? void 0 : e.llmModel;
88
- return i && (this._questionContextMaxLength = yield this.cvforceApi.getBaseModel(i).then((s) => s.maxModelLength)), this._promptVariables = yield this.cvforceApi.getPrompts(this._applicationId), this._ready = !0, this.event.emit("application:loaded"), this._application;
89
- });
90
- }
91
- getService() {
92
- return this.cvforceApi ? this.cvforceApi : g(f.apiRoot, this.token, (i, t) => A.error(t));
93
- }
94
- get token() {
95
- return this._token;
96
- }
97
- set token(i) {
98
- this.checkReady(), this._token = i, this.ready = !1;
99
- const t = d(i).rid;
100
- this._applicationId !== t && (this._applicationId = t, this._application = null, this.loadApplication().then(() => {
101
- this.event.emit("ready");
102
- }), this.clean());
103
- }
104
- get applicationId() {
105
- return this._applicationId;
106
- }
107
- get application() {
108
- return this.checkReady(), this._application;
109
- }
110
- get activeSession() {
111
- var i;
112
- return this.checkReady(), ((i = this._activeSession) == null ? void 0 : i.id) || "";
113
- }
114
- set activeSession(i) {
115
- this.checkReady(), this.loadSession(i).then((t) => {
116
- this._activeSession && this._activeSession.id !== i && this._activeSession.inactivate(), this._activeSession = t;
117
- });
118
- }
119
- createSession(i, t, e, s) {
120
- return r(this, null, function* () {
121
- return new Promise((h, p) => {
122
- const o = (n) => r(this, null, function* () {
123
- if (n === _.Agent)
124
- h(new S(i, t, e, s));
125
- else if (n === _.Dialog)
126
- h(new w(i, t, e, s));
127
- else
128
- throw Error(`不支持的应用类型:${n}`);
129
- });
130
- if (this.ready) {
131
- if (!this._application)
132
- throw Error("client is not ready");
133
- o(this._application.type);
134
- } else
135
- this.event.on("ready", () => {
136
- if (!this._application)
137
- throw Error("_application is null");
138
- o(this._application.type);
139
- }, !0);
140
- });
141
- });
142
- }
143
- getSessions(i) {
144
- return r(this, null, function* () {
145
- return new Promise((t, e) => {
146
- const s = () => this.cvforceApi.listSessions(this._applicationId, i).then((h) => {
147
- const p = [];
148
- return h.forEach((o) => r(this, null, function* () {
149
- const n = this._sessions.find((l) => o.id === l.id);
150
- if (n)
151
- n.data = o, p.push(n);
152
- else {
153
- const l = yield this.createSession(this.token, o.id, o, this.lazyload);
154
- p.push(l);
155
- }
156
- })), this.sessions = p, p;
157
- });
158
- if (this.ready) {
159
- if (!this._application)
160
- throw Error("_application is null");
161
- t(s());
162
- } else
163
- this.event.on("ready", () => {
164
- if (!this._application)
165
- throw Error("_application is null");
166
- t(s());
167
- }, !0);
168
- });
169
- });
170
- }
171
- loadSession(i = "", t) {
172
- return r(this, null, function* () {
173
- this.checkReady();
174
- let e = this.sessions.find((s) => s.id === i);
175
- if (e || (e = yield this.createSession(this.token, i, t)), this._activeSession) {
176
- if (this._activeSession === e)
177
- return e;
178
- this._activeSession.inactivate();
179
- }
180
- return e.id ? (e.activate(), this._activeSession = e) : e.addEventListener("data:loaded", () => {
181
- e == null || e.activate(), this._activeSession = e;
182
- }), e;
183
- });
184
- }
185
- reload() {
186
- return this.loadApplication().then(() => {
187
- this.event.emit("ready");
188
- });
189
- }
190
- reloadSession(i) {
191
- return r(this, null, function* () {
192
- yield this.reload();
193
- let t = i ? this._sessions.find((e) => e.id === i) : this._activeSession;
194
- if (!t) {
195
- console.warn("reloadSession session failed.");
196
- return;
197
- }
198
- return yield t.reload(), t;
199
- });
200
- }
201
- setTop(i, t, e = "top_time desc, sort_status desc, updated_at desc") {
202
- return r(this, null, function* () {
203
- let s = i ? this._sessions.find((h) => h.id === i) : this._activeSession;
204
- if (!s) {
205
- console.warn("setTop session failed.");
206
- return;
207
- }
208
- return yield s.setTop(t), this.getSessions({
209
- order: e
210
- });
211
- });
212
- }
213
- addEventListener(i, t, e = !1) {
214
- if (typeof t != "function")
215
- throw Error("event listener is not a function");
216
- if (e) {
217
- this.event.once(i, t);
218
- return;
219
- }
220
- this.event.on(i, t);
221
- }
222
- removeEventListener(i, t) {
223
- this.event.off(i, t);
224
- }
225
- removeSession(i, t) {
226
- return r(this, null, function* () {
227
- this.checkReady();
228
- let e = -1;
229
- if (typeof i == "string" ? e = this._sessions.findIndex((s) => s.id === i) : e = this._sessions.findIndex((s) => s === i), e > -1) {
230
- const s = this._sessions[e];
231
- t && (yield s.delete()), this._sessions.splice(e, 1);
232
- } else
233
- console.warn("session delete failed, session is not exist.");
234
- });
235
- }
236
- clean() {
237
- this._sessions.forEach((i) => i.destroy()), this.sessions = [];
238
- }
239
- }
240
- export {
241
- F as default
242
- };
@@ -1,34 +0,0 @@
1
- var v = Object.defineProperty, s = Object.defineProperties;
2
- var u = Object.getOwnPropertyDescriptors;
3
- var n = Object.getOwnPropertySymbols;
4
- var p = Object.prototype.hasOwnProperty, h = Object.prototype.propertyIsEnumerable;
5
- var d = (o, t, e) => t in o ? v(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e, i = (o, t) => {
6
- for (var e in t || (t = {}))
7
- p.call(t, e) && d(o, e, t[e]);
8
- if (n)
9
- for (var e of n(t))
10
- h.call(t, e) && d(o, e, t[e]);
11
- return o;
12
- }, g = (o, t) => s(o, u(t));
13
- import l from "./Logger.mjs";
14
- const R = new l("[Config] ");
15
- var f = /* @__PURE__ */ ((o) => (o.dev = "https://aiot-dev.glodon.com/api/cvforcepd", o.test = "https://aiot-dev.glodon.com/api/cvforce", o.prod = "https://copilot.glodon.com/api/cvforce", o.local = "http://localhost:3000/api/cvforcepd", o))(f || {});
16
- let c = {
17
- debug: !1,
18
- env: "prod",
19
- //AIoT 环境, 与apiRoot配对使用
20
- apiRoot: "https://copilot.glodon.com/api/cvforce",
21
- //https://${hostname}/${PRODUCD_CODE}
22
- applicationId: "",
23
- plugins: {}
24
- };
25
- function x(o) {
26
- console.log("configure", o), l.debug = (o == null ? void 0 : o.debug) || !1, c = g(i(i({}, c), o), {
27
- apiRoot: (o == null ? void 0 : o.apiRoot) || c.apiRoot || (o != null && o.env ? f[o.env || "prod"] : c.apiRoot)
28
- }), R.log("updated", c);
29
- }
30
- export {
31
- f as ApiUrl,
32
- c as configuration,
33
- x as configure
34
- };
@@ -1,281 +0,0 @@
1
- var A = Object.defineProperty, O = Object.defineProperties;
2
- var $ = Object.getOwnPropertyDescriptors;
3
- var S = Object.getOwnPropertySymbols;
4
- var _ = Object.prototype.hasOwnProperty, b = Object.prototype.propertyIsEnumerable;
5
- var M = (o, c, t) => c in o ? A(o, c, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[c] = t, u = (o, c) => {
6
- for (var t in c || (c = {}))
7
- _.call(c, t) && M(o, t, c[t]);
8
- if (S)
9
- for (var t of S(c))
10
- b.call(c, t) && M(o, t, c[t]);
11
- return o;
12
- }, p = (o, c) => O(o, $(c));
13
- var I = (o, c, t) => (M(o, typeof c != "symbol" ? c + "" : c, t), t);
14
- var y = (o, c, t) => new Promise((i, m) => {
15
- var h = (e) => {
16
- try {
17
- g(t.next(e));
18
- } catch (l) {
19
- m(l);
20
- }
21
- }, s = (e) => {
22
- try {
23
- g(t.throw(e));
24
- } catch (l) {
25
- m(l);
26
- }
27
- }, g = (e) => e.done ? i(e.value) : Promise.resolve(e.value).then(h, s);
28
- g((t = t.apply(o, c)).next());
29
- });
30
- import "axios";
31
- import "../../../node_modules/@glodon-aiot/minio/dist/minio-zj.mjs";
32
- import { IHistoryRole as k } from "../../apis/dist/es/aecpilot/model.mjs";
33
- import D from "dayjs";
34
- import "../../apis/dist/es/node_modules/uuid/dist/esm-browser/native.mjs";
35
- import "../../apis/dist/es/node_modules/uuid/dist/esm-browser/stringify.mjs";
36
- import "../../apis/dist/es/agentcliui/index.mjs";
37
- import "../../apis/dist/es/aecpilotui/index.mjs";
38
- import { ChatMessageRole as J } from "../../apis/dist/es/cvforce/model.mjs";
39
- import N from "./Logger.mjs";
40
- import P from "./Session.mjs";
41
- import { fetchEventSource as T } from "./api/fetchEventSource/fetch.mjs";
42
- import { configuration as v } from "./Config.mjs";
43
- const C = new N("[DialogClient] ");
44
- class K extends P {
45
- constructor(t, i = "", m, h) {
46
- super(t, i, m, h);
47
- I(this, "ctrl", new AbortController());
48
- }
49
- prepareConnection() {
50
- return new Promise((t) => y(this, null, function* () {
51
- this._ready || (this._ready = !0, this.event.emit("ready")), this.frozen = !1, t(!0);
52
- }));
53
- }
54
- postChatV2EventSource(t, i, m, h, s, g) {
55
- return y(this, null, function* () {
56
- const e = {
57
- code: 0,
58
- // messageId: uuidv4(),
59
- content: "",
60
- role: k.Robot,
61
- sessionId: "",
62
- reference: [],
63
- searchReference: [],
64
- messageTime: "",
65
- llmModel: "",
66
- comment: {
67
- isAgree: 0
68
- },
69
- isReplying: !1
70
- }, l = p(u({}, m), {
71
- stream: !0
72
- });
73
- T(`${v.apiRoot}/chat/v2/chat?applicationId=${t}&sessionId=${i}`, {
74
- method: "POST",
75
- headers: {
76
- Authorization: `Bearer ${this.token}`,
77
- "Content-Type": "application/json"
78
- },
79
- body: JSON.stringify(l),
80
- openWhenHidden: !0,
81
- signal: h,
82
- onopen(a) {
83
- return a.ok && s != null && s.onopen && s.onopen(), Promise.resolve();
84
- },
85
- onmessage(a) {
86
- if (!a.data.includes('{"code": ')) {
87
- let n = {};
88
- try {
89
- n = JSON.parse(a.data);
90
- } catch (f) {
91
- }
92
- (n == null ? void 0 : n.mtype) === "search" ? e.searchReference.push(n) : e.content = e.content + a.data;
93
- const d = {
94
- content: e.content,
95
- role: 1,
96
- reference: e.reference,
97
- searchReference: e.searchReference,
98
- messageId: e.messageId,
99
- sessionId: i,
100
- messageTime: D(/* @__PURE__ */ new Date()).format("YYYY-MM-DD HH:mm:ss"),
101
- comment: {
102
- isAgree: 0
103
- },
104
- isReplying: !0
105
- };
106
- return (s == null ? void 0 : s.onmessage) && s.onmessage(d);
107
- }
108
- const r = JSON.parse(a.data);
109
- if (e.reference = r.data.reference, e.searchReference = r.data.searchReference, e.messageTime = r.data.messageTime, e.messageId = r.data.messageId, e.llmModel = r.data.llmModel, e.content = r.data.content, e.code = r.code, r.code === 200) {
110
- const n = {
111
- code: e.code,
112
- content: e.content,
113
- role: 1,
114
- reference: e.reference,
115
- searchReference: e.searchReference,
116
- messageId: e.messageId,
117
- sessionId: i,
118
- messageTime: e.messageTime,
119
- isReplying: !0
120
- };
121
- s != null && s.onmessage && s.onmessage(n);
122
- } else
123
- return g && g({
124
- code: r.code,
125
- message: r.message
126
- });
127
- },
128
- onerror() {
129
- s != null && s.onerror && s.onerror();
130
- },
131
- onclose() {
132
- const a = {
133
- code: e.code,
134
- content: e.content,
135
- role: 1,
136
- reference: e.reference,
137
- searchReference: e.searchReference,
138
- messageId: e.messageId,
139
- sessionId: i,
140
- messageTime: e.messageTime,
141
- comment: {
142
- isAgree: 0
143
- },
144
- isReplying: !1,
145
- index: -1
146
- };
147
- s != null && s.onclose && s.onclose(a);
148
- }
149
- });
150
- });
151
- }
152
- postChatV3EventSource(t, i, m, h, s, g) {
153
- return y(this, null, function* () {
154
- const e = {
155
- code: 0,
156
- // messageId: uuidv4(),
157
- content: "",
158
- role: k.Robot,
159
- sessionId: "",
160
- reference: [],
161
- searchReference: [],
162
- messageTime: "",
163
- llmModel: "",
164
- comment: {
165
- isAgree: 0
166
- },
167
- isReplying: !1,
168
- reasoningContent: "",
169
- thinkingSecs: "",
170
- thinkingStatus: ""
171
- }, l = p(u({}, m), {
172
- stream: !0
173
- });
174
- T(`${v.apiRoot}/chat/v3/chat?applicationId=${t}&sessionId=${i}`, {
175
- method: "POST",
176
- headers: {
177
- Authorization: `Bearer ${this.token}`,
178
- "Content-Type": "application/json"
179
- },
180
- body: JSON.stringify(l),
181
- openWhenHidden: !0,
182
- signal: h,
183
- onopen(a) {
184
- return a.ok && s != null && s.onopen && s.onopen(), Promise.resolve();
185
- },
186
- onmessage(a) {
187
- if (!a.data && !a.event && !a.id && !a.retry)
188
- return;
189
- let r = {};
190
- try {
191
- r = JSON.parse(a.data);
192
- } catch (f) {
193
- console.error("parse eventData to JSON failed. ", a.data);
194
- }
195
- if (r.code !== 200)
196
- return g && g({
197
- code: r.code,
198
- message: r.message
199
- });
200
- const n = r.data.type, d = r.data.payload;
201
- if (e.isReplying = !0, n === "search" && e.searchReference.push(d), n === "thinking") {
202
- e.thinkingStatus = "start";
203
- const R = d.choices[0];
204
- e.reasoningContent = e.reasoningContent + R.delta.reasoningContent;
205
- }
206
- if (n === "thinkingOver") {
207
- e.thinkingStatus = "end";
208
- const f = d.thinkingSecs;
209
- e.thinkingSecs = f;
210
- }
211
- if (n === "text") {
212
- const R = d.choices[0];
213
- e.content = e.content + R.delta.content;
214
- }
215
- if (n === "reference" && (e.reference = d), n === "result") {
216
- const f = d.messageId, R = d.llmModel, w = d.messageTime;
217
- e.messageId = f, e.llmModel = R, e.messageTime = w, e.sessionId = i;
218
- }
219
- n === "over" ? e.index = -1 : (e.code = r.code, e.message = r.message), s != null && s.onmessage && s.onmessage(e);
220
- },
221
- onerror() {
222
- s != null && s.onerror && s.onerror();
223
- },
224
- onclose() {
225
- const a = p(u({}, e), {
226
- isReplying: !1
227
- });
228
- s != null && s.onclose && s.onclose(a);
229
- }
230
- });
231
- });
232
- }
233
- sendQuestion(t, i) {
234
- return y(this, null, function* () {
235
- var l;
236
- const {
237
- content: m,
238
- fileIds: h,
239
- oldMessageId: s
240
- } = t, {
241
- stream: g,
242
- referenceFirst: e
243
- } = i;
244
- if (this.active || (yield this.activate()), this._id) {
245
- let a = {
246
- content: m,
247
- fileIds: h,
248
- referenceFirst: e,
249
- oldMessageId: s,
250
- promptVariables: this.promptVariables.reduce((r, n) => p(u({}, r), {
251
- [n.key]: n.value
252
- }), {}),
253
- knowledges: (l = this.knowledges) == null ? void 0 : l.map((r) => r.id)
254
- };
255
- this.postChatV3EventSource(this._applicationId, this._id, a, this.ctrl.signal, {
256
- onopen: () => {
257
- C.log("open", this.ctrl);
258
- },
259
- onmessage: (r) => {
260
- if (this._stopAnswer)
261
- return;
262
- let n = this.messages[this.messages.length - 1];
263
- n && n.role === J.Robot ? (n = u(u({}, n), r), this.messages[this.messages.length - 1] = n, this.event.emit("message:content", n), this.event.emit("message:updated", n)) : (this.pushMessage(r), this.event.emit("message:content", r));
264
- },
265
- onclose: (r) => y(this, null, function* () {
266
- this._stopAnswer || (C.log(r, "onclose"), this.event.emit("answer:finish", r), console.log("onclose", r));
267
- }),
268
- onerror: () => {
269
- this._stopAnswer || (this.event.emit("message:error", ""), this.frozen = !1);
270
- }
271
- });
272
- }
273
- });
274
- }
275
- stopAnswer() {
276
- this.ctrl.abort();
277
- }
278
- }
279
- export {
280
- K as default
281
- };
@@ -1,64 +0,0 @@
1
- var u = Object.defineProperty;
2
- var v = Object.getOwnPropertySymbols;
3
- var o = Object.prototype.hasOwnProperty, L = Object.prototype.propertyIsEnumerable;
4
- var l = (s, e, n) => e in s ? u(s, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : s[e] = n, a = (s, e) => {
5
- for (var n in e || (e = {}))
6
- o.call(e, n) && l(s, n, e[n]);
7
- if (v)
8
- for (var n of v(e))
9
- L.call(e, n) && l(s, n, e[n]);
10
- return s;
11
- };
12
- var h = (s, e, n) => (l(s, typeof e != "symbol" ? e + "" : e, n), n);
13
- import M from "./Logger.mjs";
14
- const i = new M("[EventBus] ");
15
- class $ {
16
- constructor(e = !1) {
17
- h(this, "eventListenerMap", {});
18
- e && i.disable();
19
- }
20
- getEventListenerMap() {
21
- return a({}, this.eventListenerMap);
22
- }
23
- on(e, n, r = !1) {
24
- this.eventListenerMap[e] || (this.eventListenerMap[e] = []), r ? this.eventListenerMap[e].push({
25
- fn: n,
26
- once: !0
27
- }) : this.eventListenerMap[e].push(n), i.log(`add event ${e} listener ${r ? ", call once" : ""}`);
28
- }
29
- once(e, n) {
30
- this.on(e, n, !0);
31
- }
32
- off(e, n) {
33
- if (this.eventListenerMap[e]) {
34
- const r = this.eventListenerMap[e].findIndex((t) => {
35
- if (typeof t == "function" && n === t)
36
- return !0;
37
- if (t = t, t.fn === n)
38
- return !0;
39
- });
40
- r < 0 ? i.log(`event ${e} listener ${n.name} is not found`) : (this.eventListenerMap[e].splice(r, 1), i.log(`remove event ${e} listener`));
41
- } else
42
- i.log(`event ${e} listeners is empty`);
43
- }
44
- emit(e, n) {
45
- if (!this.eventListenerMap[e]) {
46
- i.log(`event ${e} listeners is empty`);
47
- return;
48
- }
49
- const r = [];
50
- for (let t = 0; t < this.eventListenerMap[e].length; t++) {
51
- const f = this.eventListenerMap[e][t];
52
- typeof f == "function" ? f(n) : r.push(f);
53
- }
54
- r.forEach((t) => {
55
- t && (t.fn(n), this.off(e, t.fn));
56
- }), i.log(`event ${e} is fired, has ${this.eventListenerMap[e].length} listeners`);
57
- }
58
- removeAllListeners() {
59
- this.eventListenerMap = {};
60
- }
61
- }
62
- export {
63
- $ as default
64
- };
@@ -1,31 +0,0 @@
1
- var n = Object.defineProperty;
2
- var f = (s, e, i) => e in s ? n(s, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : s[e] = i;
3
- var r = (s, e, i) => (f(s, typeof e != "symbol" ? e + "" : e, i), i);
4
- const o = class o {
5
- constructor(e, i = !1) {
6
- this.prefix = e, this.open = i;
7
- }
8
- disable() {
9
- this.open = !1;
10
- }
11
- enable() {
12
- this.open = !0;
13
- }
14
- log(...e) {
15
- !this.open && !o.debug || console.log(this.prefix, ...e);
16
- }
17
- info(...e) {
18
- !this.open && !o.debug || console.info(`%c ${this.prefix} %o`, "color:#0f0;", ...e);
19
- }
20
- error(...e) {
21
- !this.open && !o.debug || console.error(this.prefix, ...e);
22
- }
23
- warn(...e) {
24
- !this.open && !o.debug || console.warn(this.prefix, ...e);
25
- }
26
- };
27
- r(o, "debug", !1);
28
- let t = o;
29
- export {
30
- t as default
31
- };
@@ -1,4 +0,0 @@
1
- var r = /* @__PURE__ */ ((a) => (a[a.Normal = 0] = "Normal", a[a.Debug = 1] = "Debug", a))(r || {});
2
- export {
3
- r as UserMode
4
- };