@botbotgo/better-call 0.1.39 → 0.1.40

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 +4 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botbotgo/better-call",
3
- "version": "0.1.39",
3
+ "version": "0.1.40",
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
@@ -2,6 +2,7 @@
2
2
  import { betterTools, repairToolCall, reliableToolCalls } from "../dist/index.js";
3
3
 
4
4
  const json = process.argv.includes("--json");
5
+ const VALID_MARKETS = ["US", "HK", "CN"];
5
6
 
6
7
  function errorMessage(error) {
7
8
  return error instanceof Error ? error.message : String(error);
@@ -59,7 +60,7 @@ const stockQuote = {
59
60
  type: "object",
60
61
  properties: {
61
62
  ticker: { type: "string" },
62
- market: { type: "string", enum: ["US", "HK", "CN"] },
63
+ market: { type: "string", enum: VALID_MARKETS },
63
64
  },
64
65
  required: ["ticker", "market"],
65
66
  additionalProperties: false,
@@ -75,7 +76,7 @@ const stockQuote = {
75
76
  throw new Error("Invalid ticker: expected a non-empty string.");
76
77
  }
77
78
 
78
- if (!["US", "HK", "CN"].includes(market)) {
79
+ if (!VALID_MARKETS.includes(market)) {
79
80
  throw new Error("Invalid market: expected one of US, HK, CN.");
80
81
  }
81
82
 
@@ -180,8 +181,7 @@ const gatewayRepair =
180
181
  errorCause: null,
181
182
  };
182
183
 
183
- const repairedCalls = Array.isArray(reliableResult?.calls) ? reliableResult.calls : null;
184
- const repairedCall = repairedCalls && repairedCalls.length > 0 ? repairedCalls[0] : null;
184
+ const repairedCall = reliableResult?.calls?.[0] ?? null;
185
185
 
186
186
  const report = {
187
187
  wrappedTool: {