@link-assistant/hive-mind 1.21.2 → 1.21.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @link-assistant/hive-mind
2
2
 
3
+ ## 1.21.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 4426112: Fix error detection for `--tool agent` when JSON errors are pretty-printed (Issue #1258)
8
+ - Add fallback pattern matching for error events when NDJSON parsing fails
9
+ - Detect `"type": "error"` and `"type": "step_error"` patterns in raw output
10
+ - Detect critical error patterns like `AI_RetryError` and `UnhandledRejection`
11
+ - Extract error messages from output for better error reporting
12
+
3
13
  ## 1.21.2
4
14
 
5
15
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@link-assistant/hive-mind",
3
- "version": "1.21.2",
3
+ "version": "1.21.3",
4
4
  "description": "AI-powered issue solver and hive mind for collaborative problem solving",
5
5
  "main": "src/hive.mjs",
6
6
  "type": "module",
package/src/agent.lib.mjs CHANGED
@@ -703,6 +703,51 @@ export const executeAgentCommand = async params => {
703
703
  outputError.match = streamingErrorMessage;
704
704
  }
705
705
 
706
+ // Issue #1258: Fallback pattern match for error detection
707
+ // When JSON parsing fails (e.g., multi-line pretty-printed JSON in logs),
708
+ // we need to detect error patterns in the raw output string
709
+ if (!outputError.detected && !streamingErrorDetected) {
710
+ // Check for error type patterns in raw output (handles pretty-printed JSON)
711
+ const errorTypePatterns = [
712
+ { pattern: '"type": "error"', type: 'AgentError' },
713
+ { pattern: '"type":"error"', type: 'AgentError' },
714
+ { pattern: '"type": "step_error"', type: 'AgentStepError' },
715
+ { pattern: '"type":"step_error"', type: 'AgentStepError' },
716
+ ];
717
+
718
+ for (const { pattern, type } of errorTypePatterns) {
719
+ if (fullOutput.includes(pattern)) {
720
+ outputError.detected = true;
721
+ outputError.type = type;
722
+ // Try to extract the error message from the output
723
+ const messageMatch = fullOutput.match(/"message":\s*"([^"]+)"/);
724
+ outputError.match = messageMatch ? messageMatch[1] : `Error event detected in output (fallback pattern match for ${pattern})`;
725
+ await log(`⚠️ Error event detected via fallback pattern match: ${outputError.match}`, { level: 'warning' });
726
+ break;
727
+ }
728
+ }
729
+
730
+ // Also check for known critical error patterns that indicate failure
731
+ if (!outputError.detected) {
732
+ const criticalErrorPatterns = [
733
+ { pattern: 'AI_RetryError:', extract: /AI_RetryError:\s*(.+?)(?:\n|$)/ },
734
+ { pattern: 'UnhandledRejection', extract: /"errorType":\s*"UnhandledRejection"/ },
735
+ { pattern: 'Failed after 3 attempts', extract: /Failed after \d+ attempts[^"]*/ },
736
+ ];
737
+
738
+ for (const { pattern, extract } of criticalErrorPatterns) {
739
+ if (fullOutput.includes(pattern)) {
740
+ outputError.detected = true;
741
+ outputError.type = 'CriticalError';
742
+ const match = fullOutput.match(extract);
743
+ outputError.match = match ? match[0] : `Critical error pattern detected: ${pattern}`;
744
+ await log(`⚠️ Critical error pattern detected via fallback: ${outputError.match}`, { level: 'warning' });
745
+ break;
746
+ }
747
+ }
748
+ }
749
+ }
750
+
706
751
  if (exitCode !== 0 || outputError.detected) {
707
752
  // Build JSON error structure for consistent error reporting
708
753
  const errorInfo = {