@glodon-aiot/bot-client-sdk 3.26.0-alpha.5 → 3.26.0-alpha.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/README.md +76 -105
  2. package/dist/es/AgentSession.mjs +32 -33
  3. package/dist/es/Config.mjs +85 -63
  4. package/dist/es/DialogSession.mjs +39 -40
  5. package/dist/es/Session.mjs +71 -63
  6. package/dist/es/index.mjs +48 -49
  7. package/dist/es/localFiles/adapters/FileSystemAccessAdapter.mjs +103 -193
  8. package/dist/es/localFiles/adapters/HostBridgeAdapter.mjs +77 -138
  9. package/dist/es/localFiles/adapters/MemoryWorkspaceAdapter.mjs +97 -132
  10. package/dist/es/localFiles/adapters/WorkspaceFileAdapter.mjs +28 -32
  11. package/dist/es/localFiles/constants.mjs +1 -1
  12. package/dist/es/localFiles/createLocalPythonPlugin.mjs +196 -0
  13. package/dist/es/localFiles/host/connectHostBridge.mjs +18 -22
  14. package/dist/es/localFiles/host/protocol.mjs +5 -6
  15. package/dist/es/localFiles/schemas.mjs +60 -45
  16. package/dist/es/localFiles/validate.mjs +37 -37
  17. package/dist/es/localFiles/workspace/LocalWorkspace.mjs +52 -71
  18. package/dist/es/package.json.mjs +29 -38
  19. package/dist/lib/index.js +9 -372
  20. package/dist/src/Config.d.ts +2 -2
  21. package/dist/src/Session.d.ts +4 -0
  22. package/dist/src/localFiles/adapters/FileSystemAccessAdapter.d.ts +1 -4
  23. package/dist/src/localFiles/adapters/HostBridgeAdapter.d.ts +1 -20
  24. package/dist/src/localFiles/adapters/MemoryWorkspaceAdapter.d.ts +1 -4
  25. package/dist/src/localFiles/adapters/WorkspaceFileAdapter.d.ts +0 -14
  26. package/dist/src/localFiles/adapters/fsaTypes.d.ts +0 -2
  27. package/dist/src/localFiles/constants.d.ts +1 -2
  28. package/dist/src/localFiles/host/protocol.d.ts +0 -13
  29. package/dist/src/localFiles/index.d.ts +2 -3
  30. package/dist/src/localFiles/schemas.d.ts +3 -2
  31. package/dist/src/localFiles/types.d.ts +1 -14
  32. package/dist/src/localFiles/workspace/LocalWorkspace.d.ts +0 -12
  33. package/package.json +4 -13
  34. package/dist/es/builtinTools/browserRuntime/BrowserCommandRunner.mjs +0 -201
  35. package/dist/es/builtinTools/browserRuntime/PythonRunner.mjs +0 -356
  36. package/dist/es/builtinTools/browserRuntime/WorkspaceBashFs.mjs +0 -350
  37. package/dist/es/builtinTools/browserRuntime/assets.mjs +0 -9
  38. package/dist/es/builtinTools/browserRuntime/loadBash.mjs +0 -17
  39. package/dist/es/builtinTools/browserRuntime/pyodideRunner.py.mjs +0 -96
  40. package/dist/es/builtinTools/browserRuntime/pyodideWorker.mjs +0 -242
  41. package/dist/es/builtinTools/command.mjs +0 -56
  42. package/dist/es/builtinTools/constants.mjs +0 -10
  43. package/dist/es/builtinTools/createBuiltinToolsPlugin.mjs +0 -236
  44. package/dist/es/builtinTools/overview.mjs +0 -77
  45. package/dist/es/builtinTools/paths.mjs +0 -63
  46. package/dist/es/builtinTools/schemas.mjs +0 -216
  47. package/dist/es/builtinTools/tools.mjs +0 -471
  48. package/dist/src/builtinTools/browserRuntime/BrowserCommandRunner.d.ts +0 -26
  49. package/dist/src/builtinTools/browserRuntime/PythonRunner.d.ts +0 -67
  50. package/dist/src/builtinTools/browserRuntime/WorkspaceBashFs.d.ts +0 -51
  51. package/dist/src/builtinTools/browserRuntime/assets.d.ts +0 -13
  52. package/dist/src/builtinTools/browserRuntime/loadBash.d.ts +0 -3
  53. package/dist/src/builtinTools/browserRuntime/pyodideWorker.d.ts +0 -44
  54. package/dist/src/builtinTools/command.d.ts +0 -26
  55. package/dist/src/builtinTools/constants.d.ts +0 -17
  56. package/dist/src/builtinTools/createBuiltinToolsPlugin.d.ts +0 -11
  57. package/dist/src/builtinTools/overview.d.ts +0 -5
  58. package/dist/src/builtinTools/paths.d.ts +0 -15
  59. package/dist/src/builtinTools/schemas.d.ts +0 -3
  60. package/dist/src/builtinTools/tools.d.ts +0 -60
