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 89 handles = list(set(handles)) 90 90 91 91 try: 92 - client = get_letta_client() 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"]) 93 100 results = [] 94 101 95 102 # Get current blocks using the API ··· 167 174 """ 168 175 169 176 try: 170 - client = get_letta_client() 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"]) 171 185 results = [] 172 186 173 187 # Build mapping of block labels to IDs using the API ··· 216 230 """ 217 231 218 232 try: 219 - client = get_letta_client() 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"]) 220 237 221 238 # Sanitize handle for block label 222 239 clean_handle = handle.lstrip('@').replace('.', '_').replace('-', '_').replace(' ', '_') ··· 280 297 """ 281 298 282 299 try: 283 - client = get_letta_client() 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"]) 284 304 285 305 # Sanitize handle for block label 286 306 clean_handle = handle.lstrip('@').replace('.', '_').replace('-', '_').replace(' ', '_') ··· 327 347 """ 328 348 329 349 try: 330 - client = get_letta_client() 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"]) 331 354 332 355 # Sanitize handle for block label 333 356 clean_handle = handle.lstrip('@').replace('.', '_').replace('-', '_').replace(' ', '_') ··· 384 407 """ 385 408 386 409 try: 387 - client = get_letta_client() 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"]) 388 414 389 415 # Sanitize handle for block label 390 416 clean_handle = handle.lstrip('@').replace('.', '_').replace('-', '_').replace(' ', '_') ··· 421 447 user_ids = list(set(user_ids)) 422 448 423 449 try: 424 - client = get_letta_client() 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"]) 425 458 results = [] 426 459 427 460 # Get current blocks using the API ··· 459 492 ) 460 493 461 494 results.append(f"✓ {user_id}: Block attached") 462 - logger.debug(f"Successfully attached block {block_label} to agent") 463 495 464 496 except Exception as e: 465 497 results.append(f"✗ {user_id}: Error - {str(e)}") ··· 483 515 """ 484 516 485 517 try: 486 - client = get_letta_client() 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"]) 487 526 results = [] 488 527 489 528 # Build mapping of block labels to IDs using the API