@glodon-aiot/bot-client-sdk 3.26.0-alpha.26 → 3.26.0-alpha.27

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
@@ -168,12 +168,14 @@ const client = new BotClient(token, {
168
168
  | `read_file` | 读取文件 | 浏览器、端侧宿主 |
169
169
  | `write_file` | 写入文件 | 浏览器、端侧宿主 |
170
170
  | `append_file` | 追加文件 | 浏览器、端侧宿主 |
171
- | `run_file` | 执行文件 | 浏览器运行时(`.py` / `.sh`)或端侧宿主(另含 `.js`) |
171
+ | `run_file` | 执行文件 | 浏览器运行时(`.py` / `.sh` / `.bash`)或端侧宿主(另含 `.js` / `.mjs` / `.cjs`) |
172
172
  | `edit_file` | 修改文件 | 浏览器、端侧宿主 |
173
173
  | `grep` | 搜索文件 | 浏览器、端侧宿主 |
174
174
  | `find` | 查找文件 | 浏览器、端侧宿主 |
175
- | `load_skill` | 加载技能 | 浏览器、端侧宿主 |
176
- | `read_skill_resource` | 读取技能资源 | 浏览器、端侧宿主 |
175
+ | `load_skill` | 加载技能 | 浏览器、端侧宿主。附带技能包文件清单 |
176
+ | `read_skill_resource` | 读取技能资源 | 浏览器、端侧宿主。目录返回清单,`grep:` 搜索正文 |
177
+ | `list_skill_files` | 列出技能文件 | 端侧宿主 |
178
+ | `grep_skill` | 搜索技能内容 | 端侧宿主 |
177
179
  | `run_skill_script` | 运行技能脚本 | 同 `run_file` |
178
180
 
179
181
  ### 展示工具步骤
@@ -260,11 +262,13 @@ const workspace = client.localWorkspace;
260
262
 
261
263
  **`shell`** 执行一条 shell 命令(每次新 shell,只保留上次 cwd)。起始目录是工作区根。命令不超过 20000 字。执行器见[命令和脚本](#命令和脚本)。工具 `code` 为 0 时进程退出码在 `data.exitCode`。脚本能否联网由宿主决定;被拒绝的地址写在 `stderr` 里。
262
264
 
263
- **`run_file`** 执行已存在的脚本。浏览器:`.py`(Pyodide)、`.sh`(just-bash);`.js` / `node` 明确不支持。宿主沙箱:另支持 `.js`(沙箱自带 Node)。
265
+ **`run_file`** 执行已存在的脚本。浏览器:`.py`(Pyodide)、`.sh` / `.bash`(just-bash);`.js` / `.mjs` / `.cjs` 走 `node`,浏览器里明确不支持。宿主沙箱:`.js`、`.mjs`、`.cjs` 都交给沙箱自带的 Node。
264
266
 
265
- **`load_skill`** 读取编排里该技能已发布版本的 `SKILL.md`。技能包在工程外的平台缓存中,不在工作区 `skills/` 下。
267
+ **`load_skill`** 读取编排里该技能已发布版本的 `SKILL.md`,并附上技能包内的文件清单。技能包在工程外的平台缓存中,不在工作区 `skills/` 下。
266
268
 
267
- **`read_skill_resource`** 读取该版本目录内的相对路径,只返回 UTF-8 文本。
269
+ **`read_skill_resource`** 读取该版本目录内的相对路径,只返回 UTF-8 文本。路径是目录时返回其中的文件清单;`resource_name` 为 `grep:正则` 时搜索整个技能包。
270
+
271
+ **`list_skill_files`** 列出技能包或其中某个目录。**`grep_skill`** 在技能包内按 grep 基本正则搜索。
268
272
 
269
273
  **`run_skill_script`** 在宿主沙箱里执行技能脚本,`args` 是位置参数数组。工作目录是工程根。用户文件按相对工程根传入。技能自己的资源按脚本文件所在目录查找。没有宿主沙箱时返回 501,不改走浏览器运行时。
270
274
 
@@ -614,7 +618,8 @@ function openApprovalDialog(request: ApprovalRequest): Promise<boolean> {
614
618
  | `maxTransferBytes` | 50 MB |
615
619
  | `maxSearchResults` | 200 |
616
620
  | `maxConcurrentRequests` | 4 |
617
- | `toolTimeoutMs` | 30 秒 |
621
+ | `toolTimeoutMs` | 30 秒。读、写、修改文件 |
622
+ | `commandTimeoutMs` | 10 分钟。`shell`、`run_file`、`run_skill_script`,同一时限传给沙箱 |
618
623
  | `searchTimeoutMs` | 60 秒 |
619
624
  | `transferTimeoutMs` | 10 分钟 |
620
625
  | `approvalTimeoutMs` | 5 分钟,不计入工具超时 |
@@ -1,10 +1,17 @@
1
- const _ = ["shell", "read_file", "write_file", "append_file", "run_file", "edit_file", "grep", "find", "load_skill", "read_skill_resource", "run_skill_script"], e = 81920, s = 81920, l = 2e4, i = ".", n = "/workspace", o = [".py", ".sh", ".js"];
1
+ const s = ["shell", "read_file", "write_file", "append_file", "run_file", "edit_file", "grep", "find", "load_skill", "read_skill_resource", "list_skill_files", "grep_skill", "run_skill_script"], _ = 81920, e = 81920, l = 2e4, i = ".", n = "/workspace", o = {
2
+ ".py": "python3",
3
+ ".sh": "sh",
4
+ ".bash": "sh",
5
+ ".js": "node",
6
+ ".mjs": "node",
7
+ ".cjs": "node"
8
+ };
2
9
  export {
3
- _ as BUILTIN_FUNCTION_CODES,
10
+ s as BUILTIN_FUNCTION_CODES,
4
11
  l as MAX_COMMAND_CHARS,
5
- e as MAX_READ_BYTES,
6
- s as MAX_WRITE_BYTES,
7
- o as RUNNABLE_EXTENSIONS,
12
+ _ as MAX_READ_BYTES,
13
+ e as MAX_WRITE_BYTES,
14
+ o as SCRIPT_PROGRAMS,
8
15
  i as SHELL_CWD,
9
16
  n as WORKSPACE_MOUNT
10
17
  };
@@ -2,72 +2,74 @@ var K = Object.defineProperty, X = Object.defineProperties;
2
2
  var Q = Object.getOwnPropertyDescriptors;
3
3
  var C = Object.getOwnPropertySymbols;
4
4
  var Y = Object.prototype.hasOwnProperty, Z = Object.prototype.propertyIsEnumerable;
5
- var D = (e, t, n) => t in e ? K(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, s = (e, t) => {
5
+ var j = (e, t, n) => t in e ? K(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, l = (e, t) => {
6
6
  for (var n in t || (t = {}))
7
- Y.call(t, n) && D(e, n, t[n]);
7
+ Y.call(t, n) && j(e, n, t[n]);
8
8
  if (C)
9
9
  for (var n of C(t))
10
- Z.call(t, n) && D(e, n, t[n]);
10
+ Z.call(t, n) && j(e, n, t[n]);
11
11
  return e;
12
12
  }, _ = (e, t) => X(e, Q(t));
13
- var U = (e, t, n) => new Promise((a, m) => {
13
+ var H = (e, t, n) => new Promise((r, m) => {
14
14
  var d = (o) => {
15
15
  try {
16
16
  c(n.next(o));
17
- } catch (r) {
18
- m(r);
17
+ } catch (i) {
18
+ m(i);
19
19
  }
20
20
  }, f = (o) => {
21
21
  try {
22
22
  c(n.throw(o));
23
- } catch (r) {
24
- m(r);
23
+ } catch (i) {
24
+ m(i);
25
25
  }
26
- }, c = (o) => o.done ? a(o.value) : Promise.resolve(o.value).then(d, f);
26
+ }, c = (o) => o.done ? r(o.value) : Promise.resolve(o.value).then(d, f);
27
27
  c((n = n.apply(e, t)).next());
28
28
  });
29
- import { v4 as k } from "uuid";
30
- import ee from "../Logger.mjs";
31
- import { HostBridgeAdapter as H } from "../localFiles/adapters/HostBridgeAdapter.mjs";
32
- import { domError as V } from "../localFiles/adapters/WorkspaceFileAdapter.mjs";
33
- import { SANDBOX_PROTOCOL as te } from "../localFiles/host/protocol.mjs";
34
- import { cancelledError as T, workspaceNotGranted as ne, ToolError as u, ToolCode as l, toToolError as oe } from "../localFiles/errors.mjs";
35
- import { validateToolInput as re } from "../localFiles/validate.mjs";
36
- import { BrowserCommandRunner as ie } from "./browserRuntime/BrowserCommandRunner.mjs";
29
+ import { v4 as ee } from "uuid";
30
+ import te from "../Logger.mjs";
31
+ import { HostBridgeAdapter as V } from "../localFiles/adapters/HostBridgeAdapter.mjs";
32
+ import { domError as $ } from "../localFiles/adapters/WorkspaceFileAdapter.mjs";
33
+ import { SANDBOX_PROTOCOL as ne } from "../localFiles/host/protocol.mjs";
34
+ import { cancelledError as T, workspaceNotGranted as oe, ToolError as u, ToolCode as a, toToolError as re } from "../localFiles/errors.mjs";
35
+ import { validateToolInput as ie } from "../localFiles/validate.mjs";
36
+ import { BrowserCommandRunner as se } from "./browserRuntime/BrowserCommandRunner.mjs";
37
37
  import { withOutputLimit as L } from "./command.mjs";
38
- import { BUILTIN_FUNCTION_CODES as se, SHELL_CWD as le } from "./constants.mjs";
39
- import { BUILTIN_TOOL_SCHEMAS as ae } from "./schemas.mjs";
40
- import { shell as de, readFile as ce, writeFile as me, appendFile as ue, runFile as fe, editFile as ge, grep as he, find as _e, loadSkill as be, readSkillResource as ye, runSkillScript as xe } from "./tools.mjs";
41
- const Te = {
42
- shell: de,
43
- read_file: ce,
44
- write_file: me,
45
- append_file: ue,
46
- run_file: fe,
47
- edit_file: ge,
48
- grep: he,
49
- find: _e,
50
- load_skill: be,
51
- read_skill_resource: ye,
52
- run_skill_script: xe
53
- }, x = new ee("[BuiltinTools] "), j = /* @__PURE__ */ new Set(["shell", "run_file", "run_skill_script"]);
54
- function we(e, t, n) {
55
- var a, m;
38
+ import { BUILTIN_FUNCTION_CODES as le, SHELL_CWD as ae } from "./constants.mjs";
39
+ import { BUILTIN_TOOL_SCHEMAS as de } from "./schemas.mjs";
40
+ import { shell as ce, readFile as me, writeFile as ue, appendFile as fe, runFile as ge, editFile as he, grep as _e, find as be, loadSkill as ye, readSkillResource as xe, listSkillFiles as Te, grepSkill as we, runSkillScript as Ie } from "./tools.mjs";
41
+ const pe = {
42
+ shell: ce,
43
+ read_file: me,
44
+ write_file: ue,
45
+ append_file: fe,
46
+ run_file: ge,
47
+ edit_file: he,
48
+ grep: _e,
49
+ find: be,
50
+ load_skill: ye,
51
+ read_skill_resource: xe,
52
+ list_skill_files: Te,
53
+ grep_skill: we,
54
+ run_skill_script: Ie
55
+ }, x = new te("[BuiltinTools] "), S = /* @__PURE__ */ new Set(["shell", "run_file", "run_skill_script"]);
56
+ function Ee(e, t, n) {
57
+ var r, m;
56
58
  if (e.commandRunner)
57
59
  return L(e.commandRunner);
58
- if (t instanceof H) {
60
+ if (t instanceof V) {
59
61
  if (t.protocolMismatch) {
60
- const d = `${(a = t.sandboxVersion) != null ? a : ""}@${(m = t.sandboxProtocol) != null ? m : ""}`;
62
+ const d = `${(r = t.sandboxVersion) != null ? r : ""}@${(m = t.sandboxProtocol) != null ? m : ""}`;
61
63
  n.rejectedSandbox !== d && (n.rejectedSandbox = d, x.error("sandbox-protocol", {
62
64
  sandboxVersion: t.sandboxVersion,
63
65
  sandboxProtocol: t.sandboxProtocol,
64
- supported: te
66
+ supported: ne
65
67
  }));
66
68
  }
67
69
  if (!t.canExec) {
68
70
  const d = t.unavailableMessage();
69
71
  return {
70
- exec: () => Promise.reject(V("NotAllowedError", d))
72
+ exec: () => Promise.reject($("NotAllowedError", d))
71
73
  };
72
74
  }
73
75
  return {
@@ -75,21 +77,21 @@ function we(e, t, n) {
75
77
  };
76
78
  }
77
79
  if (e.browserRuntime.enabled)
78
- return (n.adapter !== t || !n.runner) && (n.adapter = t, n.runner = L(new ie({
80
+ return (n.adapter !== t || !n.runner) && (n.adapter = t, n.runner = L(new se({
79
81
  adapter: t,
80
82
  sensitive: e.sensitive,
81
83
  moduleURL: e.browserRuntime.bashModuleURL,
82
84
  pyodideIndexURL: e.browserRuntime.pyodideIndexURL
83
85
  }))), n.runner;
84
86
  }
85
- function Ie(e, t) {
87
+ function Oe(e, t) {
86
88
  if (e.commandRunner)
87
89
  return L(e.commandRunner);
88
- if (t instanceof H) {
90
+ if (t instanceof V) {
89
91
  if (!t.canExec) {
90
92
  const n = t.unavailableMessage();
91
93
  return {
92
- exec: () => Promise.reject(V("NotAllowedError", n))
94
+ exec: () => Promise.reject($("NotAllowedError", n))
93
95
  };
94
96
  }
95
97
  return {
@@ -97,68 +99,68 @@ function Ie(e, t) {
97
99
  };
98
100
  }
99
101
  }
100
- function Ee(e) {
102
+ function Re(e) {
101
103
  if (typeof e != "string")
102
104
  return e;
103
105
  try {
104
106
  return JSON.parse(e);
105
107
  } catch (t) {
106
- throw new u(l.BadRequest, "参数不是合法的 JSON 对象。");
108
+ throw new u(a.BadRequest, "参数不是合法的 JSON 对象。");
107
109
  }
108
110
  }
109
- function Oe(e) {
111
+ function Se(e) {
110
112
  const t = e instanceof DOMException ? e.name : "", n = e instanceof Error ? e.message : "";
111
113
  if (t === "NotFoundError")
112
- return new u(l.NotFound, "脚本或目录不存在。");
114
+ return new u(a.NotFound, "脚本或目录不存在。");
113
115
  if (t === "SecurityError")
114
- return new u(l.Forbidden, "命令路径不在工作区内。");
116
+ return new u(a.Forbidden, "命令路径不在工作区内。");
115
117
  if (t === "AbortError")
116
- return n.includes("超时") ? new u(l.Timeout, "命令运行超时,已中止。") : n.includes("已有") || n.includes("上限") ? new u(l.TooManyRequests, n) : T();
118
+ return n.includes("超时") ? new u(a.Timeout, "命令运行超时,已中止。") : n.includes("已有") || n.includes("上限") ? new u(a.TooManyRequests, n) : T();
117
119
  if (t === "NotAllowedError")
118
- return n.startsWith("沙箱") ? new u(l.NotImplemented, n) : new u(l.NotImplemented, "当前环境不能执行命令或脚本,需要端侧宿主。");
120
+ return n.startsWith("沙箱") ? new u(a.NotImplemented, n) : new u(a.NotImplemented, "当前环境不能执行命令或脚本,需要端侧宿主。");
119
121
  }
120
- function Re(e) {
122
+ function Le(e) {
121
123
  return new Promise((t, n) => {
122
124
  e.aborted && n(T()), e.addEventListener("abort", () => n(T()), {
123
125
  once: !0
124
126
  });
125
127
  });
126
128
  }
127
- function $(e, t = 160) {
129
+ function k(e, t = 160) {
128
130
  return e.length > t ? `${e.slice(0, t)}…` : e;
129
131
  }
130
- function pe(e) {
132
+ function Ne(e) {
131
133
  const t = {};
132
134
  for (const n of ["path", "skill_name", "resource_name", "script_name", "pattern", "name"])
133
135
  typeof e[n] == "string" && (t[n] = e[n]);
134
- return typeof e.command == "string" && (t.command = $(e.command)), typeof e.start_line == "number" && (t.start_line = e.start_line), typeof e.end_line == "number" && (t.end_line = e.end_line), typeof e.content == "string" && (t.contentLength = e.content.length), typeof e.old_text == "string" && (t.oldTextLength = e.old_text.length), typeof e.new_text == "string" && (t.newTextLength = e.new_text.length), Array.isArray(e.args) && (t.argCount = e.args.length), t;
136
+ return typeof e.command == "string" && (t.command = k(e.command)), typeof e.start_line == "number" && (t.start_line = e.start_line), typeof e.end_line == "number" && (t.end_line = e.end_line), typeof e.content == "string" && (t.contentLength = e.content.length), typeof e.old_text == "string" && (t.oldTextLength = e.old_text.length), typeof e.new_text == "string" && (t.newTextLength = e.new_text.length), Array.isArray(e.args) && (t.argCount = e.args.length), t;
135
137
  }
136
- function Le(e) {
137
- return s({
138
+ function Me(e) {
139
+ return l({
138
140
  code: e.code,
139
141
  message: e.message
140
142
  }, e.data ? {
141
143
  data: e.data
142
144
  } : {});
143
145
  }
144
- function Ve({
146
+ function Je({
145
147
  pluginCode: e,
146
148
  workspace: t
147
149
  }) {
148
- const n = /* @__PURE__ */ new Map(), a = {}, m = {};
149
- return se.forEach((d) => {
150
+ const n = /* @__PURE__ */ new Map(), r = {}, m = {};
151
+ return le.forEach((d) => {
150
152
  m[d] = (f, c, o) => {
151
- let r = !1;
152
- Se(t, n, a, d, f, (p) => {
153
- if (!r) {
154
- r = !0;
153
+ let i = !1;
154
+ Fe(t, n, r, d, f, (I) => {
155
+ if (!i) {
156
+ i = !0;
155
157
  try {
156
- c(p);
157
- } catch (I) {
158
- console.error("[BuiltinTools] callback failed", I);
158
+ c(I);
159
+ } catch (R) {
160
+ console.error("[BuiltinTools] callback failed", R);
159
161
  }
160
162
  }
161
- }, _(s({}, o), {
163
+ }, _(l({}, o), {
162
164
  pluginCode: e
163
165
  }));
164
166
  };
@@ -166,97 +168,97 @@ function Ve({
166
168
  [e]: m
167
169
  };
168
170
  }
169
- function Se(e, t, n, a, m, d, f) {
170
- return U(this, null, function* () {
171
- var N, M, F, A, v;
171
+ function Fe(e, t, n, r, m, d, f) {
172
+ return H(this, null, function* () {
173
+ var F, A, v, q, B;
172
174
  const c = {
173
- requestId: f.requestId || k(),
175
+ requestId: f.requestId || ee(),
174
176
  applicationId: f.applicationId || e.applicationId,
175
177
  sessionId: f.sessionId || "",
176
178
  pluginCode: f.pluginCode,
177
- functionCode: a,
179
+ functionCode: r,
178
180
  signal: f.signal
179
181
  }, o = {
180
182
  requestId: c.requestId,
181
183
  sessionId: c.sessionId,
182
- functionCode: a
183
- }, r = new AbortController();
184
+ functionCode: r
185
+ }, i = new AbortController();
184
186
  let w = !1;
185
- const p = setTimeout(() => {
186
- w = !0, r.abort();
187
- }, e.limits.toolTimeoutMs), I = () => r.abort();
188
- (N = c.signal) == null || N.addEventListener("abort", I, {
187
+ const I = S.has(r) ? e.limits.commandTimeoutMs : e.limits.toolTimeoutMs, R = setTimeout(() => {
188
+ w = !0, i.abort();
189
+ }, I), N = () => i.abort();
190
+ (F = c.signal) == null || F.addEventListener("abort", N, {
189
191
  once: !0
190
- }), (M = c.signal) != null && M.aborted && r.abort();
191
- let b = null, y = null, E;
192
- const S = Date.now();
192
+ }), (A = c.signal) != null && A.aborted && i.abort();
193
+ let b = null, y = null, p;
194
+ const M = Date.now();
193
195
  try {
194
- const O = Ee(m), i = re(O, ae[a].parameters);
195
- if (typeof i.path == "string" && (o.path = i.path), x.log("start", s(s({}, o), pe(i))), yield e.ready, r.signal.aborted)
196
+ const E = Re(m), s = ie(E, de[r].parameters);
197
+ if (typeof s.path == "string" && (o.path = s.path), x.log("start", l(l({}, o), Ne(s))), yield e.ready, i.signal.aborted)
196
198
  throw T();
197
199
  const g = e.adapter;
198
200
  if (!g)
199
- throw ne();
200
- if (j.has(a)) {
201
+ throw oe();
202
+ if (S.has(r)) {
201
203
  if (y = e.acquireCommand(), !y)
202
- throw new u(l.TooManyRequests, "已有一个命令在运行,请等它结束后再试。");
204
+ throw new u(a.TooManyRequests, "已有一个命令在运行,请等它结束后再试。");
203
205
  } else if (b = e.acquireSlot(), !b)
204
- throw new u(l.TooManyRequests, "同时进行的文件操作过多,请稍后重试。");
205
- E = e.track(r), e.emit("tool:start", s({}, o));
206
- const q = c.sessionId || "default";
207
- let h = t.get(q);
206
+ throw new u(a.TooManyRequests, "同时进行的文件操作过多,请稍后重试。");
207
+ p = e.track(i), e.emit("tool:start", l({}, o));
208
+ const P = c.sessionId || "default";
209
+ let h = t.get(P);
208
210
  h || (h = {
209
- cwd: le
210
- }, t.set(q, h));
211
- const J = we(e, g, n), W = h.cwd, z = {
211
+ cwd: ae
212
+ }, t.set(P, h));
213
+ const J = Ee(e, g, n), W = h.cwd, z = {
212
214
  adapter: g,
213
215
  runner: J,
214
- signal: r.signal,
215
- timeoutMs: e.limits.toolTimeoutMs,
216
+ signal: i.signal,
217
+ timeoutMs: I,
216
218
  shellCwd: h,
217
219
  skills: e.platformSkills,
218
- skillRunner: Ie(e, g)
219
- }, R = yield Promise.race([Te[a](i, z), Re(r.signal)]), B = {
220
- code: l.Ok,
220
+ skillRunner: Oe(e, g)
221
+ }, O = yield Promise.race([pe[r](s, z), Le(i.signal)]), D = {
222
+ code: a.Ok,
221
223
  message: "ok",
222
- data: R.data
224
+ data: O.data
223
225
  };
224
- R.truncated && (B.truncated = !0);
225
- const G = Date.now() - S, P = R.data.exitCode;
226
- x.log("finish", s(s(s(_(s({}, o), {
226
+ O.truncated && (D.truncated = !0);
227
+ const G = Date.now() - M, U = O.data.exitCode;
228
+ x.log("finish", l(l(l(_(l({}, o), {
227
229
  elapsedMs: G,
228
- code: l.Ok
229
- }), R.truncated ? {
230
+ code: a.Ok
231
+ }), O.truncated ? {
230
232
  truncated: !0
231
- } : {}), typeof P == "number" ? {
232
- exitCode: P
233
- } : {}), a === "shell" ? {
233
+ } : {}), typeof U == "number" ? {
234
+ exitCode: U
235
+ } : {}), r === "shell" ? {
234
236
  cwd: h.cwd,
235
237
  cwdChanged: h.cwd !== W
236
- } : {})), e.emit("tool:finish", _(s({}, o), {
237
- code: l.Ok
238
- })), j.has(a) && e.notifyFilesChanged(), d(B);
239
- } catch (O) {
240
- let i = (F = Oe(O)) != null ? F : oe(O);
241
- w ? i = new u(l.Timeout, "操作超时,已中止。") : r.signal.aborted && i.code !== l.Cancelled && (i = T());
242
- const g = Date.now() - S;
243
- i.code === l.Cancelled ? (x.log("cancelled", _(s({}, o), {
238
+ } : {})), e.emit("tool:finish", _(l({}, o), {
239
+ code: a.Ok
240
+ })), S.has(r) && e.notifyFilesChanged(), d(D);
241
+ } catch (E) {
242
+ let s = (v = Se(E)) != null ? v : re(E);
243
+ w ? s = new u(a.Timeout, "操作超时,已中止。") : i.signal.aborted && s.code !== a.Cancelled && (s = T());
244
+ const g = Date.now() - M;
245
+ s.code === a.Cancelled ? (x.log("cancelled", _(l({}, o), {
244
246
  elapsedMs: g,
245
247
  timedOut: w
246
- })), e.emit("tool:cancelled", s({}, o))) : (x.error("error", _(s({}, o), {
248
+ })), e.emit("tool:cancelled", l({}, o))) : (x.error("error", _(l({}, o), {
247
249
  elapsedMs: g,
248
- code: i.code,
249
- message: $(i.message, 300)
250
- })), e.emit("tool:error", _(s({}, o), {
251
- code: i.code,
252
- message: i.message,
253
- reason: (A = i.data) == null ? void 0 : A.reason
254
- }))), d(Le(i));
250
+ code: s.code,
251
+ message: k(s.message, 300)
252
+ })), e.emit("tool:error", _(l({}, o), {
253
+ code: s.code,
254
+ message: s.message,
255
+ reason: (q = s.data) == null ? void 0 : q.reason
256
+ }))), d(Me(s));
255
257
  } finally {
256
- clearTimeout(p), (v = c.signal) == null || v.removeEventListener("abort", I), b == null || b(), y == null || y(), E == null || E();
258
+ clearTimeout(R), (B = c.signal) == null || B.removeEventListener("abort", N), b == null || b(), y == null || y(), p == null || p();
257
259
  }
258
260
  });
259
261
  }
260
262
  export {
261
- Ve as createBuiltinToolsPlugin
263
+ Je as createBuiltinToolsPlugin
262
264
  };