@prestyj/agent 5.16.1 → 5.17.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.cjs CHANGED
@@ -133,6 +133,17 @@ function isAbortError(err) {
133
133
  const msg = err.message.toLowerCase();
134
134
  return msg.includes("aborted") || msg.includes("abort");
135
135
  }
136
+ function stripNullArguments(value) {
137
+ if (Array.isArray(value)) return value.map(stripNullArguments);
138
+ if (value !== null && typeof value === "object") {
139
+ const out = {};
140
+ for (const [key, entry] of Object.entries(value)) {
141
+ if (entry !== null) out[key] = stripNullArguments(entry);
142
+ }
143
+ return out;
144
+ }
145
+ return value;
146
+ }
136
147
  function isContextOverflow(err) {
137
148
  if (!(err instanceof Error)) return false;
138
149
  const overflowStatus = err.statusCode;
@@ -1341,7 +1352,17 @@ async function executeSingleToolCall(toolCall, options, pushEvent) {
1341
1352
  isError = true;
1342
1353
  } else {
1343
1354
  try {
1344
- const parsed = tool.parameters.parse(toolCall.args);
1355
+ let parsed;
1356
+ try {
1357
+ parsed = tool.parameters.parse(toolCall.args);
1358
+ } catch (originalError) {
1359
+ if (tool.rawInputSchema) throw originalError;
1360
+ try {
1361
+ parsed = tool.parameters.parse(stripNullArguments(toolCall.args));
1362
+ } catch {
1363
+ throw originalError;
1364
+ }
1365
+ }
1345
1366
  const callerSignal = options.signal;
1346
1367
  const toolTimeout = AbortSignal.timeout(tool.timeoutMs ?? DEFAULT_TOOL_TIMEOUT_MS);
1347
1368
  const ctx = {