a digital person for bluesky

Fix user_note_* tools NameError for cloud execution

- Fixed user_note_append, user_note_replace, user_note_set, user_note_view functions
- Changed from get_letta_client() to inline Letta client creation for cloud compatibility
- Also updated attach/detach functions to handle both local and cloud execution
- Removed logger.debug call that wouldn't work in cloud environment
- All functions now create Letta client inline using environment variables

This fixes the critical failure void reported where user_note_* tools were non-functional
due to NameError when get_letta_client couldn't import config_loader in cloud.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

Changed files
+48 -9
tools
+48 -9
tools/blocks.py
··· 89 handles = list(set(handles)) 90 91 try: 92 - client = get_letta_client() 93 results = [] 94 95 # Get current blocks using the API ··· 167 """ 168 169 try: 170 - client = get_letta_client() 171 results = [] 172 173 # Build mapping of block labels to IDs using the API ··· 216 """ 217 218 try: 219 - client = get_letta_client() 220 221 # Sanitize handle for block label 222 clean_handle = handle.lstrip('@').replace('.', '_').replace('-', '_').replace(' ', '_') ··· 280 """ 281 282 try: 283 - client = get_letta_client() 284 285 # Sanitize handle for block label 286 clean_handle = handle.lstrip('@').replace('.', '_').replace('-', '_').replace(' ', '_') ··· 327 """ 328 329 try: 330 - client = get_letta_client() 331 332 # Sanitize handle for block label 333 clean_handle = handle.lstrip('@').replace('.', '_').replace('-', '_').replace(' ', '_') ··· 384 """ 385 386 try: 387 - client = get_letta_client() 388 389 # Sanitize handle for block label 390 clean_handle = handle.lstrip('@').replace('.', '_').replace('-', '_').replace(' ', '_') ··· 421 user_ids = list(set(user_ids)) 422 423 try: 424 - client = get_letta_client() 425 results = [] 426 427 # Get current blocks using the API ··· 459 ) 460 461 results.append(f"✓ {user_id}: Block attached") 462 - logger.debug(f"Successfully attached block {block_label} to agent") 463 464 except Exception as e: 465 results.append(f"✗ {user_id}: Error - {str(e)}") ··· 483 """ 484 485 try: 486 - client = get_letta_client() 487 results = [] 488 489 # Build mapping of block labels to IDs using the API
··· 89 handles = list(set(handles)) 90 91 try: 92 + # Try to get client the local way first, fall back to inline for cloud execution 93 + try: 94 + client = get_letta_client() 95 + except (ImportError, NameError): 96 + # Create Letta client inline for cloud execution 97 + import os 98 + from letta_client import Letta 99 + client = Letta(token=os.environ["LETTA_API_KEY"]) 100 results = [] 101 102 # Get current blocks using the API ··· 174 """ 175 176 try: 177 + # Try to get client the local way first, fall back to inline for cloud execution 178 + try: 179 + client = get_letta_client() 180 + except (ImportError, NameError): 181 + # Create Letta client inline for cloud execution 182 + import os 183 + from letta_client import Letta 184 + client = Letta(token=os.environ["LETTA_API_KEY"]) 185 results = [] 186 187 # Build mapping of block labels to IDs using the API ··· 230 """ 231 232 try: 233 + # Create Letta client inline - cloud tools must be self-contained 234 + import os 235 + from letta_client import Letta 236 + client = Letta(token=os.environ["LETTA_API_KEY"]) 237 238 # Sanitize handle for block label 239 clean_handle = handle.lstrip('@').replace('.', '_').replace('-', '_').replace(' ', '_') ··· 297 """ 298 299 try: 300 + # Create Letta client inline - cloud tools must be self-contained 301 + import os 302 + from letta_client import Letta 303 + client = Letta(token=os.environ["LETTA_API_KEY"]) 304 305 # Sanitize handle for block label 306 clean_handle = handle.lstrip('@').replace('.', '_').replace('-', '_').replace(' ', '_') ··· 347 """ 348 349 try: 350 + # Create Letta client inline - cloud tools must be self-contained 351 + import os 352 + from letta_client import Letta 353 + client = Letta(token=os.environ["LETTA_API_KEY"]) 354 355 # Sanitize handle for block label 356 clean_handle = handle.lstrip('@').replace('.', '_').replace('-', '_').replace(' ', '_') ··· 407 """ 408 409 try: 410 + # Create Letta client inline - cloud tools must be self-contained 411 + import os 412 + from letta_client import Letta 413 + client = Letta(token=os.environ["LETTA_API_KEY"]) 414 415 # Sanitize handle for block label 416 clean_handle = handle.lstrip('@').replace('.', '_').replace('-', '_').replace(' ', '_') ··· 447 user_ids = list(set(user_ids)) 448 449 try: 450 + # Try to get client the local way first, fall back to inline for cloud execution 451 + try: 452 + client = get_letta_client() 453 + except (ImportError, NameError): 454 + # Create Letta client inline for cloud execution 455 + import os 456 + from letta_client import Letta 457 + client = Letta(token=os.environ["LETTA_API_KEY"]) 458 results = [] 459 460 # Get current blocks using the API ··· 492 ) 493 494 results.append(f"✓ {user_id}: Block attached") 495 496 except Exception as e: 497 results.append(f"✗ {user_id}: Error - {str(e)}") ··· 515 """ 516 517 try: 518 + # Try to get client the local way first, fall back to inline for cloud execution 519 + try: 520 + client = get_letta_client() 521 + except (ImportError, NameError): 522 + # Create Letta client inline for cloud execution 523 + import os 524 + from letta_client import Letta 525 + client = Letta(token=os.environ["LETTA_API_KEY"]) 526 results = [] 527 528 # Build mapping of block labels to IDs using the API