agentrun-sdk 0.1.2__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.

Potentially problematic release.


This version of agentrun-sdk might be problematic. Click here for more details.

Files changed (115) hide show
  1. agentrun_operation_sdk/cli/__init__.py +1 -0
  2. agentrun_operation_sdk/cli/cli.py +19 -0
  3. agentrun_operation_sdk/cli/common.py +21 -0
  4. agentrun_operation_sdk/cli/runtime/__init__.py +1 -0
  5. agentrun_operation_sdk/cli/runtime/commands.py +203 -0
  6. agentrun_operation_sdk/client/client.py +75 -0
  7. agentrun_operation_sdk/operations/runtime/__init__.py +8 -0
  8. agentrun_operation_sdk/operations/runtime/configure.py +101 -0
  9. agentrun_operation_sdk/operations/runtime/launch.py +82 -0
  10. agentrun_operation_sdk/operations/runtime/models.py +31 -0
  11. agentrun_operation_sdk/services/runtime.py +152 -0
  12. agentrun_operation_sdk/utils/logging_config.py +72 -0
  13. agentrun_operation_sdk/utils/runtime/config.py +94 -0
  14. agentrun_operation_sdk/utils/runtime/container.py +280 -0
  15. agentrun_operation_sdk/utils/runtime/entrypoint.py +203 -0
  16. agentrun_operation_sdk/utils/runtime/schema.py +56 -0
  17. agentrun_sdk/__init__.py +7 -0
  18. agentrun_sdk/agent/__init__.py +25 -0
  19. agentrun_sdk/agent/agent.py +696 -0
  20. agentrun_sdk/agent/agent_result.py +46 -0
  21. agentrun_sdk/agent/conversation_manager/__init__.py +26 -0
  22. agentrun_sdk/agent/conversation_manager/conversation_manager.py +88 -0
  23. agentrun_sdk/agent/conversation_manager/null_conversation_manager.py +46 -0
  24. agentrun_sdk/agent/conversation_manager/sliding_window_conversation_manager.py +179 -0
  25. agentrun_sdk/agent/conversation_manager/summarizing_conversation_manager.py +252 -0
  26. agentrun_sdk/agent/state.py +97 -0
  27. agentrun_sdk/event_loop/__init__.py +9 -0
  28. agentrun_sdk/event_loop/event_loop.py +499 -0
  29. agentrun_sdk/event_loop/streaming.py +319 -0
  30. agentrun_sdk/experimental/__init__.py +4 -0
  31. agentrun_sdk/experimental/hooks/__init__.py +15 -0
  32. agentrun_sdk/experimental/hooks/events.py +123 -0
  33. agentrun_sdk/handlers/__init__.py +10 -0
  34. agentrun_sdk/handlers/callback_handler.py +70 -0
  35. agentrun_sdk/hooks/__init__.py +49 -0
  36. agentrun_sdk/hooks/events.py +80 -0
  37. agentrun_sdk/hooks/registry.py +247 -0
  38. agentrun_sdk/models/__init__.py +10 -0
  39. agentrun_sdk/models/anthropic.py +432 -0
  40. agentrun_sdk/models/bedrock.py +649 -0
  41. agentrun_sdk/models/litellm.py +225 -0
  42. agentrun_sdk/models/llamaapi.py +438 -0
  43. agentrun_sdk/models/mistral.py +539 -0
  44. agentrun_sdk/models/model.py +95 -0
  45. agentrun_sdk/models/ollama.py +357 -0
  46. agentrun_sdk/models/openai.py +436 -0
  47. agentrun_sdk/models/sagemaker.py +598 -0
  48. agentrun_sdk/models/writer.py +449 -0
  49. agentrun_sdk/multiagent/__init__.py +22 -0
  50. agentrun_sdk/multiagent/a2a/__init__.py +15 -0
  51. agentrun_sdk/multiagent/a2a/executor.py +148 -0
  52. agentrun_sdk/multiagent/a2a/server.py +252 -0
  53. agentrun_sdk/multiagent/base.py +92 -0
  54. agentrun_sdk/multiagent/graph.py +555 -0
  55. agentrun_sdk/multiagent/swarm.py +656 -0
  56. agentrun_sdk/py.typed +1 -0
  57. agentrun_sdk/session/__init__.py +18 -0
  58. agentrun_sdk/session/file_session_manager.py +216 -0
  59. agentrun_sdk/session/repository_session_manager.py +152 -0
  60. agentrun_sdk/session/s3_session_manager.py +272 -0
  61. agentrun_sdk/session/session_manager.py +73 -0
  62. agentrun_sdk/session/session_repository.py +51 -0
  63. agentrun_sdk/telemetry/__init__.py +21 -0
  64. agentrun_sdk/telemetry/config.py +194 -0
  65. agentrun_sdk/telemetry/metrics.py +476 -0
  66. agentrun_sdk/telemetry/metrics_constants.py +15 -0
  67. agentrun_sdk/telemetry/tracer.py +563 -0
  68. agentrun_sdk/tools/__init__.py +17 -0
  69. agentrun_sdk/tools/decorator.py +569 -0
  70. agentrun_sdk/tools/executor.py +137 -0
  71. agentrun_sdk/tools/loader.py +152 -0
  72. agentrun_sdk/tools/mcp/__init__.py +13 -0
  73. agentrun_sdk/tools/mcp/mcp_agent_tool.py +99 -0
  74. agentrun_sdk/tools/mcp/mcp_client.py +423 -0
  75. agentrun_sdk/tools/mcp/mcp_instrumentation.py +322 -0
  76. agentrun_sdk/tools/mcp/mcp_types.py +63 -0
  77. agentrun_sdk/tools/registry.py +607 -0
  78. agentrun_sdk/tools/structured_output.py +421 -0
  79. agentrun_sdk/tools/tools.py +217 -0
  80. agentrun_sdk/tools/watcher.py +136 -0
  81. agentrun_sdk/types/__init__.py +5 -0
  82. agentrun_sdk/types/collections.py +23 -0
  83. agentrun_sdk/types/content.py +188 -0
  84. agentrun_sdk/types/event_loop.py +48 -0
  85. agentrun_sdk/types/exceptions.py +81 -0
  86. agentrun_sdk/types/guardrails.py +254 -0
  87. agentrun_sdk/types/media.py +89 -0
  88. agentrun_sdk/types/session.py +152 -0
  89. agentrun_sdk/types/streaming.py +201 -0
  90. agentrun_sdk/types/tools.py +258 -0
  91. agentrun_sdk/types/traces.py +5 -0
  92. agentrun_sdk-0.1.2.dist-info/METADATA +51 -0
  93. agentrun_sdk-0.1.2.dist-info/RECORD +115 -0
  94. agentrun_sdk-0.1.2.dist-info/WHEEL +5 -0
  95. agentrun_sdk-0.1.2.dist-info/entry_points.txt +2 -0
  96. agentrun_sdk-0.1.2.dist-info/top_level.txt +3 -0
  97. agentrun_wrapper/__init__.py +11 -0
  98. agentrun_wrapper/_utils/__init__.py +6 -0
  99. agentrun_wrapper/_utils/endpoints.py +16 -0
  100. agentrun_wrapper/identity/__init__.py +5 -0
  101. agentrun_wrapper/identity/auth.py +211 -0
  102. agentrun_wrapper/memory/__init__.py +6 -0
  103. agentrun_wrapper/memory/client.py +1697 -0
  104. agentrun_wrapper/memory/constants.py +103 -0
  105. agentrun_wrapper/memory/controlplane.py +626 -0
  106. agentrun_wrapper/py.typed +1 -0
  107. agentrun_wrapper/runtime/__init__.py +13 -0
  108. agentrun_wrapper/runtime/app.py +473 -0
  109. agentrun_wrapper/runtime/context.py +34 -0
  110. agentrun_wrapper/runtime/models.py +25 -0
  111. agentrun_wrapper/services/__init__.py +1 -0
  112. agentrun_wrapper/services/identity.py +192 -0
  113. agentrun_wrapper/tools/__init__.py +6 -0
  114. agentrun_wrapper/tools/browser_client.py +325 -0
  115. agentrun_wrapper/tools/code_interpreter_client.py +186 -0
