@botbotgo/better-call 0.1.48 → 0.1.49

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 +16 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botbotgo/better-call",
3
- "version": "0.1.48",
3
+ "version": "0.1.49",
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
@@ -3,6 +3,8 @@ import { betterTools, repairToolCall, reliableToolCalls } from "../dist/index.js
3
3
 
4
4
  const json = process.argv.includes("--json");
5
5
  const VALID_MARKETS = ["US", "HK", "CN"];
6
+ // Intentionally incorrect tool name used to demonstrate tool-call repair behavior.
7
+ const DEMO_INVALID_TOOL_NAME = "stock_price";
6
8
 
7
9
  function errorMessage(error) {
8
10
  return error instanceof Error ? error.message : String(error);
@@ -132,20 +134,24 @@ function repairDemoStockCall(repairInput = {}) {
132
134
  ? repairInput.calls[0].args
133
135
  : createDemoMalformedInput();
134
136
 
135
- const attemptedTicker =
137
+ const rawAttemptedTicker =
136
138
  typeof attemptedArgs.ticker === "string"
137
139
  ? attemptedArgs.ticker
138
140
  : typeof attemptedArgs.symbol === "string"
139
141
  ? attemptedArgs.symbol
140
142
  : "AAPL";
143
+ const attemptedTicker =
144
+ typeof rawAttemptedTicker === "string" ? rawAttemptedTicker : "AAPL";
141
145
  const normalizedTicker = attemptedTicker.trim().toLowerCase();
142
146
  // This demo maps empty input and the "apple" alias to AAPL.
143
- const ticker =
144
- normalizedTicker === ""
145
- ? "AAPL"
146
- : normalizedTicker === "apple"
147
- ? "AAPL"
148
- : normalizedTicker.toUpperCase();
147
+ let ticker;
148
+ if (normalizedTicker === "") {
149
+ ticker = "AAPL";
150
+ } else if (normalizedTicker === "apple") {
151
+ ticker = "AAPL";
152
+ } else {
153
+ ticker = normalizedTicker.toUpperCase();
154
+ }
149
155
 
150
156
  const attemptedMarket = typeof attemptedArgs.market === "string" ? attemptedArgs.market : null;
151
157
  const market =
@@ -197,9 +203,9 @@ try {
197
203
  userInput: "Get Apple stock in the US market.",
198
204
  tools: [stockQuote],
199
205
  // Both the tool name and args are intentionally wrong to demonstrate repair:
200
- // "stock_price" should be "stock_quote"; demoMalformedInput uses
206
+ // DEMO_INVALID_TOOL_NAME should be "stock_quote"; demoMalformedInput uses
201
207
  // "symbol"/"NASDAQ" instead of schema-valid stock_quote args.
202
- calls: [{ tool: "stock_price", args: demoMalformedInput }],
208
+ calls: [{ tool: DEMO_INVALID_TOOL_NAME, args: demoMalformedInput }],
203
209
  repair: repairDemoStockCall,
204
210
  });
205
211
  } catch (error) {
@@ -260,7 +266,7 @@ const report = {
260
266
  after: wrappedOutput,
261
267
  },
262
268
  reliableToolCalls: {
263
- before: { tool: "stock_price", args: demoMalformedInput },
269
+ before: { tool: DEMO_INVALID_TOOL_NAME, args: demoMalformedInput },
264
270
  repaired: repairedCall,
265
271
  // Optional validation/repair metadata; null means this run returned none.
266
272
  diagnostics: reliableResult?.diagnostics ?? null,