@botbotgo/better-call 0.1.36 → 0.1.38
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 +31 -3
package/package.json
CHANGED
package/scripts/demo.mjs
CHANGED
|
@@ -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,21 @@ try {
|
|
|
144
158
|
};
|
|
145
159
|
}
|
|
146
160
|
|
|
147
|
-
const
|
|
161
|
+
const gatewayRepair =
|
|
162
|
+
gatewayResult != null && typeof gatewayResult === "object"
|
|
163
|
+
? gatewayResult
|
|
164
|
+
: {
|
|
165
|
+
status: "error",
|
|
166
|
+
originalToolName: "research",
|
|
167
|
+
toolName: null,
|
|
168
|
+
reason: "repairToolCall returned no result.",
|
|
169
|
+
errorType: null,
|
|
170
|
+
errorMessage: null,
|
|
171
|
+
errorCause: null,
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
const repairedCalls = Array.isArray(reliableResult?.calls) ? reliableResult.calls : null;
|
|
175
|
+
const repairedCall = repairedCalls && repairedCalls.length > 0 ? repairedCalls[0] : null;
|
|
148
176
|
|
|
149
177
|
const report = {
|
|
150
178
|
wrappedTool: {
|
|
@@ -156,7 +184,7 @@ const report = {
|
|
|
156
184
|
repaired: repairedCall,
|
|
157
185
|
diagnostics: reliableResult?.diagnostics ?? null,
|
|
158
186
|
},
|
|
159
|
-
gatewayRepair
|
|
187
|
+
gatewayRepair,
|
|
160
188
|
};
|
|
161
189
|
|
|
162
190
|
if (json) {
|