agentle 0.9.32__py3-none-any.whl → 0.9.34__py3-none-any.whl

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.
@@ -2041,7 +2041,7 @@ class WhatsAppBot[T_Schema: WhatsAppResponseBase = WhatsAppResponseBase](BaseMod
2041
2041
  This method converts:
2042
2042
  - Headers (# ## ###) to bold text with separators
2043
2043
  - Tables to formatted text
2044
- - Markdown lists to plain text lists
2044
+ - Markdown lists to plain text lists (preserving line breaks)
2045
2045
  - Links to "text (url)" format
2046
2046
  - Images to descriptive text
2047
2047
  - Blockquotes to indented text
@@ -2111,7 +2111,7 @@ class WhatsAppBot[T_Schema: WhatsAppResponseBase = WhatsAppResponseBase](BaseMod
2111
2111
  i += 1
2112
2112
  continue
2113
2113
 
2114
- # Process regular line
2114
+ # Process regular line (preserve empty lines for spacing)
2115
2115
  processed_lines.append(line)
2116
2116
  i += 1
2117
2117
 
@@ -2119,7 +2119,7 @@ class WhatsAppBot[T_Schema: WhatsAppResponseBase = WhatsAppResponseBase](BaseMod
2119
2119
  if table_lines:
2120
2120
  processed_lines.extend(self._format_table(table_lines))
2121
2121
 
2122
- # Rejoin lines
2122
+ # Rejoin lines - CRITICAL: preserve all line breaks
2123
2123
  text = "\n".join(processed_lines)
2124
2124
 
2125
2125
  # Handle inline markdown elements
@@ -2698,22 +2698,32 @@ class WhatsAppBot[T_Schema: WhatsAppResponseBase = WhatsAppResponseBase](BaseMod
2698
2698
 
2699
2699
  if is_list_paragraph:
2700
2700
  # Group list items together instead of splitting each line
2701
+ # IMPORTANT: Keep line breaks intact for list formatting
2701
2702
  grouped_list = self._group_list_items(lines)
2702
2703
  messages.extend(grouped_list)
2703
2704
  else:
2704
- # For non-list paragraphs, split by lines as before
2705
- for line in lines:
2706
- line = line.strip()
2707
- if not line:
2708
- continue
2709
-
2710
- # Check if this line fits within message length limits
2711
- if len(line) <= self.config.max_message_length:
2712
- messages.append(line)
2713
- else:
2714
- # Split long lines by length
2715
- split_lines = self._split_long_line(line)
2716
- messages.extend(split_lines)
2705
+ # For non-list paragraphs, keep the whole paragraph together if possible
2706
+ paragraph_text = paragraph.strip()
2707
+ if not paragraph_text:
2708
+ continue
2709
+
2710
+ # Check if paragraph fits within message length limits
2711
+ if len(paragraph_text) <= self.config.max_message_length:
2712
+ messages.append(paragraph_text)
2713
+ else:
2714
+ # Split by individual lines only if paragraph is too long
2715
+ for line in lines:
2716
+ line = line.strip()
2717
+ if not line:
2718
+ continue
2719
+
2720
+ # Check if this line fits within message length limits
2721
+ if len(line) <= self.config.max_message_length:
2722
+ messages.append(line)
2723
+ else:
2724
+ # Split long lines by length
2725
+ split_lines = self._split_long_line(line)
2726
+ messages.extend(split_lines)
2717
2727
 
2718
2728
  # Filter out empty messages and validate
2719
2729
  final_messages = []
@@ -2725,9 +2735,11 @@ class WhatsAppBot[T_Schema: WhatsAppResponseBase = WhatsAppResponseBase](BaseMod
2725
2735
  for i in range(0, len(msg), 65536):
2726
2736
  chunk = msg[i : i + 65536]
2727
2737
  if chunk.strip():
2728
- final_messages.append(chunk.strip())
2738
+ # Don't strip - preserve line breaks
2739
+ final_messages.append(chunk)
2729
2740
  else:
2730
- final_messages.append(msg.strip())
2741
+ # Don't strip - preserve line breaks within the message
2742
+ final_messages.append(msg)
2731
2743
 
2732
2744
  # If no valid messages were created, return a placeholder
2733
2745
  if not final_messages:
@@ -2826,7 +2838,13 @@ class WhatsAppBot[T_Schema: WhatsAppResponseBase = WhatsAppResponseBase](BaseMod
2826
2838
  return chunks
2827
2839
 
2828
2840
  def _is_list_content(self, lines: Sequence[str]) -> bool:
2829
- """Check if lines contain list markers (numbered or bullet points)."""
2841
+ """Check if lines contain list markers (numbered or bullet points).
2842
+
2843
+ Detects various list formats including:
2844
+ - Numbered lists: "1.", "2)", "1 -"
2845
+ - Bullet points: "•", "*", "-", "→"
2846
+ - Indented sub-items
2847
+ """
2830
2848
  if not lines:
2831
2849
  return False
2832
2850
 
@@ -2844,13 +2862,20 @@ class WhatsAppBot[T_Schema: WhatsAppResponseBase = WhatsAppResponseBase](BaseMod
2844
2862
  # Check for bullet points: "•", "*", "-", "→", etc.
2845
2863
  elif re.match(r"^[•\*\-→▪►]\s", stripped):
2846
2864
  list_markers += 1
2865
+ # Check for indented items (common in nested lists)
2866
+ elif re.match(r"^\s+[•\*\-→▪►]\s", line):
2867
+ list_markers += 1
2847
2868
 
2848
- # If more than 50% of non-empty lines are list items, consider it a list
2869
+ # If more than 30% of non-empty lines are list items, consider it a list
2870
+ # Lowered threshold to catch lists with headers/descriptions
2849
2871
  non_empty_lines = sum(1 for line in lines if line.strip())
2850
- return non_empty_lines > 0 and (list_markers / non_empty_lines) >= 0.5
2872
+ return non_empty_lines > 0 and (list_markers / non_empty_lines) >= 0.3
2851
2873
 
2852
2874
  def _group_list_items(self, lines: Sequence[str]) -> Sequence[str]:
2853
- """Group list items together to avoid splitting each item into a separate message."""
2875
+ """Group list items together to avoid splitting each item into a separate message.
2876
+
2877
+ CRITICAL: Preserves line breaks between list items for proper WhatsApp formatting.
2878
+ """
2854
2879
  if not lines:
2855
2880
  return []
2856
2881
 
@@ -2859,8 +2884,15 @@ class WhatsAppBot[T_Schema: WhatsAppResponseBase = WhatsAppResponseBase](BaseMod
2859
2884
  current_length = 0
2860
2885
 
2861
2886
  for line in lines:
2862
- line = line.strip()
2887
+ # Don't strip the line completely - preserve leading spaces for indentation
2888
+ # But remove trailing whitespace
2889
+ line = line.rstrip()
2890
+
2891
+ # Skip completely empty lines but preserve them in the group for spacing
2863
2892
  if not line:
2893
+ # Add empty line to group for spacing between items
2894
+ if current_group:
2895
+ current_group.append("")
2864
2896
  continue
2865
2897
 
2866
2898
  # Calculate potential length if we add this line
@@ -2870,6 +2902,7 @@ class WhatsAppBot[T_Schema: WhatsAppResponseBase = WhatsAppResponseBase](BaseMod
2870
2902
 
2871
2903
  # If adding this line would exceed the limit, save current group and start new one
2872
2904
  if potential_length > self.config.max_message_length and current_group:
2905
+ # Join with newlines to preserve line breaks
2873
2906
  messages.append("\n".join(current_group))
2874
2907
  current_group = [line]
2875
2908
  current_length = len(line)
@@ -2879,6 +2912,7 @@ class WhatsAppBot[T_Schema: WhatsAppResponseBase = WhatsAppResponseBase](BaseMod
2879
2912
 
2880
2913
  # Add remaining group
2881
2914
  if current_group:
2915
+ # Join with newlines to preserve line breaks
2882
2916
  messages.append("\n".join(current_group))
2883
2917
 
2884
2918
  return messages
@@ -3369,7 +3403,7 @@ class WhatsAppBot[T_Schema: WhatsAppResponseBase = WhatsAppResponseBase](BaseMod
3369
3403
 
3370
3404
  message = self._parse_evolution_message_from_data(
3371
3405
  data,
3372
- from_number=payload.data.key.remoteJidAlt
3406
+ from_number=payload.data.key.remoteJidAlt or ""
3373
3407
  if "@lid" in payload.data.key.remoteJid
3374
3408
  else payload.data.key.remoteJid,
3375
3409
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agentle
3
- Version: 0.9.32
3
+ Version: 0.9.34
4
4
  Summary: ...
5
5
  Author-email: Arthur Brenno <64020210+arthurbrenno@users.noreply.github.com>
6
6
  License-File: LICENSE
@@ -137,7 +137,7 @@ agentle/agents/ui/__init__.py,sha256=IjHRV0k2DNwvFrEHebmsXiBvmITE8nQUnsR07h9tVkU
137
137
  agentle/agents/ui/streamlit.py,sha256=9afICL0cxtG1o2pWh6vH39-NdKiVfADKiXo405F2aB0,42829
138
138
  agentle/agents/whatsapp/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
139
139
  agentle/agents/whatsapp/human_delay_calculator.py,sha256=BGCDeoNTPsMn4d_QYmG0BWGCG8SiUJC6Fk295ulAsAk,18268
140
- agentle/agents/whatsapp/whatsapp_bot.py,sha256=8AkP6VncI04s0KEpJ_ykkZsHUoUpF1PYxXyLRWA8EW4,161954
140
+ agentle/agents/whatsapp/whatsapp_bot.py,sha256=RH4WDpaqD4yTazKkjyYYPlhb-3BA-sX8h4pWZWHWznU,163775
141
141
  agentle/agents/whatsapp/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
142
142
  agentle/agents/whatsapp/models/audio_message.py,sha256=kUqG1HdNW6DCYD-CqscJ6WHlAyv9ufmTSKMdjio9XWk,2705
143
143
  agentle/agents/whatsapp/models/context_info.py,sha256=sk80KuNE36S6VRnLh7n6UXmzZCXIB4E4lNxnRyVizg8,563
@@ -1018,7 +1018,7 @@ agentle/web/actions/scroll.py,sha256=WqVVAORNDK3BL1oASZBPmXJYeSVkPgAOmWA8ibYO82I
1018
1018
  agentle/web/actions/viewport.py,sha256=KCwm88Pri19Qc6GLHC69HsRxmdJz1gEEAODfggC_fHo,287
1019
1019
  agentle/web/actions/wait.py,sha256=IKEywjf-KC4ni9Gkkv4wgc7bY-hk7HwD4F-OFWlyf2w,571
1020
1020
  agentle/web/actions/write_text.py,sha256=9mxfHcpKs_L7BsDnJvOYHQwG8M0GWe61SRJAsKk3xQ8,748
1021
- agentle-0.9.32.dist-info/METADATA,sha256=3GykoKo9T5d89Mxuf7E-HD6yxWHDsiaIIxa41Z51Ua0,86849
1022
- agentle-0.9.32.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
1023
- agentle-0.9.32.dist-info/licenses/LICENSE,sha256=T90S9vqRS6qP-voULxAcvwEs558wRRo6dHuZrjgcOUI,1085
1024
- agentle-0.9.32.dist-info/RECORD,,
1021
+ agentle-0.9.34.dist-info/METADATA,sha256=RGHCMaogcrdNvsf-g95zBnU_RdGssPcmfltQ4440Q9I,86849
1022
+ agentle-0.9.34.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
1023
+ agentle-0.9.34.dist-info/licenses/LICENSE,sha256=T90S9vqRS6qP-voULxAcvwEs558wRRo6dHuZrjgcOUI,1085
1024
+ agentle-0.9.34.dist-info/RECORD,,