@prestyj/agent 5.16.2 → 5.19.0

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/dist/index.js CHANGED
@@ -105,6 +105,17 @@ function isAbortError(err) {
105
105
  const msg = err.message.toLowerCase();
106
106
  return msg.includes("aborted") || msg.includes("abort");
107
107
  }
108
+ function stripNullArguments(value) {
109
+ if (Array.isArray(value)) return value.map(stripNullArguments);
110
+ if (value !== null && typeof value === "object") {
111
+ const out = {};
112
+ for (const [key, entry] of Object.entries(value)) {
113
+ if (entry !== null) out[key] = stripNullArguments(entry);
114
+ }
115
+ return out;
116
+ }
117
+ return value;
118
+ }
108
119
  function isContextOverflow(err) {
109
120
  if (!(err instanceof Error)) return false;
110
121
  const overflowStatus = err.statusCode;
@@ -1313,7 +1324,17 @@ async function executeSingleToolCall(toolCall, options, pushEvent) {
1313
1324
  isError = true;
1314
1325
  } else {
1315
1326
  try {
1316
- const parsed = tool.parameters.parse(toolCall.args);
1327
+ let parsed;
1328
+ try {
1329
+ parsed = tool.parameters.parse(toolCall.args);
1330
+ } catch (originalError) {
1331
+ if (tool.rawInputSchema) throw originalError;
1332
+ try {
1333
+ parsed = tool.parameters.parse(stripNullArguments(toolCall.args));
1334
+ } catch {
1335
+ throw originalError;
1336
+ }
1337
+ }
1317
1338
  const callerSignal = options.signal;
1318
1339
  const toolTimeout = AbortSignal.timeout(tool.timeoutMs ?? DEFAULT_TOOL_TIMEOUT_MS);
1319
1340
  const ctx = {