A-Mahla commited on
Commit
6e1d8dd
Β·
1 Parent(s): 09644e5

REVERT files (#7)

Browse files
.github/workflows/pre-commit.yml CHANGED
@@ -31,4 +31,4 @@ jobs:
31
 
32
  - name: Run pre-commit
33
  run: |
34
- uv run pre-commit run --all-files --show-diff-on-failure
 
31
 
32
  - name: Run pre-commit
33
  run: |
34
+ make pre-commit
Makefile CHANGED
@@ -1,4 +1,4 @@
1
- .PHONY: sync setup install dev-backend dev-frontend dev clean
2
 
3
  # Sync all dependencies (Python + Node.js)
4
  sync:
@@ -23,6 +23,14 @@ dev-frontend:
23
 
24
  pre-commit:
25
  uv run pre-commit run --all-files --show-diff-on-failure
 
 
 
 
 
 
 
 
26
 
27
  clean:
28
  find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
@@ -30,3 +38,42 @@ clean:
30
  find . -type d -name ".pytest_cache" -exec rm -rf {} + 2>/dev/null || true
31
  cd cua2-front && rm -rf node_modules dist 2>/dev/null || true
32
  @echo "βœ“ Cleaned!"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .PHONY: sync setup install dev-backend dev-frontend dev clean docker-build docker-run docker-stop docker-clean docker-logs
2
 
3
  # Sync all dependencies (Python + Node.js)
4
  sync:
 
23
 
24
  pre-commit:
25
  uv run pre-commit run --all-files --show-diff-on-failure
26
+ make test
27
+
28
+ # Run tests
29
+ test:
30
+ cd cua2-core && uv run pytest tests/ -v
31
+
32
+ test-coverage:
33
+ cd cua2-core && uv run pytest tests/ -v --cov=cua2_core --cov-report=html --cov-report=term
34
 
35
  clean:
36
  find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
 
38
  find . -type d -name ".pytest_cache" -exec rm -rf {} + 2>/dev/null || true
39
  cd cua2-front && rm -rf node_modules dist 2>/dev/null || true
40
  @echo "βœ“ Cleaned!"
41
+
42
+ # Docker commands
43
+ docker-build:
44
+ @echo "Building Docker image..."
45
+ make docker-stop
46
+ docker build -t cua2:latest .
47
+ @echo "βœ“ Docker image built successfully!"
48
+
49
+ docker-run:
50
+ @echo "Starting CUA2 container..."
51
+ @if [ -z "$$E2B_API_KEY" ]; then \
52
+ echo "Error: E2B_API_KEY environment variable is not set"; \
53
+ echo "Please set it with: export E2B_API_KEY=your-key"; \
54
+ exit 1; \
55
+ fi
56
+ @if [ -z "$$HF_TOKEN" ]; then \
57
+ echo "Error: HF_TOKEN environment variable is not set"; \
58
+ echo "Please set it with: export HF_TOKEN=your-token"; \
59
+ exit 1; \
60
+ fi
61
+ docker run -d --name cua2-app -p 7860:7860 \
62
+ -e E2B_API_KEY="$$E2B_API_KEY" \
63
+ -e HF_TOKEN="$$HF_TOKEN" \
64
+ cua2:latest
65
+ @echo "βœ“ Container started! Access at http://localhost:7860"
66
+
67
+ docker-stop:
68
+ @echo "Stopping CUA2 container..."
69
+ docker stop cua2-app || true
70
+ docker rm cua2-app || true
71
+ @echo "βœ“ Container stopped!"
72
+
73
+ docker-clean:
74
+ @echo "Removing CUA2 Docker images..."
75
+ docker rmi cua2:latest || true
76
+ @echo "βœ“ Docker images removed!"
77
+
78
+ docker-logs:
79
+ docker logs -f cua2-app
cua2-core/src/cua2_core/app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  from contextlib import asynccontextmanager
2
 
3
  from cua2_core.services.agent_service import AgentService
@@ -17,6 +18,9 @@ async def lifespan(app: FastAPI):
17
  # Startup: Initialize services
18
  print("Initializing services...")
19
 
 
 
 
20
  websocket_manager = WebSocketManager()
21
 
22
  sandbox_service = SandboxService()
 
1
+ import os
2
  from contextlib import asynccontextmanager
3
 
4
  from cua2_core.services.agent_service import AgentService
 
18
  # Startup: Initialize services
19
  print("Initializing services...")
20
 
21
+ if not os.getenv("HF_TOKEN"):
22
+ raise ValueError("HF_TOKEN is not set")
23
+
24
  websocket_manager = WebSocketManager()
25
 
26
  sandbox_service = SandboxService()
cua2-core/src/cua2_core/websocket/websocket_manager.py CHANGED
@@ -52,7 +52,7 @@ class WebSocketManager:
52
  try:
53
  await websocket.send_text(
54
  json.dumps(
55
- message.model_dump(mode="json", context={"actions_as_json": True})
56
  )
57
  )
58
  except Exception as e:
 
52
  try:
53
  await websocket.send_text(
54
  json.dumps(
55
+ message.model_dump(mode="json", context={"actions_as_json": False})
56
  )
57
  )
58
  except Exception as e: