@glodon-aiot/bot-client-sdk 3.26.0-alpha.20 → 3.26.0-alpha.23

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 (75) hide show
  1. package/README.md +130 -179
  2. package/dist/es/BotClient.mjs +136 -154
  3. package/dist/es/Config.mjs +88 -51
  4. package/dist/es/Session.mjs +23 -35
  5. package/dist/es/index.mjs +64 -66
  6. package/dist/es/localFiles/adapters/FileSystemAccessAdapter.mjs +113 -185
  7. package/dist/es/localFiles/adapters/HostBridgeAdapter.mjs +137 -127
  8. package/dist/es/localFiles/adapters/MemoryWorkspaceAdapter.mjs +97 -132
  9. package/dist/es/localFiles/adapters/WorkspaceFileAdapter.mjs +28 -32
  10. package/dist/es/localFiles/constants.mjs +29 -24
  11. package/dist/es/localFiles/createLocalPythonPlugin.mjs +196 -0
  12. package/dist/es/localFiles/errors.mjs +19 -21
  13. package/dist/es/localFiles/host/connectHostBridge.mjs +34 -37
  14. package/dist/es/localFiles/host/protocol.mjs +13 -27
  15. package/dist/es/localFiles/schemas.mjs +86 -40
  16. package/dist/es/localFiles/validate.mjs +37 -37
  17. package/dist/es/localFiles/workspace/LocalWorkspace.mjs +87 -161
  18. package/dist/es/package.json.mjs +29 -38
  19. package/dist/lib/index.js +9 -373
  20. package/dist/src/Config.d.ts +7 -5
  21. package/dist/src/Session.d.ts +0 -6
  22. package/dist/src/index.d.ts +1 -2
  23. package/dist/src/localFiles/adapters/FileSystemAccessAdapter.d.ts +1 -4
  24. package/dist/src/localFiles/adapters/HostBridgeAdapter.d.ts +14 -30
  25. package/dist/src/localFiles/adapters/MemoryWorkspaceAdapter.d.ts +1 -4
  26. package/dist/src/localFiles/adapters/WorkspaceFileAdapter.d.ts +0 -22
  27. package/dist/src/localFiles/adapters/fsaTypes.d.ts +0 -2
  28. package/dist/src/localFiles/constants.d.ts +13 -3
  29. package/dist/src/localFiles/host/protocol.d.ts +16 -34
  30. package/dist/src/localFiles/index.d.ts +6 -11
  31. package/dist/src/localFiles/schemas.d.ts +5 -2
  32. package/dist/src/localFiles/types.d.ts +23 -16
  33. package/dist/src/localFiles/workspace/LocalWorkspace.d.ts +1 -32
  34. package/package.json +4 -13
  35. package/dist/es/builtinTools/browserRuntime/BrowserCommandRunner.mjs +0 -201
  36. package/dist/es/builtinTools/browserRuntime/PythonRunner.mjs +0 -356
  37. package/dist/es/builtinTools/browserRuntime/WorkspaceBashFs.mjs +0 -350
  38. package/dist/es/builtinTools/browserRuntime/assets.mjs +0 -9
  39. package/dist/es/builtinTools/browserRuntime/loadBash.mjs +0 -17
  40. package/dist/es/builtinTools/browserRuntime/pyodideRunner.py.mjs +0 -96
  41. package/dist/es/builtinTools/browserRuntime/pyodideWorker.mjs +0 -242
  42. package/dist/es/builtinTools/command.mjs +0 -56
  43. package/dist/es/builtinTools/constants.mjs +0 -10
  44. package/dist/es/builtinTools/createBuiltinToolsPlugin.mjs +0 -261
  45. package/dist/es/builtinTools/overview.mjs +0 -77
  46. package/dist/es/builtinTools/paths.mjs +0 -69
  47. package/dist/es/builtinTools/platformSkills.mjs +0 -210
  48. package/dist/es/builtinTools/schemas.mjs +0 -216
  49. package/dist/es/builtinTools/tools.mjs +0 -494
  50. package/dist/es/localFiles/adapters/FileSnapshotAdapter.mjs +0 -160
  51. package/dist/es/localFiles/host/sandboxClient.mjs +0 -420
  52. package/dist/es/localFiles/host/sandboxFrames.mjs +0 -21
  53. package/dist/es/localFiles/preview.mjs +0 -33
  54. package/dist/es/localFiles/workspace/WorkspaceFiles.mjs +0 -246
  55. package/dist/es/sessionUpload.mjs +0 -49
  56. package/dist/src/builtinTools/browserRuntime/BrowserCommandRunner.d.ts +0 -26
  57. package/dist/src/builtinTools/browserRuntime/PythonRunner.d.ts +0 -67
  58. package/dist/src/builtinTools/browserRuntime/WorkspaceBashFs.d.ts +0 -51
  59. package/dist/src/builtinTools/browserRuntime/assets.d.ts +0 -13
  60. package/dist/src/builtinTools/browserRuntime/loadBash.d.ts +0 -3
  61. package/dist/src/builtinTools/browserRuntime/pyodideWorker.d.ts +0 -44
  62. package/dist/src/builtinTools/command.d.ts +0 -35
  63. package/dist/src/builtinTools/constants.d.ts +0 -17
  64. package/dist/src/builtinTools/createBuiltinToolsPlugin.d.ts +0 -11
  65. package/dist/src/builtinTools/overview.d.ts +0 -5
  66. package/dist/src/builtinTools/paths.d.ts +0 -16
  67. package/dist/src/builtinTools/platformSkills.d.ts +0 -67
  68. package/dist/src/builtinTools/schemas.d.ts +0 -3
  69. package/dist/src/builtinTools/tools.d.ts +0 -64
  70. package/dist/src/localFiles/adapters/FileSnapshotAdapter.d.ts +0 -24
  71. package/dist/src/localFiles/host/sandboxClient.d.ts +0 -81
  72. package/dist/src/localFiles/host/sandboxFrames.d.ts +0 -9
  73. package/dist/src/localFiles/preview.d.ts +0 -2
  74. package/dist/src/localFiles/workspace/WorkspaceFiles.d.ts +0 -63
  75. package/dist/src/sessionUpload.d.ts +0 -14
