← back to Designer Wallcoverings
DW-Agents/dw-agents/add-memory-to-all-chats.sh
63 lines
#!/bin/bash
# Add memory context to AI chat in all agents
echo "🚀 Adding memory-aware chat to ALL agents..."
echo ""
# Function to add memory to an agent's systemPrompt
add_memory_context() {
local file=$1
local agent_name=$2
if [ ! -f "$file" ]; then
echo "⏭️ Skipping $agent_name - file not found"
return 1
fi
# Check if already has memory context
if grep -q 'agentMemory.getContextSummary()' "$file"; then
echo "✅ $agent_name - already has memory-aware chat"
return 0
fi
echo "📝 Adding to $agent_name..."
# Create backup
cp "$file" "${file}.chat-backup"
# Add memory context to systemPrompt
# Look for const systemPrompt = and add memory context before the closing backtick
sed -i '/const systemPrompt = `/,/`;$/ {
/`;$/i\
\n${agentMemory.getContextSummary()}\n\nReference stored memories and preferences when relevant.
}' "$file"
echo "✅ $agent_name - memory-aware chat added!"
return 0
}
# Add to all agents
add_memory_context "/root/DW-Agents/digital-samples-agent.ts" "Digital Samples"
add_memory_context "/root/DW-Agents/accounting-agent.ts" "Accounting"
add_memory_context "/root/DW-Agents/purchasing-office-agent.ts" "Purchasing Office"
add_memory_context "/root/DW-Agents/task-orchestrator-agent.ts" "Task Orchestrator"
add_memory_context "/root/DW-Agents/zendesk-chat-agent.ts" "Zendesk Chat"
add_memory_context "/root/DW-Agents/new-client-signup-agent.ts" "New Client Signup"
add_memory_context "/root/DW-Agents/todays-highlights-agent.ts" "Today's Highlights"
add_memory_context "/root/DW-Agents/completed-tasks-agent.ts" "Completed Tasks"
add_memory_context "/root/DW-Agents/in-parallel-agent.ts" "In Parallel"
add_memory_context "/root/DW-Agents/agent-legal-team/legal-agent.ts" "Legal Team"
echo ""
echo "🎉 Done! Restarting all agents..."
pm2 restart all
pm2 save
echo ""
echo "✨ All agents now have memory-aware chat!"
echo ""
echo "Test it:"
echo '1. Chat: "Remember: We ship on Tuesdays"'
echo '2. Chat: "When should I schedule the shipment?"'
echo '3. AI will reference your Tuesday preference!'