Skip to content

Commit 43b8736

Browse files
committed
adding the compression stuff
1 parent c29afd0 commit 43b8736

File tree

6 files changed

+285
-22
lines changed

6 files changed

+285
-22
lines changed

ab000-hello-acp-latest.tar.gz

5.06 KB
Binary file not shown.

requirements-dev.lock

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,16 @@ aiohttp==3.13.2
1616
# via agentex-sdk
1717
# via httpx-aiohttp
1818
# via litellm
19-
aiosignal==1.3.2
19+
aiosignal==1.4.0
2020
# via aiohttp
2121
annotated-types==0.7.0
2222
# via pydantic
23+
anthropic==0.75.0
24+
# via agentex-sdk
2325
anyio==4.10.0
2426
# via agentex-sdk
27+
# via anthropic
28+
# via claude-agent-sdk
2529
# via httpx
2630
# via mcp
2731
# via openai
@@ -51,6 +55,8 @@ certifi==2023.7.22
5155
# via requests
5256
charset-normalizer==3.4.3
5357
# via requests
58+
claude-agent-sdk==0.1.19
59+
# via agentex-sdk
5460
click==8.2.1
5561
# via litellm
5662
# via typer
@@ -76,9 +82,12 @@ distlib==0.3.7
7682
# via virtualenv
7783
distro==1.9.0
7884
# via agentex-sdk
85+
# via anthropic
7986
# via openai
8087
# via scale-gp
8188
# via scale-gp-beta
89+
docstring-parser==0.17.0
90+
# via anthropic
8291
envier==0.6.1
8392
# via ddtrace
8493
execnet==2.1.1
@@ -108,6 +117,7 @@ httpcore==1.0.9
108117
# via httpx
109118
httpx==0.27.2
110119
# via agentex-sdk
120+
# via anthropic
111121
# via httpx-aiohttp
112122
# via litellm
113123
# via mcp
@@ -143,6 +153,7 @@ jinja2==3.1.6
143153
# via agentex-sdk
144154
# via litellm
145155
jiter==0.10.0
156+
# via anthropic
146157
# via openai
147158
json-log-formatter==1.1.1
148159
# via agentex-sdk
@@ -172,6 +183,7 @@ matplotlib-inline==0.1.7
172183
# via ipython
173184
mcp==1.12.4
174185
# via agentex-sdk
186+
# via claude-agent-sdk
175187
# via openai-agents
176188
mdurl==0.1.2
177189
# via markdown-it-py
@@ -204,10 +216,10 @@ packaging==23.2
204216
# via ipykernel
205217
# via nox
206218
# via pytest
207-
pathspec==0.12.1
208-
# via mypy
209219
parso==0.8.4
210220
# via jedi
221+
pathspec==0.12.1
222+
# via mypy
211223
pexpect==4.9.0
212224
# via ipython
213225
platformdirs==3.11.0
@@ -237,6 +249,7 @@ pyasn1-modules==0.4.2
237249
# via google-auth
238250
pydantic==2.11.9
239251
# via agentex-sdk
252+
# via anthropic
240253
# via fastapi
241254
# via litellm
242255
# via mcp
@@ -329,6 +342,7 @@ six==1.16.0
329342
# via python-dateutil
330343
sniffio==1.3.1
331344
# via agentex-sdk
345+
# via anthropic
332346
# via anyio
333347
# via httpx
334348
# via openai
@@ -343,6 +357,8 @@ starlette==0.46.2
343357
# via mcp
344358
temporalio==1.18.2
345359
# via agentex-sdk
360+
termcolor==3.3.0
361+
# via yaspin
346362
tiktoken==0.11.0
347363
# via litellm
348364
time-machine==2.9.0
@@ -374,6 +390,7 @@ types-urllib3==1.26.25.14
374390
typing-extensions==4.12.2
375391
# via agentex-sdk
376392
# via aiosignal
393+
# via anthropic
377394
# via anyio
378395
# via fastapi
379396
# via huggingface-hub
@@ -392,7 +409,6 @@ typing-extensions==4.12.2
392409
# via temporalio
393410
# via typer
394411
# via typing-inspection
395-
# via virtualenv
396412
typing-inspection==0.4.2
397413
# via pydantic
398414
# via pydantic-settings
@@ -418,5 +434,7 @@ wrapt==1.17.3
418434
# via ddtrace
419435
yarl==1.20.0
420436
# via aiohttp
437+
yaspin==3.4.0
438+
# via agentex-sdk
421439
zipp==3.23.0
422440
# via importlib-metadata

