@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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/scripts/demo.mjs +20 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botbotgo/better-call",
3
- "version": "0.1.43",
3
+ "version": "0.1.45",
4
4
  "description": "Small-model tool-call reliability layer for LangChain and custom agent runtimes.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
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 != null
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 = attemptedTicker.trim().toLowerCase();
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 === "apple" || normalizedTicker === ""
125
+ normalizedTicker === ""
118
126
  ? "AAPL"
119
- : normalizedTicker.toUpperCase();
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 gatewayRepair =
212
+ const gatewayRepairResult =
203
213
  gatewayResult != null && typeof gatewayResult === "object"
204
214
  ? gatewayResult
205
- : createGatewayErrorResult("research", "repairToolCall returned no result.");
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) {