@danhachuel/thunderbolt 0.5.17 → 0.5.18

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.
@@ -71,19 +71,29 @@ def _first_id(value: Any, keys: tuple[str, ...]) -> str:
71
71
  return ""
72
72
 
73
73
 
74
- def _first_text_element(value: Any) -> str:
74
+ def _first_text_element(value: Any, *, text_context: bool = False) -> str:
75
75
  if isinstance(value, Mapping):
76
- for key in ("element_id", "id"):
76
+ # The MCP returns rich text elements with slightly different ID
77
+ # names depending on the design type/version of the server.
78
+ text_markers = ("text", "richtext", "rich_text", "content", "paragraph")
79
+ mapping_text = str(value).lower()
80
+ is_text_mapping = text_context or any(
81
+ marker in str(key).lower() or marker in mapping_text
82
+ for key in value
83
+ for marker in text_markers
84
+ )
85
+ for key in ("element_id", "elementId", "richtext_id", "richTextId", "text_id", "textId", "id"):
77
86
  candidate = str(value.get(key) or "").strip()
78
- if candidate and any(token in str(value).lower() for token in ("text", "richtext", "content")):
87
+ if candidate and is_text_mapping:
79
88
  return candidate
80
- for child in value.values():
81
- found = _first_text_element(child)
89
+ for key, child in value.items():
90
+ child_context = text_context or any(marker in str(key).lower() for marker in text_markers)
91
+ found = _first_text_element(child, text_context=child_context)
82
92
  if found:
83
93
  return found
84
94
  elif isinstance(value, list):
85
95
  for child in value:
86
- found = _first_text_element(child)
96
+ found = _first_text_element(child, text_context=text_context)
87
97
  if found:
88
98
  return found
89
99
  return ""
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danhachuel/thunderbolt",
3
- "version": "0.5.17",
3
+ "version": "0.5.18",
4
4
  "description": "Thunderbolt — interface local para operação de canais faceless e motor MoneyPrinterTurbo",
5
5
  "license": "MIT",
6
6
  "main": "scripts/cli.mjs",