navaia-forge 0.1.0__tar.gz
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.
- navaia_forge-0.1.0/.gitignore +46 -0
- navaia_forge-0.1.0/LICENSE +21 -0
- navaia_forge-0.1.0/PKG-INFO +135 -0
- navaia_forge-0.1.0/README.md +102 -0
- navaia_forge-0.1.0/navaia_forge/__init__.py +155 -0
- navaia_forge-0.1.0/navaia_forge/client.py +112 -0
- navaia_forge-0.1.0/navaia_forge/errors.py +83 -0
- navaia_forge-0.1.0/navaia_forge/http.py +184 -0
- navaia_forge-0.1.0/navaia_forge/resources/__init__.py +27 -0
- navaia_forge-0.1.0/navaia_forge/resources/_base.py +32 -0
- navaia_forge-0.1.0/navaia_forge/resources/agents.py +121 -0
- navaia_forge-0.1.0/navaia_forge/resources/auth.py +87 -0
- navaia_forge-0.1.0/navaia_forge/resources/conversations.py +55 -0
- navaia_forge-0.1.0/navaia_forge/resources/integrations.py +89 -0
- navaia_forge-0.1.0/navaia_forge/resources/knowledge.py +167 -0
- navaia_forge-0.1.0/navaia_forge/resources/observability.py +95 -0
- navaia_forge-0.1.0/navaia_forge/resources/setup.py +45 -0
- navaia_forge-0.1.0/navaia_forge/resources/tasks.py +92 -0
- navaia_forge-0.1.0/navaia_forge/resources/templates.py +175 -0
- navaia_forge-0.1.0/navaia_forge/resources/tools.py +87 -0
- navaia_forge-0.1.0/navaia_forge/resources/workforces.py +114 -0
- navaia_forge-0.1.0/navaia_forge/types.py +670 -0
- navaia_forge-0.1.0/navaia_forge/websocket.py +243 -0
- navaia_forge-0.1.0/pyproject.toml +69 -0
- navaia_forge-0.1.0/tests/__init__.py +0 -0
- navaia_forge-0.1.0/tests/conftest.py +26 -0
- navaia_forge-0.1.0/tests/resources/__init__.py +0 -0
- navaia_forge-0.1.0/tests/resources/test_agents.py +177 -0
- navaia_forge-0.1.0/tests/resources/test_auth.py +124 -0
- navaia_forge-0.1.0/tests/resources/test_conversations.py +106 -0
- navaia_forge-0.1.0/tests/resources/test_edges.py +85 -0
- navaia_forge-0.1.0/tests/resources/test_integrations.py +103 -0
- navaia_forge-0.1.0/tests/resources/test_knowledge.py +168 -0
- navaia_forge-0.1.0/tests/resources/test_observability.py +162 -0
- navaia_forge-0.1.0/tests/resources/test_setup.py +63 -0
- navaia_forge-0.1.0/tests/resources/test_tasks.py +156 -0
- navaia_forge-0.1.0/tests/resources/test_templates.py +186 -0
- navaia_forge-0.1.0/tests/resources/test_tools.py +123 -0
- navaia_forge-0.1.0/tests/resources/test_workforces.py +112 -0
- navaia_forge-0.1.0/tests/test_errors.py +51 -0
- navaia_forge-0.1.0/tests/test_http.py +75 -0
- navaia_forge-0.1.0/tests/test_public_surface.py +47 -0
- navaia_forge-0.1.0/tests/test_websocket.py +73 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# ── Python ──────────────────────────────────────────────────
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.egg-info/
|
|
6
|
+
*.egg
|
|
7
|
+
dist/
|
|
8
|
+
build/
|
|
9
|
+
.eggs/
|
|
10
|
+
*.whl
|
|
11
|
+
.venv/
|
|
12
|
+
venv/
|
|
13
|
+
env/
|
|
14
|
+
.mypy_cache/
|
|
15
|
+
.ruff_cache/
|
|
16
|
+
.pytest_cache/
|
|
17
|
+
htmlcov/
|
|
18
|
+
.coverage
|
|
19
|
+
.coverage.*
|
|
20
|
+
*.cover
|
|
21
|
+
|
|
22
|
+
# ── Node.js / TypeScript ───────────────────────────────────
|
|
23
|
+
node_modules/
|
|
24
|
+
dist/
|
|
25
|
+
*.tsbuildinfo
|
|
26
|
+
.turbo/
|
|
27
|
+
.next/
|
|
28
|
+
coverage/
|
|
29
|
+
*.js.map
|
|
30
|
+
|
|
31
|
+
# ── IDE / Editor ───────────────────────────────────────────
|
|
32
|
+
.vscode/
|
|
33
|
+
.idea/
|
|
34
|
+
*.swp
|
|
35
|
+
*.swo
|
|
36
|
+
*~
|
|
37
|
+
.DS_Store
|
|
38
|
+
Thumbs.db
|
|
39
|
+
|
|
40
|
+
# ── Environment / Secrets ──────────────────────────────────
|
|
41
|
+
.env
|
|
42
|
+
.env.*
|
|
43
|
+
!.env.example
|
|
44
|
+
*.pem
|
|
45
|
+
*.key
|
|
46
|
+
credentials.json
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 NavaiaSolutions
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: navaia-forge
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python SDK for the NavaiaForge AI workforce platform
|
|
5
|
+
Project-URL: Homepage, https://github.com/NavaiaSolutions/navaia-forge-sdk
|
|
6
|
+
Project-URL: Repository, https://github.com/NavaiaSolutions/navaia-forge-sdk
|
|
7
|
+
Project-URL: Documentation, https://github.com/NavaiaSolutions/navaia-forge-sdk#readme
|
|
8
|
+
Project-URL: Issues, https://github.com/NavaiaSolutions/navaia-forge-sdk/issues
|
|
9
|
+
Author-email: Navaia <dev@navaia.com>
|
|
10
|
+
License: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: agents,ai,orchestration,sdk,workforce
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Requires-Dist: httpx>=0.27.0
|
|
23
|
+
Requires-Dist: pydantic>=2.6
|
|
24
|
+
Requires-Dist: websockets>=12.0
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: mypy>=1.13.0; extra == 'dev'
|
|
27
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
|
|
28
|
+
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
|
|
29
|
+
Requires-Dist: pytest-httpx>=0.30.0; extra == 'dev'
|
|
30
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
31
|
+
Requires-Dist: ruff>=0.8.0; extra == 'dev'
|
|
32
|
+
Description-Content-Type: text/markdown
|
|
33
|
+
|
|
34
|
+
# NavaiaForge Python SDK
|
|
35
|
+
|
|
36
|
+
Official Python client for the [NavaiaForge](https://navaia.com) AI workforce platform — a typed, real-time client for building **multi-agent AI workforces** that work like teams.
|
|
37
|
+
|
|
38
|
+
Use it **standalone** (scripts, services, CI, notebooks) or **alongside the NavaiaForge dashboard**. Both speak to the same backend, so anything created in code shows up in the UI and vice versa.
|
|
39
|
+
|
|
40
|
+
## Why a workforce, not just an agent?
|
|
41
|
+
|
|
42
|
+
A single LLM call solves a single prompt; real work rarely is. NavaiaForge models work the way teams do:
|
|
43
|
+
|
|
44
|
+
- **Many specialized agents** with their own roles, instructions, and models — not one generalist.
|
|
45
|
+
- **Edges** route work between them (reviewer → tester → deployer).
|
|
46
|
+
- **Shared knowledge bases** ground every agent in the same facts via RAG.
|
|
47
|
+
- **Shared tools** (HTTP, MCP, code executors, plugins) give the team hands.
|
|
48
|
+
- **One coordinator** — submit a task to the workforce, not to a specific agent.
|
|
49
|
+
|
|
50
|
+
The SDK exposes every primitive directly.
|
|
51
|
+
|
|
52
|
+
## Installation
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pip install navaia-forge
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Quickstart
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
from navaia_forge import NavaiaForgeClient
|
|
62
|
+
|
|
63
|
+
client = NavaiaForgeClient(base_url="http://localhost:8000", api_key="nf_...")
|
|
64
|
+
|
|
65
|
+
# Build the team
|
|
66
|
+
wf = client.workforces.create(name="Code Review Team")
|
|
67
|
+
reviewer = client.agents.create(workforce_id=wf.id, name="Reviewer", role="review",
|
|
68
|
+
instructions="Review PRs for correctness and security.",
|
|
69
|
+
model_provider="anthropic", model_name="sonnet")
|
|
70
|
+
tester = client.agents.create(workforce_id=wf.id, name="Tester", role="qa",
|
|
71
|
+
instructions="Generate and run tests for approved diffs.",
|
|
72
|
+
model_provider="anthropic", model_name="sonnet")
|
|
73
|
+
|
|
74
|
+
# Wire reviewer → tester
|
|
75
|
+
client.workforces.create_edge(workforce_id=wf.id,
|
|
76
|
+
source_agent_id=reviewer.id,
|
|
77
|
+
target_agent_id=tester.id)
|
|
78
|
+
|
|
79
|
+
# Hand work to the team
|
|
80
|
+
task = client.tasks.create(workforce_id=wf.id, title="Review PR #482 and add tests")
|
|
81
|
+
final = client.tasks.wait_for_completion(task.id)
|
|
82
|
+
print(final.status, final.result)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
All resource methods return typed [Pydantic v2](https://docs.pydantic.dev/) models. Errors raise `navaia_forge.NavaiaForgeError` (or a subclass: `NotFoundError`, `RateLimitError`, `ValidationError`, `AuthenticationError`, `PermissionError`, `ServerError`, `TimeoutError`).
|
|
86
|
+
|
|
87
|
+
## Real-time events
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
from navaia_forge import NavaiaForgeWs, HttpConfig
|
|
91
|
+
|
|
92
|
+
ws = NavaiaForgeWs(HttpConfig(base_url="http://localhost:8000", api_key="nf_..."))
|
|
93
|
+
ws.on("task:status", lambda e: print("task:", e["task_id"], e["status"]))
|
|
94
|
+
ws.on("agent:status", lambda e: print("agent:", e["agent_id"], e["status"]))
|
|
95
|
+
ws.on("chat:message", lambda e: print(e["role"], e["content"]))
|
|
96
|
+
ws.connect()
|
|
97
|
+
ws.run_forever()
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Channels: `task:status`, `agent:status`, `chat:message`, `system:*`.
|
|
101
|
+
|
|
102
|
+
## What you can do
|
|
103
|
+
|
|
104
|
+
| Namespace | What it does | Why you'd use it |
|
|
105
|
+
|---|---|---|
|
|
106
|
+
| `client.workforces` | CRUD; manage edges; link tools / knowledge bases | Define the team and how work flows through it |
|
|
107
|
+
| `client.agents` | CRUD; `list_featured`, `clone`, `export`; attach/detach to workforces | Compose specialists with their own models and instructions |
|
|
108
|
+
| `client.tasks` | `create`, `approve`, `reject`, `retry`, logs, `wait_for_completion` | Hand work to the team, sync or async |
|
|
109
|
+
| `client.conversations` | Open chats, send messages targeted at agents | Build chat UIs / interactive assistants |
|
|
110
|
+
| `client.knowledge` | Knowledge bases, document upload, semantic `search`, `featured`, `download` | Ground agents in your data via RAG |
|
|
111
|
+
| `client.templates` | Workforce templates + `templates.agents` for agent templates | Don't rebuild the same team twice |
|
|
112
|
+
| `client.tools` | Full CRUD, `featured`, attach/detach to workforces | Give the team hands (HTTP, MCP, code-exec, custom) |
|
|
113
|
+
| `client.integrations` | `list`, `list_plugins`, CRUD | Connect Slack / GitHub / Linear / other plugins |
|
|
114
|
+
| `client.setup` | `options`, `validate`, `complete` | First-run onboarding / provider configuration |
|
|
115
|
+
| `client.observability` | `summary`, `cost`, `agent_metrics`, `agent_evaluations`, `log_token_usage` | See what the team is doing and what it costs |
|
|
116
|
+
| `client.auth` | `me`, `register`, `login`, `refresh`, `create_key`, `validate`, OAuth URL helpers | Build your own UI on top of NavaiaForge |
|
|
117
|
+
|
|
118
|
+
## Standalone or with the UI
|
|
119
|
+
|
|
120
|
+
- **Standalone:** the SDK is sufficient on its own — no dashboard required. Drive everything from Python: scripts, services, Airflow / Prefect tasks, Jupyter, custom CLIs, internal tools.
|
|
121
|
+
- **Alongside the dashboard:** anything you create programmatically appears in the NavaiaForge UI immediately, and anything created in the UI is reachable from `client.*`. Two views over one backend.
|
|
122
|
+
|
|
123
|
+
## Development
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
python3.12 -m venv .venv
|
|
127
|
+
source .venv/bin/activate
|
|
128
|
+
pip install -e ".[dev]"
|
|
129
|
+
pytest --cov=navaia_forge
|
|
130
|
+
ruff check navaia_forge tests
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## License
|
|
134
|
+
|
|
135
|
+
[MIT](./LICENSE) © NavaiaSolutions
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# NavaiaForge Python SDK
|
|
2
|
+
|
|
3
|
+
Official Python client for the [NavaiaForge](https://navaia.com) AI workforce platform — a typed, real-time client for building **multi-agent AI workforces** that work like teams.
|
|
4
|
+
|
|
5
|
+
Use it **standalone** (scripts, services, CI, notebooks) or **alongside the NavaiaForge dashboard**. Both speak to the same backend, so anything created in code shows up in the UI and vice versa.
|
|
6
|
+
|
|
7
|
+
## Why a workforce, not just an agent?
|
|
8
|
+
|
|
9
|
+
A single LLM call solves a single prompt; real work rarely is. NavaiaForge models work the way teams do:
|
|
10
|
+
|
|
11
|
+
- **Many specialized agents** with their own roles, instructions, and models — not one generalist.
|
|
12
|
+
- **Edges** route work between them (reviewer → tester → deployer).
|
|
13
|
+
- **Shared knowledge bases** ground every agent in the same facts via RAG.
|
|
14
|
+
- **Shared tools** (HTTP, MCP, code executors, plugins) give the team hands.
|
|
15
|
+
- **One coordinator** — submit a task to the workforce, not to a specific agent.
|
|
16
|
+
|
|
17
|
+
The SDK exposes every primitive directly.
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pip install navaia-forge
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Quickstart
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
from navaia_forge import NavaiaForgeClient
|
|
29
|
+
|
|
30
|
+
client = NavaiaForgeClient(base_url="http://localhost:8000", api_key="nf_...")
|
|
31
|
+
|
|
32
|
+
# Build the team
|
|
33
|
+
wf = client.workforces.create(name="Code Review Team")
|
|
34
|
+
reviewer = client.agents.create(workforce_id=wf.id, name="Reviewer", role="review",
|
|
35
|
+
instructions="Review PRs for correctness and security.",
|
|
36
|
+
model_provider="anthropic", model_name="sonnet")
|
|
37
|
+
tester = client.agents.create(workforce_id=wf.id, name="Tester", role="qa",
|
|
38
|
+
instructions="Generate and run tests for approved diffs.",
|
|
39
|
+
model_provider="anthropic", model_name="sonnet")
|
|
40
|
+
|
|
41
|
+
# Wire reviewer → tester
|
|
42
|
+
client.workforces.create_edge(workforce_id=wf.id,
|
|
43
|
+
source_agent_id=reviewer.id,
|
|
44
|
+
target_agent_id=tester.id)
|
|
45
|
+
|
|
46
|
+
# Hand work to the team
|
|
47
|
+
task = client.tasks.create(workforce_id=wf.id, title="Review PR #482 and add tests")
|
|
48
|
+
final = client.tasks.wait_for_completion(task.id)
|
|
49
|
+
print(final.status, final.result)
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
All resource methods return typed [Pydantic v2](https://docs.pydantic.dev/) models. Errors raise `navaia_forge.NavaiaForgeError` (or a subclass: `NotFoundError`, `RateLimitError`, `ValidationError`, `AuthenticationError`, `PermissionError`, `ServerError`, `TimeoutError`).
|
|
53
|
+
|
|
54
|
+
## Real-time events
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
from navaia_forge import NavaiaForgeWs, HttpConfig
|
|
58
|
+
|
|
59
|
+
ws = NavaiaForgeWs(HttpConfig(base_url="http://localhost:8000", api_key="nf_..."))
|
|
60
|
+
ws.on("task:status", lambda e: print("task:", e["task_id"], e["status"]))
|
|
61
|
+
ws.on("agent:status", lambda e: print("agent:", e["agent_id"], e["status"]))
|
|
62
|
+
ws.on("chat:message", lambda e: print(e["role"], e["content"]))
|
|
63
|
+
ws.connect()
|
|
64
|
+
ws.run_forever()
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Channels: `task:status`, `agent:status`, `chat:message`, `system:*`.
|
|
68
|
+
|
|
69
|
+
## What you can do
|
|
70
|
+
|
|
71
|
+
| Namespace | What it does | Why you'd use it |
|
|
72
|
+
|---|---|---|
|
|
73
|
+
| `client.workforces` | CRUD; manage edges; link tools / knowledge bases | Define the team and how work flows through it |
|
|
74
|
+
| `client.agents` | CRUD; `list_featured`, `clone`, `export`; attach/detach to workforces | Compose specialists with their own models and instructions |
|
|
75
|
+
| `client.tasks` | `create`, `approve`, `reject`, `retry`, logs, `wait_for_completion` | Hand work to the team, sync or async |
|
|
76
|
+
| `client.conversations` | Open chats, send messages targeted at agents | Build chat UIs / interactive assistants |
|
|
77
|
+
| `client.knowledge` | Knowledge bases, document upload, semantic `search`, `featured`, `download` | Ground agents in your data via RAG |
|
|
78
|
+
| `client.templates` | Workforce templates + `templates.agents` for agent templates | Don't rebuild the same team twice |
|
|
79
|
+
| `client.tools` | Full CRUD, `featured`, attach/detach to workforces | Give the team hands (HTTP, MCP, code-exec, custom) |
|
|
80
|
+
| `client.integrations` | `list`, `list_plugins`, CRUD | Connect Slack / GitHub / Linear / other plugins |
|
|
81
|
+
| `client.setup` | `options`, `validate`, `complete` | First-run onboarding / provider configuration |
|
|
82
|
+
| `client.observability` | `summary`, `cost`, `agent_metrics`, `agent_evaluations`, `log_token_usage` | See what the team is doing and what it costs |
|
|
83
|
+
| `client.auth` | `me`, `register`, `login`, `refresh`, `create_key`, `validate`, OAuth URL helpers | Build your own UI on top of NavaiaForge |
|
|
84
|
+
|
|
85
|
+
## Standalone or with the UI
|
|
86
|
+
|
|
87
|
+
- **Standalone:** the SDK is sufficient on its own — no dashboard required. Drive everything from Python: scripts, services, Airflow / Prefect tasks, Jupyter, custom CLIs, internal tools.
|
|
88
|
+
- **Alongside the dashboard:** anything you create programmatically appears in the NavaiaForge UI immediately, and anything created in the UI is reachable from `client.*`. Two views over one backend.
|
|
89
|
+
|
|
90
|
+
## Development
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
python3.12 -m venv .venv
|
|
94
|
+
source .venv/bin/activate
|
|
95
|
+
pip install -e ".[dev]"
|
|
96
|
+
pytest --cov=navaia_forge
|
|
97
|
+
ruff check navaia_forge tests
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## License
|
|
101
|
+
|
|
102
|
+
[MIT](./LICENSE) © NavaiaSolutions
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"""NavaiaForge Python SDK.
|
|
2
|
+
|
|
3
|
+
Public surface::
|
|
4
|
+
|
|
5
|
+
from navaia_forge import NavaiaForgeClient
|
|
6
|
+
from navaia_forge import Workforce, Agent, Task, Edge # typed models
|
|
7
|
+
from navaia_forge import NavaiaForgeError, NotFoundError # exceptions
|
|
8
|
+
from navaia_forge import NavaiaForgeWs # real-time WS client
|
|
9
|
+
|
|
10
|
+
Quickstart::
|
|
11
|
+
|
|
12
|
+
client = NavaiaForgeClient(base_url="http://localhost:8000", api_key="nf_...")
|
|
13
|
+
workforces = client.workforces.list()
|
|
14
|
+
task = client.tasks.create(workforce_id=workforces[0].id, title="Review PR")
|
|
15
|
+
final = client.tasks.wait_for_completion(task.id)
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
from .client import NavaiaForgeClient
|
|
19
|
+
from .errors import (
|
|
20
|
+
AuthenticationError,
|
|
21
|
+
NavaiaForgeError,
|
|
22
|
+
NotFoundError,
|
|
23
|
+
PermissionError,
|
|
24
|
+
RateLimitError,
|
|
25
|
+
ServerError,
|
|
26
|
+
TimeoutError,
|
|
27
|
+
ValidationError,
|
|
28
|
+
)
|
|
29
|
+
from .http import HttpClient, HttpConfig
|
|
30
|
+
from .types import (
|
|
31
|
+
Agent,
|
|
32
|
+
AgentConfig,
|
|
33
|
+
AgentCostBreakdown,
|
|
34
|
+
AgentCreate,
|
|
35
|
+
AgentMetrics,
|
|
36
|
+
AgentTemplate,
|
|
37
|
+
AgentTemplateCreate,
|
|
38
|
+
AgentUpdate,
|
|
39
|
+
AgentVariable,
|
|
40
|
+
ApiKeyCreated,
|
|
41
|
+
ApiKeyValidation,
|
|
42
|
+
AvailablePlugin,
|
|
43
|
+
Conversation,
|
|
44
|
+
CostSummary,
|
|
45
|
+
Edge,
|
|
46
|
+
Integration,
|
|
47
|
+
KnowledgeBase,
|
|
48
|
+
KnowledgeDocument,
|
|
49
|
+
Message,
|
|
50
|
+
MetricsSummary,
|
|
51
|
+
ModelCostBreakdown,
|
|
52
|
+
PaginatedResponse,
|
|
53
|
+
RLEvaluation,
|
|
54
|
+
SearchResponse,
|
|
55
|
+
SearchResult,
|
|
56
|
+
SetupOptions,
|
|
57
|
+
SetupValidateResult,
|
|
58
|
+
Task,
|
|
59
|
+
TaskCreate,
|
|
60
|
+
TaskLog,
|
|
61
|
+
Template,
|
|
62
|
+
TemplateInstantiateResult,
|
|
63
|
+
TokenPair,
|
|
64
|
+
TokenUsage,
|
|
65
|
+
Tool,
|
|
66
|
+
ToolCall,
|
|
67
|
+
ToolCreate,
|
|
68
|
+
ToolUpdate,
|
|
69
|
+
User,
|
|
70
|
+
Workforce,
|
|
71
|
+
WorkforceCreate,
|
|
72
|
+
WorkforceFull,
|
|
73
|
+
WorkforceKnowledgeBaseLink,
|
|
74
|
+
WorkforceMember,
|
|
75
|
+
WorkforceTemplate,
|
|
76
|
+
WorkforceTemplateCreate,
|
|
77
|
+
WorkforceToolLink,
|
|
78
|
+
WorkforceUpdate,
|
|
79
|
+
WsAgentStatusEvent,
|
|
80
|
+
WsChatEvent,
|
|
81
|
+
WsEvent,
|
|
82
|
+
WsSystemEvent,
|
|
83
|
+
WsTaskEvent,
|
|
84
|
+
)
|
|
85
|
+
from .websocket import NavaiaForgeWs
|
|
86
|
+
|
|
87
|
+
__version__ = "0.1.0"
|
|
88
|
+
|
|
89
|
+
__all__ = [
|
|
90
|
+
"Agent",
|
|
91
|
+
"AgentConfig",
|
|
92
|
+
"AgentCostBreakdown",
|
|
93
|
+
"AgentCreate",
|
|
94
|
+
"AgentMetrics",
|
|
95
|
+
"AgentTemplate",
|
|
96
|
+
"AgentTemplateCreate",
|
|
97
|
+
"AgentUpdate",
|
|
98
|
+
"AgentVariable",
|
|
99
|
+
"ApiKeyCreated",
|
|
100
|
+
"ApiKeyValidation",
|
|
101
|
+
"AuthenticationError",
|
|
102
|
+
"AvailablePlugin",
|
|
103
|
+
"Conversation",
|
|
104
|
+
"CostSummary",
|
|
105
|
+
"Edge",
|
|
106
|
+
"HttpClient",
|
|
107
|
+
"HttpConfig",
|
|
108
|
+
"Integration",
|
|
109
|
+
"KnowledgeBase",
|
|
110
|
+
"KnowledgeDocument",
|
|
111
|
+
"Message",
|
|
112
|
+
"MetricsSummary",
|
|
113
|
+
"ModelCostBreakdown",
|
|
114
|
+
"NavaiaForgeClient",
|
|
115
|
+
"NavaiaForgeError",
|
|
116
|
+
"NavaiaForgeWs",
|
|
117
|
+
"NotFoundError",
|
|
118
|
+
"PaginatedResponse",
|
|
119
|
+
"PermissionError",
|
|
120
|
+
"RLEvaluation",
|
|
121
|
+
"RateLimitError",
|
|
122
|
+
"SearchResponse",
|
|
123
|
+
"SearchResult",
|
|
124
|
+
"ServerError",
|
|
125
|
+
"SetupOptions",
|
|
126
|
+
"SetupValidateResult",
|
|
127
|
+
"Task",
|
|
128
|
+
"TaskCreate",
|
|
129
|
+
"TaskLog",
|
|
130
|
+
"Template",
|
|
131
|
+
"TemplateInstantiateResult",
|
|
132
|
+
"TimeoutError",
|
|
133
|
+
"TokenPair",
|
|
134
|
+
"TokenUsage",
|
|
135
|
+
"Tool",
|
|
136
|
+
"ToolCall",
|
|
137
|
+
"ToolCreate",
|
|
138
|
+
"ToolUpdate",
|
|
139
|
+
"User",
|
|
140
|
+
"ValidationError",
|
|
141
|
+
"Workforce",
|
|
142
|
+
"WorkforceCreate",
|
|
143
|
+
"WorkforceFull",
|
|
144
|
+
"WorkforceKnowledgeBaseLink",
|
|
145
|
+
"WorkforceMember",
|
|
146
|
+
"WorkforceTemplate",
|
|
147
|
+
"WorkforceTemplateCreate",
|
|
148
|
+
"WorkforceToolLink",
|
|
149
|
+
"WorkforceUpdate",
|
|
150
|
+
"WsAgentStatusEvent",
|
|
151
|
+
"WsChatEvent",
|
|
152
|
+
"WsEvent",
|
|
153
|
+
"WsSystemEvent",
|
|
154
|
+
"WsTaskEvent",
|
|
155
|
+
]
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"""NavaiaForge Python SDK client.
|
|
2
|
+
|
|
3
|
+
The client is intentionally thin: it owns an :class:`HttpClient` instance and
|
|
4
|
+
exposes resource namespaces (``client.workforces``, ``client.agents``, ...).
|
|
5
|
+
|
|
6
|
+
Example::
|
|
7
|
+
|
|
8
|
+
from navaia_forge import NavaiaForgeClient
|
|
9
|
+
|
|
10
|
+
client = NavaiaForgeClient(
|
|
11
|
+
base_url="http://localhost:8000",
|
|
12
|
+
api_key="nf_...",
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
workforces = client.workforces.list()
|
|
16
|
+
task = client.tasks.create(workforce_id=workforces[0].id, title="Review PR")
|
|
17
|
+
completed = client.tasks.wait_for_completion(task.id)
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
from __future__ import annotations
|
|
21
|
+
|
|
22
|
+
from typing import Any
|
|
23
|
+
|
|
24
|
+
import httpx
|
|
25
|
+
|
|
26
|
+
from .http import HttpClient, HttpConfig
|
|
27
|
+
from .resources import (
|
|
28
|
+
AgentsResource,
|
|
29
|
+
AuthResource,
|
|
30
|
+
ConversationsResource,
|
|
31
|
+
IntegrationsResource,
|
|
32
|
+
KnowledgeResource,
|
|
33
|
+
ObservabilityResource,
|
|
34
|
+
SetupResource,
|
|
35
|
+
TasksResource,
|
|
36
|
+
TemplatesResource,
|
|
37
|
+
ToolsResource,
|
|
38
|
+
WorkforcesResource,
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class NavaiaForgeClient:
|
|
43
|
+
"""Top-level entry point to the NavaiaForge SDK."""
|
|
44
|
+
|
|
45
|
+
def __init__(
|
|
46
|
+
self,
|
|
47
|
+
base_url: str = "http://localhost:8000",
|
|
48
|
+
api_key: str = "",
|
|
49
|
+
timeout: float = 60.0,
|
|
50
|
+
*,
|
|
51
|
+
http: HttpClient | None = None,
|
|
52
|
+
) -> None:
|
|
53
|
+
self._config = HttpConfig(
|
|
54
|
+
base_url=base_url,
|
|
55
|
+
api_key=api_key,
|
|
56
|
+
timeout=timeout,
|
|
57
|
+
)
|
|
58
|
+
self._http = http if http is not None else HttpClient(self._config)
|
|
59
|
+
|
|
60
|
+
# Resource namespaces.
|
|
61
|
+
self.workforces = WorkforcesResource(self._http)
|
|
62
|
+
self.agents = AgentsResource(self._http)
|
|
63
|
+
self.tasks = TasksResource(self._http)
|
|
64
|
+
self.conversations = ConversationsResource(self._http)
|
|
65
|
+
self.knowledge = KnowledgeResource(self._http)
|
|
66
|
+
self.observability = ObservabilityResource(self._http)
|
|
67
|
+
self.templates = TemplatesResource(self._http)
|
|
68
|
+
self.integrations = IntegrationsResource(self._http)
|
|
69
|
+
self.tools = ToolsResource(self._http)
|
|
70
|
+
self.setup = SetupResource(self._http)
|
|
71
|
+
self.auth = AuthResource(self._http)
|
|
72
|
+
|
|
73
|
+
# ── Configuration accessors ───────────────────────────────
|
|
74
|
+
|
|
75
|
+
@property
|
|
76
|
+
def base_url(self) -> str:
|
|
77
|
+
return self._config.base_url
|
|
78
|
+
|
|
79
|
+
@property
|
|
80
|
+
def api_key(self) -> str:
|
|
81
|
+
return self._config.api_key
|
|
82
|
+
|
|
83
|
+
@property
|
|
84
|
+
def timeout(self) -> float:
|
|
85
|
+
return self._config.timeout
|
|
86
|
+
|
|
87
|
+
@property
|
|
88
|
+
def http(self) -> HttpClient:
|
|
89
|
+
"""Underlying HTTP transport (escape hatch for advanced calls)."""
|
|
90
|
+
return self._http
|
|
91
|
+
|
|
92
|
+
# ── Lifecycle ─────────────────────────────────────────────
|
|
93
|
+
|
|
94
|
+
def close(self) -> None:
|
|
95
|
+
"""Close the underlying HTTP client."""
|
|
96
|
+
self._http.close()
|
|
97
|
+
|
|
98
|
+
def __enter__(self) -> NavaiaForgeClient:
|
|
99
|
+
return self
|
|
100
|
+
|
|
101
|
+
def __exit__(self, *_: object) -> None:
|
|
102
|
+
self.close()
|
|
103
|
+
|
|
104
|
+
# ── Misc ──────────────────────────────────────────────────
|
|
105
|
+
|
|
106
|
+
def health(self) -> dict[str, Any]:
|
|
107
|
+
"""Check API health (hits ``/health``, not ``/api/v1/health``)."""
|
|
108
|
+
url = f"{self._config.base_url.rstrip('/')}/health"
|
|
109
|
+
with httpx.Client(timeout=self._config.timeout) as client:
|
|
110
|
+
response = client.get(url)
|
|
111
|
+
response.raise_for_status()
|
|
112
|
+
return response.json()
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"""Exception hierarchy for the NavaiaForge SDK.
|
|
2
|
+
|
|
3
|
+
All SDK errors derive from :class:`NavaiaForgeError` so callers can catch them
|
|
4
|
+
with a single ``except NavaiaForgeError`` clause. HTTP status codes are mapped
|
|
5
|
+
to specific subclasses by :func:`error_from_status`.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class NavaiaForgeError(Exception):
|
|
12
|
+
"""Base exception for all NavaiaForge SDK errors."""
|
|
13
|
+
|
|
14
|
+
def __init__(self, status_code: int, message: str) -> None:
|
|
15
|
+
self.status_code = status_code
|
|
16
|
+
self.message = message
|
|
17
|
+
super().__init__(f"HTTP {status_code}: {message}" if status_code else message)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class AuthenticationError(NavaiaForgeError):
|
|
21
|
+
"""Raised when authentication fails (HTTP 401)."""
|
|
22
|
+
|
|
23
|
+
def __init__(self, message: str = "Invalid or missing API key") -> None:
|
|
24
|
+
super().__init__(401, message)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class PermissionError(NavaiaForgeError):
|
|
28
|
+
"""Raised when the caller lacks permission (HTTP 403)."""
|
|
29
|
+
|
|
30
|
+
def __init__(self, message: str = "Permission denied") -> None:
|
|
31
|
+
super().__init__(403, message)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class NotFoundError(NavaiaForgeError):
|
|
35
|
+
"""Raised when a resource is not found (HTTP 404)."""
|
|
36
|
+
|
|
37
|
+
def __init__(self, message: str = "Resource not found") -> None:
|
|
38
|
+
super().__init__(404, message)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class ValidationError(NavaiaForgeError):
|
|
42
|
+
"""Raised when the server rejects a request body (HTTP 422)."""
|
|
43
|
+
|
|
44
|
+
def __init__(self, message: str = "Validation failed") -> None:
|
|
45
|
+
super().__init__(422, message)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class RateLimitError(NavaiaForgeError):
|
|
49
|
+
"""Raised when the rate limit is exceeded (HTTP 429)."""
|
|
50
|
+
|
|
51
|
+
def __init__(self, message: str = "Rate limit exceeded") -> None:
|
|
52
|
+
super().__init__(429, message)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class ServerError(NavaiaForgeError):
|
|
56
|
+
"""Raised on 5xx server errors."""
|
|
57
|
+
|
|
58
|
+
def __init__(self, status_code: int, message: str = "Server error") -> None:
|
|
59
|
+
super().__init__(status_code, message)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class TimeoutError(NavaiaForgeError):
|
|
63
|
+
"""Raised when a polling operation exceeds its timeout."""
|
|
64
|
+
|
|
65
|
+
def __init__(self, message: str) -> None:
|
|
66
|
+
super().__init__(0, message)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def error_from_status(status_code: int, message: str) -> NavaiaForgeError:
|
|
70
|
+
"""Map an HTTP status code to the appropriate :class:`NavaiaForgeError` subclass."""
|
|
71
|
+
if status_code == 401:
|
|
72
|
+
return AuthenticationError(message)
|
|
73
|
+
if status_code == 403:
|
|
74
|
+
return PermissionError(message)
|
|
75
|
+
if status_code == 404:
|
|
76
|
+
return NotFoundError(message)
|
|
77
|
+
if status_code == 422:
|
|
78
|
+
return ValidationError(message)
|
|
79
|
+
if status_code == 429:
|
|
80
|
+
return RateLimitError(message)
|
|
81
|
+
if 500 <= status_code < 600:
|
|
82
|
+
return ServerError(status_code, message)
|
|
83
|
+
return NavaiaForgeError(status_code, message)
|