[READ-ONLY] Mirror of https://github.com/just-cameron/note. External storage tool for Letta agents to manage persistent notes
0

Configure Feed

Select the types of activity you want to include in your feed.

note / install.sh
2.0 kB 78 lines
1#!/bin/bash 2# 3# Install the Letta Note tool 4# Usage: curl -sSL https://raw.githubusercontent.com/cpfiffer/note/main/install.sh | bash 5# 6 7set -e 8 9echo "Letta Note Tool Installer" 10echo "=========================" 11echo "" 12 13# Get API key 14API_KEY="${LETTA_API_KEY:-}" 15 16if [ -z "$API_KEY" ]; then 17 read -p "Enter your Letta API key: " API_KEY 18 echo "" 19fi 20 21if [ -z "$API_KEY" ]; then 22 echo "Error: API key required" 23 exit 1 24fi 25 26echo "Checking for existing 'note' tool..." 27EXISTING=$(curl -sS "https://api.letta.com/v1/tools/?name=note" \ 28 -H "Authorization: Bearer $API_KEY") 29 30if echo "$EXISTING" | grep -q '"id"'; then 31 EXISTING_ID=$(echo "$EXISTING" | python3 -c 'import json,sys; d=json.loads(sys.stdin.read()); print(d[0]["id"] if d else "")') 32 if [ -n "$EXISTING_ID" ]; then 33 echo "" 34 echo "Warning: A tool named 'note' already exists (ID: $EXISTING_ID)" 35 read -p "Overwrite it? [y/N] " CONFIRM 36 if [ "$CONFIRM" != "y" ] && [ "$CONFIRM" != "Y" ]; then 37 echo "Aborted." 38 exit 0 39 fi 40 echo "" 41 fi 42fi 43 44echo "Fetching note_tool.py..." 45SOURCE_CODE=$(curl -sSL https://raw.githubusercontent.com/cpfiffer/note/main/note_tool.py) 46 47if [ -z "$SOURCE_CODE" ]; then 48 echo "Error: Failed to fetch note_tool.py" 49 exit 1 50fi 51 52echo "Installing tool..." 53 54# Escape for JSON 55SOURCE_CODE_JSON=$(echo "$SOURCE_CODE" | python3 -c 'import json,sys; print(json.dumps(sys.stdin.read()))') 56 57# Upsert the tool 58RESPONSE=$(curl -sS https://api.letta.com/v1/tools/ \ 59 -X PUT \ 60 -H "Content-Type: application/json" \ 61 -H "Authorization: Bearer $API_KEY" \ 62 -d "{\"source_code\": $SOURCE_CODE_JSON}") 63 64# Check for errors 65if echo "$RESPONSE" | grep -q '"error"'; then 66 echo "Error: $RESPONSE" 67 exit 1 68fi 69 70TOOL_ID=$(echo "$RESPONSE" | python3 -c 'import json,sys; print(json.loads(sys.stdin.read()).get("id", "unknown"))') 71 72echo "" 73echo "✓ Note tool installed!" 74echo "" 75echo "Tool ID: $TOOL_ID" 76echo "" 77echo "Next: Attach to your agent via ADE or SDK:" 78echo " client.agents.tools.attach(agent_id=AGENT_ID, tool_id=\"$TOOL_ID\")"