agyqueue 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- agyqueue/__init__.py +1 -0
- agyqueue/client.py +129 -0
- agyqueue/config.py +72 -0
- agyqueue/dashboard.html +1155 -0
- agyqueue/mcp_server.py +438 -0
- agyqueue/models.py +38 -0
- agyqueue/notifications.py +187 -0
- agyqueue/storage.py +423 -0
- agyqueue/task_queue.py +111 -0
- agyqueue/worker.py +671 -0
- agyqueue-0.1.0.dist-info/METADATA +287 -0
- agyqueue-0.1.0.dist-info/RECORD +15 -0
- agyqueue-0.1.0.dist-info/WHEEL +5 -0
- agyqueue-0.1.0.dist-info/entry_points.txt +2 -0
- agyqueue-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agyqueue
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A pluggable, non-blocking asynchronous task queue and MCP server for AI Agents
|
|
5
|
+
Author: Jitendra Gupta
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.10
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
Requires-Dist: mcp>=1.0.0
|
|
13
|
+
Requires-Dist: redis>=5.0.0
|
|
14
|
+
Requires-Dist: starlette>=0.30.0
|
|
15
|
+
Requires-Dist: uvicorn>=0.20.0
|
|
16
|
+
Requires-Dist: psycopg2-binary>=2.9.0
|
|
17
|
+
|
|
18
|
+
# AgyQueue: Non-Blocking Asynchronous Task Execution for AI Agents
|
|
19
|
+
|
|
20
|
+

|
|
21
|
+
|
|
22
|
+
AgyQueue is a lightweight, non-blocking asynchronous task execution framework built for AI agents. It allows agents to offload long-running operations—such as code generation, compilation, testing, and validation—to background workers while keeping client conversation threads responsive.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## 🚀 Core Capabilities
|
|
27
|
+
|
|
28
|
+
1. **Asynchronous Task Offloading**: Agents submit tasks via MCP tool calls or REST API requests and immediately receive a `task_id`, returning execution control back to the user chat session.
|
|
29
|
+
2. **Resilience & Reconnection**: Task status is saved in a persistent database store, allowing clients to query progress or fetch final outputs even after network drops or worker crashes.
|
|
30
|
+
3. **Interactive Console UI**: Built-in dark mode dashboard that visualizes enqueued runs, progress bars, vertical event history timelines (e.g. `WorkflowExecutionStarted`, `WorkflowTaskScheduled`), and aggregated markdown reports.
|
|
31
|
+
4. **Well-Architected Architecture**:
|
|
32
|
+
* **Threaded Connection Pooling**: Uses `ThreadedConnectionPool` for PostgreSQL backend tasks, preventing socket exhaust under high concurrent query volumes.
|
|
33
|
+
* **Graceful Shutdown**: Catches `SIGTERM` / `SIGINT` signals, allowing workers to finish their active task run cleanly before eviction.
|
|
34
|
+
* **Workspace Isolation**: Spawns copy-on-write scratch worktree folders for subprocess executions, ensuring zero file-system cross-interference.
|
|
35
|
+
5. **Configurable Multi-Channel Notifications**: Real-time push notifications over Slack webhook and SMTP Email when tasks hit terminal states.
|
|
36
|
+
6. **Model Context Protocol (MCP) Support**: Serves as a standard stdio/sse MCP server compatible with Cursor, Claude Desktop, Claude Code, and Copilot CLI.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## 🛠️ Architecture
|
|
41
|
+
|
|
42
|
+
AgyQueue supports both hybrid cloud-agnostic execution flows and fully-managed Google Cloud configurations:
|
|
43
|
+
|
|
44
|
+
### 1. Cloud-Agnostic Core Flow
|
|
45
|
+

|
|
46
|
+
|
|
47
|
+
### 2. Google Cloud Native Production Deployment
|
|
48
|
+

