@ai-setting/roy-agent-core 1.5.71 → 1.5.73

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 (24) hide show
  1. package/dist/env/agent/index.js +4 -4
  2. package/dist/env/index.js +9 -9
  3. package/dist/env/llm/index.js +3 -3
  4. package/dist/env/plugin/index.js +1 -1
  5. package/dist/env/session/index.js +4 -4
  6. package/dist/env/session/storage/index.js +3 -3
  7. package/dist/env/workflow/engine/index.js +3 -3
  8. package/dist/env/workflow/index.js +4 -4
  9. package/dist/index.js +12 -12
  10. package/dist/shared/@ai-setting/{roy-agent-core-kdmwhshb.js → roy-agent-core-3f0bkm7q.js} +57 -28
  11. package/dist/shared/@ai-setting/{roy-agent-core-yn229bhx.js → roy-agent-core-4hh4s0w1.js} +1 -1
  12. package/dist/shared/@ai-setting/{roy-agent-core-zgtmazxg.js → roy-agent-core-9adgwts7.js} +1 -1
  13. package/dist/shared/@ai-setting/{roy-agent-core-rcd7ek6n.js → roy-agent-core-9dja7n0q.js} +4 -4
  14. package/dist/shared/@ai-setting/{roy-agent-core-ggvv4snf.js → roy-agent-core-assbmxe0.js} +2 -2
  15. package/dist/shared/@ai-setting/{roy-agent-core-tktkp52c.js → roy-agent-core-c1j7ev4e.js} +1 -1
  16. package/dist/shared/@ai-setting/{roy-agent-core-r7zphnam.js → roy-agent-core-c4hhd1f2.js} +3 -3
  17. package/dist/shared/@ai-setting/{roy-agent-core-rjp2cqsn.js → roy-agent-core-ce10b0ez.js} +10 -2
  18. package/dist/shared/@ai-setting/{roy-agent-core-6d5v531t.js → roy-agent-core-fkv7ewz9.js} +2 -1
  19. package/dist/shared/@ai-setting/{roy-agent-core-b18mgzpc.js → roy-agent-core-jymz9fzp.js} +1 -1
  20. package/dist/shared/@ai-setting/{roy-agent-core-ap59dpve.js → roy-agent-core-p7grnnzp.js} +82 -16
  21. package/dist/shared/@ai-setting/{roy-agent-core-jweqxgyb.js → roy-agent-core-q7sqeax6.js} +1 -1
  22. package/dist/shared/@ai-setting/{roy-agent-core-dqf8t38a.js → roy-agent-core-smgpr5tz.js} +8 -6
  23. package/dist/shared/@ai-setting/{roy-agent-core-8vkr264k.js → roy-agent-core-yakvqh1d.js} +1 -1
  24. package/package.json +1 -1
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  AgentComponent,
3
3
  AgentComponentConfigSchema
4
- } from "../../shared/@ai-setting/roy-agent-core-rcd7ek6n.js";
5
- import"../../shared/@ai-setting/roy-agent-core-kdmwhshb.js";
4
+ } from "../../shared/@ai-setting/roy-agent-core-9dja7n0q.js";
5
+ import"../../shared/@ai-setting/roy-agent-core-3f0bkm7q.js";
6
6
  import"../../shared/@ai-setting/roy-agent-core-e25xkv53.js";
7
7
  import"../../shared/@ai-setting/roy-agent-core-nx3c3ce2.js";
8
8
  import"../../shared/@ai-setting/roy-agent-core-qxnbvgwe.js";
@@ -10,8 +10,8 @@ import"../../shared/@ai-setting/roy-agent-core-ctdhjv68.js";
10
10
  import {
11
11
  SummaryAgent
12
12
  } from "../../shared/@ai-setting/roy-agent-core-x3gtyqax.js";
13
- import"../../shared/@ai-setting/roy-agent-core-tktkp52c.js";
14
- import"../../shared/@ai-setting/roy-agent-core-rjp2cqsn.js";
13
+ import"../../shared/@ai-setting/roy-agent-core-c1j7ev4e.js";
14
+ import"../../shared/@ai-setting/roy-agent-core-ce10b0ez.js";
15
15
  import"../../shared/@ai-setting/roy-agent-core-qxhq8ven.js";
16
16
  import"../../shared/@ai-setting/roy-agent-core-rgckng3p.js";
17
17
  import"../../shared/@ai-setting/roy-agent-core-b8r4tfqq.js";
package/dist/env/index.js CHANGED
@@ -16,16 +16,16 @@ import {
16
16
  import"../shared/@ai-setting/roy-agent-core-v8xa6vs8.js";
17
17
  import {
18
18
  PluginComponent
19
- } from "../shared/@ai-setting/roy-agent-core-ap59dpve.js";
19
+ } from "../shared/@ai-setting/roy-agent-core-p7grnnzp.js";
20
20
  import"../shared/@ai-setting/roy-agent-core-xp8xrxgc.js";
21
21
  import"../shared/@ai-setting/roy-agent-core-az13yzmc.js";
22
22
  import {
23
23
  WorkflowComponent
24
- } from "../shared/@ai-setting/roy-agent-core-r7zphnam.js";
24
+ } from "../shared/@ai-setting/roy-agent-core-c4hhd1f2.js";
25
25
  import"../shared/@ai-setting/roy-agent-core-fjexv5nm.js";
