@kortyx/agent 0.25.0 → 0.25.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.25.1](https://github.com/kortyx-io/kortyx/compare/agent-v0.25.0...agent-v0.25.1) (2026-09-21)
4
+
5
+
6
+ ### Dependencies
7
+
8
+ * The following workspace dependencies were updated
9
+ * dependencies
10
+ * @kortyx/runtime bumped to 0.20.1
11
+ * devDependencies
12
+ * @kortyx/hooks bumped to 0.27.0
13
+
3
14
  ## [0.25.0](https://github.com/kortyx-io/kortyx/compare/agent-v0.24.0...agent-v0.25.0) (2026-09-18)
4
15
 
5
16
 
package/dist/index.js CHANGED
@@ -52,6 +52,7 @@ var require_internal = __commonJS({
52
52
  var internal_exports = {};
53
53
  __export2(internal_exports, {
54
54
  errorDiagnostics: () => errorDiagnostics,
55
+ exceptionDiagnostics: () => exceptionDiagnostics,
55
56
  isModelTraceSpan: () => isModelTraceSpan,
56
57
  runReasonEngine: () => runReasonEngine,
57
58
  safeSpan: () => safeSpan,
@@ -61,26 +62,53 @@ var require_internal = __commonJS({
61
62
  });
62
63
  module2.exports = __toCommonJS2(internal_exports);
63
64
  var import_errors6 = require("@kortyx/core/errors");
64
- function errorDiagnostics(error, project) {
65
+ var MAX_STACK_LENGTH = 32768;
66
+ var MAX_CAUSE_DEPTH = 4;
67
+ var projectDetails = (value, depth, seen) => {
68
+ const objectValue = value && typeof value === "object" ? value : void 0;
69
+ if (objectValue) {
70
+ if (seen.has(objectValue))
71
+ return { type: "Error", message: "Circular error cause." };
72
+ seen.add(objectValue);
73
+ }
74
+ const name = (0, import_errors6.errorProperty)(value, "name") ?? (value instanceof Error ? value.name : void 0);
75
+ const message = (0, import_errors6.errorProperty)(value, "message");
76
+ const stack = (0, import_errors6.errorProperty)(value, "stack") ?? (value instanceof Error ? (() => {
77
+ try {
78
+ return value.stack;
79
+ } catch {
80
+ return void 0;
81
+ }
82
+ })() : void 0);
83
+ const cause = depth < MAX_CAUSE_DEPTH ? (0, import_errors6.errorProperty)(value, "cause") : null;
84
+ return {
85
+ type: typeof name === "string" ? name.slice(0, 256) : "Error",
86
+ message: (typeof value === "string" ? value : typeof message === "string" ? message : "Execution reported a fault.").slice(0, 8192),
87
+ ...typeof stack === "string" ? { stack: stack.slice(0, MAX_STACK_LENGTH) } : {},
88
+ ...cause !== null && cause !== void 0 ? { cause: projectDetails(cause, depth + 1, seen) } : {}
89
+ };
90
+ };
91
+ var sanitizeProjectedDetails = (details, depth = 0) => ({
92
+ ...typeof details.type === "string" ? { type: details.type.slice(0, 256) } : {},
93
+ message: typeof details.message === "string" ? details.message.slice(0, 8192) : "Execution reported a fault.",
94
+ ...typeof details.stack === "string" ? { stack: details.stack.slice(0, MAX_STACK_LENGTH) } : {},
95
+ ...depth < MAX_CAUSE_DEPTH && details.cause ? { cause: sanitizeProjectedDetails(details.cause, depth + 1) } : {}
96
+ });
97
+ function exceptionDiagnostics(error, project) {
65
98
  try {
66
- const name = (0, import_errors6.errorProperty)(error, "name") ?? (error instanceof Error ? error.name : void 0);
67
- const message = (0, import_errors6.errorProperty)(error, "message");
68
- const details = project ? project(error) : {
69
- type: typeof name === "string" ? name : "Error",
70
- message: typeof error === "string" ? error : typeof message === "string" ? message : "Execution reported a fault."
71
- };
72
- if (!details) return {};
73
- const projectedMessage = details.message;
74
- const projectedType = details.type;
75
- if (typeof projectedMessage !== "string") return {};
76
- return {
77
- errorMessage: projectedMessage.slice(0, 8192),
78
- ...typeof projectedType === "string" ? { errorType: projectedType.slice(0, 256) } : {}
79
- };
99
+ const details = project ? project(error) : projectDetails(error, 0, /* @__PURE__ */ new WeakSet());
100
+ return details ? sanitizeProjectedDetails(details) : null;
80
101
  } catch {
81
- return {};
102
+ return null;
82
103
  }
83
104
  }
105
+ function errorDiagnostics(error, project) {
106
+ const details = exceptionDiagnostics(error, project);
107
+ return details ? {
108
+ errorMessage: details.message,
109
+ ...details.type ? { errorType: details.type } : {}
110
+ } : {};
111
+ }
84
112
  function isModelTraceSpan(name) {
85
113
  return name === "runReasonEngine" || name === "useReason";
86
114
  }
@@ -499,6 +527,7 @@ var require_dist = __commonJS({
499
527
  createWorkflowHooks: () => createWorkflowHooks,
500
528
  emitWorkflowCall: () => emitWorkflowCall2,
501
529
  parallel: () => parallel,
530
+ reportError: () => reportError,
502
531
  runWithHookContext: () => runWithHookContext,
503
532
  useAbortSignal: () => useAbortSignal,
504
533
  useInterrupt: () => useInterrupt,
@@ -977,26 +1006,53 @@ var require_dist = __commonJS({
977
1006
  var import_core22 = require("@kortyx/core");
978
1007
  var import_errors32 = require("@kortyx/core/errors");
979
1008
  var import_errors22 = require("@kortyx/core/errors");
980
- function errorDiagnostics(error, project) {
1009
+ var MAX_STACK_LENGTH = 32768;
1010
+ var MAX_CAUSE_DEPTH = 4;
1011
+ var projectDetails = (value, depth, seen) => {
1012
+ const objectValue = value && typeof value === "object" ? value : void 0;
1013
+ if (objectValue) {
1014
+ if (seen.has(objectValue))
1015
+ return { type: "Error", message: "Circular error cause." };
1016
+ seen.add(objectValue);
1017
+ }
1018
+ const name = (0, import_errors22.errorProperty)(value, "name") ?? (value instanceof Error ? value.name : void 0);
1019
+ const message = (0, import_errors22.errorProperty)(value, "message");
1020
+ const stack = (0, import_errors22.errorProperty)(value, "stack") ?? (value instanceof Error ? (() => {
1021
+ try {
1022
+ return value.stack;
1023
+ } catch {
1024
+ return void 0;
1025
+ }
1026
+ })() : void 0);
1027
+ const cause = depth < MAX_CAUSE_DEPTH ? (0, import_errors22.errorProperty)(value, "cause") : null;
1028
+ return {
1029
+ type: typeof name === "string" ? name.slice(0, 256) : "Error",
1030
+ message: (typeof value === "string" ? value : typeof message === "string" ? message : "Execution reported a fault.").slice(0, 8192),
1031
+ ...typeof stack === "string" ? { stack: stack.slice(0, MAX_STACK_LENGTH) } : {},
1032
+ ...cause !== null && cause !== void 0 ? { cause: projectDetails(cause, depth + 1, seen) } : {}
1033
+ };
1034
+ };
1035
+ var sanitizeProjectedDetails = (details, depth = 0) => ({
1036
+ ...typeof details.type === "string" ? { type: details.type.slice(0, 256) } : {},
1037
+ message: typeof details.message === "string" ? details.message.slice(0, 8192) : "Execution reported a fault.",
1038
+ ...typeof details.stack === "string" ? { stack: details.stack.slice(0, MAX_STACK_LENGTH) } : {},
1039
+ ...depth < MAX_CAUSE_DEPTH && details.cause ? { cause: sanitizeProjectedDetails(details.cause, depth + 1) } : {}
1040
+ });
1041
+ function exceptionDiagnostics(error, project) {
981
1042
  try {
982
- const name = (0, import_errors22.errorProperty)(error, "name") ?? (error instanceof Error ? error.name : void 0);
983
- const message = (0, import_errors22.errorProperty)(error, "message");
984
- const details = project ? project(error) : {
985
- type: typeof name === "string" ? name : "Error",
986
- message: typeof error === "string" ? error : typeof message === "string" ? message : "Execution reported a fault."
987
- };
988
- if (!details) return {};
989
- const projectedMessage = details.message;
990
- const projectedType = details.type;
991
- if (typeof projectedMessage !== "string") return {};
992
- return {
993
- errorMessage: projectedMessage.slice(0, 8192),
994
- ...typeof projectedType === "string" ? { errorType: projectedType.slice(0, 256) } : {}
995
- };
1043
+ const details = project ? project(error) : projectDetails(error, 0, /* @__PURE__ */ new WeakSet());
1044
+ return details ? sanitizeProjectedDetails(details) : null;
996
1045
  } catch {
997
- return {};
1046
+ return null;
998
1047
  }
999
1048
  }
1049
+ function errorDiagnostics(error, project) {
1050
+ const details = exceptionDiagnostics(error, project);
1051
+ return details ? {
1052
+ errorMessage: details.message,
1053
+ ...details.type ? { errorType: details.type } : {}
1054
+ } : {};
1055
+ }
1000
1056
  var import_node_crypto22 = require("crypto");
1001
1057
  function emitWorkflowCall2(telemetry, type, payload) {
1002
1058
  const base = telemetry?.correlation;
@@ -3802,6 +3858,12 @@ ${tryStringify2(args.response)}`
3802
3858
  });
3803
3859
  return promise;
3804
3860
  }
3861
+ function reportError(error, options = {}) {
3862
+ try {
3863
+ getReasonTraceAdapter()?.reportError?.(error, options);
3864
+ } catch {
3865
+ }
3866
+ }
3805
3867
  var import_node_crypto6 = require("crypto");
3806
3868
  var import_core8 = require("@kortyx/core");
3807
3869
  var import_errors8 = require("@kortyx/core/errors");