@botbotgo/better-call 0.1.33 → 0.1.35
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/package.json +1 -1
- package/scripts/demo.mjs +35 -4
package/package.json
CHANGED
package/scripts/demo.mjs
CHANGED
|
@@ -7,6 +7,29 @@ function errorMessage(error) {
|
|
|
7
7
|
return error instanceof Error ? error.message : String(error);
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
function errorDetails(error) {
|
|
11
|
+
if (error instanceof Error) {
|
|
12
|
+
const causeMessage =
|
|
13
|
+
error.cause instanceof Error
|
|
14
|
+
? error.cause.message
|
|
15
|
+
: error.cause != null
|
|
16
|
+
? String(error.cause)
|
|
17
|
+
: null;
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
message: error.message,
|
|
21
|
+
type: error.name || "Error",
|
|
22
|
+
cause: causeMessage,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
message: String(error),
|
|
28
|
+
type: typeof error,
|
|
29
|
+
cause: null,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
10
33
|
function exitWithError(step, error) {
|
|
11
34
|
const message = errorMessage(error);
|
|
12
35
|
|
|
@@ -61,7 +84,11 @@ let wrappedOutput;
|
|
|
61
84
|
try {
|
|
62
85
|
wrappedOutput = await wrappedStockQuote.invoke(malformedRepairArgs);
|
|
63
86
|
} catch (error) {
|
|
64
|
-
|
|
87
|
+
const context = `tool=stock_quote args=${JSON.stringify(malformedRepairArgs)}`;
|
|
88
|
+
const message = `${errorMessage(error)} (${context})`;
|
|
89
|
+
const contextualError =
|
|
90
|
+
error instanceof Error ? new Error(message, { cause: error }) : new Error(message);
|
|
91
|
+
exitWithError("wrapped stock_quote invocation", contextualError);
|
|
65
92
|
}
|
|
66
93
|
|
|
67
94
|
let reliableResult = null;
|
|
@@ -105,11 +132,15 @@ try {
|
|
|
105
132
|
},
|
|
106
133
|
});
|
|
107
134
|
} catch (error) {
|
|
135
|
+
const details = errorDetails(error);
|
|
108
136
|
gatewayResult = {
|
|
109
137
|
status: "error",
|
|
110
138
|
originalToolName: "research",
|
|
111
139
|
toolName: null,
|
|
112
|
-
reason: `repairToolCall failed: ${
|
|
140
|
+
reason: `repairToolCall failed: ${details.message}`,
|
|
141
|
+
errorType: details.type,
|
|
142
|
+
errorMessage: details.message,
|
|
143
|
+
errorCause: details.cause,
|
|
113
144
|
};
|
|
114
145
|
}
|
|
115
146
|
|
|
@@ -143,8 +174,8 @@ if (json) {
|
|
|
143
174
|
console.log("");
|
|
144
175
|
console.log("3. Gateway tool-name repair");
|
|
145
176
|
console.log(` status: ${report.gatewayRepair.status}`);
|
|
146
|
-
console.log(` tool: ${report.gatewayRepair.originalToolName} -> ${report.gatewayRepair.toolName}`);
|
|
147
|
-
console.log(` reason: ${report.gatewayRepair.reason}`);
|
|
177
|
+
console.log(` tool: ${report.gatewayRepair.originalToolName} -> ${report.gatewayRepair.toolName ?? "(none)"}`);
|
|
178
|
+
console.log(` reason: ${report.gatewayRepair.reason ?? "(none)"}`);
|
|
148
179
|
console.log("");
|
|
149
180
|
console.log("Run with --json for the full structured result.");
|
|
150
181
|
}
|