a tool to help your Letta AI agents navigate bluesky

Update Letta client imports and method names

Changed files
+20 -16
+20 -16
mount.ts
··· 139 139 */ 140 140 export async function mount(): Promise<void> { 141 141 const agentId = Deno.env.get("LETTA_AGENT_ID"); 142 - const agentName = Deno.env.get("LETTA_PROJECT_NAME"); 142 + const agentName = Deno.env.get("LETTA_PROJECT_ID"); 143 143 144 144 if (!agentId) { 145 145 console.error( ··· 156 156 console.log(`Agent retrieved: ${agent.name}`); 157 157 158 158 // Get all existing blocks for this agent 159 - const existingBlocks = await client.agents.blocks.list(agentId); 159 + const existingBlocksPage = await client.agents.blocks.list(agentId); 160 + const existingBlocks = existingBlocksPage.items; 160 161 console.log(`Agent has ${existingBlocks.length} existing memory blocks`); 161 162 162 163 // Build dynamic memory blocks array based on configuration ··· 216 217 ); 217 218 } else { 218 219 console.log(`Updating existing block: ${blockConfig.label}`); 219 - await client.blocks.modify(existingBlock.id, { 220 + await client.blocks.update(existingBlock.id, { 220 221 value: blockConfig.value, 221 222 description: blockConfig.description, 222 223 limit: blockConfig.limit, ··· 236 237 237 238 // Attach the block to the agent 238 239 if (newBlock.id) { 239 - await client.agents.blocks.attach(agentId, newBlock.id); 240 + await client.agents.blocks.attach(newBlock.id, { agent_id: agentId }); 240 241 console.log(`✓ Attached block: ${blockConfig.label}`); 241 242 } else { 242 243 throw new Error(`Failed to create block: ${blockConfig.label}`); ··· 259 260 } 260 261 261 262 // Update agent with tool environment variables 262 - await client.agents.modify(agentId, { 263 - toolExecEnvironmentVariables: { 263 + await client.agents.update(agentId, { 264 + secrets: { 264 265 BSKY_USERNAME: bskyUsername || "", 265 266 BSKY_APP_PASSWORD: bskyAppPassword || "", 266 267 BSKY_SERVICE_URL: bskyServiceUrl || "https://bsky.social", ··· 286 287 } 287 288 288 289 // Get currently attached tools 289 - const attachedTools = await client.agents.tools.list(agentId); 290 + const attachedToolsPage = await client.agents.tools.list(agentId); 291 + const attachedTools = attachedToolsPage.items; 290 292 const attachedToolNames = attachedTools.map((tool: any) => tool.name); 291 293 console.log(`Agent has ${attachedTools.length} tools currently attached`); 292 294 ··· 296 298 297 299 // Create a user-level client for tool operations 298 300 // Tools are user-level resources, not project-scoped 299 - const { LettaClient } = await import("@letta-ai/letta-client"); 300 - const userLevelClient = new LettaClient({ 301 - token: Deno.env.get("LETTA_API_KEY"), 301 + const { default: Letta } = await import("@letta-ai/letta-client"); 302 + const userLevelClient = new Letta({ 303 + apiKey: Deno.env.get("LETTA_API_KEY"), 302 304 }); 303 305 304 306 // First, process hardcoded required tools ··· 311 313 } 312 314 313 315 // Search for the tool in the global registry 314 - const existingTools = await userLevelClient.tools.list({ 316 + const existingToolsPage = await userLevelClient.tools.list({ 315 317 name: toolName, 316 318 }); 319 + const existingTools = existingToolsPage.items; 317 320 318 321 if (existingTools.length > 0) { 319 322 const tool = existingTools[0]; 320 323 if (tool.id) { 321 - await client.agents.tools.attach(agentId, tool.id); 324 + await client.agents.tools.attach(tool.id, { agent_id: agentId }); 322 325 console.log(`✓ Attached required tool: ${toolName}`); 323 326 toolsAttached++; 324 327 } ··· 359 362 try { 360 363 // Attempt to create the tool - Letta will extract the function name from docstring 361 364 const createParams: any = { 362 - sourceCode: toolSource, 365 + source_code: toolSource, 363 366 }; 364 367 365 368 // Add pip requirements if any were detected 366 369 if (pipRequirements.length > 0) { 367 - createParams.pipRequirements = pipRequirements; 370 + createParams.pip_requirements = pipRequirements; 368 371 } 369 372 370 373 tool = await userLevelClient.tools.create(createParams); ··· 384 387 const funcMatch = toolSource.match(/^def\s+(\w+)\s*\(/m); 385 388 if (funcMatch) { 386 389 const functionName = funcMatch[1]; 387 - const existingTools = await userLevelClient.tools.list({ 390 + const existingToolsPage = await userLevelClient.tools.list({ 388 391 name: functionName, 389 392 }); 393 + const existingTools = existingToolsPage.items; 390 394 if (existingTools.length > 0) { 391 395 tool = existingTools[0]; 392 396 } ··· 409 413 410 414 // Attach the tool to the agent 411 415 if (tool.id) { 412 - await client.agents.tools.attach(agentId, tool.id); 416 + await client.agents.tools.attach(tool.id, { agent_id: agentId }); 413 417 if (wasCreated) { 414 418 console.log( 415 419 `✓ Created and attached tool: ${toolName} (from ${toolFileName}.py)`,