@ai-setting/roy-agent-core 1.6.17 → 1.6.18
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 +1 -1
- package/dist/env/event-source/index.js +3 -3
- package/dist/env/index.js +10 -10
- package/dist/env/prompt/index.js +2 -2
- package/dist/env/task/delegate/index.js +2 -2
- package/dist/env/task/index.js +4 -4
- package/dist/env/task/plugins/index.js +2 -2
- package/dist/env/task/tools/index.js +1 -1
- package/dist/env/workflow/index.js +2 -2
- package/dist/env/workflow/tools/index.js +1 -1
- package/dist/index.js +11 -11
- package/dist/shared/@ai-setting/{roy-agent-core-pq1q854s.js → roy-agent-core-65vpkh7x.js} +8 -0
- package/dist/shared/@ai-setting/{roy-agent-core-bsxgrqzq.js → roy-agent-core-6mz26khm.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-r0t34bbh.js → roy-agent-core-c7e3htaq.js} +146 -8
- package/dist/shared/@ai-setting/{roy-agent-core-x36fsm47.js → roy-agent-core-f6x6ksz3.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-cfqm5w9b.js → roy-agent-core-h07kk80k.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-4z7dzcgb.js → roy-agent-core-kkt2ndpf.js} +168 -7
- package/dist/shared/@ai-setting/{roy-agent-core-m134hen4.js → roy-agent-core-mvmgy9t0.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-4cgkj7v0.js → roy-agent-core-n1fx2fx4.js} +679 -32
- package/dist/shared/@ai-setting/{roy-agent-core-yqxrekhg.js → roy-agent-core-nreqmmtz.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-edbhy767.js → roy-agent-core-qyb2z42s.js} +27 -1
- package/dist/shared/@ai-setting/{roy-agent-core-dnns0v64.js → roy-agent-core-vc8e968b.js} +1 -1
- package/package.json +1 -1
|
@@ -648,6 +648,128 @@ function buildErrorReturn(args) {
|
|
|
648
648
|
}
|
|
649
649
|
};
|
|
650
650
|
}
|
|
651
|
+
var MAX_ERROR_MESSAGE_CHARS = 1500;
|
|
652
|
+
var ERROR_CLASSIFICATION_PREFIX = "[ErrorType=";
|
|
653
|
+
function classifyError(error) {
|
|
654
|
+
if (error instanceof Error) {
|
|
655
|
+
const rawName = typeof error.name === "string" && error.name.trim() ? error.name.trim() : "Error";
|
|
656
|
+
const safeName = rawName.replace(/[^A-Za-z0-9_.-]/g, "_").slice(0, 80);
|
|
657
|
+
if (!error.message)
|
|
658
|
+
return `${ERROR_CLASSIFICATION_PREFIX}${safeName}:EmptyMessage]`;
|
|
659
|
+
return `${ERROR_CLASSIFICATION_PREFIX}${safeName}]`;
|
|
660
|
+
}
|
|
661
|
+
if (error === null)
|
|
662
|
+
return `${ERROR_CLASSIFICATION_PREFIX}Null]`;
|
|
663
|
+
if (error === undefined)
|
|
664
|
+
return `${ERROR_CLASSIFICATION_PREFIX}Undefined]`;
|
|
665
|
+
if (typeof error === "string") {
|
|
666
|
+
if (error.trim().length === 0)
|
|
667
|
+
return `${ERROR_CLASSIFICATION_PREFIX}EmptyString]`;
|
|
668
|
+
return `${ERROR_CLASSIFICATION_PREFIX}String]`;
|
|
669
|
+
}
|
|
670
|
+
if (typeof error === "number")
|
|
671
|
+
return `${ERROR_CLASSIFICATION_PREFIX}Number]`;
|
|
672
|
+
if (typeof error === "boolean")
|
|
673
|
+
return `${ERROR_CLASSIFICATION_PREFIX}Boolean]`;
|
|
674
|
+
if (typeof error === "object")
|
|
675
|
+
return `${ERROR_CLASSIFICATION_PREFIX}Object]`;
|
|
676
|
+
return `${ERROR_CLASSIFICATION_PREFIX}Unknown]`;
|
|
677
|
+
}
|
|
678
|
+
function normalizeErrorMessage(error) {
|
|
679
|
+
if (error instanceof Error) {
|
|
680
|
+
if (typeof error.message === "string" && error.message.length > 0) {
|
|
681
|
+
return error.message;
|
|
682
|
+
}
|
|
683
|
+
return error.name && error.name !== "Error" ? error.name : "";
|
|
684
|
+
}
|
|
685
|
+
if (typeof error === "string")
|
|
686
|
+
return error;
|
|
687
|
+
if (typeof error === "number" || typeof error === "boolean") {
|
|
688
|
+
return String(error);
|
|
689
|
+
}
|
|
690
|
+
return "";
|
|
691
|
+
}
|
|
692
|
+
function sanitizeErrorMessage(message, sensitive) {
|
|
693
|
+
if (!message || sensitive.length === 0)
|
|
694
|
+
return message;
|
|
695
|
+
let sanitized = message;
|
|
696
|
+
const ordered = [...sensitive].sort((a, b) => b.length - a.length);
|
|
697
|
+
for (const secret of ordered) {
|
|
698
|
+
if (!secret)
|
|
699
|
+
continue;
|
|
700
|
+
sanitized = sanitized.split(secret).join("[REDACTED]");
|
|
701
|
+
}
|
|
702
|
+
return sanitized;
|
|
703
|
+
}
|
|
704
|
+
function capErrorLength(message, max = MAX_ERROR_MESSAGE_CHARS) {
|
|
705
|
+
if (typeof message !== "string" || message.length <= max)
|
|
706
|
+
return message;
|
|
707
|
+
const truncated = message.substring(0, max);
|
|
708
|
+
return `${truncated}…[truncated ${message.length - max} chars; original=${message.length}]`;
|
|
709
|
+
}
|
|
710
|
+
function errorMessageBaseFor(message) {
|
|
711
|
+
return typeof message === "string" && message.length > 0 ? message : "";
|
|
712
|
+
}
|
|
713
|
+
function collectSensitiveValues(input, messageForEnvScan) {
|
|
714
|
+
const sensitive = [];
|
|
715
|
+
if (input && typeof input === "object") {
|
|
716
|
+
for (const v of Object.values(input)) {
|
|
717
|
+
if (typeof v === "string" && v.length >= 6)
|
|
718
|
+
sensitive.push(v);
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
const envSecretKeys = new Set;
|
|
722
|
+
try {
|
|
723
|
+
for (const [k, v] of Object.entries(process.env ?? {})) {
|
|
724
|
+
if (typeof v !== "string" || v.length < 6)
|
|
725
|
+
continue;
|
|
726
|
+
const kLower = k.toLowerCase();
|
|
727
|
+
if (kLower.includes("token") || kLower.includes("secret") || kLower.includes("password") || kLower.includes("api_key") || kLower.includes("apikey")) {
|
|
728
|
+
sensitive.push(v);
|
|
729
|
+
envSecretKeys.add(k);
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
} catch {}
|
|
733
|
+
if (messageForEnvScan) {
|
|
734
|
+
try {
|
|
735
|
+
for (const [k, v] of Object.entries(process.env ?? {})) {
|
|
736
|
+
if (typeof v !== "string" || v.length < 8)
|
|
737
|
+
continue;
|
|
738
|
+
if (envSecretKeys.has(k))
|
|
739
|
+
continue;
|
|
740
|
+
if (messageForEnvScan.includes(v) && (/[0-9_-]/.test(v) || /^[A-Za-z0-9+/=_-]+$/.test(v))) {
|
|
741
|
+
sensitive.push(v);
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
} catch {}
|
|
745
|
+
}
|
|
746
|
+
return sensitive;
|
|
747
|
+
}
|
|
748
|
+
function extractStackSummary(message) {
|
|
749
|
+
if (typeof message !== "string" || message.length === 0)
|
|
750
|
+
return "";
|
|
751
|
+
const lines = message.split(/\r?\n/).map((l) => l.trimEnd()).filter((l) => l.length > 0);
|
|
752
|
+
if (lines.length === 0)
|
|
753
|
+
return "";
|
|
754
|
+
const picked = [lines[0]];
|
|
755
|
+
let frameCount = 0;
|
|
756
|
+
for (let i = 1;i < lines.length; i++) {
|
|
757
|
+
const line = lines[i];
|
|
758
|
+
if (/^\s*(File\s+|at\s+)/.test(line)) {
|
|
759
|
+
picked.push(line);
|
|
760
|
+
frameCount++;
|
|
761
|
+
if (frameCount >= 3)
|
|
762
|
+
break;
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
const lastLine = lines[lines.length - 1];
|
|
766
|
+
if (picked[picked.length - 1] !== lastLine && !/^\s*(File\s+|at\s+)/.test(lastLine)) {
|
|
767
|
+
picked.push(lastLine);
|
|
768
|
+
}
|
|
769
|
+
const joined = picked.join(`
|
|
770
|
+
`);
|
|
771
|
+
return joined.length > 600 ? joined.slice(0, 600) + "…[truncated]" : joined;
|
|
772
|
+
}
|
|
651
773
|
var RunWorkflowInputSchema = z8.object({
|
|
652
774
|
workflow_name: z8.string().describe("Name of the workflow to run"),
|
|
653
775
|
input: z8.record(z8.any()).optional().describe("Input to pass to the workflow"),
|
|
@@ -801,11 +923,42 @@ function createRunWorkflowTool(workflowService, hooks) {
|
|
|
801
923
|
}
|
|
802
924
|
durationMs = Date.now() - startTime;
|
|
803
925
|
const finalRunId = capturedByCallback ? capturedRunId : result.runId ?? "";
|
|
926
|
+
const resolvedStatus = result.status;
|
|
927
|
+
const isResolvedFailure = resolvedStatus === "failed" || resolvedStatus === "stopped";
|
|
928
|
+
const sensitiveForResolved = collectSensitiveValues(input, errorMessageBaseFor(result.error ?? ""));
|
|
929
|
+
const sanitizedResolvedMessage = sanitizeErrorMessage(errorMessageBaseFor(result.error ?? ""), sensitiveForResolved);
|
|
930
|
+
const resolvedErrorClassification = result.error ? classifyError(new Error(result.error)) : "[ErrorType=EmptyMessage]";
|
|
931
|
+
const resolvedErrorMessage = capErrorLength(sanitizedResolvedMessage.length > 0 ? sanitizedResolvedMessage : "Workflow reported status=failed without an error message (runId=" + finalRunId + ")");
|
|
932
|
+
if (isResolvedFailure) {
|
|
933
|
+
const failureCode = result.error ? "WORKFLOW_FAILED" : "WORKFLOW_FAILED_NO_MESSAGE";
|
|
934
|
+
return {
|
|
935
|
+
success: false,
|
|
936
|
+
output: {
|
|
937
|
+
run_id: finalRunId,
|
|
938
|
+
session_id: result.sessionId ?? finalRunId,
|
|
939
|
+
status: resolvedStatus,
|
|
940
|
+
error: result.error,
|
|
941
|
+
error_code: failureCode,
|
|
942
|
+
error_message: result.error ? sanitizedResolvedMessage : "",
|
|
943
|
+
error_stack_summary: extractStackSummary(result.error ?? ""),
|
|
944
|
+
output: result.output,
|
|
945
|
+
duration_ms: result.durationMs || durationMs,
|
|
946
|
+
...result.pendingNodeId ? { pending_node_id: result.pendingNodeId } : {},
|
|
947
|
+
...result.query ? { query: result.query } : {},
|
|
948
|
+
...result.agentSessionId ? { agent_session_id: result.agentSessionId } : {}
|
|
949
|
+
},
|
|
950
|
+
error: `${resolvedErrorMessage} ${resolvedErrorClassification} (runId: ${finalRunId})`,
|
|
951
|
+
metadata: {
|
|
952
|
+
execution_time_ms: durationMs,
|
|
953
|
+
run_id: finalRunId
|
|
954
|
+
}
|
|
955
|
+
};
|
|
956
|
+
}
|
|
804
957
|
return {
|
|
805
|
-
success:
|
|
958
|
+
success: resolvedStatus === "completed" || resolvedStatus === "paused",
|
|
806
959
|
output: {
|
|
807
960
|
run_id: finalRunId,
|
|
808
|
-
status:
|
|
961
|
+
status: resolvedStatus,
|
|
809
962
|
output: result.output,
|
|
810
963
|
error: result.error,
|
|
811
964
|
duration_ms: result.durationMs || durationMs,
|
|
@@ -823,9 +976,13 @@ function createRunWorkflowTool(workflowService, hooks) {
|
|
|
823
976
|
clearTimeout(timeoutHandle);
|
|
824
977
|
}
|
|
825
978
|
durationMs = Date.now() - startTime;
|
|
826
|
-
const
|
|
979
|
+
const errorClassification = classifyError(error);
|
|
980
|
+
const rawErrorMessage = normalizeErrorMessage(error);
|
|
981
|
+
const errorMessageBase = rawErrorMessage.length > 0 ? rawErrorMessage : `${errorClassification} (no message from thrown value)`;
|
|
827
982
|
const errorRunId = capturedRunId ?? reservedRunId;
|
|
828
|
-
|
|
983
|
+
const sensitiveValues = collectSensitiveValues(input, errorMessageBase);
|
|
984
|
+
const sanitizedMessage = sanitizeErrorMessage(errorMessageBase, sensitiveValues);
|
|
985
|
+
if (sanitizedMessage.includes("Workflow not found")) {
|
|
829
986
|
return buildErrorReturn({
|
|
830
987
|
errorRunId,
|
|
831
988
|
status: "failed",
|
|
@@ -833,7 +990,7 @@ function createRunWorkflowTool(workflowService, hooks) {
|
|
|
833
990
|
durationMs
|
|
834
991
|
});
|
|
835
992
|
}
|
|
836
|
-
const isTimeoutLike =
|
|
993
|
+
const isTimeoutLike = sanitizedMessage.includes("abort") || sanitizedMessage.includes("timed out") || sanitizedMessage.includes("execution timeout:");
|
|
837
994
|
if (isTimeoutLike) {
|
|
838
995
|
if (!timedOut) {
|
|
839
996
|
attemptStopOnTimeout(workflowService, errorRunId, "timed out");
|
|
@@ -846,12 +1003,16 @@ function createRunWorkflowTool(workflowService, hooks) {
|
|
|
846
1003
|
});
|
|
847
1004
|
}
|
|
848
1005
|
if (logger7?.error) {
|
|
849
|
-
logger7.error(`Failed to run workflow: ${workflow_name}`, {
|
|
1006
|
+
logger7.error(`Failed to run workflow: ${workflow_name}`, {
|
|
1007
|
+
error: rawErrorMessage,
|
|
1008
|
+
errorClassification
|
|
1009
|
+
});
|
|
850
1010
|
}
|
|
1011
|
+
const composed = rawErrorMessage.length > 0 ? `Failed to run workflow ${workflow_name}: ${sanitizedMessage} ${errorClassification}` : `Failed to run workflow ${workflow_name} ${errorClassification}: ${sanitizedMessage}`;
|
|
851
1012
|
return buildErrorReturn({
|
|
852
1013
|
errorRunId,
|
|
853
1014
|
status: "failed",
|
|
854
|
-
errorMessage:
|
|
1015
|
+
errorMessage: capErrorLength(composed),
|
|
855
1016
|
durationMs
|
|
856
1017
|
});
|
|
857
1018
|
}
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
BackgroundTaskManager,
|
|
9
9
|
createDelegateTool,
|
|
10
10
|
createStopTool
|
|
11
|
-
} from "./roy-agent-core-
|
|
11
|
+
} from "./roy-agent-core-n1fx2fx4.js";
|
|
12
12
|
import {
|
|
13
13
|
SQLiteTaskStore,
|
|
14
14
|
getDefaultTaskDbPath
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
searchTasksTool,
|
|
25
25
|
treeTasksTool,
|
|
26
26
|
updateTaskTool
|
|
27
|
-
} from "./roy-agent-core-
|
|
27
|
+
} from "./roy-agent-core-c7e3htaq.js";
|
|
28
28
|
import {
|
|
29
29
|
createOperationTool,
|
|
30
30
|
deleteOperationTool,
|