Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/v2/cloud deploy #51

Open
wants to merge 5 commits into
base: v2-develop
Choose a base branch
from
Open

Conversation

jmikedupont2
Copy link
Member

Porting of scripts into new version

Future thoughts

We can think about moving these scripts into a new repo that holds Eliza as submodule so we don't need to change the base repo.
Basically, a packaging of another repo.

--profile solfunmeme_dev \
--region us-east-2 \
--document-name "UpdateEliza" \
--document-version "\$LATEST" \
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using $LATEST version in production scripts is risky as it may lead to unexpected behavior when document versions change. Should specify explicit version for consistency.

@@ -0,0 +1,8 @@

aws codebuild start-build --region us-east-2 \
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script lacks AWS credentials validation or profile specification, which could lead to authentication failures in non-interactive environments or when multiple AWS profiles are present.

#apt install -y strace

export COREPACK_ENABLE_DOWNLOAD_PROMPT=0
corepack enable && corepack install --global pnpm@9.8.0
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Global package installation requires root privileges but script doesn't check for root access. This could fail silently or with unclear error messages in non-root environments.


#strace -f -o /opt/agent/strace.log -s99999 node CMD ["pnpm", "start", "--characters=characters/eliza.character.json"]
#pnpm start --characters=characters/tine-test.character.json
pnpm start --characters=$(ls -1p characters/*.json | paste -sd,)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glob expansion without error handling for no matches. If no JSON files exist, this will pass the glob pattern literally to pnpm. Also, filenames with spaces will break the command.

# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264
set -x
#if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then
strace -f -o /opt/agent/strace.log -s99999 node "$@"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script always runs strace regardless of conditions due to commented if statement, which could impact performance and create unnecessary logs in production environment

Comment on lines +9 to +10
apt update
apt install -y strace
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running apt commands without sudo might fail in non-root environments. Additionally, there's no check if the script runs on a Debian-based system, which could cause failures on other distributions.

@@ -0,0 +1,21 @@

nvm use 23
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Node.js version 23 doesn't exist yet. The latest LTS version is 20.x, and the latest current version is 21.x. Using a non-existent version will cause the script to fail.


# Fetch all variables with the prefix and name them the same as the variable minus agent name underscore
for key in $(aws ssm describe-parameters --query 'Parameters[?starts_with(Name, `'"${AGENT_NAME}"'_`)].Name' --output text); do
value=$(aws ssm get-parameter --name "$key" | jq .Parameter.Value -r)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The AWS SSM get-parameter command doesn't include --with-decryption flag, which means encrypted parameters won't be automatically decrypted.

echo "" > "/var/run/agent/secrets/env" # blank the file

# Fetch all variables with the prefix and name them the same as the variable minus agent name underscore
for key in $(aws ssm describe-parameters --query 'Parameters[?starts_with(Name, `'"${AGENT_NAME}"'_`)].Name' --output text); do
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The command output isn't properly handled for cases where AWS CLI fails. Script continues execution even if AWS commands fail, potentially creating incomplete env file.

@@ -0,0 +1,6 @@

export TWITTER_EMAIL TWITTER_PASSWORD TWITTER_USER
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The export statement uses TWITTER_USER but the AWS SSM command uses TWITTER_USERNAME, causing a mismatch in variable names that will result in empty value being stored in SSM.


export TWITTER_EMAIL TWITTER_PASSWORD TWITTER_USER

aws ssm put-parameter --name "tine_agent_twitter_password" --value "${TWITTER_PASSWORD}" --type String
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script doesn't use --overwrite flag, which means it will fail if parameters already exist in SSM. This could cause deployment issues in existing environments.

@@ -0,0 +1,28 @@

#
bash ./get_secrets.sh
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Script execution lacks error handling and verification of get_secrets.sh existence. A failed secrets retrieval could lead to authentication issues in subsequent Docker operations.

docker kill agent-docker.service || echo skip
docker rm --force agent-docker.service || echo skip

/usr/bin/bash -c 'docker login -u AWS -p $(aws ecr get-login-password --region us-east-2) 767503528736.dkr.ecr.us-east-2.amazonaws.com'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exposing AWS credentials in command line is insecure. The password could be visible in process lists or system logs. Should use environment variables or AWS credentials file.

--env-file /var/run/agent/secrets/env \
--rm \
--name "agent-docker.service" \
--entrypoint /opt/agent/docker-entrypoint-strace2.sh $DOCKERIMAGE
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script uses $DOCKERIMAGE variable in the final docker run command, but this variable is never defined. It should likely be $CORE_AGENT_IMAGE based on the context.

@@ -0,0 +1,30 @@

#
bash ./get_secrets.sh
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script doesn't check if get_secrets.sh execution was successful. Failed secrets retrieval could lead to runtime issues in the container.

Comment on lines +39 to +41
if ! grep -q "^HOME" "/var/run/agent/secrets/env"; then
echo "WORKSPACE_DIR=\${STATE_DIRECTORY}" >> "/var/run/agent/secrets/env"
fi
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition checks for HOME but writes WORKSPACE_DIR, which appears to be a logic error. Also, the condition is identical to the previous if statement, suggesting a copy-paste error.

Comment on lines +4 to +5
cd "$(dirname "$0")"/..
echo "Cleanup started."
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script doesn't check if the directory change was successful before proceeding. A failed cd command could lead to cleanup operations in the wrong directory.

#aws ssm put-parameter --name "tine_agent_openai_key" --value "${OPENAI_API_KEY}" --type String
#aws ssm put-parameter --name "tine_agent_openai_endpoint" --value "${OPENAI_API_BASE}" --type String
#aws ssm put-parameter --name "tine_agent_openai_model" --value "${LLMMODEL}" --type String
aws ssm put-parameter --name "tine_agent_groq_key" --value "${GROQ_API_KEY}" --type String
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sensitive API key is stored without the --overwrite flag, which could lead to parameter creation failures if it already exists, and without SecureString type for encryption.


aws ssm put-parameter --name "tine_agent_2_agent_image" --value "h4ckermike/elizaos-eliza:feb10" --type String
aws ssm put-parameter --name "tine_agent_2_docker_username" --value "${DOCKER_USERNAME}" --type String
aws ssm put-parameter --name "tine_agent_2_docker_password" --value "${DOCKER_PASSWORD}" --type String
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docker credentials are stored as plain String type instead of SecureString, potentially exposing sensitive authentication data. Also missing --overwrite flag for consistency.

@@ -0,0 +1,2 @@
#!/bin/bash
source /var/run/agent/secrets/env
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script doesn't check if the environment file exists before sourcing it. This could lead to silent failures and unpredictable behavior if the file is missing or inaccessible.

Comment on lines +15 to +18
prms = {
"portNumber":["22"],
"localPortNumber":["2222"]
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard-coded port numbers should be configurable parameters or environment variables to allow flexibility and security in different environments.

source /var/run/agent/secrets/env

/usr/bin/docker run -p 3000:3000 \
-v tokenizer:/app/node_modules/@anush008/tokenizers/ \
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the same volume name 'tokenizer' for two different mount points can cause conflicts and unexpected behavior. Each volume should have a unique name to ensure proper isolation.

#!/bin/bash

source ./env
/usr/bin/docker remove agent-docker.service
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The command should be 'docker rm' instead of 'docker remove'. This is incorrect Docker CLI syntax and will fail. The command needs to be corrected to use the proper Docker command.

Copy link

trag-bot bot commented Mar 14, 2025

@trag-bot didn't find any issues in the code! ✅✨

Copy link

trag-bot bot commented Mar 14, 2025

Pull request summary

  • Updated Discord invitation link in the pull request template to the new server.
  • Added a GitHub Actions workflow to fetch news files daily at midnight UTC and allow manual triggering.
  • Introduced a new workflow to automatically update the changelog upon release publication.
  • Modified the Docker image creation workflow to include AWS credentials configuration and support for multiple platforms.
  • Created a new smoke test workflow to run on every push and pull request, ensuring integration tests are executed.
  • Refactored the integration tests workflow to use pnpm for package management and improved environment variable handling.
  • Added submodules for various Twitter-related plugins and clients to the project.
  • Updated dependencies in package.json and other configuration files to their latest versions.
  • Enhanced the Dockerfile to include additional setup steps and ensure the application starts correctly.
  • Implemented scripts for AWS SSM parameter management and Docker container management to streamline deployment processes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant