@glodon-aiot/bot-client-sdk 3.26.0-alpha.4 → 3.26.0-alpha.5
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 +105 -76
- package/dist/es/Config.mjs +63 -85
- package/dist/es/builtinTools/browserRuntime/BrowserCommandRunner.mjs +201 -0
- package/dist/es/builtinTools/browserRuntime/PythonRunner.mjs +356 -0
- package/dist/es/builtinTools/browserRuntime/WorkspaceBashFs.mjs +350 -0
- package/dist/es/builtinTools/browserRuntime/assets.mjs +9 -0
- package/dist/es/builtinTools/browserRuntime/loadBash.mjs +17 -0
- package/dist/es/builtinTools/browserRuntime/pyodideRunner.py.mjs +96 -0
- package/dist/es/builtinTools/browserRuntime/pyodideWorker.mjs +242 -0
- package/dist/es/builtinTools/command.mjs +56 -0
- package/dist/es/builtinTools/constants.mjs +10 -0
- package/dist/es/builtinTools/createBuiltinToolsPlugin.mjs +236 -0
- package/dist/es/builtinTools/overview.mjs +77 -0
- package/dist/es/builtinTools/paths.mjs +63 -0
- package/dist/es/builtinTools/schemas.mjs +216 -0
- package/dist/es/builtinTools/tools.mjs +471 -0
- package/dist/es/index.mjs +49 -48
- package/dist/es/localFiles/adapters/FileSystemAccessAdapter.mjs +193 -103
- package/dist/es/localFiles/adapters/HostBridgeAdapter.mjs +138 -77
- package/dist/es/localFiles/adapters/MemoryWorkspaceAdapter.mjs +132 -97
- package/dist/es/localFiles/adapters/WorkspaceFileAdapter.mjs +32 -28
- package/dist/es/localFiles/constants.mjs +1 -1
- package/dist/es/localFiles/host/connectHostBridge.mjs +22 -18
- package/dist/es/localFiles/host/protocol.mjs +6 -5
- package/dist/es/localFiles/schemas.mjs +45 -60
- package/dist/es/localFiles/validate.mjs +37 -37
- package/dist/es/localFiles/workspace/LocalWorkspace.mjs +71 -52
- package/dist/es/package.json.mjs +33 -27
- package/dist/lib/index.js +372 -9
- package/dist/src/Config.d.ts +2 -2
- package/dist/src/builtinTools/browserRuntime/BrowserCommandRunner.d.ts +26 -0
- package/dist/src/builtinTools/browserRuntime/PythonRunner.d.ts +67 -0
- package/dist/src/builtinTools/browserRuntime/WorkspaceBashFs.d.ts +51 -0
- package/dist/src/builtinTools/browserRuntime/assets.d.ts +13 -0
- package/dist/src/builtinTools/browserRuntime/loadBash.d.ts +3 -0
- package/dist/src/builtinTools/browserRuntime/pyodideWorker.d.ts +44 -0
- package/dist/src/builtinTools/command.d.ts +26 -0
- package/dist/src/builtinTools/constants.d.ts +17 -0
- package/dist/src/builtinTools/createBuiltinToolsPlugin.d.ts +11 -0
- package/dist/src/builtinTools/overview.d.ts +5 -0
- package/dist/src/builtinTools/paths.d.ts +15 -0
- package/dist/src/builtinTools/schemas.d.ts +3 -0
- package/dist/src/builtinTools/tools.d.ts +60 -0
- package/dist/src/localFiles/adapters/FileSystemAccessAdapter.d.ts +4 -1
- package/dist/src/localFiles/adapters/HostBridgeAdapter.d.ts +20 -1
- package/dist/src/localFiles/adapters/MemoryWorkspaceAdapter.d.ts +4 -1
- package/dist/src/localFiles/adapters/WorkspaceFileAdapter.d.ts +14 -0
- package/dist/src/localFiles/adapters/fsaTypes.d.ts +2 -0
- package/dist/src/localFiles/constants.d.ts +2 -1
- package/dist/src/localFiles/host/protocol.d.ts +13 -0
- package/dist/src/localFiles/index.d.ts +3 -2
- package/dist/src/localFiles/schemas.d.ts +2 -3
- package/dist/src/localFiles/types.d.ts +14 -1
- package/dist/src/localFiles/workspace/LocalWorkspace.d.ts +12 -0
- package/package.json +8 -2
- package/dist/es/localFiles/createLocalPythonPlugin.mjs +0 -196
|
@@ -1,50 +1,54 @@
|
|
|
1
|
-
var
|
|
1
|
+
var a = (n, e) => {
|
|
2
2
|
if (e = Symbol[n])
|
|
3
3
|
return e;
|
|
4
4
|
throw Error("Symbol." + n + " is not defined");
|
|
5
5
|
};
|
|
6
|
-
var
|
|
6
|
+
var x = function(n, e) {
|
|
7
7
|
this[0] = n, this[1] = e;
|
|
8
|
-
},
|
|
9
|
-
var d = (t, f,
|
|
8
|
+
}, E = (n, e, y) => {
|
|
9
|
+
var d = (t, f, o, l) => {
|
|
10
10
|
try {
|
|
11
|
-
var
|
|
12
|
-
Promise.resolve(
|
|
13
|
-
} catch (
|
|
14
|
-
|
|
11
|
+
var c = y[t](f), p = (f = c.value) instanceof x, u = c.done;
|
|
12
|
+
Promise.resolve(p ? f[0] : f).then((s) => p ? d(t === "return" ? t : "next", f[1] ? { done: s.done, value: s.value } : s, o, l) : o({ value: s, done: u })).catch((s) => d("throw", s, o, l));
|
|
13
|
+
} catch (s) {
|
|
14
|
+
l(s);
|
|
15
15
|
}
|
|
16
|
-
},
|
|
17
|
-
return
|
|
18
|
-
},
|
|
19
|
-
var e = n[
|
|
20
|
-
return e == null ? (e = n[
|
|
21
|
-
if (
|
|
22
|
-
if (
|
|
16
|
+
}, r = (t) => i[t] = (f) => new Promise((o, l) => d(t, f, o, l)), i = {};
|
|
17
|
+
return y = y.apply(n, e), i[Symbol.asyncIterator] = () => i, r("next"), r("throw"), r("return"), i;
|
|
18
|
+
}, h = (n) => {
|
|
19
|
+
var e = n[a("asyncIterator")], y = !1, d, r = {};
|
|
20
|
+
return e == null ? (e = n[a("iterator")](), d = (i) => r[i] = (t) => e[i](t)) : (e = e.call(n), d = (i) => r[i] = (t) => {
|
|
21
|
+
if (y) {
|
|
22
|
+
if (y = !1, i === "throw")
|
|
23
23
|
throw t;
|
|
24
24
|
return t;
|
|
25
25
|
}
|
|
26
|
-
return
|
|
26
|
+
return y = !0, {
|
|
27
27
|
done: !1,
|
|
28
|
-
value: new
|
|
29
|
-
var
|
|
30
|
-
if (!(
|
|
28
|
+
value: new x(new Promise((f) => {
|
|
29
|
+
var o = e[i](t);
|
|
30
|
+
if (!(o instanceof Object))
|
|
31
31
|
throw TypeError("Object expected");
|
|
32
|
-
f(
|
|
32
|
+
f(o);
|
|
33
33
|
}), 1)
|
|
34
34
|
};
|
|
35
|
-
}),
|
|
35
|
+
}), r[a("iterator")] = () => r, d("next"), "throw" in e ? d("throw") : r.throw = (i) => {
|
|
36
36
|
throw i;
|
|
37
|
-
}, "return" in e && d("return"),
|
|
37
|
+
}, "return" in e && d("return"), r;
|
|
38
38
|
};
|
|
39
|
-
function
|
|
39
|
+
function O(n, e) {
|
|
40
|
+
return e === n || e.startsWith(`${n}/`);
|
|
41
|
+
}
|
|
42
|
+
function g(n, e = n) {
|
|
40
43
|
return new DOMException(e, n);
|
|
41
44
|
}
|
|
42
|
-
function
|
|
43
|
-
return
|
|
44
|
-
typeof n == "string" ? yield new TextEncoder().encode(n) : n instanceof Uint8Array ? yield n : yield*
|
|
45
|
+
function k(n) {
|
|
46
|
+
return E(this, null, function* () {
|
|
47
|
+
typeof n == "string" ? yield new TextEncoder().encode(n) : n instanceof Uint8Array ? yield n : yield* h(n);
|
|
45
48
|
});
|
|
46
49
|
}
|
|
47
50
|
export {
|
|
48
|
-
|
|
49
|
-
|
|
51
|
+
g as domError,
|
|
52
|
+
O as isSameOrInside,
|
|
53
|
+
k as toChunks
|
|
50
54
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const s = ["list_directory", "read_file", "stat_file", "search_files", "search_text", "apply_patch", "write_file", "upload_file", "download_file"], _ = "
|
|
1
|
+
const s = ["list_directory", "read_file", "stat_file", "search_files", "search_text", "apply_patch", "write_file", "upload_file", "download_file"], _ = "builtin_tools", t = {
|
|
2
2
|
dev: _,
|
|
3
3
|
test: _,
|
|
4
4
|
prod: _,
|
|
@@ -1,27 +1,30 @@
|
|
|
1
1
|
import { HostBridgeAdapter as f } from "../adapters/HostBridgeAdapter.mjs";
|
|
2
|
-
import { getHostWebView as
|
|
2
|
+
import { getHostWebView as y, HOST_CHANNEL as p, parseHostMessage as m } from "./protocol.mjs";
|
|
3
3
|
let t;
|
|
4
|
-
function
|
|
4
|
+
function u(s) {
|
|
5
5
|
t == null || t(), t = void 0;
|
|
6
|
-
const
|
|
7
|
-
if (!
|
|
6
|
+
const o = y();
|
|
7
|
+
if (!o)
|
|
8
8
|
return () => {
|
|
9
9
|
};
|
|
10
|
-
const
|
|
11
|
-
const e =
|
|
10
|
+
const i = new f(o), d = (g) => {
|
|
11
|
+
const e = m(g.data);
|
|
12
12
|
if (e) {
|
|
13
13
|
if (e.type === "workspace") {
|
|
14
|
-
const
|
|
15
|
-
|
|
14
|
+
const a = e.granted === !0, r = typeof e.displayName == "string" ? e.displayName : "";
|
|
15
|
+
i.setCapabilities(e.capabilities, {
|
|
16
|
+
version: e.sandboxVersion,
|
|
17
|
+
protocol: e.sandboxProtocol
|
|
18
|
+
}), a ? (i.displayName = r || "工程目录", (s.status !== "granted" || s.displayName !== i.displayName) && s.attachAdapter(i, i.displayName)) : s.status === "granted" && s.clear();
|
|
16
19
|
return;
|
|
17
20
|
}
|
|
18
21
|
if (e.type === "fs-changed") {
|
|
19
|
-
const
|
|
20
|
-
s.notifyFilesChanged(
|
|
22
|
+
const a = Array.isArray(e.paths) ? e.paths.filter((r) => typeof r == "string") : [];
|
|
23
|
+
s.notifyFilesChanged(a);
|
|
21
24
|
return;
|
|
22
25
|
}
|
|
23
|
-
typeof e.id == "string" &&
|
|
24
|
-
channel:
|
|
26
|
+
typeof e.id == "string" && i.settle({
|
|
27
|
+
channel: p,
|
|
25
28
|
id: e.id,
|
|
26
29
|
ok: e.ok !== !1,
|
|
27
30
|
name: typeof e.name == "string" ? e.name : void 0,
|
|
@@ -32,19 +35,20 @@ function c(s) {
|
|
|
32
35
|
timedOut: e.timedOut === !0,
|
|
33
36
|
stdout: typeof e.stdout == "string" ? e.stdout : void 0,
|
|
34
37
|
stderr: typeof e.stderr == "string" ? e.stderr : void 0,
|
|
38
|
+
cwd: typeof e.cwd == "string" ? e.cwd : void 0,
|
|
35
39
|
message: typeof e.message == "string" ? e.message : void 0
|
|
36
40
|
});
|
|
37
41
|
}
|
|
38
42
|
};
|
|
39
|
-
|
|
40
|
-
channel:
|
|
43
|
+
o.addEventListener("message", d), o.postMessage({
|
|
44
|
+
channel: p,
|
|
41
45
|
type: "hello"
|
|
42
46
|
});
|
|
43
|
-
const
|
|
44
|
-
|
|
47
|
+
const n = () => {
|
|
48
|
+
o.removeEventListener("message", d), t === n && (t = void 0);
|
|
45
49
|
};
|
|
46
|
-
return t =
|
|
50
|
+
return t = n, n;
|
|
47
51
|
}
|
|
48
52
|
export {
|
|
49
|
-
|
|
53
|
+
u as connectHostBridge
|
|
50
54
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const n = "glodon-workspace";
|
|
2
|
-
function
|
|
1
|
+
const n = "glodon-workspace", i = 1;
|
|
2
|
+
function s(t) {
|
|
3
3
|
let e = t;
|
|
4
4
|
if (typeof e == "string")
|
|
5
5
|
try {
|
|
@@ -13,7 +13,7 @@ function i(t) {
|
|
|
13
13
|
if (o.channel === n)
|
|
14
14
|
return o;
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function c() {
|
|
17
17
|
var e;
|
|
18
18
|
const t = (e = globalThis.chrome) == null ? void 0 : e.webview;
|
|
19
19
|
if (!(!t || typeof t.postMessage != "function" || typeof t.addEventListener != "function"))
|
|
@@ -21,6 +21,7 @@ function s() {
|
|
|
21
21
|
}
|
|
22
22
|
export {
|
|
23
23
|
n as HOST_CHANNEL,
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
i as SANDBOX_PROTOCOL,
|
|
25
|
+
c as getHostWebView,
|
|
26
|
+
s as parseHostMessage
|
|
26
27
|
};
|
|
@@ -1,37 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var o = Object.getOwnPropertySymbols;
|
|
4
|
-
var h = Object.prototype.hasOwnProperty, g = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var a = (t, e, i) => e in t ? l(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i, d = (t, e) => {
|
|
6
|
-
for (var i in e || (e = {}))
|
|
7
|
-
h.call(e, i) && a(t, i, e[i]);
|
|
8
|
-
if (o)
|
|
9
|
-
for (var i of o(e))
|
|
10
|
-
g.call(e, i) && a(t, i, e[i]);
|
|
11
|
-
return t;
|
|
12
|
-
}, c = (t, e) => u(t, y(e));
|
|
13
|
-
import { LOCAL_PYTHON_FUNCTION_CODE as f, WORKSPACE_GRANT_ID as m } from "./constants.mjs";
|
|
14
|
-
const p = "只操作用户在当前浏览器里选择的本地文件夹,路径相对该文件夹。云端工作区的文件不要用本工具。", r = {
|
|
1
|
+
import { LOCAL_PYTHON_FUNCTION_CODE as s, WORKSPACE_GRANT_ID as p } from "./constants.mjs";
|
|
2
|
+
const t = "只操作用户在当前浏览器里选择的本地文件夹,路径相对该文件夹。云端工作区的文件不要用本工具。", e = {
|
|
15
3
|
type: "string",
|
|
16
|
-
enum: [
|
|
17
|
-
description: `工作区 ID。省略时按 ${
|
|
18
|
-
},
|
|
4
|
+
enum: [p],
|
|
5
|
+
description: `工作区 ID。省略时按 ${p} 处理,传其他值会被拒绝。`
|
|
6
|
+
}, i = (n) => ({
|
|
19
7
|
type: "string",
|
|
20
|
-
description: `${
|
|
21
|
-
}),
|
|
8
|
+
description: `${n}使用相对工作区根目录的路径,以 / 分隔,不能包含 .. 或绝对路径。`
|
|
9
|
+
}), r = {
|
|
22
10
|
type: "string",
|
|
23
11
|
description: "文件当前内容的 hash(sha256:<hex>),来自 read_file 或 stat_file 的返回值。"
|
|
24
|
-
},
|
|
12
|
+
}, d = {
|
|
25
13
|
list_directory: {
|
|
26
14
|
functionCode: "list_directory",
|
|
27
15
|
name: "列出本地目录",
|
|
28
|
-
description: `${
|
|
16
|
+
description: `${t}列出某个目录的直接子项(目录在前),支持分页。`,
|
|
29
17
|
parameters: {
|
|
30
18
|
type: "object",
|
|
31
19
|
required: ["grantId"],
|
|
32
20
|
properties: {
|
|
33
|
-
grantId:
|
|
34
|
-
path:
|
|
21
|
+
grantId: e,
|
|
22
|
+
path: i('要列出的目录,省略或传 "." 表示工作区根目录。'),
|
|
35
23
|
offset: {
|
|
36
24
|
type: "integer",
|
|
37
25
|
minimum: 0,
|
|
@@ -49,13 +37,13 @@ const p = "只操作用户在当前浏览器里选择的本地文件夹,路径
|
|
|
49
37
|
read_file: {
|
|
50
38
|
functionCode: "read_file",
|
|
51
39
|
name: "读取本地文件",
|
|
52
|
-
description: `${
|
|
40
|
+
description: `${t}按行读取文本文件,单次最多返回 1 MiB,超出部分会被截断(truncated: true)。返回内容的 hash 可用于后续修改。`,
|
|
53
41
|
parameters: {
|
|
54
42
|
type: "object",
|
|
55
43
|
required: ["grantId", "path"],
|
|
56
44
|
properties: {
|
|
57
|
-
grantId:
|
|
58
|
-
path:
|
|
45
|
+
grantId: e,
|
|
46
|
+
path: i("要读取的文件。"),
|
|
59
47
|
startLine: {
|
|
60
48
|
type: "integer",
|
|
61
49
|
minimum: 1,
|
|
@@ -82,13 +70,13 @@ const p = "只操作用户在当前浏览器里选择的本地文件夹,路径
|
|
|
82
70
|
stat_file: {
|
|
83
71
|
functionCode: "stat_file",
|
|
84
72
|
name: "查看本地文件信息",
|
|
85
|
-
description: `${
|
|
73
|
+
description: `${t}返回文件或目录的类型、大小、修改时间,可选返回 hash。不返回文件内容。`,
|
|
86
74
|
parameters: {
|
|
87
75
|
type: "object",
|
|
88
76
|
required: ["grantId", "path"],
|
|
89
77
|
properties: {
|
|
90
|
-
grantId:
|
|
91
|
-
path:
|
|
78
|
+
grantId: e,
|
|
79
|
+
path: i("要查看的文件或目录。"),
|
|
92
80
|
includeHash: {
|
|
93
81
|
type: "boolean",
|
|
94
82
|
description: "是否计算文件 hash。"
|
|
@@ -99,18 +87,18 @@ const p = "只操作用户在当前浏览器里选择的本地文件夹,路径
|
|
|
99
87
|
search_files: {
|
|
100
88
|
functionCode: "search_files",
|
|
101
89
|
name: "查找本地文件",
|
|
102
|
-
description: `${
|
|
90
|
+
description: `${t}按文件名或 glob(支持 *、?、**)查找文件。不含 / 的模式匹配文件名,含 / 的模式匹配相对 path 的路径。`,
|
|
103
91
|
parameters: {
|
|
104
92
|
type: "object",
|
|
105
93
|
required: ["grantId", "pattern"],
|
|
106
94
|
properties: {
|
|
107
|
-
grantId:
|
|
95
|
+
grantId: e,
|
|
108
96
|
pattern: {
|
|
109
97
|
type: "string",
|
|
110
98
|
minLength: 1,
|
|
111
99
|
description: "如 *.xlsx 或 reports/**/*.docx。"
|
|
112
100
|
},
|
|
113
|
-
path:
|
|
101
|
+
path: i("搜索起点目录,默认工作区根目录。"),
|
|
114
102
|
maxDepth: {
|
|
115
103
|
type: "integer",
|
|
116
104
|
minimum: 1,
|
|
@@ -129,13 +117,13 @@ const p = "只操作用户在当前浏览器里选择的本地文件夹,路径
|
|
|
129
117
|
search_text: {
|
|
130
118
|
functionCode: "search_text",
|
|
131
119
|
name: "搜索本地文本",
|
|
132
|
-
description: `${
|
|
120
|
+
description: `${t}在指定文件或目录(递归)中搜索普通文本(不支持正则),返回所在文件、行号与该行内容。必须指定 path,不能搜索整个文件夹。`,
|
|
133
121
|
parameters: {
|
|
134
122
|
type: "object",
|
|
135
123
|
required: ["grantId", "path", "query"],
|
|
136
124
|
properties: {
|
|
137
|
-
grantId:
|
|
138
|
-
path:
|
|
125
|
+
grantId: e,
|
|
126
|
+
path: i("搜索范围,可以是文件或目录。"),
|
|
139
127
|
query: {
|
|
140
128
|
type: "string",
|
|
141
129
|
minLength: 1,
|
|
@@ -171,14 +159,14 @@ const p = "只操作用户在当前浏览器里选择的本地文件夹,路径
|
|
|
171
159
|
apply_patch: {
|
|
172
160
|
functionCode: "apply_patch",
|
|
173
161
|
name: "修改本地文件",
|
|
174
|
-
description: `${
|
|
162
|
+
description: `${t}以查找替换的方式修改 UTF-8 文本文件。每条修改的 oldText 必须在文件中唯一出现(或设置 replaceAll)。执行前需要用户确认。`,
|
|
175
163
|
parameters: {
|
|
176
164
|
type: "object",
|
|
177
165
|
required: ["grantId", "path", "expectedHash", "edits"],
|
|
178
166
|
properties: {
|
|
179
|
-
grantId:
|
|
180
|
-
path:
|
|
181
|
-
expectedHash:
|
|
167
|
+
grantId: e,
|
|
168
|
+
path: i("要修改的文件。"),
|
|
169
|
+
expectedHash: r,
|
|
182
170
|
edits: {
|
|
183
171
|
type: "array",
|
|
184
172
|
minItems: 1,
|
|
@@ -209,18 +197,18 @@ const p = "只操作用户在当前浏览器里选择的本地文件夹,路径
|
|
|
209
197
|
write_file: {
|
|
210
198
|
functionCode: "write_file",
|
|
211
199
|
name: "写入本地文件",
|
|
212
|
-
description: `${
|
|
200
|
+
description: `${t}新建文件,或整体覆盖已有文件(覆盖时必须提供 expectedHash)。修改已有文件优先使用 apply_patch。执行前需要用户确认。`,
|
|
213
201
|
parameters: {
|
|
214
202
|
type: "object",
|
|
215
203
|
required: ["grantId", "path", "content"],
|
|
216
204
|
properties: {
|
|
217
|
-
grantId:
|
|
218
|
-
path:
|
|
205
|
+
grantId: e,
|
|
206
|
+
path: i("要写入的文件。"),
|
|
219
207
|
content: {
|
|
220
208
|
type: "string",
|
|
221
209
|
description: "完整的文件内容(UTF-8)。"
|
|
222
210
|
},
|
|
223
|
-
expectedHash:
|
|
211
|
+
expectedHash: r,
|
|
224
212
|
createDirectories: {
|
|
225
213
|
type: "boolean",
|
|
226
214
|
description: "父目录不存在时是否自动创建,默认否。"
|
|
@@ -231,13 +219,13 @@ const p = "只操作用户在当前浏览器里选择的本地文件夹,路径
|
|
|
231
219
|
upload_file: {
|
|
232
220
|
functionCode: "upload_file",
|
|
233
221
|
name: "上传本地文件",
|
|
234
|
-
description: `${
|
|
222
|
+
description: `${t}把本地文件夹中的文件上传到平台文件服务,返回 fileId、name、size 和 url。url 是文件访问地址,可直接用于后续推理或对话。下载回本地文件夹时使用 download_file,source.type 为 platformFile。单文件不超过 50 MB。执行前需要用户确认。`,
|
|
235
223
|
parameters: {
|
|
236
224
|
type: "object",
|
|
237
225
|
required: ["grantId", "path"],
|
|
238
226
|
properties: {
|
|
239
|
-
grantId:
|
|
240
|
-
path:
|
|
227
|
+
grantId: e,
|
|
228
|
+
path: i("要上传的文件。"),
|
|
241
229
|
target: {
|
|
242
230
|
type: "string",
|
|
243
231
|
description: "上传目标,目前只支持 session(默认),其他值返回 501。"
|
|
@@ -252,13 +240,13 @@ const p = "只操作用户在当前浏览器里选择的本地文件夹,路径
|
|
|
252
240
|
download_file: {
|
|
253
241
|
functionCode: "download_file",
|
|
254
242
|
name: "下载到本地文件夹",
|
|
255
|
-
description: `${
|
|
243
|
+
description: `${t}把会话文件、平台文件或 https 地址保存到本地文件夹。source.type 为 url 时必须同时填写 source.url(完整地址),为 sessionFile 或 platformFile 时必须同时填写 source.fileId。不要只传 type。单文件不超过 50 MB。执行前需要用户确认。`,
|
|
256
244
|
parameters: {
|
|
257
245
|
type: "object",
|
|
258
246
|
required: ["grantId", "destPath", "source"],
|
|
259
247
|
properties: {
|
|
260
|
-
grantId:
|
|
261
|
-
destPath:
|
|
248
|
+
grantId: e,
|
|
249
|
+
destPath: i("保存位置(文件路径)。"),
|
|
262
250
|
source: {
|
|
263
251
|
type: "object",
|
|
264
252
|
required: ["type"],
|
|
@@ -283,19 +271,19 @@ const p = "只操作用户在当前浏览器里选择的本地文件夹,路径
|
|
|
283
271
|
type: "boolean",
|
|
284
272
|
description: "目标已存在时是否覆盖,默认否。"
|
|
285
273
|
},
|
|
286
|
-
expectedHash:
|
|
274
|
+
expectedHash: r
|
|
287
275
|
}
|
|
288
276
|
}
|
|
289
277
|
}
|
|
290
|
-
},
|
|
291
|
-
functionCode:
|
|
278
|
+
}, o = "在已绑定的本地工程目录中运行已有 .py,路径相对该目录。不要用于云端工作区,不要传 shell 或代码,只能传 path 和 args。", c = {
|
|
279
|
+
functionCode: s,
|
|
292
280
|
name: "运行本地 Python 脚本",
|
|
293
|
-
description: `${
|
|
281
|
+
description: `${o}每次运行需用户单独确认,文件读写授权不能代替。确认后脚本可直接读写该目录并使用标准库,改动立即落盘。不能联网,不能在运行中安装包,也不能访问该目录以外的文件。第三方包写在工程根目录 sandbox-requirements.txt。结果打印到标准输出。code 为 0 只表示已结束,成功看 data.exitCode,超时看 data.timedOut。`,
|
|
294
282
|
parameters: {
|
|
295
283
|
type: "object",
|
|
296
284
|
required: ["grantId", "path"],
|
|
297
285
|
properties: {
|
|
298
|
-
grantId:
|
|
286
|
+
grantId: e,
|
|
299
287
|
path: {
|
|
300
288
|
type: "string",
|
|
301
289
|
description: "要运行的脚本。必须是已存在、以 .py 结尾的相对路径,以 / 分隔,不能包含 .. 、盘符或绝对路径。"
|
|
@@ -317,11 +305,8 @@ const p = "只操作用户在当前浏览器里选择的本地文件夹,路径
|
|
|
317
305
|
}
|
|
318
306
|
}
|
|
319
307
|
}
|
|
320
|
-
}
|
|
321
|
-
run_python: I
|
|
322
|
-
});
|
|
308
|
+
};
|
|
323
309
|
export {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
I as LOCAL_PYTHON_TOOL_SCHEMA
|
|
310
|
+
d as LOCAL_FILE_TOOL_SCHEMAS,
|
|
311
|
+
c as LOCAL_PYTHON_TOOL_SCHEMA
|
|
327
312
|
};
|
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var c = Object.defineProperty, j = Object.defineProperties;
|
|
2
|
+
var L = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var $ = Object.getOwnPropertySymbols;
|
|
4
|
-
var
|
|
5
|
-
var g = (i,
|
|
6
|
-
for (var
|
|
7
|
-
|
|
4
|
+
var p = Object.prototype.hasOwnProperty, A = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var g = (i, n, r) => n in i ? c(i, n, { enumerable: !0, configurable: !0, writable: !0, value: r }) : i[n] = r, k = (i, n) => {
|
|
6
|
+
for (var r in n || (n = {}))
|
|
7
|
+
p.call(n, r) && g(i, r, n[r]);
|
|
8
8
|
if ($)
|
|
9
|
-
for (var
|
|
10
|
-
|
|
9
|
+
for (var r of $(n))
|
|
10
|
+
A.call(n, r) && g(i, r, n[r]);
|
|
11
11
|
return i;
|
|
12
|
-
},
|
|
13
|
-
import { ToolError as
|
|
14
|
-
function
|
|
15
|
-
throw new O
|
|
12
|
+
}, x = (i, n) => j(i, L(n));
|
|
13
|
+
import { ToolError as I, ToolCode as O } from "./errors.mjs";
|
|
14
|
+
function o(i, n) {
|
|
15
|
+
throw new I(O.BadRequest, i ? `参数 ${i} ${n}` : `参数${n}`);
|
|
16
16
|
}
|
|
17
|
-
function
|
|
18
|
-
return typeof i != "string" ? i : (
|
|
17
|
+
function w(i, n) {
|
|
18
|
+
return typeof i != "string" ? i : (n.type === "integer" || n.type === "number") && /^-?\d+(\.\d+)?$/.test(i.trim()) ? Number(i) : n.type === "boolean" && (i === "true" || i === "false") ? i === "true" : i;
|
|
19
19
|
}
|
|
20
|
-
function y(i,
|
|
21
|
-
switch (i =
|
|
20
|
+
function y(i, n, r) {
|
|
21
|
+
switch (i = w(i, n), n.type) {
|
|
22
22
|
case "string":
|
|
23
|
-
typeof i != "string" &&
|
|
23
|
+
typeof i != "string" && o(r, "必须是字符串。"), n.minLength !== void 0 && i.length < n.minLength && o(r, "不能为空。"), n.maxLength !== void 0 && i.length > n.maxLength && o(r, `不能超过 ${n.maxLength} 字。`);
|
|
24
24
|
break;
|
|
25
25
|
case "integer":
|
|
26
|
-
(typeof i != "number" || !Number.isInteger(i)) &&
|
|
26
|
+
(typeof i != "number" || !Number.isInteger(i)) && o(r, "必须是整数。");
|
|
27
27
|
break;
|
|
28
28
|
case "number":
|
|
29
|
-
(typeof i != "number" || !Number.isFinite(i)) &&
|
|
29
|
+
(typeof i != "number" || !Number.isFinite(i)) && o(r, "必须是数字。");
|
|
30
30
|
break;
|
|
31
31
|
case "boolean":
|
|
32
|
-
typeof i != "boolean" &&
|
|
32
|
+
typeof i != "boolean" && o(r, "必须是布尔值。");
|
|
33
33
|
break;
|
|
34
34
|
case "array":
|
|
35
|
-
if (Array.isArray(i) ||
|
|
36
|
-
const e =
|
|
37
|
-
return i.map((f, m) => y(f, e, `${
|
|
35
|
+
if (Array.isArray(i) || o(r, "必须是数组。"), n.minItems !== void 0 && i.length < n.minItems && o(r, "不能为空。"), n.items) {
|
|
36
|
+
const e = n.items;
|
|
37
|
+
return i.map((f, m) => y(f, e, `${r}[${m}]`));
|
|
38
38
|
}
|
|
39
39
|
break;
|
|
40
40
|
case "object":
|
|
41
|
-
return
|
|
41
|
+
return s(i, n, r);
|
|
42
42
|
}
|
|
43
|
-
return
|
|
43
|
+
return n.enum && !n.enum.includes(i) && o(r, `必须是 ${n.enum.join("、")} 之一。`), typeof i == "number" && (n.minimum !== void 0 && i < n.minimum && o(r, `不能小于 ${n.minimum}。`), n.maximum !== void 0 && i > n.maximum && o(r, `不能大于 ${n.maximum}。`)), i;
|
|
44
44
|
}
|
|
45
|
-
function
|
|
45
|
+
function s(i, n, r) {
|
|
46
46
|
var m, d;
|
|
47
|
-
(!i || typeof i != "object" || Array.isArray(i)) &&
|
|
47
|
+
(!i || typeof i != "object" || Array.isArray(i)) && o(r, "必须是对象。");
|
|
48
48
|
const e = i, f = {};
|
|
49
|
-
for (const
|
|
50
|
-
(e[
|
|
51
|
-
for (const [
|
|
52
|
-
if (e[
|
|
49
|
+
for (const t of (m = n.required) != null ? m : [])
|
|
50
|
+
(e[t] === void 0 || e[t] === null) && o(r ? `${r}.${t}` : t, "是必填项。");
|
|
51
|
+
for (const [t, b] of Object.entries((d = n.properties) != null ? d : {})) {
|
|
52
|
+
if (e[t] === void 0 || e[t] === null)
|
|
53
53
|
continue;
|
|
54
|
-
const u =
|
|
55
|
-
f[
|
|
54
|
+
const u = r ? `${r}.${t}` : t;
|
|
55
|
+
f[t] = b.oneOf ? (y(e[t], x(k({}, b), {
|
|
56
56
|
oneOf: void 0
|
|
57
|
-
}), u), e[
|
|
57
|
+
}), u), e[t]) : y(e[t], b, u);
|
|
58
58
|
}
|
|
59
59
|
return f;
|
|
60
60
|
}
|
|
61
|
-
function
|
|
62
|
-
return
|
|
61
|
+
function q(i, n) {
|
|
62
|
+
return s(i, n, "");
|
|
63
63
|
}
|
|
64
64
|
export {
|
|
65
|
-
|
|
65
|
+
q as validateToolInput
|
|
66
66
|
};
|