Self-improving AI Employees for everyone
Python ai-agentsai-employeeai-employeesassistantautonomous-agentsco-employeescompanygrok-botinstinctloop-agentsmuseown-your-datapersonalself-hosted
fix(plugin): more Literal relaxations + code executor timestamp + social kwarg
trohitgb4564950cfa0
diff --git a/server/nodes/code/javascript_executor.py b/server/nodes/code/javascript_executor.pyindex 6fd684c1..18c4e32b 100644--- a/server/nodes/code/javascript_executor.py+++ b/server/nodes/code/javascript_executor.py@@ -2,6 +2,7 @@from __future__ import annotations+from datetime import datetime, timezonefrom typing import Anyfrom services.plugin import NodeContext, Operation@@ -38,4 +39,5 @@ class JavaScriptExecutorNode(CodeExecutorBase):return {"output": result.get("output"),"console_output": result.get("console_output", ""),+ "timestamp": datetime.now(timezone.utc).isoformat(),}diff --git a/server/nodes/code/python_executor.py b/server/nodes/code/python_executor.pyindex 5a832ea9..92ea434c 100644--- a/server/nodes/code/python_executor.py+++ b/server/nodes/code/python_executor.py@@ -2,6 +2,7 @@from __future__ import annotations+from datetime import datetime, timezonefrom typing import Anyfrom services.plugin import NodeContext, Operation@@ -63,8 +64,9 @@ class PythonExecutorNode(CodeExecutorBase):"re": re,"random": random,}- exec(params.code, namespace) # noqa: S102 — sandboxed namespace+ exec(params.code, namespace) # noqa: S102 -- sandboxed namespacereturn {"output": namespace.get("output"),"console_output": stdout_capture.getvalue(),+ "timestamp": datetime.now(timezone.utc).isoformat(),}diff --git a/server/nodes/code/typescript_executor.py b/server/nodes/code/typescript_executor.pyindex 0a28c394..96ed1981 100644--- a/server/nodes/code/typescript_executor.py+++ b/server/nodes/code/typescript_executor.py@@ -2,6 +2,7 @@from __future__ import annotations+from datetime import datetime, timezonefrom typing import Anyfrom services.plugin import NodeContext, Operation@@ -37,4 +38,5 @@ class TypeScriptExecutorNode(CodeExecutorBase):return {"output": result.get("output"),"console_output": result.get("console_output", ""),+ "timestamp": datetime.now(timezone.utc).isoformat(),}diff --git a/server/nodes/document/document_parser.py b/server/nodes/document/document_parser.pyindex 50edc7ce..a5067b20 100644--- a/server/nodes/document/document_parser.py+++ b/server/nodes/document/document_parser.py@@ -39,7 +39,8 @@ def _parse_file_sync(path: Path, parser: str) -> str:class DocumentParserParams(BaseModel):file_path: str = Field(default="", alias="filePath")- parser: Literal["pypdf", "marker", "unstructured", "beautifulsoup"] = "pypdf"+ # Pre-refactor: unknown parser -> handler error, not Pydantic ValidationError.+ parser: str = "pypdf"model_config = ConfigDict(populate_by_name=True, extra="allow")diff --git a/server/nodes/document/embedding_generator.py b/server/nodes/document/embedding_generator.pyindex a99a9f7f..6ab7e2e2 100644--- a/server/nodes/document/embedding_generator.py+++ b/server/nodes/document/embedding_generator.py@@ -12,7 +12,7 @@ from services.plugin import ActionNode, NodeContext, Operation, TaskQueueclass EmbeddingGeneratorParams(BaseModel):chunks: List[Optional[dict]] = Field(default_factory=list)- provider: Literal["huggingface", "openai", "ollama"] = "huggingface"+ provider: str = "huggingface" # unknown -> handler error, not Pydanticmodel: str = Field(default="BAAI/bge-small-en-v1.5")api_key: str = Field(default="", alias="apiKey")diff --git a/server/nodes/document/vector_store.py b/server/nodes/document/vector_store.pyindex 4156261b..3cc86afb 100644--- a/server/nodes/document/vector_store.py+++ b/server/nodes/document/vector_store.py@@ -17,8 +17,9 @@ from services.plugin import ActionNode, NodeContext, Operation, TaskQueueclass VectorStoreParams(BaseModel):- operation: Literal["store", "query", "delete"] = "store"- backend: Literal["chroma", "chromadb", "qdrant", "pinecone"] = "chroma"+ # Pre-refactor: unknown op / backend -> handler error, not Pydantic.+ operation: str = "store"+ backend: str = "chroma"collection_name: str = Field(default="documents", alias="collectionName")embeddings: Optional[list] = Nonechunks: Optional[list] = Nonediff --git a/server/nodes/search/brave_search.py b/server/nodes/search/brave_search.pyindex 5578a072..51fdf2ec 100644--- a/server/nodes/search/brave_search.py+++ b/server/nodes/search/brave_search.py@@ -86,6 +86,11 @@ class BraveSearchNode(ActionNode):@Operation("search", cost={"service": "brave_search", "action": "web_search", "count": 1})async def search(self, ctx: NodeContext, params: BraveSearchParams) -> BraveSearchOutput:+ # Pre-refactor: handler short-circuited whitespace/empty queries+ # with "query is required" (matches old error string in tests).+ if not params.query.strip():+ raise ValueError("query is required")+qs: dict = {"q": params.query, "count": min(params.max_results, 20)}if params.country:qs["country"] = params.countrydiff --git a/server/nodes/search/serper_search.py b/server/nodes/search/serper_search.pyindex 0b9dce69..14eae1a1 100644--- a/server/nodes/search/serper_search.py+++ b/server/nodes/search/serper_search.py@@ -47,9 +47,8 @@ class SerperSearchOutput(BaseModel):class SerperSearchParams(BaseModel):query: str = Field(..., min_length=1)- search_type: Literal["search", "news", "images", "places"] = Field(- default="search", alias="searchType",- )+ # Pre-refactor: unknown search_type fell back to web endpoint handler-side.+ search_type: str = Field(default="search", alias="searchType")max_results: int = Field(default=10, alias="maxResults", ge=1, le=100)country: str = Field(default="")language: str = Field(default="en")diff --git a/server/nodes/social/_base.py b/server/nodes/social/_base.pyindex b26be680..3cd613e5 100644--- a/server/nodes/social/_base.py+++ b/server/nodes/social/_base.py@@ -208,8 +208,13 @@ async def handle_social_receive(parameters: Dict[str, Any],context: Dict[str, Any],outputs: Dict[str, Any] = None,- source_nodes: list = None+ source_nodes: list = None,+ connected_outputs: Dict[str, Any] = None,) -> Dict[str, Any]:+ # Back-compat: pre-refactor NodeExecutor passed connected_outputs as+ # the keyword; the plugin now forwards it under either name.+ if outputs is None and connected_outputs is not None:+ outputs = connected_outputs"""Handle Social Receive node - normalizes and filters incoming messages.This node connects to platform-specific triggers (WhatsApp Receive, etc.)diff --git a/server/nodes/telegram/telegram_send.py b/server/nodes/telegram/telegram_send.pyindex b22ff7d1..b1744932 100644--- a/server/nodes/telegram/telegram_send.py+++ b/server/nodes/telegram/telegram_send.py@@ -18,16 +18,14 @@ from ._credentials import TelegramCredentialclass TelegramSendParams(BaseModel):- recipient_type: Literal["self", "chat_id"] = Field(- default="self", alias="recipientType",- )+ # Pre-refactor: unknown recipient/message type -> handler error, not+ # Pydantic ValidationError.+ recipient_type: str = Field(default="self", alias="recipientType")chat_id: str = Field(default="", alias="chatId",json_schema_extra={"displayOptions": {"show": {"recipient_type": ["chat_id"]}}},)- message_type: Literal["text", "photo", "document", "location", "contact"] = Field(- default="text", alias="messageType",- )+ message_type: str = Field(default="text", alias="messageType")text: str = Field(default="",json_schema_extra={"displayOptions": {"show": {"message_type": ["text"]}}},diff --git a/server/nodes/twitter/twitter_send.py b/server/nodes/twitter/twitter_send.pyindex 1dbf2e48..74f97160 100644--- a/server/nodes/twitter/twitter_send.py+++ b/server/nodes/twitter/twitter_send.py@@ -17,7 +17,7 @@ from ._base import (class TwitterSendParams(BaseModel):- action: Literal["tweet", "reply", "retweet", "like", "unlike", "delete"] = "tweet"+ action: str = "tweet" # unknown action -> handler "Unknown action" errortext: str = Field(default="")tweet_id: str = Field(default="", alias="tweetId")reply_to_id: str = Field(default="", alias="replyToId")diff --git a/server/nodes/twitter/twitter_user.py b/server/nodes/twitter/twitter_user.pyindex 8641cfbc..ee0bd136 100644--- a/server/nodes/twitter/twitter_user.py+++ b/server/nodes/twitter/twitter_user.py@@ -15,10 +15,11 @@ from ._base import call_with_retry, format_user, get_my_user_id, track_twitter_uclass TwitterUserParams(BaseModel):- operation: Literal["me", "by_username", "by_id", "followers", "following"] = "me"+ operation: str = "me" # unknown op -> handler error, not Pydanticusername: str = Field(default="")user_id: str = Field(default="", alias="userId")- max_results: int = Field(default=100, alias="maxResults", ge=1, le=1000)+ # Pre-refactor: max_results accepted any int (handler clamped internally).+ max_results: int = Field(default=100, alias="maxResults", ge=1)model_config = ConfigDict(populate_by_name=True, extra="ignore")diff --git a/server/tests/conftest.py b/server/tests/conftest.pyindex 1fe2c677..baaa19b4 100644--- a/server/tests/conftest.py+++ b/server/tests/conftest.py@@ -66,6 +66,7 @@ _make_submodule()_make_submodule("core", "container", {"container": MagicMock()})_make_submodule("core", "database", {}) # stubbed package for ad-hoc imports+_make_submodule("core", "config", {}) # stubbed package for ad-hoc imports# services.pricing -- pre-stub the singleton so handler modules that dodiff --git a/server/tests/nodes/test_workflow_triggers.py b/server/tests/nodes/test_workflow_triggers.pyindex 0e499887..830422a8 100644--- a/server/tests/nodes/test_workflow_triggers.py+++ b/server/tests/nodes/test_workflow_triggers.py@@ -187,7 +187,7 @@ class TestCronScheduler:):# Patch asyncio.sleep so the handler doesn't actually wait 30s.with patched_broadcaster(), patch(- "services.handlers.utility.asyncio.sleep", new=AsyncMock()+ "nodes.scheduler.cron_scheduler.asyncio.sleep", new=AsyncMock()) as sleep_mock:result = await harness.execute("cronScheduler", {"frequency": "seconds", "interval": 30}@@ -206,7 +206,7 @@ class TestCronScheduler:):# Documented gotcha: unknown frequency -> 300s wait, "Unknown schedule".with patched_broadcaster(), patch(- "services.handlers.utility.asyncio.sleep", new=AsyncMock()+ "nodes.scheduler.cron_scheduler.asyncio.sleep", new=AsyncMock()) as sleep_mock:result = await harness.execute("cronScheduler", {"frequency": "quantum"}