@kenkaiiii/gg-agent 5.57.0 → 5.57.2

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;
@@ -1252,7 +1263,17 @@ async function executeSingleToolCall(toolCall, options, pushEvent) {
1252
1263
  isError = true;
1253
1264
  } else {
1254
1265
  try {
1255
- const parsed = tool.parameters.parse(toolCall.args);
1266
+ let parsed;
1267
+ try {
1268
+ parsed = tool.parameters.parse(toolCall.args);
1269
+ } catch (originalError) {
1270
+ if (tool.rawInputSchema) throw originalError;
1271
+ try {
1272
+ parsed = tool.parameters.parse(stripNullArguments(toolCall.args));
1273
+ } catch {
1274
+ throw originalError;
1275
+ }
1276
+ }
1256
1277
  const callerSignal = options.signal;
1257
1278
  const toolTimeout = AbortSignal.timeout(tool.timeoutMs ?? DEFAULT_TOOL_TIMEOUT_MS);
1258
1279
  const ctx = {