Skip to content

Commit

Permalink
support trailing slash in API paths
Browse files Browse the repository at this point in the history
  • Loading branch information
wintonzheng committed Apr 23, 2024
1 parent 550ad65 commit 27a2bbe
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions skyvern/forge/sdk/routes/agent_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@


@base_router.post("/webhook", tags=["server"])
@base_router.post("/webhook/", tags=["server"], include_in_schema=False)
async def webhook(
request: Request,
x_skyvern_signature: Annotated[str | None, Header()] = None,
Expand Down Expand Up @@ -73,6 +74,7 @@ async def webhook(


@base_router.get("/heartbeat", tags=["server"])
@base_router.get("/heartbeat/", tags=["server"], include_in_schema=False)
async def check_server_status() -> Response:
"""
Check if the server is running.
Expand All @@ -81,6 +83,7 @@ async def check_server_status() -> Response:


@base_router.post("/tasks", tags=["agent"], response_model=CreateTaskResponse)
@base_router.post("/tasks/", tags=["agent"], response_model=CreateTaskResponse, include_in_schema=False)
async def create_agent_task(
background_tasks: BackgroundTasks,
task: TaskRequest,
Expand Down Expand Up @@ -112,11 +115,25 @@ async def create_agent_task(
response_model=Step,
summary="Executes a specific step",
)
@base_router.post(
"/tasks/{task_id}/steps/{step_id}/",
tags=["agent"],
response_model=Step,
summary="Executes a specific step",
include_in_schema=False,
)
@base_router.post(
"/tasks/{task_id}/steps",
tags=["agent"],
response_model=Step,
summary="Executes the next step",
)
@base_router.post(
"/tasks/{task_id}/steps/",
tags=["agent"],
response_model=Step,
summary="Executes the next step",
include_in_schema=False,
)
async def execute_agent_task_step(
task_id: str,
Expand Down Expand Up @@ -176,6 +193,7 @@ async def execute_agent_task_step(


@base_router.get("/tasks/{task_id}", response_model=TaskResponse)
@base_router.get("/tasks/{task_id}/", response_model=TaskResponse, include_in_schema=False)
async def get_task(
task_id: str,
current_org: Organization = Depends(org_auth_service.get_current_org),
Expand Down Expand Up @@ -263,6 +281,12 @@ async def get_task(
tags=["agent"],
response_model=TaskResponse,
)
@base_router.post(
"/tasks/{task_id}/retry_webhook/",
tags=["agent"],
response_model=TaskResponse,
include_in_schema=False,
)
async def retry_webhook(
task_id: str,
current_org: Organization = Depends(org_auth_service.get_current_org),
Expand All @@ -288,6 +312,7 @@ async def retry_webhook(


@base_router.get("/internal/tasks/{task_id}", response_model=list[Task])
@base_router.get("/internal/tasks/{task_id}/", response_model=list[Task], include_in_schema=False)
async def get_task_internal(
task_id: str,
current_org: Organization = Depends(org_auth_service.get_current_org),
Expand All @@ -310,6 +335,7 @@ async def get_task_internal(


@base_router.get("/tasks", tags=["agent"], response_model=list[Task])
@base_router.get("/tasks/", tags=["agent"], response_model=list[Task], include_in_schema=False)
async def get_agent_tasks(
page: int = Query(1, ge=1),
page_size: int = Query(10, ge=1),
Expand All @@ -328,6 +354,7 @@ async def get_agent_tasks(


@base_router.get("/internal/tasks", tags=["agent"], response_model=list[Task])
@base_router.get("/internal/tasks/", tags=["agent"], response_model=list[Task], include_in_schema=False)
async def get_agent_tasks_internal(
page: int = Query(1, ge=1),
page_size: int = Query(10, ge=1),
Expand All @@ -346,6 +373,7 @@ async def get_agent_tasks_internal(


@base_router.get("/tasks/{task_id}/steps", tags=["agent"], response_model=list[Step])
@base_router.get("/tasks/{task_id}/steps/", tags=["agent"], response_model=list[Step], include_in_schema=False)
async def get_agent_task_steps(
task_id: str,
current_org: Organization = Depends(org_auth_service.get_current_org),
Expand All @@ -361,6 +389,12 @@ async def get_agent_task_steps(


@base_router.get("/tasks/{task_id}/steps/{step_id}/artifacts", tags=["agent"], response_model=list[Artifact])
@base_router.get(
"/tasks/{task_id}/steps/{step_id}/artifacts/",
tags=["agent"],
response_model=list[Artifact],
include_in_schema=False,
)
async def get_agent_task_step_artifacts(
task_id: str,
step_id: str,
Expand Down Expand Up @@ -393,6 +427,7 @@ class ActionResultTmp(BaseModel):


@base_router.get("/tasks/{task_id}/actions", response_model=list[ActionResultTmp])
@base_router.get("/tasks/{task_id}/actions/", response_model=list[ActionResultTmp], include_in_schema=False)
async def get_task_actions(
task_id: str,
current_org: Organization = Depends(org_auth_service.get_current_org),
Expand All @@ -409,6 +444,7 @@ async def get_task_actions(


@base_router.post("/workflows/{workflow_id}/run", response_model=RunWorkflowResponse)
@base_router.post("/workflows/{workflow_id}/run/", response_model=RunWorkflowResponse, include_in_schema=False)
async def execute_workflow(
background_tasks: BackgroundTasks,
workflow_id: str,
Expand Down Expand Up @@ -444,6 +480,11 @@ async def execute_workflow(


@base_router.get("/workflows/{workflow_id}/runs/{workflow_run_id}", response_model=WorkflowRunStatusResponse)
@base_router.get(
"/workflows/{workflow_id}/runs/{workflow_run_id}/",
response_model=WorkflowRunStatusResponse,
include_in_schema=False,
)
async def get_workflow_run(
workflow_id: str,
workflow_run_id: str,
Expand All @@ -468,6 +509,17 @@ async def get_workflow_run(
},
response_model=Workflow,
)
@base_router.post(
"/workflows/",
openapi_extra={
"requestBody": {
"content": {"application/x-yaml": {"schema": WorkflowCreateYAMLRequest.model_json_schema()}},
"required": True,
},
},
response_model=Workflow,
include_in_schema=False,
)
async def create_workflow(
request: Request,
current_org: Organization = Depends(org_auth_service.get_current_org),
Expand Down

0 comments on commit 27a2bbe

Please sign in to comment.