microsoft-agents-a365-runtime 0.1.0.dev30__py3-none-any.whl → 0.2.1.dev0__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.
- microsoft_agents_a365/runtime/__init__.py +6 -1
- microsoft_agents_a365/runtime/environment_utils.py +7 -2
- microsoft_agents_a365/runtime/operation_error.py +58 -0
- microsoft_agents_a365/runtime/operation_result.py +98 -0
- microsoft_agents_a365/runtime/power_platform_api_discovery.py +2 -1
- microsoft_agents_a365/runtime/utility.py +30 -1
- {microsoft_agents_a365_runtime-0.1.0.dev30.dist-info → microsoft_agents_a365_runtime-0.2.1.dev0.dist-info}/METADATA +3 -3
- microsoft_agents_a365_runtime-0.2.1.dev0.dist-info/RECORD +11 -0
- {microsoft_agents_a365_runtime-0.1.0.dev30.dist-info → microsoft_agents_a365_runtime-0.2.1.dev0.dist-info}/WHEEL +1 -1
- {microsoft_agents_a365_runtime-0.1.0.dev30.dist-info → microsoft_agents_a365_runtime-0.2.1.dev0.dist-info}/top_level.txt +1 -0
- microsoft_agents_a365_runtime-0.1.0.dev30.dist-info/RECORD +0 -9
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
# Copyright (c) Microsoft
|
|
1
|
+
# Copyright (c) Microsoft Corporation.
|
|
2
|
+
# Licensed under the MIT License.
|
|
2
3
|
|
|
3
4
|
from .environment_utils import get_observability_authentication_scope
|
|
5
|
+
from .operation_error import OperationError
|
|
6
|
+
from .operation_result import OperationResult
|
|
4
7
|
from .power_platform_api_discovery import ClusterCategory, PowerPlatformApiDiscovery
|
|
5
8
|
from .utility import Utility
|
|
6
9
|
|
|
@@ -9,6 +12,8 @@ __all__ = [
|
|
|
9
12
|
"PowerPlatformApiDiscovery",
|
|
10
13
|
"ClusterCategory",
|
|
11
14
|
"Utility",
|
|
15
|
+
"OperationError",
|
|
16
|
+
"OperationResult",
|
|
12
17
|
]
|
|
13
18
|
|
|
14
19
|
__path__ = __import__("pkgutil").extend_path(__path__, __name__)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
# Copyright (c) Microsoft
|
|
1
|
+
# Copyright (c) Microsoft Corporation.
|
|
2
|
+
# Licensed under the MIT License.
|
|
2
3
|
|
|
3
4
|
"""
|
|
4
5
|
Utility logic for environment-related operations.
|
|
@@ -21,10 +22,14 @@ def get_observability_authentication_scope() -> list[str]:
|
|
|
21
22
|
"""
|
|
22
23
|
Returns the scope for authenticating to the observability service based on the current environment.
|
|
23
24
|
|
|
25
|
+
The scope can be overridden via the A365_OBSERVABILITY_SCOPE_OVERRIDE environment variable
|
|
26
|
+
to enable testing against pre-production environments.
|
|
27
|
+
|
|
24
28
|
Returns:
|
|
25
29
|
list[str]: The authentication scope for the current environment.
|
|
26
30
|
"""
|
|
27
|
-
|
|
31
|
+
override_scope = os.getenv("A365_OBSERVABILITY_SCOPE_OVERRIDE", "").strip()
|
|
32
|
+
return [override_scope] if override_scope else [PROD_OBSERVABILITY_SCOPE]
|
|
28
33
|
|
|
29
34
|
|
|
30
35
|
def is_development_environment() -> bool:
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Copyright (c) Microsoft Corporation.
|
|
2
|
+
# Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
Encapsulates an error from an operation.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class OperationError:
|
|
10
|
+
"""
|
|
11
|
+
Represents an error that occurred during an operation.
|
|
12
|
+
|
|
13
|
+
This class wraps an exception and provides a consistent interface for
|
|
14
|
+
accessing error information.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
def __init__(self, exception: Exception):
|
|
18
|
+
"""
|
|
19
|
+
Initialize a new instance of the OperationError class.
|
|
20
|
+
|
|
21
|
+
Args:
|
|
22
|
+
exception: The exception associated with the error.
|
|
23
|
+
|
|
24
|
+
Raises:
|
|
25
|
+
ValueError: If exception is None.
|
|
26
|
+
"""
|
|
27
|
+
if exception is None:
|
|
28
|
+
raise ValueError("exception cannot be None")
|
|
29
|
+
self._exception = exception
|
|
30
|
+
|
|
31
|
+
@property
|
|
32
|
+
def exception(self) -> Exception:
|
|
33
|
+
"""
|
|
34
|
+
Get the exception associated with the error.
|
|
35
|
+
|
|
36
|
+
Returns:
|
|
37
|
+
Exception: The exception associated with the error.
|
|
38
|
+
"""
|
|
39
|
+
return self._exception
|
|
40
|
+
|
|
41
|
+
@property
|
|
42
|
+
def message(self) -> str:
|
|
43
|
+
"""
|
|
44
|
+
Get the message associated with the error.
|
|
45
|
+
|
|
46
|
+
Returns:
|
|
47
|
+
str: The error message from the exception.
|
|
48
|
+
"""
|
|
49
|
+
return str(self._exception)
|
|
50
|
+
|
|
51
|
+
def __str__(self) -> str:
|
|
52
|
+
"""
|
|
53
|
+
Return a string representation of the error.
|
|
54
|
+
|
|
55
|
+
Returns:
|
|
56
|
+
str: A string representation of the error.
|
|
57
|
+
"""
|
|
58
|
+
return str(self._exception)
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# Copyright (c) Microsoft Corporation.
|
|
2
|
+
# Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
Represents the result of an operation.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from typing import List, Optional
|
|
9
|
+
|
|
10
|
+
from .operation_error import OperationError
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class OperationResult:
|
|
14
|
+
"""
|
|
15
|
+
Represents the result of an operation.
|
|
16
|
+
|
|
17
|
+
This class encapsulates the success or failure state of an operation along
|
|
18
|
+
with any associated errors.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
_success_instance: Optional["OperationResult"] = None
|
|
22
|
+
|
|
23
|
+
def __init__(self, succeeded: bool, errors: Optional[List[OperationError]] = None):
|
|
24
|
+
"""
|
|
25
|
+
Initialize a new instance of the OperationResult class.
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
succeeded: Flag indicating whether the operation succeeded.
|
|
29
|
+
errors: Optional list of errors that occurred during the operation.
|
|
30
|
+
"""
|
|
31
|
+
self._succeeded = succeeded
|
|
32
|
+
self._errors = errors if errors is not None else []
|
|
33
|
+
|
|
34
|
+
@property
|
|
35
|
+
def succeeded(self) -> bool:
|
|
36
|
+
"""
|
|
37
|
+
Get a flag indicating whether the operation succeeded.
|
|
38
|
+
|
|
39
|
+
Returns:
|
|
40
|
+
bool: True if the operation succeeded, otherwise False.
|
|
41
|
+
"""
|
|
42
|
+
return self._succeeded
|
|
43
|
+
|
|
44
|
+
@property
|
|
45
|
+
def errors(self) -> List[OperationError]:
|
|
46
|
+
"""
|
|
47
|
+
Get the list of errors that occurred during the operation.
|
|
48
|
+
|
|
49
|
+
Note:
|
|
50
|
+
This property returns a defensive copy of the internal error list
|
|
51
|
+
to prevent external modifications, which is especially important for
|
|
52
|
+
protecting the singleton instance returned by success().
|
|
53
|
+
|
|
54
|
+
Returns:
|
|
55
|
+
List[OperationError]: A copy of the list of operation errors.
|
|
56
|
+
"""
|
|
57
|
+
return list(self._errors)
|
|
58
|
+
|
|
59
|
+
@staticmethod
|
|
60
|
+
def success() -> "OperationResult":
|
|
61
|
+
"""
|
|
62
|
+
Return an OperationResult indicating a successful operation.
|
|
63
|
+
|
|
64
|
+
Returns:
|
|
65
|
+
OperationResult: An OperationResult indicating a successful operation.
|
|
66
|
+
"""
|
|
67
|
+
return OperationResult._success_instance
|
|
68
|
+
|
|
69
|
+
@staticmethod
|
|
70
|
+
def failed(*errors: OperationError) -> "OperationResult":
|
|
71
|
+
"""
|
|
72
|
+
Create an OperationResult indicating a failed operation.
|
|
73
|
+
|
|
74
|
+
Args:
|
|
75
|
+
*errors: Variable number of OperationError instances.
|
|
76
|
+
|
|
77
|
+
Returns:
|
|
78
|
+
OperationResult: An OperationResult indicating a failed operation.
|
|
79
|
+
"""
|
|
80
|
+
error_list = list(errors) if errors else []
|
|
81
|
+
return OperationResult(succeeded=False, errors=error_list)
|
|
82
|
+
|
|
83
|
+
def __str__(self) -> str:
|
|
84
|
+
"""
|
|
85
|
+
Convert the value of the current OperationResult object to its string representation.
|
|
86
|
+
|
|
87
|
+
Returns:
|
|
88
|
+
str: A string representation of the current OperationResult object.
|
|
89
|
+
"""
|
|
90
|
+
if self._succeeded:
|
|
91
|
+
return "Succeeded"
|
|
92
|
+
else:
|
|
93
|
+
error_messages = ", ".join(str(error.message) for error in self._errors)
|
|
94
|
+
return f"Failed: {error_messages}" if error_messages else "Failed"
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
# Module-level eager initialization (thread-safe by Python's import lock)
|
|
98
|
+
OperationResult._success_instance = OperationResult(succeeded=True)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
# Copyright (c) Microsoft
|
|
1
|
+
# Copyright (c) Microsoft Corporation.
|
|
2
|
+
# Licensed under the MIT License.
|
|
2
3
|
|
|
3
4
|
"""
|
|
4
5
|
Utility functions for Microsoft Agent 365 runtime operations.
|
|
@@ -9,7 +10,9 @@ and other common runtime operations.
|
|
|
9
10
|
|
|
10
11
|
from __future__ import annotations
|
|
11
12
|
|
|
13
|
+
import platform
|
|
12
14
|
import uuid
|
|
15
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
13
16
|
from typing import Any, Optional
|
|
14
17
|
|
|
15
18
|
import jwt
|
|
@@ -23,6 +26,8 @@ class Utility:
|
|
|
23
26
|
and other utility functions used across the Agent 365 runtime.
|
|
24
27
|
"""
|
|
25
28
|
|
|
29
|
+
_cached_version = None
|
|
30
|
+
|
|
26
31
|
@staticmethod
|
|
27
32
|
def get_app_id_from_token(token: Optional[str]) -> str:
|
|
28
33
|
"""
|
|
@@ -80,3 +85,27 @@ class Utility:
|
|
|
80
85
|
|
|
81
86
|
# Fallback to extracting App ID from the auth token
|
|
82
87
|
return Utility.get_app_id_from_token(auth_token)
|
|
88
|
+
|
|
89
|
+
@staticmethod
|
|
90
|
+
def get_user_agent_header(orchestrator: Optional[str] = None) -> str:
|
|
91
|
+
"""
|
|
92
|
+
Generates a User-Agent header string for SDK requests.
|
|
93
|
+
|
|
94
|
+
Args:
|
|
95
|
+
orchestrator: Optional orchestrator name to include in the User-Agent header.
|
|
96
|
+
Defaults to empty string if not provided.
|
|
97
|
+
|
|
98
|
+
Returns:
|
|
99
|
+
str: A formatted User-Agent header string containing SDK version, OS type,
|
|
100
|
+
Python version, and optional orchestrator information.
|
|
101
|
+
"""
|
|
102
|
+
if Utility._cached_version is None:
|
|
103
|
+
try:
|
|
104
|
+
Utility._cached_version = version("microsoft-agents-a365-runtime")
|
|
105
|
+
except PackageNotFoundError:
|
|
106
|
+
Utility._cached_version = "unknown"
|
|
107
|
+
|
|
108
|
+
orchestrator_part = f"; {orchestrator}" if orchestrator else ""
|
|
109
|
+
os_type = platform.system()
|
|
110
|
+
python_version = platform.python_version()
|
|
111
|
+
return f"Agent365SDK/{Utility._cached_version} ({os_type}; Python {python_version}{orchestrator_part})"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: microsoft-agents-a365-runtime
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.2.1.dev0
|
|
4
4
|
Summary: Telemetry, tracing, and monitoring components for AI agents
|
|
5
5
|
Author-email: Microsoft <support@microsoft.com>
|
|
6
6
|
License: MIT
|
|
@@ -53,7 +53,7 @@ For usage examples and detailed documentation, see the [Microsoft Agent 365 Deve
|
|
|
53
53
|
For issues, questions, or feedback:
|
|
54
54
|
|
|
55
55
|
- File issues in the [GitHub Issues](https://github.com/microsoft/Agent365-python/issues) section
|
|
56
|
-
- See the [main documentation](
|
|
56
|
+
- See the [main documentation](../../README.md) for more information
|
|
57
57
|
|
|
58
58
|
## Trademarks
|
|
59
59
|
|
|
@@ -63,4 +63,4 @@ For issues, questions, or feedback:
|
|
|
63
63
|
|
|
64
64
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
65
65
|
|
|
66
|
-
Licensed under the MIT License - see the [LICENSE](
|
|
66
|
+
Licensed under the MIT License - see the [LICENSE](../../LICENSE.md) file for details.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
microsoft_agents_a365/runtime/__init__.py,sha256=_Q6AfhdNV-YhvkJKqTG-TlImI2B5bEbtTC_Mv82-ob4,591
|
|
2
|
+
microsoft_agents_a365/runtime/environment_utils.py,sha256=B5A3CfGJJeuVgIW3Si7oSPYLQNkzc54nNqw3QnLgaC0,1824
|
|
3
|
+
microsoft_agents_a365/runtime/operation_error.py,sha256=OqG6IIQR5lfvZrtyqpTa9Gc4B_eo2qxfoJ1Cj96WiUs,1418
|
|
4
|
+
microsoft_agents_a365/runtime/operation_result.py,sha256=HIJLAzoAfPTINzjnThzXHDAizRaZ4xXX4D7TuOPjmdk,3066
|
|
5
|
+
microsoft_agents_a365/runtime/power_platform_api_discovery.py,sha256=B6Ar2-P9pHrv-Pe_vFl0j9gRqAWyipbTfxkLEc9aA0k,3460
|
|
6
|
+
microsoft_agents_a365/runtime/utility.py,sha256=5YEN1EGmHvRBb9gc9GeD58xAxUzGiZNON_zWkXh9Oms,4282
|
|
7
|
+
microsoft_agents_a365/runtime/version_utils.py,sha256=nkgYIaPXD9OyT_lJ8K3sqpEze_VMJzekMmjsiYNghB8,965
|
|
8
|
+
microsoft_agents_a365_runtime-0.2.1.dev0.dist-info/METADATA,sha256=WHoLAEw8Vy5lhwW29IJ8Il0rmGXOO7gJgyA0dXgExMw,3205
|
|
9
|
+
microsoft_agents_a365_runtime-0.2.1.dev0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
10
|
+
microsoft_agents_a365_runtime-0.2.1.dev0.dist-info/top_level.txt,sha256=m90AvzRnjbL6fpi20mzOj6HUVkR2LWuf2JuXm4LL9LU,27
|
|
11
|
+
microsoft_agents_a365_runtime-0.2.1.dev0.dist-info/RECORD,,
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
microsoft_agents_a365/runtime/__init__.py,sha256=g5641veSgmz8JErlGhlc-noOXcKYZpsq_yBWMg4bcyM,431
|
|
2
|
-
microsoft_agents_a365/runtime/environment_utils.py,sha256=T5b1DAUV1VxwcKxbjeqxfDkuhFCBZ-8kez-_yGbmv58,1524
|
|
3
|
-
microsoft_agents_a365/runtime/power_platform_api_discovery.py,sha256=CS-Vhd6jsMq7lSwtdZIDh-Oybzn_osOTtvml_uYZ8eQ,3435
|
|
4
|
-
microsoft_agents_a365/runtime/utility.py,sha256=FXrdaDHL1JypZkh8JKL0zh355xAllR5xd9bUDGgDCTI,3114
|
|
5
|
-
microsoft_agents_a365/runtime/version_utils.py,sha256=nkgYIaPXD9OyT_lJ8K3sqpEze_VMJzekMmjsiYNghB8,965
|
|
6
|
-
microsoft_agents_a365_runtime-0.1.0.dev30.dist-info/METADATA,sha256=y5N_0rZqUUh2BDTcPU9OZo2Vz3xfXIuzh82Xe3aL8us,3212
|
|
7
|
-
microsoft_agents_a365_runtime-0.1.0.dev30.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
8
|
-
microsoft_agents_a365_runtime-0.1.0.dev30.dist-info/top_level.txt,sha256=G3c2_4sy5_EM_BWO67SbK2tKj4G8XFn-QXRbh8g9Lgk,22
|
|
9
|
-
microsoft_agents_a365_runtime-0.1.0.dev30.dist-info/RECORD,,
|