26
- import"../shared/@ai-setting/roy-agent-core-yn229bhx.js";
27
- import"../shared/@ai-setting/roy-agent-core-zgtmazxg.js";
28
- import"../shared/@ai-setting/roy-agent-core-6d5v531t.js";
26
+ import"../shared/@ai-setting/roy-agent-core-4hh4s0w1.js";
27
+ import"../shared/@ai-setting/roy-agent-core-9adgwts7.js";
28
+ import"../shared/@ai-setting/roy-agent-core-fkv7ewz9.js";
29
29
  import"../shared/@ai-setting/roy-agent-core-6atd905e.js";
30
30
  import"../shared/@ai-setting/roy-agent-core-99j4w3fx.js";
31
31
  import"../shared/@ai-setting/roy-agent-core-ddwa0n6h.js";
@@ -39,8 +39,8 @@ import"../shared/@ai-setting/roy-agent-core-1ce3fqrk.js";
39
39
  import {
40
40
  AgentComponent,
41
41
  AgentComponentConfigSchema
42
- } from "../shared/@ai-setting/roy-agent-core-rcd7ek6n.js";
43
- import"../shared/@ai-setting/roy-agent-core-kdmwhshb.js";
42
+ } from "../shared/@ai-setting/roy-agent-core-9dja7n0q.js";
43
+ import"../shared/@ai-setting/roy-agent-core-3f0bkm7q.js";
44
44
  import"../shared/@ai-setting/roy-agent-core-e25xkv53.js";
45
45
  import {
46
46
  TaskComponent
@@ -64,8 +64,8 @@ import"../shared/@ai-setting/roy-agent-core-ctdhjv68.js";
64
64
  import"../shared/@ai-setting/roy-agent-core-fnv3ev18.js";
65
65
  import"../shared/@ai-setting/roy-agent-core-djtkntar.js";
66
66
  import"../shared/@ai-setting/roy-agent-core-x3gtyqax.js";
67
- import"../shared/@ai-setting/roy-agent-core-tktkp52c.js";
68
- import"../shared/@ai-setting/roy-agent-core-rjp2cqsn.js";
67
+ import"../shared/@ai-setting/roy-agent-core-c1j7ev4e.js";
68
+ import"../shared/@ai-setting/roy-agent-core-ce10b0ez.js";
69
69
  import"../shared/@ai-setting/roy-agent-core-qxhq8ven.js";
70
70
  import {
71
71
  BaseComponent
@@ -8,15 +8,15 @@ import {
8
8
  ProviderCapabilitiesSchema,
9
9
  ProviderConfigSchema,
10
10
  ProviderManager
11
- } from "../../shared/@ai-setting/roy-agent-core-dqf8t38a.js";
11
+ } from "../../shared/@ai-setting/roy-agent-core-smgpr5tz.js";
12
12
  import {
13
13
  createInvokeConfig,
14
14
  invoke,
15
15
  invokeNonStream,
16
16
  parseModelString
17
- } from "../../shared/@ai-setting/roy-agent-core-kdmwhshb.js";
17
+ } from "../../shared/@ai-setting/roy-agent-core-3f0bkm7q.js";
18
18
  import"../../shared/@ai-setting/roy-agent-core-ctdhjv68.js";
19
- import"../../shared/@ai-setting/roy-agent-core-rjp2cqsn.js";
19
+ import"../../shared/@ai-setting/roy-agent-core-ce10b0ez.js";
20
20
  import"../../shared/@ai-setting/roy-agent-core-qxhq8ven.js";
21
21
  import"../../shared/@ai-setting/roy-agent-core-rgckng3p.js";
22
22
  import"../../shared/@ai-setting/roy-agent-core-b8r4tfqq.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  PluginComponent
3
- } from "../../shared/@ai-setting/roy-agent-core-ap59dpve.js";
3
+ } from "../../shared/@ai-setting/roy-agent-core-p7grnnzp.js";
4
4
  import {
5
5
  BasePlugin
6
6
  } from "../../shared/@ai-setting/roy-agent-core-az13yzmc.js";
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  SessionComponent
3
- } from "../../shared/@ai-setting/roy-agent-core-b18mgzpc.js";
3
+ } from "../../shared/@ai-setting/roy-agent-core-jymz9fzp.js";
4
4
  import"../../shared/@ai-setting/roy-agent-core-rvxg1wps.js";
5
5
  import {
6
6
  MemorySessionStore
7
- } from "../../shared/@ai-setting/roy-agent-core-jweqxgyb.js";
7
+ } from "../../shared/@ai-setting/roy-agent-core-q7sqeax6.js";
8
8
  import"../../shared/@ai-setting/roy-agent-core-x3gtyqax.js";
9
9
  import {
10
10
  SessionMessageConverter
11
- } from "../../shared/@ai-setting/roy-agent-core-tktkp52c.js";
12
- import"../../shared/@ai-setting/roy-agent-core-rjp2cqsn.js";
11
+ } from "../../shared/@ai-setting/roy-agent-core-c1j7ev4e.js";
12
+ import"../../shared/@ai-setting/roy-agent-core-ce10b0ez.js";
13
13
  import"../../shared/@ai-setting/roy-agent-core-qxhq8ven.js";
14
14
  import"../../shared/@ai-setting/roy-agent-core-rgckng3p.js";
15
15
  import"../../shared/@ai-setting/roy-agent-core-b8r4tfqq.js";