requirements.lock

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,16 @@ aiohttp==3.13.2
1616
# via agentex-sdk
1717
# via httpx-aiohttp
1818
# via litellm
19-
aiosignal==1.3.2
19+
aiosignal==1.4.0
2020
# via aiohttp
2121
annotated-types==0.7.0
2222
# via pydantic
23+
anthropic==0.75.0
24+
# via agentex-sdk
2325
anyio==4.10.0
2426
# via agentex-sdk
27+
# via anthropic
28+
# via claude-agent-sdk
2529
# via httpx
2630
# via mcp
2731
# via openai
@@ -49,6 +53,8 @@ certifi==2023.7.22
4953
# via requests
5054
charset-normalizer==3.4.3
5155
# via requests
56+
claude-agent-sdk==0.1.19
57+
# via agentex-sdk
5258
click==8.2.1
5359
# via litellm
5460
# via typer
@@ -69,9 +75,12 @@ decorator==5.2.1
6975
# via ipython
7076
distro==1.8.0
7177
# via agentex-sdk
78+
# via anthropic
7279
# via openai
7380
# via scale-gp
7481
# via scale-gp-beta
82+
docstring-parser==0.17.0
83+
# via anthropic
7584
envier==0.6.1
7685
# via ddtrace
7786
executing==2.2.0
@@ -98,6 +107,7 @@ httpcore==1.0.9
98107
# via httpx
99108
httpx==0.27.2
100109
# via agentex-sdk
110+
# via anthropic
101111
# via httpx-aiohttp
102112
# via litellm
103113
# via mcp
@@ -132,6 +142,7 @@ jinja2==3.1.6
132142
# via agentex-sdk
133143
# via litellm
134144
jiter==0.10.0
145+
# via anthropic
135146
# via openai
136147
json-log-formatter==1.1.1
137148
# via agentex-sdk
@@ -161,6 +172,7 @@ matplotlib-inline==0.1.7
161172
# via ipython
162173
mcp==1.12.4
163174
# via agentex-sdk
175+
# via claude-agent-sdk
164176
# via openai-agents
165177
mdurl==0.1.2
166178
# via markdown-it-py
@@ -200,9 +212,6 @@ prompt-toolkit==3.0.51
200212
propcache==0.3.1
201213
# via aiohttp
202214
# via yarl
203-
pydantic==2.12.5
204-
# via agentex-sdk
205-
pydantic-core==2.41.5
206215
protobuf==5.29.5
207216
# via ddtrace
208217
# via temporalio
@@ -217,6 +226,19 @@ pyasn1==0.6.1
217226
# via rsa
218227
pyasn1-modules==0.4.2
219228
# via google-auth
229+
pydantic==2.12.5
230+
# via agentex-sdk
231+
# via anthropic
232+
# via fastapi
233+
# via litellm
234+
# via mcp
235+
# via openai
236+
# via openai-agents
237+
# via pydantic-settings
238+
# via python-on-whales
239+
# via scale-gp
240+
# via scale-gp-beta
241+
pydantic-core==2.41.5
220242
# via pydantic
221243
pydantic-settings==2.10.1
222244
# via mcp
@@ -290,7 +312,8 @@ six==1.17.0
290312
# via python-dateutil
291313
sniffio==1.3.0
292314
# via agentex-sdk
293-
typing-extensions==4.15.0
315+
# via anthropic
316+
# via anyio
294317
# via httpx
295318
# via openai
296319
# via scale-gp
@@ -304,6 +327,8 @@ starlette==0.46.2
304327
# via mcp
305328
temporalio==1.18.2
306329
# via agentex-sdk
330+
termcolor==3.3.0
331+
# via yaspin
307332
tiktoken==0.11.0
308333
# via litellm
309334
tokenizers==0.21.4
@@ -331,8 +356,10 @@ types-requests==2.31.0.6
331356
# via openai-agents
332357
types-urllib3==1.26.25.14
333358
# via types-requests
359+
typing-extensions==4.15.0
334360
# via agentex-sdk
335361
# via aiosignal
362+
# via anthropic
336363
# via anyio
337364
# via fastapi
338365
# via huggingface-hub
@@ -372,5 +399,7 @@ wrapt==1.17.3
372399
# via ddtrace
373400
yarl==1.20.0
374401
# via aiohttp
402+
yaspin==3.4.0
403+
# via agentex-sdk
375404
zipp==3.23.0
376405
# via importlib-metadata

