@danhachuel/thunderbolt 0.5.22 → 0.5.24
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.
|
@@ -101,6 +101,30 @@ def _first_id(value: Any, keys: tuple[str, ...]) -> str:
|
|
|
101
101
|
return ""
|
|
102
102
|
|
|
103
103
|
|
|
104
|
+
def _download_url(value: Any) -> str:
|
|
105
|
+
if isinstance(value, Mapping):
|
|
106
|
+
for key in ("url", "download_url", "downloadUrl"):
|
|
107
|
+
candidate = str(value.get(key) or "").strip()
|
|
108
|
+
if candidate.startswith(("http://", "https://")):
|
|
109
|
+
return candidate
|
|
110
|
+
urls = value.get("urls")
|
|
111
|
+
if isinstance(urls, list):
|
|
112
|
+
for url in urls:
|
|
113
|
+
candidate = str(url or "").strip()
|
|
114
|
+
if candidate.startswith(("http://", "https://")):
|
|
115
|
+
return candidate
|
|
116
|
+
for child in value.values():
|
|
117
|
+
found = _download_url(child)
|
|
118
|
+
if found:
|
|
119
|
+
return found
|
|
120
|
+
elif isinstance(value, list):
|
|
121
|
+
for child in value:
|
|
122
|
+
found = _download_url(child)
|
|
123
|
+
if found:
|
|
124
|
+
return found
|
|
125
|
+
return ""
|
|
126
|
+
|
|
127
|
+
|
|
104
128
|
def _first_text_element(value: Any, *, text_context: bool = False) -> str:
|
|
105
129
|
if isinstance(value, Mapping):
|
|
106
130
|
# The MCP returns rich text elements with slightly different ID
|
|
@@ -176,11 +200,11 @@ def run_direct_canva_thumbnail(
|
|
|
176
200
|
"user_intent": "Find an existing Canva design to edit as a Thunderbolt thumbnail.",
|
|
177
201
|
}))
|
|
178
202
|
candidates = _items(result)
|
|
179
|
-
if not candidates:
|
|
180
|
-
raise CanvaMCPError("Canva não encontrou designs para as palavras-chave da thumbnail.")
|
|
181
203
|
candidates = [candidate for candidate in candidates if _design_id(candidate)]
|
|
182
|
-
if not candidates:
|
|
204
|
+
if not candidates and _items(result):
|
|
183
205
|
raise CanvaMCPError("A pesquisa Canva devolveu um design sem ID.")
|
|
206
|
+
if not candidates and not ({"generate-design", "generate_design"} & available):
|
|
207
|
+
raise CanvaMCPError("Canva não encontrou designs para as palavras-chave da thumbnail.")
|
|
184
208
|
|
|
185
209
|
get_name = "get-design-content" if "get-design-content" in available else "get_design_content"
|
|
186
210
|
selected = None
|
|
@@ -286,7 +310,7 @@ def run_direct_canva_thumbnail(
|
|
|
286
310
|
},
|
|
287
311
|
"user_intent": "Export the finished Thunderbolt thumbnail as PNG.",
|
|
288
312
|
}))
|
|
289
|
-
url =
|
|
313
|
+
url = _download_url(exported)
|
|
290
314
|
if not url:
|
|
291
315
|
raise CanvaMCPError("Canva não devolveu URL de download do PNG.")
|
|
292
316
|
response = requests.get(url, timeout=90)
|
package/package.json
CHANGED