@glodon-aiot/bot-client-sdk 3.26.0-alpha.9 → 3.27.0-alpha.0

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 (72) hide show
  1. package/README.md +246 -225
  2. package/dist/es/AgentSession.mjs +275 -197
  3. package/dist/es/BotClient.mjs +200 -123
  4. package/dist/es/Config.mjs +58 -68
  5. package/dist/es/DialogSession.mjs +123 -118
  6. package/dist/es/EventBus.mjs +38 -34
  7. package/dist/es/Logger.mjs +19 -21
  8. package/dist/es/Session.mjs +338 -284
  9. package/dist/es/api/index.mjs +31 -30
  10. package/dist/es/builtinTools/constants.mjs +12 -5
  11. package/dist/es/builtinTools/createBuiltinToolsPlugin.mjs +182 -160
  12. package/dist/es/builtinTools/paths.mjs +34 -27
  13. package/dist/es/builtinTools/platformSkills.mjs +248 -0
  14. package/dist/es/builtinTools/schemas.mjs +63 -18
  15. package/dist/es/builtinTools/tools.mjs +368 -244
  16. package/dist/es/index.mjs +62 -61
  17. package/dist/es/localFiles/adapters/FileSnapshotAdapter.mjs +160 -0
  18. package/dist/es/localFiles/adapters/FileSystemAccessAdapter.mjs +113 -131
  19. package/dist/es/localFiles/adapters/HostBridgeAdapter.mjs +60 -55
  20. package/dist/es/localFiles/constants.mjs +24 -28
  21. package/dist/es/localFiles/createLocalFilesPlugin.mjs +53 -52
  22. package/dist/es/localFiles/errors.mjs +44 -35
  23. package/dist/es/localFiles/host/connectHostBridge.mjs +20 -15
  24. package/dist/es/localFiles/host/protocol.mjs +27 -14
  25. package/dist/es/localFiles/host/sandboxClient.mjs +297 -127
  26. package/dist/es/localFiles/preview.mjs +33 -0
  27. package/dist/es/localFiles/schemas.mjs +22 -53
  28. package/dist/es/localFiles/workspace/LocalWorkspace.mjs +156 -89
  29. package/dist/es/localFiles/workspace/WorkspaceFiles.mjs +246 -0
  30. package/dist/es/localMcp/client.mjs +234 -0
  31. package/dist/es/localMcp/endpoints.mjs +94 -0
  32. package/dist/es/localMcp/register.mjs +207 -0
  33. package/dist/es/localMcp/registry.mjs +43 -0
  34. package/dist/es/package.json.mjs +29 -49
  35. package/dist/es/sessionUpload.mjs +49 -0
  36. package/dist/es/utils.mjs +24 -11
  37. package/dist/lib/index.js +48 -40
  38. package/dist/src/AgentSession.d.ts +13 -0
  39. package/dist/src/BotClient.d.ts +13 -1
  40. package/dist/src/Config.d.ts +14 -7
  41. package/dist/src/EventBus.d.ts +3 -0
  42. package/dist/src/Logger.d.ts +15 -8
  43. package/dist/src/PayloadTypes.d.ts +7 -0
  44. package/dist/src/Session.d.ts +19 -2
  45. package/dist/src/api/index.d.ts +2 -2
  46. package/dist/src/builtinTools/command.d.ts +7 -0
  47. package/dist/src/builtinTools/constants.d.ts +10 -2
  48. package/dist/src/builtinTools/paths.d.ts +3 -2
  49. package/dist/src/builtinTools/platformSkills.d.ts +92 -0
  50. package/dist/src/builtinTools/tools.d.ts +13 -0
  51. package/dist/src/constant.d.ts +1 -1
  52. package/dist/src/index.d.ts +2 -1
  53. package/dist/src/localFiles/adapters/FileSnapshotAdapter.d.ts +24 -0
  54. package/dist/src/localFiles/adapters/HostBridgeAdapter.d.ts +7 -4
  55. package/dist/src/localFiles/adapters/WorkspaceFileAdapter.d.ts +8 -0
  56. package/dist/src/localFiles/constants.d.ts +4 -13
  57. package/dist/src/localFiles/errors.d.ts +1 -1
  58. package/dist/src/localFiles/host/protocol.d.ts +14 -3
  59. package/dist/src/localFiles/host/sandboxClient.d.ts +50 -0
  60. package/dist/src/localFiles/index.d.ts +9 -5
  61. package/dist/src/localFiles/preview.d.ts +2 -0
  62. package/dist/src/localFiles/schemas.d.ts +0 -2
  63. package/dist/src/localFiles/types.d.ts +2 -22
  64. package/dist/src/localFiles/workspace/LocalWorkspace.d.ts +25 -3
  65. package/dist/src/localFiles/workspace/WorkspaceFiles.d.ts +63 -0
  66. package/dist/src/localMcp/client.d.ts +15 -0
  67. package/dist/src/localMcp/endpoints.d.ts +19 -0
  68. package/dist/src/localMcp/register.d.ts +34 -0
  69. package/dist/src/localMcp/registry.d.ts +27 -0
  70. package/dist/src/sessionUpload.d.ts +14 -0
  71. package/dist/src/utils.d.ts +6 -0
  72. package/package.json +4 -24
