fix: DBPools(config.databases) instead of DBPools() for subprocess context
This commit is contained in:
parent
fe6666b665
commit
22820b85cd
@ -38,6 +38,11 @@ except ImportError:
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def getConfig():
|
||||||
|
class Config:
|
||||||
|
databases = None
|
||||||
|
return Config()
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class HermesConfig:
|
class HermesConfig:
|
||||||
"""Configuration for Hermes Agent module"""
|
"""Configuration for Hermes Agent module"""
|
||||||
@ -356,7 +361,9 @@ class HermesAgent:
|
|||||||
selected_memories = []
|
selected_memories = []
|
||||||
|
|
||||||
try:
|
try:
|
||||||
db = DBPools()
|
config = getConfig()
|
||||||
|
|
||||||
|
db = DBPools(config.databases)
|
||||||
async with db.sqlorContext('harnessed_agent') as sor:
|
async with db.sqlorContext('harnessed_agent') 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'}
|
||||||
@ -409,7 +416,9 @@ 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:
|
||||||
db = DBPools()
|
config = getConfig()
|
||||||
|
|
||||||
|
db = DBPools(config.databases)
|
||||||
async with db.sqlorContext('harnessed_agent') as sor:
|
async with db.sqlorContext('harnessed_agent') 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:
|
||||||
@ -431,7 +440,9 @@ class HermesAgent:
|
|||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
db = DBPools()
|
config = getConfig()
|
||||||
|
|
||||||
|
db = DBPools(config.databases)
|
||||||
async with db.sqlorContext('harnessed_agent') as sor:
|
async with db.sqlorContext('harnessed_agent') as sor:
|
||||||
# Calculate cutoff date
|
# Calculate cutoff date
|
||||||
cutoff_date = datetime.now().replace(
|
cutoff_date = datetime.now().replace(
|
||||||
@ -536,7 +547,9 @@ 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:
|
||||||
db = DBPools()
|
config = getConfig()
|
||||||
|
|
||||||
|
db = DBPools(config.databases)
|
||||||
async with db.sqlorContext('harnessed_agent') as sor:
|
async with db.sqlorContext('harnessed_agent') as sor:
|
||||||
if action == "add":
|
if action == "add":
|
||||||
memory_id = str(uuid.uuid4())
|
memory_id = str(uuid.uuid4())
|
||||||
@ -650,7 +663,9 @@ 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:
|
||||||
db = DBPools()
|
config = getConfig()
|
||||||
|
|
||||||
|
db = DBPools(config.databases)
|
||||||
async with db.sqlorContext('harnessed_agent') as sor:
|
async with db.sqlorContext('harnessed_agent') as sor:
|
||||||
filters = {'user_id': user_id}
|
filters = {'user_id': user_id}
|
||||||
if query:
|
if query:
|
||||||
@ -693,7 +708,9 @@ 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:
|
||||||
db = DBPools()
|
config = getConfig()
|
||||||
|
|
||||||
|
db = DBPools(config.databases)
|
||||||
async with db.sqlorContext('harnessed_agent') as sor:
|
async with db.sqlorContext('harnessed_agent') as sor:
|
||||||
if action == "view":
|
if action == "view":
|
||||||
filters = {'user_id': user_id, 'name': name}
|
filters = {'user_id': user_id, 'name': name}
|
||||||
@ -778,7 +795,9 @@ 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:
|
||||||
db = DBPools()
|
config = getConfig()
|
||||||
|
|
||||||
|
db = DBPools(config.databases)
|
||||||
async with db.sqlorContext('harnessed_agent') as sor:
|
async with db.sqlorContext('harnessed_agent') as sor:
|
||||||
if action == "create":
|
if action == "create":
|
||||||
# Create new remote skill configuration
|
# Create new remote skill configuration
|
||||||
@ -1184,7 +1203,9 @@ 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:
|
||||||
db = DBPools()
|
config = getConfig()
|
||||||
|
|
||||||
|
db = DBPools(config.databases)
|
||||||
async with db.sqlorContext('harnessed_agent') as sor:
|
async with db.sqlorContext('harnessed_agent') 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}
|
||||||
@ -1197,7 +1218,9 @@ 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:
|
||||||
db = DBPools()
|
config = getConfig()
|
||||||
|
|
||||||
|
db = DBPools(config.databases)
|
||||||
async with db.sqlorContext('harnessed_agent') as sor:
|
async with db.sqlorContext('harnessed_agent') as sor:
|
||||||
filters = {'user_id': user_id}
|
filters = {'user_id': user_id}
|
||||||
if workflow_id:
|
if workflow_id:
|
||||||
|
|||||||
@ -30,6 +30,11 @@ except ImportError:
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def getConfig():
|
||||||
|
class Config:
|
||||||
|
databases = None
|
||||||
|
return Config()
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class TaskDefinition:
|
class TaskDefinition:
|
||||||
"""Task definition structure for workflow execution"""
|
"""Task definition structure for workflow execution"""
|
||||||
@ -81,7 +86,9 @@ class HermesOrchestrator:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
workflow_id = str(uuid.uuid4())
|
workflow_id = str(uuid.uuid4())
|
||||||
db = DBPools()
|
config = getConfig()
|
||||||
|
|
||||||
|
db = DBPools(config.databases)
|
||||||
async with db.sqlorContext('harnessed_agent') as sor:
|
async with db.sqlorContext('harnessed_agent') as sor:
|
||||||
data = {
|
data = {
|
||||||
'id': workflow_id,
|
'id': workflow_id,
|
||||||
@ -114,7 +121,9 @@ class HermesOrchestrator:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
# Verify workflow exists and belongs to user
|
# Verify workflow exists and belongs to user
|
||||||
db = DBPools()
|
config = getConfig()
|
||||||
|
|
||||||
|
db = DBPools(config.databases)
|
||||||
async with db.sqlorContext('harnessed_agent') as sor:
|
async with db.sqlorContext('harnessed_agent') as sor:
|
||||||
workflows = await sor.R('hermes_workflows', {
|
workflows = await sor.R('hermes_workflows', {
|
||||||
'id': workflow_id,
|
'id': workflow_id,
|
||||||
@ -178,7 +187,9 @@ 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:
|
||||||
db = DBPools()
|
config = getConfig()
|
||||||
|
|
||||||
|
db = DBPools(config.databases)
|
||||||
async with db.sqlorContext('harnessed_agent') as sor:
|
async with db.sqlorContext('harnessed_agent') as sor:
|
||||||
# Load workflow
|
# Load workflow
|
||||||
workflows = await sor.R('hermes_workflows', {
|
workflows = await sor.R('hermes_workflows', {
|
||||||
@ -473,7 +484,9 @@ 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:
|
||||||
db = DBPools()
|
config = getConfig()
|
||||||
|
|
||||||
|
db = DBPools(config.databases)
|
||||||
async with db.sqlorContext('harnessed_agent') as sor:
|
async with db.sqlorContext('harnessed_agent') as sor:
|
||||||
data = {
|
data = {
|
||||||
'id': execution_id,
|
'id': execution_id,
|
||||||
@ -494,7 +507,9 @@ 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:
|
||||||
db = DBPools()
|
config = getConfig()
|
||||||
|
|
||||||
|
db = DBPools(config.databases)
|
||||||
async with db.sqlorContext('harnessed_agent') as sor:
|
async with db.sqlorContext('harnessed_agent') as sor:
|
||||||
end_time = datetime.now()
|
end_time = datetime.now()
|
||||||
data = {
|
data = {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user