@botbotgo/better-call 0.1.43 → 0.1.45
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 +20 -7
package/package.json
CHANGED
package/scripts/demo.mjs
CHANGED
|
@@ -101,8 +101,14 @@ const stockQuote = {
|
|
|
101
101
|
const intentionallyMalformedArgs = { symbol: "Apple", market: "NASDAQ" };
|
|
102
102
|
|
|
103
103
|
function repairDemoStockCall(repairInput = {}) {
|
|
104
|
+
const hasUsableArgsShape = (value) =>
|
|
105
|
+
typeof value === "object" &&
|
|
106
|
+
value != null &&
|
|
107
|
+
!Array.isArray(value) &&
|
|
108
|
+
("ticker" in value || "symbol" in value || "market" in value);
|
|
109
|
+
|
|
104
110
|
const attemptedArgs =
|
|
105
|
-
Array.isArray(repairInput?.calls) && repairInput.calls[0]?.args
|
|
111
|
+
Array.isArray(repairInput?.calls) && hasUsableArgsShape(repairInput.calls[0]?.args)
|
|
106
112
|
? repairInput.calls[0].args
|
|
107
113
|
: intentionallyMalformedArgs;
|
|
108
114
|
|
|
@@ -112,11 +118,15 @@ function repairDemoStockCall(repairInput = {}) {
|
|
|
112
118
|
: typeof attemptedArgs.symbol === "string"
|
|
113
119
|
? attemptedArgs.symbol
|
|
114
120
|
: "AAPL";
|
|
115
|
-
const normalizedTicker =
|
|
121
|
+
const normalizedTicker =
|
|
122
|
+
typeof attemptedTicker === "string" ? attemptedTicker.trim().toLowerCase() : "aapl";
|
|
123
|
+
// This demo falls back to AAPL when no ticker-like value is available.
|
|
116
124
|
const ticker =
|
|
117
|
-
normalizedTicker === "
|
|
125
|
+
normalizedTicker === ""
|
|
118
126
|
? "AAPL"
|
|
119
|
-
: normalizedTicker
|
|
127
|
+
: normalizedTicker === "apple"
|
|
128
|
+
? "AAPL"
|
|
129
|
+
: normalizedTicker.toUpperCase();
|
|
120
130
|
|
|
121
131
|
const attemptedMarket = typeof attemptedArgs.market === "string" ? attemptedArgs.market : null;
|
|
122
132
|
const market =
|
|
@@ -199,10 +209,13 @@ try {
|
|
|
199
209
|
);
|
|
200
210
|
}
|
|
201
211
|
|
|
202
|
-
const
|
|
212
|
+
const gatewayRepairResult =
|
|
203
213
|
gatewayResult != null && typeof gatewayResult === "object"
|
|
204
214
|
? gatewayResult
|
|
205
|
-
: createGatewayErrorResult(
|
|
215
|
+
: createGatewayErrorResult(
|
|
216
|
+
"research",
|
|
217
|
+
"repairToolCall returned an invalid result (expected object)."
|
|
218
|
+
);
|
|
206
219
|
|
|
207
220
|
// Missing or empty calls are expected in some demo/error paths; normalize to null for reporting.
|
|
208
221
|
// This demo reports only the first repaired call so the summary stays compact and stable.
|
|
@@ -222,7 +235,7 @@ const report = {
|
|
|
222
235
|
repaired: repairedCall,
|
|
223
236
|
diagnostics: reliableResult?.diagnostics ?? null,
|
|
224
237
|
},
|
|
225
|
-
gatewayRepair,
|
|
238
|
+
gatewayRepair: gatewayRepairResult,
|
|
226
239
|
};
|
|
227
240
|
|
|
228
241
|
if (json) {
|