@glodon-aiot/bot-client-sdk 3.26.0-alpha.13 → 3.26.0-alpha.14

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.
@@ -1,130 +1,130 @@
1
- var l = (t, n, e) => new Promise((r, o) => {
2
- var c = (a) => {
1
+ var l = (t, e, n) => new Promise((r, s) => {
2
+ var a = (i) => {
3
3
  try {
4
- s(e.next(a));
4
+ c(n.next(i));
5
5
  } catch (f) {
6
- o(f);
6
+ s(f);
7
7
  }
8
- }, i = (a) => {
8
+ }, o = (i) => {
9
9
  try {
10
- s(e.throw(a));
10
+ c(n.throw(i));
11
11
  } catch (f) {
12
- o(f);
12
+ s(f);
13
13
  }
14
- }, s = (a) => a.done ? r(a.value) : Promise.resolve(a.value).then(c, i);
15
- s((e = e.apply(t, n)).next());
14
+ }, c = (i) => i.done ? r(i.value) : Promise.resolve(i.value).then(a, o);
15
+ c((n = n.apply(t, e)).next());
16
16
  });
17
- import { throwIfAborted as x, ToolError as d, ToolCode as u } from "../localFiles/errors.mjs";
18
- import { looksBinary as g, utf8ByteLength as v, readBytes as j } from "../localFiles/tools/runtime.mjs";
19
- import { MAX_READ_BYTES as _, MAX_WRITE_BYTES as k, RUNNABLE_EXTENSIONS as A, SHELL_CWD as U } from "./constants.mjs";
20
- import { isImagePath as M, isPdf as I, isStructuredPath as z, structureOverview as W, extensionOf as X } from "./overview.mjs";
21
- import { resolveFilePath as m, resolveRunPath as Y, mentionsSyntheticDir as C, SYNTHETIC_DIR_MESSAGE as H, isSafeCwd as G, skillRelative as $, toVirtualPath as B } from "./paths.mjs";
22
- function E(t) {
17
+ import { throwIfAborted as g, ToolError as d, ToolCode as u } from "../localFiles/errors.mjs";
18
+ import { looksBinary as x, utf8ByteLength as M, readBytes as U } from "../localFiles/tools/runtime.mjs";
19
+ import { MAX_READ_BYTES as R, MAX_WRITE_BYTES as T, SHELL_CWD as I, RUNNABLE_EXTENSIONS as z } from "./constants.mjs";
20
+ import { isImagePath as L, isPdf as v, isStructuredPath as W, structureOverview as X, extensionOf as Y } from "./overview.mjs";
21
+ import { resolveFilePath as m, resolveRunPath as H, mentionsSkillDir as b, mentionsSyntheticDir as C, SYNTHETIC_DIR_MESSAGE as G, isSafeCwd as K, skillRelative as N, toVirtualPath as $ } from "./paths.mjs";
22
+ function D(t) {
23
23
  return !!t && typeof t == "object" && t.name === "NotFoundError";
24
24
  }
25
- function p(t) {
25
+ function y(t) {
26
26
  try {
27
27
  return new TextDecoder("utf-8", {
28
28
  fatal: !0
29
29
  }).decode(t);
30
- } catch (n) {
30
+ } catch (e) {
31
31
  throw new d(u.BadRequest, "文件不是 UTF-8 文本。");
32
32
  }
33
33
  }
34
- function T(t) {
34
+ function S(t) {
35
35
  return t === "" ? [] : (t.endsWith(`
36
36
  `) ? t.slice(0, -1) : t).split(`
37
37
  `);
38
38
  }
39
- function K(t, n, e) {
40
- if (n !== void 0 && e !== void 0 && e < n)
39
+ function V(t, e, n) {
40
+ if (e !== void 0 && n !== void 0 && n < e)
41
41
  throw new d(u.BadRequest, "end_line 不能小于 start_line。");
42
- const r = T(t), o = Math.max((n != null ? n : 1) - 1, 0), c = e != null ? e : r.length;
43
- return r.slice(o, c).join(`
42
+ const r = S(t), s = Math.max((e != null ? e : 1) - 1, 0), a = n != null ? n : r.length;
43
+ return r.slice(s, a).join(`
44
44
  `);
45
45
  }
46
- function q(t) {
47
- if (v(t) <= _)
46
+ function F(t) {
47
+ if (M(t) <= R)
48
48
  return {
49
49
  text: t,
50
50
  truncated: !1
51
51
  };
52
- const n = new TextEncoder().encode(t);
53
- let e = _;
54
- for (; e > 0 && (n[e] & 192) === 128; )
55
- e -= 1;
56
- const r = new TextDecoder().decode(n.slice(0, e)), o = r.lastIndexOf(`
52
+ const e = new TextEncoder().encode(t);
53
+ let n = R;
54
+ for (; n > 0 && (e[n] & 192) === 128; )
55
+ n -= 1;
56
+ const r = new TextDecoder().decode(e.slice(0, n)), s = r.lastIndexOf(`
57
57
  `);
58
58
  return {
59
- text: o > 0 ? r.slice(0, o) : r,
59
+ text: s > 0 ? r.slice(0, s) : r,
60
60
  truncated: !0
61
61
  };
62
62
  }
63
- function y(t, n) {
63
+ function p(t, e) {
64
64
  return l(this, null, function* () {
65
- const e = yield t.stat(n);
66
- if (e.kind !== "file")
65
+ const n = yield t.stat(e);
66
+ if (n.kind !== "file")
67
67
  throw new d(u.BadRequest, "目标是目录,不是文件。");
68
- const r = yield j(yield t.readFile(n));
68
+ const r = yield U(yield t.readFile(e));
69
69
  return {
70
- entry: e,
70
+ entry: n,
71
71
  bytes: r
72
72
  };
73
73
  });
74
74
  }
75
- function L(t, n, e) {
76
- const r = typeof e == "number" ? `${e} 字节,` : "";
77
- return `${t},${r}路径 ${B(n)}。不返回正文。`;
75
+ function q(t, e, n) {
76
+ const r = typeof n == "number" ? `${n} 字节,` : "";
77
+ return `${t},${r}路径 ${$(e)}。不返回正文。`;
78
78
  }
79
- function S(t) {
80
- const n = X(t);
81
- if (!A.includes(n))
79
+ function _(t) {
80
+ const e = Y(t);
81
+ if (!z.includes(e))
82
82
  throw new d(u.BadRequest, "只能执行 .py、.sh 或 .js 文件。");
83
- return n === ".py" ? "python3" : n === ".js" ? "node" : "sh";
83
+ return e === ".py" ? "python3" : e === ".js" ? "node" : "sh";
84
84
  }
85
- function N(t) {
85
+ function O(t) {
86
86
  if (!t.runner)
87
87
  throw new d(u.NotImplemented, "当前环境不能执行命令或脚本,需要端侧宿主。");
88
88
  return t.runner;
89
89
  }
90
- function b(t, n, e, r) {
90
+ function B(t, e, n, r) {
91
91
  return l(this, null, function* () {
92
- yield t.writeFile(n, e, {
92
+ yield t.writeFile(e, n, {
93
93
  createDirectories: !0,
94
94
  signal: r
95
95
  });
96
96
  });
97
97
  }
98
- function at(t, n) {
98
+ function dt(t, e) {
99
99
  return l(this, null, function* () {
100
- const e = m(t.path);
101
- if (x(n.signal), M(e)) {
102
- const a = yield n.adapter.stat(e);
103
- if (a.kind !== "file")
100
+ const n = m(t.path);
101
+ if (g(e.signal), L(n)) {
102
+ const i = yield e.adapter.stat(n);
103
+ if (i.kind !== "file")
104
104
  throw new d(u.BadRequest, "目标是目录,不是文件。");
105
105
  return {
106
106
  data: {
107
- content: L("图片", e, a.size),
107
+ content: q("图片", n, i.size),
108
108
  truncated: !1
109
109
  }
110
110
  };
111
111
  }
112
112
  const {
113
113
  entry: r,
114
- bytes: o
115
- } = yield y(n.adapter, e);
116
- if (I(e, o))
114
+ bytes: s
115
+ } = yield p(e.adapter, n);
116
+ if (v(n, s))
117
117
  return {
118
118
  data: {
119
- content: L("PDF", e, r.size),
119
+ content: q("PDF", n, r.size),
120
120
  truncated: !1
121
121
  }
122
122
  };
123
- if (g(o))
123
+ if (x(s))
124
124
  throw new d(u.BadRequest, "文件不是文本,无法读取正文。");
125
- const c = p(o);
125
+ const a = y(s);
126
126
  if (t.start_line !== void 0 || t.end_line !== void 0) {
127
- const a = K(c, t.start_line, t.end_line), f = q(a);
127
+ const i = V(a, t.start_line, t.end_line), f = F(i);
128
128
  return {
129
129
  data: {
130
130
  content: f.text,
@@ -132,278 +132,280 @@ function at(t, n) {
132
132
  }
133
133
  };
134
134
  }
135
- if (o.byteLength > _ && z(e))
135
+ if (s.byteLength > R && W(n))
136
136
  return {
137
137
  data: {
138
- content: W(e, c),
138
+ content: X(n, a),
139
139
  truncated: !0
140
140
  }
141
141
  };
142
- const s = q(c);
142
+ const c = F(a);
143
143
  return {
144
144
  data: {
145
- content: s.text,
146
- truncated: s.truncated
145
+ content: c.text,
146
+ truncated: c.truncated
147
147
  }
148
148
  };
149
149
  });
150
150
  }
151
- function it(t, n) {
151
+ function ut(t, e) {
152
152
  return l(this, null, function* () {
153
- const e = m(t.path);
154
- if (v(t.content) > k)
155
- throw new d(u.TooLarge, `content 按 UTF-8 计超过 ${k} 字节。请缩短后写入,或改用 append_file、edit_file。`);
156
- return x(n.signal), yield b(n.adapter, e, t.content, n.signal), {
153
+ const n = m(t.path);
154
+ if (M(t.content) > T)
155
+ throw new d(u.TooLarge, `content 按 UTF-8 计超过 ${T} 字节。请缩短后写入,或改用 append_file、edit_file。`);
156
+ return g(e.signal), yield B(e.adapter, n, t.content, e.signal), {
157
157
  data: {}
158
158
  };
159
159
  });
160
160
  }
161
- function lt(t, n) {
161
+ function ft(t, e) {
162
162
  return l(this, null, function* () {
163
- const e = m(t.path);
164
- x(n.signal);
163
+ const n = m(t.path);
164
+ g(e.signal);
165
165
  let r = "";
166
166
  try {
167
167
  const {
168
- bytes: o
169
- } = yield y(n.adapter, e);
170
- if (g(o))
168
+ bytes: s
169
+ } = yield p(e.adapter, n);
170
+ if (x(s))
171
171
  throw new d(u.BadRequest, "文件不是文本,无法追加。");
172
- r = p(o);
173
- } catch (o) {
174
- if (!E(o))
175
- throw o;
172
+ r = y(s);
173
+ } catch (s) {
174
+ if (!D(s))
175
+ throw s;
176
176
  }
177
- return yield b(n.adapter, e, r + t.content, n.signal), {
177
+ return yield B(e.adapter, n, r + t.content, e.signal), {
178
178
  data: {}
179
179
  };
180
180
  });
181
181
  }
182
- function dt(t, n) {
182
+ function wt(t, e) {
183
183
  return l(this, null, function* () {
184
- const e = m(t.path);
185
- x(n.signal);
184
+ const n = m(t.path);
185
+ g(e.signal);
186
186
  const {
187
187
  bytes: r
188
- } = yield y(n.adapter, e);
189
- if (g(r))
188
+ } = yield p(e.adapter, n);
189
+ if (x(r))
190
190
  throw new d(u.BadRequest, "文件不是文本,无法修改。");
191
- const o = p(r), c = o.indexOf(t.old_text);
192
- if (c < 0) {
193
- const s = V(o, t.old_text);
194
- throw new d(u.BadRequest, `找不到与 old_text 完全相同的内容。最接近的原文从第 ${s.line} 行开始,可复制后重试:
195
- ${s.excerpt}`, {
196
- line: s.line,
197
- excerpt: s.excerpt
191
+ const s = y(r), a = s.indexOf(t.old_text);
192
+ if (a < 0) {
193
+ const c = J(s, t.old_text);
194
+ throw new d(u.BadRequest, `找不到与 old_text 完全相同的内容。最接近的原文从第 ${c.line} 行开始,可复制后重试:
195
+ ${c.excerpt}`, {
196
+ line: c.line,
197
+ excerpt: c.excerpt
198
198
  });
199
199
  }
200
- const i = o.slice(0, c) + t.new_text + o.slice(c + t.old_text.length);
201
- return yield b(n.adapter, e, i, n.signal), {
200
+ const o = s.slice(0, a) + t.new_text + s.slice(a + t.old_text.length);
201
+ return yield B(e.adapter, n, o, e.signal), {
202
202
  data: {}
203
203
  };
204
204
  });
205
205
  }
206
- function V(t, n) {
207
- var a;
208
- const e = T(t);
209
- if (e.length === 0)
206
+ function J(t, e) {
207
+ var i;
208
+ const n = S(t);
209
+ if (n.length === 0)
210
210
  return {
211
211
  line: 1,
212
212
  excerpt: ""
213
213
  };
214
- const r = n.split(`
215
- `), o = ((a = r[0]) != null ? a : "").slice(0, 200);
216
- let c = 0, i = -1;
217
- for (let f = 0; f < e.length; f += 1) {
218
- const w = J(e[f], o);
219
- w > i && (i = w, c = f);
214
+ const r = e.split(`
215
+ `), s = ((i = r[0]) != null ? i : "").slice(0, 200);
216
+ let a = 0, o = -1;
217
+ for (let f = 0; f < n.length; f += 1) {
218
+ const w = Q(n[f], s);
219
+ w > o && (o = w, a = f);
220
220
  }
221
- const s = Math.min(Math.max(r.length, 1), 8);
221
+ const c = Math.min(Math.max(r.length, 1), 8);
222
222
  return {
223
- line: c + 1,
224
- excerpt: e.slice(c, c + s).join(`
223
+ line: a + 1,
224
+ excerpt: n.slice(a, a + c).join(`
225
225
  `)
226
226
  };
227
227
  }
228
- function J(t, n) {
229
- if (!n)
228
+ function Q(t, e) {
229
+ if (!e)
230
230
  return 0;
231
- const e = t.toLowerCase(), r = n.toLowerCase();
232
- let o = 0, c = 0;
233
- for (const i of e)
234
- c < r.length && i === r[c] && (o += 1, c += 1);
235
- return o;
236
- }
237
- function Q(t) {
238
- let n = "";
239
- for (let e = 0; e < t.length; e += 1) {
240
- const r = t[e];
231
+ const n = t.toLowerCase(), r = e.toLowerCase();
232
+ let s = 0, a = 0;
233
+ for (const o of n)
234
+ a < r.length && o === r[a] && (s += 1, a += 1);
235
+ return s;
236
+ }
237
+ function Z(t) {
238
+ let e = "";
239
+ for (let n = 0; n < t.length; n += 1) {
240
+ const r = t[n];
241
241
  if (r === "\\") {
242
- const o = t[e + 1];
243
- if (o === void 0) {
244
- n += "\\\\";
242
+ const s = t[n + 1];
243
+ if (s === void 0) {
244
+ e += "\\\\";
245
245
  continue;
246
246
  }
247
- e += 1, n += "+?|{}()".includes(o) ? `\\${o}` : o === "n" ? "\\n" : o === "t" ? "\\t" : R(o);
247
+ n += 1, e += "+?|{}()".includes(s) ? `\\${s}` : s === "n" ? "\\n" : s === "t" ? "\\t" : k(s);
248
248
  continue;
249
249
  }
250
250
  if ("+?|{}()".includes(r)) {
251
- n += `\\${r}`;
251
+ e += `\\${r}`;
252
252
  continue;
253
253
  }
254
254
  if (r === "[") {
255
- const o = t.indexOf("]", e + 1);
256
- if (o < 0) {
257
- n += "\\[";
255
+ const s = t.indexOf("]", n + 1);
256
+ if (s < 0) {
257
+ e += "\\[";
258
258
  continue;
259
259
  }
260
- n += t.slice(e, o + 1), e = o;
260
+ e += t.slice(n, s + 1), n = s;
261
261
  continue;
262
262
  }
263
- n += ".^$*".includes(r) ? r : R(r);
263
+ e += ".^$*".includes(r) ? r : k(r);
264
264
  }
265
- return new RegExp(n);
265
+ return new RegExp(e);
266
266
  }
267
- function R(t) {
267
+ function k(t) {
268
268
  return /[\\^$.*+?()[\]{}|]/.test(t) ? `\\${t}` : t;
269
269
  }
270
- function Z(t) {
270
+ function tt(t) {
271
271
  try {
272
- return Q(t);
273
- } catch (n) {
272
+ return Z(t);
273
+ } catch (e) {
274
274
  throw new d(u.BadRequest, "pattern 不是合法的 grep 基本正则。");
275
275
  }
276
276
  }
277
- function F(t, n, e, r, o) {
277
+ function E(t, e, n, r, s) {
278
278
  return l(this, null, function* () {
279
279
  if (r > 16)
280
280
  return;
281
- x(e);
282
- const c = yield t.stat(n);
283
- if (yield o(n, c.kind), c.kind !== "directory")
281
+ g(n);
282
+ const a = yield t.stat(e);
283
+ if (yield s(e, a.kind), a.kind !== "directory")
284
284
  return;
285
- const i = yield t.listEntries(n, e);
286
- i.sort((s, a) => s.name < a.name ? -1 : s.name > a.name ? 1 : 0);
287
- for (const s of i) {
288
- const a = n ? `${n}/${s.name}` : s.name;
289
- yield F(t, a, e, r + 1, o);
285
+ const o = yield t.listEntries(e, n);
286
+ o.sort((c, i) => c.name < i.name ? -1 : c.name > i.name ? 1 : 0);
287
+ for (const c of o) {
288
+ const i = e ? `${e}/${c.name}` : c.name;
289
+ yield E(t, i, n, r + 1, s);
290
290
  }
291
291
  });
292
292
  }
293
- function ut(t, n) {
293
+ function ht(t, e) {
294
294
  return l(this, null, function* () {
295
- const e = m(t.path), r = Z(t.pattern), o = [];
296
- yield F(n.adapter, e, n.signal, 0, (i, s) => l(this, null, function* () {
297
- if (s !== "file" || o.length >= 200)
295
+ const n = m(t.path), r = tt(t.pattern), s = [];
296
+ yield E(e.adapter, n, e.signal, 0, (o, c) => l(this, null, function* () {
297
+ if (c !== "file" || s.length >= 200)
298
298
  return;
299
299
  const {
300
- bytes: a
301
- } = yield y(n.adapter, i);
302
- if (g(a) || M(i) || I(i, a))
300
+ bytes: i
301
+ } = yield p(e.adapter, o);
302
+ if (x(i) || L(o) || v(o, i))
303
303
  return;
304
304
  let f;
305
305
  try {
306
- f = p(a);
306
+ f = y(i);
307
307
  } catch (h) {
308
308
  return;
309
309
  }
310
- const w = T(f);
311
- for (let h = 0; h < w.length && o.length < 200; h += 1) {
310
+ const w = S(f);
311
+ for (let h = 0; h < w.length && s.length < 200; h += 1) {
312
312
  if (!r.test(w[h]))
313
313
  continue;
314
- const D = w[h].length > 500 ? `${w[h].slice(0, 500)}…` : w[h];
315
- o.push(`${B(i)}:${h + 1}:${D}`);
314
+ const A = w[h].length > 500 ? `${w[h].slice(0, 500)}…` : w[h];
315
+ s.push(`${$(o)}:${h + 1}:${A}`);
316
316
  }
317
317
  }));
318
- const c = o.join(`
318
+ const a = s.join(`
319
319
  `);
320
320
  return {
321
321
  data: {
322
- matches: o.length >= 200 ? `${c}
323
- (匹配过多,已截断)` : c
322
+ matches: s.length >= 200 ? `${a}
323
+ (匹配过多,已截断)` : a
324
324
  }
325
325
  };
326
326
  });
327
327
  }
328
- function tt(t, n) {
329
- let e = "^";
328
+ function et(t, e) {
329
+ let n = "^";
330
330
  for (let r = 0; r < t.length; r += 1) {
331
- const o = t[r];
332
- if (o === "*")
333
- e += ".*";
334
- else if (o === "?")
335
- e += ".";
336
- else if (o === "[") {
337
- const c = t.indexOf("]", r + 1);
338
- c < 0 ? e += "\\[" : (e += t.slice(r, c + 1), r = c);
331
+ const s = t[r];
332
+ if (s === "*")
333
+ n += ".*";
334
+ else if (s === "?")
335
+ n += ".";
336
+ else if (s === "[") {
337
+ const a = t.indexOf("]", r + 1);
338
+ a < 0 ? n += "\\[" : (n += t.slice(r, a + 1), r = a);
339
339
  } else
340
- e += R(o);
340
+ n += k(s);
341
341
  }
342
- return new RegExp(`${e}$`).test(n);
342
+ return new RegExp(`${n}$`).test(e);
343
343
  }
344
- function ft(t, n) {
344
+ function mt(t, e) {
345
345
  return l(this, null, function* () {
346
- const e = m(t.path), r = [];
347
- yield F(n.adapter, e, n.signal, 0, (c) => l(this, null, function* () {
348
- var s;
346
+ const n = m(t.path), r = [];
347
+ yield E(e.adapter, n, e.signal, 0, (a) => l(this, null, function* () {
348
+ var c;
349
349
  if (r.length >= 500)
350
350
  return;
351
- const i = (s = c.split("/").pop()) != null ? s : c;
352
- tt(t.name, i) && r.push(B(c));
351
+ const o = (c = a.split("/").pop()) != null ? c : a;
352
+ et(t.name, o) && r.push($(a));
353
353
  })), r.sort();
354
- const o = r.join(`
354
+ const s = r.join(`
355
355
  `);
356
356
  return {
357
357
  data: {
358
- files: r.length >= 500 ? `${o}
359
- (结果过多,已截断)` : o
358
+ files: r.length >= 500 ? `${s}
359
+ (结果过多,已截断)` : s
360
360
  }
361
361
  };
362
362
  });
363
363
  }
364
- function O(t, n, e) {
364
+ function nt(t, e, n) {
365
365
  return l(this, null, function* () {
366
- const r = N(e);
367
- yield y(e.adapter, t);
368
- const o = yield r.exec({
369
- argv: [S(t), t, ...n],
370
- cwd: U,
371
- timeoutMs: e.timeoutMs,
372
- signal: e.signal
366
+ const r = O(n);
367
+ yield p(n.adapter, t);
368
+ const s = yield r.exec({
369
+ argv: [_(t), t, ...e],
370
+ cwd: I,
371
+ timeoutMs: n.timeoutMs,
372
+ signal: n.signal
373
373
  });
374
374
  return {
375
375
  data: {
376
- exitCode: o.exitCode,
377
- stdout: o.stdout,
378
- stderr: o.stderr
376
+ exitCode: s.exitCode,
377
+ stdout: s.stdout,
378
+ stderr: s.stderr
379
379
  }
380
380
  };
381
381
  });
382
382
  }
383
- function wt(t, n) {
383
+ function gt(t, e) {
384
384
  return l(this, null, function* () {
385
- const e = Y(t.path);
386
- return S(e), O(e, [], n);
385
+ const n = H(t.path);
386
+ return _(n), nt(n, [], e);
387
387
  });
388
388
  }
389
- function ht(t, n) {
389
+ function xt(t, e) {
390
390
  return l(this, null, function* () {
391
- if (C(t.command) || C(n.shellCwd.cwd))
391
+ if (b(t.command) || b(e.shellCwd.cwd))
392
+ throw new d(u.Forbidden, "技能文件只能通过技能工具访问。");
393
+ if (C(t.command) || C(e.shellCwd.cwd))
392
394
  return {
393
395
  data: {
394
396
  exitCode: 1,
395
397
  stdout: "",
396
- stderr: `${H}
398
+ stderr: `${G}
397
399
  `
398
400
  }
399
401
  };
400
- const r = yield N(n).exec({
402
+ const r = yield O(e).exec({
401
403
  command: t.command,
402
- cwd: n.shellCwd.cwd,
403
- timeoutMs: n.timeoutMs,
404
- signal: n.signal
404
+ cwd: e.shellCwd.cwd,
405
+ timeoutMs: e.timeoutMs,
406
+ signal: e.signal
405
407
  });
406
- return r.cwd && G(r.cwd) && (n.shellCwd.cwd = r.cwd), {
408
+ return r.cwd && K(r.cwd) && (e.shellCwd.cwd = r.cwd), {
407
409
  data: {
408
410
  exitCode: r.exitCode,
409
411
  stdout: r.stdout,
@@ -412,60 +414,81 @@ function ht(t, n) {
412
414
  };
413
415
  });
414
416
  }
415
- function P(t, n) {
417
+ function P(t) {
418
+ if (!t.skills)
419
+ throw new d(u.NotImplemented, "当前环境不能加载平台技能,需要端侧宿主。");
420
+ return t.skills;
421
+ }
422
+ function j(t, e, n) {
416
423
  return l(this, null, function* () {
417
- try {
418
- const {
419
- bytes: e
420
- } = yield y(n.adapter, t);
421
- if (g(e))
422
- throw new d(u.BadRequest, "技能资源不是文本。");
423
- return p(e);
424
- } catch (e) {
425
- throw E(e) ? new d(u.NotFound, "技能或资源不存在。") : e;
426
- }
424
+ N(t, e);
425
+ const r = yield P(n).read(t, e, n.signal);
426
+ if (x(r))
427
+ throw new d(u.BadRequest, "技能资源不是文本。");
428
+ return y(r);
427
429
  });
428
430
  }
429
- function mt(t, n) {
431
+ function rt(t) {
432
+ if (!t.skillRunner)
433
+ throw new d(u.NotImplemented, "当前环境不能加载平台技能,需要端侧宿主。");
434
+ return t.skillRunner;
435
+ }
436
+ function yt(t, e) {
430
437
  return l(this, null, function* () {
431
438
  return {
432
439
  data: {
433
- content: yield P($(t.skill_name, "SKILL.md"), n)
440
+ content: yield j(t.skill_name, "SKILL.md", e)
434
441
  }
435
442
  };
436
443
  });
437
444
  }
438
- function yt(t, n) {
445
+ function pt(t, e) {
439
446
  return l(this, null, function* () {
440
447
  return {
441
448
  data: {
442
- content: yield P($(t.skill_name, t.resource_name), n)
449
+ content: yield j(t.skill_name, t.resource_name, e)
443
450
  }
444
451
  };
445
452
  });
446
453
  }
447
- function xt(t, n) {
454
+ function _t(t, e) {
448
455
  return l(this, null, function* () {
449
- var r;
450
- const e = $(t.skill_name, t.script_name);
451
- S(e);
456
+ var o;
457
+ const n = P(e);
458
+ N(t.skill_name, t.script_name), _(t.script_name);
459
+ const r = rt(e), s = yield n.target(t.skill_name, e.signal), a = n.track(s.skillId, s.version);
452
460
  try {
453
- return yield O(e, (r = t.args) != null ? r : [], n);
454
- } catch (o) {
455
- throw E(o) ? new d(u.NotFound, "技能脚本不存在。") : o;
461
+ const c = yield r.exec({
462
+ argv: [_(t.script_name), t.script_name, ...(o = t.args) != null ? o : []],
463
+ cwd: I,
464
+ timeoutMs: e.timeoutMs,
465
+ signal: e.signal,
466
+ skill: s
467
+ });
468
+ return {
469
+ data: {
470
+ exitCode: c.exitCode,
471
+ stdout: c.stdout,
472
+ stderr: c.stderr
473
+ }
474
+ };
475
+ } catch (c) {
476
+ throw D(c) ? new d(u.NotFound, "技能脚本不存在。") : c;
477
+ } finally {
478
+ a();
456
479
  }
457
480
  });
458
481
  }
459
482
  export {
460
- lt as appendFile,
461
- dt as editFile,
462
- ft as find,
463
- ut as grep,
464
- mt as loadSkill,
465
- at as readFile,
466
- yt as readSkillResource,
467
- wt as runFile,
468
- xt as runSkillScript,
469
- ht as shell,
470
- it as writeFile
483
+ ft as appendFile,
484
+ wt as editFile,
485
+ mt as find,
486
+ ht as grep,
487
+ yt as loadSkill,
488
+ dt as readFile,
489
+ pt as readSkillResource,
490
+ gt as runFile,
491
+ _t as runSkillScript,
492
+ xt as shell,
493
+ ut as writeFile
471
494
  };