2026-04-16 15:40:17 +08:00

92 lines
2.6 KiB
Bash
Executable File

#!/bin/bash
# Build script for harnessed_agent module
set -e
echo "Building Hermes Agent module..."
# Create database tables if they don't exist
echo "Creating database tables..."
python3 -c "
import sys
sys.path.insert(0, '.')
from sqlor.dbpools import DBPools
from sqlor.sqlor import SQLor
# Initialize database pools
dbpools = DBPools()
db = dbpools.get('default')
# Create harnessed_agent table
try:
db.execute('''
CREATE TABLE IF NOT EXISTS harnessed_agent (
id VARCHAR(64) PRIMARY KEY,
name VARCHAR(255) NOT NULL,
description TEXT,
config JSON,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)
''')
print('harnessed_agent table created')
except Exception as e:
print(f'Error creating harnessed_agent table: {e}')
# Create sessions table
try:
db.execute('''
CREATE TABLE IF NOT EXISTS sessions (
id VARCHAR(64) PRIMARY KEY,
user_id VARCHAR(64) NOT NULL,
context JSON,
metadata JSON,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
INDEX idx_user_id (user_id),
INDEX idx_created_at (created_at)
)
''')
print('sessions table created')
except Exception as e:
print(f'Error creating sessions table: {e}')
# Create skills table
try:
db.execute('''
CREATE TABLE IF NOT EXISTS skills (
id VARCHAR(64) PRIMARY KEY,
name VARCHAR(255) NOT NULL UNIQUE,
description TEXT,
definition JSON,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
INDEX idx_name (name)
)
''')
print('skills table created')
except Exception as e:
print(f'Error creating skills table: {e}')
# Create memory table
try:
db.execute('''
CREATE TABLE IF NOT EXISTS memory (
id VARCHAR(64) PRIMARY KEY,
user_id VARCHAR(64),
key VARCHAR(255) NOT NULL,
value JSON,
memory_type ENUM('user', 'system') NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
INDEX idx_user_key (user_id, key),
INDEX idx_system_key (key),
INDEX idx_memory_type (memory_type)
)
''')
print('memory table created')
except Exception as e:
print(f'Error creating memory table: {e}')
"
echo "Hermes Agent module build completed successfully!"