@gt-fe/eap-runtime 0.0.25 → 0.0.26

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.
@@ -53,7 +53,25 @@ function harnessDefinitions() {
53
53
  manifest: {
54
54
  id: 'builtin:write_file',
55
55
  name: 'write_file',
56
- description: '写入当前用户目录(含用户自己的 skills)。预装 tools / skills 只读。',
56
+ description: '写入当前用户目录(含用户自己的 skills)。预装 tools / skills 只读。覆盖已有文件。',
57
+ ...common,
58
+ },
59
+ inputSchema: {
60
+ type: 'object',
61
+ required: ['path', 'content'],
62
+ properties: {
63
+ path: { type: 'string' },
64
+ content: { type: 'string' },
65
+ },
66
+ },
67
+ },
68
+ {
69
+ toolId: 'builtin:append_to_file',
70
+ name: 'append_to_file',
71
+ manifest: {
72
+ id: 'builtin:append_to_file',
73
+ name: 'append_to_file',
74
+ description: '向当前用户目录内的文件追加文本。文件不存在则创建。预装 tools / skills 只读。',
57
75
  ...common,
58
76
  },
59
77
  inputSchema: {
@@ -199,10 +217,10 @@ export function resolveJailRoots(options) {
199
217
  }
200
218
  return roots;
201
219
  }
202
- async function writeFileNoFollow(target, content) {
220
+ async function writeFileNoFollow(target, content, append = false) {
203
221
  const flags = fsConstants.O_WRONLY |
204
222
  fsConstants.O_CREAT |
205
- fsConstants.O_TRUNC |
223
+ (append ? fsConstants.O_APPEND : fsConstants.O_TRUNC) |
206
224
  (fsConstants.O_NOFOLLOW ?? 0);
207
225
  let handle;
208
226
  try {
@@ -216,7 +234,8 @@ async function writeFileNoFollow(target, content) {
216
234
  throw err;
217
235
  }
218
236
  try {
219
- await handle.writeFile(content, 'utf8');
237
+ const { bytesWritten } = await handle.write(content, undefined, 'utf8');
238
+ return bytesWritten;
220
239
  }
221
240
  finally {
222
241
  await handle.close();
@@ -408,7 +427,9 @@ export class HarnessPrimitiveExecutor {
408
427
  case 'read_file':
409
428
  return await this.readFile(request);
410
429
  case 'write_file':
411
- return await this.writeFile(request);
430
+ return await this.writeFile(request, false);
431
+ case 'append_to_file':
432
+ return await this.writeFile(request, true);
412
433
  case 'execute_command':
413
434
  return await this.executeCommand(request);
414
435
  default:
@@ -459,7 +480,7 @@ export class HarnessPrimitiveExecutor {
459
480
  }
460
481
  return ok(request, text);
461
482
  }
462
- async writeFile(request) {
483
+ async writeFile(request, append) {
463
484
  const filePath = String(request.arguments.path ?? '');
464
485
  const content = String(request.arguments.content ?? '');
465
486
  const workdir = this.requireWorkdir(request);
@@ -474,8 +495,8 @@ export class HarnessPrimitiveExecutor {
474
495
  if (PROTECTED_WRITE_NAMES.has(path.basename(recast))) {
475
496
  throw new Error(`禁止写入平台文件:${path.basename(recast)}`);
476
497
  }
477
- await writeFileNoFollow(recast, content);
478
- return ok(request, JSON.stringify({ ok: true, path: path.relative(workdir, recast) }));
498
+ const bytesWritten = await writeFileNoFollow(recast, content, append);
499
+ return ok(request, JSON.stringify({ ok: true, path: path.relative(workdir, recast), bytesWritten }));
479
500
  }
480
501
  async executeCommand(request) {
481
502
  const command = substituteSkillDir(String(request.arguments.command ?? '').trim(), request.skillDir);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gt-fe/eap-runtime",
3
- "version": "0.0.25",
3
+ "version": "0.0.26",
4
4
  "description": "Enterprise Agent Platform — Runtime核心:Graph执行引擎、Task生命周期、Session管理、Checkpoint持久化",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -20,7 +20,7 @@
20
20
  "ioredis": "^5.4.0",
21
21
  "pg": "^8.13.0",
22
22
  "yaml": "^2.6.1",
23
- "@gt-fe/eap-contracts": "0.0.14"
23
+ "@gt-fe/eap-contracts": "0.0.15"
24
24
  },
25
25
  "publishConfig": {
26
26
  "registry": "https://registry.npmjs.org/",