@@ -3,9 +3,9 @@ import {
3
3
  SQLiteSessionStore,
4
4
  getDefaultDataDir,
5
5
  getDefaultSessionDbPath
6
- } from "../../../shared/@ai-setting/roy-agent-core-jweqxgyb.js";
7
- import"../../../shared/@ai-setting/roy-agent-core-tktkp52c.js";
8
- import"../../../shared/@ai-setting/roy-agent-core-rjp2cqsn.js";
6
+ } from "../../../shared/@ai-setting/roy-agent-core-q7sqeax6.js";
7
+ import"../../../shared/@ai-setting/roy-agent-core-c1j7ev4e.js";
8
+ import"../../../shared/@ai-setting/roy-agent-core-ce10b0ez.js";
9
9
  import"../../../shared/@ai-setting/roy-agent-core-shme7set.js";
10
10
  import"../../../shared/@ai-setting/roy-agent-core-7z9b1fm8.js";
11
11
  import"../../../shared/@ai-setting/roy-agent-core-c6592r3c.js";
@@ -6,9 +6,9 @@ import {
6
6
  Scheduler,
7
7
  WorkflowEngine,
8
8
  init_engine
9
- } from "../../../shared/@ai-setting/roy-agent-core-yn229bhx.js";
10
- import"../../../shared/@ai-setting/roy-agent-core-zgtmazxg.js";
11
- import"../../../shared/@ai-setting/roy-agent-core-6d5v531t.js";
9
+ } from "../../../shared/@ai-setting/roy-agent-core-4hh4s0w1.js";
10
+ import"../../../shared/@ai-setting/roy-agent-core-9adgwts7.js";
11
+ import"../../../shared/@ai-setting/roy-agent-core-fkv7ewz9.js";
12
12
  import"../../../shared/@ai-setting/roy-agent-core-6atd905e.js";
13
13
  import"../../../shared/@ai-setting/roy-agent-core-99j4w3fx.js";
14
14
  import"../../../shared/@ai-setting/roy-agent-core-ddwa0n6h.js";
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  WorkflowComponent
3
- } from "../../shared/@ai-setting/roy-agent-core-r7zphnam.js";
3
+ } from "../../shared/@ai-setting/roy-agent-core-c4hhd1f2.js";
4
4
  import"../../shared/@ai-setting/roy-agent-core-fjexv5nm.js";
5
- import"../../shared/@ai-setting/roy-agent-core-yn229bhx.js";
6
- import"../../shared/@ai-setting/roy-agent-core-zgtmazxg.js";
7
- import"../../shared/@ai-setting/roy-agent-core-6d5v531t.js";
5
+ import"../../shared/@ai-setting/roy-agent-core-4hh4s0w1.js";
6
+ import"../../shared/@ai-setting/roy-agent-core-9adgwts7.js";
7
+ import"../../shared/@ai-setting/roy-agent-core-fkv7ewz9.js";
8
8
  import"../../shared/@ai-setting/roy-agent-core-6atd905e.js";
9
9
  import"../../shared/@ai-setting/roy-agent-core-99j4w3fx.js";
10
10
  import"../../shared/@ai-setting/roy-agent-core-ddwa0n6h.js";
package/dist/index.js CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  ModelLimitsSchema,
12
12
  ProviderCapabilitiesSchema,
13
13
  ProviderConfigSchema
14
- } from "./shared/@ai-setting/roy-agent-core-dqf8t38a.js";
14
+ } from "./shared/@ai-setting/roy-agent-core-smgpr5tz.js";
15
15
  import {
16
16
  ConfigComponent
17
17
  } from "./shared/@ai-setting/roy-agent-core-prdngx28.js";
@@ -79,7 +79,7 @@ import {
79
79
  } from "./shared/@ai-setting/roy-agent-core-v8xa6vs8.js";
80
80
  import {
81
81
  PluginComponent
82
- } from "./shared/@ai-setting/roy-agent-core-ap59dpve.js";
82
+ } from "./shared/@ai-setting/roy-agent-core-p7grnnzp.js";
83
83
  import {
84
84
  TaskTagPlugin,
85
85
  createAutoTaskPlugin
@@ -89,14 +89,14 @@ import {
89
89
  } from "./shared/@ai-setting/roy-agent-core-az13yzmc.js";
90
90
  import {
91
91
  WorkflowComponent
92
- } from "./shared/@ai-setting/roy-agent-core-r7zphnam.js";
92
+ } from "./shared/@ai-setting/roy-agent-core-c4hhd1f2.js";
93
93
  import {
94
94
  init_node_registry_helper,
95
95
  registerDecoratorNodeType
96
96
  } from "./shared/@ai-setting/roy-agent-core-fjexv5nm.js";
97
- import"./shared/@ai-setting/roy-agent-core-yn229bhx.js";
98
- import"./shared/@ai-setting/roy-agent-core-zgtmazxg.js";
99
- import"./shared/@ai-setting/roy-agent-core-6d5v531t.js";
97
+ import"./shared/@ai-setting/roy-agent-core-4hh4s0w1.js";
98
+ import"./shared/@ai-setting/roy-agent-core-9adgwts7.js";
99
+ import"./shared/@ai-setting/roy-agent-core-fkv7ewz9.js";
100
100
  import"./shared/@ai-setting/roy-agent-core-6atd905e.js";
