"""The two optional KAB activity steps that put files in front of a workflow's first agent. u1 "Parse Assessment Files" (parse_assessment_files): the person starting the run uploads files (Excel, PDF, CSV, TXT, MD, JSON, YAML); the run form shows the upload field `file`. Hands on `parsed_content`, one block of text. a1 "Artifacts" (select_artifacts): artifacts already in the project, fixed in the workflow by id (a `static` input). Hands on `artifacts` (records with file_path / content) or, if a step asks for it, `parsed_content` (the decoded files). Activity names, field names and outputs are the platform's registrations (agent-builder-kubernetes-deployment/.../register_activities.py, @7adfc87f). Standard library only. """ from __future__ import annotations from typing import Any, Dict, List UPLOAD_ID = "u1" ARTIFACTS_ID = "a1" CATEGORY = "file_and_data_processing" # Every agent step in every Feature's workflow: the executor's step limit (timeout_minutes) and the agent call's # endpoint timeout. The executor uses timeout_minutes for both the activity and the call; endpoint.timeout is kept # equal so the export reads consistently. AGENT_STEP_TIMEOUT_MINUTES = 20 def _activity_step(step_id: str, activity: str, display: str, description: str, inputs: Dict[str, Any], input_schema: Dict[str, Any], output_schema: Dict[str, Any], y: int) -> Dict[str, Any]: return { "id": step_id, "agent": activity, "agent_type": activity, "name": display, "timeout_minutes": 5, "type": "sequential", "executionLevel": 0, "parallelGroup": 0, "depends_on": [], "position": {"x": -320, "y": y}, "inputs": inputs, "hitl": {"enabled": False}, "data": {"agentType": activity, "name": display, "description": description, "category": CATEGORY, "temporalActivityName": activity, "inputSchema": input_schema, "outputSchema": output_schema}, } def upload_step(label: str, description: str) -> Dict[str, Any]: return _activity_step( UPLOAD_ID, "parse_assessment_files", "Parse Assessment Files", description, {"from_workflow": ["file"]}, {"type": "object", "properties": {"file": { "type": "file", "label": label, "description": description, "accept": ".xlsx,.xls,.pdf,.csv,.txt,.md,.json,.yaml,.yml,.log"}}, "required": []}, {"type": "object", "properties": { "parsed_content": {"type": "string", "description": "Combined parsed text content"}, "file_metadata": {"type": "array", "description": "Metadata about each parsed file"}, "total_files": {"type": "number"}, "total_content_length": {"type": "number"}}}, y=0) def artifacts_step(artifact_ids: List[str], description: str) -> Dict[str, Any]: return _activity_step( ARTIFACTS_ID, "select_artifacts", "Artifacts", description, {"static": {"artifact_ids": list(artifact_ids)}}, {"type": "object", "properties": {"artifact_ids": { "type": "array", "items": {"type": "string"}, "label": "Artifacts", "description": "One or more artifacts to load", "uiFieldType": "artifact_picker"}}, "required": ["artifact_ids"]}, {"type": "object", "properties": {"artifacts": { "type": "array", "description": "One record per selected file: name, file_path, content_type, size, " "and content (base64) when the file fits the inline limit"}}}, y=160) def front_steps(with_upload: bool, artifact_ids: List[str], upload_label: str, upload_description: str, artifacts_description: str) -> List[Dict[str, Any]]: steps = [] if with_upload: steps.append(upload_step(upload_label, upload_description)) if artifact_ids: steps.append(artifacts_step(artifact_ids, artifacts_description)) return steps def shift(step: Dict[str, Any], by: int) -> Dict[str, Any]: """Move an agent step after the front steps: one level later, one column right.""" step["executionLevel"] += by step["parallelGroup"] += by return step