open-swarm 0.1.1743362777__py3-none-any.whl → 0.1.1743364176__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: open-swarm
3
- Version: 0.1.1743362777
3
+ Version: 0.1.1743364176
4
4
  Summary: Open Swarm: Orchestrating AI Agent Swarms with Django
5
5
  Project-URL: Homepage, https://github.com/yourusername/open-swarm
6
6
  Project-URL: Documentation, https://github.com/yourusername/open-swarm/blob/main/README.md
@@ -40,6 +40,7 @@ Requires-Dist: google-auth-oauthlib>=1.2.1
40
40
  Requires-Dist: gunicorn>=21.0.0
41
41
  Requires-Dist: httpx<0.26.0,>=0.25.2
42
42
  Requires-Dist: jinja2>=3.1.6
43
+ Requires-Dist: jmespath>=1.0.1
43
44
  Requires-Dist: openai-agents>=0.0.1
44
45
  Requires-Dist: openai<2.0.0,>=1.3.0
45
46
  Requires-Dist: platformdirs>=4.0.0
@@ -92,6 +93,11 @@ Description-Content-Type: text/markdown
92
93
 
93
94
  **Open Swarm** is a Python framework for creating, managing, and deploying autonomous agent swarms. It leverages the `openai-agents` library for core agent functionality and provides a structured way to build complex, multi-agent workflows using **Blueprints**.
94
95
 
96
+ Open Swarm can be used in two primary ways:
97
+
98
+ 1. **As a CLI Utility (`swarm-cli`):** Manage, run, and install blueprints directly on your local machine. Ideal for personal use, testing, and creating standalone agent tools. (Recommended installation: PyPI)
99
+ 2. **As an API Service (`swarm-api`):** Deploy a web server that exposes your blueprints via an OpenAI-compatible REST API. Ideal for integrations, web UIs, and shared access. (Recommended deployment: Docker)
100
+
95
101
  ---
96
102
 
97
103
  ## Core Concepts
@@ -105,97 +111,160 @@ Description-Content-Type: text/markdown
105
111
 
106
112
  ---
107
113
 
108
- ## Quickstart (Docker - Recommended)
114
+ ## Quickstart 1: Using `swarm-cli` Locally (via PyPI)
109
115
 
110
- This is the easiest and recommended way to get started, especially for deploying the API service.
116
+ This is the recommended way to use `swarm-cli` for managing and running blueprints on your local machine.
111
117
 
112
118
  **Prerequisites:**
