fix: add env.get_module_dbname() for dynamic database lookup
This commit is contained in:
parent
34fd3ada5c
commit
eb9a90ee42
@ -361,12 +361,17 @@ class HermesAgent:
|
|||||||
selected_memories = []
|
selected_memories = []
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
env = ServerEnv()
|
||||||
|
|
||||||
|
dbname = env.get_module_dbname('harnessed_agent')
|
||||||
|
|
||||||
config = getConfig()
|
config = getConfig()
|
||||||
|
|
||||||
db = DBPools()
|
db = DBPools()
|
||||||
|
|
||||||
db.databases = config.databases
|
db.databases = config.databases
|
||||||
async with db.sqlorContext('harnessed_agent') as sor:
|
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
# High priority memories
|
# High priority memories
|
||||||
ns = {'user_id': user_id, 'priority__gte': self.config.high_priority_threshold, 'sort': 'priority desc,last_accessed desc'}
|
ns = {'user_id': user_id, 'priority__gte': self.config.high_priority_threshold, 'sort': 'priority desc,last_accessed desc'}
|
||||||
hp_rows = await sor.R('hermes_memory', ns)
|
hp_rows = await sor.R('hermes_memory', ns)
|
||||||
@ -418,12 +423,17 @@ class HermesAgent:
|
|||||||
async def _update_memory_access_stats(self, user_id: str, memory_id: str):
|
async def _update_memory_access_stats(self, user_id: str, memory_id: str):
|
||||||
"""Update memory access statistics"""
|
"""Update memory access statistics"""
|
||||||
try:
|
try:
|
||||||
|
env = ServerEnv()
|
||||||
|
|
||||||
|
dbname = env.get_module_dbname('harnessed_agent')
|
||||||
|
|
||||||
config = getConfig()
|
config = getConfig()
|
||||||
|
|
||||||
db = DBPools()
|
db = DBPools()
|
||||||
|
|
||||||
db.databases = config.databases
|
db.databases = config.databases
|
||||||
async with db.sqlorContext('harnessed_agent') as sor:
|
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
memories = await sor.R('hermes_memory', {'id': memory_id, 'user_id': user_id})
|
memories = await sor.R('hermes_memory', {'id': memory_id, 'user_id': user_id})
|
||||||
if memories:
|
if memories:
|
||||||
current_count = memories[0].get('access_count', 0)
|
current_count = memories[0].get('access_count', 0)
|
||||||
@ -444,12 +454,17 @@ class HermesAgent:
|
|||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
env = ServerEnv()
|
||||||
|
|
||||||
|
dbname = env.get_module_dbname('harnessed_agent')
|
||||||
|
|
||||||
config = getConfig()
|
config = getConfig()
|
||||||
|
|
||||||
db = DBPools()
|
db = DBPools()
|
||||||
|
|
||||||
db.databases = config.databases
|
db.databases = config.databases
|
||||||
async with db.sqlorContext('harnessed_agent') as sor:
|
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
# Calculate cutoff date
|
# Calculate cutoff date
|
||||||
cutoff_date = datetime.now().replace(
|
cutoff_date = datetime.now().replace(
|
||||||
day=datetime.now().day - self.config.min_retention_days
|
day=datetime.now().day - self.config.min_retention_days
|
||||||
@ -553,12 +568,17 @@ class HermesAgent:
|
|||||||
user_id = self._get_current_user_id(context) if context else "anonymous"
|
user_id = self._get_current_user_id(context) if context else "anonymous"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
env = ServerEnv()
|
||||||
|
|
||||||
|
dbname = env.get_module_dbname('harnessed_agent')
|
||||||
|
|
||||||
config = getConfig()
|
config = getConfig()
|
||||||
|
|
||||||
db = DBPools()
|
db = DBPools()
|
||||||
|
|
||||||
db.databases = config.databases
|
db.databases = config.databases
|
||||||
async with db.sqlorContext('harnessed_agent') as sor:
|
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
if action == "add":
|
if action == "add":
|
||||||
memory_id = str(uuid.uuid4())
|
memory_id = str(uuid.uuid4())
|
||||||
# Auto-classify priority if not provided
|
# Auto-classify priority if not provided
|
||||||
@ -671,12 +691,17 @@ class HermesAgent:
|
|||||||
user_id = self._get_current_user_id(context) if context else "anonymous"
|
user_id = self._get_current_user_id(context) if context else "anonymous"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
env = ServerEnv()
|
||||||
|
|
||||||
|
dbname = env.get_module_dbname('harnessed_agent')
|
||||||
|
|
||||||
config = getConfig()
|
config = getConfig()
|
||||||
|
|
||||||
db = DBPools()
|
db = DBPools()
|
||||||
|
|
||||||
db.databases = config.databases
|
db.databases = config.databases
|
||||||
async with db.sqlorContext('harnessed_agent') as sor:
|
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
filters = {'user_id': user_id}
|
filters = {'user_id': user_id}
|
||||||
if query:
|
if query:
|
||||||
filters['$or'] = [
|
filters['$or'] = [
|
||||||
@ -718,12 +743,17 @@ class HermesAgent:
|
|||||||
return {"success": False, "error": "Invalid skill name", "user_id": user_id}
|
return {"success": False, "error": "Invalid skill name", "user_id": user_id}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
env = ServerEnv()
|
||||||
|
|
||||||
|
dbname = env.get_module_dbname('harnessed_agent')
|
||||||
|
|
||||||
config = getConfig()
|
config = getConfig()
|
||||||
|
|
||||||
db = DBPools()
|
db = DBPools()
|
||||||
|
|
||||||
db.databases = config.databases
|
db.databases = config.databases
|
||||||
async with db.sqlorContext('harnessed_agent') as sor:
|
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
if action == "view":
|
if action == "view":
|
||||||
filters = {'user_id': user_id, 'name': name}
|
filters = {'user_id': user_id, 'name': name}
|
||||||
skills = await sor.R('harnessed_skills', {'user_id': user_id, 'name': name})
|
skills = await sor.R('harnessed_skills', {'user_id': user_id, 'name': name})
|
||||||
@ -807,12 +837,17 @@ class HermesAgent:
|
|||||||
user_id = self._get_current_user_id(context) if context else "anonymous"
|
user_id = self._get_current_user_id(context) if context else "anonymous"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
env = ServerEnv()
|
||||||
|
|
||||||
|
dbname = env.get_module_dbname('harnessed_agent')
|
||||||
|
|
||||||
config = getConfig()
|
config = getConfig()
|
||||||
|
|
||||||
db = DBPools()
|
db = DBPools()
|
||||||
|
|
||||||
db.databases = config.databases
|
db.databases = config.databases
|
||||||
async with db.sqlorContext('harnessed_agent') as sor:
|
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
if action == "create":
|
if action == "create":
|
||||||
# Create new remote skill configuration
|
# Create new remote skill configuration
|
||||||
new_skill_id = str(uuid.uuid4())
|
new_skill_id = str(uuid.uuid4())
|
||||||
@ -1217,12 +1252,17 @@ class HermesAgent:
|
|||||||
"""List workflows for current user"""
|
"""List workflows for current user"""
|
||||||
user_id = self._get_current_user_id(context) if context else "anonymous"
|
user_id = self._get_current_user_id(context) if context else "anonymous"
|
||||||
try:
|
try:
|
||||||
|
env = ServerEnv()
|
||||||
|
|
||||||
|
dbname = env.get_module_dbname('harnessed_agent')
|
||||||
|
|
||||||
config = getConfig()
|
config = getConfig()
|
||||||
|
|
||||||
db = DBPools()
|
db = DBPools()
|
||||||
|
|
||||||
db.databases = config.databases
|
db.databases = config.databases
|
||||||
async with db.sqlorContext('harnessed_agent') as sor:
|
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
workflows = await sor.R('hermes_workflows', {'sort': 'created_at desc', 'user_id': user_id})
|
workflows = await sor.R('hermes_workflows', {'sort': 'created_at desc', 'user_id': user_id})
|
||||||
return {"success": True, "workflows": workflows or [], "user_id": user_id}
|
return {"success": True, "workflows": workflows or [], "user_id": user_id}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -1234,12 +1274,17 @@ class HermesAgent:
|
|||||||
"""List executions for current user (optionally filtered by workflow)"""
|
"""List executions for current user (optionally filtered by workflow)"""
|
||||||
user_id = self._get_current_user_id(context) if context else "anonymous"
|
user_id = self._get_current_user_id(context) if context else "anonymous"
|
||||||
try:
|
try:
|
||||||
|
env = ServerEnv()
|
||||||
|
|
||||||
|
dbname = env.get_module_dbname('harnessed_agent')
|
||||||
|
|
||||||
config = getConfig()
|
config = getConfig()
|
||||||
|
|
||||||
db = DBPools()
|
db = DBPools()
|
||||||
|
|
||||||
db.databases = config.databases
|
db.databases = config.databases
|
||||||
async with db.sqlorContext('harnessed_agent') as sor:
|
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
filters = {'user_id': user_id}
|
filters = {'user_id': user_id}
|
||||||
if workflow_id:
|
if workflow_id:
|
||||||
filters['workflow_id'] = workflow_id
|
filters['workflow_id'] = workflow_id
|
||||||
|
|||||||
@ -86,12 +86,17 @@ class HermesOrchestrator:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
workflow_id = str(uuid.uuid4())
|
workflow_id = str(uuid.uuid4())
|
||||||
|
env = ServerEnv()
|
||||||
|
|
||||||
|
dbname = env.get_module_dbname('harnessed_agent')
|
||||||
|
|
||||||
config = getConfig()
|
config = getConfig()
|
||||||
|
|
||||||
db = DBPools()
|
db = DBPools()
|
||||||
|
|
||||||
db.databases = config.databases
|
db.databases = config.databases
|
||||||
async with db.sqlorContext('harnessed_agent') as sor:
|
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
data = {
|
data = {
|
||||||
'id': workflow_id,
|
'id': workflow_id,
|
||||||
'user_id': user_id,
|
'user_id': user_id,
|
||||||
@ -123,12 +128,17 @@ class HermesOrchestrator:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
# Verify workflow exists and belongs to user
|
# Verify workflow exists and belongs to user
|
||||||
|
env = ServerEnv()
|
||||||
|
|
||||||
|
dbname = env.get_module_dbname('harnessed_agent')
|
||||||
|
|
||||||
config = getConfig()
|
config = getConfig()
|
||||||
|
|
||||||
db = DBPools()
|
db = DBPools()
|
||||||
|
|
||||||
db.databases = config.databases
|
db.databases = config.databases
|
||||||
async with db.sqlorContext('harnessed_agent') as sor:
|
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
workflows = await sor.R('hermes_workflows', {
|
workflows = await sor.R('hermes_workflows', {
|
||||||
'id': workflow_id,
|
'id': workflow_id,
|
||||||
'user_id': user_id
|
'user_id': user_id
|
||||||
@ -191,12 +201,17 @@ class HermesOrchestrator:
|
|||||||
async def _load_workflow_definition(self, workflow_id: str, user_id: str) -> Dict[str, Any]:
|
async def _load_workflow_definition(self, workflow_id: str, user_id: str) -> Dict[str, Any]:
|
||||||
"""Load complete workflow definition with all tasks"""
|
"""Load complete workflow definition with all tasks"""
|
||||||
try:
|
try:
|
||||||
|
env = ServerEnv()
|
||||||
|
|
||||||
|
dbname = env.get_module_dbname('harnessed_agent')
|
||||||
|
|
||||||
config = getConfig()
|
config = getConfig()
|
||||||
|
|
||||||
db = DBPools()
|
db = DBPools()
|
||||||
|
|
||||||
db.databases = config.databases
|
db.databases = config.databases
|
||||||
async with db.sqlorContext('harnessed_agent') as sor:
|
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
# Load workflow
|
# Load workflow
|
||||||
workflows = await sor.R('hermes_workflows', {
|
workflows = await sor.R('hermes_workflows', {
|
||||||
'id': workflow_id,
|
'id': workflow_id,
|
||||||
@ -490,12 +505,17 @@ class HermesOrchestrator:
|
|||||||
task: TaskDefinition, context: Dict[str, Any]):
|
task: TaskDefinition, context: Dict[str, Any]):
|
||||||
"""Record execution start in database"""
|
"""Record execution start in database"""
|
||||||
try:
|
try:
|
||||||
|
env = ServerEnv()
|
||||||
|
|
||||||
|
dbname = env.get_module_dbname('harnessed_agent')
|
||||||
|
|
||||||
config = getConfig()
|
config = getConfig()
|
||||||
|
|
||||||
db = DBPools()
|
db = DBPools()
|
||||||
|
|
||||||
db.databases = config.databases
|
db.databases = config.databases
|
||||||
async with db.sqlorContext('harnessed_agent') as sor:
|
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
data = {
|
data = {
|
||||||
'id': execution_id,
|
'id': execution_id,
|
||||||
'user_id': user_id,
|
'user_id': user_id,
|
||||||
@ -515,12 +535,17 @@ class HermesOrchestrator:
|
|||||||
result: Dict[str, Any], error: str, retry_count: int):
|
result: Dict[str, Any], error: str, retry_count: int):
|
||||||
"""Record execution end in database"""
|
"""Record execution end in database"""
|
||||||
try:
|
try:
|
||||||
|
env = ServerEnv()
|
||||||
|
|
||||||
|
dbname = env.get_module_dbname('harnessed_agent')
|
||||||
|
|
||||||
config = getConfig()
|
config = getConfig()
|
||||||
|
|
||||||
db = DBPools()
|
db = DBPools()
|
||||||
|
|
||||||
db.databases = config.databases
|
db.databases = config.databases
|
||||||
async with db.sqlorContext('harnessed_agent') as sor:
|
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
end_time = datetime.now()
|
end_time = datetime.now()
|
||||||
data = {
|
data = {
|
||||||
'id': execution_id,
|
'id': execution_id,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user