@@ -0,0 +1,248 @@
1
+ var b = Object.defineProperty;
2
+ var v = (e, t, n) => t in e ? b(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var y = (e, t, n) => (v(e, typeof t != "symbol" ? t + "" : t, n), n);
4
+ var o = (e, t, n) => new Promise((s, i) => {
5
+ var r = (a) => {
6
+ try {
7
+ d(n.next(a));
8
+ } catch (h) {
9
+ i(h);
10
+ }
11
+ }, l = (a) => {
12
+ try {
13
+ d(n.throw(a));
14
+ } catch (h) {
15
+ i(h);
16
+ }
17
+ }, d = (a) => a.done ? s(a.value) : Promise.resolve(a.value).then(r, l);
18
+ d((n = n.apply(e, t)).next());
19
+ });
20
+ import w from "../Logger.mjs";
21
+ import { ToolError as c, ToolCode as p } from "../localFiles/errors.mjs";
22
+ import { isExpired as g } from "../utils.mjs";
23
+ const u = new w("[PlatformSkills] "), S = 20 * 1024 * 1024, k = /^[A-Za-z0-9._-]+$/;
24
+ function f(e) {
25
+ const t = e == null ? void 0 : e.skills;
26
+ return Array.isArray(t) ? t.filter((n) => n && typeof n == "object") : [];
27
+ }
28
+ function m(e, t) {
29
+ t && (e.skills = t.skills);
30
+ }
31
+ function P(e) {
32
+ return o(this, null, function* () {
33
+ var n;
34
+ if (!e.arrange)
35
+ return;
36
+ const t = yield e.fetchApplication();
37
+ e.stillCurrent && !e.stillCurrent() || m(e.arrange, (n = t == null ? void 0 : t.arrange) == null ? void 0 : n[0]);
38
+ });
39
+ }
40
+ function x(e) {
41
+ if (!e)
42
+ return !1;
43
+ try {
44
+ return !g(e);
45
+ } catch (t) {
46
+ return !1;
47
+ }
48
+ }
49
+ function I(e) {
50
+ if (!(typeof e.skillId != "string" || !k.test(e.skillId)) && !(typeof e.name != "string" || !e.name || /[\\/\0]/.test(e.name) || e.name === "." || e.name === "..") && !(typeof e.version != "number" || !Number.isInteger(e.version) || e.version < 1))
51
+ return {
52
+ skillId: e.skillId,
53
+ name: e.name,
54
+ version: e.version
55
+ };
56
+ }
57
+ function $(e) {
58
+ return Array.isArray(e) ? e.flatMap((t) => {
59
+ if (!t || typeof t != "object")
60
+ return [];
61
+ const n = t;
62
+ return typeof n.skillId != "string" || typeof n.name != "string" || typeof n.version != "number" ? [] : [{
63
+ skillId: n.skillId,
64
+ name: n.name,
65
+ version: n.version
66
+ }];
67
+ }) : [];
68
+ }
69
+ class B {
70
+ constructor(t) {
71
+ y(this, "inflight", /* @__PURE__ */ new Map());
72
+ y(this, "busy", /* @__PURE__ */ new Set());
73
+ this.options = t;
74
+ }
75
+ /** 进入会话时调用。不阻塞历史,也不改沙箱就绪。 */
76
+ sync() {
77
+ const t = f({
78
+ skills: this.options.getSkills()
79
+ });
80
+ return u.log("sync", {
81
+ count: t.length,
82
+ sandbox: !!this.options.getSandbox()
83
+ }), this.reconcile().catch((n) => {
84
+ u.error("sync failed", n instanceof Error ? n.message : String(n));
85
+ });
86
+ }
87
+ read(t, n, s) {
88
+ return o(this, null, function* () {
89
+ const i = yield this.prepare(t, s);
90
+ return this.requireSandbox().skillRead(this.options.applicationId(), i.skillId, i.version, n, s);
91
+ });
92
+ }
93
+ list(t, n, s) {
94
+ return o(this, null, function* () {
95
+ const i = yield this.prepare(t, s);
96
+ return this.requireSandbox().skillList(this.options.applicationId(), i.skillId, i.version, n, s);
97
+ });
98
+ }
99
+ grep(t, n, s, i) {
100
+ return o(this, null, function* () {
101
+ const r = yield this.prepare(t, i);
102
+ return this.requireSandbox().skillGrep(this.options.applicationId(), r.skillId, r.version, s, n, i);
103
+ });
104
+ }
105
+ target(t, n) {
106
+ return o(this, null, function* () {
107
+ const s = yield this.prepare(t, n);
108
+ return {
109
+ applicationId: this.options.applicationId(),
110
+ skillId: s.skillId,
111
+ version: s.version,
112
+ name: s.name
113
+ };
114
+ });
115
+ }
116
+ track(t, n) {
117
+ const s = `${t}/${n}`;
118
+ this.busy.add(s);
119
+ let i = !1;
120
+ return () => {
121
+ i || (i = !0, this.busy.delete(s), this.prune().catch(() => {
122
+ }));
123
+ };
124
+ }
125
+ requireSandbox() {
126
+ const t = this.options.getSandbox();
127
+ if (!t)
128
+ throw new c(p.NotImplemented, "当前环境不能加载平台技能,需要端侧宿主。");
129
+ return t;
130
+ }
131
+ prepare(t, n) {
132
+ return o(this, null, function* () {
133
+ const s = this.bound(t);
134
+ if (!s)
135
+ throw new c(p.NotFound, "技能或资源不存在。");
136
+ return yield this.ensure(s, n), s;
137
+ });
138
+ }
139
+ bound(t) {
140
+ if (!k.test(this.options.applicationId()))
141
+ return;
142
+ const n = f({
143
+ skills: this.options.getSkills()
144
+ }).find((s) => s.name === t);
145
+ return n ? I(n) : void 0;
146
+ }
147
+ reconcile() {
148
+ return o(this, null, function* () {
149
+ if (!this.options.getSandbox())
150
+ return;
151
+ const n = f({
152
+ skills: this.options.getSkills()
153
+ }).flatMap((s) => {
154
+ const i = I(s);
155
+ return i ? [i] : [];
156
+ });
157
+ yield Promise.all(n.map((s) => this.ensure(s).catch((i) => {
158
+ u.error("install failed", s.name, i instanceof Error ? i.message : String(i));
159
+ }))), yield this.prune();
160
+ });
161
+ }
162
+ ensure(t, n) {
163
+ return o(this, null, function* () {
164
+ const s = `${this.options.applicationId()}/${t.skillId}/${t.version}`, i = this.inflight.get(s);
165
+ if (i)
166
+ return i;
167
+ const r = this.installIfNeeded(t, n).finally(() => {
168
+ this.inflight.get(s) === r && this.inflight.delete(s);
169
+ });
170
+ return this.inflight.set(s, r), r;
171
+ });
172
+ }
173
+ installIfNeeded(t, n) {
174
+ return o(this, null, function* () {
175
+ var a;
176
+ const s = this.requireSandbox();
177
+ if (s.ready && (yield this.alreadyInstalled(s, t, n))) {
178
+ u.log("installed", t.name, t.version);
179
+ return;
180
+ }
181
+ u.log("download", t.name, t.skillId, t.version);
182
+ const i = this.options.getToken();
183
+ if (!x(i))
184
+ throw new c(p.Forbidden, "技能下载令牌不可用。");
185
+ const r = this.options.apiRoot().replace(/\/$/, ""), l = yield ((a = this.options.fetch) != null ? a : fetch)(`${r}/skill/v1/skills/${encodeURIComponent(t.skillId)}/versions/${t.version}/download`, {
186
+ headers: {
187
+ Authorization: `Bearer ${i}`
188
+ },
189
+ signal: n
190
+ });
191
+ if (!l.ok)
192
+ throw new c(p.BadRequest, `技能下载失败(${l.status})。`);
193
+ const d = new Uint8Array(yield l.arrayBuffer());
194
+ if (d.byteLength > S)
195
+ throw new c(p.BadRequest, "技能压缩包超过 20 MB。");
196
+ yield this.waitReady(s, n), !(yield this.alreadyInstalled(s, t, n)) && (yield s.installSkill({
197
+ applicationId: this.options.applicationId(),
198
+ skillId: t.skillId,
199
+ version: t.version,
200
+ name: t.name
201
+ }, d, n));
202
+ });
203
+ }
204
+ alreadyInstalled(t, n, s) {
205
+ return o(this, null, function* () {
206
+ return $(yield t.skillStatus(this.options.applicationId(), s)).some((r) => r.skillId === n.skillId && r.version === n.version && r.name === n.name);
207
+ });
208
+ }
209
+ prune() {
210
+ return o(this, null, function* () {
211
+ const t = this.options.getSandbox();
212
+ if (!(t != null && t.ready))
213
+ return;
214
+ const n = f({
215
+ skills: this.options.getSkills()
216
+ }).flatMap((i) => typeof i.skillId != "string" || typeof i.version != "number" || i.version < 1 ? [] : [{
217
+ skillId: i.skillId,
218
+ version: i.version
219
+ }]), s = [...this.busy].map((i) => {
220
+ const [r, l] = i.split("/");
221
+ return {
222
+ skillId: r,
223
+ version: Number(l)
224
+ };
225
+ });
226
+ yield t.skillPrune(this.options.applicationId(), n, s);
227
+ });
228
+ }
229
+ waitReady(t, n) {
230
+ return o(this, null, function* () {
231
+ t.ready || (yield new Promise((s, i) => {
232
+ const r = setInterval(() => {
233
+ if (n != null && n.aborted) {
234
+ clearInterval(r), i(new c(p.Cancelled, "已取消。"));
235
+ return;
236
+ }
237
+ t.ready && (clearInterval(r), s());
238
+ }, 50);
239
+ }));
240
+ });
241
+ }
242
+ }
243
+ export {
244
+ B as PlatformSkillSync,
245
+ m as assignArrangeSkills,
246
+ f as listedSkills,
247
+ P as pullArrangeSkills
248
+ };
@@ -1,13 +1,13 @@
1
- import { MAX_COMMAND_CHARS as s, MAX_WRITE_BYTES as n, BUILTIN_FUNCTION_CODES as r } from "./constants.mjs";
1
+ import { MAX_COMMAND_CHARS as o, MAX_WRITE_BYTES as r, BUILTIN_FUNCTION_CODES as p } from "./constants.mjs";
2
2
  const e = (i) => ({
3
3
  type: "string",
4
4
  minLength: 1,
5
5
  description: i
6
- }), t = "必填。工作区内绝对路径,以 / 开头,例如 /说明.md。不要使用 /input、/output、/uploads、/tmp,也不要新建这些目录。", o = {
6
+ }), n = "脚本能否联网由运行环境决定;被宿主网络策略拒绝的地址会在结果里列出。", t = "必填。工作区内路径。以 / 开头,例如 /说明.md;也可以不写开头的斜杠,例如 notes/a.md。不要使用 input、output、uploads、tmp,也不要新建这些目录。", a = {
7
7
  shell: {
8
8
  functionCode: "shell",
9
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 把大文件正文打到标准输出。",
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 把大文件正文打到标准输出。${n}`,
11
11
  parameters: {
12
12
  type: "object",
13
13
  required: ["command"],
@@ -15,7 +15,7 @@ const e = (i) => ({
15
15
  command: {
16
16
  type: "string",
17
17
  minLength: 1,
18
- maxLength: s,
18
+ maxLength: o,
19
19
  description: "必填。一条不超过 20000 字的 shell 命令。当前目录已是工作区根目录。可以包含短的 python 或 heredoc。读取文件正文请改用 read_file。"
20
20
  }
21
21
  }
@@ -24,7 +24,7 @@ const e = (i) => ({
24
24
  read_file: {
25
25
  functionCode: "read_file",
26
26
  name: "读取文件",
27
- description: "按绝对路径读取工作区内的文本文件并返回内容;读不到时返回失败原因。未超过上限的文本按原文返回;超过单次读取上限的结构化文本(JSON/XML/SVG/CSV/TSV)会先附带通用结构概览和短预览,需要特定片段时再用 start_line 和 end_line。PDF 和图片只返回文件摘要,不返回正文。",
27
+ description: "读取工作区内的文本文件并返回内容;读不到时返回失败原因。path 可以以 / 开头,也可以不写开头的斜杠。未超过上限的文本按原文返回;超过单次读取上限的结构化文本(JSON/XML/SVG/CSV/TSV)会先附带通用结构概览和短预览,需要特定片段时再用 start_line 和 end_line。PDF 和图片只返回文件摘要,不返回正文。",
28
28
  parameters: {
29
29
  type: "object",
30
30
  required: ["path"],
@@ -46,7 +46,7 @@ const e = (i) => ({
46
46
  write_file: {
47
47
  functionCode: "write_file",
48
48
  name: "写入文件",
49
- description: `把文本写入工作区内文件,path 为工作区内绝对路径,文件已存在时覆盖。单次覆盖写入按 UTF-8 字节计,默认不超过 ${n} 字节。超限时先写一段,再用 edit_file 修改,或用 append_file 追加下一段。SVG 和整页 HTML 由工作区里的脚本生成,不要直接放进 content。`,
49
+ description: `把文本写入工作区内文件。path 可以是以 / 开头的工作区路径,也可以不带开头斜杠,例如 /说明.md、notes/a.md。文件已存在时覆盖。单次覆盖写入按 UTF-8 字节计,默认不超过 ${r} 字节。超限时先写一段,再用 edit_file 修改,或用 append_file 追加下一段。SVG 和整页 HTML 由工作区里的脚本生成,不要直接放进 content。`,
50
50
  parameters: {
51
51
  type: "object",
52
52
  required: ["path", "content"],
@@ -54,7 +54,7 @@ const e = (i) => ({
54
54
  path: e(t),
55
55
  content: {
56
56
  type: "string",
57
- description: `必填。覆盖写入的文本,UTF-8 不超过 ${n} 字节。不要放入 SVG 或整页 HTML。`
57
+ description: `必填。覆盖写入的文本,UTF-8 不超过 ${r} 字节。不要放入 SVG 或整页 HTML。`
58
58
  }
59
59
  }
60
60
  }
@@ -62,7 +62,7 @@ const e = (i) => ({
62
62
  append_file: {
63
63
  functionCode: "append_file",
64
64
  name: "追加文件",
65
- description: "把一段文本追加到工作区内文件末尾,path 为工作区内绝对路径,文件不存在时创建。覆盖写入超过字节上限时,用本工具把下一段接到同一文件。追加不设字节上限,但不要在一次调用里放入整份 HTML 或 SVG。",
65
+ description: "把一段文本追加到工作区内文件末尾。path 可以以 / 开头,也可以不写开头的斜杠。文件不存在时创建。覆盖写入超过字节上限时,用本工具把下一段接到同一文件。追加不设字节上限,但不要在一次调用里放入整份 HTML 或 SVG。",
66
66
  parameters: {
67
67
  type: "object",
68
68
  required: ["path", "content"],
@@ -78,12 +78,12 @@ const e = (i) => ({
78
78
  run_file: {
79
79
  functionCode: "run_file",
80
80
  name: "执行文件",
81
- description: "执行工作区里已经存在的 .py、.sh 或 .js 脚本文件。生成 SVG、HTML、JSON 等产物时优先使用:先用 write_file 写脚本,脚本自行读取工作区文件并写出产物,再调用本工具。脚本运行时当前目录是工作区根目录,脚本里访问工作区文件要写相对路径,例如 data.json、notes/a.py。不要使用或新建 input、output、uploads、tmp。需要查看文件正文时用 read_file,不要把整份文件打印到标准输出。",
81
+ description: `执行工作区里已经存在的 .py、.sh、.bash、.js、.mjs 或 .cjs 脚本文件。生成 SVG、HTML、JSON 等产物时优先使用:先用 write_file 写脚本,脚本自行读取工作区文件并写出产物,再调用本工具。脚本运行时当前目录是工作区根目录,脚本里访问工作区文件要写相对路径,例如 data.json、notes/a.py。不要使用或新建 input、output、uploads、tmp。需要查看文件正文时用 read_file,不要把整份文件打印到标准输出。${n}`,
82
82
  parameters: {
83
83
  type: "object",
84
84
  required: ["path"],
85
85
  properties: {
86
- path: e("必填。要执行的 .py、.sh 或 .js 文件,工作区内绝对路径,例如 /scripts/gen.py。")
86
+ path: e("必填。要执行的 .py、.sh、.bash、.js、.mjs 或 .cjs 文件。可以是 /scripts/gen.py,也可以是 scripts/gen.py。")
87
87
  }
88
88
  }
89
89
  },
@@ -111,7 +111,7 @@ const e = (i) => ({
111
111
  grep: {
112
112
  functionCode: "grep",
113
113
  name: "搜索文件",
114
- description: "在工作区目录中递归搜索文本,返回带行号的匹配行。path 为工作区内绝对路径,pattern 按 grep 基本正则匹配。用于定位内容,不要用来取回大文件全文。",
114
+ description: "在工作区目录中递归搜索文本,返回带行号的匹配行。path 可以以 / 开头,也可以不写开头的斜杠。pattern 按 grep 基本正则匹配。用于定位内容,不要用来取回大文件全文。",
115
115
  parameters: {
116
116
  type: "object",
117
117
  required: ["path", "pattern"],
@@ -128,7 +128,7 @@ const e = (i) => ({
128
128
  find: {
129
129
  functionCode: "find",
130
130
  name: "查找文件",
131
- description: "按文件名通配在工作区目录中查找文件。path 为起始绝对路径,name 传给 find 的 -name,例如 *.html。",
131
+ description: "按文件名通配在工作区目录中查找文件。path 为起始路径,可以以 / 开头,也可以不写开头的斜杠。name 传给 find 的 -name,例如 *.html。",
132
132
  parameters: {
133
133
  type: "object",
134
134
  required: ["path", "name"],
@@ -145,7 +145,7 @@ const e = (i) => ({
145
145
  load_skill: {
146
146
  functionCode: "load_skill",
147
147
  name: "加载技能",
148
- description: "按技能名称加载指定技能的完整说明(SKILL.md)。",
148
+ description: "按技能名称加载平台技能的完整说明(SKILL.md),并附上技能包内全部文件的相对路径。技能不在工程目录里。之后用 read_skill_resource 按这些路径读取,或用 grep_skill 搜索。",
149
149
  parameters: {
150
150
  type: "object",
151
151
  required: ["skill_name"],
@@ -161,7 +161,7 @@ const e = (i) => ({
161
161
  read_skill_resource: {
162
162
  functionCode: "read_skill_resource",
163
163
  name: "读取技能资源",
164
- description: "读取与指定技能关联的资源文件,例如参考资料、模板或附加说明。",
164
+ description: "读取技能包内的文本。resource_name 是相对技能根目录的路径。传目录则列出该目录下的文件;传 . 列出整个技能包;以 grep: 开头则按基本正则搜索,例如 grep:portrait。",
165
165
  parameters: {
166
166
  type: "object",
167
167
  required: ["skill_name", "resource_name"],
@@ -179,10 +179,55 @@ const e = (i) => ({
179
179
  }
180
180
  }
181
181
  },
182
+ list_skill_files: {
183
+ functionCode: "list_skill_files",
184
+ name: "列出技能文件",
185
+ description: "列出平台技能包内的文件和目录。不传 path 时列出整个技能包。技能不在工程目录里。",
186
+ parameters: {
187
+ type: "object",
188
+ required: ["skill_name"],
189
+ properties: {
190
+ skill_name: {
191
+ type: "string",
192
+ minLength: 1,
193
+ description: "必填。技能名称。"
194
+ },
195
+ path: {
196
+ type: "string",
197
+ description: "可选。技能包内的相对目录,例如 skills 或 tools/dwgkit。省略则从技能根目录列出。"
198
+ }
199
+ }
200
+ }
201
+ },
202
+ grep_skill: {
203
+ functionCode: "grep_skill",
204
+ name: "搜索技能内容",
205
+ description: "在平台技能包内按 grep 基本正则搜索文本,返回路径、行号和匹配行。",
206
+ parameters: {
207
+ type: "object",
208
+ required: ["skill_name", "pattern"],
209
+ properties: {
210
+ skill_name: {
211
+ type: "string",
212
+ minLength: 1,
213
+ description: "必填。技能名称。"
214
+ },
215
+ pattern: {
216
+ type: "string",
217
+ minLength: 1,
218
+ description: "必填。grep 基本正则,例如 portrait 或 def .*。"
219
+ },
220
+ path: {
221
+ type: "string",
222
+ description: "可选。只搜索该相对目录或文件,例如 skills/cad-drawing-understanding。"
223
+ }
224
+ }
225
+ }
226
+ },
182
227
  run_skill_script: {
183
228
  functionCode: "run_skill_script",
184
229
  name: "运行技能脚本",
185
- description: "在当前会话工作区中执行与指定技能关联的脚本并返回输出。脚本运行时当前目录是工作区根目录,参数里的文件路径按相对工作区根目录传,例如 docs/a.docx。",
230
+ description: `执行平台技能包内的脚本并返回输出。当前目录是工作区根目录,参数里的用户文件按相对工作区根目录传,例如 docs/a.docx。技能自己的资源按脚本文件所在目录查找,不在工程的 skills 目录里。${n}`,
186
231
  parameters: {
187
232
  type: "object",
188
233
  required: ["skill_name", "script_name"],
@@ -208,9 +253,9 @@ const e = (i) => ({
208
253
  }
209
254
  }
210
255
  }
211
- }, p = Object.keys(o);
212
- if (p.length !== r.length || r.some((i) => !p.includes(i)))
256
+ }, s = Object.keys(a);
257
+ if (s.length !== p.length || p.some((i) => !s.includes(i)))
213
258
  throw new Error("BUILTIN_TOOL_SCHEMAS 与 BUILTIN_FUNCTION_CODES 不一致");
214
259
  export {
215
- o as BUILTIN_TOOL_SCHEMAS
260
+ a as BUILTIN_TOOL_SCHEMAS
216
261
  };