|
|
49
|
+
|
|
50
|
+
### Google Cloud & Google AI Managed Services Mapping
|
|
51
|
+
|
|
52
|
+
When migrating from local development/fallback to production cloud scaling, AgyQueue integrates natively with Google Cloud managed services:
|
|
53
|
+
|
|
54
|
+
| Component | Dev Fallback | Production GCP Service |
|
|
55
|
+
| :--- | :--- | :--- |
|
|
56
|
+
| **Agent Reasoning Core** | Local LLM | **Vertex AI Gemini API** (Gemini 2.5 Flash / Pro) |
|
|
57
|
+
| **API Server Compute** | Local Python Process | **Google Cloud Run** (Event-driven serverless container) |
|
|
58
|
+
| **Worker Node Compute** | Local Daemon Process | **Google Kubernetes Engine (GKE)** or **Cloud Run Jobs** |
|
|
59
|
+
| **Task Message Broker** | SQLite (FIFO Table) | **Google Cloud Pub/Sub** or **Cloud Memorystore for Redis** |
|
|
60
|
+
| **Persistent Task Store** | SQLite Database | **Google Cloud SQL for PostgreSQL** or **Cloud Spanner** |
|
|
61
|
+
| **Workspace Repos** | Local Directory | **Google Cloud Storage (GCS)** Buckets |
|
|
62
|
+
| **Traffic Router** | Direct Port Binding | **Google Cloud Load Balancing** (HTTPS Layer 7 Router) |
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## 📦 Installation & Setup
|
|
67
|
+
|
|
68
|
+
### Install as Python Package (Local Development)
|
|
69
|
+
You can install AgyQueue locally in editable mode for development and testing:
|
|
70
|
+
```bash
|
|
71
|
+
python3 -m venv .venv
|
|
72
|
+
source .venv/bin/activate
|
|
73
|
+
pip install -e .
|
|
74
|
+
cp .env.example .env
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Install from PyPI
|
|
78
|
+
Once published, users can install AgyQueue directly from PyPI:
|
|
79
|
+
```bash
|
|
80
|
+
pip install agyqueue
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## 🏁 Quick Start
|
|
86
|
+
|
|
87
|
+
### 1. Run Standalone Dev Demo
|
|
88
|
+
Spins up a local server, enqueues an SRE compliance check and FastAPI code generator workflow, executes it in isolated directories, and outputs the final report:
|
|
89
|
+
```bash
|
|
90
|
+
python examples/demo.py
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### 2. Open the Web Console Dashboard
|
|
94
|
+
Start the standalone SSE server and background worker:
|
|
95
|
+
```bash
|
|
96
|
+
# Terminal 1: Start Server
|
|
97
|
+
export AGYQUEUE_TRANSPORT=sse
|
|
98
|
+
python -m agyqueue.mcp_server
|
|
99
|
+
|
|
100
|
+
# Terminal 2: Start Worker
|
|
101
|
+
python -m agyqueue.worker
|
|
102
|
+
```
|
|
103
|
+
Navigate to [http://localhost:8000/dashboard](http://localhost:8000/dashboard) to submit runs, inspect progress, and view timeline event history logs.
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## 📁 Examples & Client Integrations
|
|
108
|
+
|
|
109
|
+
The [examples/](file:///Users/jitendragupta/Documents/github-repo/agyqueue/examples/) folder contains detailed client scripts for every connection method:
|
|
110
|
+
|
|
111
|
+
* **Antigravity 2.0 SDK**: [examples/antigravity_agent_sdk.py](file:///Users/jitendragupta/Documents/github-repo/agyqueue/examples/antigravity_agent_sdk.py) shows how to bind tools to a `google.antigravity` agent.
|
|
112
|
+
* **Google ADK Agents**: [examples/google_adk_agent.py](file:///Users/jitendragupta/Documents/github-repo/agyqueue/examples/google_adk_agent.py) demonstrates tool binding in the `google.adk.agents` framework.
|
|
113
|
+
* **StdIO MCP Client**: [examples/mcp_stdio_client.py](file:///Users/jitendragupta/Documents/github-repo/agyqueue/examples/mcp_stdio_client.py) connects programmatically via stdin/stdout subprocesses.
|
|
114
|
+
* **SSE MCP Client**: [examples/mcp_sse_client.py](file:///Users/jitendragupta/Documents/github-repo/agyqueue/examples/mcp_sse_client.py) connects over network Server-Sent Events.
|
|
115
|
+
* **Direct REST SDK**: [examples/rest_client_sdk_demo.py](file:///Users/jitendragupta/Documents/github-repo/agyqueue/examples/rest_client_sdk_demo.py) performs calls using the lightweight `AgyQueueClient` Python client.
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## 🔌 Connecting to Agentic Frameworks
|
|
120
|
+
|
|
121
|
+
### 1. Google Agent Development Kit (ADK) & Agent Engine
|
|
122
|
+
The Google **ADK** allows Python-defined agents to be deployed to **Agent Engine** (Vertex AI Reasoning Engine). Import and register AgyQueue's functional tools directly:
|
|
123
|
+
|
|
124
|
+
```python
|
|
125
|
+
from google.adk.agents import Agent
|
|
126
|
+
from agyqueue.client import submit_async_task, check_task_progress, get_task_output, cancel_running_task
|
|
127
|
+
|
|
128
|
+
# Define the coordinator agent
|
|
129
|
+
orchestrator_agent = Agent(
|
|
130
|
+
name="deployment_coordinator",
|
|
131
|
+
model="gemini-2.5-flash",
|
|
132
|
+
instruction=(
|
|
133
|
+
"You coordinate SRE compliance checks and API code generation workloads. "
|
|
134
|
+
"Use submit_async_task to spawn background jobs. Do not wait for jobs in a loop. "
|
|
135
|
+
"Return the task_id to the user/orchestrator so that progress can be tracked asynchronously."
|
|
136
|
+
),
|
|
137
|
+
tools=[
|
|
138
|
+
submit_async_task,
|
|
139
|
+
check_task_progress,
|
|
140
|
+
get_task_output,
|
|
141
|
+
cancel_running_task
|
|
142
|
+
]
|
|
143
|
+
)
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### 2. Registering with Gemini Enterprise & Agent Registry
|
|
147
|
+
Expose the deployed URL to Gemini Enterprise using the `agents-cli` tool:
|
|
148
|
+
```bash
|
|
149
|
+
agents-cli publish gemini-enterprise \
|
|
150
|
+
--name "agyqueue-service" \
|
|
151
|
+
--description "Exposes asynchronous background task execution, cancellation, and progress tracking tools." \
|
|
152
|
+
--url "https://agyqueue-server-dev-xxxx-uc.a.run.app/sse" \
|
|
153
|
+
--type "mcp"
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## 💻 Local IDE Integration (MCP)
|
|
159
|
+
|
|
160
|
+
### Claude Desktop Configuration
|
|
161
|
+
Add the following to your `claude_desktop_config.json` (located in `~/Library/Application Support/Claude/` on macOS):
|
|
162
|
+
```json
|
|
163
|
+
{
|
|
164
|
+
"mcpServers": {
|
|
165
|
+
"agyqueue": {
|
|
166
|
+
"command": "python",
|
|
167
|
+
"args": ["-m", "agyqueue.mcp_server"],
|
|
168
|
+
"env": {
|
|
169
|
+
"PYTHONPATH": "/absolute/path/to/your/agyqueue/repo",
|
|
170
|
+
"AGYQUEUE_TRANSPORT": "stdio",
|
|
171
|
+
"AGYQUEUE_DB_PATH": "/absolute/path/to/your/agyqueue/repo/agyqueue.db"
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Cursor Configuration
|
|
179
|
+
1. Open Cursor Settings -> Features -> MCP.
|
|
180
|
+
2. Click **+ Add New MCP Server**.
|
|
181
|
+
3. Configure:
|
|
182
|
+
* **Name**: `AgyQueue`
|
|
183
|
+
* **Type**: `command`
|
|
184
|
+
* **Command**: `PYTHONPATH=. .venv/bin/python -m agyqueue.mcp_server` (relative to your repo path).
|
|
185
|
+
|
|
186
|
+
### VS Code Configuration (Cline / Roo Code Extensions)
|
|
187
|
+
Append the AgyQueue stdio server configuration to `cline_mcp_settings.json`:
|
|
188
|
+
```json
|
|
189
|
+
{
|
|
190
|
+
"mcpServers": {
|
|
191
|
+
"agyqueue": {
|
|
192
|
+
"command": "python",
|
|
193
|
+
"args": ["-m", "agyqueue.mcp_server"],
|
|
194
|
+
"env": {
|
|
195
|
+
"PYTHONPATH": "/absolute/path/to/your/agyqueue/repo",
|
|
196
|
+
"AGYQUEUE_TRANSPORT": "stdio",
|
|
197
|
+
"AGYQUEUE_DB_PATH": "/absolute/path/to/your/agyqueue/repo/agyqueue.db"
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Claude Code CLI Integration
|
|
205
|
+
Add AgyQueue as a local tool under the `"mcpServers"` dictionary in `~/.config/claude-code/mcp.json`.
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## 🌳 Multi-Agent Tree-Based Orchestration Pattern
|
|
210
|
+
|
|
211
|
+
AgyQueue natively supports **parent-child task aggregation**. When an orchestrator agent splits a large request into parallel child workloads, it submits the subtasks with a `parent_id` parameter:
|
|
212
|
+
|
|
213
|
+
1. **Task Submission**:
|
|
214
|
+
* The orchestrator spawns subagents by submitting child tasks referencing the parent ID.
|
|
215
|
+
* The parent task status transitions to `WAITING`.
|
|
216
|
+
2. **Worker Isolation**:
|
|
217
|
+
* Background workers pick up and execute child tasks in isolated workspaces (`git_worktree` or copy-on-write temp folders) in parallel.
|
|
218
|
+
3. **Automatic Resumption**:
|
|
219
|
+
* As soon as the final sibling completes, the worker recognizes that all siblings are done and automatically re-queues the parent task.
|
|
220
|
+
* The orchestrator wakes up, reads the logs of all completed subtasks, aggregates the results, and marks the parent task as `COMPLETED`.
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
## 🐳 Docker Compose Deployment (Redis + SSE Mode)
|
|
225
|
+
|
|
226
|
+
To run the complete system with Redis queues and PostgreSQL stores:
|
|
227
|
+
1. **Build and Run**:
|
|
228
|
+
```bash
|
|
229
|
+
docker compose up --build
|
|
230
|
+
```
|
|
231
|
+
2. **Verify over SSE**:
|
|
232
|
+
```bash
|
|
233
|
+
python examples/mcp_sse_client.py
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## ☁️ Cloud Deployment (Cloud Run & GKE)
|
|
239
|
+
|
|
240
|
+
For Google Cloud production environments, configuration templates are located in [deployment/](file:///Users/jitendragupta/Documents/github-repo/agyqueue/deployment/):
|
|
241
|
+
* **Cloud Run**: Serverless container setups with Memorystore Redis and Cloud SQL PostgreSQL.
|
|
242
|
+
* **GKE**: Scalable Kubernetes microservices with Horizontal Pod Autoscalers (HPA).
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
## 🔔 Slack & Email Notifications
|
|
247
|
+
|
|
248
|
+
To configure alerts on task completion or failure, set the following environment variables:
|
|
249
|
+
```bash
|
|
250
|
+
# Enable channels (comma-separated list)
|
|
251
|
+
export AGYQUEUE_NOTIFICATIONS="slack,email"
|
|
252
|
+
|
|
253
|
+
# 1. Slack Webhook Configuration
|
|
254
|
+
export SLACK_WEBHOOK_URL="https://example.com/slack-webhook-url"
|
|
255
|
+
|
|
256
|
+
# 2. Email SMTP Configuration
|
|
257
|
+
export SMTP_HOST="smtp.gmail.com"
|
|
258
|
+
export SMTP_PORT="587"
|
|
259
|
+
export SMTP_USER="your-email@gmail.com"
|
|
260
|
+
export SMTP_PASSWORD="your-app-password"
|
|
261
|
+
export SMTP_FROM="noreply@agyqueue.internal"
|
|
262
|
+
export SMTP_TO="recipient-alert-inbox@domain.com"
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
## 🚀 Publishing to PyPI
|
|
268
|
+
|
|
269
|
+
### Step 1: Install Build Tools
|
|
270
|
+
```bash
|
|
271
|
+
pip install --upgrade build twine
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### Step 2: Build the Distribution Package
|
|
275
|
+
```bash
|
|
276
|
+
python -m build
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### Step 3: Upload to PyPI
|
|
280
|
+
Run twine to securely publish to PyPI under your profile:
|
|
281
|
+
```bash
|
|
282
|
+
python -m twine upload dist/*
|
|
283
|
+
```
|
|
284
|
+
Once uploaded, anyone can install and run the AgyQueue CLI globally:
|
|
285
|
+
```bash
|
|
286
|
+
pip install agyqueue
|
|
287
|
+
```
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
agyqueue/__init__.py,sha256=Cw2u8BU9kJuaMrBNhUiwy_n9NabQSL97gDYd5tFXt40,34
|
|
2
|
+
agyqueue/client.py,sha256=ZzavScN7pCBNJkrcASKyqHxUBogR9mafFHKsRbZGY_U,5085
|
|
3
|
+
agyqueue/config.py,sha256=mHA6VRxoxcOuwM03CaY5IYwSiIXkqBtTjszgv_c3m-g,1966
|
|
4
|
+
agyqueue/dashboard.html,sha256=dsNAxdBWILkbfDY2vGYPXv5E2pcy52MzlGbnbQ1dWoA,42629
|
|
5
|
+
agyqueue/mcp_server.py,sha256=XNirkItZwjfIYYYWnNuEAKqkhp4-lSOqWkFwoEW8i4A,16674
|
|
6
|
+
agyqueue/models.py,sha256=CQq3FnRQZpda3kTgFq5LJjyhYW6Odmy0nAIOBAcFp94,1156
|
|
7
|
+
agyqueue/notifications.py,sha256=jcRvMtpJAce7CliyZEglPTykGuaWRWmDdiMDILo0J-Q,7476
|
|
8
|
+
agyqueue/storage.py,sha256=eZnbIt6dqJWO1-wpfUnWYL9dOkasC0GmVloYX1zqo-Y,15822
|
|
9
|
+
agyqueue/task_queue.py,sha256=y7jHuBswguTWyb8XkiAmzQ7z0BXavoEdyyRQefBIUKE,4261
|
|
10
|
+
agyqueue/worker.py,sha256=e0fIZLnUHp9RLyC1LqkB5IYJ8LGU-mAz5OaqHHruTyE,24382
|
|
11
|
+
agyqueue-0.1.0.dist-info/METADATA,sha256=ojKi4XpkRkg7GVaXDl14Q80YpldupxtnXZngrAcFDd8,11412
|
|
12
|
+
agyqueue-0.1.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
13
|
+
agyqueue-0.1.0.dist-info/entry_points.txt,sha256=OiRh55kSov3dY6UDwPeFHZ0U4PrdtsMvhVnKLy8vW1U,54
|
|
14
|
+
agyqueue-0.1.0.dist-info/top_level.txt,sha256=2T5VJ8b9nD7kRcz6TueRlCBdCNdgKkHak2QhmKsBgFU,9
|
|
15
|
+
agyqueue-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
agyqueue
|