@glodon-aiot/bot-client-sdk 3.26.0-alpha.5 → 3.26.0-alpha.8

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