src/agentex/lib/cli/commands/agents.py

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
from agentex.lib.cli.handlers.agent_handlers import (
2727
run_agent,
2828
build_agent,
29+
prepare_cloud_build_context,
30+
parse_build_args,
31+
CloudBuildContext,
2932
)
3033
from agentex.lib.cli.handlers.deploy_handlers import (
3134
HelmError,
@@ -164,6 +167,101 @@ def build(
164167
raise typer.Exit(1) from e
165168

166169

170+
@agents.command(name="package")
171+
def package(
172+
manifest: str = typer.Option(..., help="Path to the manifest you want to use"),
173+
tag: str | None = typer.Option(
174+
None,
175+
"--tag",
176+
"-t",
177+
help="Image tag (defaults to deployment.image.tag from manifest, or 'latest')",
178+
),
179+
output: str | None = typer.Option(
180+
None,
181+
"--output",
182+
"-o",
183+
help="Output filename for the tarball (defaults to <agent-name>-<tag>.tar.gz)",
184+
),
185+
build_arg: builtins.list[str] | None = typer.Option( # noqa: B008
186+
None,
187+
"--build-arg",
188+
"-b",
189+
help="Build argument in KEY=VALUE format (can be repeated)",
190+
),
191+
):
192+
"""
193+
Package an agent's build context into a tarball for cloud builds.
194+
195+
Reads manifest.yaml, prepares build context according to include_paths and
196+
dockerignore, then saves a compressed tarball to the current directory.
197+
198+
The tag defaults to the value in deployment.image.tag from the manifest.
199+
200+
Example:
201+
agentex agents package --manifest manifest.yaml
202+
agentex agents package --manifest manifest.yaml --tag v1.0
203+
"""
204+
typer.echo(f"Packaging build context from manifest: {manifest}")
205+
206+
# Validate manifest exists
207+
manifest_path = Path(manifest)
208+
if not manifest_path.exists():
209+
typer.echo(f"Error: manifest not found at {manifest_path}", err=True)
210+
raise typer.Exit(1)
211+
212+
try:
213+
# Prepare the build context (tag defaults from manifest if not provided)
214+
build_context = prepare_cloud_build_context(
215+
manifest_path=str(manifest_path),
216+
tag=tag,
217+
build_args=build_arg,
218+
)
219+
220+
# Determine output filename using the resolved tag
221+
if output:
222+
output_filename = output
223+
else:
224+
output_filename = f"{build_context.agent_name}-{build_context.tag}.tar.gz"
225+
226+
# Save tarball to current working directory
227+
output_path = Path.cwd() / output_filename
228+
output_path.write_bytes(build_context.archive_bytes)
229+
230+
typer.echo(f"\nTarball saved to: {output_path}")
231+
typer.echo(f"Size: {build_context.build_context_size_kb:.1f} KB")
232+
233+
# Output the build parameters needed for cloud build
234+
typer.echo("\n" + "=" * 60)
235+
typer.echo("Build Parameters for Cloud Build API:")
236+
typer.echo("=" * 60)
237+
typer.echo(f" agent_name: {build_context.agent_name}")
238+
typer.echo(f" image_name: {build_context.image_name}")
239+
typer.echo(f" tag: {build_context.tag}")
240+
typer.echo(f" context_file: {output_path}")
241+
242+
if build_arg:
243+
parsed_args = parse_build_args(build_arg)
244+
typer.echo(f" build_args: {parsed_args}")
245+
246+
typer.echo("")
247+
typer.echo("Command:")
248+
build_args_str = ""
249+
if build_arg:
250+
build_args_str = " ".join(f'--build-arg "{arg}"' for arg in build_arg)
251+
build_args_str = f" {build_args_str}"
252+
typer.echo(
253+
f' sgp agentex build --context "{output_path}" '
254+
f'--image-name "{build_context.image_name}" '
255+
f'--tag "{build_context.tag}"{build_args_str}'
256+
)
257+
typer.echo("=" * 60)
258+
259+
except Exception as e:
260+
typer.echo(f"Error packaging build context: {str(e)}", err=True)
261+
logger.exception("Error packaging build context")
262+
raise typer.Exit(1) from e
263+
264+
167265
@agents.command()
168266
def run(
169267
manifest: str = typer.Option(..., help="Path to the manifest you want to use"),

0 commit comments

Comments
 (0)