@glodon-aiot/bot-client-sdk 3.26.0-alpha.24 → 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 +12 -7
- package/dist/es/builtinTools/constants.mjs +12 -5
- package/dist/es/builtinTools/createBuiltinToolsPlugin.mjs +127 -125
- package/dist/es/builtinTools/platformSkills.mjs +96 -84
- package/dist/es/builtinTools/schemas.mjs +49 -4
- package/dist/es/builtinTools/tools.mjs +280 -179
- package/dist/es/localFiles/constants.mjs +10 -9
- package/dist/es/localFiles/host/sandboxClient.mjs +33 -8
- package/dist/es/package.json.mjs +2 -2
- package/dist/lib/index.js +45 -42
- package/dist/src/builtinTools/constants.d.ts +10 -2
- package/dist/src/builtinTools/platformSkills.d.ts +4 -0
- package/dist/src/builtinTools/tools.d.ts +9 -0
- package/dist/src/localFiles/constants.d.ts +2 -0
- package/dist/src/localFiles/host/sandboxClient.d.ts +2 -0
- package/package.json +2 -2
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` / `
|
|
265
|
+
**`run_file`** 执行已存在的脚本。浏览器:`.py`(Pyodide)、`.sh` / `.bash`(just-bash);`.js` / `.mjs` / `.cjs` 走 `node`,浏览器里明确不支持。宿主沙箱:`.js`、`.mjs`、`.cjs` 都交给沙箱自带的 Node。
|
|
264
266
|
|
|
265
|
-
**`load_skill`** 读取编排里该技能已发布版本的 `SKILL.md
|
|
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
|
|
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
|
-
|
|
10
|
+
s as BUILTIN_FUNCTION_CODES,
|
|
4
11
|
l as MAX_COMMAND_CHARS,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
o as
|
|
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
|
|
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) &&
|
|
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) &&
|
|
10
|
+
Z.call(t, n) && j(e, n, t[n]);
|
|
11
11
|
return e;
|
|
12
12
|
}, _ = (e, t) => X(e, Q(t));
|
|
13
|
-
var
|
|
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 (
|
|
18
|
-
m(
|
|
17
|
+
} catch (i) {
|
|
18
|
+
m(i);
|
|
19
19
|
}
|
|
20
20
|
}, f = (o) => {
|
|
21
21
|
try {
|
|
22
22
|
c(n.throw(o));
|
|
23
|
-
} catch (
|
|
24
|
-
m(
|
|
23
|
+
} catch (i) {
|
|
24
|
+
m(i);
|
|
25
25
|
}
|
|
26
|
-
}, c = (o) => o.done ?
|
|
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
|
|
30
|
-
import
|
|
31
|
-
import { HostBridgeAdapter as
|
|
32
|
-
import { domError as
|
|
33
|
-
import { SANDBOX_PROTOCOL as
|
|
34
|
-
import { cancelledError as T, workspaceNotGranted as
|
|
35
|
-
import { validateToolInput as
|
|
36
|
-
import { BrowserCommandRunner as
|
|
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
|
|
39
|
-
import { BUILTIN_TOOL_SCHEMAS as
|
|
40
|
-
import { shell as
|
|
41
|
-
const
|
|
42
|
-
shell:
|
|
43
|
-
read_file:
|
|
44
|
-
write_file:
|
|
45
|
-
append_file:
|
|
46
|
-
run_file:
|
|
47
|
-
edit_file:
|
|
48
|
-
grep:
|
|
49
|
-
find:
|
|
50
|
-
load_skill:
|
|
51
|
-
read_skill_resource:
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
|
60
|
+
if (t instanceof V) {
|
|
59
61
|
if (t.protocolMismatch) {
|
|
60
|
-
const d = `${(
|
|
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:
|
|
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(
|
|
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
|
|
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
|
|
87
|
+
function Oe(e, t) {
|
|
86
88
|
if (e.commandRunner)
|
|
87
89
|
return L(e.commandRunner);
|
|
88
|
-
if (t instanceof
|
|
90
|
+
if (t instanceof V) {
|
|
89
91
|
if (!t.canExec) {
|
|
90
92
|
const n = t.unavailableMessage();
|
|
91
93
|
return {
|
|
92
|
-
exec: () => Promise.reject(
|
|
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
|
|
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(
|
|
108
|
+
throw new u(a.BadRequest, "参数不是合法的 JSON 对象。");
|
|
107
109
|
}
|
|
108
110
|
}
|
|
109
|
-
function
|
|
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(
|
|
114
|
+
return new u(a.NotFound, "脚本或目录不存在。");
|
|
113
115
|
if (t === "SecurityError")
|
|
114
|
-
return new u(
|
|
116
|
+
return new u(a.Forbidden, "命令路径不在工作区内。");
|
|
115
117
|
if (t === "AbortError")
|
|
116
|
-
return n.includes("超时") ? new u(
|
|
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(
|
|
120
|
+
return n.startsWith("沙箱") ? new u(a.NotImplemented, n) : new u(a.NotImplemented, "当前环境不能执行命令或脚本,需要端侧宿主。");
|
|
119
121
|
}
|
|
120
|
-
function
|
|
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
|
|
129
|
+
function k(e, t = 160) {
|
|
128
130
|
return e.length > t ? `${e.slice(0, t)}…` : e;
|
|
129
131
|
}
|
|
130
|
-
function
|
|
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 =
|
|
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
|
|
137
|
-
return
|
|
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
|
|
146
|
+
function Je({
|
|
145
147
|
pluginCode: e,
|
|
146
148
|
workspace: t
|
|
147
149
|
}) {
|
|
148
|
-
const n = /* @__PURE__ */ new Map(),
|
|
149
|
-
return
|
|
150
|
+
const n = /* @__PURE__ */ new Map(), r = {}, m = {};
|
|
151
|
+
return le.forEach((d) => {
|
|
150
152
|
m[d] = (f, c, o) => {
|
|
151
|
-
let
|
|
152
|
-
|
|
153
|
-
if (!
|
|
154
|
-
|
|
153
|
+
let i = !1;
|
|
154
|
+
Fe(t, n, r, d, f, (I) => {
|
|
155
|
+
if (!i) {
|
|
156
|
+
i = !0;
|
|
155
157
|
try {
|
|
156
|
-
c(
|
|
157
|
-
} catch (
|
|
158
|
-
console.error("[BuiltinTools] callback failed",
|
|
158
|
+
c(I);
|
|
159
|
+
} catch (R) {
|
|
160
|
+
console.error("[BuiltinTools] callback failed", R);
|
|
159
161
|
}
|
|
160
162
|
}
|
|
161
|
-
}, _(
|
|
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
|
|
170
|
-
return
|
|
171
|
-
var
|
|
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 ||
|
|
175
|
+
requestId: f.requestId || ee(),
|
|
174
176
|
applicationId: f.applicationId || e.applicationId,
|
|
175
177
|
sessionId: f.sessionId || "",
|
|
176
178
|
pluginCode: f.pluginCode,
|
|
177
|
-
functionCode:
|
|
179
|
+
functionCode: r,
|
|
178
180
|
signal: f.signal
|
|
179
181
|
}, o = {
|
|
180
182
|
requestId: c.requestId,
|
|
181
183
|
sessionId: c.sessionId,
|
|
182
|
-
functionCode:
|
|
183
|
-
},
|
|
184
|
+
functionCode: r
|
|
185
|
+
}, i = new AbortController();
|
|
184
186
|
let w = !1;
|
|
185
|
-
const
|
|
186
|
-
w = !0,
|
|
187
|
-
},
|
|
188
|
-
(
|
|
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
|
-
}), (
|
|
191
|
-
let b = null, y = null,
|
|
192
|
-
const
|
|
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
|
|
195
|
-
if (typeof
|
|
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
|
|
200
|
-
if (
|
|
201
|
+
throw oe();
|
|
202
|
+
if (S.has(r)) {
|
|
201
203
|
if (y = e.acquireCommand(), !y)
|
|
202
|
-
throw new u(
|
|
204
|
+
throw new u(a.TooManyRequests, "已有一个命令在运行,请等它结束后再试。");
|
|
203
205
|
} else if (b = e.acquireSlot(), !b)
|
|
204
|
-
throw new u(
|
|
205
|
-
|
|
206
|
-
const
|
|
207
|
-
let h = t.get(
|
|
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:
|
|
210
|
-
}, t.set(
|
|
211
|
-
const J =
|
|
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:
|
|
215
|
-
timeoutMs:
|
|
216
|
+
signal: i.signal,
|
|
217
|
+
timeoutMs: I,
|
|
216
218
|
shellCwd: h,
|
|
217
219
|
skills: e.platformSkills,
|
|
218
|
-
skillRunner:
|
|
219
|
-
},
|
|
220
|
-
code:
|
|
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:
|
|
224
|
+
data: O.data
|
|
223
225
|
};
|
|
224
|
-
|
|
225
|
-
const G = Date.now() -
|
|
226
|
-
x.log("finish",
|
|
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:
|
|
229
|
-
}),
|
|
230
|
+
code: a.Ok
|
|
231
|
+
}), O.truncated ? {
|
|
230
232
|
truncated: !0
|
|
231
|
-
} : {}), typeof
|
|
232
|
-
exitCode:
|
|
233
|
-
} : {}),
|
|
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", _(
|
|
237
|
-
code:
|
|
238
|
-
})),
|
|
239
|
-
} catch (
|
|
240
|
-
let
|
|
241
|
-
w ?
|
|
242
|
-
const g = Date.now() -
|
|
243
|
-
|
|
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",
|
|
248
|
+
})), e.emit("tool:cancelled", l({}, o))) : (x.error("error", _(l({}, o), {
|
|
247
249
|
elapsedMs: g,
|
|
248
|
-
code:
|
|
249
|
-
message:
|
|
250
|
-
})), e.emit("tool:error", _(
|
|
251
|
-
code:
|
|
252
|
-
message:
|
|
253
|
-
reason: (
|
|
254
|
-
}))), d(
|
|
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(
|
|
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
|
-
|
|
263
|
+
Je as createBuiltinToolsPlugin
|
|
262
264
|
};
|