101
101
  import"./shared/@ai-setting/roy-agent-core-99j4w3fx.js";
102
102
  import"./shared/@ai-setting/roy-agent-core-ddwa0n6h.js";
@@ -116,13 +116,13 @@ import"./shared/@ai-setting/roy-agent-core-1ce3fqrk.js";
116
116
  import {
117
117
  AgentComponent,
118
118
  AgentComponentConfigSchema
119
- } from "./shared/@ai-setting/roy-agent-core-rcd7ek6n.js";
119
+ } from "./shared/@ai-setting/roy-agent-core-9dja7n0q.js";
120
120
  import {
121
121
  createInvokeConfig,
122
122
  invoke,
123
123
  invokeNonStream,
124
124
  parseModelString
125
- } from "./shared/@ai-setting/roy-agent-core-kdmwhshb.js";
125
+ } from "./shared/@ai-setting/roy-agent-core-3f0bkm7q.js";
126
126
  import {
127
127
  AskUserError,
128
128
  init_workflow_hil
@@ -171,14 +171,14 @@ import"./shared/@ai-setting/roy-agent-core-fnv3ev18.js";
171
171
  import"./shared/@ai-setting/roy-agent-core-djtkntar.js";
172
172
  import {
173
173
  SessionComponent
174
- } from "./shared/@ai-setting/roy-agent-core-b18mgzpc.js";
174
+ } from "./shared/@ai-setting/roy-agent-core-jymz9fzp.js";
175
175
  import"./shared/@ai-setting/roy-agent-core-rvxg1wps.js";
176
176
  import {
177
177
  MemorySessionStore
178
- } from "./shared/@ai-setting/roy-agent-core-jweqxgyb.js";
178
+ } from "./shared/@ai-setting/roy-agent-core-q7sqeax6.js";
179
179
  import"./shared/@ai-setting/roy-agent-core-x3gtyqax.js";
180
- import"./shared/@ai-setting/roy-agent-core-tktkp52c.js";
181
- import"./shared/@ai-setting/roy-agent-core-rjp2cqsn.js";
180
+ import"./shared/@ai-setting/roy-agent-core-c1j7ev4e.js";
181
+ import"./shared/@ai-setting/roy-agent-core-ce10b0ez.js";
182
182
  import"./shared/@ai-setting/roy-agent-core-qxhq8ven.js";