@@ -1,69 +0,0 @@
1
- import { ToolError as o, ToolCode as i } from "../localFiles/errors.mjs";
2
- const f = ["input", "output", "uploads", "tmp"], c = "不要使用 input、output、uploads、tmp,也不要新建这些目录。请把文件直接放在工作区已有位置或根目录。", h = /(?:^|[\s'"=;|&<>`:])\/?(?:input|output|uploads|tmp)(?=\/|[\s'"=;|&<>`:]|$)/, d = /(?:^|[\s'"=;|&<>`:])\/?skills(?=\/|[\s'"=;|&<>`:]|$)/;
3
- function a(t) {
4
- return d.test(t);
5
- }
6
- function w(t) {
7
- return h.test(t);
8
- }
9
- function u(t) {
10
- const n = t.split("/")[0];
11
- return f.includes(n);
12
- }
13
- function r(t) {
14
- throw new o(i.Forbidden, t, {
15
- reason: "path_outside_workspace"
16
- });
17
- }
18
- function l(t) {
19
- if (typeof t != "string" || t.length === 0)
20
- throw new o(i.BadRequest, "path 必须是工作区内绝对路径。");
21
- (t.includes("\0") || t.includes("\\")) && r("路径不能包含反斜杠。");
22
- const n = t.normalize("NFC").trim();
23
- if (!n.startsWith("/"))
24
- throw new o(i.BadRequest, "path 必须是工作区内绝对路径,例如 /说明.md。");
25
- const e = n.split("/").filter((s) => s.length > 0);
26
- if (e.some((s) => s === "." || s === "..") && r("路径不能包含 . 或 .. 。"), e.length > 0 && u(e[0]))
27
- throw new o(i.BadRequest, c);
28
- if (e[0] === "skills")
29
- throw new o(i.Forbidden, "技能文件只能通过技能工具访问。");
30
- return e.join("/");
31
- }
32
- function R(t) {
33
- return l(t);
34
- }
35
- function S(t) {
36
- return l(t);
37
- }
38
- function g(t) {
39
- return t ? `/${t}` : "/";
40
- }
41
- function I(t) {
42
- if (t === ".")
43
- return !0;
44
- if (!t || t.startsWith("/") || t.includes("\\") || t.includes("\0"))
45
- return !1;
46
- const n = t.split("/").filter((e) => e.length > 0);
47
- return n.length > 0 && n.every((e) => e !== "." && e !== "..") && !u(n[0]);
48
- }
49
- function T(t, n) {
50
- if (!t || /[\\/\0]/.test(t) || t === "." || t === "..")
51
- throw new o(i.BadRequest, "skill_name 必须是单个技能目录名。");
52
- if (!n || n.startsWith("/") || n.includes("\\") || n.includes("\0"))
53
- throw new o(i.BadRequest, "资源路径必须是技能目录内的相对路径。");
54
- const e = n.split("/").filter((s) => s.length > 0);
55
- return (e.length === 0 || e.some((s) => s === "." || s === "..")) && r("资源路径不能跳出技能目录。"), `skills/${t}/${e.join("/")}`;
56
- }
57
- export {
58
- f as SYNTHETIC_DIRS,
59
- c as SYNTHETIC_DIR_MESSAGE,
60
- I as isSafeCwd,
61
- u as isSyntheticCwd,
62
- a as mentionsSkillDir,
63
- w as mentionsSyntheticDir,
64
- R as resolveFilePath,
65
- S as resolveRunPath,
66
- l as resolveWorkspacePath,
67
- T as skillRelative,
68
- g as toVirtualPath
69
- };
@@ -1,210 +0,0 @@
1
- var k = Object.defineProperty;
2
- var v = (s, t, n) => t in s ? k(s, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : s[t] = n;
3
- var f = (s, t, n) => (v(s, typeof t != "symbol" ? t + "" : t, n), n);
4
- var a = (s, t, n) => new Promise((e, i) => {
5
- var r = (o) => {
6
- try {
7
- d(n.next(o));
8
- } catch (u) {
9
- i(u);
10
- }
11
- }, l = (o) => {
12
- try {
13
- d(n.throw(o));
14
- } catch (u) {
15
- i(u);
16
- }
17
- }, d = (o) => o.done ? e(o.value) : Promise.resolve(o.value).then(r, l);
18
- d((n = n.apply(s, t)).next());
19
- });
20
- import { ToolError as c, ToolCode as p } from "../localFiles/errors.mjs";
21
- import { isExpired as w } from "../utils.mjs";
22
- const b = 20 * 1024 * 1024, I = /^[A-Za-z0-9._-]+$/;
23
- function h(s) {
24
- const t = s == null ? void 0 : s.skills;
25
- return Array.isArray(t) ? t.filter((n) => n && typeof n == "object") : [];
26
- }
27
- function m(s) {
28
- if (!s)
29
- return !1;
30
- try {
31
- return !w(s);
32
- } catch (t) {
33
- return !1;
34
- }
35
- }
36
- function y(s) {
37
- if (!(typeof s.skillId != "string" || !I.test(s.skillId)) && !(typeof s.name != "string" || !s.name || /[\\/\0]/.test(s.name) || s.name === "." || s.name === "..") && !(typeof s.version != "number" || !Number.isInteger(s.version) || s.version < 1))
38
- return {
39
- skillId: s.skillId,
40
- name: s.name,
41
- version: s.version
42
- };
43
- }
44
- function S(s) {
45
- return Array.isArray(s) ? s.flatMap((t) => {
46
- if (!t || typeof t != "object")
47
- return [];
48
- const n = t;
49
- return typeof n.skillId != "string" || typeof n.name != "string" || typeof n.version != "number" ? [] : [{
50
- skillId: n.skillId,
51
- name: n.name,
52
- version: n.version
53
- }];
54
- }) : [];
55
- }
56
- class R {
57
- constructor(t) {
58
- f(this, "inflight", /* @__PURE__ */ new Map());
59
- f(this, "busy", /* @__PURE__ */ new Set());
60
- this.options = t;
61
- }
62
- /** 进入会话时调用。不阻塞历史,也不改沙箱就绪。 */
63
- sync() {
64
- return this.reconcile().catch(() => {
65
- });
66
- }
67
- read(t, n, e) {
68
- return a(this, null, function* () {
69
- const i = yield this.prepare(t, e);
70
- return this.requireSandbox().skillRead(this.options.applicationId(), i.skillId, i.version, n, e);
71
- });
72
- }
73
- target(t, n) {
74
- return a(this, null, function* () {
75
- const e = yield this.prepare(t, n);
76
- return {
77
- applicationId: this.options.applicationId(),
78
- skillId: e.skillId,
79
- version: e.version,
80
- name: e.name
81
- };
82
- });
83
- }
84
- track(t, n) {
85
- const e = `${t}/${n}`;
86
- this.busy.add(e);
87
- let i = !1;
88
- return () => {
89
- i || (i = !0, this.busy.delete(e), this.prune().catch(() => {
90
- }));
91
- };
92
- }
93
- requireSandbox() {
94
- const t = this.options.getSandbox();
95
- if (!t)
96
- throw new c(p.NotImplemented, "当前环境不能加载平台技能,需要端侧宿主。");
97
- return t;
98
- }
99
- prepare(t, n) {
100
- return a(this, null, function* () {
101
- const e = this.bound(t);
102
- if (!e)
103
- throw new c(p.NotFound, "技能或资源不存在。");
104
- return yield this.ensure(e, n), e;
105
- });
106
- }
107
- bound(t) {
108
- if (!I.test(this.options.applicationId()))
109
- return;
110
- const n = h({
111
- skills: this.options.getSkills()
112
- }).find((e) => e.name === t);
113
- return n ? y(n) : void 0;
114
- }
115
- reconcile() {
116
- return a(this, null, function* () {
117
- if (!this.options.getSandbox())
118
- return;
119
- const n = h({
120
- skills: this.options.getSkills()
121
- }).flatMap((e) => {
122
- const i = y(e);
123
- return i ? [i] : [];
124
- });
125
- yield Promise.all(n.map((e) => this.ensure(e).catch(() => {
126
- }))), yield this.prune();
127
- });
128
- }
129
- ensure(t, n) {
130
- return a(this, null, function* () {
131
- const e = `${this.options.applicationId()}/${t.skillId}/${t.version}`, i = this.inflight.get(e);
132
- if (i)
133
- return i;
134
- const r = this.installIfNeeded(t, n).finally(() => {
135
- this.inflight.get(e) === r && this.inflight.delete(e);
136
- });
137
- return this.inflight.set(e, r), r;
138
- });
139
- }
140
- installIfNeeded(t, n) {
141
- return a(this, null, function* () {
142
- var o;
143
- const e = this.requireSandbox();
144
- if (e.ready && (yield this.alreadyInstalled(e, t, n)))
145
- return;
146
- const i = this.options.getToken();
147
- if (!m(i))
148
- throw new c(p.Forbidden, "技能下载令牌不可用。");
149
- const r = this.options.apiRoot().replace(/\/$/, ""), l = yield ((o = this.options.fetch) != null ? o : fetch)(`${r}/skill/v1/skills/${encodeURIComponent(t.skillId)}/versions/${t.version}/download`, {
150
- headers: {
151
- Authorization: `Bearer ${i}`
152
- },
153
- signal: n
154
- });
155
- if (!l.ok)
156
- throw new c(p.BadRequest, `技能下载失败(${l.status})。`);
157
- const d = new Uint8Array(yield l.arrayBuffer());
158
- if (d.byteLength > b)
159
- throw new c(p.BadRequest, "技能压缩包超过 20 MB。");
160
- yield this.waitReady(e, n), !(yield this.alreadyInstalled(e, t, n)) && (yield e.installSkill({
161
- applicationId: this.options.applicationId(),
162
- skillId: t.skillId,
163
- version: t.version,
164
- name: t.name
165
- }, d, n));
166
- });
167
- }
168
- alreadyInstalled(t, n, e) {
169
- return a(this, null, function* () {
170
- return S(yield t.skillStatus(this.options.applicationId(), e)).some((r) => r.skillId === n.skillId && r.version === n.version && r.name === n.name);
171
- });
172
- }
173
- prune() {
174
- return a(this, null, function* () {
175
- const t = this.options.getSandbox();
176
- if (!(t != null && t.ready))
177
- return;
178
- const n = h({
179
- skills: this.options.getSkills()
180
- }).flatMap((i) => typeof i.skillId != "string" || typeof i.version != "number" || i.version < 1 ? [] : [{
181
- skillId: i.skillId,
182
- version: i.version
183
- }]), e = [...this.busy].map((i) => {
184
- const [r, l] = i.split("/");
185
- return {
186
- skillId: r,
187
- version: Number(l)
188
- };
189
- });
190
- yield t.skillPrune(this.options.applicationId(), n, e);
191
- });
192
- }
193
- waitReady(t, n) {
194
- return a(this, null, function* () {
195
- t.ready || (yield new Promise((e, i) => {
196
- const r = setInterval(() => {
197
- if (n != null && n.aborted) {
198
- clearInterval(r), i(new c(p.Cancelled, "已取消。"));
199
- return;
200
- }
201
- t.ready && (clearInterval(r), e());
202
- }, 50);
203
- }));
204
- });
205
- }
206
- }
207
- export {
208
- R as PlatformSkillSync,
209
- h as listedSkills
210
- };
@@ -1,216 +0,0 @@
1
- import { MAX_COMMAND_CHARS as s, MAX_WRITE_BYTES as n, BUILTIN_FUNCTION_CODES as r } from "./constants.mjs";
2
- const e = (i) => ({
3
- type: "string",
4
- minLength: 1,
5
- description: i
6
- }), t = "必填。工作区内绝对路径,以 / 开头,例如 /说明.md。不要使用 /input、/output、/uploads、/tmp,也不要新建这些目录。", o = {
7
- shell: {
8
- functionCode: "shell",
9
- name: "执行命令",
10
- description: "在当前会话工作区中执行一条 shell 命令并返回标准输出。每次调用都是新的 shell,只保留上次停留的目录;环境变量不会保留,需要时在同一条命令里设置。当前目录是工作区根目录。用相对路径,或以 / 开头表示工作区内已有的路径,例如 notes/a.md、/说明.md。不要使用或新建 input、output、uploads、tmp。/dev、/usr、/bin 仍是系统路径。写进脚本文件里的路径要用相对路径(见 run_file)。超过 20000 字的脚本请用 write_file 写到工作区文件后再调用 run_file;读取文件正文或结构摘要请用 read_file 的 start_line 和 end_line,不要用 cat、sed 或 head 把大文件正文打到标准输出。",
11
- parameters: {
12
- type: "object",
13
- required: ["command"],
14
- properties: {
15
- command: {
16
- type: "string",
17
- minLength: 1,
18
- maxLength: s,
19
- description: "必填。一条不超过 20000 字的 shell 命令。当前目录已是工作区根目录。可以包含短的 python 或 heredoc。读取文件正文请改用 read_file。"
20
- }
21
- }
22
- }
23
- },
24
- read_file: {
25
- functionCode: "read_file",
26
- name: "读取文件",
27
- description: "按绝对路径读取工作区内的文本文件并返回内容;读不到时返回失败原因。未超过上限的文本按原文返回;超过单次读取上限的结构化文本(JSON/XML/SVG/CSV/TSV)会先附带通用结构概览和短预览,需要特定片段时再用 start_line 和 end_line。PDF 和图片只返回文件摘要,不返回正文。",
28
- parameters: {
29
- type: "object",
30
- required: ["path"],
31
- properties: {
32
- path: e(t),
33
- start_line: {
34
- type: "integer",
35
- minimum: 1,
36
- description: "可选。起始行号,从 1 开始,含本行。省略则从第 1 行读。"
37
- },
38
- end_line: {
39
- type: "integer",
40
- minimum: 1,
41
- description: "可选。结束行号,从 1 开始,含本行。省略则读到文件末尾。"
42
- }
43
- }
44
- }
45
- },
46
- write_file: {
47
- functionCode: "write_file",
48
- name: "写入文件",
49
- description: `把文本写入工作区内文件,path 为工作区内绝对路径,文件已存在时覆盖。单次覆盖写入按 UTF-8 字节计,默认不超过 ${n} 字节。超限时先写一段,再用 edit_file 修改,或用 append_file 追加下一段。SVG 和整页 HTML 由工作区里的脚本生成,不要直接放进 content。`,
50
- parameters: {
51
- type: "object",
52
- required: ["path", "content"],
53
- properties: {
54
- path: e(t),
55
- content: {
56
- type: "string",
57
- description: `必填。覆盖写入的文本,UTF-8 不超过 ${n} 字节。不要放入 SVG 或整页 HTML。`
58
- }
59
- }
60
- }
61
- },
62
- append_file: {
63
- functionCode: "append_file",
64
- name: "追加文件",
65
- description: "把一段文本追加到工作区内文件末尾,path 为工作区内绝对路径,文件不存在时创建。覆盖写入超过字节上限时,用本工具把下一段接到同一文件。追加不设字节上限,但不要在一次调用里放入整份 HTML 或 SVG。",
66
- parameters: {
67
- type: "object",
68
- required: ["path", "content"],
69
- properties: {
70
- path: e(t),
71
- content: {
72
- type: "string",
73
- description: "必填。要追加到文件末尾的文本。不受覆盖写入的字节上限约束。"
74
- }
75
- }
76
- }
77
- },
78
- run_file: {
79
- functionCode: "run_file",
80
- name: "执行文件",
81
- description: "执行工作区里已经存在的 .py、.sh 或 .js 脚本文件。生成 SVG、HTML、JSON 等产物时优先使用:先用 write_file 写脚本,脚本自行读取工作区文件并写出产物,再调用本工具。脚本运行时当前目录是工作区根目录,脚本里访问工作区文件要写相对路径,例如 data.json、notes/a.py。不要使用或新建 input、output、uploads、tmp。需要查看文件正文时用 read_file,不要把整份文件打印到标准输出。",
82
- parameters: {
83
- type: "object",
84
- required: ["path"],
85
- properties: {
86
- path: e("必填。要执行的 .py、.sh 或 .js 文件,工作区内绝对路径,例如 /scripts/gen.py。")
87
- }
88
- }
89
- },
90
- edit_file: {
91
- functionCode: "edit_file",
92
- name: "修改文件",
93
- description: "把工作区内文本文件中第一处与 old_text 完全相同的内容替换为 new_text。找不到 old_text 时返回最接近片段的行号,可直接复制原文重试,不必再读全文。old_text 与 new_text 不设长度上限。",
94
- parameters: {
95
- type: "object",
96
- required: ["path", "old_text", "new_text"],
97
- properties: {
98
- path: e(t),
99
- old_text: {
100
- type: "string",
101
- minLength: 1,
102
- description: "必填。文件中要被替换的原文,必须完全一致。"
103
- },
104
- new_text: {
105
- type: "string",
106
- description: "必填。替换后的文本。可以是一整段生成逻辑,不必拆成追加。"
107
- }
108
- }
109
- }
110
- },
111
- grep: {
112
- functionCode: "grep",
113
- name: "搜索文件",
114
- description: "在工作区目录中递归搜索文本,返回带行号的匹配行。path 为工作区内绝对路径,pattern 按 grep 基本正则匹配。用于定位内容,不要用来取回大文件全文。",
115
- parameters: {
116
- type: "object",
117
- required: ["path", "pattern"],
118
- properties: {
119
- path: e(t),
120
- pattern: {
121
- type: "string",
122
- minLength: 1,
123
- description: "必填。grep 基本正则表达式。"
124
- }
125
- }
126
- }
127
- },
128
- find: {
129
- functionCode: "find",
130
- name: "查找文件",
131
- description: "按文件名通配在工作区目录中查找文件。path 为起始绝对路径,name 传给 find 的 -name,例如 *.html。",
132
- parameters: {
133
- type: "object",
134
- required: ["path", "name"],
135
- properties: {
136
- path: e(t),
137
- name: {
138
- type: "string",
139
- minLength: 1,
140
- description: "必填。find -name 通配,例如 *.svg 或 *.html。"
141
- }
142
- }
143
- }
144
- },
145
- load_skill: {
146
- functionCode: "load_skill",
147
- name: "加载技能",
148
- description: "按技能名称加载平台技能的完整说明(SKILL.md)。技能不在工程目录里。",
149
- parameters: {
150
- type: "object",
151
- required: ["skill_name"],
152
- properties: {
153
- skill_name: {
154
- type: "string",
155
- minLength: 1,
156
- description: "必填。要加载的技能名称。"
157
- }
158
- }
159
- }
160
- },
161
- read_skill_resource: {
162
- functionCode: "read_skill_resource",
163
- name: "读取技能资源",
164
- description: "读取与指定技能关联的资源文件,例如参考资料、模板或附加说明。",
165
- parameters: {
166
- type: "object",
167
- required: ["skill_name", "resource_name"],
168
- properties: {
169
- skill_name: {
170
- type: "string",
171
- minLength: 1,
172
- description: "必填。技能名称。"
173
- },
174
- resource_name: {
175
- type: "string",
176
- minLength: 1,
177
- description: "必填。要读取的技能资源相对路径名称。"
178
- }
179
- }
180
- }
181
- },
182
- run_skill_script: {
183
- functionCode: "run_skill_script",
184
- name: "运行技能脚本",
185
- description: "执行平台技能包内的脚本并返回输出。当前目录是工作区根目录,参数里的用户文件按相对工作区根目录传,例如 docs/a.docx。技能自己的资源按脚本文件所在目录查找,不在工程的 skills 目录里。",
186
- parameters: {
187
- type: "object",
188
- required: ["skill_name", "script_name"],
189
- properties: {
190
- skill_name: {
191
- type: "string",
192
- minLength: 1,
193
- description: "必填。技能名称。"
194
- },
195
- script_name: {
196
- type: "string",
197
- minLength: 1,
198
- description: "必填。要运行的技能脚本相对路径(保持技能说明中列出的目录前缀,如 scripts/run.py)。"
199
- },
200
- args: {
201
- type: "array",
202
- description: '传递给脚本的命令行位置参数数组,例如 ["input.docx", "--output", "result.idx"]。',
203
- items: {
204
- type: "string",
205
- description: "单个脚本参数。"
206
- }
207
- }
208
- }
209
- }
210
- }
211
- }, p = Object.keys(o);
212
- if (p.length !== r.length || r.some((i) => !p.includes(i)))
213
- throw new Error("BUILTIN_TOOL_SCHEMAS 与 BUILTIN_FUNCTION_CODES 不一致");
214
- export {
215
- o as BUILTIN_TOOL_SCHEMAS
216
- };