agnt5 0.2.8a2__cp310-abi3-macosx_11_0_arm64.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 agnt5 might be problematic. Click here for more details.

agnt5/types.py ADDED
@@ -0,0 +1,110 @@
1
+ """Type definitions and protocols for AGNT5 SDK."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from dataclasses import dataclass
6
+ from enum import Enum
7
+ from typing import Any, Awaitable, Callable, Dict, List, Optional, Protocol, TypeVar, Union
8
+
9
+ # Type aliases
10
+ JSON = Union[Dict[str, Any], List[Any], str, int, float, bool, None]
11
+ HandlerFunc = Callable[..., Awaitable[Any]]
12
+
13
+ T = TypeVar("T")
14
+
15
+
16
+ class BackoffType(str, Enum):
17
+ """Backoff strategy for retry policies."""
18
+
19
+ CONSTANT = "constant"
20
+ LINEAR = "linear"
21
+ EXPONENTIAL = "exponential"
22
+
23
+
24
+ @dataclass
25
+ class RetryPolicy:
26
+ """Configuration for function retry behavior."""
27
+
28
+ max_attempts: int = 3
29
+ initial_interval_ms: int = 1000
30
+ max_interval_ms: int = 60000
31
+
32
+ def __post_init__(self) -> None:
33
+ if self.max_attempts < 1:
34
+ raise ValueError("max_attempts must be at least 1")
35
+ if self.initial_interval_ms < 0:
36
+ raise ValueError("initial_interval_ms must be non-negative")
37
+ if self.max_interval_ms < self.initial_interval_ms:
38
+ raise ValueError("max_interval_ms must be >= initial_interval_ms")
39
+
40
+
41
+ @dataclass
42
+ class BackoffPolicy:
43
+ """Configuration for retry backoff strategy."""
44
+
45
+ type: BackoffType = BackoffType.EXPONENTIAL
46
+ multiplier: float = 2.0
47
+
48
+ def __post_init__(self) -> None:
49
+ if self.multiplier <= 0:
50
+ raise ValueError("multiplier must be positive")
51
+
52
+
53
+ @dataclass
54
+ class FunctionConfig:
55
+ """Configuration for a function handler."""
56
+
57
+ name: str
58
+ handler: HandlerFunc
59
+ retries: Optional[RetryPolicy] = None
60
+ backoff: Optional[BackoffPolicy] = None
61
+ input_schema: Optional[Dict[str, Any]] = None
62
+ output_schema: Optional[Dict[str, Any]] = None
63
+ metadata: Optional[Dict[str, str]] = None
64
+
65
+
66
+ @dataclass
67
+ class WorkflowConfig:
68
+ """Configuration for a workflow handler."""
69
+
70
+ name: str
71
+ handler: HandlerFunc
72
+ input_schema: Optional[Dict[str, Any]] = None
73
+ output_schema: Optional[Dict[str, Any]] = None
74
+ metadata: Optional[Dict[str, str]] = None
75
+
76
+
77
+ class ContextProtocol(Protocol):
78
+ """Protocol defining the Context interface."""
79
+
80
+ @property
81
+ def run_id(self) -> str:
82
+ """Workflow/run identifier."""
83
+ ...
84
+
85
+ @property
86
+ def step_id(self) -> Optional[str]:
87
+ """Current step identifier."""
88
+ ...
89
+
90
+ @property
91
+ def attempt(self) -> int:
92
+ """Retry attempt number."""
93
+ ...
94
+
95
+ @property
96
+ def component_type(self) -> str:
97
+ """Component type: 'function', 'entity', 'workflow'."""
98
+ ...
99
+
100
+ async def get(self, key: str, default: Any = None) -> Any:
101
+ """Get value from state."""
102
+ ...
103
+
104
+ def set(self, key: str, value: Any) -> None:
105
+ """Set value in state."""
106
+ ...
107
+
108
+ def delete(self, key: str) -> None:
109
+ """Delete key from state."""
110
+ ...
agnt5/version.py ADDED
@@ -0,0 +1,19 @@
1
+ """Version information for agnt5 SDK."""
2
+
3
+
4
+ def _get_version() -> str:
5
+ """Get package version from installed metadata.
6
+
7
+ This uses importlib.metadata (Python 3.8+) to read the version from
8
+ the installed package metadata, maintaining pyproject.toml as the
9
+ single source of truth.
10
+
11
+ Returns:
12
+ Package version string, or "0.0.0+dev" for development installs.
13
+ """
14
+ try:
15
+ from importlib.metadata import version
16
+ return version("agnt5")
17
+ except Exception:
18
+ # Development/editable install fallback
19
+ return "0.0.0+dev"