-
Notifications
You must be signed in to change notification settings - Fork 7
/
clone_agent
executable file
·52 lines (40 loc) · 1.61 KB
/
clone_agent
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
# Get the base agent name from the first argument
base_agent="$1"
# Get the clone agent name from the second argument
clone_agent="$2"
# Check if base agent directory exists
if [ ! -d "./gentpool/pool/${base_agent}" ]; then
echo "Base agent directory ./gentpool/pool/${base_agent} does not exist. Exiting..."
exit 1
fi
# Check if clone agent directory already exists
if [ -d "./gentpool/pool/${clone_agent}" ]; then
echo "Clone agent directory ./gentpool/pool/${clone_agent} already exists. Exiting..."
exit 1
fi
# Directory paths
base_dir_path="./gentpool/pool/${base_agent}"
clone_dir_path="./gentpool/pool/${clone_agent}"
echo "Cloning agent ${base_agent} to ${clone_agent}, continue? (y/n)"
read answer
if [ "$answer" != "${answer#[Yy]}" ] ;then
# Copy the entire base agent directory to the clone agent directory
cp -r "${base_dir_path}" "${clone_dir_path}"
# Register the clone agent in the pool
echo "from .${clone_agent} import *" >> "./gentpool/pool/__init__.py"
# Update the agent names in the clone agent directory
if [[ "$OSTYPE" == "darwin"* ]]; then
# Mac OSX
sed -i "" "s/${base_agent}/${clone_agent}/g" "${clone_dir_path}/__init__.py"
sed -i "" "s/name: ${base_agent}/name: ${clone_agent}/g" "${clone_dir_path}/agent.yaml"
else
# Linux, other
sed -i "s/${base_agent}/${clone_agent}/g" "${clone_dir_path}/__init__.py"
sed -i "s/name: ${base_agent}/name: ${clone_agent}/g" "${clone_dir_path}/agent.yaml"
fi
echo "Agent ${clone_agent} has been cloned from ${base_agent}."
else
echo "Exiting..."
exit 1
fi