@ai-setting/roy-agent-core 1.5.91 → 1.5.92

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.
@@ -2,9 +2,10 @@ import {
2
2
  AgentComponent,
3
3
  AgentComponentConfigSchema,
4
4
  SummaryAgent
5
- } from "../../shared/@ai-setting/roy-agent-core-55br4t6v.js";
5
+ } from "../../shared/@ai-setting/roy-agent-core-mw9a595w.js";
6
6
  import"../../shared/@ai-setting/roy-agent-core-j7jeqxhd.js";
7
- import"../../shared/@ai-setting/roy-agent-core-jf865m5b.js";
7
+ import"../../shared/@ai-setting/roy-agent-core-ptb4pkva.js";
8
+ import"../../shared/@ai-setting/roy-agent-core-5h49ct1a.js";
8
9
  import"../../shared/@ai-setting/roy-agent-core-bdajt9cs.js";
9
10
  import"../../shared/@ai-setting/roy-agent-core-e25xkv53.js";
10
11
  import"../../shared/@ai-setting/roy-agent-core-vady4w02.js";
package/dist/env/index.js CHANGED
@@ -22,7 +22,7 @@ import"../shared/@ai-setting/roy-agent-core-97tjdb2r.js";
22
22
  import"../shared/@ai-setting/roy-agent-core-az13yzmc.js";
23
23
  import {
24
24
  WorkflowComponent
25
- } from "../shared/@ai-setting/roy-agent-core-9amq4epa.js";
25
+ } from "../shared/@ai-setting/roy-agent-core-vh8ncnzm.js";
26
26
  import"../shared/@ai-setting/roy-agent-core-xgnpr28w.js";
27
27
  import"../shared/@ai-setting/roy-agent-core-snvsn60t.js";
28
28
  import"../shared/@ai-setting/roy-agent-core-w1s8yrm5.js";
@@ -42,9 +42,10 @@ import"../shared/@ai-setting/roy-agent-core-1ce3fqrk.js";
42
42
  import {
43
43
  AgentComponent,
44
44
  AgentComponentConfigSchema
45
- } from "../shared/@ai-setting/roy-agent-core-55br4t6v.js";
45
+ } from "../shared/@ai-setting/roy-agent-core-mw9a595w.js";
46
46
  import"../shared/@ai-setting/roy-agent-core-j7jeqxhd.js";
47
- import"../shared/@ai-setting/roy-agent-core-jf865m5b.js";
47
+ import"../shared/@ai-setting/roy-agent-core-ptb4pkva.js";
48
+ import"../shared/@ai-setting/roy-agent-core-5h49ct1a.js";
48
49
  import"../shared/@ai-setting/roy-agent-core-bdajt9cs.js";
49
50
  import"../shared/@ai-setting/roy-agent-core-e25xkv53.js";
50
51
  import {
@@ -16,7 +16,8 @@ import {
16
16
  ToolValidator,
17
17
  getMaxOutputSize,
18
18
  setToolConfigComponent
19
- } from "../../shared/@ai-setting/roy-agent-core-jf865m5b.js";
19
+ } from "../../shared/@ai-setting/roy-agent-core-ptb4pkva.js";
20
+ import"../../shared/@ai-setting/roy-agent-core-5h49ct1a.js";
20
21
  import"../../shared/@ai-setting/roy-agent-core-bdajt9cs.js";
21
22
  import"../../shared/@ai-setting/roy-agent-core-e25xkv53.js";
22
23
  import"../../shared/@ai-setting/roy-agent-core-hvdfgvfz.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  WorkflowComponent
3
- } from "../../shared/@ai-setting/roy-agent-core-9amq4epa.js";
3
+ } from "../../shared/@ai-setting/roy-agent-core-vh8ncnzm.js";
4
4
  import"../../shared/@ai-setting/roy-agent-core-xgnpr28w.js";
5
5
  import"../../shared/@ai-setting/roy-agent-core-snvsn60t.js";
6
6
  import"../../shared/@ai-setting/roy-agent-core-w1s8yrm5.js";
package/dist/index.js CHANGED
@@ -91,7 +91,7 @@ import {
91
91
  } from "./shared/@ai-setting/roy-agent-core-az13yzmc.js";
