agent-dev-cli 0.0.1b251223__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.
agentdev/cli.py ADDED
@@ -0,0 +1,165 @@
1
+ """
2
+ agentdev CLI - Agent Dev CLI Command Line Interface.
3
+
4
+ Provides a CLI wrapper for running Python agent scripts with automatic
5
+ agentdev instrumentation, eliminating the need for users to modify their code.
6
+
7
+ Usage:
8
+ agentdev run my_agent.py
9
+ agentdev run workflow.py --port 9000
10
+ agentdev run my_agent.py -- --custom-arg value
11
+ """
12
+
13
+ import os
14
+ import sys
15
+ import subprocess
16
+ from importlib.metadata import version as get_version
17
+ from typing import Optional
18
+
19
+ import click
20
+
21
+
22
+ def _get_agentdev_version() -> str:
23
+ """Get the agentdev version from package metadata."""
24
+ try:
25
+ return get_version("agent-dev-cli")
26
+ except Exception:
27
+ return "unknown"
28
+
29
+
30
+ @click.group()
31
+ @click.version_option(version=_get_agentdev_version(), prog_name="agentdev")
32
+ def cli():
33
+ """agentdev - Agent Dev CLI for agent debugging and visualization.
34
+
35
+ Run your Python agent scripts with automatic agentdev instrumentation
36
+ for workflow visualization and debugging in VS Code.
37
+
38
+ Examples:
39
+
40
+ agentdev run my_agent.py
41
+
42
+ agentdev run workflow.py --port 9000
43
+ """
44
+ pass
45
+
46
+
47
+ @cli.command()
48
+ @click.argument('script', type=click.Path(exists=True))
49
+ @click.argument('args', nargs=-1, type=click.UNPROCESSED)
50
+ @click.option(
51
+ '--port', '-p',
52
+ default=8088,
53
+ type=int,
54
+ help='Agent server port (default: 8088)'
55
+ )
56
+ @click.option(
57
+ '--verbose', '-v',
58
+ is_flag=True,
59
+ default=False,
60
+ help='Enable verbose output'
61
+ )
62
+ def run(
63
+ script: str,
64
+ args: tuple,
65
+ port: int,
66
+ verbose: bool
67
+ ):
68
+ """Run a Python agent script with agentdev instrumentation.
69
+
70
+ SCRIPT is the path to the Python agent script to run.
71
+
72
+ Any additional arguments after the script path (or after --)
73
+ will be passed to the script.
74
+
75
+ Examples:
76
+
77
+ agentdev run my_agent.py
78
+
79
+ agentdev run workflow.py --port 9000
80
+
81
+ agentdev run my_agent.py -- --model gpt-4
82
+ """
83
+ # Resolve script to absolute path
84
+ script_path = os.path.abspath(script)
85
+
86
+ if verbose:
87
+ click.echo(f"agentdev: Running {script_path} with instrumentation")
88
+ click.echo(f"agentdev: Port={port}")
89
+
90
+ # Set up environment for instrumentation
91
+ env = os.environ.copy()
92
+ env['AGENTDEV_ENABLED'] = '1'
93
+ env['AGENTDEV_PORT'] = str(port)
94
+ # azure-ai-agentserver SDK starts the HTTP server and listens on DEFAULT_AD_PORT
95
+ # https://github.com/Azure/azure-sdk-for-python/blob/e18d002a1bf56706e83596a4720ec5f21488bab6/sdk/agentserver/azure-ai-agentserver-core/azure/ai/agentserver/core/server/base.py#L233
96
+ env['DEFAULT_AD_PORT'] = str(port)
97
+
98
+ if verbose:
99
+ env['AGENTDEV_VERBOSE'] = '1'
100
+
101
+ # Build command to run the bootstrap module
102
+ cmd = [
103
+ sys.executable,
104
+ '-m', 'agentdev._bootstrap',
105
+ script_path,
106
+ *args
107
+ ]
108
+
109
+ if verbose:
110
+ click.echo(f"agentdev: Executing: {' '.join(cmd)}")
111
+
112
+ try:
113
+ # Run the user's script with instrumentation
114
+ result = subprocess.run(cmd, env=env)
115
+ sys.exit(result.returncode)
116
+ except KeyboardInterrupt:
117
+ click.echo("\nagentdev: Interrupted by user")
118
+ sys.exit(130)
119
+ except Exception as e:
120
+ click.echo(f"agentdev: Error running script: {e}", err=True)
121
+ sys.exit(1)
122
+
123
+
124
+ @cli.command()
125
+ def info():
126
+ """Show agentdev configuration and status information."""
127
+ click.echo("agentdev - Agent Dev CLI")
128
+ click.echo("=" * 40)
129
+ click.echo(f"Version: {_get_agentdev_version()}")
130
+ click.echo(f"Python: {sys.version}")
131
+ click.echo(f"Platform: {sys.platform}")
132
+ click.echo()
133
+
134
+ # Check for VS Code
135
+ term_program = os.environ.get("TERM_PROGRAM", "Unknown")
136
+ term_version = os.environ.get("TERM_PROGRAM_VERSION", "Unknown")
137
+ click.echo(f"Terminal Program: {term_program}")
138
+ click.echo(f"Terminal Version: {term_version}")
139
+ click.echo()
140
+
141
+ # Check installed dependencies
142
+ click.echo("Dependencies:")
143
+ deps = [
144
+ "agent_framework",
145
+ "agent_framework_azure_ai",
146
+ "azure.ai.agentserver.agentframework",
147
+ "starlette",
148
+ ]
149
+ for dep in deps:
150
+ try:
151
+ # Convert package name to importable module name (hyphens to underscores)
152
+ module_name = dep.replace("-", "_")
153
+ __import__(module_name)
154
+ click.echo(f" ✓ {dep}")
155
+ except ImportError:
156
+ click.echo(f" ✗ {dep} (not installed)")
157
+
158
+
159
+ def main():
160
+ """Main entry point for the CLI."""
161
+ cli()
162
+
163
+
164
+ if __name__ == '__main__':
165
+ main()
agentdev/localdebug.py ADDED
@@ -0,0 +1,65 @@
1
+ """
2
+ Workflow visualization setup module.
3
+
4
+ This module provides functionality to set up workflow or agent visualization
5
+ """
6
+
7
+ from agent_framework import WorkflowAgent
8
+ import os
9
+ import sys
10
+ import time
11
+
12
+
13
+ def setup_test_tool(agent_server):
14
+ """
15
+ Set up workflow or agent visualization for an agent server.
16
+
17
+ This function configures a health check endpoint and starts a visualization
18
+ server for workflow agents on port 8090.
19
+
20
+ Args:
21
+ agent_server: The agent server instance to set up visualization for.
22
+ Should have 'app' (Starlette) and 'agent' attributes.
23
+
24
+ Example:
25
+ >>> from azure.ai.agentserver.agentframework import from_agent_framework
26
+ >>> agent_server = from_agent_framework(agent)
27
+ >>> setup_test_tool(agent_server)
28
+ >>> await agent_server.run_async()
29
+ """
30
+ from starlette.applications import Starlette
31
+ from starlette.responses import JSONResponse
32
+ from starlette.routing import Route
33
+ from threading import Thread
34
+ from agentdev.backend.server import TestToolServer
35
+
36
+ async def health_check(request):
37
+ """Health check endpoint handler."""
38
+ return JSONResponse({"status": "ok"}, status_code=200)
39
+
40
+ app = agent_server.app
41
+ agent = agent_server.agent
42
+
43
+ # Mount health check endpoint
44
+ app.mount(
45
+ "/agentdev/health",
46
+ Starlette(routes=[Route("/", health_check)])
47
+ )
48
+
49
+ # Prepare entities for visualization
50
+ entities = []
51
+ if type(agent) == WorkflowAgent:
52
+ entities.append(agent.workflow)
53
+ else:
54
+ entities.append(agent)
55
+
56
+ test_tool_server = TestToolServer(entities)
57
+ test_tool_server.mount_backend(app)
58
+ def show_endspattern():
59
+ time.sleep(2)
60
+ print("agentdev: Application startup complete")
61
+ thread = Thread(target=show_endspattern)
62
+ thread.daemon = True
63
+ thread.start()
64
+
65
+ print(agent)