113
- * Docker ([Install Docker](https://docs.docker.com/engine/install/))
114
- * Docker Compose ([Install Docker Compose](https://docs.docker.com/compose/install/))
119
+ * Python 3.10+
120
+ * `pip` (Python package installer)
115
121
 
116
122
  **Steps:**
117
123
 
118
- 1. **Clone the Repository:**
124
+ 1. **Install `open-swarm` from PyPI:**
119
125
  ```bash
120
- git clone https://github.com/matthewhand/open-swarm.git
121
- cd open-swarm
126
+ pip install open-swarm
122
127
  ```
128
+ *(Using a virtual environment is recommended: `python -m venv .venv && source .venv/bin/activate`)*
123
129
 
124
- 2. **Configure Environment:**
125
- * Copy the example environment file:
130
+ 2. **Initial Configuration (First Run):**
131
+ * The first time you run a `swarm-cli` command that requires configuration (like `run` or `config`), it will automatically create a default `swarm_config.json` at `~/.config/swarm/swarm_config.json` if one doesn't exist.
132
+ * You **must** set the required environment variables (like `OPENAI_API_KEY`) in your shell for the configuration to work. Create a `.env` file in your working directory or export them:
126
133
  ```bash
127
- cp .env.example .env
134
+ export OPENAI_API_KEY="sk-..."
135
+ # Add other keys as needed (GROQ_API_KEY, etc.)
128
136
  ```
129
- * Edit `.env` and add your necessary API keys (e.g., `OPENAI_API_KEY`).
137
+ * You can customize the configuration further using `swarm-cli config` commands (see `USERGUIDE.md`).
130
138
 
131
- 3. **Configure Docker Compose Overrides (Optional but Recommended):**
132
- * Copy the override example:
139
+ 3. **Add a Blueprint:**
140
+ * Download or create a blueprint file (e.g., `my_blueprint.py`). Example blueprints are available in the [project repository](https://github.com/matthewhand/open-swarm/tree/main/src/swarm/blueprints).
141
+ * Add it using `swarm-cli`:
133
142
  ```bash
134
- cp docker-compose.override.yaml.example docker-compose.override.yaml
135
- ```
136
- * Edit `docker-compose.override.yaml` to:
137
- * Mount any local directories containing custom blueprints you want the API server to access (e.g., uncomment and adjust the `./my_custom_blueprints:/app/custom_blueprints:ro` line).
138
- * Make any other necessary adjustments (ports, environment variables, etc.).
143
+ # Example: Adding a downloaded blueprint file
144
+ swarm-cli add ./path/to/downloaded/blueprint_echocraft.py
139
145
 
140
- 4. **Start the Service:**
141
- ```bash
142
- docker compose up -d
143
- ```
144
- This will build the image (if not already pulled/built) and start the `open-swarm` service, exposing the API on port 8000 (or the port specified in your `.env`/override).
146
+ # Example: Adding a directory containing a blueprint
147
+ swarm-cli add ./my_custom_blueprints/agent_smith --name agent_smith
148
+ ```
145
149
 
146
- 5. **Verify API:**
147
- * Check the available models (blueprints):
150
+ 4. **Run the Blueprint:**
151
+ * **Single Instruction:**
148
152
  ```bash
149
- curl http://localhost:8000/v1/models
153
+ swarm-cli run echocraft --instruction "Hello from CLI!"
150
154
  ```
151
- * Send a chat completion request:
155
+ * **Interactive Mode:**
152
156
  ```bash
153
- curl http://localhost:8000/v1/chat/completions \
154
- -H "Content-Type: application/json" \
155
- -d '{
156
- "model": "echocraft",
157
- "messages": [{"role": "user", "content": "Hello Docker!"}]
158
- }'
157
+ swarm-cli run echocraft
158
+ # Now you can chat with the blueprint interactively
159
159
  ```
160
- *(Replace `echocraft` with a blueprint name available in your mounted volumes or the base image).*
160
+
161
+ 5. **(Optional) Install as Command:**
162
+ ```bash
163
+ swarm-cli install echocraft
164
+ # Now run (ensure ~/.local/share/swarm/bin is in your PATH):
165
+ echocraft --instruction "I am a command now!"
166
+ ```
161
167
 
162
168
  ---
163
169
 
164
- ## Usage Modes
170
+ ## Quickstart 2: Deploying `swarm-api` Service (via Docker)
171
+
172
+ This section covers deploying the API service using Docker.
173
+
174
+ ### Option A: Docker Compose (Recommended for Flexibility)
175
+
176
+ This method uses `docker-compose.yaml` and is best if you need to customize volumes, environment variables easily, or manage related services (like Redis).
177
+
178
+ **Prerequisites:**
179
+ * Docker ([Install Docker](https://docs.docker.com/engine/install/))
180
+ * Docker Compose ([Install Docker Compose](https://docs.docker.com/compose/install/))
181
+ * Git
182
+
183
+ **Steps:**
184
+
185
+ 1. **Clone the Repository:** (Needed for `docker-compose.yaml` and config files)
186
+ ```bash
187
+ git clone https://github.com/matthewhand/open-swarm.git
188
+ cd open-swarm
189
+ ```
190
+
191
+ 2. **Configure Environment:**
192
+ * Copy `cp .env.example .env` and edit `.env` with your API keys (e.g., `OPENAI_API_KEY`, `SWARM_API_KEY`).
193
+
194
+ 3. **Prepare Blueprints & Config:**
195
+ * Place blueprints in `./blueprints`.
196
+ * Ensure `./swarm_config.json` exists and is configured.
197
+
198
+ 4. **Configure Overrides (Optional):**
199
+ * Copy `cp docker-compose.override.yaml.example docker-compose.override.yaml`.
200
+ * Edit the override file to mount additional volumes, change ports, etc.
201
+
202
+ 5. **Start the Service:**
203
+ ```bash
204
+ docker compose up -d
205
+ ```
206
+
207
+ 6. **Verify API:** (Default port 8000)
208
+ * Models: `curl http://localhost:8000/v1/models`
209
+ * Chat: `curl http://localhost:8000/v1/chat/completions -H "Content-Type: application/json" -d '{"model": "echocraft", ...}'` (Add `-H "Authorization: Bearer <key>"` if needed).
210
+
211
+ ### Option B: Direct `docker run` (Simpler for Single Container)
212
+
213
+ This method runs the pre-built image directly from Docker Hub. Good for quick tests or simple deployments without cloning the repo. Customization requires careful use of `-v` (volume) and `-e` (environment) flags.
214
+
215
+ **Prerequisites:**
216
+ * Docker ([Install Docker](https://docs.docker.com/engine/install/))
217
+
218
+ **Steps:**
165
219
 
166
- Open Swarm offers several ways to interact with your blueprints:
220
+ 1. **Prepare Local Files (If Customizing):**
221
+ * Create a directory for your blueprints (e.g., `~/my_swarm_blueprints`).
222
+ * Create your `swarm_config.json` file locally (e.g., `~/my_swarm_config.json`).
223
+ * Create a `.env` file locally (e.g., `~/swarm.env`) with your API keys (`OPENAI_API_KEY`, `SWARM_API_KEY`, etc.).
167
224
 
168
- 1. **Run via `swarm-api` (OpenAI-Compatible REST API):**
169
- * **How:** Start the Django server (`uv run python manage.py runserver` or via Docker as shown above).
170
- * **What:** Exposes blueprints listed in `settings.BLUEPRINT_DIRECTORY` (within the Docker container, this typically includes `/app/blueprints` and any volumes mounted in the override file) via `/v1/models` and `/v1/chat/completions`.
171
- * **Auth:** If `SWARM_API_KEY` is set in `.env`, requests require an `Authorization: Bearer <your_key>` header. Otherwise, access is anonymous.
172
- * **Security:** **Warning:** Running with anonymous access, especially when bound to `0.0.0.0`, can be insecure if blueprints have access to sensitive operations (filesystem, shell commands). **Setting `SWARM_API_KEY` is highly recommended for non-local deployments.**
173
- * **(TODO) Web UI:** A future mode will integrate a simple web chat interface with the API server.
225
+ 2. **Run the Container:**
226
+ ```bash
227
+ docker run -d \
228
+ --name open-swarm-api \
229
+ -p 8000:8000 \
230
+ --env-file ~/swarm.env \
231
+ -v ~/my_swarm_blueprints:/app/blueprints:ro \
232
+ -v ~/my_swarm_config.json:/app/swarm_config.json:ro \
233
+ -v open_swarm_db:/app/db.sqlite3 \
234
+ --restart unless-stopped \
235
+ mhand79/open-swarm:latest
236
+ ```
237
+ * `-d`: Run detached (in background).
238
+ * `--name`: Assign a name to the container.
239
+ * `-p 8000:8000`: Map host port 8000 to container port 8000 (adjust if needed).
240
+ * `--env-file`: Load environment variables from your local file.
241
+ * `-v ...:/app/blueprints:ro`: Mount your local blueprints directory (read-only). **Required** if you want to use custom blueprints.
242
+ * `-v ...:/app/swarm_config.json:ro`: Mount your local config file (read-only). **Required** for custom LLM/MCP settings.
243
+ * `-v open_swarm_db:/app/db.sqlite3`: Use a named Docker volume for the database to persist data.
244
+ * `--restart unless-stopped`: Automatically restart the container unless manually stopped.
245
+ * `mhand79/open-swarm:latest`: The image name on Docker Hub.
246
+
247
+ 3. **Verify API:** (Same as Docker Compose)
248
+ * Models: `curl http://localhost:8000/v1/models`
249
+ * Chat: `curl http://localhost:8000/v1/chat/completions ...` (Add `-H "Authorization: Bearer <key>"` if needed).
174
250
 
175
- 2. **Run via `swarm-cli run`:**
176
- * **How:** `swarm-cli run <blueprint_name> --instruction "Your single instruction"`
177
- * **What:** Executes a blueprint managed by `swarm-cli` (located in `~/.local/share/swarm/blueprints/`) directly in the terminal. Uses configuration from `~/.config/swarm/swarm_config.json`.
178
- * **Interactive Mode:** If you omit the `--instruction` argument (`swarm-cli run <blueprint_name>`), it will enter an interactive chat mode in the terminal.
179
- * **Use Case:** Good for testing, debugging, interactive sessions, or running specific tasks locally without the API overhead.
251
+ ---
180
252
 
181
- 3. **Run via `swarm-cli install`:**
182
- * **How:** `swarm-cli install <blueprint_name>`, then run `<blueprint_name> --instruction "..."`
183
- * **What:** Creates a standalone executable for a managed blueprint using PyInstaller and places it in the user's binary directory (e.g., `~/.local/bin/` or similar, ensure it's in your `PATH`).
184
- * **Use Case:** Convenient for frequently used blueprints that act like regular command-line tools.
253
+ ## Usage Modes Summary
185
254
 
186
- 4. **Direct Python Execution:**
187
- * **How:** `uv run python /path/to/your/blueprint_file.py --instruction "..."`
188
- * **What:** Runs a specific blueprint Python file directly. Requires manual handling of configuration loading and dependencies.
189
- * **Use Case:** Primarily for development and testing of a single blueprint file outside the managed environment.
255
+ * **`swarm-api` (via Docker or `manage.py runserver`):** Exposes blueprints as an OpenAI-compatible REST API. Ideal for integrations. Requires `SWARM_API_KEY` for security in non-local deployments.
256
+ * **`swarm-cli run` (via PyPI install):** Executes managed blueprints locally, either with a single instruction or in interactive chat mode. Good for testing and local tasks.
257
+ * **`swarm-cli install` (via PyPI install):** Creates standalone command-line executables from managed blueprints.
258
+ * **Direct Python Execution (via Git clone):** Running `uv run python <blueprint_file.py>` is mainly for development and testing individual files.
190
259
 
191
260
  ---
192
261
 
193
262
  ## Further Documentation
194
263
 
195
- This README provides a high-level overview and quickstart. For more detailed information, please refer to:
264
+ This README provides a high-level overview and quickstart guides. For more detailed information, please refer to:
196
265
 
197
- * **User Guide (`USERGUIDE.md`):** Detailed instructions on using `swarm-cli` commands for managing blueprints and configuration.
198
- * **Development Guide (`DEVELOPMENT.md`):** Information for contributors and developers, including architecture details, testing strategies, project layout, and advanced topics like XDG paths and blueprint creation.
266
+ * **User Guide (`USERGUIDE.md`):** Detailed instructions on using `swarm-cli` commands for managing blueprints and configuration locally.
267
+ * **Development Guide (`DEVELOPMENT.md`):** Information for contributors and developers, including architecture details, testing strategies, project layout, API details, and advanced topics.
199
268
  * **Example Blueprints (`src/swarm/blueprints/README.md`):** A list and description of the example blueprints included with the framework, showcasing various features and integration patterns.
200
269
 
201
270
  ---
@@ -253,8 +253,8 @@ swarm/views/message_views.py,sha256=sDUnXyqKXC8WwIIMAlWf00s2_a2T9c75Na5FvYMJwBM,
253
253
  swarm/views/model_views.py,sha256=aAbU4AZmrOTaPeKMWtoKK7FPYHdaN3Zbx55JfKzYTRY,2937
254
254
  swarm/views/utils.py,sha256=geX3Z5ZDKFYyXYBMilc-4qgOSjhujK3AfRtvbXgFpXk,3643
255
255
  swarm/views/web_views.py,sha256=ExQQeJpZ8CkLZQC_pXKOOmdnEy2qR3wEBP4LLp27DPU,7404
256
- open_swarm-0.1.1743362777.dist-info/METADATA,sha256=q3l34AHcBOzw_80TKYl3NG_RgoJMOOiwwxJ8pEN1PH8,11145
257
- open_swarm-0.1.1743362777.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
258
- open_swarm-0.1.1743362777.dist-info/entry_points.txt,sha256=LudR3dBqGnglrE1n2zAeWo38Ck0m57sKPW36KfK-pzo,71
259
- open_swarm-0.1.1743362777.dist-info/licenses/LICENSE,sha256=BU9bwRlnOt_JDIb6OT55Q4leLZx9RArDLTFnlDIrBEI,1062
260
- open_swarm-0.1.1743362777.dist-info/RECORD,,
256
+ open_swarm-0.1.1743364176.dist-info/METADATA,sha256=M2N0GZ6eCr-zftMs_AnTpgGi8oxMLXyGci0VOf2-aMA,13680
257
+ open_swarm-0.1.1743364176.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
258
+ open_swarm-0.1.1743364176.dist-info/entry_points.txt,sha256=LudR3dBqGnglrE1n2zAeWo38Ck0m57sKPW36KfK-pzo,71
259
+ open_swarm-0.1.1743364176.dist-info/licenses/LICENSE,sha256=BU9bwRlnOt_JDIb6OT55Q4leLZx9RArDLTFnlDIrBEI,1062
260
+ open_swarm-0.1.1743364176.dist-info/RECORD,,