@@ -0,0 +1,203 @@
1
+ """Bedrock AgentCore utility functions for parsing and importing Bedrock AgentCore applications."""
2
+
3
+ import logging
4
+ import sys
5
+ from dataclasses import dataclass
6
+ from pathlib import Path
7
+ from typing import Optional, Tuple
8
+
9
+ log = logging.getLogger(__name__)
10
+
11
+
12
+ def parse_entrypoint(entrypoint: str) -> Tuple[Path, str]:
13
+ """Parse entrypoint into file path and name.
14
+
15
+ Args:
16
+ entrypoint: Entrypoint specification (e.g., "app.py")
17
+
18
+ Returns:
19
+ Tuple of (file_path, bedrock_agentcore_name)
20
+
21
+ Raises:
22
+ ValueError: If entrypoint cannot be parsed or file doesn't exist
23
+ """
24
+ file_path = Path(entrypoint).resolve()
25
+ if not file_path.exists():
26
+ log.error("Entrypoint file not found: %s", file_path)
27
+ raise ValueError(f"File not found: {file_path}")
28
+
29
+ file_name = file_path.stem
30
+
31
+ log.info("Entrypoint parsed: file=%s, bedrock_agentcore_name=%s", file_path, file_name)
32
+ return file_path, file_name
33
+
34
+
35
+ def handle_requirements_file(
36
+ requirements_file: Optional[str] = None, build_dir: Optional[Path] = None
37
+ ) -> Optional[str]:
38
+ """Handle requirements file selection and validation.
39
+
40
+ Args:
41
+ requirements_file: Optional path to requirements file
42
+ build_dir: Build directory, defaults to current directory
43
+
44
+ Returns:
45
+ Validated requirements file path or None
46
+
47
+ Raises:
48
+ ValueError: If specified requirements file is invalid
49
+ """
50
+ if build_dir is None:
51
+ build_dir = Path.cwd()
52
+
53
+ if requirements_file:
54
+ log.info("Validating requirements file: %s", requirements_file)
55
+ # Validate provided requirements file
56
+ try:
57
+ deps = validate_requirements_file(build_dir, requirements_file)
58
+ log.info("Requirements file validated: %s", requirements_file)
59
+ return requirements_file
60
+ except (FileNotFoundError, ValueError) as e:
61
+ log.error("Requirements file validation failed: %s", e)
62
+ raise ValueError(str(e)) from e
63
+
64
+ # Auto-detect dependencies (no validation needed, just detection)
65
+ log.info("Auto-detecting dependencies in: %s", build_dir)
66
+ deps = detect_dependencies(build_dir)
67
+
68
+ if deps.found:
69
+ log.info("Dependencies detected: %s", deps.file)
70
+ return None # Let operations handle the detected file
71
+ else:
72
+ log.info("No dependency files found")
73
+ return None # No file found or specified
74
+
75
+
76
+ @dataclass
77
+ class DependencyInfo:
78
+ """Information about project dependencies."""
79
+
80
+ file: Optional[str] # Relative path for Docker context
81
+ type: str # "requirements", "pyproject", or "notfound"
82
+ resolved_path: Optional[str] = None # Absolute path for validation
83
+ install_path: Optional[str] = None # Path for pip install command
84
+
85
+ @property
86
+ def found(self) -> bool:
87
+ """Whether a dependency file was found."""
88
+ return self.file is not None
89
+
90
+ @property
91
+ def is_pyproject(self) -> bool:
92
+ """Whether this is a pyproject.toml file."""
93
+ return self.type == "pyproject"
94
+
95
+ @property
96
+ def is_requirements(self) -> bool:
97
+ """Whether this is a requirements file."""
98
+ return self.type == "requirements"
99
+
100
+ @property
101
+ def is_root_package(self) -> bool:
102
+ """Whether this dependency points to the root package."""
103
+ return self.is_pyproject and self.install_path == "."
104
+
105
+
106
+ def detect_dependencies(package_dir: Path, explicit_file: Optional[str] = None) -> DependencyInfo:
107
+ """Detect dependency file, with optional explicit override."""
108
+ if explicit_file:
109
+ return _handle_explicit_file(package_dir, explicit_file)
110
+
111
+ # Check for requirements.txt first (prioritized for notebook workflows)
112
+ requirements_path = package_dir / "requirements.txt"
113
+ if requirements_path.exists():
114
+ return DependencyInfo(
115
+ file="requirements.txt", type="requirements", resolved_path=str(requirements_path.resolve())
116
+ )
117
+
118
+ # Check for pyproject.toml
119
+ pyproject_path = package_dir / "pyproject.toml"
120
+ if pyproject_path.exists():
121
+ return DependencyInfo(
122
+ file="pyproject.toml",
123
+ type="pyproject",
124
+ resolved_path=str(pyproject_path.resolve()),
125
+ install_path=".", # Install from current directory
126
+ )
127
+
128
+ return DependencyInfo(file=None, type="notfound")
129
+
130
+
131
+ def _handle_explicit_file(package_dir: Path, explicit_file: str) -> DependencyInfo:
132
+ """Handle explicitly provided dependency file."""
133
+ # Handle both absolute and relative paths
134
+ explicit_path = Path(explicit_file)
135
+ if not explicit_path.is_absolute():
136
+ explicit_path = package_dir / explicit_path
137
+
138
+ # Resolve the path to handle .. and . components
139
+ explicit_path = explicit_path.resolve()
140
+
141
+ if not explicit_path.exists():
142
+ raise FileNotFoundError(f"Specified requirements file not found: {explicit_path}")
143
+
144
+ # Ensure file is within project directory for Docker context
145
+ try:
146
+ relative_path = explicit_path.relative_to(package_dir.resolve())
147
+ except ValueError:
148
+ raise ValueError(
149
+ f"Requirements file must be within project directory. File: {explicit_path}, Project: {package_dir}"
150
+ ) from None
151
+
152
+ # Determine type and install path
153
+ file_type = "requirements" if explicit_file.endswith((".txt", ".in")) else "pyproject"
154
+ install_path = None
155
+
156
+ if file_type == "pyproject":
157
+ if len(relative_path.parts) > 1:
158
+ # pyproject.toml in subdirectory - install from that directory
159
+ install_path = Path(relative_path).parent
160
+ else:
161
+ # pyproject.toml in root - install from current directory
162
+ install_path = Path(".")
163
+
164
+ # Get POSIX strings for file and install path
165
+ file_path = relative_path.as_posix()
166
+ install_path = install_path and install_path.as_posix()
167
+
168
+ # Maintain local format for explicit path
169
+ explicit_path = str(explicit_path)
170
+
171
+ return DependencyInfo(file=file_path, type=file_type, resolved_path=explicit_path, install_path=install_path)
172
+
173
+
174
+ def validate_requirements_file(build_dir: Path, requirements_file: str) -> DependencyInfo:
175
+ """Validate the provided requirements file path and return DependencyInfo."""
176
+ # Check if the provided path exists and is a file
177
+ file_path = Path(requirements_file)
178
+ if not file_path.is_absolute():
179
+ file_path = build_dir / file_path
180
+
181
+ if not file_path.exists():
182
+ raise FileNotFoundError(f"File not found: {file_path}")
183
+
184
+ if file_path.is_dir():
185
+ raise ValueError(
186
+ f"Path is a directory, not a file: {file_path}. "
187
+ f"Please specify a requirements file (requirements.txt, pyproject.toml, etc.)"
188
+ )
189
+
190
+ # Validate that it's a recognized dependency file type (flexible validation)
191
+ if not (file_path.suffix in [".txt", ".in"] or file_path.name == "pyproject.toml"):
192
+ raise ValueError(
193
+ f"'{file_path.name}' is not a supported dependency file. "
194
+ f"Supported formats: *.txt, *.in (pip requirements), or pyproject.toml"
195
+ )
196
+
197
+ # Use the existing detect_dependencies function to process the file
198
+ return detect_dependencies(build_dir, explicit_file=requirements_file)
199
+
200
+
201
+ def get_python_version() -> str:
202
+ """Get Python version for Docker image."""
203
+ return f"{sys.version_info.major}.{sys.version_info.minor}"
@@ -0,0 +1,56 @@
1
+ from pydantic import BaseModel, Field
2
+ from typing import Dict, List, Optional
3
+
4
+ class AgentRunAgentSchema(BaseModel):
5
+ name: str = Field(..., description="Name of the AgentRun application")
6
+ entrypoint: str = Field(..., description="Entrypoint file path")
7
+ platform: str = Field(default="linux/amd64", description="Target platform")
8
+ container_runtime: str = Field(default="docker", description="Container runtime to use")
9
+
10
+ def validate(self, for_local: bool = False) -> List[str]:
11
+ """Validate configuration and return list of errors.
12
+
13
+ Args:
14
+ for_local: Whether validating for local deployment
15
+
16
+ Returns:
17
+ List of validation error messages
18
+ """
19
+ errors = []
20
+
21
+ # Required fields for all deployments
22
+ if not self.name:
23
+ errors.append("Missing 'name' field")
24
+ if not self.entrypoint:
25
+ errors.append("Missing 'entrypoint' field")
26
+
27
+ return errors
28
+
29
+ class AgentRunConfigSchema(BaseModel):
30
+ default_agent: Optional[str] = Field(default=None, description="Default agent name for operations")
31
+ agents: Dict[str, AgentRunAgentSchema] = Field(
32
+ default_factory=dict, description="Named agent configurations"
33
+ )
34
+
35
+ def get_agent_config(self, agent_name: Optional[str] = None) -> AgentRunAgentSchema:
36
+ """Get agent config by name or default.
37
+
38
+ Args:
39
+ agent_name: Agent name from --agent parameter, or None for default
40
+ """
41
+ target_name = agent_name or self.default_agent
42
+ if not target_name:
43
+ if len(self.agents) == 1:
44
+ agent = list(self.agents.values())[0]
45
+ self.default_agent = agent.name
46
+ return agent
47
+ raise ValueError("No agent specified and no default set")
48
+
49
+ if target_name not in self.agents:
50
+ available = list(self.agents.keys())
51
+ if available:
52
+ raise ValueError(f"Agent '{target_name}' not found. Available agents: {available}")
53
+ else:
54
+ raise ValueError("No agents configured")
55
+
56
+ return self.agents[target_name]
@@ -0,0 +1,7 @@
1
+ """A framework for building, deploying, and managing AI agents."""
2
+
3
+ from . import agent, models, telemetry, types
4
+ from .agent.agent import Agent
5
+ from .tools.decorator import tool
6
+
7
+ __all__ = ["Agent", "agent", "models", "tool", "types", "telemetry"]
@@ -0,0 +1,25 @@
1
+ """This package provides the core Agent interface and supporting components for building AI agents with the SDK.
2
+
3
+ It includes:
4
+
5
+ - Agent: The main interface for interacting with AI models and tools
6
+ - ConversationManager: Classes for managing conversation history and context windows
7
+ """
8
+
9
+ from .agent import Agent
10
+ from .agent_result import AgentResult
11
+ from .conversation_manager import (
12
+ ConversationManager,
13
+ NullConversationManager,
14
+ SlidingWindowConversationManager,
15
+ SummarizingConversationManager,
16
+ )
17
+
18
+ __all__ = [
19
+ "Agent",
20
+ "AgentResult",
21
+ "ConversationManager",
22
+ "NullConversationManager",
23
+ "SlidingWindowConversationManager",
24
+ "SummarizingConversationManager",
25
+ ]