Self-improving AI Employees for everyone
Python ai-agentsai-employeeai-employeesassistantautonomous-agentsco-employeescompanygrok-botinstinctloop-agentsmuseown-your-datapersonalself-hosted
fix: validate Temporal namespace readiness before starting worker
trohitg177b32b8c3b5
diff --git a/.github/workflows/test-install.yml b/.github/workflows/test-install.ymlindex b7b30e42..6c779993 100644--- a/.github/workflows/test-install.yml+++ b/.github/workflows/test-install.yml@@ -29,6 +29,9 @@ jobs:- name: Install uvrun: pip install uv+ - name: Install global CLI tools+ run: npm install -g temporal-server+- name: Install machinaos from npmrun: npm install -g machinaosdiff --git a/CLAUDE.md b/CLAUDE.mdindex a6991a50..4e2f93cc 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -1325,8 +1325,8 @@ TEMPORAL_NAMESPACE=defaultTEMPORAL_TASK_QUEUE=machina-tasks```-**Temporal Server** (npm package `temporal-server` v0.0.6):-The `temporal-server` npm package bundles the official Temporal CLI binary for local dev server with SQLite persistence.+**Temporal Server** (`temporal-server` global CLI):+The `temporal-server` npm package bundles the official Temporal CLI binary for local dev server with SQLite persistence. It is a **global CLI tool** (not a project dependency) — installed automatically by `scripts/install.js` and `scripts/build.js`, or manually via `npm install -g temporal-server`. The package manages its own binary download, data directory, and lifecycle.**Ports:**| Service | Port | URL |@@ -1336,7 +1336,7 @@ The `temporal-server` npm package bundles the official Temporal CLI binary for l| Web UI | 8080 | http://localhost:8080 || Metrics | 9090 | http://localhost:9090 |-**CLI commands** (globally installed `temporal-server`):+**CLI commands**:```bashtemporal-server start # Start in background (daemon mode)temporal-server api # Start in foreground (blocks)@@ -1346,16 +1346,13 @@ temporal-server restart # Restart servertemporal-server clean # Stop + remove bin/, data/```-**Global install** (required for CLI access from scripts):-```bash-npm install -g temporal-server-```-**Start script integration** (`scripts/start.js`):The start script checks `temporal-server status` via CLI before building the concurrently service list. If Temporal is already running, it skips adding it to concurrently (prevents `--kill-others` cascade when `temporal-server api` exits immediately with "Already running"). If not running, adds `npm:temporal:start` (`temporal-server api` in foreground mode) to the service list.**Port management**: Temporal manages its own ports (7233, 8233, 8080, 9090). These ports are NOT included in MachinaOS `allPorts` and are NOT killed during port-freeing. Temporal lifecycle is managed exclusively through its own CLI (`temporal-server start/stop/status`).+**Docker**: Uses official `temporalio/temporal:latest` image as a separate container — the npm package is not needed in Docker.+**Execution Routing** (`workflow.py`):1. If `TEMPORAL_ENABLED=true` and Temporal configured → `_execute_temporal()`2. Else if Redis available → `_execute_parallel()` (local parallel)diff --git a/package.json b/package.jsonindex 8590bc5b..68fb5508 100644--- a/package.json+++ b/package.json@@ -105,6 +105,7 @@"concurrently": "^9.2.1","cross-env": "^7.0.3","rimraf": "^6.0.1",+ "temporal-server": "^0.0.6","whatsapp-rpc": "^0.0.12"}}diff --git a/server/services/temporal/client.py b/server/services/temporal/client.pyindex 9943dd49..8b0137b8 100644--- a/server/services/temporal/client.py+++ b/server/services/temporal/client.py@@ -5,6 +5,7 @@ Manages the Temporal client connection lifecycle with retry support.import asynciofrom typing import Optional+from temporalio.api.workflowservice.v1 import DescribeNamespaceRequestfrom temporalio.client import Clientfrom temporalio.runtime import LoggingConfig, Runtime, TelemetryConfig@@ -58,11 +59,17 @@ class TemporalClientWrapper:server_address=self.server_address,namespace=self.namespace,)- self._client = await Client.connect(+ client = await Client.connect(self.server_address,namespace=self.namespace,runtime=self._runtime,)+ # Verify namespace is ready (gRPC port may accept connections+ # before the server finishes registering namespaces)+ await client.service_client.workflow_service.describe_namespace(+ DescribeNamespaceRequest(namespace=self.namespace)+ )+ self._client = clientprint(f"[Temporal] Connected to {self.server_address}", flush=True)logger.info("Connected to Temporal server")return self._client