Add task tool result bridge and evidence attachment workflow
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from urllib.parse import urlencode
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -46,3 +47,25 @@ def normalize_task_tool_code(code: str | None) -> str:
|
||||
if value not in valid:
|
||||
raise ValueError(f"Unsupported task tool: {value}")
|
||||
return value
|
||||
|
||||
|
||||
def build_task_tool_launch_url(
|
||||
tool: TaskToolDefinition,
|
||||
*,
|
||||
client_id: int,
|
||||
task_id: int,
|
||||
tool_run_id: int,
|
||||
) -> str:
|
||||
if not tool.launch_url:
|
||||
raise ValueError("This ERP task tool does not expose a launch URL.")
|
||||
query = urlencode(
|
||||
{
|
||||
"client_id": int(client_id),
|
||||
"task_id": int(task_id),
|
||||
"task_tool_run_id": int(tool_run_id),
|
||||
"task_return_url": f"/services/work-tracker/tasks/{int(task_id)}/edit",
|
||||
"task_result_url": f"/services/work-tracker/tool-runs/{int(tool_run_id)}/result",
|
||||
}
|
||||
)
|
||||
separator = "&" if "?" in tool.launch_url else "?"
|
||||
return f"{tool.launch_url}{separator}{query}"
|
||||
|
||||
Reference in New Issue
Block a user