agv 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.
- agv-0.1.0/.gitignore +9 -0
- agv-0.1.0/PKG-INFO +402 -0
- agv-0.1.0/README-AI-GATEWAY.md +74 -0
- agv-0.1.0/README.md +355 -0
- agv-0.1.0/pyproject.toml +88 -0
- agv-0.1.0/scripts/check_release_version.py +74 -0
- agv-0.1.0/src/agentenv/__init__.py +26 -0
- agv-0.1.0/src/agentenv/__main__.py +6 -0
- agv-0.1.0/src/agentenv/_version.py +3 -0
- agv-0.1.0/src/agentenv/api/__init__.py +23 -0
- agv-0.1.0/src/agentenv/api/ai_gateway.py +322 -0
- agv-0.1.0/src/agentenv/api/analytics.py +350 -0
- agv-0.1.0/src/agentenv/api/app.py +127 -0
- agv-0.1.0/src/agentenv/api/auth.py +155 -0
- agv-0.1.0/src/agentenv/api/billing.py +92 -0
- agv-0.1.0/src/agentenv/api/browser.py +212 -0
- agv-0.1.0/src/agentenv/api/client.py +190 -0
- agv-0.1.0/src/agentenv/api/cluster.py +70 -0
- agv-0.1.0/src/agentenv/api/file.py +209 -0
- agv-0.1.0/src/agentenv/api/image.py +100 -0
- agv-0.1.0/src/agentenv/api/models.py +1250 -0
- agv-0.1.0/src/agentenv/api/notebook.py +640 -0
- agv-0.1.0/src/agentenv/api/sandbox.py +329 -0
- agv-0.1.0/src/agentenv/api/site.py +178 -0
- agv-0.1.0/src/agentenv/api/snapshot.py +163 -0
- agv-0.1.0/src/agentenv/api/workflow.py +265 -0
- agv-0.1.0/src/agentenv/api/workspace.py +195 -0
- agv-0.1.0/src/agentenv/cli/__init__.py +1 -0
- agv-0.1.0/src/agentenv/cli/ai.py +760 -0
- agv-0.1.0/src/agentenv/cli/analytics.py +305 -0
- agv-0.1.0/src/agentenv/cli/app.py +512 -0
- agv-0.1.0/src/agentenv/cli/app_cmd.py +349 -0
- agv-0.1.0/src/agentenv/cli/auth.py +344 -0
- agv-0.1.0/src/agentenv/cli/billing.py +148 -0
- agv-0.1.0/src/agentenv/cli/browser.py +433 -0
- agv-0.1.0/src/agentenv/cli/cluster.py +247 -0
- agv-0.1.0/src/agentenv/cli/config_cmd.py +333 -0
- agv-0.1.0/src/agentenv/cli/file.py +264 -0
- agv-0.1.0/src/agentenv/cli/image.py +500 -0
- agv-0.1.0/src/agentenv/cli/notebook.py +1959 -0
- agv-0.1.0/src/agentenv/cli/sandbox.py +944 -0
- agv-0.1.0/src/agentenv/cli/site.py +315 -0
- agv-0.1.0/src/agentenv/cli/snapshot.py +212 -0
- agv-0.1.0/src/agentenv/cli/workflow.py +1004 -0
- agv-0.1.0/src/agentenv/cli/workspace.py +383 -0
- agv-0.1.0/src/agentenv/config/__init__.py +1 -0
- agv-0.1.0/src/agentenv/config/defaults.py +132 -0
- agv-0.1.0/src/agentenv/config/settings.py +199 -0
- agv-0.1.0/src/agentenv/config/storage.py +197 -0
- agv-0.1.0/src/agentenv/oauth/__init__.py +1 -0
- agv-0.1.0/src/agentenv/oauth/flow.py +229 -0
- agv-0.1.0/src/agentenv/sdk/__init__.py +1324 -0
- agv-0.1.0/src/agentenv/sdk/ai.py +476 -0
- agv-0.1.0/src/agentenv/sdk/cluster.py +487 -0
- agv-0.1.0/src/agentenv/sdk/function.py +359 -0
- agv-0.1.0/src/agentenv/sdk/image.py +1344 -0
- agv-0.1.0/src/agentenv/spec.py +42 -0
- agv-0.1.0/src/agentenv/ui/__init__.py +1 -0
- agv-0.1.0/src/agentenv/ui/progress.py +269 -0
- agv-0.1.0/src/agentenv/ui/tables.py +1133 -0
- agv-0.1.0/tests/api/__init__.py +1 -0
- agv-0.1.0/tests/api/test_ai_gateway.py +95 -0
- agv-0.1.0/tests/api/test_browser_api.py +102 -0
- agv-0.1.0/tests/api/test_models.py +42 -0
- agv-0.1.0/tests/api/test_notebook_api.py +806 -0
- agv-0.1.0/tests/api/test_notebook_models.py +135 -0
- agv-0.1.0/tests/cli/test_ai_cli.py +54 -0
- agv-0.1.0/tests/cli/test_auth_cli.py +245 -0
- agv-0.1.0/tests/cli/test_cluster_cli.py +64 -0
- agv-0.1.0/tests/cli/test_config_cli.py +73 -0
- agv-0.1.0/tests/cli/test_entrypoint_cli.py +119 -0
- agv-0.1.0/tests/cli/test_module_entrypoint.py +32 -0
- agv-0.1.0/tests/cli/test_notebook_cell.py +892 -0
- agv-0.1.0/tests/cli/test_notebook_collab.py +49 -0
- agv-0.1.0/tests/cli/test_notebook_document.py +252 -0
- agv-0.1.0/tests/cli/test_notebook_file.py +160 -0
- agv-0.1.0/tests/cli/test_notebook_session.py +241 -0
- agv-0.1.0/tests/cli/test_release_version.py +50 -0
- agv-0.1.0/tests/cli/test_sandbox_cli.py +272 -0
- agv-0.1.0/tests/cli/test_workflow_cli.py +324 -0
- agv-0.1.0/tests/cli/test_workspace_cli.py +41 -0
- agv-0.1.0/tests/config/test_storage.py +107 -0
- agv-0.1.0/tests/conftest.py +11 -0
- agv-0.1.0/tests/docs/test_documentation_alignment.py +169 -0
- agv-0.1.0/tests/sdk/test_ai.py +73 -0
- agv-0.1.0/tests/sdk/test_notebook.py +240 -0
- agv-0.1.0/uv.lock +2290 -0
agv-0.1.0/.gitignore
ADDED
agv-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agv
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: AgentEnv Cloud CLI and Python SDK for sandboxes, notebooks, clusters, and AI workloads
|
|
5
|
+
Project-URL: Homepage, https://agentenv.io
|
|
6
|
+
Project-URL: Documentation, https://github.com/agentenv/monorepo/tree/main/mintlify_docs
|
|
7
|
+
Project-URL: Repository, https://github.com/agentenv/monorepo
|
|
8
|
+
Project-URL: Issues, https://github.com/agentenv/monorepo/issues
|
|
9
|
+
Author-email: AgentEnv <support@agentenv.io>
|
|
10
|
+
Keywords: agentenv,cli,cloud,sandbox,sdk
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Classifier: Topic :: System :: Distributed Computing
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Requires-Dist: authlib>=1.3.0
|
|
23
|
+
Requires-Dist: httpx>=0.27.0
|
|
24
|
+
Requires-Dist: keyring>=24.0.0
|
|
25
|
+
Requires-Dist: pydantic-settings>=2.0
|
|
26
|
+
Requires-Dist: pydantic>=2.0
|
|
27
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
28
|
+
Requires-Dist: pyyaml>=6.0
|
|
29
|
+
Requires-Dist: rich>=13.0.0
|
|
30
|
+
Requires-Dist: typer>=0.12.0
|
|
31
|
+
Provides-Extra: dev
|
|
32
|
+
Requires-Dist: mypy>=1.0; extra == 'dev'
|
|
33
|
+
Requires-Dist: pytest-asyncio>=0.21; extra == 'dev'
|
|
34
|
+
Requires-Dist: pytest-cov>=4.0; extra == 'dev'
|
|
35
|
+
Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
36
|
+
Requires-Dist: ruff>=0.1.0; extra == 'dev'
|
|
37
|
+
Provides-Extra: ray
|
|
38
|
+
Requires-Dist: ray<2.10,>=2.9.3; extra == 'ray'
|
|
39
|
+
Provides-Extra: spark
|
|
40
|
+
Requires-Dist: grpcio-status>=1.48.1; extra == 'spark'
|
|
41
|
+
Requires-Dist: grpcio>=1.48.1; extra == 'spark'
|
|
42
|
+
Requires-Dist: pandas>=2.2.0; extra == 'spark'
|
|
43
|
+
Requires-Dist: pyarrow>=15.0.0; extra == 'spark'
|
|
44
|
+
Requires-Dist: pyspark<3.6,>=3.5.1; extra == 'spark'
|
|
45
|
+
Requires-Dist: zstandard>=0.25.0; extra == 'spark'
|
|
46
|
+
Description-Content-Type: text/markdown
|
|
47
|
+
|
|
48
|
+
# AgentEnv CLI
|
|
49
|
+
|
|
50
|
+
A command-line interface for AgentEnv Cloud - manage containers, sandboxes, and more.
|
|
51
|
+
|
|
52
|
+
## Installation
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pip install agv
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
This package publishes the Python module as `agentenv` and installs three CLI entrypoints:
|
|
59
|
+
|
|
60
|
+
- `agv`: package-aligned short command
|
|
61
|
+
- `agentenv`: explicit command name for documentation and shell usage
|
|
62
|
+
- `av`: short alias kept for existing workflows
|
|
63
|
+
|
|
64
|
+
The examples below keep using `av`, but `agentenv` is equivalent:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
agv version
|
|
68
|
+
agentenv version
|
|
69
|
+
av version
|
|
70
|
+
python -m agentenv version
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Quick Start
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# Authenticate with an API key
|
|
77
|
+
av login --api-key sk_live_xxxxx
|
|
78
|
+
|
|
79
|
+
# Set default sandbox type
|
|
80
|
+
av set type xl
|
|
81
|
+
|
|
82
|
+
# Run a Python sandbox
|
|
83
|
+
av run -- python3 -m http.server
|
|
84
|
+
|
|
85
|
+
# List sandboxes
|
|
86
|
+
av ls
|
|
87
|
+
|
|
88
|
+
# View logs
|
|
89
|
+
av logs -f <sandbox-id>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Ray / Spark Clusters
|
|
93
|
+
|
|
94
|
+
The CLI now includes cluster lifecycle commands, and the Python SDK also exposes higher-level helpers that can provision Ray/Spark clusters and connect to the cluster head over a direct public endpoint.
|
|
95
|
+
|
|
96
|
+
### Cluster CLI
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
av cluster ray 4x2xH100 --workspace <workspace-id>
|
|
100
|
+
av cluster spark 2xH100 --workspace <workspace-id> --wait
|
|
101
|
+
av cluster ls
|
|
102
|
+
av cluster inspect <cluster-id>
|
|
103
|
+
av cluster stop <cluster-id>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Direct-connect requires the scheduler to be able to resolve the head hypervisor public IP and (best-effort) open inbound security group rules for `allow_cidr`. If that integration is not configured, the cluster may start but `metadata.rayAddress` / `metadata.sparkRemote` will be missing and auto-connect will fail.
|
|
107
|
+
|
|
108
|
+
Install optional client deps if you want auto-connect:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
pip install "agv[ray]"
|
|
112
|
+
pip install "agv[spark]"
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
The `spark` extra installs PySpark plus Spark Connect runtime deps (pandas/pyarrow/grpcio/grpcio-status/zstandard).
|
|
116
|
+
Keep the PySpark major/minor in sync with the Spark server version (defaults to Spark 3.5.x).
|
|
117
|
+
|
|
118
|
+
### Ray (Ray Client)
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
import agentenv as av
|
|
122
|
+
|
|
123
|
+
# Shape formats:
|
|
124
|
+
# - "4x2xH100" => head + 4 workers, 2x H100 per worker
|
|
125
|
+
# - "2xH100" => single node (head only), 2x H100 on the head
|
|
126
|
+
cluster = av.ray_init("4x2xH100", allow_cidr="1.2.3.4/32")
|
|
127
|
+
|
|
128
|
+
import ray
|
|
129
|
+
|
|
130
|
+
@ray.remote
|
|
131
|
+
def f(x):
|
|
132
|
+
return x + 1
|
|
133
|
+
|
|
134
|
+
print(ray.get(f.remote(1)))
|
|
135
|
+
|
|
136
|
+
cluster.close(stop_cluster=True)
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Spark (Spark Connect)
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
import agentenv as av
|
|
143
|
+
|
|
144
|
+
spark = av.spark_init("4x2xH100", allow_cidr="1.2.3.4/32")
|
|
145
|
+
print(spark.range(10).count())
|
|
146
|
+
|
|
147
|
+
spark.close(stop_cluster=True)
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Notes:
|
|
151
|
+
- `spark.remote` is a standard Spark Connect URL that includes an auth param: `sc://<host>:<port>/;x-api-key=<token>`.
|
|
152
|
+
- The Spark head image must include the gRPC auth proxy dependency (`haproxy`). Use `Dockerfile.spark` and `scripts/ci/build-public-spark-image.sh`, then set `SPARK_IMAGE_DEFAULT` on the api-server (or pass `image=` explicitly).
|
|
153
|
+
|
|
154
|
+
## Commands
|
|
155
|
+
|
|
156
|
+
### Authentication
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
av login --api-key <key> # Login with API key
|
|
160
|
+
av login # Browser-based login
|
|
161
|
+
av login --username <user> --password <pass> # Local dev login
|
|
162
|
+
av logout # Logout
|
|
163
|
+
av auth status # Show auth status
|
|
164
|
+
av auth create-key "My CLI Key" # Create API key
|
|
165
|
+
av auth list-keys # List API keys
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Sandbox Management
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
av run --type xl -- python3 -m http.server # Create and run
|
|
172
|
+
av run --expose 8080:http -- node server.js # With port exposed
|
|
173
|
+
av ls # List sandboxes
|
|
174
|
+
av inspect <id> # Show details
|
|
175
|
+
av logs -f <id> # Follow logs
|
|
176
|
+
av stop <id> # Stop sandbox
|
|
177
|
+
av rm <id> # Delete sandbox
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Preset Types
|
|
181
|
+
|
|
182
|
+
| Type | CPU | Memory |
|
|
183
|
+
|-------|--------|--------|
|
|
184
|
+
| micro | 500 | 512 MB |
|
|
185
|
+
| small | 2000 | 4 GB |
|
|
186
|
+
| medium| 4000 | 8 GB |
|
|
187
|
+
| large | 8000 | 16 GB |
|
|
188
|
+
| xl | 16000 | 32 GB |
|
|
189
|
+
|
|
190
|
+
### Snapshots
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
av snapshot create <sandbox-id> --name "My Environment"
|
|
194
|
+
av snapshot ls
|
|
195
|
+
av snapshot restore <snapshot-id>
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Apps
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
av app create --name web --port 8080 --min 0 --max 3
|
|
202
|
+
av app create --name api --port 8080 --ready http_health --health-path /health
|
|
203
|
+
av app deploy web --snapshot <snapshot-id>
|
|
204
|
+
av app ls
|
|
205
|
+
av app inspect <app-id-or-slug>
|
|
206
|
+
av app logs <app-id-or-slug>
|
|
207
|
+
av app rm <app-id-or-slug>
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
Notes:
|
|
211
|
+
- Ready types: `port_accessible`, `http_health`.
|
|
212
|
+
- If you specify `http_health` without `--health-path`, the CLI defaults to `/health`.
|
|
213
|
+
|
|
214
|
+
### av.function (Single-node remote function)
|
|
215
|
+
|
|
216
|
+
```python
|
|
217
|
+
import agentenv as av
|
|
218
|
+
|
|
219
|
+
@av.function("small", image="python:3.11-slim")
|
|
220
|
+
def add(x, y):
|
|
221
|
+
return x + y
|
|
222
|
+
|
|
223
|
+
print(add(2, 3))
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
Using an ImageBuilder:
|
|
227
|
+
|
|
228
|
+
```python
|
|
229
|
+
import agentenv as av
|
|
230
|
+
|
|
231
|
+
builder = av.py().python_packages(["numpy"])
|
|
232
|
+
|
|
233
|
+
@av.function("small", image=builder)
|
|
234
|
+
def norm(x):
|
|
235
|
+
import numpy as np
|
|
236
|
+
return float(np.linalg.norm(x))
|
|
237
|
+
|
|
238
|
+
print(norm([3, 4]))
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
Notes:
|
|
242
|
+
- Only single-node specs are supported (preset types like `small`, or `cpu:mem`).
|
|
243
|
+
- The function must be importable in the sandbox image (no nested or `__main__` functions).
|
|
244
|
+
|
|
245
|
+
### Browser Sessions
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
av browser create # Create browser session
|
|
249
|
+
av browser create --screen-width 1920 --screen-height 1080 --stealth
|
|
250
|
+
av browser create --profile-mode ephemeral --rrweb
|
|
251
|
+
av browser ls
|
|
252
|
+
av browser inspect <id>
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### Notebook Sessions
|
|
256
|
+
|
|
257
|
+
```bash
|
|
258
|
+
av notebook session create --workspace <workspace-id>
|
|
259
|
+
av notebook session create --workspace <workspace-id> --type xl
|
|
260
|
+
av notebook session create --workspace <workspace-id> --image docker://quay.io/jupyter/datascience-notebook:notebook-7.5.5
|
|
261
|
+
av notebook session create --workspace <workspace-id> --storage-mode persistent --idle-ttl 600
|
|
262
|
+
av notebook session list
|
|
263
|
+
av notebook session get <id>
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### API Coverage
|
|
267
|
+
|
|
268
|
+
The CLI focuses on common day-to-day workflows. The Mintlify site and checked-in OpenAPI schema document the full `api-server` surface, including operational resources such as browser profiles, managed agents, proxy usage, captcha usage, and webhook ingress.
|
|
269
|
+
|
|
270
|
+
### Workspaces
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
av workspace create "My Workspace"
|
|
274
|
+
av workspace ls
|
|
275
|
+
av workspace use <workspace-id>
|
|
276
|
+
av workspace secret-set <ws-id> KEY value
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### Files
|
|
280
|
+
|
|
281
|
+
```bash
|
|
282
|
+
av file upload ./myfile.txt
|
|
283
|
+
av file download /remote.txt ./local.txt
|
|
284
|
+
av file ls
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### Workflows
|
|
288
|
+
|
|
289
|
+
```bash
|
|
290
|
+
av workflow ls
|
|
291
|
+
av workflow create "Daily Sync" --file workflow.json
|
|
292
|
+
av workflow inspect <workflow-id>
|
|
293
|
+
av workflow update <workflow-id> --file workflow.json
|
|
294
|
+
av workflow deploy <workflow-id>
|
|
295
|
+
av workflow undeploy <workflow-id>
|
|
296
|
+
av workflow execute <workflow-id> --input '{"customerId":"cus_123"}'
|
|
297
|
+
av workflow execute-in-memory --workspace-id <workspace-id> --file workflow.json
|
|
298
|
+
av workflow executions <workflow-id>
|
|
299
|
+
av workflow execution <workflow-id> <execution-id>
|
|
300
|
+
av workflow cancel <workflow-id> <execution-id>
|
|
301
|
+
av workflow metrics <workflow-id>
|
|
302
|
+
av workflow metrics-timeseries <workflow-id> --interval day
|
|
303
|
+
av workflow node-definitions
|
|
304
|
+
av workflow node-definition webhook
|
|
305
|
+
av workflow plugins
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
### Billing
|
|
309
|
+
|
|
310
|
+
```bash
|
|
311
|
+
av balance # Show balance
|
|
312
|
+
av billing history # Transaction history
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
### Configuration
|
|
316
|
+
|
|
317
|
+
```bash
|
|
318
|
+
av set type xl # Set default type
|
|
319
|
+
av set image python:3.11 # Set default image
|
|
320
|
+
av set workspace <workspace-id> # Set default workspace
|
|
321
|
+
av config show # Show configuration
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
## AI Gateway
|
|
325
|
+
|
|
326
|
+
The CLI includes full support for the AgentEnv AI Gateway:
|
|
327
|
+
|
|
328
|
+
```bash
|
|
329
|
+
# Chat with AI models
|
|
330
|
+
av ai chat "Hello!" --model gpt-4
|
|
331
|
+
|
|
332
|
+
# Manage providers
|
|
333
|
+
av ai upstreams list
|
|
334
|
+
av ai pools create --name production
|
|
335
|
+
|
|
336
|
+
# See the dedicated AI Gateway guide for complete documentation
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
See the AI Gateway guide:
|
|
340
|
+
<https://github.com/agentenv/monorepo/blob/main/cli/README-AI-GATEWAY.md>
|
|
341
|
+
|
|
342
|
+
## Configuration
|
|
343
|
+
|
|
344
|
+
The CLI reads configuration from multiple sources (in priority order):
|
|
345
|
+
|
|
346
|
+
1. Command-line flags (`--api-url`, `--workspace`, etc.)
|
|
347
|
+
2. Environment variables (`AGENTENV_API_URL`, `AGENTENV_API_KEY`, etc.)
|
|
348
|
+
3. Config file (`~/.agentenv/config.yaml`)
|
|
349
|
+
4. Project `.env` file
|
|
350
|
+
5. Built-in defaults
|
|
351
|
+
|
|
352
|
+
### Config File (~/.agentenv/config.yaml)
|
|
353
|
+
|
|
354
|
+
```yaml
|
|
355
|
+
api_url: http://localhost:3000
|
|
356
|
+
workspace: wk_abc123
|
|
357
|
+
|
|
358
|
+
defaults:
|
|
359
|
+
type: small
|
|
360
|
+
image: docker.io/library/python:3.11-slim
|
|
361
|
+
cpu: 2000
|
|
362
|
+
memory: 4096
|
|
363
|
+
region: us-east-1
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
Use the API root as `api_url` without `/v1`. If you do pass a `/v1` suffix, the CLI normalizes it automatically.
|
|
367
|
+
|
|
368
|
+
## Release
|
|
369
|
+
|
|
370
|
+
Build release artifacts locally:
|
|
371
|
+
|
|
372
|
+
```bash
|
|
373
|
+
cd cli
|
|
374
|
+
uv build
|
|
375
|
+
python3 -m twine check dist/*
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
Release flow:
|
|
379
|
+
|
|
380
|
+
```bash
|
|
381
|
+
# 1. Bump the package version in cli/src/agentenv/_version.py
|
|
382
|
+
|
|
383
|
+
# 2. Sanity-check the version metadata
|
|
384
|
+
cd cli
|
|
385
|
+
python3 scripts/check_release_version.py --print-version
|
|
386
|
+
|
|
387
|
+
# 3. Build and validate the distributions
|
|
388
|
+
uv build
|
|
389
|
+
python3 -m twine check dist/*
|
|
390
|
+
|
|
391
|
+
# 4. Tag the release with the enforced format
|
|
392
|
+
git tag "agv-v$(python3 scripts/check_release_version.py --print-version)"
|
|
393
|
+
git push origin --tags
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
Upload them manually when you have PyPI credentials:
|
|
397
|
+
|
|
398
|
+
```bash
|
|
399
|
+
python3 -m twine upload dist/*
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
The repository also includes a GitHub Actions workflow for trusted publishing to PyPI, and it rejects tags whose version does not match the package version.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# AI Gateway CLI and SDK
|
|
2
|
+
|
|
3
|
+
## Quick Start
|
|
4
|
+
|
|
5
|
+
### CLI
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Set your AI Gateway key
|
|
9
|
+
export AGENTENV_AI_KEY="cr_xxxxx"
|
|
10
|
+
|
|
11
|
+
# Or save to config
|
|
12
|
+
av config set-ai-key cr_xxxxx
|
|
13
|
+
|
|
14
|
+
# Chat with AI
|
|
15
|
+
av ai chat "What is the capital of France?"
|
|
16
|
+
av ai chat "Explain quantum computing" --model gpt-4
|
|
17
|
+
av ai chat "Write a function" --system-prompt "You are a Python expert"
|
|
18
|
+
|
|
19
|
+
# Include files
|
|
20
|
+
av ai chat "Review this code" --file main.py --file utils.py
|
|
21
|
+
|
|
22
|
+
# Interactive mode
|
|
23
|
+
av ai chat --interactive
|
|
24
|
+
|
|
25
|
+
# Management (requires login with JWT)
|
|
26
|
+
av login
|
|
27
|
+
av ai providers
|
|
28
|
+
av ai models
|
|
29
|
+
av ai upstreams list
|
|
30
|
+
av ai upstreams create --provider openai --api-key $OPENAI_KEY --name "OpenAI"
|
|
31
|
+
av ai pools create --name production --strategy round-robin
|
|
32
|
+
av ai keys create --name "Production Key" --daily-limit 100.00
|
|
33
|
+
av ai usage --start-date 2025-01-01
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### SDK
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
from agentenv import AIClient
|
|
40
|
+
|
|
41
|
+
# Initialize
|
|
42
|
+
client = AIClient(api_key="cr_xxxxx")
|
|
43
|
+
|
|
44
|
+
# Chat completion
|
|
45
|
+
response = client.chat.completions.create(
|
|
46
|
+
model="gpt-4",
|
|
47
|
+
messages=[{"role": "user", "content": "Hello!"}]
|
|
48
|
+
)
|
|
49
|
+
print(response.choices[0].message.content)
|
|
50
|
+
|
|
51
|
+
# Streaming
|
|
52
|
+
for chunk in client.chat.completions.create(
|
|
53
|
+
model="gpt-4",
|
|
54
|
+
messages=[{"role": "user", "content": "Tell me a story"}],
|
|
55
|
+
stream=True
|
|
56
|
+
):
|
|
57
|
+
print(chunk.choices[0].delta.content, end="")
|
|
58
|
+
|
|
59
|
+
# Embeddings
|
|
60
|
+
embeddings = client.embeddings.create(
|
|
61
|
+
model="text-embedding-3-small",
|
|
62
|
+
input="Hello world"
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
# Management
|
|
66
|
+
upstreams = client.management.list_upstreams()
|
|
67
|
+
key = client.management.create_key(name="New Key", daily_limit=50.00)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Environment Variables
|
|
71
|
+
|
|
72
|
+
- `AGENTENV_AI_KEY` - AI Gateway API key (for chat/embeddings)
|
|
73
|
+
- `AGENTENV_API_KEY` - Management API key (for upstreams/pools/keys)
|
|
74
|
+
- `AGENTENV_AI_MODEL` - Default model (default: gpt-4o)
|