Files
ghmkandClaude Opus 4.6 d5bd8521f3 comfyui-agentazall v2.0: 20 nodes, 76 tests, 7 demo workflows
New nodes (5):
- Relay: local message delivery between agents (outbox→inbox)
- ChatHistory: multi-turn conversation persistence across runs
- PromptTemplate: {a}/{b}/{c}/{d} variable substitution
- ConditionalRouter: keyword/regex routing with matched/unmatched outputs
- BatchSplitter: split text into numbered sections by delimiter

Fixed nodes (3):
- TextCombine: removed forceInput, text_a/text_b now typeable widgets
- Remember: removed forceInput on text, now typeable widget
- Send: removed forceInput on body, now typeable widget

Demo workflows (7):
1. Character Design - art director with memory for consistent characters
2. Novel Crafter - writer+editor dual-agent with Relay message delivery
3. Story to Video - director breaks story into scenes with BatchSplitter
4. Multi-Turn Chat - persistent conversation history across queue runs
5. Agent Debate - two agents argue via message passing (FOR vs AGAINST)
6. World Builder - game world with PromptTemplate for locations/characters
7. RAG Pipeline - store docs, search, answer with ConditionalRouter error handling

76 tests all passing (46 original + 30 new).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-14 10:41:23 +01:00

110 lines
3.2 KiB
Python

"""Shared fixtures for ComfyUI AgentAZAll node tests."""
import hashlib
import json
import os
import time
from datetime import datetime
from pathlib import Path
import pytest
@pytest.fixture
def agent_config(tmp_path):
"""Create a temporary agent config and directory structure.
Returns the config dict ready for use with all nodes.
"""
agent_name = "test-agent@localhost"
mailbox_dir = str(tmp_path / "mailboxes")
agent_key = hashlib.sha256(
f"{agent_name}:{os.urandom(16).hex()}:{time.time()}".encode()
).hexdigest()[:32]
cfg = {
"agent_name": agent_name,
"agent_key": agent_key,
"allow_memory_sharing": False,
"mailbox_dir": mailbox_dir,
"transport": "agenttalk",
"sync_interval": 10,
"log_file": str(tmp_path / "logs" / "agentazall.log"),
"email": {},
"ftp": {},
"agenttalk": {"server": "", "token": ""},
"address_filter": {"mode": "blacklist", "blacklist": [], "whitelist": [], "log_blocked": True},
"relays": [],
"email_accounts": [],
"ftp_servers": [],
}
# Write config.json
config_path = tmp_path / "config.json"
with open(config_path, "w", encoding="utf-8") as f:
json.dump(cfg, f, indent=2)
cfg["_config_path"] = str(config_path)
# Create directory structure
from agentazall.helpers import ensure_dirs, agent_base
ensure_dirs(cfg)
# Store agent key
base = agent_base(cfg)
key_file = base / ".agent_key"
key_file.write_text(json.dumps({
"agent": agent_name,
"key": agent_key,
"created": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
"allow_memory_sharing": False,
}, indent=2), encoding="utf-8")
return cfg
@pytest.fixture
def dual_agent_config(tmp_path):
"""Create two agent configs sharing the same mailbox_dir.
Returns (cfg_alpha, cfg_beta) tuple.
"""
mailbox_dir = str(tmp_path / "mailboxes")
configs = []
for name in ("alpha@localhost", "beta@localhost"):
agent_key = hashlib.sha256(
f"{name}:{os.urandom(16).hex()}".encode()
).hexdigest()[:32]
cfg = {
"agent_name": name,
"agent_key": agent_key,
"allow_memory_sharing": False,
"mailbox_dir": mailbox_dir,
"transport": "agenttalk",
"sync_interval": 10,
"log_file": str(tmp_path / "logs" / "agentazall.log"),
"email": {},
"ftp": {},
"agenttalk": {"server": "", "token": ""},
"address_filter": {"mode": "blacklist", "blacklist": [], "whitelist": [], "log_blocked": True},
"relays": [],
"email_accounts": [],
"ftp_servers": [],
"_config_path": str(tmp_path / f"config_{name.split('@')[0]}.json"),
}
from agentazall.helpers import ensure_dirs, agent_base
ensure_dirs(cfg)
base = agent_base(cfg)
(base / ".agent_key").write_text(json.dumps({
"agent": name, "key": agent_key,
"created": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
"allow_memory_sharing": False,
}, indent=2), encoding="utf-8")
configs.append(cfg)
return tuple(configs)