@@ -1,21 +1,22 @@
1
- var R = Object.defineProperty, _ = Object.defineProperties;
2
- var B = Object.getOwnPropertyDescriptors;
3
- var P = Object.getOwnPropertySymbols;
4
- var w = Object.prototype.hasOwnProperty, O = Object.prototype.propertyIsEnumerable;
5
- var C = (e, n, i) => n in e ? R(e, n, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[n] = i, r = (e, n) => {
6
- for (var i in n || (n = {}))
7
- w.call(n, i) && C(e, i, n[i]);
8
- if (P)
9
- for (var i of P(n))
10
- O.call(n, i) && C(e, i, n[i]);
1
+ var O = Object.defineProperty, w = Object.defineProperties;
2
+ var k = Object.getOwnPropertyDescriptors;
3
+ var h = Object.getOwnPropertySymbols;
4
+ var F = Object.prototype.hasOwnProperty, N = Object.prototype.propertyIsEnumerable;
5
+ var a = (e, i, o) => i in e ? O(e, i, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[i] = o, c = (e, i) => {
6
+ for (var o in i || (i = {}))
7
+ F.call(i, o) && a(e, o, i[o]);
8
+ if (h)
9
+ for (var o of h(i))
10
+ N.call(i, o) && a(e, o, i[o]);
11
11
  return e;
12
- }, L = (e, n) => _(e, B(n));
13
- import g from "./Logger.mjs";
14
- import { LOCAL_FILES_PLUGIN_CODES as k, LOCAL_PYTHON_PLUGIN_CODES as E } from "./localFiles/constants.mjs";
15
- import { createBuiltinToolsPlugin as I } from "./builtinTools/createBuiltinToolsPlugin.mjs";
16
- const S = new g("[Config] ");
17
- var h = /* @__PURE__ */ ((e) => (e.dev = "https://aiot-dev.glodon.com/api/cvforcepd", e.test = "https://aiot-dev.glodon.com/api/cvforce", e.prod = "https://copilot.glodon.com/api/cvforce", e.local = "http://localhost:3000/api/cvforcepd", e))(h || {});
18
- let o = {
12
+ }, R = (e, i) => w(e, k(i));
13
+ import f from "./Logger.mjs";
14
+ import { LOCAL_PYTHON_FUNCTION_CODE as y, LOCAL_FILES_PLUGIN_CODES as A, LOCAL_PYTHON_PLUGIN_CODES as E } from "./localFiles/constants.mjs";
15
+ import { createLocalFilesPlugin as I } from "./localFiles/createLocalFilesPlugin.mjs";
16
+ import { createLocalPythonPlugin as $ } from "./localFiles/createLocalPythonPlugin.mjs";
17
+ const q = new f("[Config] ");
18
+ var _ = /* @__PURE__ */ ((e) => (e.dev = "https://aiot-dev.glodon.com/api/cvforcepd", e.test = "https://aiot-dev.glodon.com/api/cvforce", e.prod = "https://copilot.glodon.com/api/cvforce", e.local = "http://localhost:3000/api/cvforcepd", e))(_ || {});
19
+ let n = {
19
20
  debug: !1,
20
21
  env: "prod",
21
22
  //AIoT 环境, 与apiRoot配对使用
@@ -30,74 +31,95 @@ let o = {
30
31
  mcp: void 0,
31
32
  loadRelatedQuesions: !0,
32
33
  stream: !1
33
- }, u, l;
34
- const c = /* @__PURE__ */ new Set();
35
- function Q(e) {
36
- u !== e && (u = e, l = void 0, c.clear());
34
+ }, u, r, d;
35
+ const v = /* @__PURE__ */ new Set();
36
+ function T(e) {
37
+ u !== e && (u = e, r = void 0, d = void 0, v.clear());
37
38
  }
38
- function Y() {
39
- if (!l)
39
+ function j() {
40
+ if (!r)
40
41
  return;
41
42
  const {
42
43
  pluginCode: e,
43
- table: n
44
- } = l, i = o.plugins[e], t = n[e];
45
- if (!(!i || i.shell !== t.shell))
44
+ table: i
45
+ } = r, o = n.plugins[e], l = i[e];
46
+ if (!(!o || o.list_directory !== l.list_directory))
46
47
  return e;
47
48
  }
48
- function j() {
49
- if (!l)
49
+ function z() {
50
+ if (!d)
50
51
  return;
51
52
  const {
52
53
  pluginCode: e,
53
- table: n
54
- } = l, i = o.plugins[e], t = n[e];
55
- if (!(!i || i.run_file !== t.run_file))
54
+ table: i
55
+ } = d, o = n.plugins[e], l = i[e];
56
+ if (!(!o || o[y] !== l[y]))
56
57
  return e;
57
58
  }
58
- function T(e, n) {
59
- return (e == null ? void 0 : e.pluginCode) || k[n];
59
+ function S(e, i) {
60
+ return (e == null ? void 0 : e.pluginCode) || A[i];
60
61
  }
61
- function N(e, n, i) {
62
- return (e == null ? void 0 : e.pluginCode) || i || E[n];
62
+ function D(e, i, o) {
63
+ return (e == null ? void 0 : e.pluginCode) || o || E[i];
63
64
  }
64
- function D() {
65
- var v, b, p;
66
- const e = (v = o.businessPlugins) != null ? v : {}, n = (b = o.builtinPlugins) == null ? void 0 : b.localFiles, i = (p = o.builtinPlugins) == null ? void 0 : p.localPython, t = [], d = r({}, e);
67
- if (!!!(n != null && n.enabled || i != null && i.enabled))
68
- return o.plugins = d, t;
69
- if (!u)
70
- return t.push("[BuiltinTools] 内置工具依赖已启用的本地工作区。工具未注册。"), o.plugins = d, t;
71
- const f = n != null && n.enabled ? T(n, o.env) : void 0, s = f || (i != null && i.enabled ? N(i, o.env, f) : void 0);
72
- return s ? e[s] ? t.push(`[BuiltinTools] 业务插件中已存在 pluginCode「${s}」,已保留业务插件,内置工具未注册。`) : (((l == null ? void 0 : l.workspace) !== u || l.pluginCode !== s) && (l = {
65
+ function H() {
66
+ var P, C, b;
67
+ const e = (P = n.businessPlugins) != null ? P : {}, i = (C = n.builtinPlugins) == null ? void 0 : C.localFiles, o = (b = n.builtinPlugins) == null ? void 0 : b.localPython, l = [], g = c({}, e);
68
+ let s, p = !1;
69
+ if (i != null && i.enabled && u && (s = S(i, n.env), s ? e[s] ? l.push(`[LocalFiles] 业务插件中已存在 pluginCode「${s}」,已保留业务插件,内置文件工具未注册。`) : (((r == null ? void 0 : r.workspace) !== u || r.pluginCode !== s) && (r = {
73
70
  workspace: u,
74
71
  pluginCode: s,
75
72
  table: I({
76
73
  pluginCode: s,
77
74
  workspace: u
78
75
  })
79
- }), d[s] = l.table[s]) : t.push(`[BuiltinTools] 当前环境(env: ${o.env})没有默认的内置工具插件编码,请配置 builtinPlugins.localFiles.pluginCode。内置工具未注册。`), o.plugins = d, t;
76
+ }), g[s] = r.table[s], p = !0) : l.push(`[LocalFiles] 当前环境(env: ${n.env})没有默认的内置工具插件编码,请配置 builtinPlugins.localFiles.pluginCode。内置文件工具未注册。`)), o != null && o.enabled) {
77
+ const t = D(o, n.env, s);
78
+ if (!u)
79
+ l.push("[LocalPython] 运行脚本依赖已启用的本地工作区。内置脚本工具未注册。");
80
+ else if (!t)
81
+ l.push(`[LocalPython] 当前环境(env: ${n.env})没有默认的内置工具插件编码,请配置 builtinPlugins.localPython.pluginCode,或与文件工具使用同一个 pluginCode。内置脚本工具未注册。`);
82
+ else if (e[t])
83
+ l.push(`[LocalPython] pluginCode「${t}」已被业务插件占用,已保留业务插件,内置脚本工具未注册。`);
84
+ else if (g[t] && !(p && t === s))
85
+ l.push(`[LocalPython] pluginCode「${t}」已被占用,已保留原插件,内置脚本工具未注册。`);
86
+ else {
87
+ ((d == null ? void 0 : d.workspace) !== u || d.pluginCode !== t || d.approve !== o.onApprovalRequired) && (d = {
88
+ workspace: u,
89
+ pluginCode: t,
90
+ approve: o.onApprovalRequired,
91
+ table: $({
92
+ pluginCode: t,
93
+ workspace: u,
94
+ onApprovalRequired: o.onApprovalRequired
95
+ })
96
+ });
97
+ const L = d.table[t];
98
+ g[t] = p && t === s ? c(c({}, g[t]), L) : L;
99
+ }
100
+ }
101
+ return n.plugins = g, l;
80
102
  }
81
- function G() {
82
- return D().filter((e) => !c.has(e)).map((e) => (c.add(e), console.error(e), new Error(e)));
103
+ function B() {
104
+ return H().filter((e) => !v.has(e)).map((e) => (v.add(e), console.error(e), new Error(e)));
83
105
  }
84
- function q(e) {
85
- var n, i, t;
86
- g.debug = (e == null ? void 0 : e.debug) || !1, o = L(r(r({}, o), e), {
87
- apiRoot: (e == null ? void 0 : e.apiRoot) || o.apiRoot || (e != null && e.env ? h[e.env || "prod"] : o.apiRoot),
106
+ function J(e) {
107
+ var i, o, l;
108
+ f.debug = (e == null ? void 0 : e.debug) || !1, n = R(c(c({}, n), e), {
109
+ apiRoot: (e == null ? void 0 : e.apiRoot) || n.apiRoot || (e != null && e.env ? _[e.env || "prod"] : n.apiRoot),
88
110
  // 应用未注册插件时 param.plugins 为 undefined,避免覆盖默认空表
89
- businessPlugins: (i = (n = e == null ? void 0 : e.plugins) != null ? n : o.businessPlugins) != null ? i : {},
90
- builtinPlugins: (t = e == null ? void 0 : e.builtinPlugins) != null ? t : o.builtinPlugins
91
- }), G(), g.debug && S.log("updated", o);
111
+ businessPlugins: (o = (i = e == null ? void 0 : e.plugins) != null ? i : n.businessPlugins) != null ? o : {},
112
+ builtinPlugins: (l = e == null ? void 0 : e.builtinPlugins) != null ? l : n.builtinPlugins
113
+ }), B(), f.debug && q.log("updated", n);
92
114
  }
93
115
  export {
94
- h as ApiUrl,
95
- o as configuration,
96
- q as configure,
97
- Y as getRegisteredLocalFilesPluginCode,
98
- j as getRegisteredLocalPythonPluginCode,
99
- G as refreshBuiltinPlugins,
100
- T as resolveLocalFilesPluginCode,
101
- N as resolveLocalPythonPluginCode,
102
- Q as setActiveLocalWorkspace
116
+ _ as ApiUrl,
117
+ n as configuration,
118
+ J as configure,
119
+ j as getRegisteredLocalFilesPluginCode,
120
+ z as getRegisteredLocalPythonPluginCode,
121
+ B as refreshBuiltinPlugins,
122
+ S as resolveLocalFilesPluginCode,
123
+ D as resolveLocalPythonPluginCode,
124
+ T as setActiveLocalWorkspace
103
125
  };
@@ -11,7 +11,7 @@ var R = (l, c, s) => c in l ? I(l, c, { enumerable: !0, configurable: !0, writab
11
11
  return l;
12
12
  }, y = (l, c) => A(l, P(c));
13
13
  var M = (l, c, s) => (R(l, typeof c != "symbol" ? c + "" : c, s), s);
14
- var f = (l, c, s) => new Promise((a, d) => {
14
+ var f = (l, c, s) => new Promise((t, d) => {
15
15
  var h = (r) => {
16
16
  try {
17
17
  i(s.next(r));
@@ -24,7 +24,7 @@ var f = (l, c, s) => new Promise((a, d) => {
24
24
  } catch (m) {
25
25
  d(m);
26
26
  }
27
- }, i = (r) => r.done ? a(r.value) : Promise.resolve(r.value).then(h, e);
27
+ }, i = (r) => r.done ? t(r.value) : Promise.resolve(r.value).then(h, e);
28
28
  i((s = s.apply(l, c)).next());
29
29
  });
30
30
  import { IHistoryRole as C, PromptVariableType as v, ChatMessageRole as O } from "@glodon-aiot/apis";
@@ -35,8 +35,8 @@ import { configuration as S } from "./Config.mjs";
35
35
  import { fetchEventSource as T } from "./api/fetchEventSource/fetch.mjs";
36
36
  const p = new V("[DialogSession] ");
37
37
  class k extends $ {
38
- constructor(s, a = "", d, h, e, i) {
39
- super(s, a, d, h, e, i);
38
+ constructor(s, t = "", d, h, e, i) {
39
+ super(s, t, d, h, e, i);
40
40
  M(this, "ctrl", new AbortController());
41
41
  }
42
42
  prepareConnection() {
@@ -44,14 +44,14 @@ class k extends $ {
44
44
  this._ready = !0, this.event.emit("ready"), this.frozen = !1, s(!0);
45
45
  }));
46
46
  }
47
- postChatV2EventSource(s, a, d, h, e, i) {
47
+ postChatV2EventSource(s, t, d, h, e, i) {
48
48
  return f(this, null, function* () {
49
49
  const r = {
50
50
  code: 0,
51
51
  // messageId: uuidv4(),
52
52
  content: "",
53
53
  role: C.Robot,
54
- sessionId: a,
54
+ sessionId: t,
55
55
  reference: [],
56
56
  searchReference: [],
57
57
  messageTime: "",
@@ -63,7 +63,7 @@ class k extends $ {
63
63
  }, m = y(u({}, d), {
64
64
  stream: S.stream
65
65
  });
66
- T(`${S.apiRoot}/chat/v2/chat?applicationId=${s}&sessionId=${a}`, {
66
+ T(`${S.apiRoot}/chat/v2/chat?applicationId=${s}&sessionId=${t}`, {
67
67
  method: "POST",
68
68
  headers: {
69
69
  Authorization: `Bearer ${this.token}`,
@@ -77,19 +77,19 @@ class k extends $ {
77
77
  },
78
78
  onmessage(g) {
79
79
  if (!g.data.includes('{"code": ')) {
80
- let t = {};
80
+ let a = {};
81
81
  try {
82
- t = JSON.parse(g.data);
83
- } catch (J) {
82
+ a = JSON.parse(g.data);
83
+ } catch (E) {
84
84
  }
85
- (t == null ? void 0 : t.mtype) === "search" ? r.searchReference.push(t) : r.content = r.content + g.data;
85
+ (a == null ? void 0 : a.mtype) === "search" ? r.searchReference.push(a) : r.content = r.content + g.data;
86
86
  const o = {
87
87
  content: r.content,
88
88
  role: 1,
89
89
  reference: r.reference,
90
90
  searchReference: r.searchReference,
91
91
  messageId: r.messageId,
92
- sessionId: a,
92
+ sessionId: t,
93
93
  messageTime: _(/* @__PURE__ */ new Date()).format("YYYY-MM-DD HH:mm:ss"),
94
94
  comment: {
95
95
  isAgree: 0
@@ -100,18 +100,18 @@ class k extends $ {
100
100
  }
101
101
  const n = JSON.parse(g.data);
102
102
  if (r.reference = n.data.reference, r.searchReference = n.data.searchReference, r.messageTime = n.data.messageTime, r.messageId = n.data.messageId, r.llmModel = n.data.llmModel, r.content = n.data.content, r.code = n.code, n.code === 200) {
103
- const t = {
103
+ const a = {
104
104
  code: r.code,
105
105
  content: r.content,
106
106
  role: 1,
107
107
  reference: r.reference,
108
108
  searchReference: r.searchReference,
109
109
  messageId: r.messageId,
110
- sessionId: a,
110
+ sessionId: t,
111
111
  messageTime: r.messageTime,
112
112
  isReplying: !0
113
113
  };
114
- e != null && e.onmessage && e.onmessage(t);
114
+ e != null && e.onmessage && e.onmessage(a);
115
115
  } else
116
116
  return e != null && e.onclose && e.onclose(r), i && i({
117
117
  code: r.code,
@@ -129,7 +129,7 @@ class k extends $ {
129
129
  reference: r.reference,
130
130
  searchReference: r.searchReference,
131
131
  messageId: r.messageId,
132
- sessionId: a,
132
+ sessionId: t,
133
133
  messageTime: r.messageTime,
134
134
  comment: {
135
135
  isAgree: 0
@@ -142,14 +142,14 @@ class k extends $ {
142
142
  });
143
143
  });
144
144
  }
145
- postChatV3EventSource(s, a, d, h, e, i) {
145
+ postChatV3EventSource(s, t, d, h, e, i) {
146
146
  return f(this, null, function* () {
147
147
  const r = this, m = {
148
148
  code: 0,
149
149
  // messageId: uuidv4(),
150
150
  content: "",
151
151
  role: C.Robot,
152
- sessionId: a,
152
+ sessionId: t,
153
153
  reference: [],
154
154
  searchReference: [],
155
155
  messageTime: "",
@@ -165,7 +165,7 @@ class k extends $ {
165
165
  }, g = y(u({}, d), {
166
166
  stream: S.stream
167
167
  });
168
- T(`${S.apiRoot}/chat/v3/chat?applicationId=${s}&sessionId=${a}`, {
168
+ T(`${S.apiRoot}/chat/v3/chat?applicationId=${s}&sessionId=${t}`, {
169
169
  method: "POST",
170
170
  headers: {
171
171
  Authorization: `Bearer ${this.token}`,
@@ -180,18 +180,18 @@ class k extends $ {
180
180
  onmessage(n) {
181
181
  if (!n.data && !n.event && !n.id && !n.retry)
182
182
  return;
183
- let t = {};
183
+ let a = {};
184
184
  try {
185
- t = JSON.parse(n.data);
185
+ a = JSON.parse(n.data);
186
186
  } catch (o) {
187
187
  console.error("parse eventData to JSON failed. ", n.data);
188
188
  }
189
- if (t.code !== 200)
190
- return m.index = -1, m.code = t.code, m.message = t.message, e != null && e.onmessage && e.onmessage(m), i && i({
191
- code: t.code,
192
- message: t.message
189
+ if (a.code !== 200)
190
+ return m.index = -1, m.code = a.code, m.message = a.message, e != null && e.onmessage && e.onmessage(m), i && i({
191
+ code: a.code,
192
+ message: a.message
193
193
  });
194
- r.handleStreamAnswer(t, m), e != null && e.onmessage && e.onmessage(m);
194
+ r.handleStreamAnswer(a, m), e != null && e.onmessage && e.onmessage(m);
195
195
  },
196
196
  onerror() {
197
197
  e != null && e.onerror && e.onerror();
@@ -205,7 +205,7 @@ class k extends $ {
205
205
  });
206
206
  });
207
207
  }
208
- sendQuestion(s, a) {
208
+ sendQuestion(s, t) {
209
209
  return f(this, null, function* () {
210
210
  const {
211
211
  content: d,
@@ -215,7 +215,7 @@ class k extends $ {
215
215
  } = s, {
216
216
  stream: r,
217
217
  referenceFirst: m
218
- } = a;
218
+ } = t;
219
219
  if (this.active || (yield this.activate()), this._id) {
220
220
  const g = this.convertKnowledgesToChatFormat(this.knowledges);
221
221
  let n = {
@@ -223,29 +223,28 @@ class k extends $ {
223
223
  fileIds: h,
224
224
  referenceFirst: m,
225
225
  oldMessageId: e,
226
- promptVariables: this.promptVariables.filter((t) => t.type === v.User).reduce((t, o) => y(u({}, t), {
226
+ promptVariables: this.promptVariables.filter((a) => a.type === v.User).reduce((a, o) => y(u({}, a), {
227
227
  [o.key]: o.value
228
228
  }), {}),
229
- systemPromptVariables: this.promptVariables.filter((t) => t.type === v.System).reduce((t, o) => y(u({}, t), {
229
+ systemPromptVariables: this.promptVariables.filter((a) => a.type === v.System).reduce((a, o) => y(u({}, a), {
230
230
  [o.key]: o.value
231
231
  }), {}),
232
232
  knowledges: g,
233
- //开启内容摘要
234
- enableTitleSummary: !0,
233
+ enableTitleSummary: this.resolveEnableTitleSummary(),
235
234
  imageContent: i
236
235
  };
237
236
  this.ctrl = new AbortController(), this.postChatV3EventSource(this._applicationId, this._id, n, this.ctrl.signal, {
238
237
  onopen: () => {
239
238
  p.log("open", this.ctrl);
240
239
  },
241
- onmessage: (t) => {
240
+ onmessage: (a) => {
242
241
  if (this._stopAnswer)
243
242
  return;
244
243
  let o = this.messages[this.messages.length - 1];
245
- o && o.role === O.Robot ? (o = u(u({}, o), t), this.messages[this.messages.length - 1] = o, this.event.emit("message:content", o), this.event.emit("message:updated", o)) : (this.pushMessage(t), this.event.emit("message:content", t));
244
+ o && o.role === O.Robot ? (o = u(u({}, o), a), this.messages[this.messages.length - 1] = o, this.event.emit("message:content", o), this.event.emit("message:updated", o)) : (this.pushMessage(a), this.event.emit("message:content", a));
246
245
  },
247
- onclose: (t) => f(this, null, function* () {
248
- this._stopAnswer || (p.log(t, "onclose"), this.event.emit("answer:finish", t));
246
+ onclose: (a) => f(this, null, function* () {
247
+ this._stopAnswer || (p.log(a, "onclose"), this.event.emit("answer:finish", a));
249
248
  }),
250
249
  onerror: () => {
251
250
  this._stopAnswer || (this.event.emit("message:error", ""), this.frozen = !1);
@@ -273,10 +272,10 @@ class k extends $ {
273
272
  });
274
273
  }
275
274
  convertKnowledgesToChatFormat(s) {
276
- return s ? s.map((a) => a != null && a.fileIds ? {
277
- id: a.id,
278
- fileIds: a.fileIds
279
- } : a.id) : [];
275
+ return s ? s.map((t) => t != null && t.fileIds ? {
276
+ id: t.id,
277
+ fileIds: t.fileIds
278
+ } : t.id) : [];
280
279
  }
281
280
  }
282
281
  export {