@ai-setting/roy-agent-core 1.5.51 → 1.5.53
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.
- package/dist/env/agent/index.js +3 -2
- package/dist/env/index.js +7 -6
- package/dist/env/llm/index.js +4 -2
- package/dist/env/prompt/index.js +1 -1
- package/dist/env/session/index.js +3 -3
- package/dist/env/session/storage/index.js +2 -2
- package/dist/env/task/delegate/index.js +1 -1
- package/dist/env/task/index.js +2 -2
- package/dist/env/tool/built-in/index.js +1 -1
- package/dist/env/tool/index.js +2 -2
- package/dist/env/workflow/engine/index.js +1 -1
- package/dist/env/workflow/index.js +2 -2
- package/dist/index.js +19 -17
- package/dist/shared/@ai-setting/{roy-agent-core-smwwze1m.js → roy-agent-core-0vt0trev.js} +1 -1
- package/dist/shared/@ai-setting/roy-agent-core-4ch3ghj6.js +610 -0
- package/dist/shared/@ai-setting/{roy-agent-core-6de35s2n.js → roy-agent-core-9m9m6fe1.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-ysvh8er9.js → roy-agent-core-bwrzwq5x.js} +10 -0
- package/dist/shared/@ai-setting/{roy-agent-core-7b35emr7.js → roy-agent-core-ew29335n.js} +3 -2
- package/dist/shared/@ai-setting/{roy-agent-core-wbqmmavh.js → roy-agent-core-fwq0hs6e.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-2k4r9grg.js → roy-agent-core-g7qhnsz3.js} +46 -8
- package/dist/shared/@ai-setting/{roy-agent-core-qjh1ec46.js → roy-agent-core-hv713d36.js} +13 -582
- package/dist/shared/@ai-setting/{roy-agent-core-rmndq0sb.js → roy-agent-core-jkhhsa3t.js} +13 -6
- package/dist/shared/@ai-setting/{roy-agent-core-vehgmfj1.js → roy-agent-core-nfa6fc3a.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-6mcb7nqa.js → roy-agent-core-pcjenbaf.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-h9tpga25.js → roy-agent-core-vbyct0e7.js} +18 -13
- package/package.json +1 -1
- /package/dist/shared/@ai-setting/{roy-agent-core-4hk6ey73.js → roy-agent-core-nt1q2g91.js} +0 -0
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
withTimeout
|
|
3
|
+
} from "./roy-agent-core-4ch3ghj6.js";
|
|
1
4
|
import {
|
|
2
5
|
AskUserError,
|
|
3
6
|
init_workflow_hil
|
|
@@ -10,7 +13,7 @@ import {
|
|
|
10
13
|
} from "./roy-agent-core-ctdhjv68.js";
|
|
11
14
|
import {
|
|
12
15
|
SessionMessageConverter
|
|
13
|
-
} from "./roy-agent-core-
|
|
16
|
+
} from "./roy-agent-core-ew29335n.js";
|
|
14
17
|
import {
|
|
15
18
|
envKeyToConfigKey
|
|
16
19
|
} from "./roy-agent-core-qxhq8ven.js";
|
|
@@ -671,7 +674,8 @@ class AgentComponent extends BaseComponent {
|
|
|
671
674
|
if (typeof tc.function.arguments === "string") {
|
|
672
675
|
argsStr = tc.function.arguments;
|
|
673
676
|
try {
|
|
674
|
-
|
|
677
|
+
const parsed = JSON.parse(argsStr);
|
|
678
|
+
argsObj = typeof parsed === "string" ? { _raw: parsed } : parsed;
|
|
675
679
|
} catch {
|
|
676
680
|
argsObj = { _raw: argsStr };
|
|
677
681
|
}
|
|
@@ -683,7 +687,8 @@ class AgentComponent extends BaseComponent {
|
|
|
683
687
|
if (typeof tc.arguments === "string") {
|
|
684
688
|
argsStr = tc.arguments;
|
|
685
689
|
try {
|
|
686
|
-
|
|
690
|
+
const parsed = JSON.parse(argsStr);
|
|
691
|
+
argsObj = typeof parsed === "string" ? { _raw: parsed } : parsed;
|
|
687
692
|
} catch {
|
|
688
693
|
argsObj = { _raw: argsStr };
|
|
689
694
|
}
|
|
@@ -721,7 +726,14 @@ class AgentComponent extends BaseComponent {
|
|
|
721
726
|
}
|
|
722
727
|
const func = toolCall.function;
|
|
723
728
|
const tcName = func?.name || toolCall.name || "unknown";
|
|
724
|
-
const tcArgs = func?.arguments ? typeof func.arguments === "string" ?
|
|
729
|
+
const tcArgs = func?.arguments ? typeof func.arguments === "string" ? (() => {
|
|
730
|
+
const parsed = JSON.parse(func.arguments);
|
|
731
|
+
if (typeof parsed === "string") {
|
|
732
|
+
logger.warn(`[agent.component] Tool "${tcName}" arguments are double-stringified, wrapping in { _raw }`);
|
|
733
|
+
return { _raw: parsed };
|
|
734
|
+
}
|
|
735
|
+
return parsed;
|
|
736
|
+
})() : func.arguments : toolCall.arguments;
|
|
725
737
|
hookCtx.currentToolCall = {
|
|
726
738
|
id: toolCall.id,
|
|
727
739
|
name: tcName,
|
|
@@ -789,11 +801,15 @@ class AgentComponent extends BaseComponent {
|
|
|
789
801
|
});
|
|
790
802
|
}
|
|
791
803
|
for (const tc of llmOutput.toolCalls) {
|
|
804
|
+
const tcInput = typeof tc.function?.arguments === "string" ? (() => {
|
|
805
|
+
const parsed = JSON.parse(tc.function.arguments);
|
|
806
|
+
return typeof parsed === "string" ? { _raw: parsed } : parsed;
|
|
807
|
+
})() : tc.arguments || {};
|
|
792
808
|
assistantParts.push({
|
|
793
809
|
type: "tool-call",
|
|
794
810
|
toolCallId: tc.id,
|
|
795
811
|
toolName: tc.function?.name || tc.name || "unknown",
|
|
796
|
-
input:
|
|
812
|
+
input: tcInput
|
|
797
813
|
});
|
|
798
814
|
}
|
|
799
815
|
this.pushMessage(hookCtx, {
|
|
@@ -952,6 +968,16 @@ class AgentComponent extends BaseComponent {
|
|
|
952
968
|
}
|
|
953
969
|
logger.info(`Agent aborted: ${agentName}`);
|
|
954
970
|
}
|
|
971
|
+
abortAll() {
|
|
972
|
+
for (const key of this.aborted.keys()) {
|
|
973
|
+
this.aborted.set(key, true);
|
|
974
|
+
}
|
|
975
|
+
for (const [key, controller] of this.abortControllers) {
|
|
976
|
+
controller.abort();
|
|
977
|
+
logger.debug(`[abortAll] AbortController.abort() called for run: ${key}`);
|
|
978
|
+
}
|
|
979
|
+
logger.info(`All agents aborted (${this.abortControllers.size} runs)`);
|
|
980
|
+
}
|
|
955
981
|
async _buildAdditionInfo(ctx) {
|
|
956
982
|
let additionInfo = ctx.context?.additionInfo || "";
|
|
957
983
|
const currentTaskId = getCurrentTaskId();
|
|
@@ -989,7 +1015,7 @@ ${additionInfo}`
|
|
|
989
1015
|
const convertedMessages = messages.map(toLLMMessage);
|
|
990
1016
|
logger.debug(`[invokeLLM] Calling LLMComponent.invoke with ${convertedMessages.length} messages`);
|
|
991
1017
|
try {
|
|
992
|
-
const
|
|
1018
|
+
const llmPromise = this.llmComponent.invoke({
|
|
993
1019
|
messages: convertedMessages,
|
|
994
1020
|
tools: ctx.tools.map((t) => ({
|
|
995
1021
|
name: t.name,
|
|
@@ -1003,6 +1029,7 @@ ${additionInfo}`
|
|
|
1003
1029
|
},
|
|
1004
1030
|
abortSignal: ctx.context.abort
|
|
1005
1031
|
});
|
|
1032
|
+
const result = await withTimeout(llmPromise, 120000, "LLM invocation timeout after 120s");
|
|
1006
1033
|
logger.debug("[invokeLLM] LLMComponent.invoke returned successfully");
|
|
1007
1034
|
return {
|
|
1008
1035
|
content: result.output?.content || "",
|
|
@@ -1076,11 +1103,22 @@ ${additionInfo}`
|
|
|
1076
1103
|
context: toolContext
|
|
1077
1104
|
};
|
|
1078
1105
|
let result;
|
|
1106
|
+
const isLongRunningTool = toolName === "delegate_task" || toolName === "stop_task" || toolName === "bash";
|
|
1079
1107
|
if (this.toolComponent?.execute) {
|
|
1080
|
-
|
|
1108
|
+
const toolPromise = this.toolComponent.execute(request);
|
|
1109
|
+
if (isLongRunningTool) {
|
|
1110
|
+
result = await toolPromise;
|
|
1111
|
+
} else {
|
|
1112
|
+
result = await withTimeout(toolPromise, 120000, `Tool '${toolName}' execution timeout after 120s`);
|
|
1113
|
+
}
|
|
1081
1114
|
} else {
|
|
1082
1115
|
logger.debug(`[executeTool] No ToolComponent available, executing tool directly`);
|
|
1083
|
-
|
|
1116
|
+
const toolPromise = tool.execute(toolCall.arguments, toolContext);
|
|
1117
|
+
if (isLongRunningTool) {
|
|
1118
|
+
result = await toolPromise;
|
|
1119
|
+
} else {
|
|
1120
|
+
result = await withTimeout(toolPromise, 120000, `Tool '${toolName}' execution timeout after 120s`);
|
|
1121
|
+
}
|
|
1084
1122
|
}
|
|
1085
1123
|
this.pushEnvEvent({
|
|
1086
1124
|
type: "tool.result",
|