92
92
  import {
93
93
  WorkflowComponent
94
- } from "./shared/@ai-setting/roy-agent-core-9amq4epa.js";
94
+ } from "./shared/@ai-setting/roy-agent-core-vh8ncnzm.js";
95
95
  import {
96
96
  init_node_registry_helper,
97
97
  registerDecoratorNodeType
@@ -120,7 +120,7 @@ import"./shared/@ai-setting/roy-agent-core-1ce3fqrk.js";
120
120
  import {
121
121
  AgentComponent,
122
122
  AgentComponentConfigSchema
123
- } from "./shared/@ai-setting/roy-agent-core-55br4t6v.js";
123
+ } from "./shared/@ai-setting/roy-agent-core-mw9a595w.js";
124
124
  import {
125
125
  createInvokeConfig,
126
126
  invoke,
@@ -131,7 +131,8 @@ import {
131
131
  ToolComponent,
132
132
  ToolRegistry,
133
133
  ToolValidator
134
- } from "./shared/@ai-setting/roy-agent-core-jf865m5b.js";
134
+ } from "./shared/@ai-setting/roy-agent-core-ptb4pkva.js";
135
+ import"./shared/@ai-setting/roy-agent-core-5h49ct1a.js";
135
136
  import {
136
137
  createAutoTaskPlugin
137
138
  } from "./shared/@ai-setting/roy-agent-core-bdajt9cs.js";
