@botbotgo/better-call 0.1.37 → 0.1.39

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 +28 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botbotgo/better-call",
3
- "version": "0.1.37",
3
+ "version": "0.1.39",
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
@@ -30,6 +30,15 @@ function errorDetails(error) {
30
30
  };
31
31
  }
32
32
 
33
+ function displayValue(value) {
34
+ if (typeof value === "string") {
35
+ const trimmed = value.trim();
36
+ return trimmed === "" ? "(none)" : trimmed;
37
+ }
38
+
39
+ return value == null ? "(none)" : String(value);
40
+ }
41
+
33
42
  function exitWithError(step, error) {
34
43
  const message = errorMessage(error);
35
44
 
@@ -158,6 +167,19 @@ try {
158
167
  };
159
168
  }
160
169
 
170
+ const gatewayRepair =
171
+ gatewayResult != null && typeof gatewayResult === "object"
172
+ ? gatewayResult
173
+ : {
174
+ status: "error",
175
+ originalToolName: "research",
176
+ toolName: null,
177
+ reason: "repairToolCall returned no result.",
178
+ errorType: null,
179
+ errorMessage: null,
180
+ errorCause: null,
181
+ };
182
+
161
183
  const repairedCalls = Array.isArray(reliableResult?.calls) ? reliableResult.calls : null;
162
184
  const repairedCall = repairedCalls && repairedCalls.length > 0 ? repairedCalls[0] : null;
163
185
 
@@ -171,7 +193,7 @@ const report = {
171
193
  repaired: repairedCall,
172
194
  diagnostics: reliableResult?.diagnostics ?? null,
173
195
  },
174
- gatewayRepair: gatewayResult,
196
+ gatewayRepair,
175
197
  };
176
198
 
177
199
  if (json) {
@@ -188,9 +210,11 @@ if (json) {
188
210
  console.log(` after: ${JSON.stringify(report.reliableToolCalls.repaired)}`);
189
211
  console.log("");
190
212
  console.log("3. Gateway tool-name repair");
191
- console.log(` status: ${report.gatewayRepair.status}`);
192
- console.log(` tool: ${report.gatewayRepair.originalToolName} -> ${report.gatewayRepair.toolName ?? "(none)"}`);
193
- console.log(` reason: ${report.gatewayRepair.reason ?? "(none)"}`);
213
+ console.log(` status: ${displayValue(report.gatewayRepair.status)}`);
214
+ console.log(
215
+ ` tool: ${displayValue(report.gatewayRepair.originalToolName)} -> ${displayValue(report.gatewayRepair.toolName)}`
216
+ );
217
+ console.log(` reason: ${displayValue(report.gatewayRepair.reason)}`);
194
218
  console.log("");
195
219
  console.log("Run with --json for the full structured result.");
196
220
  }