@botbotgo/better-call 0.1.35 → 0.1.37

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 +18 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botbotgo/better-call",
3
- "version": "0.1.35",
3
+ "version": "0.1.37",
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
@@ -18,7 +18,7 @@ function errorDetails(error) {
18
18
 
19
19
  return {
20
20
  message: error.message,
21
- type: error.name || "Error",
21
+ type: error.name,
22
22
  cause: causeMessage,
23
23
  };
24
24
  }
@@ -56,7 +56,21 @@ const stockQuote = {
56
56
  additionalProperties: false,
57
57
  },
58
58
  async invoke(args) {
59
- return { quote: args };
59
+ if (typeof args !== "object" || args == null) {
60
+ throw new Error("Invalid stock quote arguments: expected an object.");
61
+ }
62
+
63
+ const { ticker, market } = args;
64
+
65
+ if (typeof ticker !== "string" || ticker.trim() === "") {
66
+ throw new Error("Invalid ticker: expected a non-empty string.");
67
+ }
68
+
69
+ if (!["US", "HK", "CN"].includes(market)) {
70
+ throw new Error("Invalid market: expected one of US, HK, CN.");
71
+ }
72
+
73
+ return { quote: { ticker: ticker.trim().toUpperCase(), market } };
60
74
  },
61
75
  };
62
76
 
@@ -144,7 +158,8 @@ try {
144
158
  };
145
159
  }
146
160
 
147
- const repairedCall = reliableResult?.calls?.[0] ?? null;
161
+ const repairedCalls = Array.isArray(reliableResult?.calls) ? reliableResult.calls : null;
162
+ const repairedCall = repairedCalls && repairedCalls.length > 0 ? repairedCalls[0] : null;
148
163
 
149
164
  const report = {
150
165
  wrappedTool: {