@@ -0,0 +1,135 @@
1
+ import {
2
+ createLogger,
3
+ init_logger
4
+ } from "./roy-agent-core-vyygk314.js";
5
+
6
+ // src/utils/temp-file-manager/index.ts
7
+ init_logger();
8
+ import * as fs from "node:fs";
9
+ import * as path from "node:path";
10
+ import * as os from "node:os";
11
+ import * as crypto from "node:crypto";
12
+ var logger = createLogger("temp-file-manager");
13
+
14
+ class TempFileManager {
15
+ static _instance = null;
16
+ _files = new Set;
17
+ _hooksRegistered = false;
18
+ static FILE_PREFIX = "roy-agent-truncation";
19
+ static FILE_EXT = ".txt";
20
+ static LARGE_FILE_THRESHOLD = 10 * 1024 * 1024;
21
+ static STALE_FILE_AGE_MS = 24 * 60 * 60 * 1000;
22
+ constructor() {
23
+ this.sweepStaleFiles().catch((err) => {
24
+ logger.warn(`[TempFileManager] Stale file sweep failed: ${err}`);
25
+ });
26
+ }
27
+ static getInstance() {
28
+ if (!TempFileManager._instance) {
29
+ TempFileManager._instance = new TempFileManager;
30
+ }
31
+ return TempFileManager._instance;
32
+ }
33
+ static _resetForTesting() {
34
+ if (TempFileManager._instance) {
35
+ TempFileManager._instance.cleanupAll().catch(() => {});
36
+ }
37
+ TempFileManager._instance = null;
38
+ }
39
+ async writeTempFile(content, prefix = "default") {
40
+ this.ensureHooksRegistered();
41
+ if (content.length > TempFileManager.LARGE_FILE_THRESHOLD) {
42
+ logger.warn(`[TempFileManager] Writing large temp file: ${content.length} bytes (> ${TempFileManager.LARGE_FILE_THRESHOLD} bytes). Consider increasing maxOutputSize or filtering output.`);
43
+ }
44
+ const sanitizedPrefix = this.sanitizePrefix(prefix);
45
+ const uuid = crypto.randomUUID();
46
+ const filename = `${TempFileManager.FILE_PREFIX}-${process.pid}-${uuid}-${sanitizedPrefix}${TempFileManager.FILE_EXT}`;
47
+ const filePath = path.join(os.tmpdir(), filename);
48
+ await fs.promises.writeFile(filePath, content, "utf-8");
49
+ this._files.add(filePath);
50
+ logger.debug(`[TempFileManager] Created temp file: ${filePath} (${content.length} bytes)`);
51
+ return filePath;
52
+ }
53
+ async cleanupAll() {
54
+ const files = Array.from(this._files);
55
+ this._files.clear();
56
+ const results = await Promise.allSettled(files.map(async (filePath) => {
57
+ try {
58
+ await fs.promises.unlink(filePath);
59
+ } catch (err) {
60
+ if (err.code !== "ENOENT") {
61
+ logger.warn(`[TempFileManager] Failed to delete ${filePath}: ${err.message}`);
62
+ }
63
+ }
64
+ }));
65
+ const succeeded = results.filter((r) => r.status === "fulfilled").length;
66
+ logger.debug(`[TempFileManager] Cleanup complete: ${succeeded}/${files.length} files deleted`);
67
+ }
68
+ getActiveFileCount() {
69
+ return this._files.size;
70
+ }
71
+ async sweepStaleFiles(maxAgeMs = TempFileManager.STALE_FILE_AGE_MS) {
72
+ const tmpDir = os.tmpdir();
73
+ const now = Date.now();
74
+ let deletedCount = 0;
75
+ let entries;
76
+ try {
77
+ entries = await fs.promises.readdir(tmpDir);
78
+ } catch (err) {
79
+ logger.warn(`[TempFileManager] Failed to read tmpdir ${tmpDir}: ${err.message}`);
80
+ return 0;
81
+ }
82
+ for (const entry of entries) {
83
+ if (!entry.startsWith(`${TempFileManager.FILE_PREFIX}-`))
84
+ continue;
85
+ const filePath = path.join(tmpDir, entry);
86
+ try {
87
+ const stat = await fs.promises.stat(filePath);
88
+ const age = now - stat.mtimeMs;
89
+ if (age > maxAgeMs) {
90
+ await fs.promises.unlink(filePath);
91
+ deletedCount++;
92
+ }
93
+ } catch (err) {
94
+ if (err.code !== "ENOENT") {
95
+ logger.warn(`[TempFileManager] Failed to sweep ${filePath}: ${err.message}`);
96
+ }
97
+ }
98
+ }
99
+ if (deletedCount > 0) {
100
+ logger.info(`[TempFileManager] Swept ${deletedCount} stale files from ${tmpDir}`);
101
+ }
102
+ return deletedCount;
103
+ }
104
+ ensureHooksRegistered() {
105
+ if (this._hooksRegistered)
106
+ return;
107
+ if (typeof process === "undefined" || !process.on) {
108
+ return;
109
+ }
110
+ const cleanup = () => {
111
+ for (const filePath of this._files) {
112
+ try {
113
+ fs.unlinkSync(filePath);
114
+ } catch (err) {}
115
+ }
116
+ this._files.clear();
117
+ };
118
+ process.on("exit", cleanup);
119
+ process.on("SIGINT", () => {
120
+ cleanup();
121
+ process.exit(130);
122
+ });
123
+ process.on("SIGTERM", () => {
124
+ cleanup();
125
+ process.exit(143);
126
+ });
127
+ this._hooksRegistered = true;
128
+ logger.debug("[TempFileManager] Process exit hooks registered");
129
+ }
130
+ sanitizePrefix(prefix) {
131
+ return prefix.replace(/[\/\\<>:"|?*\x00-\x1f]/g, "-").replace(/\s+/g, "-").substring(0, 32) || "default";
132
+ }
133
+ }
134
+
135
+ export { TempFileManager };
@@ -3,7 +3,7 @@ import {
3
3
  } from "./roy-agent-core-j7jeqxhd.js";
4
4
  import {
5
5
  truncateOutputInline
6
- } from "./roy-agent-core-jf865m5b.js";
6
+ } from "./roy-agent-core-ptb4pkva.js";
7
7
  import {
8
8
  AskUserError,
9
9
  init_workflow_hil
@@ -1,3 +1,6 @@
1
+ import {
2
+ TempFileManager
3
+ } from "./roy-agent-core-5h49ct1a.js";
1
4
  import {
2
5
  AUTO_TASK_METADATA_BEGIN,
3
6
  AUTO_TASK_METADATA_END
@@ -181,138 +184,7 @@ var TOOL_CONFIG_REGISTRATION = {
181
184
  // src/env/tool/tool-component.ts
182
185
  init_workflow_hil();
183
186
  init_env_context();
184
-
185
- // src/utils/temp-file-manager.ts
186
- init_logger();
187
- import * as fs from "node:fs";
188
- import * as path from "node:path";
189
- import * as os from "node:os";
190
- import * as crypto from "node:crypto";
191
- var logger = createLogger("temp-file-manager");
192
-
193
- class TempFileManager {
194
- static _instance = null;
195
- _files = new Set;
196
- _hooksRegistered = false;
197
- static FILE_PREFIX = "roy-agent-truncation";
198
- static FILE_EXT = ".txt";
199
- static LARGE_FILE_THRESHOLD = 10 * 1024 * 1024;
200
- static STALE_FILE_AGE_MS = 24 * 60 * 60 * 1000;
201
- constructor() {
202
- this.sweepStaleFiles().catch((err) => {
203
- logger.warn(`[TempFileManager] Stale file sweep failed: ${err}`);
204
- });
205
- }
206
- static getInstance() {
207
- if (!TempFileManager._instance) {
208
- TempFileManager._instance = new TempFileManager;
209
- }
210
- return TempFileManager._instance;
211
- }
212
- static _resetForTesting() {
213
- if (TempFileManager._instance) {
214
- TempFileManager._instance.cleanupAll().catch(() => {});
215
- }
216
- TempFileManager._instance = null;
217
- }
218
- async writeTempFile(content, prefix = "default") {
219
- this.ensureHooksRegistered();
220
- if (content.length > TempFileManager.LARGE_FILE_THRESHOLD) {
221
- logger.warn(`[TempFileManager] Writing large temp file: ${content.length} bytes (> ${TempFileManager.LARGE_FILE_THRESHOLD} bytes). Consider increasing maxOutputSize or filtering output.`);
222
- }
223
- const sanitizedPrefix = this.sanitizePrefix(prefix);
224
- const uuid = crypto.randomUUID();
225
- const filename = `${TempFileManager.FILE_PREFIX}-${process.pid}-${uuid}-${sanitizedPrefix}${TempFileManager.FILE_EXT}`;
226
- const filePath = path.join(os.tmpdir(), filename);
227
- await fs.promises.writeFile(filePath, content, "utf-8");
228
- this._files.add(filePath);
229
- logger.debug(`[TempFileManager] Created temp file: ${filePath} (${content.length} bytes)`);
230
- return filePath;
231
- }
232
- async cleanupAll() {
233
- const files = Array.from(this._files);
234
- this._files.clear();
235
- const results = await Promise.allSettled(files.map(async (filePath) => {
236
- try {
237
- await fs.promises.unlink(filePath);
238
- } catch (err) {
239
- if (err.code !== "ENOENT") {
240
- logger.warn(`[TempFileManager] Failed to delete ${filePath}: ${err.message}`);
241
- }
242
- }
243
- }));
244
- const succeeded = results.filter((r) => r.status === "fulfilled").length;
245
- logger.debug(`[TempFileManager] Cleanup complete: ${succeeded}/${files.length} files deleted`);
246
- }
247
- getActiveFileCount() {
248
- return this._files.size;
249
- }
250
- async sweepStaleFiles(maxAgeMs = TempFileManager.STALE_FILE_AGE_MS) {
251
- const tmpDir = os.tmpdir();
252
- const now = Date.now();
253
- let deletedCount = 0;
254
- let entries;
255
- try {
256
- entries = await fs.promises.readdir(tmpDir);
257
- } catch (err) {
258
- logger.warn(`[TempFileManager] Failed to read tmpdir ${tmpDir}: ${err.message}`);
259
- return 0;
260
- }
261
- for (const entry of entries) {
262
- if (!entry.startsWith(`${TempFileManager.FILE_PREFIX}-`))
263
- continue;
264
- const filePath = path.join(tmpDir, entry);
265
- try {
266
- const stat = await fs.promises.stat(filePath);
267
- const age = now - stat.mtimeMs;
268
- if (age > maxAgeMs) {
269
- await fs.promises.unlink(filePath);
270
- deletedCount++;
271
- }
272
- } catch (err) {
273
- if (err.code !== "ENOENT") {
274
- logger.warn(`[TempFileManager] Failed to sweep ${filePath}: ${err.message}`);
275
- }
276
- }
277
- }
278
- if (deletedCount > 0) {
279
- logger.info(`[TempFileManager] Swept ${deletedCount} stale files from ${tmpDir}`);
280
- }
281
- return deletedCount;
282
- }
283
- ensureHooksRegistered() {
284
- if (this._hooksRegistered)
285
- return;
286
- if (typeof process === "undefined" || !process.on) {
287
- return;
288
- }
289
- const cleanup = () => {
290
- for (const filePath of this._files) {
291
- try {
292
- fs.unlinkSync(filePath);
293
- } catch (err) {}
294
- }
295
- this._files.clear();
296
- };
297
- process.on("exit", cleanup);
298
- process.on("SIGINT", () => {
299
- cleanup();
300
- process.exit(130);
301
- });
302
- process.on("SIGTERM", () => {
303
- cleanup();
304
- process.exit(143);
305
- });
306
- this._hooksRegistered = true;
307
- logger.debug("[TempFileManager] Process exit hooks registered");
308
- }
309
- sanitizePrefix(prefix) {
310
- return prefix.replace(/[\/\\<>:"|?*\x00-\x1f]/g, "-").replace(/\s+/g, "-").substring(0, 32) || "default";
311
- }
312
- }
313
-
314
- // src/env/tool/tool-component.ts
315
- var logger2 = createLogger("tool");
187
+ var logger = createLogger("tool");
316
188
  var configComponentInstance = null;
317
189
  function setToolConfigComponent(component) {
318
190
  configComponentInstance = component;
@@ -438,7 +310,7 @@ class ToolComponent extends BaseComponent {
438
310
  if (this.config?.builtInTools?.enabled !== false) {
439
311
  await this.loadBuiltInTools();
440
312
  }
441
- logger2.info(`ToolComponent initialized with ${this.getToolCount()} tools`);
313
+ logger.info(`ToolComponent initialized with ${this.getToolCount()} tools`);
442
314
  }
443
315
  async registerConfig(options) {
444
316
  const configComponent = options.configComponent;
@@ -536,7 +408,7 @@ class ToolComponent extends BaseComponent {
536
408
  });
537
409
  }
538
410
  onConfigChange(event) {
539
- logger2.info(`Tool config changed: ${event.key}`, {
411
+ logger.info(`Tool config changed: ${event.key}`, {
540
412
  oldValue: event.oldValue,
541
413
  newValue: event.newValue
542
414
  });
@@ -554,7 +426,7 @@ class ToolComponent extends BaseComponent {
554
426
  source,
555
427
  enabled: true
556
428
  });
557
- logger2.debug(`Registered tool: ${tool.name}`);
429
+ logger.debug(`Registered tool: ${tool.name}`);
558
430
  globalHookManager.execute(ToolHookPoints.AFTER_REGISTER, { tool });
559
431
  }
560
432
  registerMany(tools, source = "dynamic") {
@@ -643,9 +515,9 @@ class ToolComponent extends BaseComponent {
643
515
  ⚠️ 输出被截断(原 ${truncationMeta.original_output_size} 字符,截断到 ${truncationMeta.truncated_output_size} 字符)
644
516
  \uD83D\uDCC1 完整内容保存到: ${tempFilePath}
645
517
  \uD83D\uDD0D 使用 read_file 工具按需读取`;
646
- logger2.debug(`[tool-component] Truncated output saved to temp file: ${tempFilePath} (${truncationMeta.original_output_size} bytes)`);
518
+ logger.debug(`[tool-component] Truncated output saved to temp file: ${tempFilePath} (${truncationMeta.original_output_size} bytes)`);
647
519
  } catch (err) {
648
- logger2.warn(`[tool-component] Failed to write temp file for truncated output: ${err}`);
520
+ logger.warn(`[tool-component] Failed to write temp file for truncated output: ${err}`);
649
521
  }
650
522
  }
651
523
  }
@@ -690,9 +562,9 @@ class ToolComponent extends BaseComponent {
690
562
  const { getAllBuiltInTools } = await import("../../env/tool/built-in/index.js");
691
563
  const tools = getAllBuiltInTools();
692
564
  this.registerMany(tools, "built-in");
693
- logger2.info(`Loaded ${tools.length} built-in tools`);
565
+ logger.info(`Loaded ${tools.length} built-in tools`);
694
566
  } catch (err) {
695
- logger2.warn(`Failed to load built-in tools: ${err.message}`);
567
+ logger.warn(`Failed to load built-in tools: ${err.message}`);
696
568
  }
697
569
  }
698
570
  getHookPoints() {
@@ -0,0 +1,10 @@
1
+ import {
2
+ TempFileManager
3
+ } from "../../shared/@ai-setting/roy-agent-core-5h49ct1a.js";
4
+ import"../../shared/@ai-setting/roy-agent-core-vyygk314.js";
5
+ import"../../shared/@ai-setting/roy-agent-core-7z9b1fm8.js";
6
+ import"../../shared/@ai-setting/roy-agent-core-c6592r3c.js";
7
+ import"../../shared/@ai-setting/roy-agent-core-fs0mn2jk.js";
8
+ export {
9
+ TempFileManager
10
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-setting/roy-agent-core",
3
- "version": "1.5.91",
3
+ "version": "1.5.92",
4
4
  "type": "module",
5
5
  "description": "Core SDK for roy-agent - Environment, Components, Tools, Sessions, Tasks",
6
6
  "main": "./dist/index.js",