@glodon-aiot/bot-client-sdk 3.26.0-alpha.31 → 3.26.0-alpha.33
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/README.md +3 -8
- package/dist/es/AgentSession.mjs +63 -59
- package/dist/es/BotClient.mjs +32 -31
- package/dist/es/localMcp/client.mjs +101 -90
- package/dist/es/localMcp/endpoints.mjs +94 -0
- package/dist/es/localMcp/register.mjs +149 -97
- package/dist/es/localMcp/registry.mjs +22 -18
- package/dist/es/package.json.mjs +2 -2
- package/dist/lib/index.js +45 -45
- package/dist/src/AgentSession.d.ts +1 -0
- package/dist/src/localMcp/client.d.ts +4 -0
- package/dist/src/localMcp/endpoints.d.ts +19 -0
- package/dist/src/localMcp/register.d.ts +2 -0
- package/dist/src/localMcp/registry.d.ts +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -8,11 +8,9 @@ AIoT 应用客户端 SDK,支持 Agent 与对话型应用。会话、消息、
|
|
|
8
8
|
| --- | --- |
|
|
9
9
|
| 只接对话 UI | [快速开始](#快速开始) → [对话界面](#对话界面) → [产出物](#产出物) |
|
|
10
10
|
| 浏览器里读本地文件夹 / 跑命令 | 上栏 + [Agent 插件](#agent-插件) → [本地工作文件夹](#本地工作文件夹) → [命令和脚本](#命令和脚本) |
|
|
11
|
-
| 端侧宿主(桌面内嵌页 + 沙箱) | [宿主通道](#宿主通道)
|
|
11
|
+
| 端侧宿主(桌面内嵌页 + 沙箱) | [宿主通道](#宿主通道);沙箱协议与策略见 npm 包 `@glodon-aiot/workspace-sandbox` |
|
|
12
12
|
| 查工具参数 / 错误码 / 限额 | [内置工具参考](#内置工具参考) · [安全与限额](#安全与限额) · [错误码](#错误码) |
|
|
13
13
|
|
|
14
|
-
集成方总览:[`bot-client-ui/docs/agent-integration-handbook.md`](../bot-client-ui/docs/agent-integration-handbook.md)。Windows 宿主步骤:[`local-workspace-windows-host.md`](../bot-client-ui/docs/local-workspace-windows-host.md)。
|
|
15
|
-
|
|
16
14
|
| 能力 | 适用应用 | 运行环境 | 见 |
|
|
17
15
|
| --- | --- | --- | --- |
|
|
18
16
|
| 会话与流式对话 | Agent、对话型 | 浏览器、端侧宿主 | [对话界面](#对话界面) |
|
|
@@ -490,8 +488,6 @@ function openApprovalDialog(request: ApprovalRequest): Promise<boolean> {
|
|
|
490
488
|
|
|
491
489
|
宿主已授权但沙箱未就绪时**不**降级。`starting` = 启动中;失败看 `sandbox.message`。协议非 1 另发 `error`。收到 `bye` / `exited` / `failed` 后在途调用以 `AbortError` 失败且不重放;等新的 `ready` 再用新地址与令牌。
|
|
492
490
|
|
|
493
|
-
参照宿主:`examples/qt-workspace-host`。
|
|
494
|
-
|
|
495
491
|
### 浏览器运行时
|
|
496
492
|
|
|
497
493
|
| 能力 | 行为 |
|
|
@@ -512,7 +508,7 @@ CSP:放行 OBS 的 `script-src` / `connect-src`;Pyodide 需 `worker-src blob
|
|
|
512
508
|
|
|
513
509
|
### 宿主沙箱(摘要)
|
|
514
510
|
|
|
515
|
-
完整协议、策略 JSON、平台隔离差异见
|
|
511
|
+
完整协议、策略 JSON、平台隔离差异见 npm 包 `@glodon-aiot/workspace-sandbox`。此处只列页面侧要点:
|
|
516
512
|
|
|
517
513
|
- 启动:`workspace-sandbox --listen --root <工程> --origin <页面来源>`;联网 / pip / 并发由 `--policy` 定,页面不能改
|
|
518
514
|
- 宿主职责:启停、读 ready、可选 status / policy、shutdown(3 秒后杀进程组)、把退出告诉页面;**不中转**文件与命令
|
|
@@ -522,7 +518,6 @@ CSP:放行 OBS 的 `script-src` / `connect-src`;Pyodide 需 `worker-src blob
|
|
|
522
518
|
- 默认断网;`allowlist` 拒绝项写在 `stderr`;允许时 `pip install` 直装工程 venv,不必先改 `open`
|
|
523
519
|
- 平台技能:进会话按编排核对版本;页面用 `client.token` 下载 ZIP,经已认证 WS 调 `installSkill`(沙箱收不到令牌)。缓存在用户目录,不在工程内
|
|
524
520
|
- 分发:`Resources/node/`(Node 24)+ `Resources/workspace-sandbox/`;可选 `python/`
|
|
525
|
-
- Windows 细节:[`local-workspace-windows-host.md`](../bot-client-ui/docs/local-workspace-windows-host.md)
|
|
526
521
|
|
|
527
522
|
## 宿主通道
|
|
528
523
|
|
|
@@ -572,7 +567,7 @@ CSP:放行 OBS 的 `script-src` / `connect-src`;Pyodide 需 `worker-src blob
|
|
|
572
567
|
|
|
573
568
|
脚本跑完、用户在资源管理器改文件都应推送。Qt 示例默不监视 `.git` / `node_modules` / `__pycache__` 内部。
|
|
574
569
|
|
|
575
|
-
数据面:页面连沙箱后发协议 1
|
|
570
|
+
数据面:页面连沙箱后发协议 1 帧(细节见 `@glodon-aiot/workspace-sandbox`)。取消只发 `{ "op": "cancel", "id" }`,不关套接字。`bye` / `exited` / `failed` 后在途失败且不重放。
|
|
576
571
|
|
|
577
572
|
## 安全与限额
|
|
578
573
|
|
package/dist/es/AgentSession.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var U = Object.defineProperty, x = Object.defineProperties;
|
|
2
|
+
var q = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var P = Object.getOwnPropertySymbols;
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var j = Object.prototype.hasOwnProperty, F = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var R = (o, c, e) => c in o ? U(o, c, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[c] = e, h = (o, c) => {
|
|
6
6
|
for (var e in c || (c = {}))
|
|
7
|
-
|
|
7
|
+
j.call(c, e) && R(o, e, c[e]);
|
|
8
8
|
if (P)
|
|
9
9
|
for (var e of P(c))
|
|
10
|
-
|
|
10
|
+
F.call(c, e) && R(o, e, c[e]);
|
|
11
11
|
return o;
|
|
12
|
-
},
|
|
13
|
-
var
|
|
12
|
+
}, C = (o, c) => x(o, q(c));
|
|
13
|
+
var k = (o, c, e) => (R(o, typeof c != "symbol" ? c + "" : c, e), e);
|
|
14
14
|
var y = (o, c, e) => new Promise((r, a) => {
|
|
15
15
|
var n = (i) => {
|
|
16
16
|
try {
|
|
@@ -27,16 +27,17 @@ var y = (o, c, e) => new Promise((r, a) => {
|
|
|
27
27
|
}, s = (i) => i.done ? r(i.value) : Promise.resolve(i.value).then(n, t);
|
|
28
28
|
s((e = e.apply(o, c)).next());
|
|
29
29
|
});
|
|
30
|
-
import { ChatMessageRole as
|
|
31
|
-
import
|
|
32
|
-
import { configuration as
|
|
33
|
-
import { io as
|
|
34
|
-
import { UserMode as
|
|
30
|
+
import { ChatMessageRole as M, PromptVariableType as A } from "@glodon-aiot/apis";
|
|
31
|
+
import N from "./Logger.mjs";
|
|
32
|
+
import { configuration as p } from "./Config.mjs";
|
|
33
|
+
import { io as O } from "socket.io-client";
|
|
34
|
+
import { UserMode as w } from "./PayloadTypes.mjs";
|
|
35
35
|
import D, { SessionErrors as I } from "./Session.mjs";
|
|
36
36
|
import V from "dayjs";
|
|
37
|
-
import { v4 as
|
|
38
|
-
import {
|
|
39
|
-
|
|
37
|
+
import { v4 as B } from "uuid";
|
|
38
|
+
import { connectLocalMcpBridge as J, subscribeLocalMcpEndpoints as Y } from "./localMcp/endpoints.mjs";
|
|
39
|
+
import { registerLocalMcp as $ } from "./localMcp/register.mjs";
|
|
40
|
+
const m = new N("[AgentSession] ");
|
|
40
41
|
function _(o) {
|
|
41
42
|
if (typeof o != "string")
|
|
42
43
|
return o;
|
|
@@ -48,33 +49,34 @@ function _(o) {
|
|
|
48
49
|
return o;
|
|
49
50
|
}
|
|
50
51
|
}
|
|
51
|
-
function
|
|
52
|
+
function L(o) {
|
|
52
53
|
return o == null || o === "" || typeof o == "object" && !Array.isArray(o) && Object.keys(o).length === 0;
|
|
53
54
|
}
|
|
54
|
-
function
|
|
55
|
+
function z(o, c) {
|
|
55
56
|
const e = _(o == null ? void 0 : o.query);
|
|
56
|
-
if (!
|
|
57
|
+
if (!L(e))
|
|
57
58
|
return e;
|
|
58
59
|
const r = _(c);
|
|
59
|
-
return
|
|
60
|
+
return L(r) && e != null ? e : r;
|
|
60
61
|
}
|
|
61
|
-
class
|
|
62
|
+
class ne extends D {
|
|
62
63
|
constructor(e, r = "", a, n, t, s) {
|
|
63
64
|
super(e, r, a, n, t, s);
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
k(this, "inflightCalls", /* @__PURE__ */ new Set());
|
|
66
|
+
k(this, "localMcpTicket", 0);
|
|
67
|
+
k(this, "stopLocalMcpUpdates");
|
|
66
68
|
}
|
|
67
69
|
prepareConnection() {
|
|
68
70
|
return new Promise((e) => y(this, null, function* () {
|
|
69
71
|
this.socket && e(!0);
|
|
70
72
|
const r = {
|
|
71
73
|
version: "1.0",
|
|
72
|
-
stream: JSON.stringify(
|
|
74
|
+
stream: JSON.stringify(p.stream),
|
|
73
75
|
appId: this._applicationId,
|
|
74
76
|
sessionId: this.id,
|
|
75
77
|
Authorization: `${this.token}`,
|
|
76
|
-
userMode:
|
|
77
|
-
}, a = new URL(
|
|
78
|
+
userMode: p.debug ? w.Debug : w.Normal
|
|
79
|
+
}, a = new URL(p.apiRoot), n = yield O(a.origin, {
|
|
78
80
|
path: a.pathname.replace("api", "socketio") + "/copilot",
|
|
79
81
|
query: r,
|
|
80
82
|
transports: ["websocket"]
|
|
@@ -86,8 +88,8 @@ class se extends D {
|
|
|
86
88
|
}), n.on("ready", (t) => {
|
|
87
89
|
if (t.code === 200) {
|
|
88
90
|
m.log("ready");
|
|
89
|
-
const s =
|
|
90
|
-
s ===
|
|
91
|
+
const s = p.debug ? w.Debug : w.Normal;
|
|
92
|
+
s === w.Debug && t.userMode, this._ready || (this._ready = !0, this.event.emit("ready")), this.frozen = !1, this.registerMcpFromClientConfig(), this.registerLocalMcp(), e(!0);
|
|
91
93
|
} else {
|
|
92
94
|
this._ready && (this._ready = !1);
|
|
93
95
|
const s = new Error(
|
|
@@ -99,7 +101,7 @@ class se extends D {
|
|
|
99
101
|
m.error("error", s), this.event.emit("error", s), e(!1);
|
|
100
102
|
}
|
|
101
103
|
}), n.on("action", (t, s) => y(this, null, function* () {
|
|
102
|
-
var
|
|
104
|
+
var b;
|
|
103
105
|
if (this._stopAnswer || !this.id)
|
|
104
106
|
return;
|
|
105
107
|
const {
|
|
@@ -111,17 +113,17 @@ class se extends D {
|
|
|
111
113
|
parameters: f,
|
|
112
114
|
requestBody: E
|
|
113
115
|
}
|
|
114
|
-
} = t,
|
|
115
|
-
if (!
|
|
116
|
-
|
|
117
|
-
messageId:
|
|
116
|
+
} = t, u = this.messages[this.messages.length - 1];
|
|
117
|
+
if (!u.messageId)
|
|
118
|
+
u.actions || (u.actions = []), u.actions[t.data.step - 1] || (u.actions[t.data.step - 1] = []), u.actions[t.data.step - 1].push(t), this.event.emit("message:action", {
|
|
119
|
+
messageId: u.messageId,
|
|
118
120
|
action: t
|
|
119
|
-
}), this.event.emit("message:updated",
|
|
121
|
+
}), this.event.emit("message:updated", u);
|
|
120
122
|
else {
|
|
121
123
|
const v = {
|
|
122
124
|
messageId: "",
|
|
123
125
|
content: "",
|
|
124
|
-
role:
|
|
126
|
+
role: M.Robot,
|
|
125
127
|
sessionId: this.id,
|
|
126
128
|
reference: [],
|
|
127
129
|
searchReference: [],
|
|
@@ -153,7 +155,7 @@ class se extends D {
|
|
|
153
155
|
} else if (i === "FUNCTION_CALL" && l) {
|
|
154
156
|
m.log(`calling function ${g} of plugin ${d} with argument:
|
|
155
157
|
${JSON.stringify(f)}`);
|
|
156
|
-
const v = (
|
|
158
|
+
const v = (b = p.plugins) == null ? void 0 : b[d];
|
|
157
159
|
if (!v) {
|
|
158
160
|
s({
|
|
159
161
|
code: 404,
|
|
@@ -161,16 +163,16 @@ class se extends D {
|
|
|
161
163
|
});
|
|
162
164
|
return;
|
|
163
165
|
}
|
|
164
|
-
const
|
|
165
|
-
if (typeof
|
|
166
|
+
const S = v[g];
|
|
167
|
+
if (typeof S != "function") {
|
|
166
168
|
s({
|
|
167
169
|
code: 404,
|
|
168
170
|
message: "没有找到插件方法。"
|
|
169
171
|
});
|
|
170
172
|
return;
|
|
171
173
|
}
|
|
172
|
-
const
|
|
173
|
-
this.invokeClientPlugin(
|
|
174
|
+
const T = z(f, E);
|
|
175
|
+
this.invokeClientPlugin(S, T, s, {
|
|
174
176
|
requestId: t.requestId,
|
|
175
177
|
pluginCode: d,
|
|
176
178
|
functionCode: g
|
|
@@ -180,12 +182,12 @@ class se extends D {
|
|
|
180
182
|
if (!this._stopAnswer)
|
|
181
183
|
if (t.data.code !== 200 && (t.data.index = -1), t.data.stream || t.data.stream === void 0) {
|
|
182
184
|
let s = this.messages[this.messages.length - 1];
|
|
183
|
-
if (s && s.role ===
|
|
185
|
+
if (s && s.role === M.Robot)
|
|
184
186
|
this.handleStreamAnswer(t.data, s), this.messages[this.messages.length - 1] = s, this.event.emit("message:content", s), this.event.emit("message:updated", s), s.index === -1 && (s.isReplying = !1, this.event.emit("answer:finish", s));
|
|
185
187
|
else {
|
|
186
188
|
const i = {
|
|
187
189
|
content: "",
|
|
188
|
-
role:
|
|
190
|
+
role: M.Robot,
|
|
189
191
|
reference: [],
|
|
190
192
|
searchReference: [],
|
|
191
193
|
messageId: "",
|
|
@@ -215,7 +217,7 @@ class se extends D {
|
|
|
215
217
|
const i = h({
|
|
216
218
|
messageId: "",
|
|
217
219
|
content: "",
|
|
218
|
-
role:
|
|
220
|
+
role: M.Robot,
|
|
219
221
|
sessionId: this.id,
|
|
220
222
|
reference: [],
|
|
221
223
|
searchReference: [],
|
|
@@ -234,7 +236,7 @@ class se extends D {
|
|
|
234
236
|
s && !s.messageId ? (s = h(h({}, s), t.data), this.messages[this.messages.length - 1] = s, this.event.emit("message:content", s), this.event.emit("message:updated", s)) : (this.pushMessage(h({
|
|
235
237
|
messageId: "",
|
|
236
238
|
content: "",
|
|
237
|
-
role:
|
|
239
|
+
role: M.Robot,
|
|
238
240
|
sessionId: this.id,
|
|
239
241
|
reference: [],
|
|
240
242
|
searchReference: [],
|
|
@@ -264,7 +266,7 @@ class se extends D {
|
|
|
264
266
|
type: s,
|
|
265
267
|
data: i,
|
|
266
268
|
requestId: l
|
|
267
|
-
} = t, d = this.messages.findIndex((f) => f.messageId === l && f.role ===
|
|
269
|
+
} = t, d = this.messages.findIndex((f) => f.messageId === l && f.role === M.User);
|
|
268
270
|
if (d < 0)
|
|
269
271
|
return;
|
|
270
272
|
const g = d + 1;
|
|
@@ -272,7 +274,7 @@ class se extends D {
|
|
|
272
274
|
const f = {
|
|
273
275
|
messageId: "",
|
|
274
276
|
content: "",
|
|
275
|
-
role:
|
|
277
|
+
role: M.Robot,
|
|
276
278
|
sessionId: this.id,
|
|
277
279
|
reference: [],
|
|
278
280
|
searchReference: [],
|
|
@@ -286,21 +288,21 @@ class se extends D {
|
|
|
286
288
|
};
|
|
287
289
|
this.pushMessage(f);
|
|
288
290
|
}
|
|
289
|
-
s === "KG" ? (this.messages[g] =
|
|
291
|
+
s === "KG" ? (this.messages[g] = C(h({}, this.messages[g]), {
|
|
290
292
|
reference: i.knowledgeReference
|
|
291
|
-
}), yield this.fillMessageReference(this.messages[g]), this.event.emit("message:reference", i.knowledgeReference), this.event.emit("message:updated", this.messages[g])) : s === "WEB_SEARCH" && (this.messages[g] =
|
|
293
|
+
}), yield this.fillMessageReference(this.messages[g]), this.event.emit("message:reference", i.knowledgeReference), this.event.emit("message:updated", this.messages[g])) : s === "WEB_SEARCH" && (this.messages[g] = C(h({}, this.messages[g]), {
|
|
292
294
|
searchReference: i.knowledgeReference
|
|
293
295
|
}), this.event.emit("message:searchreference", i.searchReference), this.event.emit("message:updated", this.messages[g]));
|
|
294
296
|
})), this.socket = n, n.open();
|
|
295
297
|
}));
|
|
296
298
|
}
|
|
297
299
|
registerMcpFromClientConfig() {
|
|
298
|
-
return
|
|
300
|
+
return p.mcp ? new Promise((e, r) => {
|
|
299
301
|
if (!this.socket) {
|
|
300
302
|
r("socket is undefined");
|
|
301
303
|
return;
|
|
302
304
|
}
|
|
303
|
-
this.socket.emit("add_mcp_servers",
|
|
305
|
+
this.socket.emit("add_mcp_servers", p.mcp, (a) => {
|
|
304
306
|
a.code === 200 ? (Object.keys(a.data).forEach((n) => {
|
|
305
307
|
a.data[n].code !== 200 && console.error(n, "MCP Server 注册失败。", a.data[n]);
|
|
306
308
|
}), e(!0)) : (console.error("MCP Server 注册失败。", a), r(a));
|
|
@@ -312,11 +314,12 @@ class se extends D {
|
|
|
312
314
|
const e = this.socket;
|
|
313
315
|
if (!e)
|
|
314
316
|
return;
|
|
317
|
+
J(), this.stopLocalMcpUpdates || (this.stopLocalMcpUpdates = Y(() => this.registerLocalMcp()));
|
|
315
318
|
const r = ++this.localMcpTicket;
|
|
316
|
-
|
|
319
|
+
$({
|
|
317
320
|
arrange: (n = (a = this.application) == null ? void 0 : a.arrange) == null ? void 0 : n[0],
|
|
318
|
-
initMcp:
|
|
319
|
-
apiRoot:
|
|
321
|
+
initMcp: p.mcp,
|
|
322
|
+
apiRoot: p.apiRoot,
|
|
320
323
|
token: this.token,
|
|
321
324
|
socket: e,
|
|
322
325
|
isCurrent: () => r === this.localMcpTicket
|
|
@@ -348,11 +351,11 @@ class se extends D {
|
|
|
348
351
|
return y(this, null, function* () {
|
|
349
352
|
var n, t, s;
|
|
350
353
|
this.convertKnowledgesToChatFormat(this.knowledges);
|
|
351
|
-
let a =
|
|
352
|
-
promptVariables: this.promptVariables.filter((i) => i.type === A.User).reduce((i, l) =>
|
|
354
|
+
let a = C(h({}, e), {
|
|
355
|
+
promptVariables: this.promptVariables.filter((i) => i.type === A.User).reduce((i, l) => C(h({}, i), {
|
|
353
356
|
[l.key]: l.value
|
|
354
357
|
}), {}),
|
|
355
|
-
systemPromptVariables: this.promptVariables.filter((i) => i.type === A.System).reduce((i, l) =>
|
|
358
|
+
systemPromptVariables: this.promptVariables.filter((i) => i.type === A.System).reduce((i, l) => C(h({}, i), {
|
|
356
359
|
[l.key]: l.value
|
|
357
360
|
}), {}),
|
|
358
361
|
knowledges: (n = this.knowledges) == null ? void 0 : n.map((i) => i.id),
|
|
@@ -387,7 +390,7 @@ class se extends D {
|
|
|
387
390
|
const i = (...d) => {
|
|
388
391
|
s || (s = !0, this.inflightCalls.delete(t), !(this._stopAnswer || t.signal.aborted) && a(...d));
|
|
389
392
|
}, l = {
|
|
390
|
-
requestId: n.requestId ||
|
|
393
|
+
requestId: n.requestId || B(),
|
|
391
394
|
applicationId: this._applicationId,
|
|
392
395
|
sessionId: this.id,
|
|
393
396
|
pluginCode: n.pluginCode,
|
|
@@ -421,7 +424,8 @@ class se extends D {
|
|
|
421
424
|
return this.abortClientPluginCalls(), super.inactivate(e);
|
|
422
425
|
}
|
|
423
426
|
destroy() {
|
|
424
|
-
|
|
427
|
+
var e;
|
|
428
|
+
return (e = this.stopLocalMcpUpdates) == null || e.call(this), this.stopLocalMcpUpdates = void 0, this.abortClientPluginCalls(), super.destroy();
|
|
425
429
|
}
|
|
426
430
|
convertKnowledgesToChatFormat(e) {
|
|
427
431
|
return e ? e.map((r) => r != null && r.fileIds ? {
|
|
@@ -431,5 +435,5 @@ class se extends D {
|
|
|
431
435
|
}
|
|
432
436
|
}
|
|
433
437
|
export {
|
|
434
|
-
|
|
438
|
+
ne as default
|
|
435
439
|
};
|
package/dist/es/BotClient.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
var x = Object.defineProperty, b = Object.defineProperties;
|
|
2
2
|
var R = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var v = Object.getOwnPropertySymbols;
|
|
4
|
-
var
|
|
4
|
+
var L = Object.prototype.hasOwnProperty, E = Object.prototype.propertyIsEnumerable;
|
|
5
5
|
var m = (h, i, e) => i in h ? x(h, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : h[i] = e, _ = (h, i) => {
|
|
6
6
|
for (var e in i || (i = {}))
|
|
7
|
-
|
|
7
|
+
L.call(i, e) && m(h, e, i[e]);
|
|
8
8
|
if (v)
|
|
9
9
|
for (var e of v(i))
|
|
10
|
-
|
|
10
|
+
E.call(i, e) && m(h, e, i[e]);
|
|
11
11
|
return h;
|
|
12
|
-
},
|
|
12
|
+
}, g = (h, i) => b(h, R(i));
|
|
13
13
|
var l = (h, i, e) => (m(h, typeof i != "symbol" ? i + "" : i, e), e);
|
|
14
14
|
var p = (h, i, e) => new Promise((t, o) => {
|
|
15
15
|
var n = (a) => {
|
|
@@ -31,25 +31,26 @@ import { parseJWT as y } from "./utils.mjs";
|
|
|
31
31
|
import W from "./Logger.mjs";
|
|
32
32
|
import { getAIShopService as M, getCVForceService as T } from "./api/index.mjs";
|
|
33
33
|
import { configure as k, configuration as f, setActiveLocalWorkspace as S, refreshBuiltinPlugins as w } from "./Config.mjs";
|
|
34
|
-
import { PlatformSkillSync as
|
|
35
|
-
import { HostBridgeAdapter as
|
|
34
|
+
import { PlatformSkillSync as B } from "./builtinTools/platformSkills.mjs";
|
|
35
|
+
import { HostBridgeAdapter as C } from "./localFiles/adapters/HostBridgeAdapter.mjs";
|
|
36
36
|
import { connectHostBridge as V } from "./localFiles/host/connectHostBridge.mjs";
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
import
|
|
42
|
-
import F from "./
|
|
43
|
-
import j from "./
|
|
44
|
-
import Q from "./
|
|
37
|
+
import { connectLocalMcpBridge as O } from "./localMcp/endpoints.mjs";
|
|
38
|
+
import { LocalWorkspace as H } from "./localFiles/workspace/LocalWorkspace.mjs";
|
|
39
|
+
import { createIndexedDbStore as P } from "./localFiles/workspace/handleStore.mjs";
|
|
40
|
+
import { createDefaultSessionFileTransfer as D } from "./localFiles/transfer/SessionFileTransfer.mjs";
|
|
41
|
+
import { ApplicationTypes as u, PromptVariableType as A } from "@glodon-aiot/apis";
|
|
42
|
+
import F from "./AgentSession.mjs";
|
|
43
|
+
import j from "./DialogSession.mjs";
|
|
44
|
+
import Q from "./EventBus.mjs";
|
|
45
|
+
import z from "./package.json.mjs";
|
|
45
46
|
const I = new W("[BotClient] ");
|
|
46
|
-
class
|
|
47
|
+
class ri {
|
|
47
48
|
constructor(i, e, t = !0, o = {
|
|
48
49
|
analytics: {
|
|
49
50
|
enabled: !1
|
|
50
51
|
}
|
|
51
52
|
}) {
|
|
52
|
-
l(this, "event", new
|
|
53
|
+
l(this, "event", new Q());
|
|
53
54
|
l(this, "cvforceApi");
|
|
54
55
|
//从token解析出来的用户信息
|
|
55
56
|
l(this, "_applicationId");
|
|
@@ -68,9 +69,9 @@ class ni {
|
|
|
68
69
|
refreshBuiltinPlugins: !1
|
|
69
70
|
}), this._applicationId = y(i).rid || f.applicationId, !this._applicationId)
|
|
70
71
|
throw "token is not vaild";
|
|
71
|
-
this.cvforceApi = this.getService(), this.setupLocalWorkspace(), this.loadApplication().then((n) => {
|
|
72
|
-
k(
|
|
73
|
-
stream: e.stream === void 0 ? (n == null ? void 0 : n.type) ===
|
|
72
|
+
this.cvforceApi = this.getService(), O(), this.setupLocalWorkspace(), this.loadApplication().then((n) => {
|
|
73
|
+
k(g(_({}, e), {
|
|
74
|
+
stream: e.stream === void 0 ? (n == null ? void 0 : n.type) === u.Dialog || (n == null ? void 0 : n.type) === u.Agent : e.stream
|
|
74
75
|
})), this.event.emit("ready");
|
|
75
76
|
});
|
|
76
77
|
}
|
|
@@ -86,13 +87,13 @@ class ni {
|
|
|
86
87
|
e.push(new Error(`[LocalFiles] 不支持的 backend:${i.backend}`));
|
|
87
88
|
else {
|
|
88
89
|
const r = M(f.apiRoot, this.token, (s, a) => I.error(a));
|
|
89
|
-
this._localWorkspace = new
|
|
90
|
+
this._localWorkspace = new H({
|
|
90
91
|
applicationId: this._applicationId,
|
|
91
92
|
config: i,
|
|
92
|
-
store:
|
|
93
|
+
store: P(),
|
|
93
94
|
picker: t === "host-bridge" ? null : void 0,
|
|
94
|
-
transfer:
|
|
95
|
-
}), S(this._localWorkspace), this._localWorkspace.platformSkills = new
|
|
95
|
+
transfer: D(() => this.cvforceApi, () => r)
|
|
96
|
+
}), S(this._localWorkspace), this._localWorkspace.platformSkills = new B({
|
|
96
97
|
applicationId: () => this._applicationId,
|
|
97
98
|
getToken: () => this.token,
|
|
98
99
|
getSkills: () => {
|
|
@@ -103,7 +104,7 @@ class ni {
|
|
|
103
104
|
getSandbox: () => {
|
|
104
105
|
var a;
|
|
105
106
|
const s = (a = this._localWorkspace) == null ? void 0 : a.adapter;
|
|
106
|
-
return s instanceof
|
|
107
|
+
return s instanceof C ? s.sandbox : void 0;
|
|
107
108
|
}
|
|
108
109
|
}), t === "host-bridge" ? this._disconnectHost = V(this._localWorkspace) : this._localWorkspace.restore();
|
|
109
110
|
}
|
|
@@ -148,10 +149,10 @@ class ni {
|
|
|
148
149
|
{
|
|
149
150
|
ui: (e = this.sdkConfigs.ui) == null ? void 0 : e.name,
|
|
150
151
|
uiVersion: (t = this.sdkConfigs.ui) == null ? void 0 : t.version,
|
|
151
|
-
sdkVersion:
|
|
152
|
+
sdkVersion: z.version
|
|
152
153
|
}
|
|
153
|
-
).then((s) => (typeof s.arrange[0].thinkingModeOpen != "boolean" && (s.arrange[0].thinkingModeOpen = !0), typeof s.arrange[0].thinkingTextOpen != "boolean" && (s.arrange[0].thinkingTextOpen = !0),
|
|
154
|
-
arrange: [
|
|
154
|
+
).then((s) => (typeof s.arrange[0].thinkingModeOpen != "boolean" && (s.arrange[0].thinkingModeOpen = !0), typeof s.arrange[0].thinkingTextOpen != "boolean" && (s.arrange[0].thinkingTextOpen = !0), g(_({}, s), {
|
|
155
|
+
arrange: [g(_({}, s.arrange[0]), {
|
|
155
156
|
recommendQuestionOpen: f.loadRelatedQuesions && s.arrange[0].recommendQuestionOpen
|
|
156
157
|
})]
|
|
157
158
|
})));
|
|
@@ -196,10 +197,10 @@ class ni {
|
|
|
196
197
|
const r = this;
|
|
197
198
|
return new Promise((s, a) => {
|
|
198
199
|
const c = (d) => p(this, null, function* () {
|
|
199
|
-
if (d ===
|
|
200
|
-
s(new D(i, e, t, o, n, r));
|
|
201
|
-
else if (d === g.Dialog)
|
|
200
|
+
if (d === u.Agent)
|
|
202
201
|
s(new F(i, e, t, o, n, r));
|
|
202
|
+
else if (d === u.Dialog)
|
|
203
|
+
s(new j(i, e, t, o, n, r));
|
|
203
204
|
else
|
|
204
205
|
throw Error(`不支持的应用类型:${d}`);
|
|
205
206
|
});
|
|
@@ -340,5 +341,5 @@ class ni {
|
|
|
340
341
|
}
|
|
341
342
|
}
|
|
342
343
|
export {
|
|
343
|
-
|
|
344
|
+
ri as default
|
|
344
345
|
};
|