@wrongstack/core 0.8.4 → 0.8.5

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.
@@ -2225,7 +2225,7 @@ var ToolExecutor = class {
2225
2225
  return { result, tool, durationMs: Date.now() - start };
2226
2226
  }
2227
2227
  if (hasMalformedArguments(use.input)) {
2228
- const result = this.malformedInputResult(use);
2228
+ const result = this.malformedInputResult(use, extractMalformedRaw(use.input));
2229
2229
  budget = this.decrementBudget(result, budget);
2230
2230
  return { result, tool, durationMs: Date.now() - start };
2231
2231
  }
@@ -2432,11 +2432,18 @@ var ToolExecutor = class {
2432
2432
  is_error: true
2433
2433
  };
2434
2434
  }
2435
- malformedInputResult(use) {
2435
+ malformedInputResult(use, raw) {
2436
+ let content = `Tool "${use.name}" received arguments that were not a valid JSON object, so they could not be parsed. Re-issue the call with the arguments encoded as a single well-formed JSON object matching the tool's input schema.`;
2437
+ if (raw) {
2438
+ const max = 800;
2439
+ const excerpt = raw.length > max ? `${raw.slice(0, max)}\u2026 (truncated, ${raw.length} chars total)` : raw;
2440
+ content += ` Common cause: a string field (e.g. code in old_string/new_string) contains literal newlines, quotes, or backslashes that must be JSON-escaped, or the payload was cut off mid-stream. The raw arguments received were:
2441
+ ${excerpt}`;
2442
+ }
2436
2443
  return {
2437
2444
  type: "tool_result",
2438
2445
  tool_use_id: use.id,
2439
- content: `Tool "${use.name}" received arguments that were not a valid JSON object, so they could not be parsed. Re-issue the call with the arguments encoded as a single well-formed JSON object matching the tool's input schema.`,
2446
+ content,
2440
2447
  is_error: true
2441
2448
  };
2442
2449
  }
@@ -2492,6 +2499,18 @@ function hasMalformedArguments(input) {
2492
2499
  const keys = Object.keys(obj);
2493
2500
  return keys.length === 1 && MALFORMED_ARG_MARKERS.includes(keys[0]);
2494
2501
  }
2502
+ function extractMalformedRaw(input) {
2503
+ if (!hasMalformedArguments(input)) return void 0;
2504
+ const obj = input;
2505
+ const value = obj[Object.keys(obj)[0]];
2506
+ if (value === void 0 || value === null) return void 0;
2507
+ if (typeof value === "string") return value;
2508
+ try {
2509
+ return JSON.stringify(value);
2510
+ } catch {
2511
+ return String(value);
2512
+ }
2513
+ }
2495
2514
 
2496
2515
  // src/utils/regex-guard.ts
2497
2516
  var MAX_PATTERN_LEN = 512;