@glodon-aiot/bot-client-sdk 3.26.0-alpha.12 → 3.26.0-alpha.14

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 CHANGED
@@ -156,7 +156,7 @@ const client = new BotClient(token, {
156
156
 
157
157
  `localFiles` 启用后,SDK 把内置工具注册到 `pluginCode` `builtin_tools`。`client.localWorkspace` 只在 `localFiles.enabled === true` 时存在。
158
158
 
159
- `shell` / `run_file` / `run_skill_script` 按[命令和脚本](#命令和脚本)选择执行器:注入的 `commandRunner` → 已就绪的协议 2 沙箱 → 无宿主页面中的 just-bash / Pyodide(默认开启)→ 否则 501。宿主工作区已授权但沙箱未就绪时直接失败,不降级到浏览器运行时。
159
+ `shell` / `run_file` / `run_skill_script` 按[命令和脚本](#命令和脚本)选择执行器:注入的 `commandRunner` → 已就绪的协议 1 沙箱 → 无宿主页面中的 just-bash / Pyodide(默认开启)→ 否则 501。宿主工作区已授权但沙箱未就绪时直接失败,不降级到浏览器运行时。
160
160
 
161
161
  业务 `plugins` 里如果已经有 `builtin_tools` 这个 key,内置工具不会注册,`error` 事件会带上原因。同一页面只支持一个启用了内置插件的 `BotClient`(插件表是全局配置)。
162
162
 
@@ -202,7 +202,7 @@ const schema = pluginCode === getRegisteredLocalFilesPluginCode()
202
202
 
203
203
  - 工具参数使用工作区内以 `/` 开头的绝对路径,或相对工作区根的相对路径,例如 `/说明.md`、`notes/a.md`。
204
204
  - **不要**使用或新建 `input`、`output`、`uploads`、`tmp` 作为约定根目录。
205
- - 技能在 `skills/<名称>/` 下,只通过技能工具访问。
205
+ - 平台技能不在工程里。`load_skill`、`read_skill_resource`、`run_skill_script` 读取端侧缓存;`read_file`、`shell` 等拒绝第一段为 `skills` 的路径。
206
206
  - `/dev`、`/usr`、`/bin` 仍是系统路径。写进脚本文件里的路径请用相对路径。
207
207
 
208
208
  网页里由用户选择文件夹时依赖 File System Access API,只在 Chromium 内核(Chrome、Edge、WebView2)的安全上下文(https 或 localhost)中可用。端侧宿主自己掌握工程目录时,页面不再弹选择框,见[宿主通道](#宿主通道)。
@@ -240,7 +240,7 @@ const client = new BotClient(token, {
240
240
  const workspace = client.localWorkspace;
241
241
  ```
242
242
 
243
- `transfer` 仍可供旧的上传下载实现使用。当前注册的内置工具不走这套传输。宿主沙箱由 `workspace.sandbox.state === "ready"` 且 `protocol === 2` 表示可用,不在 `commandRuntime` 里配置;`capabilities` 只用于兼容旧的 workspace 消息。
243
+ `transfer` 仍可供旧的上传下载实现使用。当前注册的内置工具不走这套传输。宿主沙箱由 `workspace.sandbox.state === "ready"` 且 `protocol === 1` 表示可用,不在 `commandRuntime` 里配置;`capabilities` 只用于兼容旧的 workspace 消息。
244
244
 
245
245
  ### 十一个工具
246
246
 
@@ -262,11 +262,11 @@ const workspace = client.localWorkspace;
262
262
 
263
263
  **`run_file`** 执行已存在的脚本。浏览器:`.py`(Pyodide)、`.sh`(just-bash);`.js` / `node` 明确不支持。宿主沙箱:另支持 `.js`(沙箱自带 Node)。
264
264
 
265
- **`load_skill`** 读取 `skills/<名称>/SKILL.md`。
265
+ **`load_skill`** 读取编排里该技能已发布版本的 `SKILL.md`。技能包在工程外的平台缓存中,不在工作区 `skills/` 下。
266
266
 
267
- **`read_skill_resource`** 读取该技能目录内的相对路径。
267
+ **`read_skill_resource`** 读取该版本目录内的相对路径,只返回 UTF-8 文本。
268
268
 
269
- **`run_skill_script`** 执行技能脚本,`args` 是位置参数数组。工作目录为工作区根(与当前命令执行器一致)。
269
+ **`run_skill_script`** 在宿主沙箱里执行技能脚本,`args` 是位置参数数组。工作目录是工程根。用户文件按相对工程根传入。技能自己的资源按脚本文件所在目录查找。没有宿主沙箱时返回 501,不改走浏览器运行时。
270
270
 
271
271
  ### 浏览器里授权
272
272
 
@@ -455,16 +455,16 @@ function openApprovalDialog(request: ApprovalRequest): Promise<boolean> {
455
455
 
456
456
  ## 命令和脚本
457
457
 
458
- `shell`、`run_file`、`run_skill_script` 共用同一套执行器选择(`runnerFor`),成功时 `data` 为 `{ exitCode, stdout, stderr, cwd? }`。`exitCode !== 0` 仍是工具成功(`code === 0`)。跨命令只保留 cwd,不保留环境变量。
458
+ `shell`、`run_file` 共用同一套执行器选择(`runnerFor`)。`run_skill_script` 只用注入的执行器或已就绪的宿主沙箱,没有沙箱时不改走浏览器运行时。成功时 `data` 为 `{ exitCode, stdout, stderr, cwd? }`。`exitCode !== 0` 仍是工具成功(`code === 0`)。跨命令只保留 cwd,不保留环境变量。
459
459
 
460
460
  ### 执行器选择顺序
461
461
 
462
462
  1. **注入的** `LocalWorkspace.commandRunner`(测试 / 自定义,优先级最高)
463
- 2. **沙箱直连**:宿主工作区已授权,且 `sandbox.state` 为 `ready`、`protocol` 为 `2` → 页面对 `ws://127.0.0.1` 发 WebSocket,不经宿主转发文件和命令
463
+ 2. **沙箱直连**:宿主工作区已授权,且 `sandbox.state` 为 `ready`、`protocol` 为 `1` → 页面对 `ws://127.0.0.1` 发 WebSocket,不经宿主转发文件和命令
464
464
  3. **浏览器运行时**:没有宿主 WebView 时,`commandRuntime.browser.enabled` 默认为 `true` → just-bash + Pyodide Worker
465
465
  4. 以上皆不可用 → **501**
466
466
 
467
- 宿主工作区已经授权时,沙箱没就绪不会改走浏览器运行时。`starting` 时说明正在启动;失败说明使用 `sandbox.message`。协议不是 2 时另发一次 `error` 事件。收到 `bye`、`exited` 或 `failed` 后,在途调用以 `AbortError` 失败且不会重放;只有新的 `ready` 到达后才使用新地址和令牌连接。
467
+ 宿主工作区已经授权时,沙箱没就绪不会改走浏览器运行时。`starting` 时说明正在启动;失败说明使用 `sandbox.message`。协议不是 1 时另发一次 `error` 事件。收到 `bye`、`exited` 或 `failed` 后,在途调用以 `AbortError` 失败且不会重放;只有新的 `ready` 到达后才使用新地址和令牌连接。
468
468
 
469
469
  参照宿主:`examples/qt-workspace-host`。
470
470
 
@@ -500,7 +500,8 @@ function openApprovalDialog(request: ApprovalRequest): Promise<boolean> {
500
500
  - 运行中崩溃时推送 `sandbox.state: "exited"`。同一次打开最多自动重启一次
501
501
  - 文件被其他程序占用时原文件保持不变,错误是「文件正在被占用,没有写入。」
502
502
  - 随安装包分发:`Resources/node/`(Node 24)+ `Resources/workspace-sandbox/`(`yarn bundle --platform …` 产物),可选 `python/`
503
- - 输出做路径反向替换,页面看不到工程绝对路径
503
+ - 输出做路径反向替换,页面看不到工程绝对路径,也看不到技能缓存的绝对路径
504
+ - 平台技能:进入会话时按编排 `arrange[0].skills` 核对已发布版本(`version >= 1`)。页面用当时的 `client.token` 作 `Authorization: Bearer` 下载 ZIP,再经已认证的本地 WebSocket 交给沙箱 `installSkill`。沙箱收不到这个令牌。缓存按系统放在用户目录(Windows `%LOCALAPPDATA%\glodon-workspace-sandbox`,macOS `~/Library/Caches/glodon-workspace-sandbox`,Linux `$XDG_CACHE_HOME` 或 `~/.cache` 下的同名目录),不在工程内。删除会话不删缓存;编排不再引用且没有脚本在跑的版本,下次进入会话时删除。非 debug 的对话气泡不显示这三个技能工具
504
505
  - 细节与 Windows 步骤见 [`local-workspace-windows-host.md`](../bot-client-ui/docs/local-workspace-windows-host.md)
505
506
 
506
507
  ## 宿主通道
@@ -531,7 +532,7 @@ function openApprovalDialog(request: ApprovalRequest): Promise<boolean> {
531
532
  "state": "ready",
532
533
  "url": "ws://127.0.0.1:53124",
533
534
  "token": "<32 字节十六进制>",
534
- "protocol": 2
535
+ "protocol": 1
535
536
  }
536
537
  }
537
538
  ```
@@ -546,7 +547,7 @@ function openApprovalDialog(request: ApprovalRequest): Promise<boolean> {
546
547
 
547
548
  脚本跑完、用户在资源管理器里改文件,都应推送。Qt 示例用目录监视做这件事,默认不监视 `.git`、`node_modules`、`__pycache__` 内部。
548
549
 
549
- 文件和命令不经过宿主。页面连上沙箱后发协议 2 的文本帧和二进制分片:`read` 按 `offset` / `maxBytes` 取窗口,`write` 按偏移写入临时文件再改名。占用时原文件不变。命令输出流式返回,SDK 每个流只保留最后 16000 字符;若有 `logPath`,截断说明里带上 `tmp/sandbox-exec/<id>.log`。
550
+ 文件和命令不经过宿主。页面连上沙箱后发协议 1 的文本帧和二进制分片:`read` 按 `offset` / `maxBytes` 取窗口,`write` 按偏移写入临时文件再改名。占用时原文件不变。命令输出流式返回,SDK 每个流只保留最后 16000 字符;若有 `logPath`,截断说明里带上 `tmp/sandbox-exec/<id>.log`。
550
551
 
551
552
  取消命令只发 `{ "op": "cancel", "id" }`,不关闭套接字。收到 `bye`、`exited` 或 `failed` 时,在途调用失败且不重放。下一次 `ready` 使用新令牌再连。
552
553
 
@@ -1,53 +1,55 @@
1
1
  var x = Object.defineProperty, b = Object.defineProperties;
2
2
  var R = Object.getOwnPropertyDescriptors;
3
- var m = Object.getOwnPropertySymbols;
3
+ var v = Object.getOwnPropertySymbols;
4
4
  var E = Object.prototype.hasOwnProperty, L = Object.prototype.propertyIsEnumerable;
5
- var v = (c, e, i) => e in c ? x(c, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : c[e] = i, f = (c, e) => {
6
- for (var i in e || (e = {}))
7
- E.call(e, i) && v(c, i, e[i]);
8
- if (m)
9
- for (var i of m(e))
10
- L.call(e, i) && v(c, i, e[i]);
11
- return c;
12
- }, _ = (c, e) => b(c, R(e));
13
- var l = (c, e, i) => (v(c, typeof e != "symbol" ? e + "" : e, i), i);
14
- var d = (c, e, i) => new Promise((t, s) => {
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
+ for (var e in i || (i = {}))
7
+ E.call(i, e) && m(h, e, i[e]);
8
+ if (v)
9
+ for (var e of v(i))
10
+ L.call(i, e) && m(h, e, i[e]);
11
+ return h;
12
+ }, u = (h, i) => b(h, R(i));
13
+ var l = (h, i, e) => (m(h, typeof i != "symbol" ? i + "" : i, e), e);
14
+ var p = (h, i, e) => new Promise((t, o) => {
15
15
  var n = (a) => {
16
16
  try {
17
- o(i.next(a));
18
- } catch (h) {
19
- s(h);
17
+ s(e.next(a));
18
+ } catch (c) {
19
+ o(c);
20
20
  }
21
21
  }, r = (a) => {
22
22
  try {
23
- o(i.throw(a));
24
- } catch (h) {
25
- s(h);
23
+ s(e.throw(a));
24
+ } catch (c) {
25
+ o(c);
26
26
  }
27
- }, o = (a) => a.done ? t(a.value) : Promise.resolve(a.value).then(n, r);
28
- o((i = i.apply(c, e)).next());
27
+ }, s = (a) => a.done ? t(a.value) : Promise.resolve(a.value).then(n, r);
28
+ s((e = e.apply(h, i)).next());
29
29
  });
30
30
  import { parseJWT as y } from "./utils.mjs";
31
31
  import W from "./Logger.mjs";
32
- import { getAIShopService as M, getCVForceService as C } from "./api/index.mjs";
33
- import { configure as k, configuration as p, setActiveLocalWorkspace as S, refreshBuiltinPlugins as w } from "./Config.mjs";
34
- import { connectHostBridge as T } from "./localFiles/host/connectHostBridge.mjs";
35
- import { LocalWorkspace as B } from "./localFiles/workspace/LocalWorkspace.mjs";
36
- import { createIndexedDbStore as V } from "./localFiles/workspace/handleStore.mjs";
37
- import { createDefaultSessionFileTransfer as O } from "./localFiles/transfer/SessionFileTransfer.mjs";
38
- import { ApplicationTypes as u, PromptVariableType as A } from "@glodon-aiot/apis";
32
+ import { getAIShopService as M, getCVForceService as T } from "./api/index.mjs";
33
+ import { configure as k, configuration as f, setActiveLocalWorkspace as S, refreshBuiltinPlugins as w } from "./Config.mjs";
34
+ import { PlatformSkillSync as C } from "./builtinTools/platformSkills.mjs";
35
+ import { HostBridgeAdapter as B } from "./localFiles/adapters/HostBridgeAdapter.mjs";
36
+ import { connectHostBridge as V } from "./localFiles/host/connectHostBridge.mjs";
37
+ import { LocalWorkspace as O } from "./localFiles/workspace/LocalWorkspace.mjs";
38
+ import { createIndexedDbStore as H } from "./localFiles/workspace/handleStore.mjs";
39
+ import { createDefaultSessionFileTransfer as P } from "./localFiles/transfer/SessionFileTransfer.mjs";
40
+ import { ApplicationTypes as g, PromptVariableType as A } from "@glodon-aiot/apis";
39
41
  import D from "./AgentSession.mjs";
40
- import H from "./DialogSession.mjs";
41
- import P from "./EventBus.mjs";
42
- import F from "./package.json.mjs";
42
+ import F from "./DialogSession.mjs";
43
+ import j from "./EventBus.mjs";
44
+ import Q from "./package.json.mjs";
43
45
  const I = new W("[BotClient] ");
44
- class ie {
45
- constructor(e, i, t = !0, s = {
46
+ class ni {
47
+ constructor(i, e, t = !0, o = {
46
48
  analytics: {
47
49
  enabled: !1
48
50
  }
49
51
  }) {
50
- l(this, "event", new P());
52
+ l(this, "event", new j());
51
53
  l(this, "cvforceApi");
52
54
  //从token解析出来的用户信息
53
55
  l(this, "_applicationId");
@@ -62,37 +64,50 @@ class ie {
62
64
  l(this, "_promptVariables", []);
63
65
  l(this, "_localWorkspace");
64
66
  l(this, "_disconnectHost");
65
- if (this._token = e, this.lazyload = t, this.sdkConfigs = s, k(i, {
67
+ if (this._token = i, this.lazyload = t, this.sdkConfigs = o, k(e, {
66
68
  refreshBuiltinPlugins: !1
67
- }), this._applicationId = y(e).rid || p.applicationId, !this._applicationId)
69
+ }), this._applicationId = y(i).rid || f.applicationId, !this._applicationId)
68
70
  throw "token is not vaild";
69
71
  this.cvforceApi = this.getService(), this.setupLocalWorkspace(), this.loadApplication().then((n) => {
70
- k(_(f({}, i), {
71
- stream: i.stream === void 0 ? (n == null ? void 0 : n.type) === u.Dialog || (n == null ? void 0 : n.type) === u.Agent : i.stream
72
+ k(u(_({}, e), {
73
+ stream: e.stream === void 0 ? (n == null ? void 0 : n.type) === g.Dialog || (n == null ? void 0 : n.type) === g.Agent : e.stream
72
74
  })), this.event.emit("ready");
73
75
  });
74
76
  }
75
77
  setupLocalWorkspace() {
76
- var s, n;
77
- const e = (s = p.builtinPlugins) == null ? void 0 : s.localFiles;
78
- if (!(e != null && e.enabled)) {
78
+ var o, n;
79
+ const i = (o = f.builtinPlugins) == null ? void 0 : o.localFiles;
80
+ if (!(i != null && i.enabled)) {
79
81
  S(void 0), w();
80
82
  return;
81
83
  }
82
- const i = [], t = (n = e.backend) != null ? n : "file-system-access";
84
+ const e = [], t = (n = i.backend) != null ? n : "file-system-access";
83
85
  if (t !== "file-system-access" && t !== "host-bridge")
84
- i.push(new Error(`[LocalFiles] 不支持的 backend:${e.backend}`));
86
+ e.push(new Error(`[LocalFiles] 不支持的 backend:${i.backend}`));
85
87
  else {
86
- const r = M(p.apiRoot, this.token, (o, a) => I.error(a));
87
- this._localWorkspace = new B({
88
+ const r = M(f.apiRoot, this.token, (s, a) => I.error(a));
89
+ this._localWorkspace = new O({
88
90
  applicationId: this._applicationId,
89
- config: e,
90
- store: V(),
91
+ config: i,
92
+ store: H(),
91
93
  picker: t === "host-bridge" ? null : void 0,
92
- transfer: O(() => this.cvforceApi, () => r)
93
- }), S(this._localWorkspace), t === "host-bridge" ? this._disconnectHost = T(this._localWorkspace) : this._localWorkspace.restore();
94
+ transfer: P(() => this.cvforceApi, () => r)
95
+ }), S(this._localWorkspace), this._localWorkspace.platformSkills = new C({
96
+ applicationId: () => this._applicationId,
97
+ getToken: () => this.token,
98
+ getSkills: () => {
99
+ var s, a, c, d;
100
+ return (d = (c = (a = (s = this._application) == null ? void 0 : s.arrange) == null ? void 0 : a[0]) == null ? void 0 : c.skills) != null ? d : [];
101
+ },
102
+ apiRoot: () => f.apiRoot,
103
+ getSandbox: () => {
104
+ var a;
105
+ const s = (a = this._localWorkspace) == null ? void 0 : a.adapter;
106
+ return s instanceof B ? s.sandbox : void 0;
107
+ }
108
+ }), t === "host-bridge" ? this._disconnectHost = V(this._localWorkspace) : this._localWorkspace.restore();
94
109
  }
95
- i.push(...w()), i.length && Promise.resolve().then(() => i.forEach((r) => this.event.emit("error", r)));
110
+ e.push(...w()), e.length && Promise.resolve().then(() => e.forEach((r) => this.event.emit("error", r)));
96
111
  }
97
112
  /** 启用 builtinPlugins.localFiles 后可用;UI 与纯 SDK 集成共用此实例。 */
98
113
  get localWorkspace() {
@@ -105,8 +120,8 @@ class ie {
105
120
  get ready() {
106
121
  return this._ready;
107
122
  }
108
- set ready(e) {
109
- this._ready = e;
123
+ set ready(i) {
124
+ this._ready = i;
110
125
  }
111
126
  get questionContextMaxLength() {
112
127
  return this.checkReady(), this._questionContextMaxLength;
@@ -115,49 +130,49 @@ class ie {
115
130
  return this.checkReady(), this._promptVariables;
116
131
  }
117
132
  get knowledges() {
118
- var e;
119
- return this.checkReady(), (e = this._application) == null ? void 0 : e.arrange[0].knowledges;
133
+ var i;
134
+ return this.checkReady(), (i = this._application) == null ? void 0 : i.arrange[0].knowledges;
120
135
  }
121
136
  get sessions() {
122
137
  return this.checkReady(), this._sessions;
123
138
  }
124
- set sessions(e) {
125
- this.checkReady(), this._sessions = e, this.event.emit("sessions:updated", e);
139
+ set sessions(i) {
140
+ this.checkReady(), this._sessions = i, this.event.emit("sessions:updated", i);
126
141
  }
127
142
  loadApplication() {
128
- return d(this, null, function* () {
129
- var i, t, s, n, r;
143
+ return p(this, null, function* () {
144
+ var e, t, o, n, r;
130
145
  this._application = yield this.cvforceApi.getApplicationId(
131
146
  this._applicationId,
132
147
  // 这里记录应用的名称和版本,以便后期数据分析
133
148
  {
134
- ui: (i = this.sdkConfigs.ui) == null ? void 0 : i.name,
149
+ ui: (e = this.sdkConfigs.ui) == null ? void 0 : e.name,
135
150
  uiVersion: (t = this.sdkConfigs.ui) == null ? void 0 : t.version,
136
- sdkVersion: F.version
151
+ sdkVersion: Q.version
137
152
  }
138
- ).then((o) => (typeof o.arrange[0].thinkingModeOpen != "boolean" && (o.arrange[0].thinkingModeOpen = !0), typeof o.arrange[0].thinkingTextOpen != "boolean" && (o.arrange[0].thinkingTextOpen = !0), _(f({}, o), {
139
- arrange: [_(f({}, o.arrange[0]), {
140
- recommendQuestionOpen: p.loadRelatedQuesions && o.arrange[0].recommendQuestionOpen
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), u(_({}, s), {
154
+ arrange: [u(_({}, s.arrange[0]), {
155
+ recommendQuestionOpen: f.loadRelatedQuesions && s.arrange[0].recommendQuestionOpen
141
156
  })]
142
157
  })));
143
- const e = (r = (n = (s = this._application) == null ? void 0 : s.arrange) == null ? void 0 : n[0]) == null ? void 0 : r.llmModel;
144
- return e && (this._questionContextMaxLength = yield this.cvforceApi.getBaseModel(e).then((o) => o.maxModelLength)), this._promptVariables = yield Promise.all([this.cvforceApi.getPrompts(this._applicationId, {
158
+ const i = (r = (n = (o = this._application) == null ? void 0 : o.arrange) == null ? void 0 : n[0]) == null ? void 0 : r.llmModel;
159
+ return i && (this._questionContextMaxLength = yield this.cvforceApi.getBaseModel(i).then((s) => s.maxModelLength)), this._promptVariables = yield Promise.all([this.cvforceApi.getPrompts(this._applicationId, {
145
160
  type: A.User
146
161
  }), this.cvforceApi.getPrompts(this._applicationId, {
147
162
  type: A.System
148
- })]).then(([o, a]) => [...o, ...a]), this._ready = !0, this.event.emit("application:loaded"), this._application;
163
+ })]).then(([s, a]) => [...s, ...a]), this._ready = !0, this.event.emit("application:loaded"), this._application;
149
164
  });
150
165
  }
151
166
  getService() {
152
- return this.cvforceApi ? this.cvforceApi : C(p.apiRoot, this.token, (e, i) => I.error(i));
167
+ return this.cvforceApi ? this.cvforceApi : T(f.apiRoot, this.token, (i, e) => I.error(e));
153
168
  }
154
169
  get token() {
155
170
  return this._token;
156
171
  }
157
- set token(e) {
158
- this.checkReady(), this._token = e, this.ready = !1;
159
- const i = y(e).rid;
160
- this._applicationId !== i && (this._applicationId = i, this._application = null, this.loadApplication().then(() => {
172
+ set token(i) {
173
+ this.checkReady(), this._token = i, this.ready = !1;
174
+ const e = y(i).rid;
175
+ this._applicationId !== e && (this._applicationId = e, this._application = null, this.loadApplication().then(() => {
161
176
  this.event.emit("ready");
162
177
  }), this.clean());
163
178
  }
@@ -168,35 +183,35 @@ class ie {
168
183
  return this.checkReady(), this._application;
169
184
  }
170
185
  get activeSession() {
171
- var e;
172
- return this.checkReady(), ((e = this._activeSession) == null ? void 0 : e.id) || "";
186
+ var i;
187
+ return this.checkReady(), ((i = this._activeSession) == null ? void 0 : i.id) || "";
173
188
  }
174
- set activeSession(e) {
175
- this.checkReady(), this.loadSession(e).then((i) => {
176
- this._activeSession && this._activeSession.id !== e && this._activeSession.inactivate(), this._activeSession = i;
189
+ set activeSession(i) {
190
+ this.checkReady(), this.loadSession(i).then((e) => {
191
+ this._activeSession && this._activeSession.id !== i && this._activeSession.inactivate(), this._activeSession = e;
177
192
  });
178
193
  }
179
- createSession(e, i, t, s, n) {
180
- return d(this, null, function* () {
194
+ createSession(i, e, t, o, n) {
195
+ return p(this, null, function* () {
181
196
  const r = this;
182
- return new Promise((o, a) => {
183
- const h = (g) => d(this, null, function* () {
184
- if (g === u.Agent)
185
- o(new D(e, i, t, s, n, r));
186
- else if (g === u.Dialog)
187
- o(new H(e, i, t, s, n, r));
197
+ return new Promise((s, a) => {
198
+ const c = (d) => p(this, null, function* () {
199
+ if (d === g.Agent)
200
+ s(new D(i, e, t, o, n, r));
201
+ else if (d === g.Dialog)
202
+ s(new F(i, e, t, o, n, r));
188
203
  else
189
- throw Error(`不支持的应用类型:${g}`);
204
+ throw Error(`不支持的应用类型:${d}`);
190
205
  });
191
206
  if (this.ready) {
192
207
  if (!this._application)
193
208
  throw Error("client is not ready");
194
- h(this._application.type);
209
+ c(this._application.type);
195
210
  } else
196
211
  this.event.on("ready", () => {
197
212
  if (!this._application)
198
213
  throw Error("_application is null");
199
- h(this._application.type);
214
+ c(this._application.type);
200
215
  }, !0);
201
216
  });
202
217
  });
@@ -204,38 +219,38 @@ class ie {
204
219
  /**
205
220
  * 获取会话产出物。不传 sessionId 时取当前活跃会话。没有产出物时返回空数组。
206
221
  */
207
- getArtifacts(e) {
208
- return d(this, null, function* () {
222
+ getArtifacts(i) {
223
+ return p(this, null, function* () {
209
224
  var n, r;
210
225
  this.checkReady();
211
- const i = e || ((n = this._activeSession) == null ? void 0 : n.id);
212
- if (!i)
226
+ const e = i || ((n = this._activeSession) == null ? void 0 : n.id);
227
+ if (!e)
213
228
  throw new Error("session id is not defined");
214
- const t = this._sessions.find((o) => o.id === i);
229
+ const t = this._sessions.find((s) => s.id === e);
215
230
  if (t)
216
231
  return t.getArtifacts();
217
- const s = yield this.cvforceApi.getSessionArtifacts(this._applicationId, i);
218
- return (r = s == null ? void 0 : s.artifacts) != null ? r : [];
232
+ const o = yield this.cvforceApi.getSessionArtifacts(this._applicationId, e);
233
+ return (r = o == null ? void 0 : o.artifacts) != null ? r : [];
219
234
  });
220
235
  }
221
- getSessions(e) {
222
- return d(this, null, function* () {
223
- return new Promise((i, t) => {
224
- const s = () => this.cvforceApi.listSessions(this._applicationId, e).then((n) => d(this, null, function* () {
236
+ getSessions(i) {
237
+ return p(this, null, function* () {
238
+ return new Promise((e, t) => {
239
+ const o = () => this.cvforceApi.listSessions(this._applicationId, i).then((n) => p(this, null, function* () {
225
240
  const r = [];
226
- for (const o of n) {
227
- const a = this._sessions.find((h) => h.id === o.id);
241
+ for (const s of n) {
242
+ const a = this._sessions.find((c) => c.id === s.id);
228
243
  if (a)
229
- a.data = o, this._application ? a.application = this._application : yield a.loadApplicationInfo(), r.push(a);
244
+ a.data = s, this._application ? a.application = this._application : yield a.loadApplicationInfo(), r.push(a);
230
245
  else {
231
- const h = yield this.createSession(this.token, o.id, o, this.lazyload, this._application || void 0);
232
- r.push(h);
246
+ const c = yield this.createSession(this.token, s.id, s, this.lazyload, this._application || void 0);
247
+ r.push(c);
233
248
  }
234
249
  }
235
- if (e != null && e.pageSize) {
236
- const o = [...this._sessions, ...r], a = /* @__PURE__ */ new Map();
237
- for (const h of o)
238
- a.set(h.id, h);
250
+ if (i != null && i.pageSize) {
251
+ const s = [...this._sessions, ...r], a = /* @__PURE__ */ new Map();
252
+ for (const c of s)
253
+ a.set(c.id, c);
239
254
  return this.sessions = Array.from(a.values()), this.sessions;
240
255
  } else
241
256
  return this.sessions = r, r;
@@ -243,21 +258,22 @@ class ie {
243
258
  if (this.ready) {
244
259
  if (!this._application)
245
260
  throw Error("_application is null");
246
- i(s());
261
+ e(o());
247
262
  } else
248
263
  this.event.on("ready", () => {
249
264
  if (!this._application)
250
265
  throw Error("_application is null");
251
- i(s());
266
+ e(o());
252
267
  }, !0);
253
268
  });
254
269
  });
255
270
  }
256
- loadSession(e = "", i) {
257
- return d(this, null, function* () {
258
- this.checkReady();
259
- let t = this.sessions.find((s) => s.id === e);
260
- if (t || (t = yield this.createSession(this.token, e, i), this._sessions.push(t)), this._activeSession) {
271
+ loadSession(i = "", e) {
272
+ return p(this, null, function* () {
273
+ var o, n;
274
+ this.checkReady(), (n = (o = this._localWorkspace) == null ? void 0 : o.platformSkills) == null || n.sync();
275
+ let t = this.sessions.find((r) => r.id === i);
276
+ if (t || (t = yield this.createSession(this.token, i, e), this._sessions.push(t)), this._activeSession) {
261
277
  if (this._activeSession === t)
262
278
  return t;
263
279
  this._activeSession.inactivate();
@@ -268,61 +284,61 @@ class ie {
268
284
  });
269
285
  }
270
286
  reload() {
271
- return this.loadApplication().then(() => d(this, null, function* () {
287
+ return this.loadApplication().then(() => p(this, null, function* () {
272
288
  return yield this.getSessions(), this.event.emit("ready"), this;
273
289
  }));
274
290
  }
275
- reloadSession(e) {
276
- return d(this, null, function* () {
291
+ reloadSession(i) {
292
+ return p(this, null, function* () {
277
293
  yield this.reload();
278
- let i = this._sessions.find((t) => t.id === e) || this._activeSession;
279
- if (!i) {
294
+ let e = this._sessions.find((t) => t.id === i) || this._activeSession;
295
+ if (!e) {
280
296
  console.warn("reloadSession session failed.");
281
297
  return;
282
298
  }
283
- return yield i.reload(), i;
299
+ return yield e.reload(), e;
284
300
  });
285
301
  }
286
- setTop(e, i, t = "top_time desc, sort_status desc, updated_at desc") {
287
- return d(this, null, function* () {
288
- let s = e ? this._sessions.find((n) => n.id === e) : this._activeSession;
289
- if (!s) {
302
+ setTop(i, e, t = "top_time desc, sort_status desc, updated_at desc") {
303
+ return p(this, null, function* () {
304
+ let o = i ? this._sessions.find((n) => n.id === i) : this._activeSession;
305
+ if (!o) {
290
306
  console.warn("setTop session failed.");
291
307
  return;
292
308
  }
293
- return yield s.setTop(i), this.getSessions({
309
+ return yield o.setTop(e), this.getSessions({
294
310
  order: t
295
311
  });
296
312
  });
297
313
  }
298
- addEventListener(e, i, t = !1) {
299
- if (typeof i != "function")
314
+ addEventListener(i, e, t = !1) {
315
+ if (typeof e != "function")
300
316
  throw Error("event listener is not a function");
301
317
  if (t) {
302
- this.event.once(e, i);
318
+ this.event.once(i, e);
303
319
  return;
304
320
  }
305
- this.event.on(e, i);
321
+ this.event.on(i, e);
306
322
  }
307
- removeEventListener(e, i) {
308
- this.event.off(e, i);
323
+ removeEventListener(i, e) {
324
+ this.event.off(i, e);
309
325
  }
310
- removeSession(e, i) {
311
- return d(this, null, function* () {
326
+ removeSession(i, e) {
327
+ return p(this, null, function* () {
312
328
  this.checkReady();
313
329
  let t = -1;
314
- if (typeof e == "string" ? t = this._sessions.findIndex((s) => s.id === e) : t = this._sessions.findIndex((s) => s.id === e.id), t > -1) {
315
- const s = this._sessions[t];
316
- i && (yield s.delete()), this._sessions.splice(t, 1);
330
+ if (typeof i == "string" ? t = this._sessions.findIndex((o) => o.id === i) : t = this._sessions.findIndex((o) => o.id === i.id), t > -1) {
331
+ const o = this._sessions[t];
332
+ e && (yield o.delete()), this._sessions.splice(t, 1);
317
333
  } else
318
334
  console.warn("session delete failed, session is not exist.");
319
335
  });
320
336
  }
321
337
  clean() {
322
- var e;
323
- (e = this._disconnectHost) == null || e.call(this), this._disconnectHost = void 0, this._sessions.forEach((i) => i.destroy()), this.sessions = [];
338
+ var i;
339
+ (i = this._disconnectHost) == null || i.call(this), this._disconnectHost = void 0, this._sessions.forEach((e) => e.destroy()), this.sessions = [];
324
340
  }
325
341
  }
326
342
  export {
327
- ie as default
343
+ ni as default
328
344
  };