183
183
  import {
184
184
  BaseComponent
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  safeParseToolArgs
3
- } from "./roy-agent-core-rjp2cqsn.js";
3
+ } from "./roy-agent-core-ce10b0ez.js";
4
4
  import {
5
5
  createLogger,
6
6
  init_logger
@@ -253,9 +253,9 @@ function processThinkingStream(textDelta, config, state) {
253
253
  }
254
254
  const tags = config.tags || ["thinking"];
255
255
  let remainingText = textDelta;
256
- const reasoningEvents2 = [];
257
- let isOpen2 = state.isOpen;
258
- let currentContent2 = state.content;
256
+ const reasoningEvents = [];
257
+ let isOpen = state.isOpen;
258
+ let currentContent = state.content;
259
259
  for (const tag of tags) {
260
260
  const openTag = `<${tag}>`;
261
261
  const closeTag = `</${tag}>`;
@@ -266,35 +266,35 @@ function processThinkingStream(textDelta, config, state) {
266
266
  if (openIndex !== -1 && (closeIndex === -1 || openIndex < closeIndex)) {
267
267
  const beforeOpen = text.substring(0, openIndex);
268
268
  const afterOpen = text.substring(openIndex + openTag.length);
269
- if (!isOpen2) {
270
- isOpen2 = true;
271
- currentContent2 = "";
272
- reasoningEvents2.push("");
269
+ if (!isOpen) {
270
+ isOpen = true;
271
+ currentContent = "";
272
+ reasoningEvents.push("");
273
273
  }
274
274
  result += beforeOpen;
275
275
  const innerCloseIndex = afterOpen.toLowerCase().indexOf(closeTag.toLowerCase());
276
276
  if (innerCloseIndex !== -1) {
277
277
  const thinkingContent = afterOpen.substring(0, innerCloseIndex);
278
278
  const afterClose = afterOpen.substring(innerCloseIndex + closeTag.length);
279
- currentContent2 += thinkingContent;
280
- reasoningEvents2.push(currentContent2);
281
- isOpen2 = false;
282
- currentContent2 = "";
279
+ currentContent += thinkingContent;
280
+ reasoningEvents.push(currentContent);
281
+ isOpen = false;
282
+ currentContent = "";
283
283
  result += afterClose;
284
284
  } else {
285
- currentContent2 += afterOpen;
286
- reasoningEvents2.push(currentContent2);
285
+ currentContent += afterOpen;
286
+ reasoningEvents.push(currentContent);
287
287
  result += "";
288
288
  }
289
289
  remainingText = result;
290
290
  } else if (closeIndex !== -1) {
291
291
  const beforeClose = text.substring(0, closeIndex);
292
292
  const afterClose = text.substring(closeIndex + closeTag.length);
293
- if (isOpen2) {
294
- currentContent2 += beforeClose;
295
- reasoningEvents2.push(currentContent2);
296
- isOpen2 = false;
297
- currentContent2 = "";
293
+ if (isOpen) {
294
+ currentContent += beforeClose;
295
+ reasoningEvents.push(currentContent);
296
+ isOpen = false;
297
+ currentContent = "";
298
298
  result = afterClose;
299
299
  } else {
300
300
  result = text;
@@ -302,16 +302,16 @@ function processThinkingStream(textDelta, config, state) {
302
302
  remainingText = result;
303
303
  }
304
304
  }
305
- if (isOpen2 && remainingText === textDelta) {
306
- currentContent2 += remainingText;
307
- reasoningEvents2.push(currentContent2);
305
+ if (isOpen && remainingText === textDelta) {
306
+ currentContent += remainingText;
307
+ reasoningEvents.push(currentContent);
308
308
  remainingText = "";
309
309
  }
310
310
  return {
311
311
  cleanedText: remainingText,
312
- isThinkingTagOpen: isOpen2,
313
- currentThinkingContent: currentContent2,
314
- reasoningEvents: reasoningEvents2
312
+ isThinkingTagOpen: isOpen,
313
+ currentThinkingContent: currentContent,
314
+ reasoningEvents
315
315
  };
316
316
  }
317
317
  async function invoke(config, options, ctx) {
@@ -389,16 +389,17 @@ async function invoke(config, options, ctx) {
389
389
  let reasoningContent = "";
390
390
  const toolCalls = [];
391
391
  let usageInfo;
392
+ const textDeltaLog = [];
392
393
  let isThinkingTagOpen = false;
393
394
  let currentThinkingContent = "";
394
395
  for await (const part of result.fullStream) {
395
396
  const streamPart = part;
397
+ const thinkingConfig = config.options?.thinkingInText;
396
398
  switch (streamPart.type) {
397
399
  case "text-delta": {
398
400
  const textDelta = getStreamPartText(streamPart);
399
401
  if (!textDelta)
400
402
  break;
401
- const thinkingConfig = config.options?.thinkingInText;
402
403
  if (thinkingConfig?.enabled) {
403
404
  const thinkingResult = processThinkingStream(textDelta, thinkingConfig, {
404
405
  isOpen: isThinkingTagOpen,
@@ -421,6 +422,9 @@ async function invoke(config, options, ctx) {
421
422
  } else {
422
423
  fullContent += textDelta;
423
424
  rawFullContent += textDelta;
425
+ if (process.env.DEBUG_DUPLICATE) {
426
+ textDeltaLog.push(textDelta);
427
+ }
424
428
  if (emitToEnv) {
425
429
  emitToEnv({ type: "text", content: fullContent, delta: textDelta });
426
430
  }
@@ -431,6 +435,8 @@ async function invoke(config, options, ctx) {
431
435
  const reasoningDelta = getStreamPartText(streamPart);
432
436
  if (!reasoningDelta)
433
437
  break;
438
+ if (thinkingConfig?.enabled)
439
+ break;
434
440
  reasoningContent += reasoningDelta;
435
441
  if (emitToEnv) {
436
442
  emitToEnv({ type: "reasoning", content: reasoningContent, delta: reasoningDelta });
@@ -476,12 +482,35 @@ async function invoke(config, options, ctx) {
476
482
  }
477
483
  });
478
484
  }
485
+ const thinkingOpts = config.options?.thinkingInText;
486
+ const outputContent = thinkingOpts?.removeFromOutput ? fullContent : rawFullContent;
487
+ if (process.env.DEBUG_DUPLICATE) {
488
+ const outputLines = outputContent.split(`
489
+ `).filter(Boolean);
490
+ const uniqueLines = new Set(outputLines);
491
+ if (outputLines.length !== uniqueLines.size) {
492
+ logger.warn("[DEBUG_DUPLICATE] outputContent has duplicate lines", {
493
+ fullContent,
494
+ rawFullContent,
495
+ outputContent,
496
+ reasoningContent: reasoningContent || "",
497
+ textDeltas: textDeltaLog
498
+ });
499
+ } else {
500
+ logger.info("[DEBUG_DUPLICATE] outputContent OK", {
501
+ charCount: outputContent.length,
502
+ lineCount: outputLines.length,
503
+ uniqueLineCount: uniqueLines.size,
504
+ hasReasoning: !!reasoningContent
505
+ });
506
+ }
507
+ }
479
508
  if (toolCalls.length > 0) {
480
509
  const firstToolCall = toolCalls[0];
481
510
  return {
482
511
  toolCallId: firstToolCall.id,
483
512
  result: JSON.stringify({
484
- content: rawFullContent,
513
+ content: outputContent,
485
514
  reasoning: reasoningContent || undefined,
486
515
  tool_calls: toolCalls.map((tc) => ({
487
516
  id: tc.id,
@@ -496,7 +525,7 @@ async function invoke(config, options, ctx) {
496
525
  return {
497
526
  toolCallId: "invoke-" + Date.now(),
498
527
  result: JSON.stringify({
499
- content: rawFullContent,
528
+ content: outputContent,
500
529
  reasoning: reasoningContent || undefined,
501
530
  usage: usageInfo,
502
531
  model
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  AgentComponentAdapter,
3
3
  init_agent_component_adapter
4
- } from "./roy-agent-core-zgtmazxg.js";
4
+ } from "./roy-agent-core-9adgwts7.js";
5
5
  import {
6
6
  buildWorkflowNodeMetadata,
7
7
  getWorkflowNodeIdFromMetadata,
@@ -3,7 +3,7 @@ import {
3
3
  init_workflow_json_output_plugin,
4
4
  registerWorkflowJsonOutputPlugin,
5
5
  tracedExtractStructuredJsonViaLlm
6
- } from "./roy-agent-core-6d5v531t.js";
6
+ } from "./roy-agent-core-fkv7ewz9.js";
7
7
  import {
8
8
  AskUserError,
9
9
  init_workflow_hil
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  withTimeout
3
- } from "./roy-agent-core-kdmwhshb.js";
3
+ } from "./roy-agent-core-3f0bkm7q.js";
4
4
  import {
5
5
  AskUserError,
6
6
  init_workflow_hil
@@ -13,10 +13,10 @@ import {
13
13
  } from "./roy-agent-core-ctdhjv68.js";
14
14
  import {
15
15
  SessionMessageConverter
16
- } from "./roy-agent-core-tktkp52c.js";
16
+ } from "./roy-agent-core-c1j7ev4e.js";
17
17
  import {
18
18
  safeParseToolArgs
19
- } from "./roy-agent-core-rjp2cqsn.js";
19
+ } from "./roy-agent-core-ce10b0ez.js";
20
20
  import {
21
21
  envKeyToConfigKey
22
22
  } from "./roy-agent-core-qxhq8ven.js";
@@ -112,7 +112,7 @@ function toLLMMessage(msg) {
112
112
  toolName = toolResult?.toolName;
113
113
  } else {
114
114
  const toolCallParts = msg.content.filter((part) => part.type === "tool-call");
115
- const contentParts = msg.content.filter((part) => part.type === "text" || part.type === "reasoning").map((part) => part.text || "");
115
+ const contentParts = msg.content.filter((part) => part.type === "text").map((part) => part.text || "");
116
116
  content = contentParts.join(`
117
117
  `);
118
118
  if (msg.role === "assistant" && toolCallParts.length > 0) {
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  AgentComponentAdapter,
3
3
  init_agent_component_adapter
4
- } from "./roy-agent-core-zgtmazxg.js";
5
- import"./roy-agent-core-6d5v531t.js";
4
+ } from "./roy-agent-core-9adgwts7.js";
5
+ import"./roy-agent-core-fkv7ewz9.js";
6
6
  import"./roy-agent-core-nhfy3p8q.js";
7
7
  import"./roy-agent-core-e25xkv53.js";
8
8
  import"./roy-agent-core-7tp56w6n.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  safeParseToolArgs
3
- } from "./roy-agent-core-rjp2cqsn.js";
3
+ } from "./roy-agent-core-ce10b0ez.js";
4
4
 
5
5
  // src/env/session/session-message-converter.ts
6
6
  import { randomUUID } from "crypto";
@@ -6,7 +6,7 @@ import {
6
6
  WorkflowEngine,
7
7
  exports_engine,
8
8
  init_engine
9
- } from "./roy-agent-core-yn229bhx.js";
9
+ } from "./roy-agent-core-4hh4s0w1.js";
10
10
  import {
11
11
  WorkflowService
12
12
  } from "./roy-agent-core-4t40mkpv.js";
@@ -136,7 +136,7 @@ class WorkflowComponent extends BaseComponent {
136
136
  const agentComponent = this._workflowEnv.getComponent("agent");
137
137
  const llmComponent = this._workflowEnv.getComponent("llm");
138
138
  if (agentComponent) {
139
- const { AgentComponentAdapter } = await import("./roy-agent-core-ggvv4snf.js");
139
+ const { AgentComponentAdapter } = await import("./roy-agent-core-assbmxe0.js");
140
140
  agentRunner = new AgentComponentAdapter(agentComponent, {}, this.sessionComponent, llmComponent);
141
141
  }
142
142
  }
@@ -208,7 +208,7 @@ class WorkflowComponent extends BaseComponent {
208
208
  const sessionComponent = this._workflowEnv?.getComponent("session");
209
209
  componentLogger.info(`initSqliteService - toolComponent: ${!!toolComponent}, llmComponent: ${!!llmComponent}, skillRegistry: ${!!skillComponent}, sessionComponent: ${!!sessionComponent}`);
210
210
  if (llmComponent) {
211
- const { registerWorkflowJsonOutputPlugin } = await import("./roy-agent-core-8vkr264k.js");
211
+ const { registerWorkflowJsonOutputPlugin } = await import("./roy-agent-core-yakvqh1d.js");
212
212
  registerWorkflowJsonOutputPlugin(llmComponent);
213
213
  }
214
214
  this.createService({
@@ -12,9 +12,13 @@ function safeParseToolArgs(args, depth = 0) {
12
12
  logger.warn(`[safeParseToolArgs] Max recursion depth (${MAX_SAFE_DEPTH}) exceeded at depth ${depth}. ` + "Input may be malicious or abnormally deeply nested. Returning empty object.", { depth, argsType: typeof args });
13
13
  return {};
14
14
  }
15
- if (typeof args === "object" && args !== null) {
15
+ if (typeof args === "object" && args !== null && !Array.isArray(args)) {
16
16
  return args;
17
17
  }
18
+ if (Array.isArray(args)) {
19
+ logger.debug(`[safeParseToolArgs] Input is an array. Tool arguments should be objects. Returning empty object.`, { depth, arrayLength: args.length });
20
+ return {};
21
+ }
18
22
  if (typeof args === "string") {
19
23
  try {
20
24
  const parsed = JSON.parse(args);
@@ -22,9 +26,13 @@ function safeParseToolArgs(args, depth = 0) {
22
26
  logger.debug(`[safeParseToolArgs] Detected double/multi-stringified JSON at depth ${depth}. ` + "LLM may be double-stringifying tool arguments. Parsing recursively.", { depth, parsedLength: parsed.length });
23
27
  return safeParseToolArgs(parsed, depth + 1);
24
28
  }
25
- if (typeof parsed === "object" && parsed !== null) {
29
+ if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
26
30
  return parsed;
27
31
  }
32
+ if (Array.isArray(parsed)) {
33
+ logger.debug(`[safeParseToolArgs] Parsed result is an array at depth ${depth}. ` + "Tool arguments should be objects, not arrays. Returning empty object.", { depth, parsedLength: parsed.length });
34
+ return {};
35
+ }
28
36
  return { value: parsed };
29
37
  } catch {
30
38
  return {};
@@ -159,7 +159,8 @@ function toLLMMessage(msg) {
159
159
  name: toolResult?.toolName
160
160
  };
161
161
  }
162
- const text = msg.content.filter((part) => part.type === "text").map((part) => part.text ?? "").join("");
162
+ const text = msg.content.filter((part) => part.type === "text").map((part) => part.text ?? "").join(`
163
+ `);
163
164
  const toolCallParts = msg.content.filter((part) => part.type === "tool-call");
164
165
  const toolCalls = msg.role === "assistant" && toolCallParts.length > 0 ? toolCallParts.map((part) => {
165
166
  const argsString = typeof part.input === "string" ? part.input : JSON.stringify(part.input ?? {});
@@ -6,7 +6,7 @@ import {
6
6
  import {
7
7
  MemorySessionStore,
8
8
  SQLiteSessionStore
9
- } from "./roy-agent-core-jweqxgyb.js";
9
+ } from "./roy-agent-core-q7sqeax6.js";
10
10
  import {
11
11
  SummaryAgent
12
12
  } from "./roy-agent-core-x3gtyqax.js";
@@ -1,3 +1,6 @@
1
+ import {
2
+ BasePlugin
3
+ } from "./roy-agent-core-az13yzmc.js";
1
4
  import {
2
5
  BaseComponent
3
6
  } from "./roy-agent-core-rgckng3p.js";
@@ -13,6 +16,9 @@ import {
13
16
  // src/env/plugin/plugin-component.ts
14
17
  init_global_hook_manager();
15
18
  init_logger();
19
+ import { existsSync, readFileSync } from "node:fs";
20
+ import { join } from "node:path";
21
+ import { homedir } from "node:os";
16
22
 
17
23
  class PluginComponent extends BaseComponent {
18
24
  name = "plugin";
@@ -32,27 +38,87 @@ class PluginComponent extends BaseComponent {
32
38
  }
33
39
  this.configComponent = options.configComponent;
34
40
  this.setStatus("running");
41
+ await this.loadInstalledPlugins();
35
42
  this.logger.info("[PluginComponent] Initialized");
36
43
  }
37
- register(plugin) {
44
+ async loadInstalledPlugins() {
45
+ const configPath = join(homedir(), ".roy-agent", "plugins.json");
46
+ if (!existsSync(configPath)) {
47
+ this.logger.debug("[PluginComponent] No plugins.json found, skipping auto-load");
48
+ return;
49
+ }
50
+ let config;
51
+ try {
52
+ const raw = readFileSync(configPath, "utf-8");
53
+ config = JSON.parse(raw);
54
+ } catch (err) {
55
+ this.logger.warn(`[PluginComponent] Failed to read plugins.json: ${err}`);
56
+ return;
57
+ }
58
+ const plugins = config.plugins ?? [];
59
+ if (plugins.length === 0) {
60
+ this.logger.debug("[PluginComponent] plugins.json is empty, skipping auto-load");
61
+ return;
62
+ }
63
+ this.logger.info(`[PluginComponent] Loading ${plugins.length} installed plugin(s) from plugins.json`);
64
+ for (const entry of plugins) {
65
+ try {
66
+ await this.loadPluginFromPackage(entry.packageName);
67
+ } catch (err) {
68
+ this.logger.error(`[PluginComponent] Failed to load plugin '${entry.packageName}': ${err}`);
69
+ }
70
+ }
71
+ }
72
+ async loadPluginFromPackage(packageName) {
73
+ let pluginModule;
74
+ try {
75
+ pluginModule = await import(packageName);
76
+ } catch (err) {
77
+ this.logger.warn(`[PluginComponent] Could not import plugin '${packageName}': ${err}`);
78
+ return;
79
+ }
80
+ const tryCreateInstance = (candidate, exportKind) => {
81
+ if (!candidate)
82
+ return;
83
+ if (candidate instanceof BasePlugin) {
84
+ return candidate;
85
+ }
86
+ if (typeof candidate === "function" && candidate.prototype instanceof BasePlugin) {
87
+ return new candidate;
88
+ }
89
+ if (typeof candidate === "object" && typeof candidate.name === "string" && typeof candidate.init === "function") {
90
+ this.logger.debug(`[PluginComponent] Plugin '${packageName}' ${exportKind} matches duck-type BasePlugin interface (instance)`);
91
+ return candidate;
92
+ }
93
+ if (typeof candidate === "function" && typeof candidate.prototype?.init === "function") {
94
+ this.logger.debug(`[PluginComponent] Plugin '${packageName}' ${exportKind} matches duck-type BasePlugin interface (class)`);
95
+ return new candidate;
96
+ }
97
+ return;
98
+ };
99
+ let pluginInstance;
100
+ if (pluginModule.default) {
101
+ pluginInstance = tryCreateInstance(pluginModule.default, "default export");
102
+ }
103
+ if (!pluginInstance && pluginModule.plugin) {
104
+ pluginInstance = tryCreateInstance(pluginModule.plugin, "named export 'plugin'");
105
+ }
106
+ if (!pluginInstance) {
107
+ this.logger.warn(`[PluginComponent] Plugin '${packageName}' does not export a valid plugin instance (expected default export or named export 'plugin' with { name, init, dispose? })`);
108
+ return;
109
+ }
110
+ await this.register(pluginInstance);
111
+ this.logger.info(`[PluginComponent] Loaded plugin: ${pluginInstance.name} (from ${packageName})`);
112
+ }
113
+ async register(plugin) {
38
114
  if (this.registry.has(plugin.name)) {
39
115
  throw new Error(`Plugin "${plugin.name}" is already registered`);
40
116
  }
41
117
  const env = this.createPluginEnv(plugin);
42
118
  try {
43
- const result = plugin.init(env);
44
- if (result instanceof Promise) {
45
- result.then(() => {
46
- this.registry.set(plugin.name, plugin);
47
- this.logger.info(`Registered plugin: ${plugin.name}`);
48
- }).catch((err) => {
49
- this.logger.error(`Failed to init plugin ${plugin.name}: ${err}`);
50
- throw err;
51
- });
52
- } else {
53
- this.registry.set(plugin.name, plugin);
54
- this.logger.info(`Registered plugin: ${plugin.name}`);
55
- }
119
+ await plugin.init(env);
120
+ this.registry.set(plugin.name, plugin);
121
+ this.logger.info(`Registered plugin: ${plugin.name}`);
56
122
  } catch (err) {
57
123
  this.logger.error(`Failed to init plugin ${plugin.name}: ${err}`);
58
124
  throw err;
@@ -84,9 +150,9 @@ class PluginComponent extends BaseComponent {
84
150
  getConfig(name) {
85
151
  return this.configComponent?.get(`plugin.${name}`);
86
152
  }
87
- registerAll(plugins) {
153
+ async registerAll(plugins) {
88
154
  for (const plugin of plugins) {
89
- this.register(plugin);
155
+ await this.register(plugin);
90
156
  }
91
157
  }
92
158
  async stop() {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  SessionMessageConverter
3
- } from "./roy-agent-core-tktkp52c.js";
3
+ } from "./roy-agent-core-c1j7ev4e.js";
4
4
  import {
5
5
  __require
6
6
  } from "./roy-agent-core-fs0mn2jk.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  invoke
3
- } from "./roy-agent-core-kdmwhshb.js";
3
+ } from "./roy-agent-core-3f0bkm7q.js";
4
4
  import {
5
5
  ContextError,
6
6
  ErrorCodes
@@ -631,7 +631,9 @@ class LLMComponent extends BaseComponent {
631
631
  toolCalls: msg.toolCalls
632
632
  }));
633
633
  const provider = this.getProvider(providerId);
634
- const thinkingInText = provider?.capabilities?.thinkingInText;
634
+ const capabilities = provider?.capabilities;
635
+ const thinkingInText = capabilities?.thinkingInText;
636
+ const effectiveThinkingInText = thinkingInText !== undefined ? thinkingInText : undefined;
635
637
  return {
636
638
  providerId,
637
639
  model,
@@ -639,12 +641,12 @@ class LLMComponent extends BaseComponent {
639
641
  model: `${providerId}/${model}`,
640
642
  apiKey,
641
643
  baseURL: provider?.baseURL,
642
- ...thinkingInText?.enabled ? {
644
+ ...effectiveThinkingInText?.enabled ? {
643
645
  options: {
644
646
  thinkingInText: {
645
- enabled: thinkingInText.enabled,
646
- tags: thinkingInText.tags,
647
- removeFromOutput: thinkingInText.removeFromOutput
647
+ enabled: effectiveThinkingInText.enabled,
648
+ tags: effectiveThinkingInText.tags,
649
+ removeFromOutput: effectiveThinkingInText.removeFromOutput
648
650
  }
649
651
  }
650
652
  } : {}
@@ -10,7 +10,7 @@ import {
10
10
  tracedExtractStructuredJsonViaLlm,
11
11
  tracedRunWorkflowJsonOutputExtraction,
12
12
  unregisterWorkflowJsonOutputPlugin
13
- } from "./roy-agent-core-6d5v531t.js";
13
+ } from "./roy-agent-core-fkv7ewz9.js";
14
14
  import"./roy-agent-core-nhfy3p8q.js";
15
15
  import"./roy-agent-core-e25xkv53.js";
16
16
  import"./roy-agent-core-7tp56w6n.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-setting/roy-agent-core",
3
- "version": "1.5.71",
3
+ "version": "1.5.73",
4
4
  "type": "module",
5
5
  "description": "Core SDK for roy-agent - Environment, Components, Tools, Sessions, Tasks",
6
6
  "main": "./dist/index.js",