@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.
- package/package.json +1 -1
- package/scripts/demo.mjs +18 -3
package/package.json
CHANGED
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
|
|
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
|
-
|
|
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
|
|
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: {
|